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

[spv-in]: Cull unused builtins inside structs #1469

Merged
merged 1 commit into from
Oct 20, 2021

Conversation

JCapucho
Copy link
Collaborator

Some compilers like shaderc introduce a full gl_PerVertex struct, this
includes gl_ClipDistance. Normally this isn't a problem since most
drivers optimize it away, but naga zero inits globals if they weren't
previously initialized. This causes gl_ClipDistance to be initialized to
zero which can be really bad for performance.

It only culls builtins inside structs since the problems only have been observed inside them and adding it to all expressions could be costly (would need a benchmark to be certain).

This is only observed in spirv backend since it's the only backend to zero initialize stuff.

Some compilers like shaderc introduce a full gl_PerVertex struct, this
includes gl_ClipDistance. Normally this isn't a problem since most
drivers optimize it away, but naga zero inits globals if they weren't
previously initialized. This causes gl_ClipDistance to be initialized to
zero which can be really bad for performance.
@JCapucho JCapucho requested a review from kvark October 19, 2021 20:33
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks tidy!

@kvark kvark merged commit 70ad084 into gfx-rs:master Oct 20, 2021
@kvark kvark added the can backport PR that can be back-ported to a release branch label Oct 20, 2021
kvark pushed a commit to kvark/naga that referenced this pull request Dec 2, 2021
Some compilers like shaderc introduce a full gl_PerVertex struct, this
includes gl_ClipDistance. Normally this isn't a problem since most
drivers optimize it away, but naga zero inits globals if they weren't
previously initialized. This causes gl_ClipDistance to be initialized to
zero which can be really bad for performance.
@kvark kvark mentioned this pull request Dec 2, 2021
@kvark kvark removed the can backport PR that can be back-ported to a release branch label Dec 2, 2021
kvark pushed a commit that referenced this pull request Dec 2, 2021
Some compilers like shaderc introduce a full gl_PerVertex struct, this
includes gl_ClipDistance. Normally this isn't a problem since most
drivers optimize it away, but naga zero inits globals if they weren't
previously initialized. This causes gl_ClipDistance to be initialized to
zero which can be really bad for performance.
@kvark
Copy link
Member

kvark commented Dec 2, 2021

Published in 0.7.2

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

Successfully merging this pull request may close these issues.

2 participants