Repository navigation
spirv-opt: Don't fold to 8/16-bit constants without Int8/Int16 - #6990
Open
apollo-2006 wants to merge 1 commit into
Open
apollo-2006 wants to merge 1 commit into
apollo-2006 wants to merge 1 commit into
Conversation
s-perron
approved these changes
Oct 30, 2026
s-perron
enabled auto-merge (squash)
October 30, 2026 15:53
Collaborator
|
Please rebase your change on the latest main. |
With only StorageBuffer8BitAccess (or the 16-bit storage
capabilities), constants of 8- or 16-bit types are not allowed, but
CCP and instruction simplification folded
%c = OpUConvert %uchar %uint_9
into %uchar_9 = OpConstant %uchar 9, which spirv-val rejects with
"Cannot form constants of 8- or 16-bit types".
Skip folding to a constant in those passes when the module can't
declare a constant of the result type.
auto-merge was automatically disabled
October 30, 2026 17:48
Head branch was pushed to by a user without write access
apollo-2006
force-pushed
the
fold-int8-without-capability
branch
from
October 30, 2026 17:48
31f4331 to
53ae00d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With only
StorageBuffer8BitAccess(noInt8), constants of 8-bit types aren't allowed, but CCP and simplification were foldingOpUConvert %uchar %uint_9intoOpConstant %uchar 9, which spirv-val rejects:glslang's
spv.bufferhandle11.fraghits this under-O,-Osand--legalize-hlsl. This skips folding to a constant in those two passes when the module can't declare a constant of that type (same rule as the validator: 8/16-bit ints and fp16 withoutInt8/Int16/Float16).Added tests to
ccp_test.cppandsimplification_test.cpp. test_opt passes, and running glslang's tests through spirv-opt only changesspv.bufferhandle11.frag(invalid to valid). Let me know if you'd rather handle it somewhere else :)