[Mesa-dev] [PATCH 1/2] gallium: Add a new clip_halfz rasterizer state.
jfonseca at vmware.com
jfonseca at vmware.com
Sat Apr 20 14:38:12 PDT 2013
From: José Fonseca <jfonseca at vmware.com>
gl_rasterization_rules lumps too many different flags.
---
src/gallium/auxiliary/draw/draw_context.c | 1 +
src/gallium/auxiliary/draw/draw_llvm.c | 2 +-
src/gallium/auxiliary/draw/draw_pt.h | 2 +-
.../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 9 +++------
.../draw/draw_pt_fetch_shade_pipeline_llvm.c | 9 +++------
src/gallium/auxiliary/draw/draw_pt_post_vs.c | 8 ++++----
src/gallium/docs/source/cso/rasterizer.rst | 4 ++++
src/gallium/include/pipe/p_state.h | 6 ++++++
8 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 0f98021..5272951 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -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);
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index e0c0705..e1c08c6 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -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;
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index 764d311..dca8368 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -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 );
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index e17f161..8e48f46 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -105,17 +105,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 );
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index d312dc4..4dff4f8 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -156,17 +156,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 );
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index a83bb59..681a12d 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -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,12 +152,12 @@ 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) {
+ if (clip_z && !clip_halfz) {
pvs->flags |= DO_CLIP_FULL_Z;
ASSIGN_4V( pvs->draw->plane[4], 0, 0, 1, 1 );
}
- if (clip_z && !opengl) {
+ if (clip_z && clip_halfz) {
pvs->flags |= DO_CLIP_HALF_Z;
ASSIGN_4V( pvs->draw->plane[4], 0, 0, 1, 0 );
}
diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst
index 8338243..be4bad5 100644
--- a/src/gallium/docs/source/cso/rasterizer.rst
+++ b/src/gallium/docs/source/cso/rasterizer.rst
@@ -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
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index dfafd0b..5da3a53 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -134,6 +134,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.
* Note that if the bound shader exports any clip distances, these
--
1.7.9.5
More information about the mesa-dev
mailing list