If the geometry shader refers to the built-in variable
gl_PrimitiveIDIn, we need to set a bit in 3DSTATE_GS to tell the
hardware to dispatch primitive ID to r1, and we need to leave room for
it when allocating registers.
Note: this feature doesn't yet work properly when software primitive
restart is in use (the primitive ID counter will incorrectly reset
with each primitive restart, since software primitive restart works by
performing multiple draw calls). I plan to address that in a future
patch series.
Fixes piglit test "spec/glsl-1.50/execution/geometry/primitive-id-in".
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* Ignored if control_data_header_size is 0.
*/
unsigned control_data_format;
+
+ bool include_primitive_id;
};
/** Number of texture sampler units */
c.key = *key;
c.gp = gp;
+ c.prog_data.include_primitive_id =
+ (gp->program.Base.InputsRead & VARYING_BIT_PRIMITIVE_ID) != 0;
+
/* Allocate the references to the uniforms that will end up in the
* prog_data associated with the compiled program, and which will be freed
* by the state cache.
*/
reg++;
+ /* If the shader uses gl_PrimitiveIDIn, that goes in r1. */
+ if (c->prog_data.include_primitive_id)
+ attribute_map[VARYING_SLOT_PRIMITIVE_ID] = reg++;
+
reg = setup_uniforms(reg);
reg = setup_varying_inputs(reg, attribute_map);
GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT) |
GEN7_GS_DISPATCH_MODE_DUAL_OBJECT |
GEN6_GS_STATISTICS_ENABLE |
+ (brw->gs.prog_data->include_primitive_id ?
+ GEN7_GS_INCLUDE_PRIMITIVE_ID : 0) |
GEN7_GS_ENABLE;
if (brw->is_haswell) {