#define NOUVEAU_MSG(fmt, args...) \
fprintf(stderr, "nouveau: "fmt, ##args);
-#define NV50_NEW_BLEND (1 << 0)
-#define NV50_NEW_ZSA (1 << 1)
+#define NV50_NEW_BLEND (1 << 0)
+#define NV50_NEW_ZSA (1 << 1)
+#define NV50_NEW_BLEND_COLOUR (1 << 2)
+#define NV50_NEW_STIPPLE (1 << 3)
+#define NV50_NEW_SCISSOR (1 << 4)
+#define NV50_NEW_VIEWPORT (1 << 5)
struct nv50_blend_stateobj {
struct pipe_blend_state pipe;
unsigned dirty;
struct nv50_blend_stateobj *blend;
struct nv50_zsa_stateobj *zsa;
+ struct pipe_blend_color blend_colour;
+ struct pipe_poly_stipple stipple;
+ struct pipe_scissor_state scissor;
+ struct pipe_viewport_state viewport;
};
static INLINE struct nv50_context *
nv50_set_blend_color(struct pipe_context *pipe,
const struct pipe_blend_color *bcol)
{
+ struct nv50_context *nv50 = nv50_context(pipe);
+
+ nv50->blend_colour = *bcol;
+ nv50->dirty |= NV50_NEW_BLEND_COLOUR;
}
static void
nv50_set_polygon_stipple(struct pipe_context *pipe,
const struct pipe_poly_stipple *stipple)
{
+ struct nv50_context *nv50 = nv50_context(pipe);
+
+ nv50->stipple = *stipple;
+ nv50->dirty |= NV50_NEW_STIPPLE;
}
static void
nv50_set_scissor_state(struct pipe_context *pipe,
const struct pipe_scissor_state *s)
{
+ struct nv50_context *nv50 = nv50_context(pipe);
+
+ nv50->scissor = *s;
+ nv50->dirty |= NV50_NEW_SCISSOR;
}
static void
nv50_set_viewport_state(struct pipe_context *pipe,
const struct pipe_viewport_state *vpt)
{
+ struct nv50_context *nv50 = nv50_context(pipe);
+
+ nv50->viewport = *vpt;
+ nv50->dirty |= NV50_NEW_VIEWPORT;
}
static void
nv50_state_validate(struct nv50_context *nv50)
{
struct nouveau_winsys *nvws = nv50->screen->nvws;
+ struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nouveau_stateobj *so;
+ unsigned i;
if (nv50->dirty & NV50_NEW_BLEND)
so_emit(nvws, nv50->blend->so);
+
if (nv50->dirty & NV50_NEW_ZSA)
so_emit(nvws, nv50->zsa->so);
+ if (nv50->dirty & NV50_NEW_BLEND_COLOUR) {
+ so = so_new(5, 0);
+ so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 8);
+ so_data (so, fui(nv50->blend_colour.color[3]));
+ so_data (so, fui(nv50->blend_colour.color[0]));
+ so_data (so, fui(nv50->blend_colour.color[1]));
+ so_data (so, fui(nv50->blend_colour.color[2]));
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ }
+
+ if (nv50->dirty & NV50_NEW_STIPPLE) {
+ so = so_new(33, 0);
+ so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32);
+ for (i = 0; i < 32; i++)
+ so_data(so, nv50->stipple.stipple[i]);
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ }
+
+ if (nv50->dirty & NV50_NEW_SCISSOR) {
+ so = so_new(3, 0);
+ so_method(so, tesla, NV50TCL_SCISSOR_HORIZ, 2);
+ so_data (so, (nv50->scissor.maxx << 16) |
+ nv50->scissor.minx);
+ so_data (so, (nv50->scissor.maxy << 16) |
+ nv50->scissor.miny);
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ }
+
+ if (nv50->dirty & NV50_NEW_VIEWPORT) {
+ so = so_new(8, 0);
+ so_method(so, tesla, NV50TCL_VIEWPORT_UNK0(0), 3);
+ so_data (so, fui(nv50->viewport.translate[0]));
+ so_data (so, fui(nv50->viewport.translate[1]));
+ so_data (so, fui(nv50->viewport.translate[2]));
+ so_method(so, tesla, NV50TCL_VIEWPORT_UNK1(0), 3);
+ so_data (so, fui(nv50->viewport.scale[0]));
+ so_data (so, fui(nv50->viewport.scale[1]));
+ so_data (so, fui(nv50->viewport.scale[2]));
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ }
+
nv50->dirty = 0;
return TRUE;
}