gallium: Add a new clip_halfz rasterizer state.
authorJosé Fonseca <jfonseca@vmware.com>
Sat, 20 Apr 2013 11:24:44 +0000 (12:24 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 22 Apr 2013 17:39:06 +0000 (18:39 +0100)
gl_rasterization_rules lumps too many different flags.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
src/gallium/auxiliary/draw/draw_pt_post_vs.c
src/gallium/docs/source/cso/rasterizer.rst
src/gallium/include/pipe/p_state.h

index 0f98021247ab799719dca79752710cd6875ff341..5272951d2b377bb6f2860caaedbefbf6d3192853 100644 (file)
@@ -712,6 +712,7 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
       rast.flatshade = flatshade;
       rast.front_ccw = 1;
       rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules;
+      rast.clip_halfz = draw->rasterizer->clip_halfz;
 
       draw->rasterizer_no_cull[scissor][flatshade] =
          pipe->create_rasterizer_state(pipe, &rast);
index e0c07057441c5cb0fa43a36386e8fcc413ac6bb5..e1c08c6b58daa7b24c94971662c824aa2f30da02 100644 (file)
@@ -1669,7 +1669,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
    key->clip_z = llvm->draw->clip_z;
    key->clip_user = llvm->draw->clip_user;
    key->bypass_viewport = llvm->draw->identity_viewport;
-   key->clip_halfz = !llvm->draw->rasterizer->gl_rasterization_rules;
+   key->clip_halfz = llvm->draw->rasterizer->clip_halfz;
    key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE);
    key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
    key->has_gs = llvm->draw->gs.geometry_shader != NULL;
index 764d3111755fc61ff682e11eaeb0bb04db410360..dca836859cc258b0acbfffb466e5422b6b49de9b 100644 (file)
@@ -233,7 +233,7 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean clip_user,
                               boolean guard_band,
                              boolean bypass_viewport,
-                             boolean opengl,
+                              boolean clip_halfz,
                              boolean need_edgeflags );
 
 struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
index ab32a8033ac2787e0e294567b9722572974714ce..664c5949e8cc40c424fdbb7880c8d9392afa6014 100644 (file)
@@ -107,17 +107,14 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
                           vs->info.num_inputs,
                           fpme->vertex_size,
                           instance_id_index );
-   /* XXX: it's not really gl rasterization rules we care about here,
-    * but gl vs dx9 clip spaces.
-    */
    draw_pt_post_vs_prepare( fpme->post_vs,
                            draw->clip_xy,
                            draw->clip_z,
                            draw->clip_user,
                             draw->guard_band_xy,
-                           draw->identity_viewport,
-                           (boolean)draw->rasterizer->gl_rasterization_rules,
-                           (draw->vs.edgeflag_output ? TRUE : FALSE) );
+                            draw->identity_viewport,
+                            draw->rasterizer->clip_halfz,
+                            (draw->vs.edgeflag_output ? TRUE : FALSE) );
 
    draw_pt_so_emit_prepare( fpme->so_emit, FALSE );
 
index 31bd7ce734d3a4c75bc07f5428b15579fc176953..7ce845ed7daf421fc86ca4724b61759e0fd78e8c 100644 (file)
@@ -158,17 +158,14 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
    fpme->vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float);
 
 
-   /* XXX: it's not really gl rasterization rules we care about here,
-    * but gl vs dx9 clip spaces.
-    */
    draw_pt_post_vs_prepare( fpme->post_vs,
                            draw->clip_xy,
                            draw->clip_z,
                            draw->clip_user,
                             draw->guard_band_xy,
-                           draw->identity_viewport,
-                           (boolean)draw->rasterizer->gl_rasterization_rules,
-                           (draw->vs.edgeflag_output ? TRUE : FALSE) );
+                            draw->identity_viewport,
+                            draw->rasterizer->clip_halfz,
+                            (draw->vs.edgeflag_output ? TRUE : FALSE) );
 
    draw_pt_so_emit_prepare( fpme->so_emit, gs == NULL );
 
index a83bb59a748433bf15bc5a8634e1933b2b5e4d00..021265633f764239eefad91da820253efe9cb53c 100644 (file)
@@ -127,14 +127,14 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                               boolean clip_user,
                               boolean guard_band,
                              boolean bypass_viewport,
-                             boolean opengl,
+                              boolean clip_halfz,
                              boolean need_edgeflags )
 {
    pvs->flags = 0;
 
    /* This combination not currently tested/in use:
     */
-   if (opengl)
+   if (!clip_halfz)
       guard_band = FALSE;
 
    if (clip_xy && !guard_band) {
@@ -152,14 +152,14 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
       ASSIGN_4V( pvs->draw->plane[3],  0,  0.5,  0, 1 );
    }
 
-   if (clip_z && opengl) {
-      pvs->flags |= DO_CLIP_FULL_Z;
-      ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 1 );
-   }
-
-   if (clip_z && !opengl) {
-      pvs->flags |= DO_CLIP_HALF_Z;
-      ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 0 );
+   if (clip_z) {
+      if (clip_halfz) {
+         pvs->flags |= DO_CLIP_HALF_Z;
+         ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 0 );
+      } else {
+         pvs->flags |= DO_CLIP_FULL_Z;
+         ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 1 );
+      }
    }
 
    if (clip_user)
index 8338243be9f19a257702e279bb34796de8c025d8..be4bad56c0022fa42e7efcbd16e888a1cb6f1c65 100644 (file)
@@ -242,6 +242,10 @@ 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.
 
+clip_halfz
+    When true clip space in the z axis goes from [0..1] (D3D).  When false
+    [-1, 1] (GL)
+
 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
index dfafd0bb99f0414adb900d3de13fdee79f080507..5da3a533e8537aeddca4fbad3ecbc6303882cddd 100644 (file)
@@ -133,6 +133,12 @@ struct pipe_rasterizer_state
     */
    unsigned depth_clip:1;
 
+   /**
+    * When true clip space in the z axis goes from [0..1] (D3D).  When false
+    * [-1, 1] (GL).
+    */
+   unsigned clip_halfz:1;
+
    /**
     * Enable bits for clipping half-spaces.
     * This applies to both user clip planes and shader clip distances.