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>
(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):
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;
}
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();
{
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;
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);
}
/* 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);
* 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);
}
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);
*/
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 */