summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-08-27 17:02:27 -0700
committerKenneth Graunke <[email protected]>2015-09-03 22:31:03 -0700
commit082b7f1876095f32578720f30fdc35771b2b3e0a (patch)
tree2d13e631d4ba29d65a5e82ddad83bf98ae30a809
parent294282aaa6a517b455d3e31d12e2d85516ac04e6 (diff)
i965: Delete the brw_vue_program_key::userclip_active flag.
There are two uses of this flag. The primary use is checking whether we need to emit code to convert legacy gl_ClipVertex/gl_Position clipping to clip distances. In this case, we also have to upload the clip planes as uniforms, which means setting nr_userclip_plane_consts to a positive value. Checking if it's > 0 works for detecting this case. Gen4-5 also wants to know whether we're doing clipping at all, so it can emit user clip flags. Checking if output_reg[VARYING_SLOT_CLIP_DIST0] is set to a real register suffices for this. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.h9
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp7
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c17
5 files changed, 15 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 504673f8bd9..7100646750e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -810,7 +810,7 @@ void fs_visitor::compute_clip_distance(gl_clip_plane *clip_planes)
(const struct brw_vue_prog_key *) this->key;
/* Bail unless some sort of legacy clipping is enabled */
- if (!key->userclip_active || prog->UsesClipDistanceOut)
+ if (key->nr_userclip_plane_consts == 0)
return;
/* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index bfcd1c93178..5ebf9226cdd 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -82,14 +82,11 @@ struct brw_vue_prog_key {
unsigned program_string_id;
/**
- * True if at least one clip flag is enabled, regardless of whether the
- * shader uses clip planes or gl_ClipDistance.
- */
- bool userclip_active:1;
-
- /**
* How many user clipping planes are being uploaded to the vertex shader as
* push constants.
+ *
+ * These are used for lowering legacy gl_ClipVertex/gl_Position clipping to
+ * clip distances.
*/
unsigned nr_userclip_plane_consts:4;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 501461c6d94..0c2326c9cec 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1750,7 +1750,7 @@ vec4_visitor::run(gl_clip_plane *clip_planes)
}
base_ir = NULL;
- if (key->userclip_active && !prog->UsesClipDistanceOut)
+ if (key->nr_userclip_plane_consts > 0)
setup_uniform_clipplane_values(clip_planes);
emit_thread_end();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index ca86e8b6d56..4d3d28164b5 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3121,7 +3121,8 @@ vec4_visitor::emit_psiz_and_flags(dst_reg reg)
{
if (devinfo->gen < 6 &&
((prog_data->vue_map.slots_valid & VARYING_BIT_PSIZ) ||
- key->userclip_active || devinfo->has_negative_rhw_bug)) {
+ output_reg[VARYING_SLOT_CLIP_DIST0].file != BAD_FILE ||
+ devinfo->has_negative_rhw_bug)) {
dst_reg header1 = dst_reg(this, glsl_type::uvec4_type);
dst_reg header1_w = header1;
header1_w.writemask = WRITEMASK_W;
@@ -3136,7 +3137,7 @@ vec4_visitor::emit_psiz_and_flags(dst_reg reg)
emit(AND(header1_w, src_reg(header1_w), 0x7ff << 8));
}
- if (key->userclip_active) {
+ if (output_reg[VARYING_SLOT_CLIP_DIST0].file != BAD_FILE) {
current_annotation = "Clipping flags";
dst_reg flags0 = dst_reg(this, glsl_type::uint_type);
dst_reg flags1 = dst_reg(this, glsl_type::uint_type);
@@ -3354,7 +3355,7 @@ vec4_visitor::emit_vertex()
}
/* Lower legacy ff and ClipVertex clipping to clip distances */
- if (key->userclip_active && !prog->UsesClipDistanceOut) {
+ if (key->nr_userclip_plane_consts > 0) {
current_annotation = "user clip distances";
output_reg[VARYING_SLOT_CLIP_DIST0] = dst_reg(this, glsl_type::vec4_type);
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 211929a5235..365396825dc 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -172,7 +172,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
* distance varying slots whenever clipping is enabled, even if the vertex
* shader doesn't write to gl_ClipDistance.
*/
- if (key->base.userclip_active) {
+ if (key->base.nr_userclip_plane_consts > 0) {
outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0);
outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1);
}
@@ -257,10 +257,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
key->gl_attrib_wa_flags[i]);
}
- found |= key_debug(brw, "user clip flags",
- old_key->base.userclip_active, key->base.userclip_active);
-
- found |= key_debug(brw, "user clipping planes as push constants",
+ found |= key_debug(brw, "legacy user clipping",
old_key->base.nr_userclip_plane_consts,
key->base.nr_userclip_plane_consts);
@@ -311,12 +308,10 @@ brw_vs_populate_key(struct brw_context *brw,
*/
key->base.program_string_id = vp->id;
- if (ctx->Transform.ClipPlanesEnabled != 0) {
- key->base.userclip_active = true;
- if (!vp->program.Base.UsesClipDistanceOut) {
- key->base.nr_userclip_plane_consts =
- _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
- }
+ if (ctx->Transform.ClipPlanesEnabled != 0 &&
+ !vp->program.Base.UsesClipDistanceOut) {
+ key->base.nr_userclip_plane_consts =
+ _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
}
/* _NEW_POLYGON */