Commit 2af431cf authored by Connor Abbott's avatar Connor Abbott

gallium: Plumb through a way to disable GLSL const lowering

For radeonsi, we will prefer the NIR pass as it'll generate better code
(some index calculation and a single load vs. a load, then index
calculation, then another load) and oftentimes NIR optimization can kick
in and make all the access indices constant.
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri's avatarTimothy Arceri <tarceri@itsqueeze.com>
parent 49503ae7
......@@ -5211,7 +5211,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
linker_optimisation_loop(ctx, prog->_LinkedShaders[i]->ir, i);
/* Call opts after lowering const arrays to copy propagate things. */
if (lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i))
if (ctx->Const.GLSLLowerConstArrays &&
lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i))
linker_optimisation_loop(ctx, prog->_LinkedShaders[i]->ir, i);
propagate_invariance(prog->_LinkedShaders[i]->ir);
......
......@@ -296,6 +296,10 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
*/
return 1;
case PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF:
/* Don't unset this unless your driver can do better */
return 1;
case PIPE_CAP_POST_DEPTH_COVERAGE:
case PIPE_CAP_BINDLESS_TEXTURE:
case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
......
......@@ -548,6 +548,10 @@ The integer capabilities:
types with texture functions having interaction with LOD of texture lookup.
* ``PIPE_CAP_SHADER_SAMPLES_IDENTICAL``: True if the driver supports a shader query to tell whether all samples of a multisampled surface are definitely identical.
* ``PIPE_CAP_TGSI_ATOMINC_WRAP``: Atomic increment/decrement + wrap around are supported.
* ``PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF``: True if the state tracker should
turn arrays whose contents can be deduced at compile time into constant
buffer loads, or false if the driver can handle such arrays itself in a more
efficient manner.
.. _pipe_capf:
......
......@@ -897,6 +897,7 @@ enum pipe_cap
PIPE_CAP_TEXTURE_SHADOW_LOD,
PIPE_CAP_SHADER_SAMPLES_IDENTICAL,
PIPE_CAP_TGSI_ATOMINC_WRAP,
PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF,
};
/**
......
......@@ -633,6 +633,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->GLSLVersion = api == API_OPENGL_CORE ? 130 : 120;
consts->GLSLVersionCompat = consts->GLSLVersion;
consts->GLSLLowerConstArrays = true;
/* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
* gl_VertexID is implemented using a native hardware register with OpenGL
* semantics.
......
......@@ -3928,6 +3928,11 @@ struct gl_constants
*/
bool GLSLOptimizeConservatively;
/**
* Whether to call lower_const_arrays_to_uniforms() during linking.
*/
bool GLSLLowerConstArrays;
/**
* True if gl_TessLevelInner/Outer[] in the TES should be inputs
* (otherwise, they're system values).
......
......@@ -344,6 +344,8 @@ void st_init_limits(struct pipe_screen *screen,
c->GLSLOptimizeConservatively =
screen->get_param(screen, PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY);
c->GLSLLowerConstArrays =
screen->get_param(screen, PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF);
c->GLSLTessLevelsAsInputs =
screen->get_param(screen, PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS);
c->LowerTessLevel =
......
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