Commit f17de6a8 authored by Rhys Perry's avatar Rhys Perry Committed by Marge Bot

radv: add RADV_DEBUG=invariantgeom

This can be used to work around a common class of bugs appearing as
flickering.
Signed-off-by: Rhys Perry's avatarRhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset's avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf's avatarTimur Kristóf <timur.kristof@gmail.com>
Cc: mesa-stable
Part-of: <!8104>
parent 08fbd5d4
......@@ -568,6 +568,9 @@ RADV driver environment variables
Print image info
``info``
show GPU-related information
``invariantgeom``
Mark geometry-affecting outputs as invariant. This works around a common
class of application bugs appearing as flickering.
``metashaders``
dump internal meta shaders
``nobinning``
......
......@@ -60,6 +60,7 @@ enum {
RADV_DEBUG_HANG = 1u << 29,
RADV_DEBUG_IMG = 1u << 30,
RADV_DEBUG_NO_UMR = 1u << 31,
RADV_DEBUG_INVARIANT_GEOM = 1ull << 32,
};
enum {
......
......@@ -551,6 +551,7 @@ static const struct debug_control radv_debug_options[] = {
{"hang", RADV_DEBUG_HANG},
{"img", RADV_DEBUG_IMG},
{"noumr", RADV_DEBUG_NO_UMR},
{"invariantgeom", RADV_DEBUG_INVARIANT_GEOM},
{NULL, 0}
};
......
......@@ -223,6 +223,8 @@ static uint32_t get_hash_flags(const struct radv_device *device)
hash_flags |= RADV_HASH_SHADER_DISCARD_TO_DEMOTE;
if (device->instance->enable_mrt_output_nan_fixup)
hash_flags |= RADV_HASH_SHADER_MRT_NAN_FIXUP;
if (device->instance->debug_flags & RADV_DEBUG_INVARIANT_GEOM)
hash_flags |= RADV_HASH_SHADER_INVARIANT_GEOM;
return hash_flags;
}
......
......@@ -1666,6 +1666,7 @@ struct radv_shader_module;
#define RADV_HASH_SHADER_LLVM (1 << 4)
#define RADV_HASH_SHADER_DISCARD_TO_DEMOTE (1 << 5)
#define RADV_HASH_SHADER_MRT_NAN_FIXUP (1 << 6)
#define RADV_HASH_SHADER_INVARIANT_GEOM (1 << 7)
void
radv_hash_shaders(unsigned char *hash,
......
......@@ -313,6 +313,27 @@ static void radv_compiler_debug(void *private_data,
0, 0, "radv", message);
}
static void
mark_geom_invariant(nir_shader *nir)
{
nir_foreach_shader_out_variable(var, nir) {
switch (var->data.location) {
case VARYING_SLOT_POS:
case VARYING_SLOT_PSIZ:
case VARYING_SLOT_CLIP_DIST0:
case VARYING_SLOT_CLIP_DIST1:
case VARYING_SLOT_CULL_DIST0:
case VARYING_SLOT_CULL_DIST1:
case VARYING_SLOT_TESS_LEVEL_OUTER:
case VARYING_SLOT_TESS_LEVEL_INNER:
var->data.invariant = true;
break;
default:
break;
}
}
}
static bool
lower_intrinsics(nir_shader *nir)
{
......@@ -538,6 +559,11 @@ radv_shader_compile_to_nir(struct radv_device *device,
nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared,
NULL);
if (device->instance->debug_flags & RADV_DEBUG_INVARIANT_GEOM &&
stage != MESA_SHADER_FRAGMENT) {
mark_geom_invariant(nir);
}
NIR_PASS_V(nir, nir_propagate_invariant);
NIR_PASS_V(nir, nir_lower_system_values);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment