A recent change from a recent PR includes changes to how the MDVals data
structure inside of EmitDxilFunctionProps gets elements (push_back
instead of index assignment).
However, there was no accompanying test for these changes, because
HLSLFileCheck\hlsl\workgraph\called_function_arg_nodeoutput.hlsl
exercised this code path and failed without the MDVals changes.
This PR adds some extra context to the above test so that the extra
purpose the above test serves isn't lost with time.
The test passes with the MDVals pushback changes, and fails with the
original valIdx index assignments.
Replace incorrect sizeof() with strlen() in compiler version test
This would produce a failure only on x86 because it sizeof() gave the size
of a pointer, which just so happens to be the hard coded size of the hash
on x64. On x86, it would advance only 4 bytes, and fail the comparison.
This also checks to see if the VersionStringListSizeInBytes is > 2 more than the hash size, because both null-terminators are always added, so it will always be at least 2 more, even with no CustomVersionString.
Add Shader Model 6.8 features in preview state: Work Graphs and Wave Matrix.
This code is considered preview ready, with more work planned before retail shaders can be compiled to Shader Model 6.8.
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.
When using libc++, the build fails with errors like:
error: incomplete type 'clang::DeclContext::udir_iterator' used in type trait expression
: public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
^
note: while substituting deduced template arguments into function template 'iterator_adaptor_base' [with U = const llvm::iterator_adaptor_base<clang::DeclContext::udir_iterator, clang::DeclContextLookupResult::iterator, std::random_access_iterator_tag, clang::UsingDirectiveDecl *> &]
class iterator_adaptor_base
This was fixed in upstream LLVM in this CL:
e78e32a443
(also see original review: https://reviews.llvm.org/D22951#change-zKJSAlLXXy11)
Unfortunately, the CL does not explain why this change was made, so I
can only assume that it was failing a libc++ build as well.
I also added the static_assert that was later added in this CL:
0aecae3452
This restores the build failure that would occur if U is not a base of DerivedT.
Although seemingly unnecessary for CMake builds of DXC, for our
GN build, we needed to write a script to replicate the behaviour of
CMake's "configure_file". Having an variable expansion with no variable
("${}") made the script more complex. Besides, this looks like a bug.
Remove scope resolution on call to SetupAndRun. This works on MSVC
presumably because of it's former non-conformant two-phase lookup. Clang
can be made to emulate this behaviour by enabling
`-fdelayed-template-parsing`, but GCC does not seem to support this flag.
It seems easier to just fix the code this way.
Several static functions from the signal API can be invoked
simultaneously; RemoveFileOnSignal for instance can be called indirectly
by multiple parallel loadModule() invocations, which might lead to
the assertion:
Assertion failed: (NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"),
function RegisterHandler, file /llvm/lib/Support/Unix/Signals.inc, line 105.
RemoveFileOnSignal calls RegisterHandlers(), which isn't currently
mutex protected, leading to the behavior above. This potentially affect
a few other users of RegisterHandlers() too.
rdar://problem/30381224
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298871 91177308-0d34-0410-b5e6-96231b3b80d8
Co-authored-by: Bruno Cardoso Lopes <bruno.cardoso@gmail.com>
* [Metadata] Limit bitfield annotation to validator version >= 1.7
Only emit bitfield annotation for validator version >= 1.7
This is to avoid validation error on old validator.
* Prevent update_spirv_deps.sh from updating re2 and effcee.
As per discussion in
https://github.com/microsoft/DirectXShaderCompiler/pull/5246, the
repositories re2 and effcee should not be updated when rolling
submodules forward.
* Also ignore DirectX-Headers submodule updates.
* Fix comment to match code.
The current behavior of the lifetime markers flags is to allow the
`-disable-lifetime-markers` flag to override the enable flag no matter
where it occurs. This means that if you write
dxc -disable-lifetime-markers ... -enable-lifetime-markers
the lifetime markers will be disabled. This works differently from most
clang flags which allow the last version of the enable/disable flag to win.
This PR modifies these flags so that when there are multiple occurences of
enable/disable the last one will win. It is not clear if the original behavior
was intentional or just a mis-understanding of the flag API. There were no
tests enforcing the original behavior.
When handling the swizzles in the SPIR-V backen, there is a special case when
the final result returns the original vector. It tries to avoid adding the
vector shuffle instruction in spir-v. However, that path calls `doExpr` instead
of `loadIfGLValue` like the other path. This can sometimes cause a load to be
omitted.
This is changed so that `loadIfGLValue` is called for both cases.
Fixes#5275
generated SPIR-V is invalid: [VUID-StandaloneSpirv-Flat-04744] Fragment OpEntryPoint operand 4 with Input interfaces with integer or float type must have a Flat decoration for Entry Point id 1.
%SubgroupLocalInvocationId = OpVariable %_ptr_Input_uint Input
This reverts commit 0a1f7a19f4.
Use an array of 32-bit integer values instead of 32-bit float values for the "dx.icb" immediate constant buffer data.
This prevents the FPU flipping the 22nd bit of integer constants, when their bit pattern represents a float32 signalling NaN on x86 architecture.
This change is causing rendering issues on PCs with AMD GPU and is blocking an upcoming Windows release.
The target branch of this revert is a release branch based on release-1.7.2212 at commit 83f8c6c5 and it will be used for the upcoming Windows release. The dxilconv change stays in main, at least for now.
(cherry picked from commit 03df61df18)
Replaced all the `if "%var%"==""` with `if [not] defined var`, which is
the proper way to determine whether the variable is defined or empty.
The other way breaks if statement parsing under various conditions.
This fixes handling of TAEF's /p:"var=val" parameter syntax as long as you
specify your additional TAEF parameters after a `--` argument break.
- Added `-opt-enable partial-lifetime-markers` to only generate `@llvm.lifetime.start` and not `@llvm.lifetime.end`.
`@llvm.lifetime.start` can sometimes be helpful for codegen, but inserting `@llvm.lifetime.end` in the right places sometimes requires modifying cfg in ways that could negatively impact codegen quality. This change adds a way to generate only `@llvm.lifetime.start` and not `@llvm.lifetime.end` for all the benefits it provides without the problems of inserting `@llvm.lifetime.end`.
The added `-opt-enable partial-lifetime-markers` is off by default, and only kicks in when lifetime-markers are enabled.
In cases where generating `@llvm.lifetime.end` is easy (around function calls for arguments), they are generated as normal.
-----------------------------------------------------
In certain cases, lifetime markers can help reduce register pressure by reducing lifetime of values. In this example:
```
for (int i = 0; i < N; ++i) {
S state;
if (conds[i]) {
state.x0 = input[i+0];
}
if (conds2[i]) {
output[i+0] = state.x0;
}
}
```
`State state` is declared inside the loop, but the alloca is effectively "hoisted" to the entry block, and the compiler has no knowledge that no value of `state` flows between loop iterations. The codegen ends up looking like this:
```
loop:
%last_iteration_val = phi float [ %new_val, %if.end.b ], [ undef, <preheader> ] ; <--- Value from previous iteration.
br i1 %same_cond, %if.then.a, %if.end.a
if.then.a:
%new_val.then = ...
if.end.a:
%new_val = phi float [ %last_iteration_val, %loop ], [ %new_val.then, %if.then.0 ]
br i1 %same_cond, %if.then.b, %if.end.b
if.then.b:
store %new_val
br %if.end.b
if.end.b:
br i1, <loop-exit>, %loop
```
`mem2reg` has special logic for handling `lifetime.start`, where it basically assumes it as a def for the alloca. With lifetime-markers turned on, the IR ends up looking like this:
```
loop:
// Notice the phi is gone.
br i1, %if.then.a, %if.end.a
if.then.a:
%new_val.then = ...
if.end.a:
// The undef is now here!
%new_val = phi float [ undef, %loop ], [ %new_val.then, %if.then.0 ]
br i1 %same_cond, %if.then.b, %if.end.b
if.then.b:
store %new_val
br %if.end.b
if.end.b:
br i1 %same_cond, <loop-exit>, %loop
```
When `state` is a big struct, and when the loop has many temporary values, the phis for previous loop iterations can cause very large register pressure.
* [lit] Clear temp directory for strip_dbg test.
This is for case the temp directory not remove and pdb hash changed.
If that happens, there will be 2 pdb files in the temp dir which cause strip_dbg.test fail.
* Enable lit by default.
* Update README for git user bin.
* Add DXC_DISABLE_LIT to replace DXC_ENABLE_LIT
* Set -DDXC_DISABLE_LIT=Off for appveyor.
* Keep original name for ClangSPIRVTests
* Set correct path for unit tests binary.
* Remove doc about DXC_DISABLE_LIT
* Remove extra space.
* Remove DxcOnUnix.rst.
* remove warnings on dxc
* address feedback
* remove removed functions' declarations
* get rid of another unused function
* use maybe_unused instead of if 0 when removing unused functions
* address commenting issues
* Revert "use maybe_unused instead of if 0 when removing unused functions" because c++17 extensions aren't enabled
This reverts commit 3a00d8eb84.
* remove incorrect scope
We currently check if the shader is a pixel shader when we see a
declaration of a SubpassInput type. However, it is possible that there
are multiple shader in the same hlsl file, and that the SubpassInput is
only used in the pixel shader.
So that we do not get an error in this case, I moved the check for the
shader type to the use of the variable. I only has a single member
function, so identifying uses of that member function is a good proxy.
Fixes#4704
When processing the dot intrinsic, there is an assert that ensure the
return type is the same as the componentent type of the operands. This
is not true when the types were originally half. At that point, the
operands will have been promoted to float, but the return type will be
promoted later.
Since the assert is not universally true, I will remove it.
Fixes#5048
* [lit] Move ls *.pdb to unique directory
Avoid check *.pdb by moving ls *.pdb to unique directory.
This will fix the random failure caused by entangled with pdb output of other tests.
Implement latest `SV_Barycentrics` semantics in DXC, according to DXC wiki spec.
For variant qualifier decorated baryCoord inputs, as KHR extension has no matched built-in, still mapped to Bary*AMD.
Add support for using input as first parameter of GetAttributeAtVertex. This would expand input's dimension to meet extension spec.
Merge some features from AMD_shader_explicit_parameter and current extension together for MSAA usage. Keep generated SPIR-V codes similar to GLSL as possible.
With concern to HLSL/DXIL part, keep most type modification/variable decoration change in SPIRV trans unit.
Remove AMD_shader_explicit_parameter related features.
Support struct member as parameter of GetAttributeAtVertex.
Support using Decorator for MSAA features.
* [SPIR-V] Add fspv-preserve-bindings option to preserve decoration bindings even when unused
* Set preserve bindings option in SpirvEmitter::spirvToolsLegalize() also
We effectively have reference parameter passing for intrinsics, but we
accomplish it by extremely careful interpretation of `out` and `inout`
in specific contexts.
This change separates the two in our intrinsic defintiions. Parameters
marked `ref` become lvalue reference types in the intrinsic function
declarations but do not get annotated with `AR_QUAL_OUT`. This allows
us to differentate them as true reference parameters.
For the atomic result intrinsics this allows us to clear up some hacks
because we needed them to not be `out` parameters but we needed them to
be passed by reference.
I've left a comment in SemaHLSL where we match arguement types about a
further cleanup we should do to correct reference binding errors, but
that is a larger task that we should do separately.
* [lit] Port Support %if ... %else syntax for RUN lines from upstream
Based on
1041a9642b
This syntax allows to modify RUN lines based on features
available. For example:
RUN: ... | FileCheck %s --check-prefix=%if windows %{CHECK-W%} %else %{CHECK-NON-W%}
CHECK-W: ...
CHECK-NON-W: ...
This is merged to allow dxilver check apply on each RUN line.
The args in the PDB and debug DXIL are based CodeGenOptions::HLSLArgs. This list was created by copying the raw unprocessed arg list and excluding any args equal to the input file name. When the entry point happens to be the same as the input filename, it would get excluded from this list and the PDB and debug module end up with corrupted arg list where -E has no value or wrong value.
Fixed by only excluding args that are InputClass.
* [dxa] Add option to dump reflection
New option -dumpreflection is added to dump reflection data.
This is to support %D3DReflect test in lit.
* Move Reflection dump to DxilContainer.
Default parameters for function templates is a C++11 feature. Since HLSL
is defined as C++03 using default parameters for function templates
produces a language extension warning. There is really no need for the
warning since the template syntax is disallowed in HLSL 2018 and earlier
and we effectively always support this syntax in 2021.
This change suppresses the warning by treating HLSL as C++11 when
diagnosing default template arguments. This changes the warning to a
C++98 compatability warning, which is only enabled if explicitly
requested.
In the future we should consider making future HLSL language versions
based on a more modern C++ to avoid issues like this.
Fixes#5221
* [lit] Use ls instead of file
Avoid use file -E for ls -l is more available on Windows.
* Use grep instead of not ls *.pdb.
Because on Windows, not ls *.pdb does not work.
* Use -1 for ls.
This change moves the `globallycoherent` mismatch diagnostics out of
code generation and into semantic analysis. Additionally the diagnostic
is enhanced to provide more information in the text about the mismatch,
and to fire in source locations more directly attributable to the
location of the mismatch.
This change also allows the `globallycoherent` annotation to apply to
functions, where it applies to the return type of the function, and
mismatches can be diagnosed on assignment of the return value and on
the return statements.
Fixes#4537.
* Correct the validation of vk::image_format. Fixes#5189
* - Fix a bug where the image format doesn't propagate from OpTypeArray to OpTypeImage
- Add a unit test that tests the vk::image_format on arrays
* Support case when memcpy src/dst are only use/def of the src/dst.
When src of memcpy is the only read from src and dst of memcpy is the only write to dst, as long all writes to src dominate the memcpy, it is safe to replace dst with src.