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

3897 Коммитов

Автор SHA1 Сообщение Дата
Nathan Gauër 90225f0fea
bitfields: refactorize struct offset computation (#4781)
This is some preliminary work to bitfield addition into the SPIR-V
backend. This commit should not change the behavior of our backend.

Signed-off-by: Nathan Gauër <brioche@google.com>

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-11-10 12:27:05 -08:00
Nathan Gauër 7b5200b9fa
maintenance: update submodules (#4782)
Signed-off-by: Nathan Gauër <brioche@google.com>

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-11-10 11:07:39 -08:00
Nathan Gauër 0ff2aa5fd7
doc: fix code display on Github (#4775) 2022-11-08 16:04:11 +01:00
Xiang Li 7cf0019578
Add check-prefixes support for FileCheck. (#4769)
Merge from fd557cb01f (diff-216ac5edd1cbc96da1241dc98b8d114529a874800aac4622871dbc99d16892d7)
2022-11-07 15:58:21 -08:00
Cassandra Beckley 161ddc2b7c
Update submodules (#4770) 2022-11-07 13:46:49 +01:00
Xiang Li 72585c0188
Avoid > in FileCheck run line. (#4768)
Things like -DResType=RasterizerOrderedStructuredBuffer<uint> could be workaround with
-DResType="RasterizerOrderedStructuredBuffer<uint>" for lit.
But clang-hlsl-tests will not work.
So put the template inside the test.
2022-11-04 17:57:31 -07:00
Jeff Noyle 5bb5559a9f
PIX: Switch back to non-raw buffer stores (#4764)
* PIX: No raw access for PIX UAVs (upsets some drivers)

* Fix tests
2022-11-04 12:29:01 -07:00
Xiang Li 4e3a243af5
Remove > %s in FileCheck tests (#4765)
Things like RUN: %dxc /Tps_6_0 /Eps_main > %s will overwrite the test when running with lit.
2022-11-03 20:06:48 -07:00
Cassandra Beckley aabcd6e10e
[SPIR-V] Run clang-format (#4756) 2022-11-01 16:32:22 -04:00
Helena Kotas 6fdabdb1f0
IsNormalTest - correct Disassemble arguments (#4754) 2022-10-31 20:10:55 -07:00
Cassandra Beckley 036b2e3f6d
Update Windows build link (#4753) 2022-10-31 15:53:42 -04:00
Jeff Noyle 8492f4a165
PIX: Fix shader-access-tracking pass' reportage of dynamic indexing (#4748) 2022-10-28 13:13:00 -07:00
Adam Yang 80fb4622a4
Made shader reflection return thread group size for AS and MS (#4745)
Fixed DxilShaderReflection::GetThreadGroupSize returning only thread group size only for CS but not MS and AS.
2022-10-27 16:23:58 -07:00
Helena Kotas 61725a51d6
Reduce IsNormalTest dependencies and revert Hlsl/DxcTestUtils refactoring (#4744) 2022-10-27 13:22:45 -07:00
Jeff Noyle 7712232baa
PIX: Access tracking for libs, switch to raw IO (#4734)
Mostly about handling CreateHandleForLib and GEP as an operand instead of a value.
2022-10-26 15:22:43 -07:00
Paul Dodzweit 6dd7014f24
Allow host to be passed to CMake for cross compile (#3914)
Co-authored-by: Dodzweit, Paul <Paul.Dodzweit@amd.com>
2022-10-25 17:36:30 -07:00
Diego Novillo 8d144f450e
Update submodule hashes for SPIRV-Tools, SPIRV-Headers and re2. (#4743)
This makes DXC use the latest SDK release for SPIRV-Tools and
SPIRV-Headers.
2022-10-25 17:26:26 +00:00
Helena Kotas 924f650af9
Fix build warning (#4739) 2022-10-24 17:51:48 -07:00
Helena Kotas 977bed27b9
IsNormalTest: Use IDxcContainerReflection interface instead of helper functions from DxilContainer.cpp (#4730) 2022-10-18 14:39:20 -07:00
Helena Kotas 60b1f859ae
Update build to Visual Studio 2022 (new default); remove VS 2017 support (#4726) 2022-10-17 18:49:35 -07:00
Marijn Suijten 47f31378a9
[Linux] WinAdapter: Remove virtual dtors from IUnknown to fix vtable ABI (#3793)
* WinAdapter: Remove virtual dtors from IUnknown to fix vtable ABI

The vtable for `IUnknown` and its subclasses contain two deletion
pointers when compiled on non-Windows systems with `IUnknown` from
`WinAdapter.h`:

    vtable for 'DxcLibrary' @ 0x7ffff7cbc5f8 (subobject @ 0x5555556bb9e0):
    [0]: 0x7ffff6a56d40 <DxcLibrary::QueryInterface(_GUID const&, void**)>
    [1]: 0x7ffff6a56d20 <DxcLibrary::AddRef()>
    [2]: 0x7ffff6a56d30 <DxcLibrary::Release()>
    [3]: 0x7ffff6b36bc0 <IUnknown::~IUnknown()> // Complete object destructor
    [4]: 0x7ffff6a57130 <DxcLibrary::~DxcLibrary()> // Deleting destructor
    [5]: 0x7ffff6a56d50 <DxcLibrary::SetMalloc(IMalloc*)>
    [6]: 0x7ffff6a56d60 <DxcLibrary::CreateBlobFromBlob(IDxcBlob*, unsigned int, unsigned int, IDxcBlob**)>
    ... More DxcLibrary virtual functions

This shifts the the pointers for functions for all subclasses, and is
[annoying] to deal with in otherwise cross-platform applications using
DirectXShaderCompiler as library.  `dxcompiler.dll` compiled on/for
Windows without `WinAdapter.h` does not suffer this problem, and only
has three function pointers for `IUnknown`.

Fortunately, it is easily solved by removing the virtual destructor from
`IUnknown`.  LLVM enables `-Wnon-virtual-dtor` that warns against
classes with virtual methods but no virtual destructor, though this
warning is best not enabled akin to Windows builds where `IUnknown` from
`windows.h` (`unknwn.h`) results in the same warning on MSVC ([1]/[2]).

[annoying]: 1e624792fc/src/unknown.rs
[1]: https://github.com/microsoft/DirectXShaderCompiler/issues/3783#issuecomment-844189358
[2]: https://godbolt.org/z/hKPT6ThEf

* WinAdapter: Make `IUnknown` and `IMalloc` pure-virtual classes

`IUnknown` in Windows' `unknwn.h` and `IMalloc` in `ObjIdl.h` are marked
as pure virtual, and are best marked as such in `WinAdapter` for
non-Windows platforms too [1].  Only the shim for `IMalloc` was relying
on the default refcounting implementation, all other subclasses either
contain pure-virtual methods themselves or provide an implementation for
`AddRef`/`Release` as required.  Likewise the default implementation for
`IMalloc` was only instantiated once by `CoGetMalloc`, and has been
moved into a local class implementing the `IMalloc` interface instead.

[1]: https://github.com/microsoft/DirectXShaderCompiler/pull/3793#issuecomment-846459741

* WinAdapter: Add three missing virtual functions to `IMalloc` interface

To prevent unexpected vtable breakage, add the missing functions from
the [documentation].  Note that they are listed in the wrong order, the
right order is retrieved from the `ObjIdl.h` header and implementations
for `IMalloc` in DirectXShaderCompiler.  All implementations are now
properly using the `override` keyword too, to enforce virtual method
existence in the base class.

[documentation]: https://docs.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-imalloc

* Make all WinAdapter destructions explicit

This prevents warnings about non-virtual destructor usage that trip up
the Linux build. It represents status quo on Windows.

Co-authored-by: Greg Roth <grroth@microsoft.com>
2022-10-13 10:19:39 -07:00
Chris B 9975a80c87
Enable template dependent globallycoherent types (#4718)
This change alters how globallycoherent attributes are validated. We
will need similar changes for other HLSL type attributes as well.

Without this change, globallycoherent attributes are only allowed to
apply to declarations of builtin objects during parsing. Additionally
if applied to a non-UAV we catch that late (during code generation) and
report a different error there.

This patch reworks all of that. Instead, during parsing we allow verify
the attribute is applying to a UAV builtin type and issue a diagnostic
if applied to a non-UAV type. We also allow the attribute to be applied
to any dependent type.

If the attribute is applied to a dependent type, we verify that the
dependent type is resolved to a valid UAV type during instantation.

This change also reworks the existing test case for globallycoherent
diagnostics and deletes duplicated tests that were not adding meanigful
value.

Fixes 4583.
2022-10-13 09:27:20 -05:00
Chris B 1e98bf3b7a
[HLSL2021] Disallow bitfields and annotations (#4711)
This change makes mixing bitfields and HLSL annotations an error. Since
the syntax for HLSL annotations and bitfields are ambiguous, this change
works around some issues with the ambiguity by disallowing mixing the
two on the same declaration.

Fixes #4686
2022-10-12 16:29:48 -05:00
Helena Kotas 4792ae561b
DXC Release build pipeline - add Linux config, improve display strings (#4719) 2022-10-12 09:33:32 -07:00
Tex Riddell bf1c9e4c89
Change some getAsStructureType() uses to getAs<RecordType>() (#4707)
In some cases, code using getAsStructureType() seemed to expect any user-
defined type to result in RecordType here, but only 'struct' types would,
leaving 'class' types to fail certain code paths.  Some code paths had an
additional getAs<RecordType>() if the getAsStructureType() returned nullptr,
but at that point, why bother with getAsStructureType() in the first place?

This updates cases in CGHLSLMS.cpp that looked to be misusing getAsStructureType
to simply use getAs<RecordType>() instead.  One case is with constructing
type annotations, where two branches are used and code is almost identical,
except skipping size return when a member is a resource was only in the struct
path.  I think removing this separate path and checking for resource on any
RecordType makes sense here.
2022-10-10 15:16:36 -07:00
Chris B d5aa3ff387
[NFC] Fix asan error in test case (#4668)
This test relies on a stack allocation remaining live after the scope
of an if block that it is allocated in... Clearly no good.
2022-10-10 15:12:48 -05:00
Chris B 81ef064a47
Fix broken ternary on matrix return type (#4434) (#4460)
HLSL ternary operators that result in vector or matrix types need
special handling even if the condition is not a vector. This change
allows vector and matrix result types for ternary operators even if
matrix and vector conditions are not allowed.

The change works by generating an alloca before ternary blocks, and
terminating ternary blocks by writing the resulting matrices to the
alloca. The result of the ternary is then a load of the alloca'd matrix.

Fixes #4434
2022-10-04 13:06:09 -05:00
Joshua Batista f0b5fd2416
User/jbatista/remove isnormal dependencies02 (#4692)
There are some other functions that are found in the IsNormal HLK test that are defined and declared in the DxcTestUtils files. This is bad because DxcTestUtils takes a dependency on LLVM. This PR gets rid of the rest of the functions that don't need to depend on an llvm include, but are necessary to allow IsNormal to function, and moves the functions to HLSLTestUtils.h. Hopefully after this PR, IsNormal will be able to run when copied to other repos.
These functions and all their dependent functions were moved to HLSLTestUtils.h:
-VerifyCompileOK
-DisassembleProgram
-AssembleToContainer
2022-09-29 17:52:58 -07:00
Tex Riddell c31ea7998b
Fix failing test and DxilMutateResourceToHandle case hit by updated test (#4694)
DxilMutateResourceToHandle would skip GEP if result type does not need to be mutated.
But then the GEP would not have setSourceElementType called with the new source type leaving invalid IR.

The fix makes sure the GEP is added to MutateValSet when skipping recursion.
2022-09-29 00:51:39 +00:00
Tex Riddell 25307b4c22
Remove unused type annotations (#4689)
Types no longer in use, potentially due to type translation, are still kept
around just because they are referenced in the type annotation metadata.

This change adds a method DxilModule::RemoveUnusedTypeAnnotations() that
removes any type annotations not used by resources or function arguments
or return types.  Types outside this set should no longer need any type
annotations.  This will get rid of extra unused types often left over in
final dxil before.
2022-09-28 13:46:02 -07:00
Tex Riddell 87c30cf38f
Remove ResourceAttribute metadata node from DxilFieldAnnotation (#4671)
Currently, ResourceAttribute is only used to capture resource type information during CodeGen for the annotate handle generated during AddOpcodeParamForIntrinsic.

Going through a metadata node is totally unnecessary, just adding code and complexity.

This change just stores the DxilResourceProperties instead, renaming `*ResourceAttribute` methods to `*ResourceProperties`.
This change also emits the resource properties to new field annotaion metadata in validator version 1.8+ to preserve through serialization.
2022-09-28 13:43:49 -07:00
gmitrano-unity aaa30e2c9c
[SPIRV] Support 16-bit Type Cast Intrinsics (#4679)
* [SPIRV] Support 16-bit Type Cast Intrinsics

This change adds support for 16-bit type cast intrinsics by routing
them into the same logic used by the 32-bit type casts. With this
change in place, asfloat16, asint16, and asuint16 are now translated
into OpBitcast in SPIR-V.

This change also includes new partial disassembly tests for each
function similar to the ones used for 32-bit casts.

* Update Comments in processIntrinsicsAsType

This commit updates the comments at the top of processIntrinsicsAsType
in order to indicate that this function also supports the 16-bit
variants of the type casting intrinsics.
2022-09-27 14:58:29 -04:00
Joshua Batista dc5949e167
Pull ReplaceDisassemblyText out of DXCTestUtils.cpp (#4687)
ReplaceDisassemblyText dependency on llvm removed in the case that a regex is unnecessary to replace text in the disassembly.
2022-09-27 11:44:29 -07:00
Adam Yang 1eea5457de
Fixed a crash with cbuffer lowering with new poison value mechanism (#4684)
There was a crash when CBuffer vector subscript uses a non-literal index but is replaced with Constant in the optimizer before CBuffer load is lowerd. The CBuffer lowering code expects the constant to be within bounds, since it's translating the GEP to extractvalue. The out of bounds subscript is not correct and should cause an error, but ONLY if it actually exists in the final DXIL.

This change adds a way to emit error that only get emitted if the associated code is not removed by the end of compilation. Instead of emitting an error right away, emit a poison value with line number and error message instead and have it used by the problematic code. If the problematic code is not removed by the end of compilation, then this poison value would also be there, and it's safe to emit a real error based on it.
2022-09-27 11:39:36 -07:00
Tex Riddell 69e6a84ed1
Remove arbitrary run line length limit (#4685)
A very strange sequence of copying the run line to a stack char array of
size 300, where it would not even null-terminate the line if it hit the
limit, seems totally unnecessary, since it's dealing with std::strings
in the first place.
This would truncate and pick up garbage from the stack in the stored run
line when length >= 300 characters - causing the test to fail, of course.
Perhaps some of this is an artifact of some older version of the code.

In any case, this change removes the extra copying step and simply uses
the entire std::string result from std::getline() instead.
2022-09-27 11:07:14 -07:00
Tex Riddell ecf4e0a5c4
RDAT: Revert default to MaxRecordSize for tables (#4682)
On second thought, it's safer to default to the initial version, letting
code that writes to RDAT set strides for newer record versions it actually
uses, rather than breaking RDAT writing code at runtime when versioned
updates are added to the structures.
2022-09-22 16:51:29 -07:00
Tex Riddell 4672db64b3
Insert cast when types are identical to HLSL but not to clang (#4631)
It's possible to get a value of a type `unsigned long` in HLSL, such as
the result of sizeof(), while the uint type is `unsigned int` instead.
This leads to the situation where no cast is inserted because the types
look identical when translated down to ArBasicKind, which can lead to an
assert during codegen, such as when passing sizeof() result to a function
call parameter.

This change preserves the original canonical type ptr from clang and
sets the conversion type when these differ, even when ArBasicKind is
identical.
2022-09-22 12:36:50 -07:00
Helena Kotas dfceabdb17
dxexp - report advanced texture ops capability (#4677)
- add D3D12_FEATURE_DATA_D3D12_OPTIONS14 definition if not supported by current WinSDK
- move all D3D_SHADER_MODEL defines into one spot
2022-09-22 10:54:56 -07:00
Tex Riddell 6c7ad3ed90
Add RDAT::RecordTraits::MaxRecordSize to default to newest version (#4680)
Added MaxRecordSize calling DerivedRecordSize that gets specialized for each base in RDAT_STRUCT_TABLE_DERIVED macro to call the derived MaxRecordStride. The most-derived version of DerivedRecordSize will use the default implementation, which is the size of that type.
2022-09-22 07:51:06 +00:00
Cassandra Beckley 009e7f1070
[SPIR-V] Add support for logical operator intrinsics (#4674)
* [SPIR-V] Add support for logical operator intrinsics

Implemented `and`, `or`, and `select`. I used the existing tests for the
old behavior of `&&`, `||`, and `?:` in order to verify that they behave
as expected (with the caveat of #4673, but that has the same behavior
for DXIL as for SPIR-V).

Fixes #4148

* Clean up

* Remove unused variable
2022-09-21 19:11:40 +02:00
Yuriy O'Donnell 581cc5aee6
Fix ShaderModel::Get() when entry does not exist in hashToIdxMap (#4678) 2022-09-21 09:52:57 -07:00
Yuriy O'Donnell 8b8956f82b
Fix error on shutdown when using custom memory allocator (#4656)
ShaderModel::Get() used a static std::unordered_map which is torn down when custom allocator may no longer be active.
2022-09-20 15:03:38 -07:00
Adam Yang c033915723
Deleted the old miniz library (#4675) 2022-09-20 15:22:05 +02:00
Xiang Li 43a38d473c
Fix issue in HelperLaneTestWave ExecutionTest caused by assume last lane has VertexID 2. (#4670)
Use the last lane in the wave with VertexID 2 instead of the lane with VertexID 2 when writes results.
2022-09-19 10:23:26 -07:00
Daniele Vettorel 16ad9c07db
[SPIR-V] Add short-circuiting ternary operator for HLSL 2021 (#4672) 2022-09-19 17:21:37 +00:00
Chris B eb4d0ec385
Add `LLVM_OPTIMZIE_SANITIZED_BUIDS` option (#4667)
I added this upstream a few years ago so that you can control passing
`-O1` to the compiler when building debug sanitized builds. Without
being able to disable optimizing sanitizer builds it is really tricky to
debug sanitizer failures, but without optimizing the build ASan builds
take _forever_ to run tests which makes them difficult to use.
2022-09-19 10:13:24 -05:00
Cassandra Beckley eec7261fa5
[SPIR-V] Fix default arguments for function templates (#4665)
Fixes #4169
2022-09-19 12:30:53 +02:00
Adam Yang 826ff8ea4f
Added new DxilPDBInfo definition (#4669)
- Added new PDBI part for PDBs to eventually replace SRCI
- Added new IDxcPdbUtils2 that can read PDBI
- Removed all functionalities to do with GetFullPDB (and its tests)
2022-09-19 02:38:31 -07:00
Greg Fischer a0b1b84747
[SPIR-V] Handle debugInfo for composite types across source files (#4654)
This fixes a crash when generating source debugInfo for composite types
across multiple source files.
2022-09-18 19:36:26 -07:00
Adam Yang 8d6100fc60
Separated RDAT creation code into its own library (#4662)
- Pulled out RDAT writing from DxilContainerAssembly into its own helper DxilRDATBuilder
- Changed the way RawBytesPart deduplicates inputs. Instead of using the pointer address, use the data's content as keys in a hash table, then writing it to the final buffer in the order they were inserted.
2022-09-16 15:49:38 -07:00