diff options
author | Connor Abbott <[email protected]> | 2019-08-30 17:57:18 +0200 |
---|---|---|
committer | Connor Abbott <[email protected]> | 2019-09-05 12:38:46 +0200 |
commit | 2af431cf7fe9303bbfbd719e4612f00043583f40 (patch) | |
tree | 47b24510d420f4fa65984147b7959e9fbcc1c15d /src | |
parent | 49503ae74e2634ebd2e0d3caa36c25ed99e19b9c (diff) |
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 <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/linker.cpp | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_screen.c | 4 | ||||
-rw-r--r-- | src/gallium/docs/source/screen.rst | 4 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 1 | ||||
-rw-r--r-- | src/mesa/main/context.c | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 2 |
7 files changed, 20 insertions, 1 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 281d59d12a5..c52c665a4c2 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -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); diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 88f4945e755..879e49d8d5b 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -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: diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index d149a2f4c9f..1df04b6c3bf 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -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: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 808c2b8cfaf..8530994d9ad 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -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, }; /** diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c68be8d01e5..d77647ccda9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -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. diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b740671559b..f035287ac7e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3929,6 +3929,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). */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 50471d63f2b..4da6e559ed5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -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 = |