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 <kenneth@whitecape.org> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -81,15 +81,12 @@ struct brw_sampler_prog_key_data {
|
||||
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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user