radv: move radv_shader_create out of radv_graphics_shaders_compile

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40627>
This commit is contained in:
Rhys Perry 2026-03-23 13:49:05 +00:00 committed by Marge Bot
parent 618cad6bfe
commit 2260105ba1
3 changed files with 48 additions and 20 deletions

View file

@ -29,6 +29,7 @@
#include "radv_rmv.h"
#include "radv_shader.h"
#include "radv_shader_args.h"
#include "shader_enums.h"
#include "vk_nir_convert_ycbcr.h"
#include "vk_pipeline.h"
#include "vk_render_pass.h"
@ -2720,9 +2721,9 @@ void
radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_shader_stage *stages, const struct radv_graphics_state_key *gfx_state,
bool keep_executable_info, bool keep_statistic_info, bool is_internal,
bool skip_shaders_cache, struct radv_retained_shaders *retained_shaders, bool noop_fs,
struct radv_shader **shaders, struct radv_shader_binary **binaries,
struct radv_shader **gs_copy_shader, struct radv_shader_binary **gs_copy_binary)
struct radv_retained_shaders *retained_shaders, bool noop_fs,
struct radv_shader_debug_info *debug, struct radv_shader_binary **binaries,
struct radv_shader_debug_info *gs_copy_debug, struct radv_shader_binary **gs_copy_binary)
{
const struct radv_physical_device *pdev = radv_device_physical(device);
const struct radv_instance *instance = radv_physical_device_instance(pdev);
@ -2944,18 +2945,23 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac
radv_get_legacy_gs_info(device, NULL, &stages[MESA_SHADER_GEOMETRY].info);
/* Compile NIR shaders to AMD assembly. */
struct radv_shader_debug_info debug[MESA_VULKAN_SHADER_STAGES] = {};
struct radv_shader_debug_info gs_copy_debug = {};
radv_graphics_shaders_nir_to_asm(device, cache, stages, gfx_state, keep_executable_info, keep_statistic_info,
active_nir_stages, debug, binaries, &gs_copy_debug, gs_copy_binary);
active_nir_stages, debug, binaries, gs_copy_debug, gs_copy_binary);
}
void
radv_graphics_shaders_create(struct radv_device *device, struct vk_pipeline_cache *cache, bool skip_shaders_cache,
struct radv_shader **shaders, struct radv_shader_binary **binaries,
struct radv_shader_debug_info *debug, struct radv_shader **gs_copy_shader,
struct radv_shader_binary *gs_copy_binary, struct radv_shader_debug_info *gs_copy_debug)
{
for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {
struct radv_shader_binary *binary = binaries[i];
if (binary)
shaders[i] = radv_shader_create(device, cache, binary, skip_shaders_cache, &debug[i]);
}
if (*gs_copy_binary)
*gs_copy_shader = radv_shader_create(device, cache, *gs_copy_binary, skip_shaders_cache, &gs_copy_debug);
if (gs_copy_binary)
*gs_copy_shader = radv_shader_create(device, cache, gs_copy_binary, skip_shaders_cache, gs_copy_debug);
}
static bool
@ -3188,10 +3194,13 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
const bool noop_fs = radv_pipeline_needs_noop_fs(pipeline, &gfx_state->key.gfx_state);
struct radv_shader_debug_info debug[MESA_VULKAN_SHADER_STAGES] = {};
struct radv_shader_debug_info gs_copy_debug = {};
radv_graphics_shaders_compile(device, cache, stages, &gfx_state->key.gfx_state, keep_executable_info,
keep_statistic_info, pipeline->base.is_internal, skip_shaders_cache, retained_shaders,
noop_fs, pipeline->base.shaders, binaries, &pipeline->base.gs_copy_shader,
&gs_copy_binary);
keep_statistic_info, pipeline->base.is_internal, retained_shaders, noop_fs, debug,
binaries, &gs_copy_debug, &gs_copy_binary);
radv_graphics_shaders_create(device, cache, skip_shaders_cache, pipeline->base.shaders, binaries, debug,
&pipeline->base.gs_copy_shader, gs_copy_binary, &gs_copy_debug);
if (!skip_shaders_cache) {
radv_pipeline_cache_insert(device, cache, &pipeline->base);

View file

@ -657,9 +657,16 @@ struct radv_ps_epilog_key radv_generate_ps_epilog_key(const struct radv_device *
void radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_shader_stage *stages, const struct radv_graphics_state_key *gfx_state,
bool keep_executable_info, bool keep_statistic_info, bool is_internal,
bool skip_shaders_cache, struct radv_retained_shaders *retained_shaders,
bool noop_fs, struct radv_shader **shaders, struct radv_shader_binary **binaries,
struct radv_shader **gs_copy_shader, struct radv_shader_binary **gs_copy_binary);
struct radv_retained_shaders *retained_shaders, bool noop_fs,
struct radv_shader_debug_info *debug, struct radv_shader_binary **binaries,
struct radv_shader_debug_info *gs_copy_debug,
struct radv_shader_binary **gs_copy_binary);
void radv_graphics_shaders_create(struct radv_device *device, struct vk_pipeline_cache *cache, bool skip_shaders_cache,
struct radv_shader **shaders, struct radv_shader_binary **binaries,
struct radv_shader_debug_info *debug, struct radv_shader **gs_copy_shader,
struct radv_shader_binary *gs_copy_binary,
struct radv_shader_debug_info *gs_copy_debug);
struct radv_vgt_shader_key {
uint8_t tess : 1;

View file

@ -160,9 +160,13 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r
if (!pCreateInfo->nextStage) {
struct radv_shader *shaders[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_debug_info debug[MESA_VULKAN_SHADER_STAGES] = {};
struct radv_shader_debug_info gs_copy_debug = {};
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, true, NULL, false, shaders,
binaries, &shader_obj->gs.copy_shader, &shader_obj->gs.copy_binary);
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, NULL, false, debug, binaries,
&gs_copy_debug, &shader_obj->gs.copy_binary);
radv_graphics_shaders_create(device, NULL, true, shaders, binaries, debug, &shader_obj->gs.copy_shader,
shader_obj->gs.copy_binary, &gs_copy_debug);
shader = shaders[stage];
binary = binaries[stage];
@ -185,12 +189,16 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r
radv_foreach_stage (next_stage, next_stages) {
struct radv_shader *shaders[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_debug_info debug[MESA_VULKAN_SHADER_STAGES] = {};
struct radv_shader_debug_info gs_copy_debug = {};
radv_shader_stage_init(pCreateInfo, &stages[stage]);
stages[stage].next_stage = next_stage;
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, true, NULL, false,
shaders, binaries, &shader_obj->gs.copy_shader, &shader_obj->gs.copy_binary);
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, NULL, false, debug,
binaries, &gs_copy_debug, &shader_obj->gs.copy_binary);
radv_graphics_shaders_create(device, NULL, true, shaders, binaries, debug, &shader_obj->gs.copy_shader,
shader_obj->gs.copy_binary, &gs_copy_debug);
shader = shaders[stage];
binary = binaries[stage];
@ -454,11 +462,15 @@ radv_shader_object_create_linked(VkDevice _device, uint32_t createInfoCount, con
struct radv_shader *shaders[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_debug_info debug[MESA_VULKAN_SHADER_STAGES] = {};
struct radv_shader *gs_copy_shader = NULL;
struct radv_shader_binary *gs_copy_binary = NULL;
struct radv_shader_debug_info gs_copy_debug = {};
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, true, NULL, false, shaders,
binaries, &gs_copy_shader, &gs_copy_binary);
radv_graphics_shaders_compile(device, NULL, stages, &gfx_state, false, false, false, NULL, false, debug, binaries,
&gs_copy_debug, &gs_copy_binary);
radv_graphics_shaders_create(device, NULL, true, shaders, binaries, debug, &gs_copy_shader, gs_copy_binary,
&gs_copy_debug);
for (unsigned i = 0; i < createInfoCount; i++) {
const VkShaderCreateInfoEXT *pCreateInfo = &pCreateInfos[i];