Add FileCheck testing to dxil2spv, and a first static vertex shader test case to test #4426. Also includes documentation for how to add additional tests, and replaces the existing WholeFileTestFixture with regular FileCheck.
* enable optimization passes to throw hlsl exceptions to abort further compilation and capture relevant error data
* add HLSL change comments, and simplify Diagnostics data saving
* throw legalization exception, give more info when aborting
* change exception throw back to return, and remove error string
When we handle `Load/Store` method of ByteAddressBuffer, we first load
the ByteAddressBuffer object if it is a reference of an alias variable.
`this` object is a reference of an alias variable if a
ByteAddressBuffer is a member of the class. The existing code checks
members of the class to determine if it has ByteAddressBuffer or not,
but it does not check its parent. Since we add all members of a parent
to its child class, we have to check members of the parent as well.
This commit fixes the issue and now `loadIfAliasVarRef(..)` properly
loads the access chain to ByteAddressBuffer.
For example,
```
// HLSL:
struct Base {
ByteAddressBuffer buffer;
};
struct Child : Base {
float load(in uint offset) {
return asfloat(buffer.Load(offset));
}
};
// Before:
%param_this = OpFunctionParameter %_ptr_Function_Child
%base = OpAccessChain %_ptr_Function_Base %param_this %uint_0
%ptr = OpAccessChain %_ptr_Function__ptr_Uniform_type_ByteAddressBuffer %base %int_0
OpAccessChain %_ptr_Uniform_uint %ptr %uint_0 ; <-- Error!!
// After:
%param_this = OpFunctionParameter %_ptr_Function_Child
%base = OpAccessChain %_ptr_Function_Base %param_this %uint_0
%ptr = OpAccessChain %_ptr_Function__ptr_Uniform_type_ByteAddressBuffer %base %int_0
%buffer = OpLoad %_ptr_Uniform_type_ByteAddressBuffer %ptr
OpAccessChain %_ptr_Uniform_uint %buffer %uint_0
```
SV_Position elements in DXIL input signature should be treated as SPIR-V
BuiltIn variables with the Position type rather than regular stage IO
variables with a Location.
The already broad i64 atomics testing was missing most coverage for
texture (image) types. This adds to atomicop_i64, and the various
atomic*_i64_and_i32 tests to use int64 texture types and verify the
DXIL output
The following subtests have updated expected results to account for
helper lanes being a part of wave operations in SM 6.7:
- WavePrefixSum
- WaveMultiPrefixSum
- QuadReadAcross for lane 0
- WaveActiveBitXor
The WaveReadLaneFirst waterfall loop test has also been updated to use a
new loop structure for SM 6.7 as suggested by Tex.
GetBlobAsWide was added as a new method to the existing interfaces,
but the existing GetBlobAsUtf16 should have simply been renamed to
GetBlobAsWide instead, since that's what GetBlobAsUtf16 actually did.
Otherwise interface compatibility is broken between builds/releases.
If we want to add a GetBlobAsUtf16 which guarantees UTF16 across platforms,
we can add that in a future interface revision.
Resource used as UAV must have TransitionTo="UNORDERED_ACCESS" for correct
runtime state.
These tests (by name in ShaderOpArith.xml) were missing this:
- Derivatives
- QuadRead
- ComputeSample
- ProgOffset
- SampleCmpLevel
- Saturate
- AtomicsRoot
- AtomicsHeap
- FloatAtomics
* [SM6.7][WritableMSAA] Front-end and test fixes
This change fixes DXC to properly pass the SampleCount attribute to DXIL
metadata. A few test issues are also fixed, namely:
- Do not create upload resource for MSAA textures, since this will cause
a sample count mismatch in the runtime and we do not need the upload
resource anyway.
- Fix inverted logic to detect support for ATO and WritableMSAA.
- Pass D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET resource flag when
creating MSAA resource, which is required by the runtime.
* Actually return after skipping ATOWriteMSAATest
* Fix props_ms.hlsl test case encode sample count
Co-authored-by: Tex Riddell <texr@microsoft.com>
Writable MSAA ExecutionTest was setting TestResults::Skipped for devices
that have the necessary support and continuing to run the test.
Follow the style of the RawGather ExecutionTest.
* Made nologo option hidden
* working tests for compute and ps/vs shaders
* working tests for compute and ps/vs shaders
* Fix test and add fallback mode for SM 6.0 to verify test logic
* Correct StructuredBuffer descriptors
* add separate result buffers for each shader, other changes from Tex
* fallback works, add transition to field to uav's
fallback works, add transition to field to uav's. 6_6 still returns all 0's, and there's a message about highest debug layer model supported being 6_5
* fallback works, and on non-fallback, CS works.
* change hardcoded to true rval
* swap root signature and set descriptor heaps so that heaps comes before root
* Remove unnecessary comments, fix indexing to be completely dynamic
* remove extraneous resources in root sig, and use Test_F macro in execution test
Co-authored-by: Tex Riddell <texr@microsoft.com>
Creates a texture interface that represents an anonymous texture to be
populated with valid values then raw gathered from a shader and copied
to a UAV whose contents are compared with the original to verify correct
behavior. Derived textures use templating to share code that varies
depending on the type, type size, format characteristics (norm, signed,
etc), and number of channels.
This includes a fallback mechanism that uses a standard gather or loads
to retrieve the expected results from the aliased texture.
Some incidental refinements and corrections to the resource and view
creation functions
Add support for translation of LLVM extractValue operations and DXIL
bufferStore operations to SPIR-V instructions.
The bufferStore implementation is limited to what is required to
support a simple passthrough compute shader. For the yet unsupported
cases, an error is emitted.
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.
- Taught DxilValueCache to handle switch statements where each case has more than just a single block.
- Fixed `DxilValueCache::ResetUnknowns` just setting value association to nullptr, which was entirely incorrect. Now it correctly deletes the value association that have been marked as unknown.
- Deleted the idea of 'AlwaysReachable' from DxilValueCache, which is unused, ill-defined, and potentially dangerous.
- Improved the dump function for 'DxilValueCache' for better debugging.
Add support for translating createHandle and bufferLoad DXIL operations
to SPIR-V instructions. The most significant limitation of this current
implementation is the naive translation of descriptor set and binding
numbers, but it is sufficient for simple passthrough shaders.
FixOverloadNames renames intrinsics to match renamed overload types,
which happen as a result of loading modules with conflicting types into
the same llvm context. A conflicting type would be one that has the same
name but is a different type.
UDT (User Defined Type) arguments are always pointer types, so when the
intrinsic overload is based on a UDT argument, the type retrieved by
GetOverloadType will be a pointer. The code did not handle this case,
skipping the overload name fix.
This change adds the check for pointer type so UDT overloads will be fixed.
The test links two libraries with a conflicting UDT by the same name, used
in a TraceRay call. This previously crashed during bitcode writing because
of invalid IR.
Writes sample values to a RWTexture2DMS that are the sample index plus 1
in the shader. It copies that data to an output UAV in a separate shader
then reads it back and verifies that it matches.
Incidentally cleans up some of the DX12 utility functions and comments
* Rework name lookup
This is a big change... A lot of the change here is actually reverting
back to clang 3.7 code. Specifically around template name resoltuion.
The root cause of issue #4263 is that in DXC (before this change) HLSL
routes all name lookup through template name resolution. This results
in annotating some things as templates that shouldn't be. Specifically
in the test case in #4263, the second `Load` gets annotated as a
template-id tracking to the first `Load` when it should be just a
method specialization.
This fix is a bit involved.
I revert a bunch of the template handling code back to clang-3.7. This
causes two problems:
(1) HLSL allows omiting empty template argument lists for default
template cases (i.e. `matrix` is valid in HLSL, but in C++ it would
need to be `matrix<>`). This patch should fully resolve that case.
(2) Since DXC routes all names through template lookup, some
diagnostics were only emitted in template name lookup. This patch fixes
_some_ of those cases, but there are test failures that I'll resolve in
a subsequent commit on this PR.
I'm posting this change before it is fully ready to go because it is
large and may take some time to review.
* Issue precision warnings during decl diagnosis
* Adding template test cases
This adds two new test cases. One that verifies that template default
arguments are correctly instantiated when the empty template parameter
list is omitted, and a second that verifies that template function
overloads parse correctly.
* Auto update verifier tests
This is an automated update of the verifier tests. I've manually
reviewed it and it looks correct to me but there's a lot of change here.
Expected differences are:
(1) Some of the old warnings were just wrong...
(2) We only emit promotion warnings on declarations, this removes them
from cases like `std::is_same` uses
(3) Template typenames are unsugared, so `Texture2D` becomes
`Texture2D<vector<float, 4> >`
(4) Warnings are not emitted after fatal errors in the same context (so
we lose a few warnings)
(5) Typenames are quoted
(6) QualType names are printed instaed of custom strings, this results
in some errors that would have said `float16_t` to say `half`, and
errors that ignored `unsigned` qualifiers to bake it in
(7) The order of warning emission changed because we emit in a
different place :(
* One more test case fix for quoted typenames
* Fixing the test case for 4263
* Fixing diagnostic for missing template arguments
* Updating SPIR-V testcase for template changes
* Updating PrettyPrinter with rule for rewriter
This patch adds an option to omit HLSL default template arguments when
pretty printing types inside the rewriter. This minimizes the impact of
the template lookup changes on the rewriter cases.
* Correct missing diagnostics for constant buffers
* Restoring warning to verifier test.
* Updating a testcase I added upstream
VK_KHR_buffer_device_address extension support a Vulkan feature to load data
from an arbitrary raw buffer address. We added
'uint vk::RawBufferLoad(uint64_t address)' before, but it is limited to loading data
with the unsigned integer type.
This commit adds
'T vk::RawBufferLoad<T = uint>(uint64_t address [, uint alignment = 4] )' that
allows us to load data with an arbitrary type.
This mistake was upsetting a certain driver. The UAV being declared is always u0 in space -2. Also changed the name of one struct type to make it more obvious what PIX had added.
authored-by: Jeff Noyle <jeffno@ntdev.microsoft.com>
Enable NRVO when no precise and global coherent to avoid extra memcpy created in clang codeGen.
Also propagate precise from the function to named return value.
* Complete builtin types when used as array params
This is an odd edge case.
C doesn't require array element types to be complete because they decay
to pointers. In HLSL we don't decay to pointers, so we need them to be
complete, otherwise things trip up.
* Fixing code comment
One of these days I'll learn how to write what I mean...
According to the SPIR-V validator this annotation was last usable on
SPIR-V 1.3:
fatal error: generated SPIR-V is invalid: 2nd operand of Decorate: operand BufferBlock(3) requires SPIR-V version 1.3 or earlier
OpDecorate %type_ByteAddressBuffer BufferBlock
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
The visitor was originally built to remove/omit it on Vulkan 1.2 and
higher only, but since supporting Vulkan 1.1 with SPIR-V 1.4 (in #4364)
- which conveniently sits inbetween SPIR-V 1.3 and Vulkan 1.2 - the
check must be made more stict and apply from SPIR-V 1.4 universal
onwards.
Since we check for the "SPIR-V 1.4 (under Vulkan 1.1 semantics)"
minimum target environment for ray tracing extension use, this change
allows it to be now configured as a target-env via command line options.
Some out of date documentation target environments is also updated,
and improvements are made to version checking to use enums rather
than string comparisons.
Fixes#4313
Currently, DXC assigns new locations for each stage variable. When there
are lots of stage variables, the number of locations we use can exceed the
maximum location limit. This commit uses `Component` decoration to pack
signature and reduce the number of locations DXC uses.
SPIR-V backend finds the source code by reading the source file,
which does not work when we pass the source code via memory
buffer. This commit adds a fallback for the case.
Fixes#4218
Implement first part of support for a passthrough compute shader.
This iteration translates the HLSL resources used in a simple
passthrough compute shader (ByteAddressBuffer and RWByteAddressBuffer)
to the appropriate SPIR-V module variables. Errors are emitted for
unhandled instructions.
Compare the expected and generated error output for whole file check
tests. For existing tests, these should be empty, but upcoming tests
will check expected errors as we iterate towards passthrough compute
shader support.
* Added a DXC_OUT_REMARKS kind that prints to stdout in dxc.
Moving -Vi and -H displayed include process from warnings to DXC_OUT_REMARKS.
* Adding a Compiler Test to check DXC_OUT_REMARKS output text