GLbitfield64 inputs_read;
bool uses_vertexid;
+ bool uses_instanceid;
};
static void brw_emit_vertices(struct brw_context *brw)
{
- GLuint i, nr_elements;
+ GLuint i;
brw_prepare_vertices(brw);
brw_prepare_shader_draw_parameters(brw);
brw_emit_query_begin(brw);
- nr_elements = brw->vb.nr_enabled + brw->vs.prog_data->uses_vertexid;
+ unsigned nr_elements = brw->vb.nr_enabled;
+ if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid)
+ ++nr_elements;
/* If the VS doesn't read any inputs (calculating vertex position from
* a state variable for some reason, for example), emit a single pad
(BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_3_SHIFT));
}
- if (brw->vs.prog_data->uses_vertexid) {
+ if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid) {
uint32_t dw0 = 0, dw1 = 0;
+ uint32_t comp0 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp1 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp2 = BRW_VE1_COMPONENT_STORE_0;
+ uint32_t comp3 = BRW_VE1_COMPONENT_STORE_0;
- dw1 = (BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_0_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_1_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_VID << BRW_VE1_COMPONENT_2_SHIFT) |
- (BRW_VE1_COMPONENT_STORE_IID << BRW_VE1_COMPONENT_3_SHIFT);
+ if (brw->vs.prog_data->uses_vertexid) {
+ comp0 = BRW_VE1_COMPONENT_STORE_SRC;
+ comp2 = BRW_VE1_COMPONENT_STORE_VID;
+ }
+
+ if (brw->vs.prog_data->uses_instanceid) {
+ comp3 = BRW_VE1_COMPONENT_STORE_IID;
+ }
+
+ dw1 = (comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
+ (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
+ (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
+ (comp3 << BRW_VE1_COMPONENT_3_SHIFT);
if (brw->gen >= 6) {
dw0 |= GEN6_VE0_VALID |
* don't represent it with a flag in inputs_read, so we call it
* VERT_ATTRIB_MAX.
*/
- if (vs_prog_data->uses_vertexid) {
+ if (vs_prog_data->uses_vertexid || vs_prog_data->uses_instanceid) {
attribute_map[VERT_ATTRIB_MAX] = payload_reg + nr_attributes;
nr_attributes++;
}
* it VERT_ATTRIB_MAX, which setup_attributes() picks up on.
*/
dst_reg *reg = new(mem_ctx) dst_reg(ATTR, VERT_ATTRIB_MAX);
- vs_prog_data->uses_vertexid = true;
switch (ir->data.location) {
case SYSTEM_VALUE_BASE_VERTEX:
reg->writemask = WRITEMASK_X;
+ vs_prog_data->uses_vertexid = true;
break;
case SYSTEM_VALUE_VERTEX_ID:
case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
reg->writemask = WRITEMASK_Z;
+ vs_prog_data->uses_vertexid = true;
break;
case SYSTEM_VALUE_INSTANCE_ID:
reg->writemask = WRITEMASK_W;
+ vs_prog_data->uses_instanceid = true;
break;
default:
unreachable("not reached");
brw_prepare_vertices(brw);
brw_prepare_shader_draw_parameters(brw);
- if (brw->vs.prog_data->uses_vertexid) {
+ if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid) {
unsigned vue = brw->vb.nr_enabled;
WARN_ONCE(brw->vs.prog_data->inputs_read & VERT_BIT_EDGEFLAG,
"Trying to insert VID/IID past 33rd vertex element, "
"need to reorder the vertex attrbutes.");
+ unsigned dw1 = 0;
+ if (brw->vs.prog_data->uses_vertexid) {
+ dw1 |= GEN8_SGVS_ENABLE_VERTEX_ID |
+ (2 << GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT) | /* .z channel */
+ (vue << GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT);
+ }
+
+ if (brw->vs.prog_data->uses_instanceid) {
+ dw1 |= GEN8_SGVS_ENABLE_INSTANCE_ID |
+ (3 << GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT) | /* .w channel */
+ (vue << GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT);
+ }
+
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_VF_SGVS << 16 | (2 - 2));
- OUT_BATCH(GEN8_SGVS_ENABLE_VERTEX_ID |
- (2 << GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT) | /* .z channel */
- (vue << GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT) |
- GEN8_SGVS_ENABLE_INSTANCE_ID |
- (3 << GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT) | /* .w channel */
- (vue << GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT));
+ OUT_BATCH(dw1);
ADVANCE_BATCH();
BEGIN_BATCH(3);