diff options
author | Dave Airlie <airlied@redhat.com> | 2016-10-10 03:20:36 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-10-19 10:17:48 +1000 |
commit | b0e11a153c4b8cd9bf29bdb8e26a776de241a5b4 (patch) | |
tree | 92b906dcddf195e9e52cd8a83239b2a6b793dbe8 /src/amd | |
parent | 6c3bd1cdb3c60a0140b57a2064e02f5869b0f9bc (diff) | |
download | external_mesa3d-b0e11a153c4b8cd9bf29bdb8e26a776de241a5b4.zip external_mesa3d-b0e11a153c4b8cd9bf29bdb8e26a776de241a5b4.tar.gz external_mesa3d-b0e11a153c4b8cd9bf29bdb8e26a776de241a5b4.tar.bz2 |
radv: start using defines for the user sgpr offsets
This adds some comments and adds defines for the user sgprs,
so that we can move them around easier later and not have
to change/revalidate every one of these.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 7 | ||||
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.h | 17 | ||||
-rw-r--r-- | src/amd/vulkan/radv_cmd_buffer.c | 24 |
3 files changed, 34 insertions, 14 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 56814ec..4b5f043 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -334,9 +334,12 @@ static void create_function(struct nir_to_llvm_context *ctx, unsigned array_count = 0; unsigned sgpr_count = 0, user_sgpr_count; unsigned i; + + /* 1 for each descriptor set */ for (unsigned i = 0; i < 4; ++i) arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024); + /* 1 for push constants and dynamic descriptors */ arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024); array_count = arg_idx; @@ -351,7 +354,7 @@ static void create_function(struct nir_to_llvm_context *ctx, arg_types[arg_idx++] = LLVMVectorType(ctx->i32, 3); break; case MESA_SHADER_VERTEX: - arg_types[arg_idx++] = const_array(ctx->v16i8, 16); + arg_types[arg_idx++] = const_array(ctx->v16i8, 16); /* vertex buffers */ arg_types[arg_idx++] = ctx->i32; // base vertex arg_types[arg_idx++] = ctx->i32; // start instance user_sgpr_count = sgpr_count = arg_idx; @@ -361,7 +364,7 @@ static void create_function(struct nir_to_llvm_context *ctx, arg_types[arg_idx++] = ctx->i32; // instance id break; case MESA_SHADER_FRAGMENT: - arg_types[arg_idx++] = const_array(ctx->f32, 32); + arg_types[arg_idx++] = const_array(ctx->f32, 32); /* sample positions */ user_sgpr_count = arg_idx; arg_types[arg_idx++] = ctx->i32; /* prim mask */ sgpr_count = arg_idx; diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h index 550fe84..a17caf2 100644 --- a/src/amd/common/ac_nir_to_llvm.h +++ b/src/amd/common/ac_nir_to_llvm.h @@ -96,6 +96,23 @@ void ac_compile_nir_shader(LLVMTargetMachineRef tm, const struct ac_nir_compiler_options *options, bool dump_shader); +/* SHADER ABI defines */ + +/* offset in dwords */ +#define AC_USERDATA_DESCRIPTOR_SET_0 0 +#define AC_USERDATA_DESCRIPTOR_SET_1 2 +#define AC_USERDATA_DESCRIPTOR_SET_2 4 +#define AC_USERDATA_DESCRIPTOR_SET_3 6 +#define AC_USERDATA_PUSH_CONST_DYN 8 + +#define AC_USERDATA_VS_VERTEX_BUFFERS 10 +#define AC_USERDATA_VS_BASE_VERTEX 12 +#define AC_USERDATA_VS_START_INSTANCE 13 + +#define AC_USERDATA_PS_SAMPLE_POS 10 + +#define AC_USERDATA_CS_GRID_SIZE 10 + #ifdef __cplusplus extern "C" #endif diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 6e90910..690c739 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -327,7 +327,7 @@ radv_update_multisample_state(struct radv_cmd_buffer *cmd_buffer, uint64_t va = cmd_buffer->device->ws->buffer_get_va(cmd_buffer->upload.upload_bo); va += samples_offset; - radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B030_SPI_SHADER_USER_DATA_PS_0 + 10 * 4, 2); + radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B030_SPI_SHADER_USER_DATA_PS_0 + AC_USERDATA_PS_SAMPLE_POS * 4, 2); radeon_emit(cmd_buffer->cs, va); radeon_emit(cmd_buffer->cs, va >> 32); } @@ -919,21 +919,21 @@ radv_flush_constants(struct radv_cmd_buffer *cmd_buffer, if (stages & VK_SHADER_STAGE_VERTEX_BIT) { radeon_set_sh_reg_seq(cmd_buffer->cs, - R_00B130_SPI_SHADER_USER_DATA_VS_0 + 8 * 4, 2); + R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_PUSH_CONST_DYN * 4, 2); radeon_emit(cmd_buffer->cs, va); radeon_emit(cmd_buffer->cs, va >> 32); } if (stages & VK_SHADER_STAGE_FRAGMENT_BIT) { radeon_set_sh_reg_seq(cmd_buffer->cs, - R_00B030_SPI_SHADER_USER_DATA_PS_0 + 8 * 4, 2); + R_00B030_SPI_SHADER_USER_DATA_PS_0 + AC_USERDATA_PUSH_CONST_DYN * 4, 2); radeon_emit(cmd_buffer->cs, va); radeon_emit(cmd_buffer->cs, va >> 32); } if (stages & VK_SHADER_STAGE_COMPUTE_BIT) { radeon_set_sh_reg_seq(cmd_buffer->cs, - R_00B900_COMPUTE_USER_DATA_0 + 8 * 4, 2); + R_00B900_COMPUTE_USER_DATA_0 + AC_USERDATA_PUSH_CONST_DYN * 4, 2); radeon_emit(cmd_buffer->cs, va); radeon_emit(cmd_buffer->cs, va >> 32); } @@ -988,7 +988,7 @@ radv_cmd_buffer_flush_state(struct radv_cmd_buffer *cmd_buffer) va = device->ws->buffer_get_va(cmd_buffer->upload.upload_bo); va += vb_offset; radeon_set_sh_reg_seq(cmd_buffer->cs, - R_00B130_SPI_SHADER_USER_DATA_VS_0 + 10 * 4, 2); + R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_VS_VERTEX_BUFFERS * 4, 2); radeon_emit(cmd_buffer->cs, va); radeon_emit(cmd_buffer->cs, va >> 32); @@ -1780,7 +1780,7 @@ void radv_CmdDraw( unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 9); - radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B130_SPI_SHADER_USER_DATA_VS_0 + 12 * 4, 2); + radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_VS_BASE_VERTEX * 4, 2); radeon_emit(cmd_buffer->cs, firstVertex); radeon_emit(cmd_buffer->cs, firstInstance); radeon_emit(cmd_buffer->cs, PKT3(PKT3_NUM_INSTANCES, 0, 0)); @@ -1827,7 +1827,7 @@ void radv_CmdDrawIndexed( radeon_emit(cmd_buffer->cs, PKT3(PKT3_INDEX_TYPE, 0, 0)); radeon_emit(cmd_buffer->cs, cmd_buffer->state.index_type); - radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B130_SPI_SHADER_USER_DATA_VS_0 + 12 * 4, 2); + radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_VS_BASE_VERTEX * 4, 2); radeon_emit(cmd_buffer->cs, vertexOffset); radeon_emit(cmd_buffer->cs, firstInstance); radeon_emit(cmd_buffer->cs, PKT3(PKT3_NUM_INSTANCES, 0, 0)); @@ -1874,8 +1874,8 @@ radv_emit_indirect_draw(struct radv_cmd_buffer *cmd_buffer, PKT3_DRAW_INDIRECT_MULTI, 8, false)); radeon_emit(cs, 0); - radeon_emit(cs, (R_00B160_SPI_SHADER_USER_DATA_VS_12 - SI_SH_REG_OFFSET) >> 2); - radeon_emit(cs, (R_00B164_SPI_SHADER_USER_DATA_VS_13 - SI_SH_REG_OFFSET) >> 2); + radeon_emit(cs, ((R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_VS_BASE_VERTEX * 4) - SI_SH_REG_OFFSET) >> 2); + radeon_emit(cs, ((R_00B130_SPI_SHADER_USER_DATA_VS_0 + AC_USERDATA_VS_START_INSTANCE * 4) - SI_SH_REG_OFFSET) >> 2); radeon_emit(cs, 0); /* draw_index */ radeon_emit(cs, draw_count); /* count */ radeon_emit(cs, 0); /* count_addr -- disabled */ @@ -1949,7 +1949,7 @@ void radv_CmdDispatch( si_emit_cache_flush(cmd_buffer); unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 10); - radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B900_COMPUTE_USER_DATA_0 + 10 * 4, 3); + radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B900_COMPUTE_USER_DATA_0 + AC_USERDATA_CS_GRID_SIZE * 4, 3); radeon_emit(cmd_buffer->cs, x); radeon_emit(cmd_buffer->cs, y); radeon_emit(cmd_buffer->cs, z); @@ -1989,7 +1989,7 @@ void radv_CmdDispatchIndirect( COPY_DATA_DST_SEL(COPY_DATA_REG)); radeon_emit(cmd_buffer->cs, (va + 4 * i)); radeon_emit(cmd_buffer->cs, (va + 4 * i) >> 32); - radeon_emit(cmd_buffer->cs, (R_00B928_COMPUTE_USER_DATA_10 >> 2) + i); + radeon_emit(cmd_buffer->cs, ((R_00B900_COMPUTE_USER_DATA_0 + AC_USERDATA_CS_GRID_SIZE * 4) >> 2) + i); radeon_emit(cmd_buffer->cs, 0); } @@ -2043,7 +2043,7 @@ void radv_unaligned_dispatch( S_00B81C_NUM_THREAD_FULL(compute_shader->info.cs.block_size[2]) | S_00B81C_NUM_THREAD_PARTIAL(remainder[2])); - radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B900_COMPUTE_USER_DATA_0 + 10 * 4, 3); + radeon_set_sh_reg_seq(cmd_buffer->cs, R_00B900_COMPUTE_USER_DATA_0 + AC_USERDATA_CS_GRID_SIZE * 4, 3); radeon_emit(cmd_buffer->cs, blocks[0]); radeon_emit(cmd_buffer->cs, blocks[1]); radeon_emit(cmd_buffer->cs, blocks[2]); |