diff options
author | Marek Olšák <[email protected]> | 2012-01-10 00:19:00 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-01-10 00:25:05 +0100 |
commit | dc4c821f0817a3db716f965692fb701079f66340 (patch) | |
tree | 51c25da0a3746c34f946a7ceac8f9e6f9208fbb5 /src/gallium/drivers | |
parent | a48cc138a8b7c55f8d12796677e081c2b2085f48 (diff) |
Squash-merge branch 'gallium-clip-state'
Conflicts:
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/mesa/state_tracker/st_atom_clip.c
commit d919791f2742e913173d6b335128e7d4c63c0840
Author: Christoph Bumiller <[email protected]>
Date: Fri Jan 6 17:59:22 2012 +0100
d3d1x: adapt to new clip state
commit cfec82bca3fefcdefafca3f4555285ec1d1ae421
Author: Christoph Bumiller <[email protected]>
Date: Fri Jan 6 14:16:51 2012 +0100
gallium/docs: update for clip state changes
commit c02bfeb81ad9f62041a2285ea6373bbbd602912a
Author: Christoph Bumiller <[email protected]>
Date: Fri Jan 6 14:21:43 2012 +0100
tgsi: add TGSI_PROPERTY_PROHIBIT_UCPS
commit d4e0a785a6a23ad2f6819fd72e236acb9750028d
Author: Brian Paul <[email protected]>
Date: Thu Jan 5 08:30:00 2012 -0700
tgsi: consolidate TGSI string arrays in new tgsi_strings.h
There was some duplication between the tgsi_dump.c and tgsi_text.c
files. Also use some static assertions to help catch errors when
adding new TGSI values.
v2: put strings in tgsi_strings.c file instead of the .h file.
Reviewed-by: Dave Airlie <[email protected]>
commit c28584ce0d8c62bd92c8f140729d344f88a0b3cd
Author: Christoph Bumiller <[email protected]>
Date: Fri Jan 6 12:48:09 2012 +0100
gallium: extend user_clip_plane_enable to apply to clip distances
commit f1d5016c07f786229ed057effbe55fbfd160b019
Author: Marek Olšák <[email protected]>
Date: Fri Jan 6 02:39:09 2012 +0100
nvfx: adapt to new clip state
commit 6f6fa1c26bd19f797c1996731708e3569c9bfe24
Author: Marek Olšák <[email protected]>
Date: Fri Jan 6 01:41:39 2012 +0100
st/mesa: fix DrawPixels with GL_DEPTH_CLAMP
commit c86ad730aa1c017788ae88a55f54071bf222be12
Author: Christoph Bumiller <[email protected]>
Date: Tue Jan 3 23:51:30 2012 +0100
nv50: adapt to new clip state
commit 3a8ae6ac243bae5970729dc4057fe02d992543dc
Author: Christoph Bumiller <[email protected]>
Date: Tue Jan 3 23:32:36 2012 +0100
nvc0: adapt to new clip state
commit 6243a8246997f8d2fcc69ab741a2c2dea080ff11
Author: Marek Olšák <[email protected]>
Date: Thu Dec 29 01:32:51 2011 +0100
draw: initalize pt.user.planes in draw_init
This fixes a crash in glean/fpexceptions.
commit e3056524b19b56d473f4faff84ffa0eb41497408
Author: Marek Olšák <[email protected]>
Date: Mon Dec 26 06:26:55 2011 +0100
svga: adapt to new clip state
commit c5bfa8b37d6d489271df457229081d6bbb51b4b7
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 14:11:51 2011 +0100
r600g: adapt to new clip state
commit f11890905362f62627c4a28a8255b76eb7de7df2
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 14:10:26 2011 +0100
r300g: adapt to new clip state
commit e37465327c79a01112f15f6278d9accc5bf3103f
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 12:39:16 2011 +0100
draw: adapt to new clip state
This adds a regression in the LLVM clipping path. Can anybody see anything
wrong with the code? It works for every other case, just glean/fpexceptions
crashes when doing the "Infinite clip plane test".
commit b474d2b18c72d965eefae4e427c269cba5ce6ba2
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 13:14:59 2011 +0100
u_blitter: don't save/set/restore clip state
commit 9dd240ea91f523a677af45e8d0adb9e661e28602
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 13:11:56 2011 +0100
gallium: don't cso_save/set/restore clip state
The enable bits are in the rasterizer state.
commit a4f7031179f5f4ad524b34b394214b984ac950f6
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 12:58:55 2011 +0100
gallium: default depth_clip to 1
depth_clip = !depth_clamp
commit fe21147a00ab90e549d63fe12ee4625c9c2ffcc3
Author: Marek Olšák <[email protected]>
Date: Mon Dec 26 06:14:19 2011 +0100
trace,util: update state logging to new clip state
Also dump the other missing flags.
commit 2a3b96e84ac872dcc5bc1de049fe76bb58d64b23
Author: Marek Olšák <[email protected]>
Date: Sun Dec 25 10:43:43 2011 +0100
st/mesa: adapt to new clip state
commit b7b656a42fca19d7c85267f42649a206a85a2c72
Author: Marek Olšák <[email protected]>
Date: Sat Dec 17 15:45:19 2011 +0100
gallium: move state enable bits from clip_state to rasterizer_state
Diffstat (limited to 'src/gallium/drivers')
32 files changed, 201 insertions, 196 deletions
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 2a64ba4dbab..5444425d5ea 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -185,7 +185,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) /* Unsupported features (boolean caps). */ case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_INDEP_BLEND_ENABLE: case PIPE_CAP_INDEP_BLEND_FUNC: case PIPE_CAP_SHADER_STENCIL_EXPORT: diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 731d2f6d988..1d1b6f7d5ee 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -66,7 +66,6 @@ i915_surface_copy_render(struct pipe_context *pipe, util_blitter_save_fragment_shader(i915->blitter, i915->saved_fs); util_blitter_save_vertex_shader(i915->blitter, i915->saved_vs); util_blitter_save_viewport(i915->blitter, &i915->viewport); - util_blitter_save_clip(i915->blitter, &i915->saved_clip); util_blitter_save_vertex_elements(i915->blitter, i915->saved_velems); util_blitter_save_vertex_buffers(i915->blitter, i915->saved_nr_vertex_buffers, i915->saved_vertex_buffers); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 98b838be4db..5798a19e5f7 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -150,7 +150,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) return 1; case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: return 1; - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: return 0; case PIPE_CAP_TGSI_INSTANCEID: case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 15f579efb86..4f22284c3a6 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -103,7 +103,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return 0; case PIPE_CAP_TWO_SIDED_STENCIL: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_POINT_SPRITE: return 1; diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c index d73f7c7f213..d3cdb697960 100644 --- a/src/gallium/drivers/nv50/nv50_shader_state.c +++ b/src/gallium/drivers/nv50/nv50_shader_state.c @@ -171,12 +171,6 @@ nv50_vertprog_validate(struct nv50_context *nv50) struct nouveau_channel *chan = nv50->screen->base.channel; struct nv50_program *vp = nv50->vertprog; - if (nv50->clip.nr > vp->vp.clpd_nr) { - if (vp->translated) - nv50_program_destroy(nv50, vp); - vp->vp.clpd_nr = nv50->clip.nr; - } - if (!nv50_program_validate(nv50, vp)) return; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index ede8713ae76..0f46afb882b 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -225,6 +225,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { struct nv50_rasterizer_stateobj *so; + uint32_t reg; so = CALLOC_STRUCT(nv50_rasterizer_stateobj); if (!so) @@ -312,6 +313,22 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, SB_DATA (so, fui(cso->offset_clamp)); } + if (cso->depth_clip) { + reg = 0; + } else { + reg = + NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; + } +#ifndef NV50_SCISSORS_CLIPPING + reg |= + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK7 | + NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; +#endif + SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1); + SB_DATA (so, reg); + assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); return (void *)so; } @@ -763,12 +780,8 @@ nv50_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) { struct nv50_context *nv50 = nv50_context(pipe); - const unsigned size = clip->nr * sizeof(clip->ucp[0]); - - memcpy(&nv50->clip.ucp[0][0], &clip->ucp[0][0], size); - nv50->clip.nr = clip->nr; - nv50->clip.depth_clamp = clip->depth_clamp; + memcpy(nv50->clip.ucp, clip->ucp, sizeof(clip->ucp)); nv50->dirty |= NV50_NEW_CLIP; } diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 05f32ea78d2..edf648e5533 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -213,42 +213,48 @@ nv50_validate_viewport(struct nv50_context *nv50) #endif } +static INLINE void +nv50_check_program_ucps(struct nv50_context *nv50, + struct nv50_program *vp, uint8_t mask) +{ + const unsigned n = util_logbase2(mask) + 1; + + if (vp->vp.clpd_nr >= n) + return; + nv50_program_destroy(nv50, vp); + + vp->vp.clpd_nr = n; + if (likely(vp == nv50->vertprog)) + nv50_vertprog_validate(nv50); + else + nv50_gmtyprog_validate(nv50); + nv50_fp_linkage_validate(nv50); +} + static void nv50_validate_clip(struct nv50_context *nv50) { struct nouveau_channel *chan = nv50->screen->base.channel; - uint32_t clip; - - if (nv50->clip.depth_clamp) { - clip = - NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; - } else { - clip = 0; - } - -#ifndef NV50_SCISSORS_CLIPPING - clip |= - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK7 | - NV50_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK1; -#endif - - BEGIN_RING(chan, RING_3D(VIEW_VOLUME_CLIP_CTRL), 1); - OUT_RING (chan, clip); + struct nv50_program *vp; + uint8_t clip_enable; - if (nv50->clip.nr) { + if (nv50->dirty & NV50_NEW_CLIP) { BEGIN_RING(chan, RING_3D(CB_ADDR), 1); OUT_RING (chan, (0 << 8) | NV50_CB_AUX); - BEGIN_RING_NI(chan, RING_3D(CB_DATA(0)), nv50->clip.nr * 4); - OUT_RINGp (chan, &nv50->clip.ucp[0][0], nv50->clip.nr * 4); + BEGIN_RING_NI(chan, RING_3D(CB_DATA(0)), PIPE_MAX_CLIP_PLANES * 4); + OUT_RINGp (chan, &nv50->clip.ucp[0][0], PIPE_MAX_CLIP_PLANES * 4); } + vp = nv50->gmtyprog; + if (likely(!vp)) + vp = nv50->vertprog; + + clip_enable = nv50->rast->pipe.clip_plane_enable; + BEGIN_RING(chan, RING_3D(VP_CLIP_DISTANCE_ENABLE), 1); - OUT_RING (chan, (1 << nv50->clip.nr) - 1); + OUT_RING (chan, clip_enable); - if (nv50->vertprog && nv50->clip.nr > nv50->vertprog->vp.clpd_nr) - nv50->dirty |= NV50_NEW_VERTPROG; + nv50_check_program_ucps(nv50, vp, clip_enable); } static void @@ -350,7 +356,8 @@ static struct state_validate { { nv50_validate_scissor, NV50_NEW_SCISSOR }, #endif { nv50_validate_viewport, NV50_NEW_VIEWPORT }, - { nv50_validate_clip, NV50_NEW_CLIP }, + { nv50_validate_clip, NV50_NEW_CLIP | NV50_NEW_RASTERIZER | + NV50_NEW_VERTPROG | NV50_NEW_GMTYPROG }, { nv50_vertprog_validate, NV50_NEW_VERTPROG }, { nv50_gmtyprog_validate, NV50_NEW_GMTYPROG }, { nv50_fragprog_validate, NV50_NEW_FRAGPROG }, diff --git a/src/gallium/drivers/nv50/nv50_stateobj.h b/src/gallium/drivers/nv50/nv50_stateobj.h index 83a08b0bd3d..c443dfbfec6 100644 --- a/src/gallium/drivers/nv50/nv50_stateobj.h +++ b/src/gallium/drivers/nv50/nv50_stateobj.h @@ -27,7 +27,7 @@ struct nv50_blend_stateobj { struct nv50_rasterizer_stateobj { struct pipe_rasterizer_state pipe; int size; - uint32_t state[46]; + uint32_t state[48]; }; struct nv50_zsa_stateobj { diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 910e18ff03c..28e34bd9ef6 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -433,7 +433,6 @@ struct nv50_blitctx struct pipe_sampler_view *texture; struct nv50_tsc_entry *sampler; unsigned dirty; - unsigned clip_nr; } saved; struct nv50_program vp; struct nv50_program fp; @@ -775,10 +774,6 @@ nv50_blitctx_pre_blit(struct nv50_blitctx *blit, struct nv50_context *nv50) nv50->gmtyprog = NULL; nv50->fragprog = &blit->fp; - blit->saved.clip_nr = nv50->clip.nr; - - nv50->clip.nr = 0; - for (s = 0; s < 3; ++s) { blit->saved.num_textures[s] = nv50->num_textures[s]; blit->saved.num_samplers[s] = nv50->num_samplers[s]; @@ -816,8 +811,6 @@ nv50_blitctx_post_blit(struct nv50_context *nv50, struct nv50_blitctx *blit) nv50->gmtyprog = blit->saved.gp; nv50->fragprog = blit->saved.fp; - nv50->clip.nr = blit->saved.clip_nr; - pipe_sampler_view_reference(&nv50->textures[2][0], NULL); for (s = 0; s < 3; ++s) { diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c index 8c14f9e61aa..069e68f1a55 100644 --- a/src/gallium/drivers/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nvc0/nvc0_screen.c @@ -92,7 +92,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return 0; case PIPE_CAP_TWO_SIDED_STENCIL: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_POINT_SPRITE: return 1; diff --git a/src/gallium/drivers/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nvc0/nvc0_shader_state.c index 446bd948a53..630ad20c31d 100644 --- a/src/gallium/drivers/nvc0/nvc0_shader_state.c +++ b/src/gallium/drivers/nvc0/nvc0_shader_state.c @@ -59,25 +59,6 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0, } } -static void -nvc0_program_validate_clip(struct nvc0_context *nvc0, struct nvc0_program *vp) -{ - struct nouveau_channel *chan = nvc0->screen->base.channel; - - if (nvc0->vertprog->vp.num_ucps) - return; - - if (nvc0->state.clip_enable != vp->vp.clip_enable) { - nvc0->state.clip_enable = vp->vp.clip_enable; - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), vp->vp.clip_enable); - } - if (nvc0->state.clip_mode != vp->vp.clip_mode) { - nvc0->state.clip_mode = vp->vp.clip_mode; - BEGIN_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 1); - OUT_RING (chan, vp->vp.clip_mode); - } -} - static INLINE boolean nvc0_program_validate(struct nvc0_context *nvc0, struct nvc0_program *prog) { @@ -101,14 +82,6 @@ nvc0_vertprog_validate(struct nvc0_context *nvc0) struct nouveau_channel *chan = nvc0->screen->base.channel; struct nvc0_program *vp = nvc0->vertprog; - if (nvc0->clip.nr > vp->vp.num_ucps) { - assert(nvc0->clip.nr <= 6); - vp->vp.num_ucps = 6; - - if (vp->translated) - nvc0_program_destroy(nvc0, vp); - } - if (!nvc0_program_validate(nvc0, vp)) return; nvc0_program_update_context_state(nvc0, vp, 0); @@ -119,9 +92,6 @@ nvc0_vertprog_validate(struct nvc0_context *nvc0) BEGIN_RING(chan, RING_3D(SP_GPR_ALLOC(1)), 1); OUT_RING (chan, vp->max_gpr); - if (!nvc0->gmtyprog && !nvc0->tevlprog) - nvc0_program_validate_clip(nvc0, vp); - // BEGIN_RING(chan, RING_3D_(0x163c), 1); // OUT_RING (chan, 0); } @@ -203,9 +173,6 @@ nvc0_tevlprog_validate(struct nvc0_context *nvc0) OUT_RING (chan, tp->code_base); BEGIN_RING(chan, RING_3D(SP_GPR_ALLOC(3)), 1); OUT_RING (chan, tp->max_gpr); - - if (!nvc0->gmtyprog) - nvc0_program_validate_clip(nvc0, tp); } void @@ -233,8 +200,6 @@ nvc0_gmtyprog_validate(struct nvc0_context *nvc0) OUT_RING (chan, gp->max_gpr); BEGIN_RING(chan, RING_3D(LAYER), 1); OUT_RING (chan, (gp->hdr[13] & (1 << 9)) ? NVC0_3D_LAYER_USE_GP : 0); - - nvc0_program_validate_clip(nvc0, gp); } void diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c index 1e334a01d87..32b7a8a8ecf 100644 --- a/src/gallium/drivers/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nvc0/nvc0_state.c @@ -270,6 +270,18 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe, SB_DATA (so, fui(cso->offset_clamp)); } + if (cso->depth_clip) + reg = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1; + else + reg = + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | + NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2; + + SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1); + SB_DATA (so, reg); + assert(so->size <= (sizeof(so->state) / sizeof(so->state[0]))); return (void *)so; } @@ -647,12 +659,8 @@ nvc0_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) { struct nvc0_context *nvc0 = nvc0_context(pipe); - const unsigned size = clip->nr * sizeof(clip->ucp[0]); - - memcpy(&nvc0->clip.ucp[0][0], &clip->ucp[0][0], size); - nvc0->clip.nr = clip->nr; - nvc0->clip.depth_clamp = clip->depth_clamp; + memcpy(nvc0->clip.ucp, clip->ucp, sizeof(clip->ucp)); nvc0->dirty |= NVC0_NEW_CLIP; } diff --git a/src/gallium/drivers/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nvc0/nvc0_state_validate.c index 0dc822a2f15..472ddee5216 100644 --- a/src/gallium/drivers/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nvc0/nvc0_state_validate.c @@ -260,43 +260,74 @@ nvc0_validate_viewport(struct nvc0_context *nvc0) OUT_RINGf (chan, zmax); } +static INLINE void +nvc0_upload_uclip_planes(struct nvc0_context *nvc0) +{ + struct nouveau_channel *chan = nvc0->screen->base.channel; + struct nouveau_bo *bo = nvc0->screen->uniforms; + + MARK_RING (chan, 6 + PIPE_MAX_CLIP_PLANES * 4, 2); + BEGIN_RING(chan, RING_3D(CB_SIZE), 3); + OUT_RING (chan, 256); + OUT_RELOCh(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCl(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + BEGIN_RING_1I(chan, RING_3D(CB_POS), PIPE_MAX_CLIP_PLANES * 4 + 1); + OUT_RING (chan, 0); + OUT_RINGp (chan, &nvc0->clip.ucp[0][0], PIPE_MAX_CLIP_PLANES * 4); +} + +static INLINE void +nvc0_check_program_ucps(struct nvc0_context *nvc0, + struct nvc0_program *vp, uint8_t mask) +{ + const unsigned n = util_logbase2(mask) + 1; + + if (vp->vp.num_ucps >= n) + return; + nvc0_program_destroy(nvc0, vp); + + vp->vp.num_ucps = n; + if (likely(vp == nvc0->vertprog)) + nvc0_vertprog_validate(nvc0); + else + if (likely(vp == nvc0->gmtyprog)) + nvc0_vertprog_validate(nvc0); + else + nvc0_tevlprog_validate(nvc0); +} + static void nvc0_validate_clip(struct nvc0_context *nvc0) { struct nouveau_channel *chan = nvc0->screen->base.channel; - uint32_t clip; - - if (nvc0->clip.depth_clamp) { - clip = - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1 | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_NEAR | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_CLAMP_FAR | - NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK12_UNK2; - } else { - clip = NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK1; - } + struct nvc0_program *vp; + uint8_t clip_enable; - BEGIN_RING(chan, RING_3D(VIEW_VOLUME_CLIP_CTRL), 1); - OUT_RING (chan, clip); + if (nvc0->dirty & NVC0_NEW_CLIP) + nvc0_upload_uclip_planes(nvc0); - if (nvc0->clip.nr) { - struct nouveau_bo *bo = nvc0->screen->uniforms; + vp = nvc0->gmtyprog; + if (!vp) { + vp = nvc0->tevlprog; + if (!vp) + vp = nvc0->vertprog; + } + clip_enable = vp->vp.clip_enable; - MARK_RING (chan, 6 + nvc0->clip.nr * 4, 2); - BEGIN_RING(chan, RING_3D(CB_SIZE), 3); - OUT_RING (chan, 256); - OUT_RELOCh(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RELOCl(chan, bo, 5 << 16, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - BEGIN_RING_1I(chan, RING_3D(CB_POS), nvc0->clip.nr * 4 + 1); - OUT_RING (chan, 0); - OUT_RINGp (chan, &nvc0->clip.ucp[0][0], nvc0->clip.nr * 4); + if (!clip_enable) { + clip_enable = nvc0->rast->pipe.clip_plane_enable; + if (unlikely(clip_enable)) + nvc0_check_program_ucps(nvc0, vp, clip_enable); } - if (nvc0->vertprog->vp.num_ucps) { - nvc0->state.clip_mode = 0; - nvc0->state.clip_enable = (1 << nvc0->clip.nr) - 1; - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), nvc0->state.clip_enable); - IMMED_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 0); + if (nvc0->state.clip_enable != clip_enable) { + nvc0->state.clip_enable = clip_enable; + IMMED_RING(chan, RING_3D(CLIP_DISTANCE_ENABLE), clip_enable); + } + if (nvc0->state.clip_mode != vp->vp.clip_mode) { + nvc0->state.clip_mode = vp->vp.clip_mode; + BEGIN_RING(chan, RING_3D(CLIP_DISTANCE_MODE), 1); + OUT_RING (chan, vp->vp.clip_mode); } } @@ -497,7 +528,10 @@ static struct state_validate { { nvc0_fragprog_validate, NVC0_NEW_FRAGPROG }, { nvc0_validate_derived_1, NVC0_NEW_FRAGPROG | NVC0_NEW_ZSA | NVC0_NEW_RASTERIZER }, - { nvc0_validate_clip, NVC0_NEW_CLIP }, + { nvc0_validate_clip, NVC0_NEW_CLIP | NVC0_NEW_RASTERIZER | + NVC0_NEW_VERTPROG | + NVC0_NEW_TEVLPROG | + NVC0_NEW_GMTYPROG }, { nvc0_constbufs_validate, NVC0_NEW_CONSTBUF }, { nvc0_validate_textures, NVC0_NEW_TEXTURES }, { nvc0_validate_samplers, NVC0_NEW_SAMPLERS }, diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h index 5c0d0c1149b..dc5771a03aa 100644 --- a/src/gallium/drivers/nvc0/nvc0_stateobj.h +++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h @@ -25,7 +25,7 @@ struct nvc0_blend_stateobj { struct nvc0_rasterizer_stateobj { struct pipe_rasterizer_state pipe; int size; - uint32_t state[41]; + uint32_t state[43]; }; struct nvc0_zsa_stateobj { diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c index a2e1a853995..46b5da551db 100644 --- a/src/gallium/drivers/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nvc0/nvc0_surface.c @@ -461,7 +461,6 @@ struct nvc0_blitctx struct pipe_sampler_view *texture; struct nv50_tsc_entry *sampler; unsigned dirty; - unsigned clip_nr; } saved; struct nvc0_program vp; struct nvc0_program fp; @@ -771,10 +770,6 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *blit, struct nvc0_context *nvc0) nvc0->tevlprog = NULL; nvc0->gmtyprog = NULL; - blit->saved.clip_nr = nvc0->clip.nr; - - nvc0->clip.nr = 0; - for (s = 0; s <= 4; ++s) { blit->saved.num_textures[s] = nvc0->num_textures[s]; blit->saved.num_samplers[s] = nvc0->num_samplers[s]; @@ -815,8 +810,6 @@ nvc0_blitctx_post_blit(struct nvc0_context *nvc0, struct nvc0_blitctx *blit) nvc0->gmtyprog = blit->saved.gp; nvc0->fragprog = blit->saved.fp; - nvc0->clip.nr = blit->saved.clip_nr; - pipe_sampler_view_reference(&nvc0->textures[4][0], NULL); for (s = 0; s <= 4; ++s) { diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index abf4937e8cb..b4a1b3ac0d9 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -73,7 +73,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 1; - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: return 0; // TODO: implement depth clamp case PIPE_CAP_PRIMITIVE_RESTART: return 0; // TODO: implement primitive restart diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c index ae9c31418c3..25da80e8433 100644 --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c @@ -114,16 +114,23 @@ nvfx_ucp_validate(struct nvfx_context* nvfx) { struct nouveau_channel* chan = nvfx->screen->base.channel; struct nouveau_grobj *eng3d = nvfx->screen->eng3d; - unsigned enables[7] = + unsigned enables[] = { - 0, NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4, - NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE0 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4 | NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE5, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE1, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE2, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE3, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE4, + NV30_3D_VP_CLIP_PLANES_ENABLE_PLANE5 }; + unsigned i, enable = 0, nr = 0; + + for (i = 0; i < 6; i++) { + if (nvfx->rasterizer->pipe.clip_plane_enable & (1 << i)) { + enable |= enables[i]; + nr = i+1; + } + } if(!nvfx->use_vp_clipping) { @@ -131,12 +138,12 @@ nvfx_ucp_validate(struct nvfx_context* nvfx) OUT_RING(chan, 0); BEGIN_RING(chan, eng3d, NV30_3D_VP_CLIP_PLANE(0, 0), - nvfx->clip.nr * 4); - OUT_RINGp(chan, &nvfx->clip.ucp[0][0], nvfx->clip.nr * 4); + nr * 4); + OUT_RINGp(chan, &nvfx->clip.ucp[0][0], nr * 4); } BEGIN_RING(chan, eng3d, NV30_3D_VP_CLIP_PLANES_ENABLE, 1); - OUT_RING(chan, enables[nvfx->clip.nr]); + OUT_RING(chan, enable); } static void @@ -146,7 +153,10 @@ nvfx_vertprog_ucp_validate(struct nvfx_context* nvfx) struct nouveau_grobj *eng3d = nvfx->screen->eng3d; unsigned i; struct nvfx_vertex_program* vp = nvfx->hw_vertprog; - if(nvfx->clip.nr != vp->clip_nr) + unsigned enable = nvfx->rasterizer->pipe.clip_plane_enable; + unsigned nr = util_bitcount(enable); + + if(nr != vp->clip_nr) { unsigned idx; @@ -161,21 +171,24 @@ nvfx_vertprog_ucp_validate(struct nvfx_context* nvfx) } /* set last instruction bit */ - idx = vp->nr_insns - 7 + nvfx->clip.nr; + idx = vp->nr_insns - 7 + nr; BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_FROM_ID, 1); OUT_RING(chan, vp->exec->start + idx); BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_INST(0), 4); OUT_RINGp(chan, vp->insns[idx].data, 3); OUT_RING(chan, vp->insns[idx].data[3] | 1); - vp->clip_nr = nvfx->clip.nr; + vp->clip_nr = nr; } // TODO: only do this for the ones changed - for(i = 0; i < nvfx->clip.nr; ++i) + for(i = 0; enable; ++i) { + unsigned index = ffs(enable) - 1; + enable &= ~(1 << index); + BEGIN_RING(chan, eng3d, NV30_3D_VP_UPLOAD_CONST_ID, 5); OUT_RING(chan, vp->data->start + i); - OUT_RINGp (chan, nvfx->clip.ucp[i], 4); + OUT_RINGp (chan, nvfx->clip.ucp[index], 4); } } @@ -266,10 +279,10 @@ nvfx_state_validate_common(struct nvfx_context *nvfx) if(dirty & NVFX_NEW_STIPPLE) nvfx_state_stipple_validate(nvfx); - if(nvfx->dirty & NVFX_NEW_UCP) + if(nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_RAST)) nvfx_ucp_validate(nvfx); - if(nvfx->use_vp_clipping && (nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_VERTPROG))) + if(nvfx->use_vp_clipping && (nvfx->dirty & (NVFX_NEW_UCP | NVFX_NEW_VERTPROG | NVFX_NEW_RAST))) nvfx_vertprog_ucp_validate(nvfx); if(dirty & (NVFX_NEW_FRAGPROG | NVFX_NEW_FRAGCONST | NVFX_NEW_VERTPROG | NVFX_NEW_SPRITE)) @@ -282,7 +295,7 @@ nvfx_state_validate_common(struct nvfx_context *nvfx) if(nvfx->is_nv4x) { unsigned vp_output = nvfx->hw_vertprog->or | nvfx->hw_fragprog->or; - vp_output |= (1 << (nvfx->clip.nr + 6)) - (1 << 6); + vp_output |= ((1 << (nvfx->rasterizer->pipe.clip_plane_enable & 63)) - 1) << 6; if(vp_output != nvfx->hw_vp_output) { diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c index d489bbf9473..cac3fcaabc0 100644 --- a/src/gallium/drivers/nvfx/nvfx_surface.c +++ b/src/gallium/drivers/nvfx/nvfx_surface.c @@ -187,7 +187,6 @@ nvfx_get_blitter(struct pipe_context* pipe, int copy) util_blitter_save_vertex_shader(blitter, nvfx->vertprog); util_blitter_save_viewport(blitter, &nvfx->viewport); util_blitter_save_framebuffer(blitter, &nvfx->framebuffer); - util_blitter_save_clip(blitter, &nvfx->clip); util_blitter_save_vertex_elements(blitter, nvfx->vtxelt); util_blitter_save_vertex_buffers(blitter, nvfx->vtxbuf_nr, nvfx->vtxbuf); diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index c780c8dd1ad..d1326380f3d 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -62,7 +62,6 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o util_blitter_save_fragment_shader(r300->blitter, r300->fs.state); util_blitter_save_vertex_shader(r300->blitter, r300->vs_state.state); util_blitter_save_viewport(r300->blitter, &r300->viewport); - util_blitter_save_clip(r300->blitter, (struct pipe_clip_state*)r300->clip_state.state); util_blitter_save_vertex_elements(r300->blitter, r300->velems); util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers, r300->vbuf_mgr->vertex_buffer); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index fb9f34a1ed3..7d289ca6346 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -204,7 +204,7 @@ static boolean r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(vertex_stream_state, 0); R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(vs_constants, 0); - R300_INIT_ATOM(clip_state, has_tcl ? 5 + (6 * 4) : 2); + R300_INIT_ATOM(clip_state, has_tcl ? 3 + (6 * 4) : 0); /* VAP, RS, GA, GB, SU, SC. */ R300_INIT_ATOM(rs_block_state, 0); R300_INIT_ATOM(rs_state, 0); @@ -277,8 +277,6 @@ static void r300_init_states(struct pipe_context *pipe) struct pipe_blend_color bc = {{0}}; struct pipe_clip_state cs = {{{0}}}; struct pipe_scissor_state ss = {0}; - struct r300_clip_state *clip = - (struct r300_clip_state*)r300->clip_state.state; struct r300_gpu_flush *gpuflush = (struct r300_gpu_flush*)r300->gpu_flush.state; struct r300_vap_invariant_state *vap_invariant = @@ -289,17 +287,9 @@ static void r300_init_states(struct pipe_context *pipe) CB_LOCALS; pipe->set_blend_color(pipe, &bc); + pipe->set_clip_state(pipe, &cs); pipe->set_scissor_state(pipe, &ss); - /* Initialize the clip state. */ - if (r300->screen->caps.has_tcl) { - pipe->set_clip_state(pipe, &cs); - } else { - BEGIN_CB(clip->cb, 2); - OUT_CB_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE); - END_CB; - } - /* Initialize the GPU flush. */ { BEGIN_CB(gpuflush->cb_flush_clean, 6); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 5588e51ada9..e40b7af45dd 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -78,8 +78,6 @@ struct r300_blend_color_state { }; struct r300_clip_state { - struct pipe_clip_state clip; - uint32_t cb[29]; }; @@ -139,7 +137,7 @@ struct r300_gpu_flush { uint32_t cb_flush_clean[6]; }; -#define RS_STATE_MAIN_SIZE 25 +#define RS_STATE_MAIN_SIZE 27 struct r300_rs_state { /* Original rasterizer state. */ diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index f8546443692..2266b48c948 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -59,6 +59,7 @@ static void r300_flush_and_cleanup(struct r300_context *r300, unsigned flags) if (!r300->screen->caps.has_tcl) { r300->vs_state.dirty = FALSE; r300->vs_constants.dirty = FALSE; + r300->clip_state.dirty = FALSE; } } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7f04c93e418..83cad42c415 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1194,7 +1194,6 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, r300_update_derived_state(r300); /* Mark some states we don't care about as non-dirty. */ - r300->clip_state.dirty = FALSE; r300->viewport_state.dirty = FALSE; if (!r300_prepare_for_rendering(r300, PREP_EMIT_STATES, NULL, dwords, 0, 0, -1)) @@ -1244,7 +1243,6 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, done: /* Restore the state. */ - r300_mark_atom_dirty(r300, &r300->clip_state); r300_mark_atom_dirty(r300, &r300->rs_state); r300_mark_atom_dirty(r300, &r300->viewport_state); diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d79ed99aee7..763321b480e 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -119,7 +119,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_DUAL_SOURCE_BLEND: case PIPE_CAP_INDEP_BLEND_ENABLE: case PIPE_CAP_INDEP_BLEND_FUNC: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 3606e0bf505..2bc703669ae 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -493,21 +493,13 @@ static void r300_set_clip_state(struct pipe_context* pipe, (struct r300_clip_state*)r300->clip_state.state; CB_LOCALS; - clip->clip = *state; - if (r300->screen->caps.has_tcl) { - r300->clip_state.size = 2 + !!state->nr * 3 + state->nr * 4; - BEGIN_CB(clip->cb, r300->clip_state.size); - if (state->nr) { - OUT_CB_REG(R300_VAP_PVS_VECTOR_INDX_REG, + OUT_CB_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300->screen->caps.is_r500 ? R500_PVS_UCP_START : R300_PVS_UCP_START)); - OUT_CB_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, state->nr * 4); - OUT_CB_TABLE(state->ucp, state->nr * 4); - } - OUT_CB_REG(R300_VAP_CLIP_CNTL, ((1 << state->nr) - 1) | - R300_PS_UCP_MODE_CLIP_AS_TRIFAN); + OUT_CB_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4); + OUT_CB_TABLE(state->ucp, 6 * 4); END_CB; r300_mark_atom_dirty(r300, &r300->clip_state); @@ -1027,6 +1019,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); float psiz; uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */ + uint32_t vap_clip_cntl; /* R300_VAP_CLIP_CNTL: 0x221C */ uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ @@ -1166,6 +1159,13 @@ static void* r300_create_rs_state(struct pipe_context* pipe, } } + if (r300_screen(pipe->screen)->caps.has_tcl) { + vap_clip_cntl = (state->clip_plane_enable & 63) | + R300_PS_UCP_MODE_CLIP_AS_TRIFAN; + } else { + vap_clip_cntl = R300_CLIP_DISABLE; + } + /* Vertex color clamping. FP20 means no clamping. */ round_mode = R300_GA_ROUND_MODE_GEOMETRY_ROUND_NEAREST | @@ -1175,13 +1175,14 @@ static void* r300_create_rs_state(struct pipe_context* pipe, /* Build the main command buffer. */ BEGIN_CB(rs->cb_main, RS_STATE_MAIN_SIZE); OUT_CB_REG(R300_VAP_CNTL_STATUS, vap_control_status); + OUT_CB_REG(R300_VAP_CLIP_CNTL, vap_clip_cntl); OUT_CB_REG(R300_GA_POINT_SIZE, point_size); OUT_CB_REG_SEQ(R300_GA_POINT_MINMAX, 2); OUT_CB(point_minmax); OUT_CB(line_control); OUT_CB_REG_SEQ(R300_SU_POLY_OFFSET_ENABLE, 2); OUT_CB(polygon_offset_enable); - rs->cull_mode_index = 9; + rs->cull_mode_index = 11; OUT_CB(cull_mode); OUT_CB_REG(R300_GA_LINE_STIPPLE_CONFIG, line_stipple_config); OUT_CB_REG(R300_GA_LINE_STIPPLE_VALUE, line_stipple_value); diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 7ded03d4428..f3aab69dec5 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -986,6 +986,10 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx, } r600_pipe_state_add_reg(rstate, R_028B7C_PA_SU_POLY_OFFSET_CLAMP, fui(state->offset_clamp), 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0); + r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, + S_028810_PS_UCP_MODE(3) | (state->clip_plane_enable & 63) | + S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) | + S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip), 0xFFFFFFFF, NULL, 0); return rstate; } @@ -1206,7 +1210,7 @@ static void evergreen_set_clip_state(struct pipe_context *ctx, rctx->clip = *state; rstate->id = R600_PIPE_STATE_CLIP; - for (int i = 0; i < state->nr; i++) { + for (int i = 0; i < 6; i++) { r600_pipe_state_add_reg(rstate, R_0285BC_PA_CL_UCP0_X + i * 16, fui(state->ucp[i][0]), 0xFFFFFFFF, NULL, 0); @@ -1220,10 +1224,6 @@ static void evergreen_set_clip_state(struct pipe_context *ctx, R_0285C8_PA_CL_UCP0_W + i * 16, fui(state->ucp[i][3]), 0xFFFFFFFF, NULL, 0); } - r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, - S_028810_PS_UCP_MODE(3) | ((1 << state->nr) - 1) | - S_028810_ZCLIP_NEAR_DISABLE(state->depth_clamp) | - S_028810_ZCLIP_FAR_DISABLE(state->depth_clamp), 0xFFFFFFFF, NULL, 0); free(rctx->states[R600_PIPE_STATE_CLIP]); rctx->states[R600_PIPE_STATE_CLIP] = rstate; diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index 9ad247a3a0a..6947c99c2ee 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -59,9 +59,6 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op if (rctx->states[R600_PIPE_STATE_VIEWPORT]) { util_blitter_save_viewport(rctx->blitter, &rctx->viewport); } - if (rctx->states[R600_PIPE_STATE_CLIP]) { - util_blitter_save_clip(rctx->blitter, &rctx->clip); - } util_blitter_save_vertex_buffers(rctx->blitter, rctx->vbuf_mgr->nr_vertex_buffers, rctx->vbuf_mgr->vertex_buffer); diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 4a31b43269a..e50b5cc3d16 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -353,7 +353,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: case PIPE_CAP_TEXTURE_SWIZZLE: case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: - case PIPE_CAP_DEPTH_CLAMP: + case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 12157ffd797..5fe038e79e5 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1029,6 +1029,10 @@ static void *r600_create_rs_state(struct pipe_context *ctx, r600_pipe_state_add_reg(rstate, R_028C18_PA_CL_GB_HORZ_DISC_ADJ, 0x3F800000, 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_028DFC_PA_SU_POLY_OFFSET_CLAMP, fui(state->offset_clamp), 0xFFFFFFFF, NULL, 0); r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0); + r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, + S_028810_PS_UCP_MODE(3) | (state->clip_plane_enable & 63) | + S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) | + S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip), 0xFFFFFFFF, NULL, 0); return rstate; } @@ -1313,7 +1317,7 @@ static void r600_set_clip_state(struct pipe_context *ctx, rctx->clip = *state; rstate->id = R600_PIPE_STATE_CLIP; - for (int i = 0; i < state->nr; i++) { + for (int i = 0; i < 6; i++) { r600_pipe_state_add_reg(rstate, R_028E20_PA_CL_UCP0_X + i * 16, fui(state->ucp[i][0]), 0xFFFFFFFF, NULL, 0); @@ -1327,10 +1331,6 @@ static void r600_set_clip_state(struct pipe_context *ctx, R_028E2C_PA_CL_UCP0_W + i * 16, fui(state->ucp[i][3]), 0xFFFFFFFF, NULL, 0); } - r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, - S_028810_PS_UCP_MODE(3) | ((1 << state->nr) - 1) | - S_028810_ZCLIP_NEAR_DISABLE(state->depth_clamp) | - S_028810_ZCLIP_FAR_DISABLE(state->depth_clamp), 0xFFFFFFFF, NULL, 0); free(rctx->states[R600_PIPE_STATE_CLIP]); rctx->states[R600_PIPE_STATE_CLIP] = rstate; diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index 8c0dddf7ae7..f3625e0de30 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -477,7 +477,7 @@ emit_clip_planes( struct svga_context *svga, /* TODO: just emit directly from svga_set_clip_state()? */ - for (i = 0; i < svga->curr.clip.nr; i++) { + for (i = 0; i < 6; i++) { /* need to express the plane in D3D-style coordinate space. * GL coords get converted to D3D coords with the matrix: * [ 1 0 0 0 ] diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index a4d56bd7394..d94ac35c644 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -246,7 +246,7 @@ static int emit_rss( struct svga_context *svga, if (dirty & SVGA_NEW_CLIP) { /* the number of clip planes is how many planes to enable */ - unsigned enabled = (1 << svga->curr.clip.nr) - 1; + unsigned enabled = svga->curr.rast->templ.clip_plane_enable; EMIT_RS( svga, enabled, CLIPPLANEENABLE, fail ); } diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 038a80ef945..8af084c2769 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -121,6 +121,8 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, flatshade); trace_dump_member(bool, state, light_twoside); + trace_dump_member(bool, state, clamp_vertex_color); + trace_dump_member(bool, state, clamp_fragment_color); trace_dump_member(uint, state, front_ccw); trace_dump_member(uint, state, cull_face); trace_dump_member(uint, state, fill_front); @@ -144,6 +146,9 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, line_last_pixel); trace_dump_member(bool, state, flatshade_first); trace_dump_member(bool, state, gl_rasterization_rules); + trace_dump_member(bool, state, rasterizer_discard); + trace_dump_member(bool, state, depth_clip); + trace_dump_member(uint, state, clip_plane_enable); trace_dump_member(float, state, line_width); trace_dump_member(float, state, point_size); @@ -241,8 +246,6 @@ void trace_dump_clip_state(const struct pipe_clip_state *state) trace_dump_array_end(); trace_dump_member_end(); - trace_dump_member(uint, state, nr); - trace_dump_struct_end(); } |