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

3783 Коммитов

Автор SHA1 Сообщение Дата
Greg Roth 6cf7fbbe45
Remove YUV formats from rawgather test (#4479)
R8G8_B8G8_UNORM and G8R8_G8B8_UNORM are YUV formats really in spite of
not explicitly indicating by their names. We are leaving such out of
format casting for now
2022-06-02 15:44:01 -07:00
Helena Kotas 3ee5e140fc
Remove dxilconv tests dependency on FXC to enable testing on ARM64 (#4494) 2022-06-01 15:14:31 -07:00
Joshua Batista 8d55ed9ce7
dxil disassembly: update check convention, add entry point properties on topology for mesh shaders (#4491)
* update check convention, add entry point properties on topology for mesh shaders

* test all possible output topologies for mesh / geometry shaders
2022-06-01 14:14:22 -07:00
Jakub Kuderski ae943bc576
Bump spirv-tools, spirv-headers, effcee, and re2 submodules (#4493) 2022-06-01 14:20:16 -04:00
Tex Riddell 73c96bfb3c
Add inline GetBlobAsUtf16 methods for back-compat (#4490) 2022-05-31 17:21:53 -07:00
Joshua Batista 69627993e5
Add numthreads to disassembly output (#4484)
* add metadata on numthreads for CS, AS, and MS

* add associated hlsl test file

* move test hlsl file to correct location

* update check values

* tested each shader type separately, added breaks in switch statement

* add some extra numthread checking to each separate type of shader in other existing tests
2022-05-31 12:21:09 -07:00
Jakub Kuderski 7f8f9acc89
[dxil2spv] Print missing runtime errors (#4481)
- Emit a diagnostic when input cannot be parsed.
- Add exception handling code, for exceptions that can originate from
  DXC utility code.

This cannot be easily tested with FileCheck because we would have to
negate the dxil2spv return code.
2022-05-31 15:20:17 -04:00
Greg Roth 9395376ef5
Skip trivially dead GVs during SROA (#4476)
Similar to how allocas are skipped when they are popped off of the
worklist and found to have no users, GVs are similarly removed and no
further processing is performed. That processing flattened the unused
GV, creating new child GVs and associating the debug info from the
parent with the children. Since the unused GV had all its uses replaced
with another, no debug info is found and the compiler crashed.

Also includes more graceful failure if debug info isn't found for any reason

Add a test that prompts that memcpy replacement order and verifies that
it doesn't crash and doesn't flatten the unused GV

A change was made to the order in which identically sized GVs are processed
in SROA to make the flattened GVs order consistently
2022-05-28 01:25:38 -04:00
Tex Riddell 07bf1ae857
Fix leak of FixedSizeMemoryStream object from DxilConv (#4483) 2022-05-27 18:56:48 -04:00
Jeff Sooknarine f1bde42472
Fix build break with new CopyDesc0ToDesc1 (#4477)
Second argument should be D3D12_RESOURCE_DESC for the old version.

Function call needs a semicolon and no open curly brace.
2022-05-26 14:46:36 -04:00
Greg Roth e1f8c6a28a
Correctly copy to resource_desc1 in rawgather test (#4467)
The previous approach was assigning garbage to the final field of desc1
due to alignment padding in desc0 where that field would be.
This just duplicates the utility function behavior to copy one desc to
the new one
2022-05-26 00:11:43 -07:00
Adam Yang 6f1d6d9b2b
Replaced some code in dxil-cond-mem2reg with a dxilutils helper. Fixed a crash. (#4474)
* Replaced the code to delete unread allocas in dxil-cond-mem2reg with calling the helper in dxilutils.
* Fixed a crash in the helper caused by walking the entry in forward order, which could invalidate next iterator.
* Added handling of memcpy's in the helper.
* Added tests that actually exercise the memcpy path.
2022-05-24 20:10:32 -07:00
Joshua Batista fafb0aed39
change filter comparison type for samplers, update test name (#4473)
* change filter comparison type for samplers, update test name

* change filter/comparison type MIN_MAG_MIP_POINT
2022-05-24 15:59:28 -07:00
Greg Roth 9cd1f68c46
Correct const check for atomic methods (#4472)
The check for a const destination param for atomic functions mistakenly
encompassed the first param of atomic methods, which is an offset and
can very well be const. This changes the check to account for methods
when relevant.

Adds a test for this and a few other aspects of atomic methods
2022-05-23 17:35:38 -07:00
Xiang Li 227bd311f2
Fix crash for llvm-dis for windows build. (#4471) 2022-05-23 16:53:25 -07:00
Chris B 37e13a87ec
Teach llvm-dis to read DXIL out of DXBC files (#4451)
* Teach llvm-dis to read DXIL out of DXBC files

This change has no impact on the DXC codebase since we don't use
llvm-dis here, but in LLVM upstream I'm using llvm-dis from DXC to
verify bitcode compatability.

The change here is to intercept the file passed into llvm-dis to detect
DXIL Container files, and read the bitcode out of the DXIL part.

* Updating error handling code

Thanks for the review @tex3d!
2022-05-23 11:16:08 -05:00
Tex Riddell 90ad634f0e
Fix lifetime marker detection causing other users to be missed (#4468)
The codepath to detect lifetime-marker only uses (bitcast -> lifetime intrinsic), failed to check the instruction itself, which could be a user function call directly using the alloca ptr instead of the expected bitcast for the lifetime marker scenario.
If that user function call was unused (for instance, if it returns void), then it will improperly assume that the instruction is inconsequential and only used by lifetime markers, or is unused, thus doesn't matter.

The fix is to only check onlyUsedByLifetimeMarkers if the instruction is a bitcast, since that's the pattern for lifetime marker use on the alloca. If the bitcast is unused, that's also safe to continue, since it does nothing on its own.

BreakUpArrayAllocas during DxilLoopUnroll had the same issue. Targeting and testing this led to several issues (crashes) around multi-dimensional arrays and library paths. For now, there is no simple way to pass multi-dimensional arrays directly to function calls across library boundaries, without either relaxing validation or lowering function parameter types. However, it's legal to use the offline-linking target with these, and that scenario shouldn't crash or generate bad code.

Tests have been added for multi-dim resource array passing and passing of a sub-array type to a user function, which both used to crash or assert.
2022-05-19 19:29:32 -07:00
microsoft-github-policy-service[bot] 5df23a7b0d
Adding Microsoft SECURITY.MD (#4464)
Microsoft mandatory file

Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com>
2022-05-19 11:49:07 -07:00
Adam Yang 24909be7d4
Disable NRVO for entry functions and patch constant functions (#4466)
Disable NRVO for entry functions and patch constant functions.

For entry functions (and patch constant functions) each write to an output argument creates a new call to dx.storeOutput (or dx.storePatchConstant). With RVO enabled, every write to the return variable becomes an output instruction, which could be excessive. To avoid this, disable NRVO for any entry functions and patch constant functions.
2022-05-19 03:42:33 -04:00
Natalie Chouinard 2e49e6809b
[dxil2spv] Command line parsing and output file (#4454)
Add command line argument parsing with the CommandLine library,
and support writing SPIR-V module binary to an output file when
specified.
2022-05-18 16:56:26 -04:00
Jakub Kuderski 9ff4815c86
[cmake] Allow to set C/C++ linker (#4462)
Backport an LLVM cmake option to specify the C/C++ linker to use.
This implementation is simplified and unlike the llvm-project one
does not contain any linker-specific tweaks.

On my system, setting `-DLLVM_USE_LINKER=mold` reduces the full build
time from 81s to 43s.
2022-05-18 13:04:28 -04:00
Greg Roth caec6aaf9e
Disallow illegal Atomic targets + propagate consts (#4453)
This change does a few things.

First and foremost, it disallows a number of illegal destination
parameters to atomic operations. This includes SRVs and other const
 values, non-groupshared and non-resource variables, members of
typed resources, and bitfield members of any resource.

In addition, this correctly propagates const information so that they
can be properly rejected and also the information is reflected.
This involves the consolidation and earlier detection of a number of
these failures as well as an expansion of that detection.
Also adds validation checks that the targets are not const and either
UAVs or groupshared address space.

The const errors are produced in clang and manifest as overload
mismatches. The errors for member access of typed buffers, bitfields,
or non-groupshared and non-UAV destinations are generated
as part of the lowering operation. This is where they were before
and easier to replicate though they would be better in codegen.
In some cases, existing errors were moved earlier in the process
and the logic to generate them simplified.

Add compilation and verifier tests for all.

Also adds validation errors for const destination targets and other
invalid targets and tests for the same.

In order to make those tests, I had to give locations to the function
candidate notes for function builtins. This changed a single verifier
test that depended on the locationless notes.

These tests make use of const groupshared variables that are of
questionable utility, but are valid for now.

Incidentally enhances some existing atomics tests to use a more
complex sequence of references and subscripts.

Finally incidentally added some foolproofing for mistakenly comparing
opcodes without taking into account the "table" or namespace that
they belonged to by changing some utility functions in Sema to require
the table as well as the opcode to produce results.

Fixes #4319
Fixes #4377
Fixes #4437
2022-05-16 21:26:21 -07:00
Greg Roth 5bdf5f8300
instcombine pass before jumpthread for lifetimes (#4459)
Lifetime markers require a cleanup pass to eliminate some unnecessary
code, however one of those passes was JumpThreading, which only
eliminated certain dead blocks, which eliminated phi instructions
leaving looped self increments unconditionally incrementing themselves,
which ended up with infinite recursion when trying to process that
instruction.

By adding Instcombining first, all unreachable blocks are elimianted
first so the partial elimination doesn't leave such bad phi users. To
avoid losing convergence for DXIL specific operations, we must first run
the convergent marker pass, so these passes are moved a little later
than before.
2022-05-16 15:07:54 -07:00
Helena Kotas 95da6e7452
Rename master branch to main (#4461) 2022-05-16 15:00:19 -07:00
JiaoluAMD 50c0199c17
[spirv] Add FixFuncCallArguments options (#4439)
1) promotion of spirv-opt `FixFuncCallArgumentsPass`
2) add tests for the FixFuncCallArguments for the compute shader and
   export linkage shaders
2022-05-13 14:39:08 -04:00
Helena Kotas d3c7fac3c4
Enable control flow guard (#4457) 2022-05-12 23:04:29 -04:00
Tex Riddell ed717499a7
Fix memcpy replacement removing memcpy to output argument (#4456) 2022-05-12 19:37:04 -07:00
Tex Riddell 5118e1876c
Fix use constant corruption from ReplaceUsesForLoweredUDT (#4452)
ReplaceUsesForLoweredUDT was calling use.set(NewV), or calling dropAllReferences() on constant user.
This results in modification of the constant operand, which is illegal and led to corruption of constants.

Loop in ReplaceUsesForLoweredUDT relies on all uses being eliminated to terminate, so constant or potentially constant users are now handled with legal replacements and removeDeadConstantUsers at the end as needed.
2022-05-12 19:08:52 -07:00
Tex Riddell 733740f100
Fix AV from DxBreak adding branch to null location (unreachable) (#4446)
CodeGen for unreachable break would normally skip generation, but DxBreak
mechanism would insert conditional branch still.  Unreachable location
means the builder has no insertion point.  This led to null preds for
blocks, and an AV in SimplifyCFG.

Checking CFG.HaveInsertPoint() is the mechanism used elsewhere to skip
CodeGen in unreachable locations, so this is added to EmitHLSLCondBreak.
2022-05-12 13:55:34 -07:00
Joshua Batista 5ebfae414c
add non-uniform dynamic indexing option to dynamic resources uniform indexing test (#4428)
* add non-uniform dynamic indexing option to dynamic resources uniform indexing test

* assign non-uniform results to different result indices, reduce thread count to 2, use NonUniformResourceIndex correctly

* add non-uniform indexing for samplers, add a definition option in the test, and update the fallback path.

* fixed global variable names, made some simplifications

* unified testing, hardcode 0 for fallback case

* checkpoint, some concerns were addressed

* change test name, make result arrays separate depending on non-uniformity, other fixes

* swapped loops, simplified verification function, fixed 2 fields that weren't reset, other stuff

* variable changes and condition clarity
2022-05-12 00:39:07 -04:00
Daniele Vettorel 71fbb021fa
[spirv] Update SPIRV-Tools (#4445)
This includes some fixes related to flattening resource arrays.
2022-05-10 15:03:42 -04:00
Jaebaek Seo bf9632e8c8
[spirv] run interface variable SROA if signature packing is enabled (#4442)
Based on the Vulkan spec "15.1.5. Component Assignment":

"A Component decoration must not be specified for any type that is not a
scalar or vector."

we cannot decorate `Component` for array/matrix stage variables, which
is critical for the signature packing. We conduct the scalar replacement
for the stage variables to assign `Component` all stage variables, which
allows us to reduce the number of assigned `Location`s. This commit uses
the interface-variable-scalar-replacement spirv-opt pass for the SROA.

Note that the interface-variable-scalar-replacement spirv-opt pass is
experimental. We want to avoid the side effect caused by the pass as
much as possible. Therefore, we enable the pass only when the option for
the signature packing is enabled.
2022-05-10 11:54:05 -04:00
Natalie Chouinard 3c1918e21e
[dxil2spv] Add additional error checking (#4440)
Add some missing error checking for possible nullptrs, and use result of
diagnostic client for setting a succes/failure return value.
2022-05-10 09:09:26 -04:00
Greg Roth 0d053cce0e
Refix new resource creation in rawgather test (#4443)
The previous usage of createCommittedResource3 had a parameter of the
incorrect type too
2022-05-09 23:16:16 -04:00
Greg Roth 2556103bc2
Fix new resource creation in rawgather test (#4441)
The previous implementation had some parameters out of place
2022-05-09 17:14:46 -04:00
Greg Roth 1f4f4c7543
Align RawGather Exe Test with dependencies (#4432)
This introduces the correct mechanism for creating resources that might
be cast to a different format of the same bit size when enhanced
variables are found to be available. It also limits the formats to those
that are natively castable unless the relaxed format casting feature is
available.

To allow this, the resource creation utility function now has the
ability to provide these potential casting targets if supported, new
queries for these features are added, and some of the formats were shuffled
to make it easier to isolate the relevant ones.

Also, retreive advanced tex ops caps bits from from proper options struct
The previous implementation drew from options13, but the settings ended
up on options14
2022-05-06 19:51:26 -07:00
Natalie Chouinard d6cec44c6f
[dxil2spv] Add FileCheck testing (#4431)
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.
2022-05-05 13:20:25 -04:00
Joshua Batista b91ff3c586
enable optimization passes to throw hlsl exceptions (#4427)
* 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
2022-05-03 14:22:55 -07:00
Greg Fischer b71bfeac6a
[SPIR-V] Add support for empty string (#4363)
Fixes #4360
2022-05-03 13:19:27 -04:00
Jaebaek Seo 21773f157c
[spirv] Check parent class when setting contains-alias-component of "this" (#4425)
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
```
2022-05-03 09:38:10 -04:00
Natalie Chouinard f00b3c285d
[dxil2spv] Translate DXIL constants to SPIR-V (#4426)
Add intial handling of DXIL float constants, translating to SPIR-V float
constant instructions. Emit errors for other constant types not yet
handled.
2022-05-02 16:09:13 -04:00
Natalie Chouinard b292f9482b
[dxil2spv] Translate SV_Position to BuiltIn::Position (#4423)
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.
2022-05-02 15:19:08 -04:00
Greg Roth 3082ec4a0f
Enhance i64 atomics testing for texture types (#4424)
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
2022-04-28 16:25:21 -07:00
Justin Holewinski 8a92da0456
[SM6.7][HelperLane] Test fixes for HelperLaneTestWave (#4417)
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.
2022-04-28 11:08:29 -04:00
Tex Riddell bc3c2db697
Fix interface breaks in IDxcUtils and IDxcLibrary from GetBlobAsWide (#4419)
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.
2022-04-27 12:08:40 -07:00
Tex Riddell ae9bf56515
Fix TransitionTo for UAVs in various tests (#4420)
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
2022-04-27 11:46:52 -07:00
Justin Holewinski 751eab03f2
[SM6.7][WritableMSAA] Front-end and test fixes (#4416)
* [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>
2022-04-27 05:04:56 -07:00
Justin Holewinski e3a853a657
[ATORawGather] Remove unreferenced local variable (#4418)
This is causing VS2022 builds to fail with warnings-as-errors enabled.
2022-04-26 17:55:41 -07:00
Jeff Sooknarine ff7580a1fa
Fix Writable MSAA ExecutionTest device checks (#4412)
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.
2022-04-26 10:28:56 -07:00
Joshua Batista 72d679ae86
User/jbatista/drui hlk test02 (#4413)
* 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>
2022-04-25 20:32:12 -07:00