diff options
author | Ian Romanick <[email protected]> | 2017-10-31 22:18:10 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2017-11-08 18:37:29 -0800 |
commit | 88f5588f777d76fe48fded8add745b4da2024ebc (patch) | |
tree | d8355a5d35434972b905e2ad133cf8bf24707f47 /src/compiler/glsl | |
parent | ef1ca06ce89cba03fcb30f34c47808569517957d (diff) |
glsl/linker: Optimize swizzles again after linking
Without this, the SPIR-V generator has to deal with a bunch of junk
like:
(swiz z (swiz xxx (swiz x (var_ref packed:binormal.z,light_dir))))
It seems better to cull that stuff out than to add code to deal with
it. The problem is the way swizzles to and from scalars have to be
handled in SPIR-V.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r-- | src/compiler/glsl/linker.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index d6f9c2d91ff..33fd76deae9 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -5079,6 +5079,16 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if(!link_varyings_and_uniforms(first, last, ctx, prog, mem_ctx)) goto done; + /* Linking varyings can cause some extra, useless swizzles to be generated + * due to packing and unpacking. + */ + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + optimize_swizzles(prog->_LinkedShaders[i]->ir); + } + /* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both * be present in a linked program. GL_ARB_ES2_compatibility doesn't say * anything about shader linking when one of the shaders (vertex or |