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

3950 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li fed08e5c0d [lit] allow find git usr bin in path directly. (#5385)
This is for case where git usr bin is not in winreg.
2023-07-20 14:56:04 -04:00
Xiang Li 2f58557f49 [lit] Add git usr bin to path automatically. (#5355)
This will avoid test fail when forget to add git usr bin to PATH.

Port from
0f1f13fcb1
2023-07-20 14:55:53 -04:00
Jesse Natalie f09905d0ec
Fix include in DxilNodeProps.h (#5433)
Globals.h defines things like `IFC` macros that leak into callers. All
that was really needed here was a definition of `std::string`.
2023-07-18 07:29:29 -07:00
Joshua Batista 6b18a6ab84
[NFC] Add more information on testing MDVals insertion in EmitDxilFunctionProps (#5335)
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.
2023-07-01 00:42:29 +00:00
Greg Roth 60719ebc65
Disambiguate RecordDispatchGrid type name for GCC (#5314)
GCC failed when faced with a variable of both type and name
RecordDispatchGrid. Adding struct to the type to make it clear
eliminates the error
2023-06-22 23:55:44 +00:00
Tex Riddell 25156fbbff
Add missing dxilver 1.8 to test. (#5313)
Test relies on validator version 1.8, but doesn't specify this version
requirement. Added requirement.
2023-06-22 14:45:49 -07:00
Helena Kotas 3e105849cc Merged PR 5770: Remove extra space in sha value in latest-release.json
The versioning is broken if the extra space in there.
2023-06-21 19:43:57 +00:00
Tex Riddell 657d13ca74 Merged PR 5769: Replace incorrect sizeof() with strlen() in compiler version test
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.
2023-06-21 17:31:52 +00:00
Chris Bieneman 7f6d946c4b Merged PR 5704: Add SM 6.8 preview features to release-preview-1.8.2306
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.
2023-06-21 01:59:32 +00:00
Helena Kotas edf5b27bea Merged PR 5765: Update version to 1.8.2306 and fork commit sha to 6a3e2485 2023-06-20 21:50:34 +00: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
Antonio Maiorano 5e080a7729
Fix build when compiling against libc++ (#5284)
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.
2023-06-14 18:40:17 -07:00
Antonio Maiorano 66f8c6d1e6
Add missing headers for clang with libc++ builds (#5285)
Add these headers to successfully build DXC with clang and libc++.
2023-06-14 18:39:55 -07:00
Antonio Maiorano e41afcef07
Add missing CMake variable for configure_file (#5287)
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.
2023-06-14 18:39:04 -07:00
Antonio Maiorano eaa85e0cc8
Fix clang build depending on delayed template parsing (#5288)
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.
2023-06-14 18:38:47 -07:00
Marijn Suijten 22c761c582
Avoid concurrency hazard in signal handler registration (#5272)
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>
2023-06-14 16:05:23 -05:00
Xiang Li fb7043e34e
[Metadata] Limit bitfield annotation to validator version >= 1.7 (#5282)
* [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.
2023-06-14 13:27:18 -07:00
Diego Novillo c8c6347c05
Prevent update_spirv_deps.sh from updating re2 and effcee. (#5250)
* 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.
2023-06-14 11:25:36 -04:00
David Peixotto 815055bb01
[flag] Update the lifetime markers flag to correctly handle multiple instances (#5283)
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.
2023-06-13 11:00:50 -07:00
Chris B 7c774396ce
[NFC] Fix typos in code comments. (#5286)
This just fixes two small typos in code comments.

Nothing to see here...
2023-06-13 17:25:43 +00:00
Steven Perron 43482b7c64
Fix special case with vector swizzle (#5281)
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
2023-06-13 10:52:23 -04:00
Rajiv Gupta a742bb62b5
[Spirv] Fix for validation error VUID-StandaloneSpirv-Flat-04744 (#5276)
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
2023-06-09 18:18:37 +00:00
Panagiotis Christopoulos Charitos 2afa325d4c
[SPIR-V] Fix an issue where OpConstantComposite is being used with spec constants (#5263)
Fixes #4849
2023-06-09 16:25:57 +02:00
Helena Kotas 40e3d02e5c
Revert "[DxbcConverter] Fix corruption of ICB integer values (#4790)" (#5253) (#5279)
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)
2023-06-08 12:02:27 -07:00
Tex Riddell 8f3f77ed70
Fix variable definition checks in hcttest.cmd (#5277)
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.
2023-06-07 21:30:48 -07:00
Chris B 128b6fd16b
[NFC] Remove unstable opcodes from filecheck matches (#5274)
HLSL HL Opcodes are unstable so we shouldn't have them in the check
lines.
2023-06-07 00:08:13 +00:00
Adam Yang f645acbbd7
Added "partial-lifetime-markers" to only generate lifetime.start (#5267)
- 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.
2023-06-06 14:48:09 -07:00
Xiang Li e0a29650cd
[lit] Remove temp directory for strip_dbg test. (#5264)
* [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.
2023-06-05 11:27:06 -07:00
Xiang Li 06a7197e23
Enable lit by default. (#5133)
* 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.
2023-06-05 10:35:24 -07:00
Xiang Li 58d305353f
[dndxc] Add option when dump ast. (#5266)
* [dndxc] Add option when dump ast.

This will allow dump ast to add option like -HV 2021.
2023-06-02 22:55:40 +00:00
Xiang Li 451cd8be3c
[BitField] Fix crash on enum bit field. (#5260)
* [BitField] Fix crash on enum bit field.

Support bit field on enum type.
Fixes 5257 https://github.com/microsoft/DirectXShaderCompiler/issues/5257
2023-06-02 15:45:39 -07:00
Joshua Batista 071972d7df
Remove some warnings from GCC when building DXC (#5262)
* 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
2023-06-02 13:10:20 -07:00
Steven Perron adc0363539
Move the check for Subpass into to uses (#5252)
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
2023-06-02 11:40:29 -04:00
Steven Perron 03d3677ddd
Remove unneeded assert (#5256)
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
2023-06-02 11:28:28 -04:00
Xiang Li 19c32587be
[lit] Move ls *.pdb to unique directory. (#5254)
* [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.
2023-05-31 14:00:05 -07:00
Chow cd3b40bd2e
[SPIR-V] add support for extension KHR_fragment_shading_barycentric (SV_Barycentrics) (#4638)
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.
2023-05-31 09:48:52 -04:00
Rajiv Gupta e2c42174d1
[SPIR-V] Add fspv-preserve-bindings option to preserve decoration bin… (#5211)
* [SPIR-V] Add fspv-preserve-bindings option to preserve decoration bindings even when unused

* Set preserve bindings option in SpirvEmitter::spirvToolsLegalize() also
2023-05-31 09:23:07 -04:00
Chris B ea3623fdf7
Allow `ref` parameters for intrinsics (#5166)
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.
2023-05-30 11:46:33 -05:00
Brian Favela 2bd4ee7ca4
Remove unused and failing script (#5220)
* Remove unused and failing script

* Removing/changing other pointers to 'hctcheckin'
2023-05-30 16:43:11 +00:00
Diego Novillo c4f9df287b
Add new script to update external dependencies for the SPIRV backend. (#5246)
This simplifies the updating of the external dependencies for the SPIRV
backend.

Tested on Linux.
2023-05-30 11:16:24 -04:00
Diego Novillo a42e054983
Update SPIRV-Tools submodule. (#5245)
This also required a fix to the unrolling loop, as the SPIRV optimizer
has changed upstream.
2023-05-30 08:14:31 -07:00
Xiang Li 18c9e114f9
[lit] Port Support %if ... %else syntax for RUN lines from upstream (#5227)
* [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.
2023-05-26 14:10:34 -07:00
Jeff Noyle 4e0ef84941
PIX Shader debugger: Fixes for structs that contain resources or member functions (#5237)
-don't allow ancestor structs and member functions to contribute to member index, from the point of view of PIX
-account for resources-as-members
2023-05-26 10:27:47 -07:00
Adam Yang d5d478470d
Fixed entry point omitted from the PDB when it's the same as input filename (#5236)
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.
2023-05-24 12:34:48 -07:00
Xiang Li daf1386161
[dxa] Add option to dump reflection (#5232)
* [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.
2023-05-24 10:13:36 -07:00
Chris B ae3e317fff
Allow function template default parameters in HLSL (#5234)
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
2023-05-24 10:58:40 -05:00
Xiang Li b37eb57822
[lit] Use ls -l instead of file -E (#5235)
* [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.
2023-05-24 06:16:50 -07:00
Chris B e50393e499
Enhance `globallycoherent` mismatch diagnostics (#5121)
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.
2023-05-23 15:54:55 -05:00
Panagiotis Christopoulos Charitos 3cf68d5def
Correct the validation of vk::image_format. Fixes #5189 (#5190)
* 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
2023-05-23 11:22:37 -04:00
Xiang Li 1097696fc1
Support case when memcpy src/dst are only use/def of the src/dst. (#5200)
* 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.
2023-05-22 13:04:18 -07:00