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

4756 Коммитов

Автор SHA1 Сообщение Дата
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
Xiang Li 9e039e254e
Move dxil.dll to DXC repo. (#6866)
Build dxil.dll in DXC repo.
It will shares same validator code with dxcompiler.dll.

Fixes #6769
2024-09-05 11:27:19 -07:00
Xiang Li 72f306c883
[ViewID] build viewid mask for primitive output (#6886)
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
2024-09-05 18:09:06 +00:00
Shaikh Yaser 663785ad7c
Typo fix in Readme file (#6890)
Replaced 'As of of' to 'As of'
2024-09-03 09:17:54 -07:00
Jeff Noyle bf24b7a54d
PIX: Rationalize UAV generation (#6883)
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.
2024-09-03 09:02:07 -07:00
artamonovoleg bb3a0c3641
[SPIR-V] add -fvk-support-nonzero-base-vertex option (#6865)
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.
2024-09-03 09:25:44 -04:00
Steven Perron b766b43267
Process subrecord decls in spirv backend (#6879)
The spir-v backend does not recurse into structs defined in struct in
doRecoredDecl. This causes us to miss some declarations.

Fixes #5916
2024-08-28 16:56:06 -04:00
Xiang Li 6c99ecfc8a
[Dump] Fix PSV dump issues. (#6881)
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.
2024-08-28 12:24:18 -07:00
Xiang Li 6227e57c25
[Build] Update to clang-18 for linux clang pipeline (#6876)
This is to work around LeakSanitizer issue 'LeakSanitizer has encountered a fatal error.'

For #6769
2024-08-26 10:09:55 -07:00
Steven Perron 9c6b2c1275
Remove invalid assert in literal visitor (#6875)
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
2024-08-23 09:47:43 +02:00
Steven Perron 7dcf2b483d
Add SPIRV version macros to DXC (#6874)
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.
2024-08-22 10:01:27 -04:00
Xiang Li 8a677d22cb
[NFC] add utils for PSV. (#6869)
Add init functions to help build
PSVSignatureElement0/PSVRuntimeInfo/PSVResourceInfo.

Add print function for DxilPipelineStateValidation.

Add new option -dumppsv to dxa for testing.

For #6817.
2024-08-21 15:24:52 -07:00
Greg Roth 9018970f26
Correct build exclusion in gitignore (#6870)
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
2024-08-20 15:24:50 -07:00
Xiang Li 913ae2ce86
[Validator] enable validator hash by default. (#6853)
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
2024-08-16 14:24:32 -07:00
Xiang Li 0e7591a6ee
[NFC] Move DxilValidation to a dedicated folder. (#6849)
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>
2024-08-13 17:33:09 -07:00
Antonio Maiorano f810e92e72
scalarrepl-param-hlsl: fix zero replacement in entry (#6855)
This is the same fix as was done in
https://github.com/microsoft/DirectXShaderCompiler/pull/6516 except that
this is for replace uses of zero-init for instructions in the entry
block.
2024-08-12 13:24:31 -04:00
Steven Perron 06da989c4a
[SPIRV] Add vulkan memory option to DXC (#6848)
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
2024-08-08 12:47:52 -04:00