Commit e23b55c3 authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Marge Bot
Browse files

i965: Use nir_lower_passthrough_edgeflags

Now that there's a common NIR pass, there's no point in us doing this in
the back-end anymore.  In order to use this pass in i965, we do have to
make one tiny change.  Gallium runs the pass after assigning input and
output locations and so needs the pass to respect those locations and
num_inputs.  i965, however, runs it before any location assignment or
I/O lowering so we don't care.  We do, however, need the pass to succeed
with num_inputs == 0 because we set that later.
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <>
Part-of: <!11313>
parent eff418fe
......@@ -35,8 +35,11 @@ lower_impl(nir_function_impl *impl)
nir_builder_init(&b, impl);
b.cursor = nir_before_cf_list(&impl->body);
/* The edge flag is the last input in st/mesa. */
assert(shader->num_inputs == util_bitcount64(shader->info.inputs_read));
/* The edge flag is the last input in st/mesa. This code is also called by
* i965 which calls it before any input locations are assigned.
assert(shader->num_inputs == 0 ||
shader->num_inputs == util_bitcount64(shader->info.inputs_read));
/* Lowered IO only uses intrinsics. It doesn't use variables. */
if (shader->info.io_lowered) {
......@@ -2902,21 +2902,6 @@ brw_compile_vs(const struct brw_compiler *compiler,
const unsigned *assembly = NULL;
if (prog_data->base.vue_map.varying_to_slot[VARYING_SLOT_EDGE] != -1) {
/* If the output VUE map contains VARYING_SLOT_EDGE then we need to copy
* the edge flag from VERT_ATTRIB_EDGEFLAG. This will be done
* automatically by brw_vec4_visitor::emit_urb_slot but we need to
* ensure that prog_data->inputs_read is accurate.
* In order to make late NIR passes aware of the change, we actually
* whack shader->info.inputs_read instead. This is safe because we just
* made a copy of the shader.
nir->info.inputs_read |= VERT_BIT_EDGEFLAG;
prog_data->inputs_read = nir->info.inputs_read;
prog_data->double_inputs_read = nir->info.vs.double_inputs;
......@@ -1219,20 +1219,6 @@ vec4_visitor::emit_urb_slot(dst_reg reg, int varying)
if (output_reg[VARYING_SLOT_POS][0].file != BAD_FILE)
emit(MOV(reg, src_reg(output_reg[VARYING_SLOT_POS][0])));
/* This is present when doing unfilled polygons. We're supposed to copy
* the edge flag from the user-provided vertex array
* (glEdgeFlagPointer), or otherwise we'll copy from the current value
* of that attribute (starts as 1.0f). This is then used in clipping to
* determine which edges should be drawn as wireframe.
current_annotation = "edge flag";
int edge_attr = util_bitcount64(nir->info.inputs_read &
emit(MOV(reg, src_reg(dst_reg(ATTR, edge_attr,
glsl_type::float_type, WRITEMASK_XYZW))));
/* No need to write to this slot */
......@@ -76,10 +76,6 @@ brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
const struct intel_device_info *devinfo = &brw->screen->devinfo;
GLbitfield64 outputs_written = user_varyings;
if (key->copy_edgeflag) {
outputs_written |= BITFIELD64_BIT(VARYING_SLOT_EDGE);
if (devinfo->ver < 6) {
/* Put dummy slots into the VUE for the SF to put the replaced
* point sprite coords in. We shouldn't need these dummy slots,
......@@ -156,6 +152,9 @@ brw_codegen_vs_prog(struct brw_context *brw,
if (key->copy_edgeflag)
uint64_t outputs_written =
brw_vs_outputs_written(brw, key, nir->info.outputs_written);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment