diff options
author | Samuel Pitoiset <[email protected]> | 2019-02-05 20:21:58 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2019-02-12 17:25:34 +0100 |
commit | 5806d99984a4dd276e277b3615e2194adad70b18 (patch) | |
tree | fe2ad83edad3d122a314e7b959a2d87b81877c36 /src/amd/vulkan | |
parent | 129a9f4937b8f2adb4d37999677d748d816d611c (diff) |
radv: gather more info about push constants
This is needed in order to inline some push constants when possible.
This also adds a new helper for initializing the pass.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r-- | src/amd/vulkan/radv_nir_to_llvm.c | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_shader.h | 4 | ||||
-rw-r--r-- | src/amd/vulkan/radv_shader_info.c | 37 |
4 files changed, 44 insertions, 1 deletions
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 7f74678d5f1..dbeae2aafde 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -3439,6 +3439,8 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm, memset(shader_info, 0, sizeof(*shader_info)); + radv_nir_shader_info_init(&shader_info->info); + for(int i = 0; i < shader_count; ++i) radv_nir_shader_info_pass(shaders[i], options, &shader_info->info); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index d4a9e9f0e95..1e38a12a2a7 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1951,6 +1951,8 @@ void radv_nir_shader_info_pass(const struct nir_shader *nir, const struct radv_nir_compiler_options *options, struct radv_shader_info *info); +void radv_nir_shader_info_init(struct radv_shader_info *info); + struct radeon_winsys_sem; #define RADV_DEFINE_HANDLE_CASTS(__radv_type, __VkType) \ diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index b67cd2b4f15..92886188459 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -162,6 +162,10 @@ struct radv_streamout_info { struct radv_shader_info { bool loads_push_constants; + uint8_t min_push_constant_used; + uint8_t max_push_constant_used; + bool has_only_32bit_push_constants; + bool has_indirect_push_constants; uint32_t desc_set_used_mask; bool needs_multiview_view_index; bool uses_invocation_id; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index e17b0e54e69..bece7b20f02 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -191,6 +191,33 @@ gather_intrinsic_store_deref_info(const nir_shader *nir, } static void +gather_push_constant_info(const nir_shader *nir, + const nir_intrinsic_instr *instr, + struct radv_shader_info *info) +{ + nir_const_value *cval = nir_src_as_const_value(instr->src[0]); + int base = nir_intrinsic_base(instr); + int range = nir_intrinsic_range(instr); + + if (!cval) { + info->has_indirect_push_constants = true; + } else { + uint32_t min = base + cval->u32[0]; + uint32_t max = min + instr->num_components * 4; + + info->max_push_constant_used = + MAX2(max, info->max_push_constant_used); + info->min_push_constant_used = + MIN2(min, info->min_push_constant_used); + } + + if (instr->dest.ssa.bit_size != 32) + info->has_only_32bit_push_constants = false; + + info->loads_push_constants = true; +} + +static void gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct radv_shader_info *info) { @@ -243,7 +270,7 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, info->uses_prim_id = true; break; case nir_intrinsic_load_push_constant: - info->loads_push_constants = true; + gather_push_constant_info(nir, instr, info); break; case nir_intrinsic_vulkan_resource_index: info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr)); @@ -505,6 +532,14 @@ gather_xfb_info(const nir_shader *nir, struct radv_shader_info *info) } void +radv_nir_shader_info_init(struct radv_shader_info *info) +{ + /* Assume that shaders only have 32-bit push constants by default. */ + info->min_push_constant_used = UINT8_MAX; + info->has_only_32bit_push_constants = true; +} + +void radv_nir_shader_info_pass(const struct nir_shader *nir, const struct radv_nir_compiler_options *options, struct radv_shader_info *info) |