Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: allow SpirvToolsEliminateDeadInputComponents() to strip non-trailing members from blocks #5631

Open
mbechard opened this issue Apr 3, 2024 · 2 comments

Comments

@mbechard
Copy link

mbechard commented Apr 3, 2024

Sending the the following fragment shader through SpirvToolsEliminateDeadInputComponents() and SpirvToolsAnalyzeDeadOutputStores() results in t getting eliminated, but not pos. Can't pos also be eliminated? The analyze pass is correctly detecting that only c is being used, and only returning it as part of the livelocs.
And then similarly, SpirvToolsEliminateDeadOutputStores() would need to also to remove pos.

Vertex

out Vertex
{
	vec3 pos;
	vec4 c;
	vec2 t;
} oVert;
void main() 
{
	oVert.pos = vec3(0.5);
	oVert.c = vec4(1.0);
	oVert.t = vec2(0.4);
	gl_Position = vec4(0.0);
}

Fragment

in Vertex
{
	vec3 pos;
	vec4 c;
	vec2 t;
} iVert;

out vec4 fragColor;
void main()
{
	vec4 color = vec4(iVert.c);
	fragColor = color;
}

Compiled using 'auto map locations'.

Thanks

@mbechard mbechard changed the title SpirvToolsEliminateDeadInputComponents() seems to only strips trailing members from blocks Request: allow SpirvToolsEliminateDeadInputComponents() to strips non-trailing members from blocks Apr 3, 2024
@mbechard mbechard changed the title Request: allow SpirvToolsEliminateDeadInputComponents() to strips non-trailing members from blocks Request: allow SpirvToolsEliminateDeadInputComponents() to strip non-trailing members from blocks Apr 3, 2024
@jeremy-lunarg jeremy-lunarg self-assigned this Apr 4, 2024
@greg-lunarg
Copy link
Contributor

As you are likely aware, moving non-trailing members of input blocks in vertex shaders is impossible and would cause incompatibility at the vertex input interface. Likewise for output blocks in frag shaders and the frag output interface.

Technically we could remove non-trailing members from other shader interfaces but we would have to add logic to remap any OpAccessChain instructions that index into the block because the positions of the remaining members would change. This is very do-able. It would not cause any changes to the larger workflow. It would just be some coding effort.

@mbechard
Copy link
Author

Yep, this is what I would expect. I'm only looking for this optimization in shader->shader interfaces, since those resources are quite limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants