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

3022 Коммитов

Автор SHA1 Сообщение Дата
Helena Kotas d5608d5ffd
Remove LLVM_C_FALLTHROUGH instances that cause warnings on clang-12 (#6192)
The clang-12 warning is:

error: fallthrough annotation in unreachable code
[-Werror,-Wimplicit-fallthrough]

These LLVM_C_FALLTHROUGH were originally added to silence GCC warnings,
but the GCC PR validation build is has succeeded, so it looks like they
are not needed.

(cherry picked from commit eb4cec4ad1)
2024-01-23 23:27:52 +00:00
Jeff Noyle 5d31c2ded7
PIX: CP of shader debugger regression (#6054)
CP of main PR (#6053), regression caused by main PR
https://github.com/microsoft/DirectXShaderCompiler/pull/6033

The misplacement of that "return" in DxilDebugInstrumentation.cpp meant
that a thread would continue to the following call to
addStepDebugEntryValue, even if pix_dxil::PixDxilReg::FromInst had
failed (i.e. returned false), which means that RegNum is not valid
(although initialized to 0).

This meant that PIX was instrumenting a bunch of void-return DXIL
instructions that it shouldn't have.
Didn't think to test that it WASN'T instrumenting instructions, but
herein is added a test to do just that.

(cherry picked from commit 71afbcc7cf)
2023-11-22 10:34:22 -08:00
Jeff Noyle 78863cda87
PIX: CP of two fixes (vars in inline fns, instrument ret for shader debug) (#6039)
These are two fixes needed for a point release of WinPIX
Original PRs:
https://github.com/microsoft/DirectXShaderCompiler/pull/6033
https://github.com/microsoft/DirectXShaderCompiler/pull/5954

Since PixDiaTest.cpp would require bringing over a whole bunch of
changes that were made for the linux build, I elected to remove that
file from the CP. These commands were used to generate this PR:
git cherry-pick -n -x 2c19e8121b
git rm tools/clang/unittests/HLSL/PixDiaTest.cpp
git commit -am "CP of 2c19e8121b without
PixDiaTest.cpp"
git cherry-pick -x 5ffdf14527
2023-11-17 17:05:52 -08:00
Joshua Batista 52da17e29a
[ExecutionTests] Add validation and signing step to isNormal Test CherryPick (#5798)
The IsNormal tests required an addition to the testing framework
provided by ShaderOpTest.cpp, known as the MakeShaderReplacementCallback
function. This function takes a shader, compiles it to DXIL,
disassembles it into a string, replaces anything specified in the
function parameters, and reassembles the shader back into a dxil
container. The problem with the initial implementation was that after
disassembling the shader, the signature applied to the shader on the
compile step would be lost.

This PR adds a validation / signing step right after assembling the
shader to ensure the new DXIL container has a signature. This will
prevent problems with calling CreateComputePipelineState due to a
missing signature.
Verified that this fails when disabling experimental mode, and passes
only when dxil.dll is available.
Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/5337

(cherry picked from commit
3974b57d12)
2023-09-28 15:50:45 -07:00
Jeff Noyle 9d02d824fb
WinPIX: Cherry-pick of "Find correct filename for subroutines in included headers within namespaces (#5776)" (#5787)
From a customer bug report, the previous code would skip over a
DISubProgram scope if that scope was contained in a DINamespace (as in
the first test case herein, wherein an include file is enclosed in a
namespace). This would result in DXIL being attributed to the includer
file instead of the included file.

(cherry picked from commit 5adc7bcf67)
2023-09-26 15:56:55 -07:00
Helena Kotas c60cbc0bed
Fix HelperLaneTest (release branch version) (#5769)
Add `-opt-disable sink` to HelperLaneTest shader compilation to prevent
sinking of `ddx_fine`/`ddy_fine` intrinsics into flow control.

Separate issue has been filed to track down the root of the problem:
#5744: Intrinsics ddx_fine/ddy_fine should not be allowed to sink into
flow control
2023-09-22 03:17:47 +00:00
Jeff Noyle 66faf0d7b0
CP: PIX: unnamed types, and debug instrumentation control (#5670)
CP of two PIX fixes
2023-09-14 14:39:25 -07:00
Helena Kotas edc1bf03a8
DXC Tests: Filter out unsupported test, add verbose option and improve output (#5537) (#5657)
Improve output of DXC test runs:
- Add `-lit-verbose` option to `hctbuild` to setup lit test runs with
verbose output (`hcttest` will list test names as they run)
- Hide tests that are never supported (there was over 10K of unsupported
tests found by LIT discovery)
- Show warnings about non-essential tools only in LIT debug mode
- Skip over file copying and non-LIT part of `hcttest.cmd` if all
requested tests have already been run
- CMD tests have been move under clang's lit tests; keep the `hcttest
cmd` option for running cmd tests separately

Number of unsupported tests was reduced from 10452 to 1 if spir-v is
enabled, 39 if not. The number of tests that run did not change.

(cherry picked from commit b503da7084)
2023-09-06 11:34:27 -07:00
Helena Kotas c52f704a60
Lit TAEF fixes: Use filter when listing tests and fix verbose parameter (#5494) (#5656)
Lit TAEF files fixes:
- Use filter parameter when enumerating tests. This enables listing of
just the tests that should run, and it also filtering by architecture.
This is crucial for isolating ARM64 and ARM64EC versions of tests that
are in the same test dll.
- Fix verbose parameter - it was not getting applied
- Enable verbose on all tests - the output is shown only when the test
fails

Related to #5489.

(cherry picked from commit 96e13a0e0a)
2023-09-06 11:34:02 -07:00
Helena Kotas 9da643f9d6
WArgV is needed only on non-Windows platforms (#5576) (#5592)
Fixes internal build break.

(cherry picked from commit f206b3d19d)
2023-08-23 17:35:49 -07:00
Jeff Noyle 7824d4d20b
PIX: CP of "Educate debug data interface about nested namespaces (#5558)" (#5580)
The comment from the checkin kinda says it all:
// DINamespace has a getScope member (that hides DIScope's) // that
returns a DIScope directly, but if that namespace
                // is at file-level scope, it will return nullptr.
(The upshot of this is that you couldn't step into functions within a
namespace in WinPIX's shader debugger)

(cherry picked from commit c2233c6c0a)
2023-08-21 17:10:35 -07:00
Greg Roth 69e54e2908
Fix attribute collision for HL intrinsics (#5451) (#5543)
HL Intrinsic functions share declarations with those that match group
and function signature, regardless of the original intrinsic name. This
means that intrinsics with differing attributes can be collapsed into
the same HL functions, leading to incorrect attributes for some HL
intrinsics.

This fixes this issue by adding the attributes to the HL operation
mangling, the same way this issue was fixed for the HLWaveSensitive
attribute before.

Fixes #3505

---------

Co-authored-by: Joshua Batista <jbatista@microsoft.com>
(cherry picked from commit d9c07e90e1)

Co-authored-by: Tex Riddell <texr@microsoft.com>
2023-08-14 17:29:54 +00:00
Chris B ba06290a66
Fix debug info generation for `this` (#5534) (#5536)
My recent changes to correct AST inaccuracies around `this` objects
caused crashes in debug info generation for `this`. This resolves the
crashes by making the code behave correctly when `this` is a reference.

This has no change to debug info output. The added test case should
verify the same output we've always had, but is an important addition
since this was not tested in our pre-merge testing.

Fixes #5530

Cherry-pick of dc82ed29c9
2023-08-14 08:42:58 -07:00
Jeff Noyle 8031652496
CP: Pix changes for hitgroup/miss debugging (#5529)
…shaders (#5499)

Two main themes:
-Add instrumentation to the DXR hit group and miss shader types -Return
a bit more info to the caller (PIX) via output text

(cherry picked from commit 3693755da6)
2023-08-10 14:56:39 -07:00
Chris B 0cc4dca946
This is really a reference (#5473) (#5522)
This fixes a few cases that were missed when I updated `this` objects to
be references. Specifically we were still generating some implicit
`this` cases as pointers, and we were not always correctly looking
through the reference types.

Fixes #4709

Cherry-pick of 871fba1edc
2023-08-10 11:46:47 -05:00
Greg Roth bf7fd1a536
Allow select() to work with samplers (#5508) (#5524)
Add any_sampler builtin parameter type. This will match any sampler type
as the select() built-in added with HLSL 2021 requires.

Adds a new built-in overload that takes the any_sampler type and ensures
that the last two arguments and return type match. Many of the changes
were required because we never had to ensure object parameter types
matched nor transmit that type to the return type before. Most of the
changes to MatchArguments in SemaHLSL are addressing new issues this
revealed. Non-basic types can pass the conversion check if they outright
match.

Adds testing to select() and the ternary operator that it supplements
for these usages

Fixes #4673

(cherry picked from commit a6497c3894)
2023-08-10 11:42:24 -05:00
Xiang Li 7502f0f985
[lit] Only enable spirv lit test when spirv build is enabled. (#5471)
To avoid test fail when spirv build is not enabled.
2023-07-28 08:57:16 -07:00
Steven Perron 6c9592f24a
Enable the vk::counter_binding attribute for arrays (#5456)
The `vk::counter_binding` binding attribute is defined to only apply to
scalars because until recently arrays of RWStructuredBuffers and the
like could not be arrays. That has changed, so the attribute can apply
to the arrays of RWStructuredBuffers.
2023-07-28 03:20:56 -07:00
Helena Kotas 0033aa85b5
Allow new/delete operators to be called before DllMain (#5454)
Allow new/delete operators to be called before DllMain and allocator
initialization in DxcInitThreadMalloc().

The operators can be called before DllMain from CRT libraries when
static linking is enabled. If that happens, the new/delete operators
will fallback to the standard allocator and use CoTaskMemAlloc/Free
directly instead of CoGetMalloc, Alloc/Free & Release for better perf.

Enables fixing of
[#5163](https://github.com/microsoft/DirectXShaderCompiler/issues/5163)
and
[#5178](https://github.com/microsoft/DirectXShaderCompiler/issues/5178).
2023-07-28 01:01:55 +00:00
Chris B 634c2f3499
Make HLSL 2021 the default language mode (#5466)
This enables HLSL 2021 as the default language mode. The mode can be
overridden to older language modes using the -HV flag.

Fixes #5465
2023-07-27 18:22:10 -05:00
Xiang Li b4044d29cd
[lit] [SPIRV} Copy legal-examples to lit (#5320)
Copy SPIRV tests under legal-examples and modify to work with lit.

This is first PR for moving SPIRV test to lit.
The reason to copy instead of moving the tests is to make sure not lost
coverage before all tests switch to lit. And update all tests in one PR
will be a PR with 1000 files.
2023-07-27 19:20:49 -04:00
Xiang Li 65aa41f9b6
[lit] use lit.py directly to allow send parameter to lit from hcttest (#5438)
This is for support adapter option for exec test when using lit.
no_priority is enabled for clang test too.

CMake behavior will be the same except not support adapter option.

Also hcttest cmd will only run cmd test for lit.
2023-07-27 14:37:49 -04:00
Steven Perron b97f9b9388
Handle passing an element of a RWStructureBuffer array to a function (#5447)
getFinalACSBufferCounter currently returns a CounterIdAliasPair. This is
because all cases in the original design could return the entire
counter variable. When using arrays for RWStructuredBuffers, we will
need to be able to return something the represents a portion of the
array that is needed. The best method of doing that is to write reusable
functions that return a SpirvInstruction whose result is a pointer to
the approparite element of the array.

This is then used to allow copying individual counter variables.

It does not handle copying the entire array of counter variables.
2023-07-26 15:19:41 +02:00
Chris B 573b652210
Instantiate argument default parameters (#5443)
This addresses a latent bug in Clang that was fixed _way_ after DXC was
forked. We encounter it in DXC because of the way that we inject AST
bits through the external sema source, but it likely wasn't exposable
through C++.

This change is mostly a back porting of the following upstream LLVM
commits:

llvm-project/73c6a2448f24
llvm-project/f721e0582b15
llvm-project/c601377b2376
llvm-project/4409a83c2935

The end result of this change is that we still lazily instantiate
default arguments, but we do force them to be instantiated during sema
when they are used.

Fixes #5145
2023-07-24 10:19:07 -05:00
Steven Perron 15c8723458
Generate counter for arrays of RW, consume, and append structured buffers. (#5415)
This commit adds code to generate counters for single dimensional arrays
of RW,consume, and append structured buffers.

After this commit, the counter can be used if the global resource is
used directly.
2023-07-20 23:48:13 -07:00
Joshua Batista af0b809140
Error out if two blobs compiled with different compiler versions are linked. (#5361)
This PR aims to accomplish the final step of the task to prevent blobs
compiled with different compiler versions from being linked together.
The same compiler is used to compile both blobs in the test, but the
compilerversion part in the first blob is forcefully changed to conflict
with the compilerversion part within the second blob.
The test detects the correct error message, which mentions the names of
the two libraries that differ, and what their differing versions are
exactly.
The PR aims to resolve this issue:
https://github.com/microsoft/DirectXShaderCompiler/issues/5310
2023-07-20 11:16:16 -07:00
Steven Perron 9021cae50b
Expand WaveActiveAllEqual with vector and matrix arguments. (#5428)
For vector and matrix inputs to WaveActiveAllEqual, the
OpGroupNonuniformAllEqual instruction must be applied on each element of
the vector or matrix, and then have the results combined into a vector
or matrix of bools. We make that change in this PR.

Fixes #5426
2023-07-19 12:58:44 -07:00
Adam Yang 325ae8efbf
Fixed a crash when linker erases functions that still have users. (#5437)
When linking to library with a list of `-exports`, the linker erases
functions that are not exported assuming they are no longer used. This
assumption is not correct when the function is a constructor for a
global variable. This change fixes the crash by first checking whether
the function still has uses before erasing.

This change adds a regression test with a non-trivially removable global
variable constructor that would crash without this change.
2023-07-19 11:48:57 -07:00
Xiang Li cdee4461c9
[Build] cleanup build dependency (#5432)
Add LLVMHLSL dependency to LLVMIPO and LLVMScalarOpts. Remove
passprinters from LLVMHLSL to avoid cycle.

This is to fix link error found when trying to enable clang_cc1.
2023-07-19 01:06:31 -04:00
Antonio Maiorano 44f8833938
Add macro to disable usage of allocator overrides (#5296)
Add macro DXC_DISABLE_ALLOCATOR_OVERRIDES which, if defined, will use
the default CRT allocator for new/delete and malloc/realloc/free.

We need this on Chrome for our GN build of DXC, because our component
builds use libc++as a shared library, and we end up with mismatched
new/delete calls between libc++ and these custom overrides.

---------

Co-authored-by: Chris Bieneman <cbieneman@microsoft.com>
2023-07-17 15:27:30 -04:00
Steven Perron 1501181418
Update spirv-headers and spirv-tools (#5419)
Updates the submodules, and disables validation on two tests. The SPIR-V
is invalid, and spir-val just started checking it. Since we have been
generating this code for a while, I do not see the need to modify the
generated code immediatly.
2023-07-17 10:28:48 -07:00
Nathan Gauër f4dcc6e296
SPIRV: don't generate invalid debug instructions (#5397)
When generating debug instructions for a function, each one is linked to
its scope.
In case of member functions, this scope is the class.

When declaring a class, all its member, including functions must be
declared.

This cycle requires a forward reference, which is allowed by the debug
instruction spec, but not by parents: NonSemantic & SPIR-V specs. This
is a spec issue we have to fix. In the meantime, we decided to emit a
warning, and generate slightly worse debug instructions.

Context: https://github.com/KhronosGroup/SPIRV-Registry/issues/203

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-07-17 12:40:19 +00:00
Steven Perron 34b47c2c8b
Allow arrays of RW, consume, and append structured buffers. (#5405)
This is the first commit in a series that will enable array of
RW, consume, and append Structured buffers. This commit removes the
error when one is used on its own.

There will be a failure if a counter variable is needed.

This is the first PR is a series that will slowly enable different
features for arrays of RWStructuredBuffers. To see the general direction
the changes will go see
https://github.com/microsoft/DirectXShaderCompiler/pull/5407.
2023-07-13 17:23:36 +00:00
Kirill Kozlov 38fcd6f741
[SPIRV] Add option to preserve interface variables (#5400)
Add `-fspv-preserve-interface` CLI option to prevent DCE optimization
pass from compiling out interface variables. It happens if these
variables are unused.

The option may be useful when decompiling SPIR-V back to HLSL.
Personally, I need it to convert DX12 shaders to DX11 ones using
SPIRV-Cross as a tool for converting SPIR-V, produced by DXC, to the old
shader model HLSL.

SPIR-V Tools now have a parameter in `RegisterPerformancePasses()` and
`RegisterLegalizationPasses()` for this. This PR creates a new command
line option in DXC and passes it to the `spvtools::Optimizer`.

Closes #4567
2023-07-11 12:20:58 +02:00
Joshua Batista 6287d513d1
Error on diff blob versions part 1 (#5378)
This PR is the first of 2 PRs to prevent libraries of different compiler
versions from linking together. This first PR implements adding the
compiler version information into the Dxil Container itself, to allow
for comparison later. It also adds some basic validation to the new part
in the Dxil Container.
2023-07-10 11:01:06 -07:00
Steven Perron e931c944ce
Make assert consistent with the code (#5382)
There is an assert that checks if a variable will be placed in the
Function or Private storage class in the spir-v. However, the condition
checked in that assert is inconsistent with the part of the code that
determines which storage class a variable belongs to.

The fix is to make the function `isExternalVar` available outside of
SprivEmitter.cpp, and use that in the assert. Now the same check is used
everywhere.

Fixes #5273
2023-07-07 11:50:09 -07:00
Nathan Gauër 6289ba317e
[SPIRV] Emit Offset decoration for PhysicalStorage structs (#5392)
When the SPV_EXT_physical_storage_buffer extensions is used, vulkan can
load raw addresses. For structs loaded through this mecanism, the
offsets must be explicit.

This commit fixes decoration emission by attaching the correct layout
when a struct is loaded using this extensions.
(Specifying a layout different than void forces explicit offsets).

Fixes #5327

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-07-07 17:17:51 +00:00
Nathan Gauër dcf754c264
Fix SPIRV struct reconstruction with bitfields (#5390)
HLSL/SPIR-V structs have some layout differences due to bitfields being
squashed.
The reconstruction logic was using the AST layout, and not the new
SPIR-V layout, meaning we could generate invalid indices during
extraction/construction.

This PR fixes a potential bug with bitfields, while making the code
reusable.

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-07-07 11:57:23 -04:00
Nathan Gauër 2096d1b805
Revert "[SPIR-V] add support for extension KHR_fragment_shading_barycentric (SV_Barycentrics)" (#5384)
Reverts microsoft/DirectXShaderCompiler#4638
This PR causes multiples issues (#5326, #5342, #5270). Reverting, will
need more testing.

Fixed #5270
2023-07-04 09:39:23 -04:00
Steven Perron bf2d6c073a
Propagate literal types through loads. (#5339)
We currently do not do anything to determine the correct type for
variables with a literal type. This leads to type mismatches. In this
commit, I propagate the type the result of the load to the variable that
is loaded. This makes sure that the load is correct.

Fixes #5319
2023-06-30 11:42:09 +02:00
Steven Perron 8d9daa25d4
Process enums in class (#5330)
The SPIR-V emitter does not process enum that are declared in class.
This leads to errors in some places it will be used. The fix is to
process the enum in the same place that static variables for an enum are
processed. They are essentially treated like a static variable.

Fixes #5325
2023-06-30 10:57:14 +02:00
Chris B b28885f7d0
[NFC] Fix RUN line in SPIR-V test (#5344)
This was introduced from an out-of-date PR.
2023-06-28 20:11:12 +00:00
Jaebaek Seo 1d2bc2c05f
[spirv] emit valid stride for array of empty struct (#3885)
Fixes #3101
2023-06-28 11:02:53 -04:00
Adam Yang 8e0e56fe9d
Made linker preserve nops for Od. (#5317)
For `-Od`/`-O0` compilations, the compiler generates nop instructions in
the form of:

```
@dx.nothing.a = internal constant [1 x i32] zeroinitializer
...
%0 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @dx.nothing.a, i32 0, i32 0)
```
This instruction is intended to be a complete no-op, and backends that
recognizes this pattern can turn it into proper hardware specific no-op
instructions for debug purposes.

When linking DXIL libraries, the passes that run end up removing these
nops. This change adds a new pass `DxilReinsertNops` to run at the
beginning of linking to read the `LoadInst`s representing nops and turn
them back into calls of `dx.noop`, before turning back into loads again
at the end.
2023-06-28 01:21:29 +08:00
Steven Perron 8f2881e511
Propagate bitwidth for BitCast in LiteralTypeVisitor (#5324)
For a BitCast instruction, the bitwidth of the operand must be the same
as the bitwidth of the result type. That requirement is coded into the
LiteralTypeVisitor, so that we do not get validation errors.

Fixes #5319.
2023-06-27 14:37:43 +00:00
Jeff Noyle c9b50a588a
WinPIX: File-check test for new DXR invocations log pass (#5322)
A test for the DXR invocations log pass
2023-06-25 08:49:59 -07:00
Xiang Li 3dc858f82f
[NFC] [lit] [SPIRV] change header ext from hlsl to hlsli (#5304)
This is to avoid lit treat the headers with hlsl ext as Unresolved
Tests.
2023-06-22 13:14:41 +02:00
Steven Perron e8b1fcb05f
Add cast after RWByteAddressBuffer atomic compare exchange (#5295)
* Add cast after RWByteAddressBuffer atomic compare exchange

The type of the RWByteAddressBuffer is always uint in the SPIR-V
representation. This means that the OpAtomicCompareExchange instruction
must have parameters and a result of type uint. If the original code
used an in for the result, then there is a type mismatch when storing
the value. This is fixed by add a cast when appropriate.

Fixes #4741
2023-06-20 11:19:58 -04:00
Steven Perron 0ed5abb419
Handle size 1 vectors in getTypeWithCustomBitwidth (#5305)
Vectors of 1 element are handled as scalars in the spir-v backend
because the element count of [vectors in

spir-v](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpTypeVector)
must be at least 2.

This case is not handled in getTypeWithCustomBitwidth and is causing an
assert. The fix is to add code to explicitly handle vectors of size one.

Fixes #5130
2023-06-20 13:10:30 +02:00
Austin Kinross 6a3e2485de
[PIX] Add pass to log DXR 1.0 shader invocation info into a UAV (#5301)
This PR adds a new PIX pass that instruments DXR 1.0 shaders
(intersection, any/closest hit and miss). The new pass emits each shader
invocation's [ray system
values](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#system-value-intrinsics)
and DispatchRaysIndex into a UAV that can be read back later. This will
enable new DXR debugging features in PIX.
2023-06-16 14:01:18 -07:00