From bedb6faec0882cf01ae8773f2ea685135471a87b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 20:55:33 +0100 Subject: nv30: adapt to stencil ref changes not sure if this has any hope of working --- src/gallium/drivers/nv30/nv30_context.h | 6 +++++- src/gallium/drivers/nv30/nv30_state.c | 21 ++++++++++++++++----- src/gallium/drivers/nv30/nv30_state_emit.c | 1 + src/gallium/drivers/nv30/nv30_state_zsa.c | 24 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src/gallium/drivers/nv30') diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index b3b26f7f94..ca3d6aca7f 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -61,7 +61,8 @@ enum nv30_state_index { NV30_STATE_VTXBUF = 31, NV30_STATE_VTXFMT = 32, NV30_STATE_VTXATTR = 33, - NV30_STATE_MAX = 34 + NV30_STATE_SR = 34, + NV30_STATE_MAX = 35 }; #include "nv30_screen.h" @@ -79,6 +80,7 @@ enum nv30_state_index { #define NV30_NEW_FRAGPROG (1 << 10) #define NV30_NEW_ARRAYS (1 << 11) #define NV30_NEW_UCP (1 << 12) +#define NV30_NEW_SR (1 << 13) struct nv30_rasterizer_state { struct pipe_rasterizer_state pipe; @@ -129,6 +131,7 @@ struct nv30_context { struct nv30_zsa_state *zsa; struct nv30_blend_state *blend; struct pipe_blend_color blend_colour; + struct pipe_stencil_ref stencil_ref; struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; struct pipe_buffer *idxbuf; @@ -194,6 +197,7 @@ extern struct nv30_state_entry nv30_state_viewport; extern struct nv30_state_entry nv30_state_framebuffer; extern struct nv30_state_entry nv30_state_fragtex; extern struct nv30_state_entry nv30_state_vbo; +extern struct nv30_state_entry nv30_state_sr; /* nv30_vbo.c */ extern void nv30_draw_arrays(struct pipe_context *, unsigned mode, diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index f775938ba7..8fc6856ee5 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(5, 21, 0); + struct nouveau_stateobj *so = so_new(6, 20, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3); @@ -449,11 +449,11 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, so_data (so, float_to_ubyte(cso->alpha.ref_value)); if (cso->stencil[0].enabled) { - so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 8); + so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 3); so_data (so, cso->stencil[0].enabled ? 1 : 0); so_data (so, cso->stencil[0].writemask); so_data (so, nvgl_comparison_op(cso->stencil[0].func)); - so_data (so, cso->stencil[0].ref_value); + so_method(so, rankine, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4); so_data (so, cso->stencil[0].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op)); @@ -464,11 +464,11 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, } if (cso->stencil[1].enabled) { - so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 8); + so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 3); so_data (so, cso->stencil[1].enabled ? 1 : 0); so_data (so, cso->stencil[1].writemask); so_data (so, nvgl_comparison_op(cso->stencil[1].func)); - so_data (so, cso->stencil[1].ref_value); + so_method(so, rankine, NV34TCL_STENCIL_BACK_FUNC_MASK, 4); so_data (so, cso->stencil[1].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[1].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op)); @@ -582,6 +582,16 @@ nv30_set_blend_color(struct pipe_context *pipe, nv30->dirty |= NV30_NEW_BCOL; } +static void +nv30_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *sr) +{ + struct nv30_context *nv30 = nv30_context(pipe); + + nv30->stencil_ref = *sr; + nv30->dirty |= NV30_NEW_SR; +} + static void nv30_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -704,6 +714,7 @@ nv30_init_state_functions(struct nv30_context *nv30) nv30->pipe.delete_fs_state = nv30_fp_state_delete; nv30->pipe.set_blend_color = nv30_set_blend_color; + nv30->pipe.set_stencil_ref = nv30_set_stencil_ref; nv30->pipe.set_clip_state = nv30_set_clip_state; nv30->pipe.set_constant_buffer = nv30_set_constant_buffer; nv30->pipe.set_framebuffer_state = nv30_set_framebuffer_state; diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c index d9650f63eb..deefe7fd8d 100644 --- a/src/gallium/drivers/nv30/nv30_state_emit.c +++ b/src/gallium/drivers/nv30/nv30_state_emit.c @@ -12,6 +12,7 @@ static struct nv30_state_entry *render_states[] = { &nv30_state_blend, &nv30_state_blend_colour, &nv30_state_zsa, + &nv30_state_sr, &nv30_state_viewport, &nv30_state_vbo, NULL diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c index 0940b7269b..6c0baa8be7 100644 --- a/src/gallium/drivers/nv30/nv30_state_zsa.c +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c @@ -15,3 +15,27 @@ struct nv30_state_entry nv30_state_zsa = { .hw = NV30_STATE_ZSA } }; + +static boolean +nv30_state_sr_validate(struct nv30_context *nv30) +{ + struct nouveau_stateobj *so = so_new(2, 2, 0); + struct pipe_stencil_ref *sr = &nv30->stencil_ref; + + so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, sr->ref_value[0]; + so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, sr->ref_value[1]; + + so_ref(so, &nv30->state.hw[NV30_STATE_SR]); + so_ref(NULL, &so); + return TRUE; +} + +struct nv30_state_entry nv30_state_sr = { + .validate = nv30_state_sr_validate, + .dirty = { + .pipe = NV30_NEW_SR, + .hw = NV30_STATE_SR + } +}; -- cgit v1.2.3 From 16d520f6d69edb112887d8db1e014a521a34f532 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 23:11:03 +0100 Subject: nouveau: fix compile errors... --- src/gallium/drivers/nv30/nv30_state_zsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/nv30') diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c index 6c0baa8be7..88cd74f180 100644 --- a/src/gallium/drivers/nv30/nv30_state_zsa.c +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c @@ -23,9 +23,9 @@ nv30_state_sr_validate(struct nv30_context *nv30) struct pipe_stencil_ref *sr = &nv30->stencil_ref; so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_FRONT_FUNC_REF, 1); - so_data (so, sr->ref_value[0]; + so_data (so, sr->ref_value[0]); so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_BACK_FUNC_REF, 1); - so_data (so, sr->ref_value[1]; + so_data (so, sr->ref_value[1]); so_ref(so, &nv30->state.hw[NV30_STATE_SR]); so_ref(NULL, &so); -- cgit v1.2.3 From ebe12d50064370e4ddec21a1e087b24295940319 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 12 Feb 2010 00:43:38 +0100 Subject: gallium: make max_anisotropy a unsigned bitfield member saves us a dword in sampler state, hw can't do non-integer aniso degree anyway. To allow aniso 1x (which seems of dubious value but some hardware (radeons) have such a mode, and even d3d allows specifiying it) redefine anisotropic filtering as disabled only if max_anistropy is 0. --- src/gallium/drivers/nv30/nv30_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/nv30') diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 8fc6856ee5..d911c80707 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -139,13 +139,13 @@ nv30_sampler_state_create(struct pipe_context *pipe, ps->en = 0; - if (cso->max_anisotropy >= 8.0) { + if (cso->max_anisotropy >= 8) { ps->en |= NV34TCL_TX_ENABLE_ANISO_8X; } else - if (cso->max_anisotropy >= 4.0) { + if (cso->max_anisotropy >= 4) { ps->en |= NV34TCL_TX_ENABLE_ANISO_4X; } else - if (cso->max_anisotropy >= 2.0) { + if (cso->max_anisotropy >= 2) { ps->en |= NV34TCL_TX_ENABLE_ANISO_2X; } -- cgit v1.2.3