Squash-merge branch 'gallium-clip-state'
authorMarek Olšák <maraeo@gmail.com>
Mon, 9 Jan 2012 23:19:00 +0000 (00:19 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 9 Jan 2012 23:25:05 +0000 (00:25 +0100)
Conflicts:
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/mesa/state_tracker/st_atom_clip.c

commit d919791f2742e913173d6b335128e7d4c63c0840
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
Date:   Fri Jan 6 17:59:22 2012 +0100

    d3d1x: adapt to new clip state

commit cfec82bca3fefcdefafca3f4555285ec1d1ae421
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
Date:   Fri Jan 6 14:16:51 2012 +0100

    gallium/docs: update for clip state changes

commit c02bfeb81ad9f62041a2285ea6373bbbd602912a
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
Date:   Fri Jan 6 14:21:43 2012 +0100

    tgsi: add TGSI_PROPERTY_PROHIBIT_UCPS

commit d4e0a785a6a23ad2f6819fd72e236acb9750028d
Author: Brian Paul <brianp@vmware.com>
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 <airlied@redhat.com>
commit c28584ce0d8c62bd92c8f140729d344f88a0b3cd
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
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 <maraeo@gmail.com>
Date:   Fri Jan 6 02:39:09 2012 +0100

    nvfx: adapt to new clip state

commit 6f6fa1c26bd19f797c1996731708e3569c9bfe24
Author: Marek Olšák <maraeo@gmail.com>
Date:   Fri Jan 6 01:41:39 2012 +0100

    st/mesa: fix DrawPixels with GL_DEPTH_CLAMP

commit c86ad730aa1c017788ae88a55f54071bf222be12
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
Date:   Tue Jan 3 23:51:30 2012 +0100

    nv50: adapt to new clip state

commit 3a8ae6ac243bae5970729dc4057fe02d992543dc
Author: Christoph Bumiller <e0425955@student.tuwien.ac.at>
Date:   Tue Jan 3 23:32:36 2012 +0100

    nvc0: adapt to new clip state

commit 6243a8246997f8d2fcc69ab741a2c2dea080ff11
Author: Marek Olšák <maraeo@gmail.com>
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 <maraeo@gmail.com>
Date:   Mon Dec 26 06:26:55 2011 +0100

    svga: adapt to new clip state

commit c5bfa8b37d6d489271df457229081d6bbb51b4b7
Author: Marek Olšák <maraeo@gmail.com>
Date:   Sun Dec 25 14:11:51 2011 +0100

    r600g: adapt to new clip state

commit f11890905362f62627c4a28a8255b76eb7de7df2
Author: Marek Olšák <maraeo@gmail.com>
Date:   Sun Dec 25 14:10:26 2011 +0100

    r300g: adapt to new clip state

commit e37465327c79a01112f15f6278d9accc5bf3103f
Author: Marek Olšák <maraeo@gmail.com>
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 <maraeo@gmail.com>
Date:   Sun Dec 25 13:14:59 2011 +0100

    u_blitter: don't save/set/restore clip state

commit 9dd240ea91f523a677af45e8d0adb9e661e28602
Author: Marek Olšák <maraeo@gmail.com>
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 <maraeo@gmail.com>
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 <maraeo@gmail.com>
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 <maraeo@gmail.com>
Date:   Sun Dec 25 10:43:43 2011 +0100

    st/mesa: adapt to new clip state

commit b7b656a42fca19d7c85267f42649a206a85a2c72
Author: Marek Olšák <maraeo@gmail.com>
Date:   Sat Dec 17 15:45:19 2011 +0100

    gallium: move state enable bits from clip_state to rasterizer_state

79 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/draw/draw_cliptest_tmp.h
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/postprocess/pp_program.c
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/auxiliary/util/u_dump_state.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_mc.c
src/gallium/auxiliary/vl/vl_zscan.c
src/gallium/docs/source/cso/rasterizer.rst
src/gallium/docs/source/tgsi.rst
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_surface.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_shader_state.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_stateobj.h
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nvc0/nvc0_screen.c
src/gallium/drivers/nvc0/nvc0_shader_state.c
src/gallium/drivers/nvc0/nvc0_state.c
src/gallium/drivers/nvc0/nvc0_state_validate.c
src/gallium/drivers/nvc0/nvc0_stateobj.h
src/gallium/drivers/nvc0/nvc0_surface.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_state_emit.c
src/gallium/drivers/nvfx/nvfx_surface.c
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/svga/svga_state_framebuffer.c
src/gallium/drivers/svga/svga_state_rss.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_shader_tokens.h
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/xa/xa_renderer.c
src/gallium/state_trackers/xorg/xorg_renderer.c
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/quad-sample.c
src/gallium/tests/graw/quad-tex.c
src/gallium/tests/graw/shader-leak.c
src/gallium/tests/graw/tri-gs.c
src/gallium/tests/graw/tri-instanced.c
src/gallium/tests/graw/tri.c
src/gallium/tests/graw/vs-test.c
src/gallium/tests/trivial/quad-tex.c
src/gallium/tests/trivial/tri.c
src/mesa/state_tracker/st_atom_clip.c
src/mesa/state_tracker/st_atom_rasterizer.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_extensions.c

index b46e66869d8bfd5b2e2af8d0f4b8bf7cd144e573..c95a1ba4117225e371b0324c5e51e8602418ca4c 100644 (file)
@@ -858,27 +858,14 @@ static INLINE void
 clip_state_cpy(struct pipe_clip_state *dst,
                const struct pipe_clip_state *src)
 {
-   dst->depth_clamp = src->depth_clamp;
-   dst->nr = src->nr;
-   if (src->nr) {
-      memcpy(dst->ucp, src->ucp, src->nr * sizeof(src->ucp[0]));
-   }
+   memcpy(dst->ucp, src->ucp, sizeof(dst->ucp));
 }
 
 static INLINE int
 clip_state_cmp(const struct pipe_clip_state *a,
                const struct pipe_clip_state *b)
 {
-   if (a->depth_clamp != b->depth_clamp) {
-      return 1;
-   }
-   if (a->nr != b->nr) {
-      return 1;
-   }
-   if (a->nr) {
-      return memcmp(a->ucp, b->ucp, a->nr * sizeof(a->ucp[0]));
-   }
-   return 0;
+   return memcmp(a->ucp, b->ucp, sizeof(a->ucp));
 }
 
 void
index 1ca152911ebe623365f9abaf94d0bf138e2406cf..9e6827cc452bcbdd0ed162c1969168bfca52a5db 100644 (file)
@@ -36,7 +36,7 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
    /* const */ float (*plane)[4] = pvs->draw->plane;
    const unsigned pos = draw_current_shader_position_output(pvs->draw);
    const unsigned ef = pvs->draw->vs.edgeflag_output;
-   const unsigned nr = pvs->draw->nr_planes;
+   const unsigned ucp_enable = pvs->draw->rasterizer->clip_plane_enable;
    const unsigned flags = (FLAGS);
    unsigned need_pipeline = 0;
    unsigned j;
@@ -81,10 +81,16 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
          }
 
          if (flags & DO_CLIP_USER) {
-            unsigned i;
-            for (i = 6; i < nr; i++) {
-               if (dot4(position, plane[i]) < 0) 
-                  mask |= (1<<i);
+            unsigned ucp_mask = ucp_enable;
+
+            while (ucp_mask) {
+               unsigned plane_idx = ffs(ucp_mask)-1;
+               ucp_mask &= ~(1 << plane_idx);
+               plane_idx += 6;
+
+               if (dot4(position, plane[plane_idx]) < 0) {
+                  mask |= 1 << plane_idx;
+               }
             }
          }
 
index f6db95d756e5f56f4451d9ccbd96233f46415742..f91e408cbf02298606ff909d2060f1c80bbbb35c 100644 (file)
@@ -151,11 +151,10 @@ boolean draw_init(struct draw_context *draw)
    ASSIGN_4V( draw->plane[3],  0,  1,  0, 1 );
    ASSIGN_4V( draw->plane[4],  0,  0,  1, 1 ); /* yes these are correct */
    ASSIGN_4V( draw->plane[5],  0,  0, -1, 1 ); /* mesa's a bit wonky */
-   draw->nr_planes = 6;
    draw->clip_xy = TRUE;
    draw->clip_z = TRUE;
 
-
+   draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]);
    draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
 
 
@@ -247,8 +246,9 @@ static void update_clip_flags( struct draw_context *draw )
    draw->guard_band_xy = (!draw->driver.bypass_clip_xy &&
                           draw->driver.guard_band_xy);
    draw->clip_z = (!draw->driver.bypass_clip_z &&
-                   !draw->depth_clamp);
-   draw->clip_user = (draw->nr_planes > 6);
+                   draw->rasterizer && draw->rasterizer->depth_clip);
+   draw->clip_user = draw->rasterizer &&
+                     draw->rasterizer->clip_plane_enable != 0;
 }
 
 /**
@@ -264,8 +264,8 @@ void draw_set_rasterizer_state( struct draw_context *draw,
 
       draw->rasterizer = raster;
       draw->rast_handle = rast_handle;
-
-  }
+      update_clip_flags(draw);
+   }
 }
 
 /* With a little more work, llvmpipe will be able to turn this off and
@@ -311,14 +311,7 @@ void draw_set_clip_state( struct draw_context *draw,
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 
-   assert(clip->nr <= PIPE_MAX_CLIP_PLANES);
-   memcpy(&draw->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0]));
-   draw->nr_planes = 6 + clip->nr;
-   draw->depth_clamp = clip->depth_clamp;
-
-   draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]);
-
-   update_clip_flags(draw);
+   memcpy(&draw->plane[6], clip->ucp, sizeof(clip->ucp));
 }
 
 
index 296c8fdef4136617236e6bcffe677007f55ee721..cf97e82a63c8e774846b6999bc07366cb1cea6f4 100644 (file)
@@ -1021,7 +1021,7 @@ generate_clipmask(struct gallivm_state *gallivm,
                   boolean clip_z,
                   boolean clip_user,
                   boolean clip_halfz,
-                  unsigned nr,
+                  unsigned ucp_enable,
                   LLVMValueRef context_ptr)
 {
    LLVMBuilderRef builder = gallivm->builder;
@@ -1030,7 +1030,6 @@ generate_clipmask(struct gallivm_state *gallivm,
    LLVMValueRef zero, shift;
    LLVMValueRef pos_x, pos_y, pos_z, pos_w;
    LLVMValueRef plane1, planes, plane_ptr, sum;
-   unsigned i;
    struct lp_type f32_type = lp_type_float_vec(32); 
 
    mask = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 0);
@@ -1098,12 +1097,15 @@ generate_clipmask(struct gallivm_state *gallivm,
    if (clip_user) {
       LLVMValueRef planes_ptr = draw_jit_context_planes(gallivm, context_ptr);
       LLVMValueRef indices[3];
-      temp = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 32);
 
       /* userclip planes */
-      for (i = 6; i < nr; i++) {
+      while (ucp_enable) {
+         unsigned plane_idx = ffs(ucp_enable)-1;
+         ucp_enable &= ~(1 << plane_idx);
+         plane_idx += 6;
+
          indices[0] = lp_build_const_int32(gallivm, 0);
-         indices[1] = lp_build_const_int32(gallivm, i);
+         indices[1] = lp_build_const_int32(gallivm, plane_idx);
 
          indices[2] = lp_build_const_int32(gallivm, 0);
          plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, "");
@@ -1133,8 +1135,8 @@ generate_clipmask(struct gallivm_state *gallivm,
          sum = LLVMBuildFAdd(builder, sum, test, "");
 
          test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, sum);
-         temp = LLVMBuildShl(builder, temp, shift, "");
-         test = LLVMBuildAnd(builder, test, temp, ""); 
+         temp = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 1 << plane_idx);
+         test = LLVMBuildAnd(builder, test, temp, "");
          mask = LLVMBuildOr(builder, mask, test, "");
       }
    }
@@ -1365,7 +1367,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
                                       variant->key.clip_z, 
                                       variant->key.clip_user,
                                       variant->key.clip_halfz,
-                                      variant->key.nr_planes,
+                                      variant->key.ucp_enable,
                                       context_ptr);
          /* return clipping boolean value for function */
          clipmask_bool(gallivm, clipmask, ret_ptr);
@@ -1447,7 +1449,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
    key->bypass_viewport = llvm->draw->identity_viewport;
    key->clip_halfz = !llvm->draw->rasterizer->gl_rasterization_rules;
    key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE);
-   key->nr_planes = llvm->draw->nr_planes;
+   key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
    key->pad = 0;
 
    /* All variants of this shader will have the same value for
index bc361357de537d5421352207f54d5d4cf4f3ac29..edd1a08e3db03832a5c1e1eb93563e45d9544e5c 100644 (file)
@@ -171,8 +171,8 @@ struct draw_llvm_variant_key
    unsigned clip_halfz:1;
    unsigned bypass_viewport:1;
    unsigned need_edgeflags:1;
-   unsigned nr_planes:4;
-   unsigned pad:5;
+   unsigned ucp_enable:PIPE_MAX_CLIP_PLANES;
+   unsigned pad:9-PIPE_MAX_CLIP_PLANES;
 
    /* Variable number of vertex elements:
     */
index 89653e111619f0966fa8a84fbb07bde4edc1eae1..c0ef18e3ed2ab57ef26f0064f24fd0c3b8404f6a 100644 (file)
@@ -278,8 +278,6 @@ struct draw_context
    /* Clip derived state:
     */
    float plane[DRAW_TOTAL_CLIP_PLANES][4];
-   unsigned nr_planes;
-   boolean depth_clamp;
 
    /* If a prim stage introduces new vertex attributes, they'll be stored here
     */
index 1a8a584b5158c2a281cc353b1f2897e5157eb005..5c819a9c60328de08629668b2433469967f02827 100644 (file)
@@ -88,6 +88,7 @@ pp_init_prog(struct pp_queue_t *ppq, struct pipe_screen *pscreen)
 
    p->rasterizer.cull_face = PIPE_FACE_NONE;
    p->rasterizer.gl_rasterization_rules = 1;
+   p->rasterizer.depth_clip = 1;
 
    p->sampler.wrap_s = p->sampler.wrap_t = p->sampler.wrap_r =
       PIPE_TEX_WRAP_CLAMP_TO_EDGE;
index 973b9fec0d2bd3334f137bce4774c9b685979d69..aa12493d9b0c81f803aaba049f44b185b83059e3 100644 (file)
@@ -100,7 +100,8 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
    "FS_COORD_ORIGIN",
    "FS_COORD_PIXEL_CENTER",
    "FS_COLOR0_WRITES_ALL_CBUFS",
-   "FS_DEPTH_LAYOUT"
+   "FS_DEPTH_LAYOUT",
+   "VS_PROHIBIT_UCPS"
 };
 
 const char *tgsi_type_names[5] =
index bba0031d772422579776e3bef16c5f234a2c038f..a10fd17cbffdefdf9b8f1db6db7d5e390c3debf0 100644 (file)
@@ -62,7 +62,6 @@ struct blit_state
    struct pipe_rasterizer_state rasterizer;
    struct pipe_sampler_state sampler;
    struct pipe_viewport_state viewport;
-   struct pipe_clip_state clip;
    struct pipe_vertex_element velem[2];
    enum pipe_texture_target internal_target;
 
@@ -109,6 +108,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
    memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
    ctx->rasterizer.cull_face = PIPE_FACE_NONE;
    ctx->rasterizer.gl_rasterization_rules = 1;
+   ctx->rasterizer.depth_clip = 1;
 
    /* samplers */
    memset(&ctx->sampler, 0, sizeof(ctx->sampler));
@@ -535,7 +535,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
    cso_save_geometry_shader(ctx->cso);
-   cso_save_clip(ctx->cso);
    cso_save_vertex_elements(ctx->cso);
    cso_save_vertex_buffers(ctx->cso);
 
@@ -545,7 +544,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
                                dst_is_depth ? &ctx->depthstencil_write :
                                               &ctx->depthstencil_keep);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
-   cso_set_clip(ctx->cso, &ctx->clip);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
 
@@ -621,7 +619,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_restore_fragment_shader(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
    cso_restore_geometry_shader(ctx->cso);
-   cso_restore_clip(ctx->cso);
    cso_restore_vertex_elements(ctx->cso);
    cso_restore_vertex_buffers(ctx->cso);
    cso_restore_stream_outputs(ctx->cso);
@@ -731,7 +728,6 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
    cso_save_geometry_shader(ctx->cso);
-   cso_save_clip(ctx->cso);
    cso_save_vertex_elements(ctx->cso);
    cso_save_vertex_buffers(ctx->cso);
 
@@ -739,7 +735,6 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_set_blend(ctx->cso, &ctx->blend);
    cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil_keep);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
-   cso_set_clip(ctx->cso, &ctx->clip);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
 
@@ -803,7 +798,6 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_restore_fragment_shader(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
    cso_restore_geometry_shader(ctx->cso);
-   cso_restore_clip(ctx->cso);
    cso_restore_vertex_elements(ctx->cso);
    cso_restore_vertex_buffers(ctx->cso);
    cso_restore_stream_outputs(ctx->cso);
index 80fdfe0a9ae9d44f852675a26c2f6b783f8b705c..59940d9cbe73184a310ac6184e73973cb22d5ebd 100644 (file)
@@ -104,9 +104,6 @@ struct blitter_context_priv
    /* Viewport state. */
    struct pipe_viewport_state viewport;
 
-   /* Clip state. */
-   struct pipe_clip_state clip;
-
    /* Destination surface dimensions. */
    unsigned dst_width;
    unsigned dst_height;
@@ -193,7 +190,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    ctx->dsa_write_depth_stencil =
       pipe->create_depth_stencil_alpha_state(pipe, &dsa);
 
-
    dsa.depth.enabled = 0;
    dsa.depth.writemask = 0;
    ctx->dsa_keep_depth_write_stencil =
@@ -212,6 +208,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    rs_state.cull_face = PIPE_FACE_NONE;
    rs_state.gl_rasterization_rules = 1;
    rs_state.flatshade = 1;
+   rs_state.depth_clip = 1;
    ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
 
    if (ctx->has_stream_out) {
@@ -439,7 +436,6 @@ static void blitter_restore_fragment_states(struct blitter_context_priv *ctx)
     * (depending on the operation) */
    pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
    pipe->set_viewport_state(pipe, &ctx->base.saved_viewport);
-   pipe->set_clip_state(pipe, &ctx->base.saved_clip);
 }
 
 static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx)
@@ -516,9 +512,6 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
    ctx->viewport.translate[2] = 0.0f;
    ctx->viewport.translate[3] = 0.0f;
    ctx->base.pipe->set_viewport_state(ctx->base.pipe, &ctx->viewport);
-
-   /* clip */
-   ctx->base.pipe->set_clip_state(ctx->base.pipe, &ctx->clip);
 }
 
 static void blitter_set_clear_color(struct blitter_context_priv *ctx,
index 4dd64c5164e607611a0a78a949a7465e0b7c7b3b..d4d30852b5849c09166a5e43a50ee278eff81d35 100644 (file)
@@ -94,7 +94,6 @@ struct blitter_context
    struct pipe_framebuffer_state saved_fb_state;  /**< framebuffer state */
    struct pipe_stencil_ref saved_stencil_ref;     /**< stencil ref */
    struct pipe_viewport_state saved_viewport;
-   struct pipe_clip_state saved_clip;
 
    int saved_num_sampler_states;
    void *saved_sampler_states[PIPE_MAX_SAMPLERS];
@@ -364,13 +363,6 @@ void util_blitter_save_viewport(struct blitter_context *blitter,
    blitter->saved_viewport = *state;
 }
 
-static INLINE
-void util_blitter_save_clip(struct blitter_context *blitter,
-                            struct pipe_clip_state *state)
-{
-   blitter->saved_clip = *state;
-}
-
 static INLINE
 void util_blitter_save_fragment_sampler_states(
                   struct blitter_context *blitter,
index e44c6194c77a3bf28b047d15e3fcd67bb0bf14c0..c728bc4021c7653fe1cd60c7982c2eccb52cda9c 100644 (file)
@@ -303,6 +303,8 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta
 
    util_dump_member(stream, bool, state, flatshade);
    util_dump_member(stream, bool, state, light_twoside);
+   util_dump_member(stream, bool, state, clamp_vertex_color);
+   util_dump_member(stream, bool, state, clamp_fragment_color);
    util_dump_member(stream, uint, state, front_ccw);
    util_dump_member(stream, uint, state, cull_face);
    util_dump_member(stream, uint, state, fill_front);
@@ -326,6 +328,9 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta
    util_dump_member(stream, bool, state, line_last_pixel);
    util_dump_member(stream, bool, state, flatshade_first);
    util_dump_member(stream, bool, state, gl_rasterization_rules);
+   util_dump_member(stream, bool, state, rasterizer_discard);
+   util_dump_member(stream, bool, state, depth_clip);
+   util_dump_member(stream, uint, state, clip_plane_enable);
 
    util_dump_member(stream, float, state, line_width);
    util_dump_member(stream, float, state, point_size);
@@ -413,8 +418,6 @@ util_dump_clip_state(FILE *stream, const struct pipe_clip_state *state)
    util_dump_array_end(stream);
    util_dump_member_end(stream);
 
-   util_dump_member(stream, uint, state, nr);
-
    util_dump_struct_end(stream);
 }
 
index 7cce815beba62cecee68599a9fc8b426006e68b7..a28d41825493bbd4ca1a1d0061409dec8e0e444a 100644 (file)
@@ -63,7 +63,6 @@ struct gen_mipmap_state
    struct pipe_depth_stencil_alpha_state depthstencil;
    struct pipe_rasterizer_state rasterizer;
    struct pipe_sampler_state sampler;
-   struct pipe_clip_state clip;
    struct pipe_vertex_element velem[2];
 
    void *vs;
@@ -1283,6 +1282,7 @@ util_create_gen_mipmap(struct pipe_context *pipe,
    memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
    ctx->rasterizer.cull_face = PIPE_FACE_NONE;
    ctx->rasterizer.gl_rasterization_rules = 1;
+   ctx->rasterizer.depth_clip = 1;
 
    /* sampler state */
    memset(&ctx->sampler, 0, sizeof(ctx->sampler));
@@ -1564,14 +1564,12 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_save_vertex_shader(ctx->cso);
    cso_save_geometry_shader(ctx->cso);
    cso_save_viewport(ctx->cso);
-   cso_save_clip(ctx->cso);
    cso_save_vertex_elements(ctx->cso);
 
    /* bind our state */
    cso_set_blend(ctx->cso, &ctx->blend);
    cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
-   cso_set_clip(ctx->cso, &ctx->clip);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
 
@@ -1688,7 +1686,6 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_restore_vertex_shader(ctx->cso);
    cso_restore_geometry_shader(ctx->cso);
    cso_restore_viewport(ctx->cso);
-   cso_restore_clip(ctx->cso);
    cso_restore_vertex_elements(ctx->cso);
    cso_restore_stream_outputs(ctx->cso);
 }
index 3631145b3b5c4decaf5d76774c9b8580966830e1..0f2210c2e159ecdfe7d259ee4d6216472c332bd0 100644 (file)
@@ -305,6 +305,7 @@ init_pipe_state(struct vl_compositor *c)
    rast.offset_units = 1;
    rast.offset_scale = 1;
    rast.gl_rasterization_rules = 1;
+   rast.depth_clip = 1;
 
    c->rast = c->pipe->create_rasterizer_state(c->pipe, &rast);
 
index 1486c00e7f0208b3c3e47d0aa7127a51efd4c42a..1166de017598f993593c9cdbf36232b44dbdd05c 100644 (file)
@@ -517,6 +517,7 @@ init_state(struct vl_idct *idct)
    memset(&rs_state, 0, sizeof(rs_state));
    rs_state.point_size = 1;
    rs_state.gl_rasterization_rules = true;
+   rs_state.depth_clip = 1;
    idct->rs_state = idct->pipe->create_rasterizer_state(idct->pipe, &rs_state);
    if (!idct->rs_state)
       goto error_rs_state;
index 0f41c687f4604f373e0a700a8394f1f232dea503..976b526d1a3ee44b9e5b53dc4c09d9402909aadd 100644 (file)
@@ -429,6 +429,7 @@ init_pipe_state(struct vl_mc *r)
    rs_state.point_quad_rasterization = true;
    rs_state.point_size = BLOCK_WIDTH;
    rs_state.gl_rasterization_rules = true;
+   rs_state.depth_clip = 1;
    r->rs_state = r->pipe->create_rasterizer_state(r->pipe, &rs_state);
    if (!r->rs_state)
       goto error_rs_state;
index 730074c0c57bf46b04293566a5911e0e463ef476..6ff4056a241edd9216afd776946b89d8f02124de 100644 (file)
@@ -270,6 +270,7 @@ init_state(struct vl_zscan *zscan)
 
    memset(&rs_state, 0, sizeof(rs_state));
    rs_state.gl_rasterization_rules = true;
+   rs_state.depth_clip = 1;
    zscan->rs_state = zscan->pipe->create_rasterizer_state(zscan->pipe, &rs_state);
    if (!zscan->rs_state)
       goto error_rs_state;
index a3836d9286ade43e9ab6601695ef3ddb23ce5327..482b1ea02c938d4800a7e4e05c10dd5bb9dc8b64 100644 (file)
@@ -227,3 +227,17 @@ gl_rasterization_rules
     Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set,
     the rasterizer will use (0, 0) for pixel centers.
 
+depth_clip
+    When false, the near and far depth clipping planes of the view volume are
+    disabled and the depth value will be clamped at the per-pixel level, after
+    polygon offset has been applied and before depth testing.
+
+clip_plane_enable
+    For each k in [0, PIPE_MAX_CLIP_PLANES), if bit k of this field is set,
+    clipping half-space k is enabled, if it is clear, it is disabled.
+    The clipping half-spaces are defined either by the user clip planes in
+    ``pipe_clip_state``, or by the clip distance outputs of the shader stage
+    preceding the fragment shader.
+    If any clip distance output is written, those half-spaces for which no
+    clip distance is written count as disabled; i.e. user clip planes and
+    shader clip distances cannot be mixed, and clip distances take precedence.
index 7e7010f407ff41e98c200509b25c89dbc94f1f5f..fda21a21ed41ef739e1cb1f9dbd7c9bd10053fc1 100644 (file)
@@ -1754,6 +1754,17 @@ Specifies that writes to the fragment shader color 0 are replicated to all
 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
 fragData is directed to a single color buffer, but fragColor is broadcast.
 
+VS_PROHIBIT_UCPS
+""""""""""""""""""""""""""
+If this property is set on the program bound to the shader stage before the
+fragment shader, user clip planes should have no effect (be disabled) even if
+that shader does not write to any clip distance outputs and the rasterizer's
+clip_plane_enable is non-zero.
+This property is only supported by drivers that also support shader clip
+distance outputs.
+This is useful for APIs that don't have UCPs and where clip distances written
+by a shader cannot be disabled.
+
 
 Texture Sampling and Texture Formats
 ------------------------------------
index 2a64ba4dbab2cbdd1a4d44f58420ef5293a0ffc5..5444425d5ea445886f4175de60213db9832a4602 100644 (file)
@@ -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:
index 731d2f6d988ad135b6671a48c2029ee8954e74d1..1d1b6f7d5eec071ff559deb806914cb9bcb12489 100644 (file)
@@ -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);
index 98b838be4dbd92b31ce414b9c32accd1e0acb8ba..5798a19e5f7fd724eadb8ae67be9f2df57092f11 100644 (file)
@@ -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:
index 15f579efb86bf534159d03243a175736e67c634b..4f22284c3a6fb423b0a87f875c2add20bfb7dd82 100644 (file)
@@ -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;
index d73f7c7f213f80d8f5e2b99bd0df1ce715d24a3a..d3cdb69796091ca58dfd4d4a4dca78e3bba786d0 100644 (file)
@@ -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;
 
index ede8713ae76e99f4912b6ebfff301b9f80487d38..0f46afb882b5f1f76a336426336390a76ffb7e2f 100644 (file)
@@ -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;
 }
index 05f32ea78d2447750a9f93d495ded30b12c9fcb8..edf648e5533a039c7d3849abbac033a8fbe9e0a1 100644 (file)
@@ -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 },
index 83a08b0bd3de0095bfe711ca9a2848db0a6a8c77..c443dfbfec643fd8954553e6229505a5768284bd 100644 (file)
@@ -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 {
index 910e18ff03c3e47a0891a0c349769dbb85dfb33f..28e34bd9ef6ab02e93a6ec1ca972e4cdca90f3d8 100644 (file)
@@ -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) {
index 8c14f9e61aa91d74ce1533bb177fa645bda7eba0..069e68f1a555a5da1899bf3fccd7124e3fe9f118 100644 (file)
@@ -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;
index 446bd948a5376390ab3f8c481303adf71ef36a9e..630ad20c31d3c642b5fc30ae110289ef5cc1ea89 100644 (file)
@@ -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
index 1e334a01d87726fc70ee5ae5562def3d52974245..32b7a8a8ecfcf3fead62e23b6bb12b9e2aa9e8d3 100644 (file)
@@ -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;
 }
index 0dc822a2f15a9899276e4c018cbfc3018d4aba76..472ddee52164da46fe94776bdc0a3069614c8b6c 100644 (file)
@@ -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 },
index 5c0d0c1149b74b6306c8cbae143d3ab340d046dd..dc5771a03aa5adf07fa599d5b1d32559a73619c9 100644 (file)
@@ -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 {
index a2e1a8539958b93c31a83f2616ab92b9aa427617..46b5da551db35711ad529639cf0ddf4f7abaaba0 100644 (file)
@@ -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) {
index abf4937e8cb29d7cf034c28f9c40bde3c29df263..b4a1b3ac0d9d894dfa0b07d4a738c9fb49a210ff 100644 (file)
@@ -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
index ae9c31418c3c097a3e9650bb3b6be7b8f3d45487..25da80e8433a52c49e22ea41d36f88536b48d8d6 100644 (file)
@@ -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)
                {
index d489bbf9473360f9514fa248ef677a064ae3f58b..cac3fcaabc01ed52178f7deb9d194644dd06c6cd 100644 (file)
@@ -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);
 
index c780c8dd1ad2be6c1db2f4c03ab551862e732f9a..d1326380f3db0257cf7f212e358a37831db7a98a 100644 (file)
@@ -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);
index fb9f34a1ed3aed005f62372ddc91daf48cc3b0a5..7d289ca6346e3a5d326cb69c33f02c59da7f0775 100644 (file)
@@ -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);
index 5588e51ada943ecafa0664de2057bde833e0f36c..e40b7af45dd35e1ba0ea1c0af955c4d1a32d6ea9 100644 (file)
@@ -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. */
index f85464436929d7ca4615aace8ec9ceadab39d50c..2266b48c948511536dd34afb2a1e1989ac08b73e 100644 (file)
@@ -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;
     }
 }
 
index 7f04c93e418a867037dbd8dab9514f3d3e35e2e9..83cad42c4158085c7959620befdf074337152346 100644 (file)
@@ -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);
 
index d79ed99aee716daef575beae9954a47671b10c07..763321b480ef1654dbc2a24dfb83a33f88865ecc 100644 (file)
@@ -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:
index 3606e0bf505d028385f6bcda54b82fd112f129d4..2bc703669ae449c2bb28a1e675b55daa57e8dac7 100644 (file)
@@ -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);
index 7ded03d4428238e3a9e2ad4fa83a9efdea6fcc7f..f3aab69dec50d66d61a93b5a4ce19ab37dcffbd9 100644 (file)
@@ -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;
index 9ad247a3a0a2ad4623f94029c9beadabd27867c8..6947c99c2ee9ff24a5090020fa06461b685b1dc2 100644 (file)
@@ -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);
index 4a31b43269aa352c8a30ed389ec1f07d753d3245..e50b5cc3d160ac3eef92f79a6f9ea8c3a9535f2d 100644 (file)
@@ -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:
index 12157ffd797a2ab9344505315662b95397833460..5fe038e79e5dc215c507e2dcf8ac93cdbea28ae9 100644 (file)
@@ -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;
index 8c0dddf7ae758c4e5183143638bbb5ba48297fac..f3625e0de301752a460b0d88bc99557a1bf522f7 100644 (file)
@@ -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 ]
index a4d56bd73946b57f5f8f3c13e080038da7e7b53d..d94ac35c644a49b8a3e50f0733919d2cf2fbfdd6 100644 (file)
@@ -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 );
    }
 
index 038a80ef945437d2ed803d654163f4a77fb23b63..8af084c2769201ffe60a7735f63541d70e28a4fa 100644 (file)
@@ -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();
 }
 
index 91d8b1e4525832f874ea2656e246febad5d97f4e..4425fc9f9464b59d8ee828fc9139bcb480a2865e 100644 (file)
@@ -468,7 +468,7 @@ enum pipe_cap {
    PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT = 38,
    PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER = 39,
    PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER = 40,
-   PIPE_CAP_DEPTH_CLAMP = 41,
+   PIPE_CAP_DEPTH_CLIP_DISABLE = 41,
    PIPE_CAP_SHADER_STENCIL_EXPORT = 42,
    PIPE_CAP_TGSI_INSTANCEID = 43,
    PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR = 44,
index 75e17a1f74edecaa93d518fdb15b5a1f31151cad..2fbe1df831220cf733d389166df5cee4fb688bac 100644 (file)
@@ -191,7 +191,8 @@ union tgsi_immediate_data
 #define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER  4
 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5
 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
-#define TGSI_PROPERTY_COUNT                  7
+#define TGSI_PROPERTY_VS_PROHIBIT_UCPS       7
+#define TGSI_PROPERTY_COUNT                  8
 
 struct tgsi_property {
    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
index f943ca58b88fe31cfd1bee6c882576de5656afeb..024d544e3ef271fa3ad4c3fac5e3acc5faeb9f36 100644 (file)
@@ -127,6 +127,22 @@ struct pipe_rasterizer_state
     */
    unsigned rasterizer_discard:1;
 
+   /**
+    * When false, depth clipping is disabled and the depth value will be
+    * clamped later at the per-pixel level before depth testing.
+    * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.
+    */
+   unsigned depth_clip:1;
+
+   /**
+    * Enable bits for clipping half-spaces.
+    * This applies to both user clip planes and shader clip distances.
+    * Note that if the bound shader exports any clip distances, these
+    * replace all user clip planes, and clip half-spaces enabled here
+    * but not written by the shader count as disabled.
+    */
+   unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES;
+
    unsigned line_stipple_factor:8;  /**< [1..256] actually */
    unsigned line_stipple_pattern:16;
 
@@ -165,8 +181,6 @@ struct pipe_scissor_state
 struct pipe_clip_state
 {
    float ucp[PIPE_MAX_CLIP_PLANES][4];
-   unsigned nr;
-   unsigned depth_clamp:1;
 };
 
 
index 2828389cebfcf8285f8a044bc4a623050d65b792..5d581aa2e3f6ddf5e00da3ce276477f29b893d96 100644 (file)
@@ -754,6 +754,7 @@ struct dxgi_blitter
                memset(&rs_state, 0, sizeof(rs_state));
                rs_state.cull_face = PIPE_FACE_NONE;
                rs_state.gl_rasterization_rules = 1;
+               rs_state.depth_clip = 1;
                rs_state.flatshade = 1;
                rasterizer = pipe->create_rasterizer_state(pipe, &rs_state);
 
index a64e8d195a977cc18a9ff628f8d3971ff58038c8..da3cc237c7ba7e09c2867ea4df6a1077118eaa15 100644 (file)
@@ -75,7 +75,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
        float blend_color[4];
        unsigned sample_mask;
        unsigned stencil_ref;
-       bool depth_clamp;
 
        void* default_input_layout;
        void* default_rasterizer;
@@ -169,7 +168,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                memset(blend_color, 0, sizeof(blend_color));
                sample_mask = ~0;
                stencil_ref = 0;
-               depth_clamp = 0;
 
                // derived state
                primitive_mode = 0;
@@ -194,6 +192,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                rasterizerd.flatshade_first = 1;
                rasterizerd.line_width = 1.0f;
                rasterizerd.point_size = 1.0f;
+               rasterizerd.depth_clip = TRUE;
                default_rasterizer = pipe->create_rasterizer_state(pipe, &rasterizerd);
 
                struct pipe_depth_stencil_alpha_state depth_stencild;
@@ -938,14 +937,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
        }
 #endif
 
-       void set_clip()
-       {
-               pipe_clip_state clip;
-               clip.nr = 0;
-               clip.depth_clamp = depth_clamp;
-               pipe->set_clip_state(pipe, &clip);
-       }
-
        virtual void STDMETHODCALLTYPE RSSetState(
                ID3D11RasterizerState *new_rasterizer_state)
        {
@@ -954,12 +945,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                {
                        rasterizer_state = new_rasterizer_state;
                        pipe->bind_rasterizer_state(pipe, new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->object : default_rasterizer);
-                       bool new_depth_clamp = new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->depth_clamp : false;
-                       if(depth_clamp != new_depth_clamp)
-                       {
-                               depth_clamp = new_depth_clamp;
-                               set_clip();
-                       }
                }
        }
 
@@ -1688,7 +1673,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                        pipe->set_stream_output_targets(pipe, num_so_targets, so_targets, ~0);
                set_framebuffer();
                set_viewport();
-               set_clip();
                set_render_condition();
 
                update_flags |= UPDATE_VERTEX_BUFFERS | (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_PS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_PS));
index e1ef7b807beffacbeac8643912db7fad42a209fd..faeb30617b9c39f37ce1a37f5a6c2640335f307b 100644 (file)
@@ -210,10 +210,8 @@ struct GalliumD3D10BlendState : public GalliumD3D10BlendStateBase
 
 struct GalliumD3D11RasterizerState : public GalliumD3D11RasterizerStateBase
 {
-       bool depth_clamp;
-
-       GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc, bool depth_clamp)
-       : GalliumD3D11RasterizerStateBase(device, object, desc), depth_clamp(depth_clamp)
+       GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc)
+       : GalliumD3D11RasterizerStateBase(device, object, desc)
        {}
 };
 
index e64e1f6b3fc6ec9ed7c3bc10879b6b166ab86ee6..31e59bf38b116695c9130645d320bc320ace74fb 100644 (file)
@@ -578,6 +578,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                state.offset_scale = rasterizer_desc->SlopeScaledDepthBias;
                state.offset_units = rasterizer_desc->DepthBias;
                state.offset_clamp = rasterizer_desc->DepthBiasClamp;
+               state.depth_clip = rasterizer_desc->DepthClipEnable;
                state.scissor = !!rasterizer_desc->ScissorEnable;
                state.multisample = !!rasterizer_desc->MultisampleEnable;
                state.line_smooth = !!rasterizer_desc->AntialiasedLineEnable;
@@ -595,7 +596,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                if(!object)
                        return E_FAIL;
 
-               *out_rasterizer_state = new GalliumD3D11RasterizerState(this, object, *rasterizer_desc, !rasterizer_desc->DepthClipEnable);
+               *out_rasterizer_state = new GalliumD3D11RasterizerState(this, object, *rasterizer_desc);
                return S_OK;
        }
 
index e4c1fd5e3a36976229f852ca7f315b0744e6194d..add1eec00385b11473aebace171a08f6e638488d 100644 (file)
@@ -1187,6 +1187,7 @@ struct renderer * renderer_create(struct vg_context *owner)
    raster = &renderer->g3d.rasterizer;
    memset(raster, 0, sizeof(*raster));
    raster->gl_rasterization_rules = 1;
+   raster->depth_clip = 1;
    cso_set_rasterizer(renderer->cso, raster);
 
    /* fixed at 0 */
index 5496fc04bfedb3605b2c47333a1284f6b0f60038..7052f396c3aadb81fe235bab53250d09d68a958f 100644 (file)
@@ -130,6 +130,7 @@ renderer_init_state(struct xa_context *r)
     /* XXX: move to renderer_init_state? */
     memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
     raster.gl_rasterization_rules = 1;
+    raster.depth_clip = 1;
     cso_set_rasterizer(r->cso, &raster);
 
     /* vertex elements state */
index 6b799af90c8a1cc613f8a3b9a34b09da7662bdb5..eba72d81908defcda8d81a87445b1a937dddf096 100644 (file)
@@ -107,6 +107,7 @@ renderer_init_state(struct xorg_renderer *r)
    /* XXX: move to renderer_init_state? */
    memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
    raster.gl_rasterization_rules = 1;
+   raster.depth_clip = 1;
    cso_set_rasterizer(r->cso, &raster);
 
    /* vertex elements state */
index d9e70f074768a902a39c36e65a7d3d4d726c5db1..f8b2a0a77a0a36425bf3df664bcaafc1f51f7198 100644 (file)
@@ -504,6 +504,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index e95306e82721a9f378ee8c35e74f60c57daef0d9..ef2440291fc28f95bbee360eca596c353bd0b638 100644 (file)
@@ -567,6 +567,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 561234694f4e29a585e00264ae2763afd5e81b8c..712ff515befdd7f7ddbf049c3cc1ff5d8270b47f 100644 (file)
@@ -377,6 +377,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index a2749cab3695d0dbb267bc89b7952ec4aed5baca..96c6f3fdc8e31cb29f6f79c2c4666306c7d8664d 100644 (file)
@@ -375,6 +375,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 57cd2dc2b12ded168bc3a3989eaf900b9f08b626..103aa6d3f3a97d1dc2fac91deb2f2dd64cf79bba 100644 (file)
@@ -249,6 +249,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 43486636ff780ac97a17fe61c9395c6039bcda03..733263133ca4e4450703bf4d871f0e963d5644d8 100644 (file)
@@ -254,6 +254,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 521dab04da9d842aa8639ef17cb65631a442a156..837381592c26648acdaf974a8b2c6e3aa9c6805a 100644 (file)
@@ -304,6 +304,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 11f8bb35cafc2937f2a351e0f71bc813dc24be26..fc5d66ad18fda694a6b499e00ffd9fceeaba70b1 100644 (file)
@@ -239,6 +239,7 @@ static void init( void )
       memset(&rasterizer, 0, sizeof rasterizer);
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 74b3273192c0ab8f6a43f923a7a92c7dfcdd3319..83d86fbf5b253ea73434d9add08a9d897849e6e3 100644 (file)
@@ -456,6 +456,7 @@ static void init( void )
       rasterizer.cull_face = PIPE_FACE_NONE;
       rasterizer.point_size = 8.0;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = 1;
       handle = ctx->create_rasterizer_state(ctx, &rasterizer);
       ctx->bind_rasterizer_state(ctx, handle);
    }
index 79c66e0e67e4c0246312bc4295963aa082274f21..cc19e8d5eece058804cc38571c97344a6b9bbfbb 100644 (file)
@@ -201,6 +201,7 @@ static void init_prog(struct program *p)
        memset(&p->rasterizer, 0, sizeof(p->rasterizer));
        p->rasterizer.cull_face = PIPE_FACE_NONE;
        p->rasterizer.gl_rasterization_rules = 1;
+       p->rasterizer.depth_clip = 1;
 
        /* sampler */
        memset(&p->sampler, 0, sizeof(p->sampler));
index d036db8003909cb89f5d4eee9c5b83cd273a4462..9190f7824e91e6865fe0c9fd0e2d40968a74af1b 100644 (file)
@@ -152,6 +152,7 @@ static void init_prog(struct program *p)
        memset(&p->rasterizer, 0, sizeof(p->rasterizer));
        p->rasterizer.cull_face = PIPE_FACE_NONE;
        p->rasterizer.gl_rasterization_rules = 1;
+       p->rasterizer.depth_clip = 1;
 
        surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM;
        surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
index 236d3cf409d814c8ce3b4404ad531322adaf0e75..2a51100984aa2cc7620a76fead30348da9da6e58 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe/p_context.h"
 #include "st_atom.h"
 #include "st_program.h"
+#include "util/u_debug.h"
 #include "cso_cache/cso_context.h"
 
 
@@ -44,10 +45,9 @@ static void update_clip( struct st_context *st )
 {
    struct pipe_clip_state clip;
    const struct gl_context *ctx = st->ctx;
-   GLuint i;
    bool use_eye = FALSE;
 
-   memset(&clip, 0, sizeof(clip));
+   assert(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane));
 
    /* if we have a vertex shader that writes clip vertex we need to pass
       the pre-projection transformed coordinates into the driver. */
@@ -56,21 +56,11 @@ static void update_clip( struct st_context *st )
          use_eye = TRUE;
    }
 
-   for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) {
-      if (ctx->Transform.ClipPlanesEnabled & (1 << i)) {
-         memcpy(clip.ucp[clip.nr],
-                use_eye ? ctx->Transform.EyeUserPlane[i] : ctx->Transform._ClipUserPlane[i],
-                sizeof(clip.ucp[0]));
-         clip.nr++;
-      }
-   }
-
-   clip.depth_clamp = ctx->Transform.DepthClamp != GL_FALSE;
-      
-   if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) {
-      st->state.clip = clip;
-      cso_set_clip(st->cso_context, &clip);
-   }
+   memcpy(clip.ucp,
+          use_eye ? ctx->Transform.EyeUserPlane
+                  : ctx->Transform._ClipUserPlane, sizeof(clip.ucp));
+   st->state.clip = clip;
+   cso_set_clip(st->cso_context, &clip);
 }
 
 
index 2d6ad45bad9a9318b9820e96ea5e983a423f3506..f3d28e675f53d64c64f9f65f77fb791a8e5756a7 100644 (file)
@@ -261,6 +261,10 @@ static void update_raster_state( struct st_context *st )
    /* _NEW_RASTERIZER_DISCARD */
    raster->rasterizer_discard = ctx->RasterDiscard;
 
+   /* _NEW_TRANSFORM */
+   raster->depth_clip = ctx->Transform.DepthClamp == GL_FALSE;
+   raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
+
    cso_set_rasterizer(st->cso_context, raster);
 }
 
@@ -276,7 +280,8 @@ const struct st_tracked_state st_update_rasterizer = {
        _NEW_PROGRAM |
        _NEW_SCISSOR |
        _NEW_FRAG_CLAMP |
-       _NEW_RASTERIZER_DISCARD),      /* mesa state dependencies*/
+       _NEW_RASTERIZER_DISCARD |
+       _NEW_TRANSFORM),      /* mesa state dependencies*/
       ST_NEW_VERTEX_PROGRAM,  /* state tracker dependencies */
    },
    update_raster_state     /* update function */
index af33bcf86054bcbce1031b8e215954dbb9b15713..a9709680208c11da474f3d786a3558e3bbbdd0b9 100644 (file)
@@ -870,6 +870,7 @@ st_init_bitmap(struct st_context *st)
    /* init baseline rasterizer state once */
    memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer));
    st->bitmap.rasterizer.gl_rasterization_rules = 1;
+   st->bitmap.rasterizer.depth_clip = 1;
 
    /* find a usable texture format */
    if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM,
index 23700eeb7ed1e3852df53998f98b51a174fb3d7e..a8365a70843869773a04d994def43af90d5a8242 100644 (file)
@@ -68,6 +68,7 @@ st_init_clear(struct st_context *st)
    memset(&st->clear, 0, sizeof(st->clear));
 
    st->clear.raster.gl_rasterization_rules = 1;
+   st->clear.raster.depth_clip = 1;
    st->clear.enable_ds_separate = pscreen->get_param(pscreen, PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE);
 }
 
@@ -248,7 +249,6 @@ clear_with_quad(struct gl_context *ctx,
    cso_save_depth_stencil_alpha(st->cso_context);
    cso_save_rasterizer(st->cso_context);
    cso_save_viewport(st->cso_context);
-   cso_save_clip(st->cso_context);
    cso_save_fragment_shader(st->cso_context);
    cso_save_stream_outputs(st->cso_context);
    cso_save_vertex_shader(st->cso_context);
@@ -326,7 +326,6 @@ clear_with_quad(struct gl_context *ctx,
       cso_set_viewport(st->cso_context, &vp);
    }
 
-   cso_set_clip(st->cso_context, &st->clear.clip);
    set_fragment_shader(st);
    set_vertex_shader(st);
    cso_set_geometry_shader_handle(st->cso_context, NULL);
@@ -346,7 +345,6 @@ clear_with_quad(struct gl_context *ctx,
    cso_restore_depth_stencil_alpha(st->cso_context);
    cso_restore_rasterizer(st->cso_context);
    cso_restore_viewport(st->cso_context);
-   cso_restore_clip(st->cso_context);
    cso_restore_fragment_shader(st->cso_context);
    cso_restore_vertex_shader(st->cso_context);
    cso_restore_geometry_shader(st->cso_context);
index 0609a54eab098eb349f3f1d8a1fd5069d755214b..13c4f3369cc96fae6f4a1b1276c6e923d99621c4 100644 (file)
@@ -686,6 +686,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       memset(&rasterizer, 0, sizeof(rasterizer));
       rasterizer.clamp_fragment_color = ctx->Color._ClampFragmentColor;
       rasterizer.gl_rasterization_rules = 1;
+      rasterizer.depth_clip = !ctx->Transform.DepthClamp;
       rasterizer.scissor = ctx->Scissor.Enabled;
       cso_set_rasterizer(cso, &rasterizer);
    }
index c60780989638843981814760a5ffb85a9781375d..9db50b3f4c8fc874177cb578670c014a42cd5244 100644 (file)
@@ -167,7 +167,6 @@ struct st_context
    struct {
       struct pipe_rasterizer_state raster;
       struct pipe_viewport_state viewport;
-      struct pipe_clip_state clip;
       void *vs;
       void *fs;
       float vertices[4][2][4];  /**< vertex pos + color */
index 4c8c67fca089eb9dc57c5158ac4a3cfa90bb2793..a9d40543638316faed6ccd036382b7a7414310d8 100644 (file)
@@ -592,7 +592,7 @@ void st_init_extensions(struct st_context *st)
       st->sw_primitive_restart = GL_TRUE;
    }
 
-   if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) {
+   if (screen->get_param(screen, PIPE_CAP_DEPTH_CLIP_DISABLE)) {
       ctx->Extensions.ARB_depth_clamp = GL_TRUE;
    }