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

4513 Коммитов

Автор SHA1 Сообщение Дата
Tex Riddell 364a5234dc
Make tests robust for high-level opcode changes. (#6010)
Several workgraph tests had AST checks which check not only the expected
operation attribute by name, but included the opcode value, which is not
stable when HL operations are changed.

This change removes the high-level opcode value from the CHECK lines.
2023-11-14 11:43:44 -08:00
Xiang Li bdd7d9b0b9
[lit][SPIRV] move shaders to lit folder (471 left to go) (#5998)
Convert from bottom of CodeGenSpirvTest.cpp.

Skipped FileTest::CompatibilityWithVk1p1 as barrier for runCodeTest.
2023-11-14 11:07:59 +01:00
Xiang Li ba90e249df
Remove InsertAddrSpaceCastIfRequired which is redundant (#5862)
For users of hlsl::ReplaceUsesForLoweredUDT, only
EmitGetNodeRecordPtrAndUpdateUsers will has V and NewV with different
address space. But there will be no addrspacecast for NodeRecordPtr from
clangCodeGen, because NodeRecordPtr doesn't have address space before
HLLowerOperation.

As a result, when hit addrspacecast in hlsl::ReplaceUsesForLoweredUDT,
the address space of V and NewV should match. So
InsertAddrSpaceCastIfRequired will always has AddrSpace !=
Ty->getPointerAddressSpace().

Removed InsertAddrSpaceCastIfRequired and add assert for address space
mismatch.

Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/5695
2023-11-13 13:25:48 -05:00
Nathan Gauër 3fdcaf9688
[SPIRV][NFC] Fix iterator usage after invalidation (#5926)
This is a quick fix to unblock users, but it could hide other issues.

During this iteration, some function down the line push_back to the
debugInstructions vector. If the storage gets moved, then we fail.

Fixes #5566
Signed-off-by: Nathan Gauër <brioche@google.com>
2023-11-13 13:58:33 +01:00
Xiang Li 89710e5694
[Build] remove VS_STARTUP_PROJECT to avoid require cmake3.4 (#5994)
Since we don't use dndxc as startup project in most cases, just remove
the VS_STARTUP_PROJECT so not need cmake3.4 to build on windows.
2023-11-10 19:37:00 -05:00
Xiang Li 8d38549821
[SM68] convert workgraph verify test as lit test (#6000)
Fixes #5964
2023-11-09 23:00:47 +00:00
Xiang Li 668ecf2c09
[Linux] Enable PDBUtil test for Linux build (#5942)
Added CComBSTR::Length for WinAdapter.

Use VERIFY_ARE_EQUAL_WSTR to verify CComBSTR.

Use UTF8 for Linux test.

This is for #5877
2023-11-09 14:16:14 -05:00
Greg Roth 0c322bda24
[lit][SPIRV] convert runFileTest shaders to lit FileCheck test (#5929)
Convert from bottom of CodeGenSpirvTest.cpp.
Skipped FileTest::CompatibilityWithVk1p1 as barrier for runCodeTest.
2023-11-09 11:53:34 -07:00
Xiang Li 4a6fdfa20f
[CI] add workflow to apply clang-format diff (#5984)
When hit clang-format error in a pull request, edit the comment with
diff.
Add @apply-format at the beginning of the comment and Update comment.  
 

New added "Apply code format" workflow will be triggered.  
It will checkout the code from compare branch of the pull request, apply
the diff,
then commit and push it to the compare branch to fix the format issue.  
  
The process should be getting clang-format diff comment first.  
Then review the diff in the comment.
If the diff looks good, edit and add @apply-format to apply the diff.
2023-11-09 13:37:21 -05:00
Helena Kotas ceff9b8043
Shader Model 6.8 (#5982)
Shader Model 6.8 is still a work in progress.

New features include:

**Work Graphs (experimental)**
Work Graphs define a system of shader nodes that feed into each other to
enable tailored GPU work creation.

**Wave Matrix (experimental)**
Wave Matrices are type abstractions of hardware support for higher
bandwidth matrix multiplications, useful in machine learning and image
processing. Previously called Wave Matrix Multiply and Accumulate or
WaveMMA for short.

**Orthogonal Comparison Sampling**
This is an addition to the existing sampling methods (`SampleCmp`,
`SampleCmpLevel`) with the difference between Orthogonal Comparison
Sampling and the existing methods is how the LOD is computed.

Comparison sampling prior to Shader Model 6.8 has supported the
following ops: `SampleCmp` with implicit LOD and `SampleCmpLevel` with
explicit LOD as of shader model 6.7, prior to that only
`SampleCmpLevelZero` was supported.

Methods added in Shader Model 6.8 are `SampleCmpBias` and
`SampleCmpGrad` as well as requiring `CalculateLevelOfDetail[Unclamped]`
to reference a non-comparison sampler object.

**Extended Command Information**
New system-value semantics `SV_StartVertexLocation` and
`SV_StartInstanceLocation`.
2023-11-08 17:19:30 -08:00
Helena Kotas 4b7b4ce637 Fix typo in DXIL.rst 2023-11-08 16:14:37 -08:00
Helena Kotas 89fbd19c85 Fix typo in Decl.RayQueryInFnSig validation rule 2023-11-08 15:40:37 -08:00
Helena Kotas 19fd70ae19 Merge branch 'main' of https://github.com/Microsoft/DirectXShaderCompiler into sm68 2023-11-08 15:28:29 -08:00
Helena Kotas 0e3de8736a
Turn off clang formatting for RDAT_LibraryTypes.inl and RDAT_SubobjectTypes.inl (#5986)
Turn off clang formatting for `RDAT_LibraryTypes.inl` and
`RDAT_SubobjectTypes.inl`. Macro indentation makes these files easier to
read.

This PR was created in 2 steps:
1. `RDAT_LibraryTypes.inl` and `RDAT_SubobjectTypes.inl` were reverted
to the version `64348c7e~1` The commit
64348c7eec is the first that started
preparing the code base for clang formatting. Except for that there were
no functional commits done to these files since then.
2. `//clang-format off` and a comment with explanation was added to the
top of these files
2023-11-08 15:03:28 -08:00
Helena Kotas d5ddb1e9df Clang formatting 2023-11-08 08:35:15 -08:00
Helena Kotas 01cedea8b5 Addressing code review feedback
- remove unused "class." parsing
- use llvm_unreachable instead of DXASSERT
- remove priority 2 from WaveMatrix execution tests
- use StringSwitch in validator arg parsing
- remove unused lit configs
2023-11-08 08:26:53 -08:00
Alexey Panteleev 6db52c7b56
[SPIRV] Implement dot4add_i8packed and dot4add_u8packed intrinsics (#5959)
This change implements the translation of the two DP4a intrinsics into
pairs of operations:
```
dot4add_i8packed -> OpSDot + OpIAdd
dot4add_u8packed -> OpUDot + OpIAdd
```

Note that the `OpSDotAccSat` and `OpUDotAccSat` operations are not
matching the HLSL intrinsics as there should not be any saturation.

The SPIR-V test for these intrinsics is also updated by copying and
adjusting the corresponding test from the DXIL side.

Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/4528
2023-11-08 09:45:50 -05:00
Antonio Maiorano 8147212ee5
azure-pipelines: Enable UBSAN on Linux_Clang_Release (#5978)
Now that all UBSAN issues have been fixed, we can enable UBSAN checks on
our CI.
2023-11-07 17:04:23 -05:00
Antonio Maiorano 63cbf4b58c
Fix enable asan on pipeline (#5976)
Two commits in this one:

 azure-pipelines: Fix ASAN not being enabled on Linux bot
    
Unfortunately, the following CL did not correctly spell out the CMake
    variable to enable ASAN properly:
    https://github.com/microsoft/DirectXShaderCompiler/pull/5799
    
    This commit fixes that.


 azure-pipelines: disable ASAN alloc_dealloc_mismatch checks
    
We are currently hitting false positives because of this. See the issue
I opened: https://github.com/microsoft/DirectXShaderCompiler/issues/5971
    
Perhaps a future Linux image will include a build of libc++ that does
not exhibit this false positive, at which point this workaround can be
    reverted.
2023-11-07 14:46:30 -05:00
Antonio Maiorano 0a141e7ccb
Improve pipeline build (#5977)
Two commits:

    azure-pipelines: Use 'lld' linker for Linux builds
    
    This should speed up the total build time using a faster linker.


   azure-pipelines: Add verbose flag to LLVM_LIT_ARGS
    
With `--xunit-xml-output` set, stderr is not fed to stdout, so we cannot
easily see the errors in the build log. The errors only appear in the
pipeline's "Test" tab. Adding the verbose flag allows it to also output
    stderr to the log.
2023-11-07 11:02:08 -05:00
Antonio Maiorano 0780548803
Fix ASAN stack-use-after-scope in SpirvEmitter::processGetAttributeAt… (#5975)
…Vertex

arg1ConstExpr->getValue() returns an APInt by value, and we were calling
getRawData() on the returned temporary, making the pointer dangle after
the statement executed, and the APInt temporary was destroyed. Fixed by
keeping the returned APInt on the stack.
2023-11-07 10:45:03 -05:00
Antonio Maiorano 519dd5bd56
Fix ASAN heap-buffer-overflow in PixTests (#5974)
PixStructAnnotation tests were converting an IDxcBlobEncoding to a
std::string, but this isn't valid if the underlying object is an
InternalDxcBlobEncoding_Impl, which holds a buffer that may not be
null-terminated. Fix this by using the BlobToUtf8 helper, which handles
this case gracefully.

Fixes 23 ASAN failures.
2023-11-07 10:44:50 -05:00
Antonio Maiorano 620c29d278
Fix ASAN leak in HLSL/ClangHLSLTests/RewriterTest.RunSpirv (#5972)
Reorder the GetStatus check that earlies out of the function before
creating a MemBufferCopy, otherwise it leaks upon early out.

This is a quick fix, but not the ideal one. The unique_ptr<MemoryBuffer>
gives the false impression that the buffer will be automatically cleaned
up; however, MemoryBuffer is just a pair of string and raw pointer to a
buffer, so no cleanup occurs. Indeed, there's no real need for
unique_ptr at all here. The ASTUnit::RemappedFile is passed down a chain
of functions until SetupCompilerCommon is called, where the buffer is
passed to compiler.getPreprocessorOpts().addRemappedFile, where
ownership is established. Ideally, a unique_ptr to the buffer would be
passed down, safely transferring ownership so that if an error occurs,
no memory is leaked. This will be for another day.
2023-11-07 10:44:32 -05:00
Helena Kotas 3e25309846 clang-format 2023-11-06 11:29:51 -08:00
Helena Kotas 8f9c5017d0 Merge branch 'staging-sm-6.8' of https://github.com/Microsoft/DirectXShaderCompiler into sm68 2023-11-06 10:46:43 -08:00
Tex Riddell 3ab440cdf7
Fix downlevel validation testing failures (#5979)
Moving some tests from CodeGenDXIL to HLSLFileCheck because they will be properly gated on validator version here. These can be moved back once we have support for this in lit shell test.

Added %dxilver for %dxv tests requiring new validator version.

Moved `DXILValidation/Metadata` tests to `HLSLFileCheck/validation/Metadata` to allow %dxilver.  Needed to add RUN line for the HLSL file there.

Added -select-validator internal to lit shell test that checks diagnostics, thus does not run through validation, and shouldn't be limited by external validator version.

Updated version requirement in ValidationTest::AtomicsInvalidDests because the message was changed in the latest validator version.
2023-11-05 23:20:30 +00:00
Steven Perron 0509463673
Add error message for incompatible image format and sampled type. (#5969)
This adds an error when the OpImageType create would violate the
requirements in

https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#spirvenv-format-type-matching.

Fixes #5955
2023-11-03 17:00:31 -07:00
Steven Perron 9ee884f34f
Use OpDemoteToHelper for clip (#5970)
The use of OpKill has been deprecated in later versions of spir-v, and
should not be used when OpDemoteToHelper is available. This commit
makes the use of OpKill in the implementation of clip conditional on the
extensions available and the vulkan version used.

Fixes #5955
2023-11-03 16:55:48 -07:00
Tex Riddell de3339ce3b
Merge main to staging-sm-6.8 (#5968)
Merging main @ 5f8737603d to staging-sm-6.8.
2023-11-03 15:18:11 -07:00
Helena Kotas 273f431320 One more conflict resolution fix 2023-11-03 13:53:21 -07:00
Helena Kotas f12d91c7cd Add back shader attribute to couple of PIX dia tests 2023-11-03 13:01:40 -07:00
Helena Kotas 33d695af5e Update SPIR-V submodules to be the same as main branch 2023-11-02 21:53:35 -07:00
Helena Kotas 627cf788e9 Update invalid_barrier_1.ll DXIL
Based on PR #5825: Update Barrier intrinsic to merge ACCESS and SYNC flags
2023-11-02 21:48:58 -07:00
Helena Kotas 536972d789 Add 2 verifier tests that were accidentally removed; update expected diags in template-diag-deferred.hlsl 2023-11-02 15:15:04 -07:00
Helena Kotas 96bb59b95a Merge branch 'main' into merge-from-main-11-2-no3 2023-11-02 14:25:31 -07:00
Helena Kotas 2377aa756f Format hctdb.py and hctdb_instrhelp.py with black for conflict resolution in the upcoming merge 2023-11-02 13:47:55 -07:00
Joshua Batista cd03365aa5
[Diagnostics] Improve recursion diagnostics, specifically for library shaders (#5858)
Previously, there would be no recursion validation performed on any
function declarations in library shaders. This PR adds code that
validates that no function declarations that are found inside library
shaders are recursive. The diagnostics aren't repeated, since there's
logic to prevent the same diagnostic from being emitted by 2 similar
ancestors of the same recursive function. The PR also adjusts recursion
detection for shaders in non-library cases, and improves the original
diagnostic by adding information about the name of the function that is
recursive. The PR is meant to complete the work on issue #5789. However,
more work needs to be done for full accuracy.
The PR checks *all* function declarations in the translation unit for
the library shader case, when it should really only be checking a subset
of function declarations. This issue is filed here: #5857
Fixes #5789
2023-11-02 10:33:41 -07:00
Xiang Li 5f8737603d
[lit] convert verify test as lit FileCheck test part2 (#5909)
Convert second part of verify test shaders as lit FileCheck test.

This is for #5870

Still same files left in HLSL folder need to check.
2023-11-02 10:10:26 -04:00
Antonio Maiorano 2155125c08
Fix UBSAN out-of-range of representable values errors (#5805)
Implicit casts of double to integer types result in UB if the value
cannot be represented as the target integer type. Use the APSInt
facilities to round the double, and truncate as necessary.
2023-11-02 09:29:36 -04:00
Xiang Li 00cd76e20f
[Diag] report error when SV_DispatchGrid has illegal type. (#5953)
verify that the input record field with SV_DispatchGrid semantic is a
valid type: 32 or 16-bit uint scalar or array/vector with up to 3
components.

Fixes #5845

---------

Co-authored-by: Chris B <cbieneman@microsoft.com>
2023-11-01 23:24:50 -04:00
Tex Riddell 8377726642
Fix RDAT table versioning for ver 1.8 (#5943)
- Reorganize part and table IDs to move shader info after ver 1.8
- Move NodeShaderInfo into RuntimeDataFunctionInfo2 shader info union,
since it is mutually exclusive with other shader types
- Remove RuntimeDataFunctionInfo3
- Re-organize RDAT_LibraryTypes into 3 sections by versioning
- Format unformatted section of RDAT_LibraryTypes due to typo
- Add indentation to make definitions easier to read and disable
clang-format for RDAT_LibraryTypes.inl and RDAT_SubobjectTypes.inl
- Include Node in ShaderStageFlags for 1.8+
- Added some explicit scopes due to VS IDE thinking they were ambiguous
- RDATDumper: Don't try to visit or print null records
- Fix reflection tests:
    - tests meant to check shader info use: -Vd -validator-version 0.0
    - use regex for record strides for versioning robustness
    - update ShaderStageFlags to include Node
- use regex for RuntimeDataFunctionInfo name for versioning robustness
    - remove shader info CHECKs for cases not meant to test that

Fixes #5900
2023-11-02 00:37:02 +00:00
Tex Riddell 52ace1c57c
Fix module loading and validation issues (#5880)
Fix module loading and validation issues

There are a couple interacting issues:
1. When RefreshCache occurs, it doesn't fill in the m_pResRetType cache.
  - This is because in GetOpFunc, if it finds a function matching the
    expected name, it simply returns that, skipping function type
    construction.
- This causes a validation error if CheckAccessFullyMapped is validated
    before a function that calls it.  This depends on the order of
    function declarations/definitions in the module.
- The solution is to move the check after type construction, and verify
    that the function type matches expectations as well.
2. When RefreshCache() and FixOverloadNames() was called from
DxilOperations
    constructor, the m_LowPrecisionMode has not yet been set, leading to
    incorrect overload types when allowing function type construction to
    proceed in GetOpFunc before looking for a matching function by name.
  - This leads to an incorrect type for 16-bit CBufRet type being used.
  - The solution is to move RefreshCache() and FixOverloadNames() calls
to after we actually know the m_LowPrecisionMode, so that the correct
    types may be constructed.

Rename hlsl::OP::SetMinPrecision to InitWithMinPrecision to make clear
what's being done.
Added validation tests to verify the fixes.
Fixed validation test that produced invalid DXIL op function signature.
Fix HLModule not setting min-precision mode when loading from metadata.

Fixes #5879
2023-11-01 12:32:06 -07:00
Xiang Li ae85bb8ceb
[lit] convert verify test as lit FileCheck test part1.5 (#5912)
Add non-lib profile RUN line when possible.
2023-11-01 14:04:50 -04:00
Xiang Li 245fd121d7
[Test] enable rewriter test for linux (#5908)
Added InitSupport to setup m_dllSupport and m_pIncludeHandler.

Work around GetTempPathW and GetFileSize.

RewriterTest.RunNonUnicode is disabled for dependent on Greek language
support.

This is for
https://github.com/microsoft/DirectXShaderCompiler/issues/5877
2023-10-31 16:45:46 -04:00
Xiang Li 3d1b501290
Add SV_BaseVertexLocation and SV_StartInstanceLocation to VSIn (#5770)
New VS Input semantics SV_BaseVertexLocation and
SV_StartInstanceLocation are added for
BaseVertexLocation and StartInstanceLocation of
https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-drawindexedinstanced

Also added DXIL operation for these 2 input semantics.

Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/2907
2023-10-31 14:43:37 -04:00
Xiang Li a333d3b8c3
[lit] convert verify test as lit FileCheck test part3 (#5910)
Move the verify shaders which not enabled in taef to lit.

This is for #5870
2023-10-31 13:53:40 -04:00
Xiang Li e496555aae
[Linux] Enable PixTest for Linux (#5945)
DxilDia is enabled for Linux with only
DxcPixLiveVariables_FragmentIterator enabled for PixTest.

Enabled PixTest for Linux build.

This is for #5877
2023-10-31 12:49:44 -04:00
Cassandra Beckley d66d34a417
[SPIR-V] implement vk::spvexecutionmode attribute for inline SPIR-V (#5927)
Implements `vk::spvexecutionmode` from
https://github.com/microsoft/hlsl-specs/blob/main/proposals/0011-inline-spirv.md#execution-modes.
2023-10-31 11:16:33 -04:00
Steven Perron c6cf5c9f14
Add execution mode for derivatives in compute shaders (#5939)
This commit adds the execution mode to compute shaders when derivatives
are used. I only added a single test because the derivatives are all
handled in one place. The choice of execution mode was tested using the
implicit LOD instructions.
2023-10-31 09:47:49 -04:00
Chow ed1502e9bc
Support PerVertexKHR decorated input and SV_Barycentric (#5649)
1. Replace extension AMD_shader_explicit_vertex_parameter with
KHR_fragment_shading_barycentric as they define same semantic.

2. Support new usage of SV_BaryCentrics and PerVertexKHR decorated
input.

3. For per-vertex inputs, they will be used as an array if a shader call
new intrinsic GetAttributeAtVertex explicitly.

4. Support mixed deprecate usage of `nointerpolation` qualifier. When
use non-interpolated inputs outside new intrinsic, it will be treated as
accessing to first provoking vertex : data[0]. But it will still be
treated as an array if used as a function call's argument.

5. As now we allow mixed usage of this kind of inputs, add spirv
instruction operand replacement in DXC. A new visitor will replace
normal access to those inputs with a new AccessChain instruction targets
its first element.

6. For bool and bool vector type, we reconstruct a new bool/boolVec type
array in entry function wrapper.
2023-10-30 15:28:13 -04:00