zink: emit consts as uint only on IMG proprietary drivers

After the SPIR-V generator is optimized to generate multiple constant
types, the shader compiler of Imagination proprietary drivers can no
longer correctly handle these shaders and will bail out.

Handle this as a driver quirk and revert to the old behavior with only
uint constants when IMG proprietary drivers are detected.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32342>
This commit is contained in:
Icenowy Zheng 2024-11-26 10:46:55 +08:00 committed by Marge Bot
parent 7755c41b3e
commit b6c2ea4d99
4 changed files with 17 additions and 1 deletions

View file

@ -2180,7 +2180,10 @@ emit_load_const(struct ntv_context *ctx, nir_load_const_instr *load_const)
components[i] = spirv_builder_const_bool(&ctx->builder,
load_const->value[i].b);
} else {
atype = infer_nir_alu_type_from_uses_ssa(&load_const->def);
if (ctx->sinfo->broken_arbitary_type_const)
atype = nir_type_uint;
else
atype = infer_nir_alu_type_from_uses_ssa(&load_const->def);
for (int i = 0; i < num_components; i++) {
switch (atype) {
case nir_type_uint: {

View file

@ -6134,6 +6134,7 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir)
zs->sinfo.have_vulkan_memory_model = screen->info.have_KHR_vulkan_memory_model;
zs->sinfo.have_workgroup_memory_explicit_layout = screen->info.have_KHR_workgroup_memory_explicit_layout;
zs->sinfo.broken_arbitary_type_const = screen->driver_compiler_workarounds.broken_const;
if (screen->info.have_KHR_shader_float_controls) {
if (screen->info.props12.shaderDenormFlushToZeroFloat16)
zs->sinfo.float_controls.flush_denorms |= 0x1;

View file

@ -3001,6 +3001,16 @@ init_driver_workarounds(struct zink_screen *screen)
break;
}
/* these drivers cannot handle arbitary const value types */
switch (zink_driverid(screen)) {
case VK_DRIVER_ID_IMAGINATION_PROPRIETARY:
screen->driver_compiler_workarounds.broken_const = true;
break;
default:
screen->driver_compiler_workarounds.broken_const = false;
break;
}
/* When robust contexts are advertised but robustImageAccess2 is not available */
screen->driver_compiler_workarounds.lower_robustImageAccess2 =
!screen->info.rb2_feats.robustImageAccess2 &&

View file

@ -753,6 +753,7 @@ struct zink_shader_info {
bool have_sparse;
bool have_vulkan_memory_model;
bool have_workgroup_memory_explicit_layout;
bool broken_arbitary_type_const;
struct {
uint8_t flush_denorms:3; // 16, 32, 64
uint8_t preserve_denorms:3; // 16, 32, 64
@ -1534,6 +1535,7 @@ struct zink_screen {
bool needs_zs_shader_swizzle;
bool needs_sanitised_layer;
bool io_opt;
bool broken_const;
} driver_compiler_workarounds;
struct {
bool broken_l4a4;