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.
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.
This is the support for non-floating-point matrices,
which are emulated using arrays of vectors because
SPIR-V does not allow non-floating-point matrices.
* Initial support for non-fp matrix
* Add support for non-fp matrix in all()
* Conversion of float matrix to int matrix
* support for modf returning an int matrix
* Add tests for non-fp matrix access
* Mixed arithmetic for non-fp matrices
* Support non-fp matrix in flat conversion
* Non-fp matrix in asint/asuint/asfloat
* Mul of non-fp Matrix with Vector/Scalar
* Add tests for non-fp matrix cast
TODO: Layout decoration of non-fp matrices
TODO: Majorness of non-fp matrices
According to HLSL doc, "variables that are placed in the global scope
are added implicitly to the $Global cbuffer, using the same packing
method that is used for cbuffers."
But we emit all global variables as stand-alone SPIR-V variables.
This causes issues for matrix variables since we cannot annotate
them with majorness decoration anymore.
Wrap global matrix variables in a struct to solve the problem.
This commit add support for generating OpSpecConstant* instructions
with SpecId decorations. Spec constants are only allowed to be of
scalar boolean/integer/float types. Using spec constant as the array
size does not work at the moment.
This only supports .GetSamplePosition() for standard sample
positions, i.e., sample count is 1, 2, 4, 8, or 16. For other
cases, the method will just return float2(0, 0).
Added a new command line option -fvk-ignore-unused-resources
to avoid emitting SPIR-V code for resources defined but not statically
referenced by the call tree of the entry point in question.
[[vk::builtin("...")]] is introduced to support Vulkan-specific
builtins.
There are two supported in this commit:
* gl_PointSize
* gl_HelperInvocation
Validating the usages of these two builtins is left for anther
commit.
[[vk::push_constant]] can be attached to a global variable of
struct type to put that variable in the PushConstant storage
class.
PushConstant should be of OpTypeStruct type with std430 layout.
* Translation of GroupMemoryBarrier(WithGroupSync)
* Translation of DeviceMemoryBarrier(WithGroupSync)
* Translation of AllMemoryBarrier(WithGroupSync)
This commit supports .Append() and .RestartStrip() method calls
on stream-output objects, which will be translated into SPIR-V
OpEmitVertex and OpEndPrimitive, respectively.
For each .Append() call, all affected stage output variables
will be flushed.
This change is an extension of float16 support. We are adding LoadHalf, LoadFloat, and LoadDouble method to byte address buffer so that users can access data from byte address buffer by these types. Also starting shader model 6.2, we are mapping byte address buffer and structure buffer load/store operations to RawBufferLoad/Store to differentiate raw buffer load from typed buffer load. Unlike BufferLoad for typed buffers, RawBufferLoad for min precision types will not have its min precision values as its return types, but their actual scalar size in buffer (i.e rawBufferLoad.i32 for min16int and rawBufferLoad.f32 for min16float). RawBufferLoad/Store contains additional parameters, where mask was required for correct status behavior for CheckAccessFullyMapped, and alignment is for relative alignment for future potential benefit for backend.
As per the Vulkan spec requirement:
Any variable decorated with Position must be declared as a
four-component vector of 32-bit floating-point values.
But for HS/DS/GS, we actually have an extra arrayness. If we
generate a stand-alone Postion builtin variable, it will be
an array of float4, which does not comply with the spec.
Similary for the type requirements on ClipDistance and
CullDistance.
The spec could have an problem on this issue, but the GLSL way
is to emit a gl_PerVertex that contains Position, ClipDistance,
and CullDistance. That satisfies the current Vulkan spec.
This commit converts VS output, HS/DS input and output, GS
input to emit the gl_PerVertex struct. It also splits arrays
of structs into arrays of the fields for HS/DS/GS input/output.
ClipDistance/CullDistance is also supported in this commit,
which requires quite some non-trivial handling.
A new attribute [[vk::counter_binding(X)]] can be used to specify
the binding number for associated counters for RW/append/consume
structured buffers.
Also added support for .IncrementCounter() and .DecrementCounter()
for RWStructuredBuffer.
Also fixed the type error of OpAtomicI{Add|Sub}.
Added the following four command line options to shift register
number for Vulkan:
* -fvk-b-shift
* -fvk-t-shift
* -fvk-s-shift
* -fvk-u-shift
These options are used to avoid assigning the same binding
number to more than one resources.
This change is to enforce the new constraint on signature packing: pack signature elements by data width. Before we introduce fp16 type, every element was assumed to reserve 32 bits. Since we are introducing a new 16 bit data type, we need a new way to enforce signature rules.
After discussions we decided that it would be nice to pack elements based on data width. However, we are still enforcing the rule that each row contains up to 4 elements, regardless of the size. This way, depending on the hardware support drivers can optimize packing signatures, while on DXIL level we maintain the assumption that there are 4 elements per row. We are also still constraining on the total number of rows to be 32 for now. This can be changed in the future if people find this limit to be an issue.
* [spirv] OpImageRead can read a vector of any size.
* [spirv] Add support for Load() of RWTexture types.
* [spirv] Texture2DMS and Texture2DMSArray types.
* [spirv] Capability for 1D images without a sampler
* [spirv] Update documentation of Texture2DMS(Array)
Moved logistics and designs to the wiki page. Now the doc is only
for HLSL to SPIR-V mappings.
Also link to the doc and wiki page in the main README.md.
A new CL option -fvk-stage-io-order={alpha|decl} is added to
control the order for assigning stage I/O location numbers.
The default is also changed to declaration order (decl) instead
of alphabetical order (alpha).
Also extended testing fixtures to support additional CL options.