radv: Pass draw index to shader.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 31 Jan 2017 20:25:41 +0000 (21:25 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 1 Feb 2017 18:49:40 +0000 (19:49 +0100)
Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
src/amd/vulkan/radv_cmd_buffer.c

index 091d970ee0ba6e65deaeec9a7ec72ba93235bfe9..97c6b63ce0111d2a965b4192608e1e8db0830476 100644 (file)
@@ -2174,15 +2174,16 @@ void radv_CmdDraw(
        RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
        radv_cmd_buffer_flush_state(cmd_buffer);
 
-       MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 9);
+       MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 10);
 
        struct ac_userdata_info *loc = radv_lookup_user_sgpr(cmd_buffer->state.pipeline, MESA_SHADER_VERTEX,
                                                             AC_UD_VS_BASE_VERTEX_START_INSTANCE);
        if (loc->sgpr_idx != -1) {
                uint32_t base_reg = shader_stage_to_user_data_0(MESA_SHADER_VERTEX, radv_pipeline_has_gs(cmd_buffer->state.pipeline));
-               radeon_set_sh_reg_seq(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, 2);
+               radeon_set_sh_reg_seq(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, 3);
                radeon_emit(cmd_buffer->cs, firstVertex);
                radeon_emit(cmd_buffer->cs, firstInstance);
+               radeon_emit(cmd_buffer->cs, 0);
        }
        radeon_emit(cmd_buffer->cs, PKT3(PKT3_NUM_INSTANCES, 0, 0));
        radeon_emit(cmd_buffer->cs, instanceCount);
@@ -2225,7 +2226,7 @@ void radv_CmdDrawIndexed(
        radv_cmd_buffer_flush_state(cmd_buffer);
        radv_emit_primitive_reset_index(cmd_buffer);
 
-       MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 14);
+       MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 15);
 
        radeon_emit(cmd_buffer->cs, PKT3(PKT3_INDEX_TYPE, 0, 0));
        radeon_emit(cmd_buffer->cs, cmd_buffer->state.index_type);
@@ -2234,9 +2235,10 @@ void radv_CmdDrawIndexed(
                                                             AC_UD_VS_BASE_VERTEX_START_INSTANCE);
        if (loc->sgpr_idx != -1) {
                uint32_t base_reg = shader_stage_to_user_data_0(MESA_SHADER_VERTEX, radv_pipeline_has_gs(cmd_buffer->state.pipeline));
-               radeon_set_sh_reg_seq(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, 2);
+               radeon_set_sh_reg_seq(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, 3);
                radeon_emit(cmd_buffer->cs, vertexOffset);
                radeon_emit(cmd_buffer->cs, firstInstance);
+               radeon_emit(cmd_buffer->cs, 0);
        }
        radeon_emit(cmd_buffer->cs, PKT3(PKT3_NUM_INSTANCES, 0, 0));
        radeon_emit(cmd_buffer->cs, instanceCount);
@@ -2298,7 +2300,9 @@ radv_emit_indirect_draw(struct radv_cmd_buffer *cmd_buffer,
        radeon_emit(cs, 0);
        radeon_emit(cs, ((base_reg + loc->sgpr_idx * 4) - SI_SH_REG_OFFSET) >> 2);
        radeon_emit(cs, ((base_reg + (loc->sgpr_idx + 1) * 4) - SI_SH_REG_OFFSET) >> 2);
-       radeon_emit(cs, S_2C3_COUNT_INDIRECT_ENABLE(!!count_va)); /* draw_index and count_indirect enable */
+       radeon_emit(cs, (((base_reg + (loc->sgpr_idx + 2) * 4) - SI_SH_REG_OFFSET) >> 2) |
+                       S_2C3_DRAW_INDEX_ENABLE(1) |
+                       S_2C3_COUNT_INDIRECT_ENABLE(!!count_va));
        radeon_emit(cs, draw_count); /* count */
        radeon_emit(cs, count_va); /* count_addr */
        radeon_emit(cs, count_va >> 32);