Граф коммитов

4772 Коммитов

Автор SHA1 Сообщение Дата
Jeff Noyle 848b7c42bd
PIX: Make shader access tracking pass return whether or not it modified anything (#7010)
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.
2024-11-21 08:48:09 -08:00
Steven Perron e824ae3d67
[SPIRV] Check if decl is identifier before getting name (#7012)
We hit an assert when trying to get the name of `operator()`. This is
fixed by first checking if it function declatarion is an identifier.

Fixes #6973
2024-11-20 17:19:38 +01:00
Nathan Gauër 9b9442cd86
Update bug_report_spirv.md (#6988)
Removes shader playground link. Shader playground hasn't been updated
since earlier this year, hence DXC version is very stale.
2024-11-19 17:06:11 +00:00
Steve Urquhart 891392e87e
[SPIRV] Emit DebugFunction/Definition for both wrapper and real functions (#6966)
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.
2024-11-18 17:01:12 -08:00
Xiang Li 72b353a345
[tools] add -help option for opt. (#7002)
Add -help option to opt in opt.cpp.

The -help option for opt in clean llvm3.7 was disabled with 
[disable
-help](d5bb3089cf (diff-1c7e1b16bc72f52ebd811ef2a24aa91fc4df0f9b47c279b75d0bbb0ae1684d0aR1719))

Fixes #5514
2024-11-16 02:59:29 +00:00
Xiang Li ee98b2e09d
[Test] fix typo in CompileToShaderHash which compares same value. (#6999)
Compare hashFromPart and hashFromResult.

Fixes #5147
2024-11-15 17:21:36 -08:00
Nathan Gauër ac36a797d3
[SPIR-V] Fix cast elision with initializer lists (#6992)
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>
2024-11-01 13:23:50 -04:00
Cassandra Beckley 5704c4744e
[SPIR-V] Handle vectors passed to asuint (#6953)
`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
2024-10-29 23:03:15 +00:00
Nathan Gauër 6a7eae1bbe
[SPIR-V] Fix image write to unknown format (#6984)
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>
2024-10-28 17:25:46 +01:00
Nathan Gauër ee1f013dcf
[SPIR-V] Fix bad OpLoad on loaded texture (#6985)
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>
2024-10-28 10:34:57 -04:00
Nathan Gauër e090984225
[SPIR-V] Fixes SPV_KHR_fragment_shading_rate preventing optimizations (#6980)
Updated the SPIRV-Tools version to bring 2 fixes.

Fixes #6915

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-10-28 10:30:10 -04:00
Antonio Maiorano a023a95f73
Do not require __STDC_LIMIT_MACROS and others (#6976)
Apply LLVM patch: https://reviews.llvm.org/D21553
GitHub commit:
f4437e9b48 (diff-5fb0c3e347a7fc69d806be92c7b786cda1018152b3d264e3293697a1ac41eb7eR61)

This fixes compilation of DXC with latest libc++, which removes C
headers like locale.h and stdint.h:

aa7f377c96
2024-10-22 11:43:41 -04:00
Steven Perron db90a461c5
[SPIRV] Simplify looking for input storage class (#6968)
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
2024-10-21 14:04:22 +02:00
Steven Perron c72be81fff
[SPIRV] Round the stride to be a multiple of the alignment. (#6967)
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
2024-10-21 13:56:38 +02:00
Steven Perron 16e67272b7
[SPIRV] Register all decls for a variable. (#6969)
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
2024-10-21 13:53:03 +02:00
Cassandra Beckley c6d98ef25c
[SPIR-V] Update dependencies (#6970)
Fixes #6960
2024-10-21 13:52:15 +02:00
Sergey Muraviov 7dcb4e6e0c
Both blocks of the if statement are identical. (#6965)
Simplification of the code due to the fact that both blocks of the if
statement are identical.
2024-10-17 09:18:50 -07:00
Greg Roth 26d7dd984b
Ready tests for 6.9 version (#6465)
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
2024-10-14 15:01:05 -07:00
Jeff Noyle 080aeb7199
PIX: Implement shader access tracking for descriptor-heap-indexed TLAS for TraceRay (#6950)
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.
2024-10-10 17:44:15 -07:00
Cassandra Beckley b26fd8099a
[SPIR-V] Implement EvaluateAttribute* functions (#6945)
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
2024-10-08 14:53:49 -04:00
Farzon Lotfi b48341e403
[NFC] Fix a spelling mistake (#6946)
We have folks implementing the `firstbithigh` intrinsic and I noticed
this SPIRV error has a misspelling.
2024-10-04 16:05:20 -04:00
Jesse Natalie d6d3f02bac
Fix DxilPayloadFieldAnnotation::GetPayloadFieldQualifier (#6942)
Fixes #6941
2024-10-04 09:18:38 -07:00
Cassandra Beckley 775a6b8bdd
Update dependencies (#6944)
Pulls in the InterpolateAt* support for SPIRV-Tools.
2024-10-03 17:58:06 +00:00
Xiang Li 9221570027
[Validator] Check size of PSV. (#6924)
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
2024-10-02 20:48:32 -07:00
Xiang Li b05313c384
Unwrap top-level array for OutVertices when flattenArgument. (#6943)
For primitives and vertices output of mesh shader, we need to unwrap the
top-level array to get correct semantic index.

Fixes #6940
2024-10-02 21:43:40 +00:00
Xiang Li dfa1c814cc
[Doc] Update release notes for dxil validator hash. (#6904)
Add release notes for dxildll open sourced.

Fixes #6808
2024-10-02 10:48:17 -07:00
Steven Perron 75ff50caa0
[SPIRV] More test fixes (#6937)
The coop matrix tests all use `dxc` instead of `%dxc` in the tests.
Fixing that up.
2024-09-26 15:17:41 -04:00
Steven Perron e12d3a7e44
[SPIRV] Update submodules (#6936)
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.
2024-09-26 15:17:15 -04:00
Steve Urquhart 5c16ae70d5
[SPIRV] Fix NonSemanticDebugInfo to include all files (#6935)
Previously, we fixed the SPIRV OpenCL debug info to always represent all
include files, even those that only have preprocessor definitions. This
work was merged in
https://github.com/microsoft/DirectXShaderCompiler/pull/6094. This PR
applies the same fix to the NonSemantic debug info, and resolves
https://github.com/microsoft/DirectXShaderCompiler/issues/6907
2024-09-26 11:41:02 -07:00
Steven Perron c0c01e900d
[SPIRV] Change "dxc" to "%dxc" in tests (#6934)
The workgroupspirvpointer tests use `dxc` in the run commands, and it
should be `%dxc`.
2024-09-26 06:53:28 -04:00
Steven Perron c299228599
Add header file to define cooperative matrices in spir-v (#6720)
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.
2024-09-25 19:54:22 +00:00
Nathan Gauër 88fcc1b031
[SPIR-V] Fix build with -DENABLE_SPIRV_CODEGEN=OFF (#6933)
A 'using' was not gated.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-09-25 17:37:38 +00:00
Antonio Maiorano 0372fb792d
Fix assertion on splat of groupshared scalar (#6930)
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.
2024-09-25 01:14:38 +00:00
Cassandra Beckley d9a5e97d04
Update deps for release (#6929) 2024-09-24 13:01:29 -07:00
Nathan Gauër 97af068e42
[SPIR-V] Add -fvk-bind-*-heap flag to DXC (#6919)
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>
2024-09-20 16:01:06 +02:00
Zhengxing li 9bfbee6c44
Conditionally include <assert.h> in DxilPipelineStateValidation.h (#6925)
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
2024-09-19 14:16:35 -07:00
Steven Perron 26ea670d97
Fix mismatched memory allocation and deallocation. (#6923)
In NestedNameSpecifier.cpp, the Append function allocates data using
`new`:


e1bb926f63/tools/clang/lib/AST/NestedNameSpecifier.cpp (L449-L450)

However, if it deallocated using `free`:


e1bb926f63/tools/clang/lib/AST/NestedNameSpecifier.cpp (L514-L516)

This can cause problems. I'm changing the `free` to `delete`.
2024-09-19 19:10:56 +00:00
Nathan Gauër 9f298d6fa2
sema: fix string literal allowed in templates (#6920)
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>
2024-09-19 16:42:37 +02:00
Xiang Li 5155b0934c
[Validator] Check content of PSV0 part in validation (#6859)
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
2024-09-19 07:24:28 -07:00
AndreyVK_D3D e1bb926f63
Update SPIR-V.rst (#6918)
Supports SPV_KHR_float_controls

05334a70d3/tools/clang/lib/SPIRV/FeatureManager.cpp (L293)
2024-09-18 11:22:07 -07:00
Steven Perron 4e799936fb
Add specific handling for inline spirv pointer types (#6873)
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>
2024-09-16 18:41:53 +00:00
Chris B 09e4742436
Add license and readme for HLSL header library (#6872)
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.
2024-09-16 11:24:36 -05:00
Antonio Maiorano 05334a70d3
Fix CMake gen failing when HLSL_BUILD_DXILCONV=0 (#6912)
Target dxildll depends on DxcRuntimeEtw, so make sure to add this
target, even when HLSL_BUILD_DXILCONV is false.
2024-09-12 19:04:41 +00:00
Antonio Maiorano f11914c4ef
Fix ASAN UAF in DxilConditionalMem2Reg (#6910)
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.
2024-09-11 17:57:50 -04:00
Nathan Gauër b400c7281e
[SPIR-V] Fix isfinite/isinf generation for mat/buffers (#6905)
In some cases (matrices for ex), we generated the wrong result type for
isinf/isfinite.

Fixes #6783

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-09-10 17:52:32 +02:00
Nathan Gauër efdee6c994
deps: update spirv-headers/spirv-tools (#6906)
Pull latest revision of both repositories.

Fixes #6804

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-09-10 17:51:53 +02:00
Steven Perron 496482c4e4
Enable vk-allow-rwstructuredbuffer-arrays, and remove option (#6903)
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
2024-09-09 20:32:17 -07:00
Cassandra Beckley ca2e67d29e
[SPIRV-V] Implement Shader Model 6.8 Expanded Comparison Sampling (#6854)
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.
2024-09-09 18:42:24 +00:00
Steven Perron 937c8c8811
Add linkage capability based on decorations (#6900)
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
2024-09-06 14:30:08 -04:00
Xiang Li 0fd84aa814
[Test] Add validator version check for tests (#6901)
This change adds validation version check for the tests.

This is for fix tests fail when running on different version of
validator.
2024-09-05 17:47:30 -07:00