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

75 Коммитов

Автор SHA1 Сообщение Дата
Chris B 37ed613864
[NFC] Clang-format DXC sources (#5602)
This change applies clang-format to all of the sources added in DXC that
were not part of the original LLVM/Clang 3.7 release when DXC forked.
This provides consistent code formatting across the codebase.

Fixes #5591.
2023-09-19 07:49:22 -05:00
Chris B 3266a87f9a
[NFC] Remove SAL annotations from internal APIs (#5639)
We don't keep these annotations up to date or rely on them, so to
simplify our platform layering and ease code formatting this change
removes all the SAL annotations from internal APIs. This change also
replaces most `_Analysis_Assme_(...)` annotations with `assert(...)`.

One `_Analysis_Assume_` in ParseDecl.cpp needed to be updated because it
was incorrect. The code was `_Analysis_Assume_(assert(name.size() >
sizeof("space"));`. When converted to an `assert` it fired in our test
suite because the sizeof a string literal includes the null terminator,
but the size of a StringRef does not.

A few of the `_Analysis_Assume_` annotations were removed because they
didn't make sense (like the ones inside the `DXASSERT` implementation,
and a few others were removed to avoid introducing additional header or
linkage dependencies.

This change does not introduce any functional or behavioral changes.
2023-09-14 08:59:49 -05:00
Helena Kotas 93555aa911
Add TransformUtils dependency to DxilContainer for Linux builds (#5468)
The dependency is necessary because DxilContainerAssembler.cpp uses
llvm::CloneModule.
2023-07-27 21:17:50 +00: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
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
Sebastian Neubauer d529af3e2b
Replace deprecated std::iterator inheritance (#5111)
std::iterator is deprecated since C++17. E.g. when using the standard
library of gcc 12, deprecation warnings are shown.

There is some background info here:
https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
2023-04-03 19:25:04 -05:00
Greg Roth 5eb7c77d7c
Move WinAdapter into interface directory (#5066)
Since it is shipped and relied upon, the WinAdapter header belongs in
the release directory. This removes the need to include the Support
directory for building purposes

revises fix to #4918
2023-02-28 10:41:50 -08:00
Chris B 2168dcb4fb
Clean up and rework DXIL library depencencies (#4877)
* Clean up and rework DXIL library depencencies

This change reworks the dependency specifications for the DXIL*
libraries. Many of these libraries had over and under specified
dependencies.

This also collapses the DxilRDATBuidlder into the DxilContainer library
to remove the cyclic dependency between the two libraries.

* Break assert dependency between DXIL and Analysis

In assert builds the DXILModule constructor was creating forced bindings
to debugging methods that are often used from the debugger. This forced
binding is useful, but doesn't need to live in the DXIL library.

To break the dependency I've moved the code into Analysis. I've also
made that code only included when building with MSVC. When using other
compilers `__attribute__((used))` can be applied to the function via the
`LLVM_DUMP_METHOD` annotation to have the same effect.
2023-01-03 10:04:22 -06:00
Tex Riddell 2c3d965b2f
dxcopt: Support full container and restore extra data to module (#4845)
This modifies IDxcOptimizer::RunOptimizier to accept full DxilContainer input. When full container input is used, this restores some data that is stripped from the module and placed in various other container parts.

Data restored:
  - Subobjects from RDAT
  - RootSignature from RTS0
  - ViewID and I/O dependency data from PSV0
  - Resource names and types/annotations from STAT

Serialization of these to metadata in module bitcode output still requires hlsl-dxilemit step.
2022-12-13 02:54:10 +00:00
Greg Roth 7ad9c9c032
Fallthrough (#4843)
A common source of bugs. Although many of these were harmless, some were
not. By eliminating them and enabling this warning as an error, we won't
add more in the future.


Fixed a real SPIRV bug that required a test update to expect the correct behavior.
SPIRV testing was expecting incorrect results that came from a fallthrough error
2022-12-09 10:13:56 -08: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
Tex Riddell e138888302
Dedup semantic names in IO signature parts for valver 1.7 (#4406)
Create new NameOffsetMap that uses StringRef to prevent identical strings from being duplicated. Old behavior is maintained when earlier validator version set by using a *_nodedup map that continues to use a pointer to allow duplicates as previous validators did.
2022-04-21 15:02:36 -07:00
Tex Riddell b338314f6e
Implement Shader Model 6.7 (#4260)
Shader Model 6.7 is still a work in progress.
Thanks to multiple contributors at Microsoft for this work.

Added support for additional advanced texture operations, including:
Raw Gather, Programmable Offsets, SampleCmpLevel, and RWTexture2DMSAA.

Added new QuadAny/QuadAll intrinsics to help with writing quad-uniform control flow.

Added [WaveOpsIncludeHelperLanes] pixel shader entry attribute, changing the
behavior of wave ops to treat helper lanes as active lanes.
2022-02-15 11:38:42 -08:00
Grace Jennings 979cc4a276
Support -setprivate, -setrootsignature, and -Qstrip_priv to compile API (#4230)
* Adding /setprivate, /setrootsignature, and /Qstrip_priv to compile API calls

* Adding setprivate to initial container serialization, change warning to error

* Removed unused variable

* Adding private data blob last, because no gaurantee of aligned size

* Add error messages for conflicting private options
2022-02-08 13:36:55 -08:00
Tex Riddell 0c49f28ebd
Allow unaligned private data size, by keeping it at end of container. (#4239)
Since all other blob parts are expected to be aligned, make sure we always add private data at the end of the container.
Update DxcContainerBuilder to keep private data at the end as well.
2022-02-08 12:14:41 -08:00
Tex Riddell 9d03a00fd7
Fix DxilProgramSignature size alignment. (#4237)
- Maintain compatibility for validator version < 1.7.
- DxilContainerWriter_impl verifies size alignment for all parts, unless created with bUnaligned=true, used for backward compatibility.
- DxilValidation uses NewProgramSignatureWriter(), so bUnaligned is based on validator version in module.
2022-02-07 15:41:54 -08:00
Tex Riddell 6fdea4bdf8
Renormalize line endings to lf in index. (#4223)
Various files were committed with mixed line endings.  This change renormalizes them to our settings.
2022-02-01 13:55:43 -08:00
Minmin Gong 2bd9843e95
Fix frequent warnings on gcc and clang (#4175) 2022-01-20 13:43:05 -08:00
Tex Riddell 6683f4d9f9
Fix missing RDAT function resource usage by recursing constant users (#3983)
Before module serialization, constant users of resource globals could themselves have multiple constant users. These could be consolidated through module serialization/deserialization, leading to a difference when only the first constant user was followed. The difference could lead to a validation failure only with external validator (DXIL.dll) since reconstructed RDAT would not match the original RDAT with the missing use. This would happen in cases such as identical constant indexing of resource arrays from multiple entries.

Also, fix groupshared usage detection when setting function compat flags for RDAT.
2021-10-01 12:14:36 -07:00
Tex Riddell 58f0ee2637
Strip Byte Order Markers (BOMs) and fix some related issues (#3880)
* Stop creating binary blobs with UTF-8 encoding

* Strip BOM and fix some related issues

- detect and strip BOM only when interpreting as text:
  - DxcCreateBlob: only when encoding is known and not CP_ACP
  - DxcGetBlobAsUtf[8|16]: when encoding not known or CP_ACP
- strncmp in BOM detection would misfire (should have been memcmp)
- ambiguous BOM case not handled/noted
- empty blob case fixes (handle null-term empty, don't leak)

Note, there are still problems in the unicode handling:
- No actual support for UTF-32 or big endian input encodings.
- For Linux: "UTF-16" isn't, and bad assumptions around "wide" strings.

* Add defines for CP_UTF*; improve error for unsupported utf conversions
2021-07-15 16:41:30 -07:00
Adam Yang 86104f415f
Internal validator error messages don't need /Zi anymore. (#3606) 2021-03-20 19:21:26 -07:00
Greg Roth 1ca779732f
Correct atomics on heap usage for libs (#3525)
The previous shader flag code failed to account for the library-specific
handle creation function
2021-02-28 16:02:44 -08:00
Greg Roth deacf03358
Add used by atomics resource flag (#3513)
To identify resources that are used in 64-bit atomics operations in order to catch invalid use of heap resources
2021-02-26 11:25:28 -08:00
Greg Roth 5fbaf73466
Error for groupshared outside of compute (#3472)
groupshared variables shouldn't be allowed outside of compute and
compute-like shaders. This adds a validation error when such
variables are used.

Add shader mask where groupshared are used

Correct several tests that used groupshared incorrectly

Incidental fix to atomics tests where the special case initializations
might have allowed the threads that failed to write to proceed
before the write took place and read the improperly initialized values

Changed up the assignments to avoid write collisions and be more
readable

Fixes #2603, #2677
2021-02-24 15:22:29 -08:00
Adam Yang 98ddd699de
Added shader reflection part to source-only PDB. (#3467) 2021-02-18 13:32:13 -08:00
Tex Riddell b0f129cd09
Add ResourceKind/NumThreads to PSV0 (DxilPipelineStateValidation) (#3233)
- Increment MAX_PSV_VERSION to 2
- Clean up versioning logic
- Add NumThreads to PSV0 v2
2021-01-22 16:41:40 -08:00
Greg Roth 708935e996
Add missing LLVM library interdependencies (#3301) 2020-12-04 13:36:19 -08:00
Greg Roth d574d27c1f
Implement Shader Model 6.6 (#3293)
This is the work of many contributors from Microsoft and our partners.
Thank you all!

Add support for 64-bit atomics, compute shader derivatives, dynamic
resources (from heap), 8-bit Packed Operations, and Wave Size.
All of these require compiling with 6_6 targets with just a few
exceptions. Each of these features include unittests and Execution
tests.

64-bit atomics add 64-bit variants of all Interlocked* intrinsic
operations. This involves changing some of the code that matches
intrinsic overloads to call instructions. Also adds a few float
intrinsics for compare and exchange interlocked ops which are available
for all shader models 6.0 and up.

Compute shader derivatives adds dd[x|y], CalculateLevelOfDetail, and
Sample operations that require derivatives to compute. QuadRead
operations have been allowed in compute from 6.0+ and tests are added
for them here.

Dynamic resources introduce global arrays that represent the resource
and sampler heaps that can be indexed without requiring root signature
representations. This involves a new way of creating and annotating
resource handles.

8-bit Packed operations introduces a set of intrinsics to pack and
unpack 8-bit values into and out of new 32-bit unsigned types that can
be trivially converted to and from uints.

WaveSize introduces a shader attribute that indicates what size the
shader depends on the wave being. If the runtime has a different wave
size, trying to create a pipeline with this size will fail.
2020-12-02 21:10:44 -08:00
Tex Riddell c3fa785435
Remove assert.h include from DxilPipelineStateValidation.h (#3129)
Also:
- fixed size_t to uint32_t error when building with other tools.
- removed DxilPipelineStateValidation.h where unused.
2020-09-16 23:15:08 -07:00
Minmin Gong 7e0f44fa6f
Cleanup part of compiling warnings (#2903)
Try to fix some compiler warnings produced by clang when building the dxc compiler
2020-06-25 02:57:41 -06:00
Helena Kotas 4aa4840103
Dxil container builder refactor + bug fix (#2947)
* Dxil container builder refactor + bug fix

- move from dxcompiler to DxilContainer.lib
- rename source file, move class definition to header file
- enable inheritance by changing microcom fields to protected
- enable AddPart for shader debug info
- move CreateDxcContainerBuilder to dxcapi.h to remove dependency
  on DxilLibCreateInstance from DxcContainerBuilder.cpp

* Remove unused include
2020-06-05 20:35:10 -07:00
Tex Riddell ee442e01bc
Support instruction counts in reflection (#2930) 2020-05-29 20:09:29 -07:00
Tex Riddell 713c80ce4e
Rename 'module' to 'hModule' for C++20 compat (#2667)
* Rename 'module' to 'hModule' for C++20 compat
* Replace a bunch of unintended uses of new keyword 'module' with 'mod'
2020-03-01 18:12:31 -08:00
Helena Kotas 5d741a0279
HLSL test infrastucture and other refactoring and helper classes (#2682)
* HLSL test infrastucture and other refactoring

Refactor common test infrastructure code into HLSLTestLib
Enable invocation of fxc and other executables via // RUN: commands in test files
Add latest d3dx12.h to include/dxc/Support and remove two other outdated copies
Improve DXIL container header validation on load
New helper classes DxilContainerReader and FixedSizeMemoryStream
Move LoadSubobjectsFromRDAT to DxilSubobjects.cpp

Co-authored-by: Greg Roth <grroth@microsoft.com>
2020-02-06 21:49:21 -08:00
Tex Riddell 00c6d87f68 Switch metadata generation on shader model instead of validator version.
- MinVal[Major|Minor] tracks shader model.
- Account for reflection by special casing for version 0.0 (no validation)
- Tolerate additions to non-critical metadata for future version
- Keep track of unrecognized non-critical metadata for validation
- Update validator to detect this case.
2019-11-20 17:12:42 -08:00
Tex Riddell f4965b71dd Integrate dxcapi v2 and other changes from internal (#2575)
* Integrate changes from internal.

- dxcapi v2
- new dxc options
- DxilValueCache
- PDB and NoOpt improvements
- noop / llvm::donothing() support

* Update dxrfallbacklayer for dxcapi internal changes

* Reorder diag block based on whether pDiag is set first.

* llvm::donothing() requires dxil 1.6 / SM 6.6 for now, lib as well.

* Fixes for spir-v, non-VC compiler and non-Windows builds

- DEFINE_CROSS_PLATFORM_UUIDOF for new interfaces
- add SAL annotations
- turn output argument validation for -P into warning
- handle warnings without concatenating them to main output
- update spirv preprocessing and compilation paths
- return E_NOTIMPL from IDxcUtils::CreateReflection
- cleanup: DxcContainerBuilder back to uft8, DxcTestUtils: remove comment

* Fix some warnings from clang/gcc.

* Fix unicode conversion problems on linux, where sizeof(wchar_t) == 4

Note this is an intermediate fix.
On linux, what we are calling utf16 is actually a wide string
that's probably utf32.  This change fixes issues introduced by
the new interface changes so things are consistent and pass tests.

A future fix should correct the encodings so they are correctly labeled
on platforms where wchar_t doesn't mean UTF16.

* Return false for IsBufferNullTerminated when CP_ACP.

One test for Disassembler was crashing because it created a pinned blob
with a size of 1 << 31 + 1 without actual memory backing this.  The
IsBufferNullTerminated would attempt to see if this was null terminated,
causing AV.

This change also removes CP_UTF8 from this test when it was creating
binary blobs, not UTF8 text blobs.
2019-11-13 16:16:45 -08:00
Tex Riddell f5a75b4e4c
Update PSVSemanticKind for SV_ShadingRate and SV_CullPrimitive. (#2532) 2019-10-17 15:38:56 -07:00
Tex Riddell 8fdb31fa36
Always write shader hash when supported, don't tie to debug name (#2468)
* Always write shader hash when supported, don't tie to debug name

* Stop trimming quotes from pdb name

This is the responsibility of cmd.exe, not the API.
The API user should not be adding extra quotes to the pdb name string
if they don't want them.
2019-09-19 17:36:18 -07:00
amarpMSFT 05d1ad532a
Acceleration structures should be classified as raw srv buffers, not typed srv buffers (#2425)
* acceleration structures should be classified as raw buffers
2019-08-22 16:35:47 -07:00
Tex Riddell 892765cc4b Default to stripping reflection from DXIL and fix a bunch of fallout.
Two test options, -Qstrip_reflect_from_dxil and -Qkeep_reflect_in_dxil
for making tests work with reflection removed, since many tests are relying
on main module disassembly-reassembly between test phases and reflection
metadata will no longer be present there.  The strip option is for the
few cases where tests don't want the reflection kept in DXIL by default.

Validator no longer requires function annotations for no reason.

Fix places where remove global hook was not being called when functions
were removed manually from the list.

StripReflection now deletes function annotations, unless targeting lib or
old validator that required them.  Preserve global constructor list and
add annotation for 1.4 validator.  The global hook fixes were required
here, otherwise annotations would refer to dead functions during linking.
Struct annotations may not be removed in library case when they still need
translation to legacy types.

Allow missing struct annotation when not necessary to upgrade the layout.

Preserve usage in reflection by upgrading the module, emitting metadata,
cloning for reflection, then restoring validator version and re-emit
metadata.

Fix size for 16-bit type for usage and reflected size.

Make various batch reflection tests require validator 1.5, since these
tests rely on module disassembly->assembly, which will not preserve extra
usage metadata for reflection in 1.4.

Include reflection part in IDxcAssembler, but don't strip from module,
since there are no options to prevent this from breaking a lot of tests.

Don't strip reflection from offline lib target.
2019-08-19 00:39:39 -07:00
Tex Riddell f48650865e Add part header and RDAT to separate reflection output 2019-08-14 20:06:09 -07:00
Tex Riddell 5aec592757 Add seperate reflection part (STAT), add -Qstrip_reflect_from_dxil
- Put separate reflection in STAT part for now.
- Separate reflection is the module with deleted function bodies.
- Use new -Qstrip_reflect_from_dxil to drive stipping of reflection
  metadata from DXIL part, since now -Qstrip_reflect means strip
  the STAT reflection part, or don't include it in the first place.
- Update disassembler to use STAT part if available for reflecting
  resource bindings, buffer descriptions, and ViewID state.
- Put some Qstrip_* flags under DriverOption as well as CoreOption.
2019-08-12 18:15:19 -07:00
Tex Riddell eea0c94c08 Add Sig element usage masks to metadata, compute in hlsl-dxilfinalize 2019-08-12 15:30:01 -07:00
Tex Riddell 153edf8f5e RDAT: Fix shader stage and feature masks for ValVer 1.4 compat 2019-08-12 15:22:59 -07:00
Tex Riddell d9f134530d Fix Validator 1.4 compat break for bool signature element. 2019-08-12 15:20:51 -07:00
amarpMSFT f9c973536e
flesh out SV_CullPrimitive support (#2373)
* flesh out SV_CullPrimitive support (and fill in some missing SV_ShadingRate entries)

* fix build breakl

* moved #defines and added comment

* removed depenency on adding new entries to OS header d3dcommon.h

* test fixes
2019-07-26 17:51:09 -07:00
Tex Riddell f6ff322db3
Add mesh shader support to RootSignature parsing/validation and fix PSV (#2363)
* Add mesh shader support to RootSignature parsing/validation
* Fix PSV so MS output topology doesn't overlap SigInputVectors
* fix PSV version code to use latest when validation disabled
2019-07-24 16:39:34 -07:00
Tex Riddell 2facceae0b
Store mesh payload in function props, fix Wave/Quad/Barrier validation (#2361)
- Compute mesh payload size before final object serialization
  - During CodeGen for MS based on payload parameter
  - During CollecShaderFlagsForModule for AS based on DispatchMesh call
- Store payload sizes in corresponding funtion properties, serializing
  these properly for HL and Dxil Modules
- Use payload sizes from function props for PSV0 data during serialization
- Validate measured and declared payload sizes, don't just fill in
  properties during validation
- Fix Wave/Quad allowed shader stages, enabling Quad* with CS-like models
- rename payloadByteSize members to payloadSizeInBytes
- Add GetMinShaderModelAndMask overload taking CallInst for additional
  detail required to produce correct SM mask for Barrier operations
2019-07-24 10:22:28 -07:00
amarpMSFT 37acf90723 add payload size to Amplification Shader metadata to mirror MS metadata (#2359) 2019-07-23 17:27:42 -07:00
amarpMSFT c41606c737 Add RaytracingPipelineConfig1 subobject to DXR (#2342) 2019-07-16 01:34:45 -07:00