Module: Mesa Branch: main Commit: 467bf4728121e86ce597be0900c1fb5fe8739dce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=467bf4728121e86ce597be0900c1fb5fe8739dce
Author: Samuel Pitoiset <[email protected]> Date: Mon Aug 14 12:01:49 2023 +0200 radv: add radv_shader_info::is_monolithic This will be used to implement shader object on GFX9+. Signed-off-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24697> --- src/amd/vulkan/radv_shader.h | 3 ++- src/amd/vulkan/radv_shader_info.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 9c5114f4153..691a8bc53a0 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -311,7 +311,8 @@ struct radv_shader_info { uint32_t user_data_0; bool inputs_linked; bool outputs_linked; - bool has_epilog; /* Only for TCS or PS */ + bool has_epilog; /* Only for TCS or PS */ + bool is_monolithic; /* False only for merged shaders which are compiled separately */ struct { uint8_t input_usage_mask[RADV_VERT_ATTRIB_MAX]; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 18a08ef2229..743d213d545 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -1011,6 +1011,32 @@ radv_get_user_data_0(const struct radv_device *device, struct radv_shader_info * } } +static bool +radv_is_shader_monolithic(const struct radv_device *device, const struct radv_shader_info *info) +{ + const enum amd_gfx_level gfx_level = device->physical_device->rad_info.gfx_level; + + if (gfx_level >= GFX9) { + switch (info->stage) { + case MESA_SHADER_VERTEX: + if (info->next_stage == MESA_SHADER_TESS_CTRL || info->next_stage == MESA_SHADER_GEOMETRY) + return info->outputs_linked; + break; + case MESA_SHADER_TESS_EVAL: + if (info->next_stage == MESA_SHADER_GEOMETRY) + return info->outputs_linked; + break; + case MESA_SHADER_TESS_CTRL: + case MESA_SHADER_GEOMETRY: + return info->inputs_linked; + default: + break; + } + } + + return true; +} + void radv_nir_shader_info_init(gl_shader_stage stage, gl_shader_stage next_stage, struct radv_shader_info *info) { @@ -1134,6 +1160,7 @@ radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *n } info->user_data_0 = radv_get_user_data_0(device, info); + info->is_monolithic = radv_is_shader_monolithic(device, info); switch (nir->info.stage) { case MESA_SHADER_COMPUTE:
