int
-vec4_gs_visitor::setup_varying_inputs(int payload_reg, int *attribute_map)
+vec4_gs_visitor::setup_varying_inputs(int payload_reg, int *attribute_map,
+ int attributes_per_reg)
{
/* For geometry shaders there are N copies of the input attributes, where N
* is the number of input vertices. attribute_map[BRW_VARYING_SLOT_COUNT *
int varying = c->input_vue_map.slot_to_varying[slot];
for (unsigned vertex = 0; vertex < num_input_vertices; vertex++) {
attribute_map[BRW_VARYING_SLOT_COUNT * vertex + varying] =
- payload_reg + input_array_stride * vertex + slot;
+ attributes_per_reg * payload_reg + input_array_stride * vertex +
+ slot;
}
}
- return payload_reg + input_array_stride * num_input_vertices;
+ int regs_used = ALIGN(input_array_stride * num_input_vertices,
+ attributes_per_reg) / attributes_per_reg;
+ return payload_reg + regs_used;
}
{
int attribute_map[BRW_VARYING_SLOT_COUNT * MAX_GS_INPUT_VERTICES];
+ /* If we are in dual instanced mode, then attributes are going to be
+ * interleaved, so one register contains two attribute slots.
+ */
+ int attributes_per_reg = c->prog_data.dual_instanced_dispatch ? 2 : 1;
+
/* If a geometry shader tries to read from an input that wasn't written by
* the vertex shader, that produces undefined results, but it shouldn't
* crash anything. So initialize attribute_map to zeros--that ensures that
/* If the shader uses gl_PrimitiveIDIn, that goes in r1. */
if (c->prog_data.include_primitive_id)
- attribute_map[VARYING_SLOT_PRIMITIVE_ID] = reg++;
+ attribute_map[VARYING_SLOT_PRIMITIVE_ID] = attributes_per_reg * reg++;
reg = setup_uniforms(reg);
- reg = setup_varying_inputs(reg, attribute_map);
+ reg = setup_varying_inputs(reg, attribute_map, attributes_per_reg);
- lower_attributes_to_hw_regs(attribute_map, false /* interleaved */);
+ lower_attributes_to_hw_regs(attribute_map,
+ c->prog_data.dual_instanced_dispatch);
this->first_non_payload_grf = reg;
}
printf("\n\n");
}
+ /* Assume the geometry shader will use DUAL_OBJECT dispatch for now. */
+ c->prog_data.dual_instanced_dispatch = false;
+
vec4_gs_visitor v(brw, c, prog, shader, mem_ctx, false /* no_spills */);
if (!v.run()) {
prog->LinkStatus = false;
((brw->max_gs_threads - 1) << max_threads_shift) |
(brw->gs.prog_data->control_data_header_size_hwords <<
GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT) |
- GEN7_GS_DISPATCH_MODE_DUAL_OBJECT |
+ (brw->gs.prog_data->dual_instanced_dispatch ?
+ GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE :
+ GEN7_GS_DISPATCH_MODE_DUAL_OBJECT) |
GEN6_GS_STATISTICS_ENABLE |
(brw->gs.prog_data->include_primitive_id ?
GEN7_GS_INCLUDE_PRIMITIVE_ID : 0) |