From 7b4e478496cf45f527f72c39d72efe2e94fe2386 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 9 Apr 2011 18:25:29 +0200 Subject: [PATCH] nv50-nvc0: make use of COLOR_MASK,BLEND_ENABLE_COMMON --- src/gallium/drivers/nv50/nv50_3d.xml.h | 6 +++--- src/gallium/drivers/nv50/nv50_screen.c | 2 ++ src/gallium/drivers/nv50/nv50_state.c | 19 ++++++++++++------- src/gallium/drivers/nv50/nv50_stateobj.h | 2 +- src/gallium/drivers/nvc0/nvc0_3d.xml.h | 8 ++++++-- src/gallium/drivers/nvc0/nvc0_graph_macros.h | 13 ------------- src/gallium/drivers/nvc0/nvc0_screen.c | 7 ++++--- src/gallium/drivers/nvc0/nvc0_state.c | 4 +++- src/gallium/drivers/nvc0/nvc0_stateobj.h | 2 +- 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_3d.xml.h b/src/gallium/drivers/nv50/nv50_3d.xml.h index e3177e0b8bd..41a380ec2ec 100644 --- a/src/gallium/drivers/nv50/nv50_3d.xml.h +++ b/src/gallium/drivers/nv50/nv50_3d.xml.h @@ -558,7 +558,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV50_3D_UNK0F8C 0x00000f8c -#define NV50_3D_UNK0F90 0x00000f90 +#define NV50_3D_COLOR_MASK_COMMON 0x00000f90 #define NV50_3D_UNK0F94 0x00000f94 @@ -1007,7 +1007,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV50_3D_TEX_CACHE_CTL_UNK1__MASK 0x00000030 #define NV50_3D_TEX_CACHE_CTL_UNK1__SHIFT 4 -#define NV50_3D_UNK133C 0x0000133c +#define NV50_3D_BLEND_SEPARATE_ALPHA 0x0000133c #define NV50_3D_BLEND_EQUATION_RGB 0x00001340 #define NV50_3D_BLEND_EQUATION_RGB_FUNC_ADD 0x00008006 @@ -1033,7 +1033,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV50_3D_BLEND_FUNC_DST_ALPHA 0x00001358 -#define NV50_3D_UNK135C 0x0000135c +#define NV50_3D_BLEND_ENABLE_COMMON 0x0000135c #define NV50_3D_BLEND_ENABLE(i0) (0x00001360 + 0x4*(i0)) #define NV50_3D_BLEND_ENABLE__ESIZE 0x00000004 diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 439202dfe97..46622b4be76 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -422,6 +422,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) OUT_RING (chan, 0); BEGIN_RING(chan, RING_3D(LINE_LAST_PIXEL), 1); OUT_RING (chan, 0); + BEGIN_RING(chan, RING_3D(BLEND_SEPARATE_ALPHA), 1); + OUT_RING (chan, 1); BEGIN_RING(chan, RING_3D(SCREEN_Y_CONTROL), 1); OUT_RING (chan, 0); diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index ef5a1842b11..799f49619d2 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -97,8 +97,14 @@ nv50_blend_state_create(struct pipe_context *pipe, so->pipe = *cso; - SB_BEGIN_3D(so, BLEND_ENABLE(0), 8); + SB_BEGIN_3D(so, COLOR_MASK_COMMON, 1); + SB_DATA (so, !cso->independent_blend_enable); + + SB_BEGIN_3D(so, BLEND_ENABLE_COMMON, 1); + SB_DATA (so, !cso->independent_blend_enable); + if (cso->independent_blend_enable) { + SB_BEGIN_3D(so, BLEND_ENABLE(0), 8); for (i = 0; i < 8; ++i) { SB_DATA(so, cso->rt[i].blend_enable); if (cso->rt[i].blend_enable) @@ -121,8 +127,8 @@ nv50_blend_state_create(struct pipe_context *pipe, } } } else { - for (i = 0; i < 8; ++i) - SB_DATA(so, cso->rt[0].blend_enable); + SB_BEGIN_3D(so, BLEND_ENABLE(0), 1); + SB_DATA (so, cso->rt[0].blend_enable); } if (emit_common_func) { @@ -145,14 +151,13 @@ nv50_blend_state_create(struct pipe_context *pipe, SB_DATA (so, 0); } - SB_BEGIN_3D(so, COLOR_MASK(0), 8); if (cso->independent_blend_enable) { + SB_BEGIN_3D(so, COLOR_MASK(0), 8); for (i = 0; i < 8; ++i) SB_DATA(so, nv50_colormask(cso->rt[i].colormask)); } else { - uint32_t cmask = nv50_colormask(cso->rt[0].colormask); - for (i = 0; i < 8; ++i) - SB_DATA(so, cmask); + SB_BEGIN_3D(so, COLOR_MASK(0), 1); + SB_DATA (so, nv50_colormask(cso->rt[0].colormask)); } assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); diff --git a/src/gallium/drivers/nv50/nv50_stateobj.h b/src/gallium/drivers/nv50/nv50_stateobj.h index cd55ad83f84..4c98c7e46fc 100644 --- a/src/gallium/drivers/nv50/nv50_stateobj.h +++ b/src/gallium/drivers/nv50/nv50_stateobj.h @@ -21,7 +21,7 @@ struct nv50_blend_stateobj { struct pipe_blend_state pipe; int size; - uint32_t state[78]; + uint32_t state[82]; // TODO: allocate less if !independent_blend_enable }; struct nv50_rasterizer_stateobj { diff --git a/src/gallium/drivers/nvc0/nvc0_3d.xml.h b/src/gallium/drivers/nvc0/nvc0_3d.xml.h index 9a64e3ff6af..63efc74d4a9 100644 --- a/src/gallium/drivers/nvc0/nvc0_3d.xml.h +++ b/src/gallium/drivers/nvc0/nvc0_3d.xml.h @@ -344,6 +344,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NVC0_3D_VERTEX_RUNOUT_ADDRESS_LOW 0x00000f88 +#define NVC0_3D_COLOR_MASK_COMMON 0x00000f90 + #define NVC0_3D_DEPTH_BOUNDS(i0) (0x00000f9c + 0x4*(i0)) #define NVC0_3D_DEPTH_BOUNDS__ESIZE 0x00000004 #define NVC0_3D_DEPTH_BOUNDS__LEN 0x00000002 @@ -563,6 +565,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NVC0_3D_TEX_CACHE_CTL_UNK1__MASK 0x00000030 #define NVC0_3D_TEX_CACHE_CTL_UNK1__SHIFT 4 +#define NVC0_3D_BLEND_SEPARATE_ALPHA 0x0000133c + #define NVC0_3D_BLEND_EQUATION_RGB 0x00001340 #define NVC0_3D_BLEND_EQUATION_RGB_FUNC_ADD 0x00008006 #define NVC0_3D_BLEND_EQUATION_RGB_MIN 0x00008007 @@ -585,6 +589,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NVC0_3D_BLEND_FUNC_DST_ALPHA 0x00001358 +#define NVC0_3D_BLEND_ENABLE_COMMON 0x0000135c + #define NVC0_3D_BLEND_ENABLE(i0) (0x00001360 + 0x4*(i0)) #define NVC0_3D_BLEND_ENABLE__ESIZE 0x00000004 #define NVC0_3D_BLEND_ENABLE__LEN 0x00000008 @@ -1226,8 +1232,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NVC0_3D_TFB_VARYING_LOCS__ESIZE 0x00000004 #define NVC0_3D_TFB_VARYING_LOCS__LEN 0x00000020 -#define NVC0_3D_COLOR_MASK_BROADCAST 0x00003808 - #define NVC0_3D_VERTEX_ARRAY_SELECT 0x00003820 #define NVC0_3D_BLEND_ENABLES 0x00003858 diff --git a/src/gallium/drivers/nvc0/nvc0_graph_macros.h b/src/gallium/drivers/nvc0/nvc0_graph_macros.h index b7d0d3eafa4..a0a875fe627 100644 --- a/src/gallium/drivers/nvc0/nvc0_graph_macros.h +++ b/src/gallium/drivers/nvc0/nvc0_graph_macros.h @@ -68,19 +68,6 @@ static const uint32_t nvc0_9097_vertex_array_select[] = 0x00001841, /* 0x0b: send $r3 */ }; -static const uint32_t nvc0_9097_color_mask_brdc[] = -{ - 0x05a00021, /* maddr [NVC0_3D_COLOR_MASK(0), increment = 4] */ - 0x00000841, /* send $r1 */ - 0x00000841, /* send $r1 */ - 0x00000841, /* send $r1 */ - 0x00000841, /* send $r1 */ - 0x00000841, /* send $r1 */ - 0x00000841, /* send $r1 */ - 0x000008c1, /* exit send $r1 */ - 0x00000841, /* send $r1 */ -}; - /* * [GL_POLYGON_MODE_FRONT] = arg; * diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c index 17f42e6fc6c..7f01a5eea32 100644 --- a/src/gallium/drivers/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nvc0/nvc0_screen.c @@ -313,8 +313,6 @@ nvc0_magic_3d_init(struct nouveau_channel *chan) BEGIN_RING(chan, RING_3D_(0x0fac), 1); OUT_RING (chan, 0); - BEGIN_RING(chan, RING_3D_(0x0f90), 1); - OUT_RING (chan, 0); } static void @@ -450,6 +448,10 @@ nvc0_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) OUT_RING (chan, 1); BEGIN_RING(chan, RING_3D(LINE_LAST_PIXEL), 1); OUT_RING (chan, 0); + BEGIN_RING(chan, RING_3D(BLEND_SEPARATE_ALPHA), 1); + OUT_RING (chan, 1); + BEGIN_RING(chan, RING_3D(BLEND_ENABLE_COMMON), 1); + OUT_RING (chan, 0); nvc0_magic_3d_init(chan); @@ -582,7 +584,6 @@ nvc0_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) MK_MACRO(NVC0_3D_GP_SELECT, nvc0_9097_gp_select); MK_MACRO(NVC0_3D_POLYGON_MODE_FRONT, nvc0_9097_poly_mode_front); MK_MACRO(NVC0_3D_POLYGON_MODE_BACK, nvc0_9097_poly_mode_back); - MK_MACRO(NVC0_3D_COLOR_MASK_BROADCAST, nvc0_9097_color_mask_brdc); BEGIN_RING(chan, RING_3D(RASTERIZE_ENABLE), 1); OUT_RING (chan, 1); diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c index 85a4d991687..b0b2065167e 100644 --- a/src/gallium/drivers/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nvc0/nvc0_state.c @@ -117,7 +117,8 @@ nvc0_blend_state_create(struct pipe_context *pipe, SB_DATA (so, nvc0_blend_fac(cso->rt[0].alpha_dst_factor)); } - SB_BEGIN_3D(so, COLOR_MASK_BROADCAST, 1); + SB_IMMED_3D(so, COLOR_MASK_COMMON, 1); + SB_BEGIN_3D(so, COLOR_MASK(0), 1); SB_DATA (so, nvc0_colormask(cso->rt[0].colormask)); } else { uint8_t en = 0; @@ -137,6 +138,7 @@ nvc0_blend_state_create(struct pipe_context *pipe, } SB_IMMED_3D(so, BLEND_ENABLES, en); + SB_IMMED_3D(so, COLOR_MASK_COMMON, 0); SB_BEGIN_3D(so, COLOR_MASK(0), 8); for (i = 0; i < 8; ++i) SB_DATA(so, nvc0_colormask(cso->rt[i].colormask)); diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h index b300ec9097c..e0fe9df25d7 100644 --- a/src/gallium/drivers/nvc0/nvc0_stateobj.h +++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h @@ -19,7 +19,7 @@ struct nvc0_blend_stateobj { struct pipe_blend_state pipe; int size; - uint32_t state[69]; + uint32_t state[70]; }; struct nvc0_rasterizer_stateobj { -- 2.30.2