The SAT pass will now report a string when it finds that no resource
access was performed by a module.
This solves two issues.
-The SAT pass, when operating on a shader that has no resource access,
will add a resource declaration for the PIX output UAV. This becomes a
problem for PIX in terms of juggling root signatures and/or root
parameters.
-SAT is a notoriously time-consuming operation in PIX, so if the SAT
pass can report that its results do not need to be re-packaged into a
new container for passing to the d3d API, then PIX can avoid the
overhead of doing so.
But of course we need to be careful that the SAT pass doesn't
erroneously report that it didn't modify the module when in fact it did,
cuz then PIX would fail to notice some dynamic resource accesses. That's
what the tests are for.
https://github.com/microsoft/DirectXShaderCompiler/pull/6758
unfortunately caused a regression for shaders compiled without -fcgl.
This PR extends the original fix and corrects the regression. We now
emit DebugFunction and DebugFunctionDefinition pairs for both the
wrapper and the main functions, and a DebugEntrypoint that points at the
wrapper function. This survives inlining.
When an a chain of casts were performed in an initializer list, only the
source and destination types were considered. This means float -> uint
was the same as float -> int -> uint. This however is not correct:
intermediate casts can change the result.
Removing the shortcut we took solves this issue.
Fixes#6975
Signed-off-by: Nathan Gauër <brioche@google.com>
`asuint` should be able to take vectors in addition to scalar values.
Previously, it would be lowered as a bitcast from the input value to a
vector of uints with a width of 2, which is not large enough if the
input value is larger than a scalar value. In order to handle, for
example, an input value that is a `double4`, we instead perform a
component-wise bitcast.
Fixes#6735
By default, texture format is guessed from the type. But the
`vk::image_format` attribute can be added to specify it.
The `unknown` value was used to convey `no format selected`, and require
the guess to happen.
This made selecting `unknown` as value impossible.
Once the optional added, we have a new issue:
- The format setup relied on the legalizer.
- load/stores are done using the default format, then we fix it, then we
use the legalizer to propagate the format fix to all users.
The capability visitor is running before the legalizer, meaning it can
look at a non-fixed load, which still carries the old type.
The way to solve this is to remove this logic, and move the capability
addition/deletion to the capability_trimming pass, run after
legalization.
Fixes#6981
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
This code path always added an OpLoad since it expected either an
OpAccessChain or a variable.
This is wrong if we get the texture from a called function.
There is one thing I do find weird is the OpAccessChain result is
considered to be an L-value. But I'd expect this to be an r-value.
Fixes#4136
Signed-off-by: Nathan Gauër <brioche@google.com>
The function `DeclResultIdMapper::isInputStorageClass` tries to
determine the storage class for the stage variable by looking at its
SigPoint. This does not always work.
This change simply looks at the storage class that is already associated
with the variable, which should have been set when the StageVar was
created.
Fixes#6959
We currently pick the size of a struct to be the stride of the array
elements when doing scalar layout. This is not correct because this
could cause the struct to not be correctly aligned.
This is fixed by rounding the size of the struct up to a mutliple of the
alignment.
Fixes#6947
Some variable can have multiple decls. In one case, there could be a
declaration of a const static member variable that is later defined. All
of these decls need to be in astDecls and associated with the same
variable.
The current code will only add the decl for the defintion. This leads to
problems when trying to find the variable for the declaration.
Fixes#6787
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