zink: Don't flag legacy_shadow_mask for RED-only reads in the shader.
It is very common in games to read just the .x channel of a vec4 shadow result (since GL defaults to either LUMINANCE or RED depth mode depending on context). So, we can avoid shader recompiles to handle the other components, in that case. Fixes some recompiles in CS:GO. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22912>
This commit is contained in:
@@ -3367,10 +3367,17 @@ rewrite_tex_dest(nir_builder *b, nir_tex_instr *tex, nir_variable *var, struct z
|
||||
return NULL;
|
||||
nir_ssa_def *dest = &tex->dest.ssa;
|
||||
if (rewrite_depth && zs) {
|
||||
if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
|
||||
flag_shadow_tex(var, zs);
|
||||
else
|
||||
mesa_loge("unhandled old-style shadow sampler in non-fragment stage!");
|
||||
/* If only .x is used in the NIR, then it's effectively not a legacy depth
|
||||
* sample anyway and we don't want to ask for shader recompiles. This is
|
||||
* the typical path, since GL_DEPTH_TEXTURE_MODE defaults to either RED or
|
||||
* LUMINANCE, so apps just use the first channel.
|
||||
*/
|
||||
if (nir_ssa_def_components_read(dest) & ~1) {
|
||||
if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
|
||||
flag_shadow_tex(var, zs);
|
||||
else
|
||||
mesa_loge("unhandled old-style shadow sampler in non-fragment stage!");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (bit_size != dest_size) {
|
||||
|
||||
@@ -797,7 +797,11 @@ struct zink_shader {
|
||||
} non_fs;
|
||||
|
||||
struct {
|
||||
uint32_t legacy_shadow_mask; //is_new_style_shadow is false for these
|
||||
/* Bitmask of textures that have shadow sampling result components
|
||||
* other than RED accessed. This is a subset of !is_new_style_shadow
|
||||
* (GLSL <1.30, ARB_fp) shadow sampling usage.
|
||||
*/
|
||||
uint32_t legacy_shadow_mask;
|
||||
nir_variable *fbfetch; //for fs output
|
||||
} fs;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user