Previously we emit a store for each sub-element, which is not
friendly to SPIR-V transformations. This commit converted that
into first constructing a temporary value of the target storage
class, and the store once.
This commit uses the HlslCounterBufferGOOGLE decoration to link
the main RW/Append/Consume StructuredBuffer with its associated
counter buffer. It also uses HLSLSemanticGOOGLE to decorate
stage IO variables with their semantic strings from the source code.
In SPIR-V, if shifting a value by an amount that is greater than
the value's bitwidth, the result is undefined.
FXC and DXC/DXIL performs a bitwise and over the RHS of the shift
operation to only consider its (n - 1) least significant bits,
where n is the bitwidth of LHS.
Fix HoistConstantArray pass to recognize more complex load & store patterns.
Previously it was expecting no nesting and just a simple list of GetElementPtr's that fed loads or stores. Now it can accept a tree (DAG) of GetElementPtrs that feed leaf node loads or stores.
These patterns cannot be directly derived from HLSL, however they can occur due to previous optimizations that transform the array accesses (like a partial CSE or similar).
Previously we use an additional parameter to translateType()
to convey the matrix majorness info. It causes lots of type
inconsistency issue.
Now the majorness info is queried directly from the QualType.
This should be more robust.
This commit changes the behavior of how to handle externally-visiable
non-resource-type stand-alone variables. Previously they are emitted
as stand-alone SPIR-V variables. Now they are grouped into a cbuffer
that named as $Globals. This is more aligned with how DirectX handles
them.
Based on GLSL std140/std430 layout rules, relaxed layout allows
using vector's element type's alignment as the vector types's
alignment, so that we can pack a float value and a float3 value
tightly. This is the default right now.
Also add an option, -fvk-use-glsl-layout, to turn off the relaxed
layout for vectors and use conventional GLSL std140/std430 layout
rules.
Handle FlatConversion for cases such as:
```
S myS = (S)(1.0/0.0);
```
These cases result in an initializer of type 'literal float', even
though the initializer is *not* a FloatingLiteral!
Moved majorness info into SpirvEvalInfo so that we can translate
type correctly based on it. This affects accessing matrices inside
cbuffer; otherwise, we will have wrong type for the matrix field
loaded out of a cbuffer.
Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1112
Compound assignments don't have the proper AST nodes to implicitly
casting LHS and RHS to the same type. But it has an API called
getComputationLHSType() to tell us what the LHS are expected to
convert to when doing the computation. We need to take into
consideration of that information when CodeGen'ing compound
assignments.