Add command line support which enables the following behavior:
- Remap discard
Map discard to DemoteToHelperInvocation for HLSL shaders. Map to
OpTerminateInvocation for GLSL shaders.
- Decorate HelperInvocation with Volatile
- Use localSizeId for execution mode
WorkGroupSize is deprecated in spirv1.6
Also update known goods to SPIRV 1.6
Fix OpImageRead result type when compiling HLSL
- Per the Vulkan spec, OpImageRead must return a 4-component vector always. When compiling HLSL, loads from a RWTexture of a template type with < 4 components would incorrectly generate an OpImageRead with a < 4 component result, resulting in validation errors.
- This was previously fixed for OpImageFetch in commit 4425f24; this commit does the same thing for OpImageRead.
- Added associated tests and expanded existing image fetch tests to check all the different types of textures, in both float and int incarnations, for completeness.
- Update other HLSL tests involving OpImageRead
Generate load of interpolant for first operand to GLSLstd450
InterpolateAt* SPIR-V ops. This allows the interpolants to
propagate from the input struct in the wrapper around main
into the shader during HLSL legalization. A new pass has been
added to legalization which will remove the load and replace
with the pointer of the load to create valid external
interpolate op.
Fixes#2584
Translate printf() to what GL_EXT_debug_printf has done. HLSL could
define non-constant string variable and we don't have such features
in SPIR-V, so just support constant string variable.
Previously, casting an object of a struct type to an identical type
would produce an error. This PR allows this case.
As a side-effect of the change, several self-type casts in existing
tests go away. For example:
0:10 Construct float ( temp float)
0:10 'f' ( in float)
becomes this (without the unneeded constructor op):
0:10 'f' ( in float)
For vector or array types this can result in somewhat less overall code.
Fixes: #1218
SPIR-V requires the coverage mask to be an array of integers, but HLSL
allows scalar integers. This adds the requisite type conversion and
wrapped entry point handling.
Fixes: #1202
This PR forces the external definition of SV_GroupID variables to 3-vectors.
The conversion process between the shader-declared type and the external type
happens in wrapped main IO variable conversion.
The same applies to SV_DispatchThreadID and SV_GroupThreadID.
Fixes: #1371
Append() method is special: unlike most outputs, it does not copy
some temporary data to a symbol in the entry point epilogue, but
rather uses an emit builtin after each write to the output stream.
This had been handled by remembering the special output symbol for
the stream as it was declared in the shader entry point before
symbol sanitization. However the prior code was too simple and
only handled cases where the Append() method happened after the
entry point, so that the output symbol had been seen.
This PR adds a patching step so that the Append()s may appear in
any order WRT the entry point. They are patched in an epilogue,
whereupon it is guaranteed in a well formed shader that we have
seen the appropriate declaration.
Fixes#1217.
HLSL allows image and texture types to be templatized on sub-vec4 types,
or even structures. This was mostly handled already during creation of
sampling operations. However, for operator[] which can generate image
loads, this wasn't happening.
It also isn't very easy to do at that point in time, because operator[]
does not know where the results it produces will end up. They may be
an lvalue or an rvalue, and there's a post-process to convert loads to
stores. They may end up in atomic ops.
To bypass that difficulty, GlslangToSpv now looks for this case and
adds the appropriate conversion. LIMITATION: this only works for
cases for which a simple conversion opcode suffices. That is to say,
it will not work if the type is templatized on a struct.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
Issue #791 was partially fixed by PR #1161 (the mat mul implicit
truncations were its main point), but it still wouldn't compile due to
the use of ConstantBuffer as an identifier. Apparently those fall into
the same class as "float float", where float is both a type and an
identifier.
This allows struct definitions with such keyword-identifiers,
and adds ConstantBuffer to the set. 'cbuffer int' is legal in HLSL,
and 'struct int' appears to only be rejected due to the redefinition
of the 'int' type.
Fixes#791
HLSL truncates the vector, or one of the two matrix dimensions if there is a
dimensional mismatch in m*v, v*m, or m*m.
This PR adds that ability. Conversion constructors are added as required.
If a shader includes a mixture of several stages, such as HS and GS,
the non-stage output geometry should be ignored, lest it conflict
with the stage output.