In experimenting with bumping the max shader model version in the mesh
nodes branch, many unrelated tests started failing due to being
overly-sensitive to ordering, particularly for metadata. This uses
regular expressions or order-independent checks to make these tests more
robust so they will be able to handle the change to 6.9 when it comes to
main, whatever form that takes.
Followup to #6432
Simple missing case, should have implemented it in the first place.
Also noticed that from a recent change to move to raw buffer writes, the
debug output UAV offset was being set to a non-dword aligned offset. No
drivers/hardware seem to care, but it's a concerning thing to leave
as-is.
Emits SPIR-V InterpolateAt* instructions from the GLSL.std.450 extended
instruction set for EvaluateAttribute*. Relies on the optimizer's copy
propagate passes to ensure that these instructions are passed valid
pointers in the Input storage class after legalization.
Fixes#3649
Check size of PSV part matches the PSVVersion.
Updated DxilPipelineStateValidation::ReadOrWrite to read based on
initInfo.PSVVersion.
And return fail when size mismatch in RWMode::Read.
Fixes#6817
Updates the submodules. One test started to fail because the
"needslegalization" flag was not set correctly. That was fixed by
identifiying SubpassInput as an opaque type.
This pr will introduce the HLSL standard header files. This will become
the a
way to add new extensions to HLSL without having to make modifications
to the
compiler.
This first example is a fairly complex example that demonstrates how to
do a few
different things:
1. Trying to create a simple class interface that allows the compiler to
naturally enforce the validation rules. In this case, we might be more
strict
than the spir-v validation, but I believe this is still usable.
2. How to create a builtin that can be expanded by the spir-v backend.
The
OpCooperativeMatrixLengthKHR instruction does not have an interface that
is
natural in a language like HLSL. However, we can define a function that
is, and
have the backend, make small adjustments. These cases should be avoided
as much
as possible.
When splatting a groupshared scalar, we would trip an "Invalid
constantexpr cast!" assertion. This would happen while evaluating the
ImplicitCastExpr to turn the groupshared scalar into a vector because
the scalar expression was in a different address space (groupshared) vs
the target vector (local). The fix is to ensure that when looking up the
vector member expression, insert an lvalue-to-rvalue cast if necessary;
i.e. when a swizzle contains duplicate elements.
Those flags allow the user to hardcode the binding ID for the heaps.
This allow the user to either force heap aliasing, or simply have more
control over the heaps.
Fixes#6913
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
DxilPipelineStateValidation.h is included from multiple environments.
Conditionally include <assert.h> here is to avoid overwriting the assert
that's using by the code which includes this header.
Fixes#6922
String literal are not supported in HLSL, except in the special printf
case.
Most cases were handled, but not the templated function case.
Fixes#6877
Signed-off-by: Nathan Gauër <brioche@google.com>
Replace the memcpy check for PSV0 part.
Build DxilPipelineStateValidation object from data in PSV0 part. Then
compare the content with information from input DxilModule.
With this change, the order of signature elements and resources could be
different between the container and the DxilModule.
And the StringTable could be in different order as well.
Second step for #6817
Add specific handling for inline spirv pointer types
We currently blindly create a new type for all vk::SpirvType* types.
This can cause problems when the type is suppose to match another type.
In this case, we want a spirv pointer type to match the pointer type of
the
variable. The OpTypePointer for the variable is implicitly created when
declaring the variable, but, if we want to explicitly declare the
pointer as a SpirvType, we get two different OpTypePointer instructions
in the module. So technically the types do not match.
To fix this, I add special handling in the SPIR-V backend to be able to
merge the implicit pointer type created and the SpirvType when they
match.
This implements the SPIR-V Pointers in [HLSL spec proposal
0021](https://github.com/microsoft/hlsl-specs/blob/main/proposals/0021-vk-coop-matrix.md#spir-v-pointers)
---------
Co-authored-by: Nathan Gauër <github@keenuts.net>
As we're starting to grow some new language features that are more
convienent to write in headers, having a set of headers that are
distributable without attribution requirement is a big win. These
headers will all be contributed under the Apache 2.0 with LLVM exception
license to align with upstream LLVM and provide apporpriate protections.
ScalarizePreciseVectorAlloca would iterate over all instructions, then
for each instruction use, would iterate and potentially erase the
instruction. If the erased instruction was the immediate next
instruction after the alloca, this would invalidate the outer
instruction iterator. Fixed by collecting the allocas in a vector first.
We have done all of the development on this feature that we will do.
We cannot handle Multidimentional arrays of these buffers because Vulkan
does not allow it.
We cannot handle arrays that are in a struct if the counter variable is
used. We have tests cases to identify those cases.
Closes https://github.com/microsoft/DirectXShaderCompiler/issues/5440
Compile `SampleCmpBias` using `OpImage*SampleDrefImplicitLod` and
`SampleCmpGrad` using `OpImage*SampleDrefExplicitLod`.
The existing handlers for `CalculateLevelOfDetail` and
`CalculateLevelOfDetailUnclamped` work for the
`SamplerComparisonSampler` overload, so no new code is needed other than
tests.
We currently add the linkage attribute only if there are no extry
pointer. However, there are cases where we may want an extry point with
an exported function.
This commit add the linkage capability any time it sees the linkage
attribute decoration. Note I do not add the linkage attribute all of the
time and leave it to the capability trimming pass because having this
capability with vulkan shaders is generally illegal, and I don't want
the unoptimized code to fail validation.
Fixes#6738
Currently, viewid mask for primitive output is always empty. This change
will fix it by treat entry as PC entry and skip output when it is not
what is checking.
For #6817
The impetus for these changes was unexplained crashes in a display
driver while attempting to create a debug-instrumented shader for PIX.
The heart of it is the new test in pixtest.cpp: use the compiler to
generate a raw UAV, and then compare the generated DXIL with what PIX
generates for the same purpose.
Some of the PIX passes need only one UAV for a module, but some need two
or more. In the latter case, the previous code was a bit loose about
what it was doing with respect to adding the UAV resource, and creating
its handles for each interested function. Most of the actual changes
herein are to do with that.
Lastly, the PIX UAV is raw at the D3D API level, but the instrumentation
had been doing non-raw writes. No driver seemed to care, but I've fixed
it anyway.
There is already a workaround for the SV_BaseInstance inconsistency
between HLSL and SPIR-V. The same issue applies to SV_BaseVertex, but no
such option is available. This commit adds the
-fvk-support-nonzero-base-vertex option, which behaves the same as the
-fvk-support-nonzero-base-instance option.
1. Number of SemanticIndex should match number of rows instead of number
of columns.
2. Mesh shader could have ViewID mask for Primitive output.
For #6817.
The code has an assert when processing an OpLoad in the literal visitor
to make sure that the result of the load is not a literal type. This is
not always true. If there is a compiler-generated, temporary variable
that gets its type from a literal, then the result type of the load will
have to be decuded by the literal visitor. That is not always possible.
However, the code already handle this situation correctly. If the result
of the load is a literal type, then the function will return true
without doing anything because `canDeduceTypeFromLitType` will return
false, as it should.
Fixes#6798
With inline spir-v, it becomes important for users to know which version
of SPIR-V is being targeted. They may need to generate different code
depending on the version.
This commit add these `__SPIRV_MAJOR_VERSION__` and
`__SPIRV_MINOR_VERSION__` to the compiler.
Add init functions to help build
PSVSignatureElement0/PSVRuntimeInfo/PSVResourceInfo.
Add print function for DxilPipelineStateValidation.
Add new option -dumppsv to dxa for testing.
For #6817.
The build* entry in .gitignore was intended to exclude any build
directories with whatever suffixes a developer might use for various
build configurations. The way it was written made it exclude any file
that had build in the name, which was more aggressive than needed.
By adding a leading slash, it is limited to items in the git root
directory. By adding a trailing slash, it is limited to directories in
the root directory. This accomplishes the intended exclusions as
narrowly as possible.
(I swear I'm not trying to win a bet on writing the longest description
of a two character change in history)
Fixes#4733
The changes affect both the internal validator (used within the DXIL
compiler) and external validation tools. Now, by default, validator hash
is enabled for all validation processes.
#6863 was created for tracking the skip hash discussion.
This is second step for #6808.
Fixes#6857
Move DxilValidation out of HLSL.
Also move code to validate dxil container into
DxilContainerValidation.cpp from DxilValidation.cpp.
This is a preparatory step for #6817.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Some recent features require the vulkan memory model. We need a way to
support it in DXC. This commit adds an option to enable the Vulkan
memory model. The generated code will not change, but the compiler will
call the upgrade-memory-model pass in spirv-opt to generate the correct
code.
The expectation is that new code that requieres the vulkan memory model
can be written using the vulkan memory model, and then have the pass
update other references.
This change will undo the fix for #6066. The device scope in GLSL450 was
not a real device scope. It corresponds to QueueFamily scope in the
Vulkan memory model. We will start to use that scope for the atomic
operations in order to keep the behavoiur of the atomics the same
between the two memory models.
Haveing a true device scope atomic will not be possible with DXC. We
should be able to do something better when atomic operations are
implemented in clang.
Fixes#5784