radv: add drirc options to force re-compilation of shaders when needed
On Steam Deck, shaders are pre-compiled for better performance (less stuttering, less CPU usage, etc). But when a compiler fix needs to be backported, there is currently no way to handle this properly. This introduces 3 drirc options radv_override_{graphics,compute,ray_tracing}_shader_version in order to force the driver to re-compile pipelines when needed. By default, the shader version is 0 for all pipelines. When one drirc is set for a specific game, RADV will re-compile all pipelines only once with the compiler fix included (because the pipeline key would be different). Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26094>
This commit is contained in:

committed by
Marge Bot

parent
fe159c85de
commit
9b840df9f6
@@ -152,6 +152,9 @@ static const driOptionDescription radv_dri_options[] = {
|
||||
DRI_CONF_RADV_FLUSH_BEFORE_TIMESTAMP_WRITE(false)
|
||||
DRI_CONF_RADV_RT_WAVE64(false)
|
||||
DRI_CONF_DUAL_COLOR_BLEND_BY_LOCATION(false)
|
||||
DRI_CONF_RADV_OVERRIDE_GRAPHICS_SHADER_VERSION(0)
|
||||
DRI_CONF_RADV_OVERRIDE_COMPUTE_SHADER_VERSION(0)
|
||||
DRI_CONF_RADV_OVERRIDE_RAY_TRACING_SHADER_VERSION(0)
|
||||
DRI_CONF_RADV_APP_LAYER()
|
||||
DRI_CONF_SECTION_END
|
||||
};
|
||||
@@ -208,6 +211,13 @@ radv_init_dri_options(struct radv_instance *instance)
|
||||
instance->force_rt_wave64 = driQueryOptionb(&instance->dri_options, "radv_rt_wave64");
|
||||
|
||||
instance->dual_color_blend_by_location = driQueryOptionb(&instance->dri_options, "dual_color_blend_by_location");
|
||||
|
||||
instance->override_graphics_shader_version =
|
||||
driQueryOptioni(&instance->dri_options, "radv_override_graphics_shader_version");
|
||||
instance->override_compute_shader_version =
|
||||
driQueryOptioni(&instance->dri_options, "radv_override_compute_shader_version");
|
||||
instance->override_ray_tracing_shader_version =
|
||||
driQueryOptioni(&instance->dri_options, "radv_override_ray_tracing_shader_version");
|
||||
}
|
||||
|
||||
static const struct vk_instance_extension_table radv_instance_extensions_supported = {
|
||||
|
@@ -109,7 +109,12 @@ static struct radv_pipeline_key
|
||||
radv_generate_compute_pipeline_key(const struct radv_device *device, const struct radv_compute_pipeline *pipeline,
|
||||
const VkComputePipelineCreateInfo *pCreateInfo)
|
||||
{
|
||||
return radv_generate_pipeline_key(device, &pCreateInfo->stage, 1, pipeline->base.create_flags, pCreateInfo->pNext);
|
||||
struct radv_pipeline_key key =
|
||||
radv_generate_pipeline_key(device, &pCreateInfo->stage, 1, pipeline->base.create_flags, pCreateInfo->pNext);
|
||||
|
||||
key.shader_version = device->instance->override_compute_shader_version;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -1815,6 +1815,8 @@ radv_generate_graphics_pipeline_key(const struct radv_device *device, const stru
|
||||
struct radv_pipeline_key key = radv_generate_pipeline_key(device, pCreateInfo->pStages, pCreateInfo->stageCount,
|
||||
pipeline->base.create_flags, pCreateInfo->pNext);
|
||||
|
||||
key.shader_version = device->instance->override_graphics_shader_version;
|
||||
|
||||
key.lib_flags = lib_flags;
|
||||
key.has_multiview_view_index = state->rp ? !!state->rp->view_mask : 0;
|
||||
|
||||
|
@@ -90,6 +90,8 @@ radv_generate_rt_pipeline_key(const struct radv_device *device, const struct rad
|
||||
struct radv_pipeline_key key = radv_generate_pipeline_key(device, pCreateInfo->pStages, pCreateInfo->stageCount,
|
||||
pipeline->base.base.create_flags, pCreateInfo->pNext);
|
||||
|
||||
key.shader_version = device->instance->override_ray_tracing_shader_version;
|
||||
|
||||
if (pCreateInfo->pLibraryInfo) {
|
||||
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||
RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||
|
@@ -419,6 +419,9 @@ struct radv_instance {
|
||||
bool force_rt_wave64;
|
||||
bool dual_color_blend_by_location;
|
||||
char *app_layer;
|
||||
uint8_t override_graphics_shader_version;
|
||||
uint8_t override_compute_shader_version;
|
||||
uint8_t override_ray_tracing_shader_version;
|
||||
};
|
||||
|
||||
VkResult radv_init_wsi(struct radv_physical_device *physical_device);
|
||||
|
@@ -101,6 +101,9 @@ struct radv_pipeline_key {
|
||||
uint32_t vertex_robustness1 : 1;
|
||||
uint32_t mesh_fast_launch_2 : 1;
|
||||
|
||||
/* Pipeline shader version (up to 8) to force re-compilation when RADV_BUILD_ID_OVERRIDE is enabled. */
|
||||
uint32_t shader_version : 3;
|
||||
|
||||
struct radv_shader_stage_key stage_info[MESA_VULKAN_SHADER_STAGES];
|
||||
|
||||
struct {
|
||||
|
@@ -678,6 +678,23 @@
|
||||
DRI_CONF_OPT_B(radv_rt_wave64, def, \
|
||||
"Force wave64 in RT shaders")
|
||||
|
||||
/**
|
||||
* Overrides for forcing re-compilation of pipelines when RADV_BUILD_ID_OVERRIDE is enabled.
|
||||
* These need to be bumped every time a compiler bugfix is backported (up to 8 shader
|
||||
* versions are supported).
|
||||
*/
|
||||
#define DRI_CONF_RADV_OVERRIDE_GRAPHICS_SHADER_VERSION(def) \
|
||||
DRI_CONF_OPT_I(radv_override_graphics_shader_version, def, 0, 7, \
|
||||
"Override the shader version of graphics pipelines to force re-compilation. (0 = default)")
|
||||
|
||||
#define DRI_CONF_RADV_OVERRIDE_COMPUTE_SHADER_VERSION(def) \
|
||||
DRI_CONF_OPT_I(radv_override_compute_shader_version, def, 0, 7, \
|
||||
"Override the shader version of compute pipelines to force re-compilation. (0 = default)")
|
||||
|
||||
#define DRI_CONF_RADV_OVERRIDE_RAY_TRACING_SHADER_VERSION(def) \
|
||||
DRI_CONF_OPT_I(radv_override_ray_tracing_shader_version, def, 0, 7, \
|
||||
"Override the shader version of ray tracing pipelines to force re-compilation. (0 = default)")
|
||||
|
||||
#define DRI_CONF_RADV_APP_LAYER() DRI_CONF_OPT_S_NODEF(radv_app_layer, "Select an application layer.")
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user