google / google/shaderc

Is shaderc/glslc now stripping unused inputs/outputs?

Open
#1,244 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.2k
Forks
445
Avg merge
11h 6m
Merged PRs (30d)
6

Description

We run our GLSL shaders through glslc and then through spiv-opt. In the 6/20 and 8/20 builds of glslc and spirv-opt, the unused inputs/outputs remained, and our shaders could pass the correct data in and out. Often times, a fragment shader wouldn't use but would still declare an input to line up with the vertex output. Also I see unused vertex inputs getting stripped, and then that throws off matching those up with cpu data passed down.

As of 1.3.211.0, unused inputs/outputs are stripped. Was this a recent change, and if so, how do I disable it?

This is an example of a fragment input that is stripped away. It's easy to imagine a case where the vertex inputs are also stripped from non-use, or code that is commented out in the vertex shader. Note, this could also be a spirv-opt optimization, but I've only identified that the spriv is missing these variables.

This is mostly problematic when transpiling to HLSL SM 5.0. Our MSL transpiles look fine. Spriv running on Android is also okay.

```
// vs
#version 450

in vec4 a_position;
out vec3 a_worldPos;

void main()
{
gl_position = a_position;
a_worldPos = a_position.xyz;
}

// fs
#version 450

in vec3 a_worldPos;
layout (location = 0) out vec4 o_fragColor0;

void main()
{
// with this commented out, the input is stripped, and vs outputs/fs inputs now have a gap
//o_fragColor0 = float4(a_worldPos, 1.0);
o_fragColor0 = float4(0.0);
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.