For GLSL function imageAtomicStore, it will be translated to
OpImageTexelPointer + OpAtomicStore. The result type of
OpImageTexelPointer must be the same as the sampled type of OpTypeImage.
On translation, the result type is mistakenly fetched from operand list
operands[2] while operands[2] corresponds to sampleNum whose type is
always uint. This leads to an error if the image type is iimageXXX that is
int image.
Root cause:
GlslangToSpv use symbol structure's ptr as a map key, but multiple shader object can build a new AST.
In the AST the the same symbol has different ptr point to their structure, so indext map faild.
solution:
Add a new map glslangTypeToIdMap to map ptr to symbol id, and use symbol id to index memberRemapper.
v2: Move addCapability and addExtension extension calls from
TGlslangToSpvTraverser::createBinaryOperation to
TGlslangToSpvTraverser::visitAggregate. Suggested by JohnK.
More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
- a merge block becomes OpLabel, then OpUnreachable
- a continue target becomes OpLabel, then an OpBranch back to the
loop header
- any basic block which is dominated by such a merge block or continue
target is removed as well.
- decorations targeting the removed instructions are removed.
Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
If the semantics that require the KHR form over the EXT form are seen
(OpBitcast between a vector and a pointer) promote the requested extension
from the EXT to the KHR.
Saved about 21K, size down to 380K of MSVC x86 code.
Fixed one bug that needs to be looked at on the master branch:
The test for needing a Vulkan binding has a bug in it, "!layoutAttachment"
which does not mean "no layoutAttachment", because that is non-zero.
This is why some test and test results changed.
About 50 fewer #ifdefs.
About 14K smaller.
Note, the base size is ill-defined due to optimizer settings (size vs. performance),
compression, and target architecture. Some recent %'s are accidentally reported as
3X the real savings. Early %'s were accurate. What matters though is that each
step got worthwhile gains, and what the final size ends up being.
Focus was on the front end (not SPIR-V), minus the grammar.
Reduces #ifdef count by around 320 and makes the web build 270K smaller,
which is about 90% the target size.
The grammar and scanner will be another step, as will the SPIR-V backend.
This makes heavy use of methods #ifdef'd to return false as a global way
of turning off code, relying on C++ DCE to do the rest.
Save about 100K.
N.B.: This is done by eliminating a function call, at a high level,
not by #ifdef'ing a bunch of code.
Also, removed no longer needed *_EXTENSION #ifdef in the code not
needed by GLSLANG_WEB.
On reading built-in variables SubgroupEqMask, SubgroupGeMask, SubgroupGtMask,
SubgroupLeMask, and SubgroupLtMask, the AST expects 64-bit ints, while SPIR-V
is defined as vectors of 32-bit ints.
The declaration type has to be translated in the opposite direction.
Including spirv and AST tests
Also increase size of TBuiltInVariable bitfields since we've now exceeded 127
and add a static_assert to make this easier to find next time it happens!
Closes#1735
GlslangToSpv.cpp
- minor formatting cleanup
BaseTypes.h
- minor formatting cleanup
- add subgroup builtins to GetBuiltInVariableString
(was resulting in "unknown built-in variable" messages in test output)
Initialize.cpp
- better naming and re-use of strings for subgroup builtin variable declarations
- define subgroup builtin variables in ray-tracing shaders
intermOut.cpp
- add handling of the EOpSubgroupParition* variables
(was resulting in "ERROR: Bad aggregation op" messages in test output)
Update test results.