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

632 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li 5ae4b02c38
Fix issue when updateCounter for dynamic resource, also remove createHandleForLib on handle type when not a library. (#3935) 2021-09-07 10:24:42 -07:00
Adam Yang 2bc41323ff
Added binding table file to specify resource binding (#3843) 2021-08-26 11:56:36 -07:00
Grace Jennings 0c2c998326
Add --version flag to print dxc version info (#3912)
* basic -version flag from -? flag

* now --version and added to -? text
2021-08-24 09:53:13 -07:00
Jeff Noyle 5d63d48f44
PIX: Add thread ID to amplification shader payload (#3904)
This change is required to enable PIX to reconstruct mesh shader output data correctly. Without knowing the thread id of the AS thread that launched the mesh shader threads, we don't know which probably-a-mesh to attribute each MS's output to.
2021-08-13 14:04:46 -07:00
Jeff Noyle ec7e332308
PIX: Check SM66 handle types for dynamic indexing (#3819)
While working on another issue I noticed that I had forgotten these cases.
(PIX uses this pass to detect non-constant indexing into resource arrays in order to decide if it should run the whole "shader access tracking" pass to check for out-of-range access etc. So it was failing to detect dynamic indexing and so could choose not to run the SAT pass.)
2021-06-11 14:50:24 -07:00
Atte Seppälä 12b81409bb
Remove execinfo.h include in WinAdapter.h (#3797)
This small change makes it possible to build and use
DirectXShaderCompiler on Android, at least on arm64-v8a.

execinfo.h does not exist in Android toolchain. However it is
only used by clang-hlsl-tests which can be disabled from the build.

CaptureStackBackTrace is not used in any files
compiled in non-Windows builds. This is because CompilerTest.cpp,
where it was used, is disabled from non-Windows build at the moment.

Co-authored-by: Atte Seppälä <atte.seppala@ul.com>
2021-05-27 15:51:23 -07:00
Tex Riddell e6ba792e2d
Fold bitcast-to-base into GEP in MergeGepUse, plus refactor and resource fixes (#3801)
* Fold bitcast-to-base into GEP in MergeGepUse, plus refactor

  - Fixes case where bitcast isn't eliminated under -Od.
  - Fix issue with constant GEP path that was unintentionally using GEP
    from failed prior branch.
  - Change to worklist pattern, which simplifies things.
  - One case wasn't handled, which was going to complicate code:
    GEP -> bitcast -> GEP would combine bitcast -> GEP, but not combine
    outer GEP with the new one.
  - Add dxilutil::TryReplaceBaseCastWithGep that simply replaces if it matches.

* Fix cbuffer layouts when resources are in structs

  - keep track of resources in type annotation information
  - fix cbuffer packing locations for things around resources
  - when translating struct for legacy:
    - remove resource fields from struct types
    - properly replace HLSL type
  - remove unused structs and annotations
  - don't produce type annotations for silly things
  - fix other random bugs found along the way

* Fix ValidateVersionNotAllowed test issue with external validator

  It turns out the test wasn't correct in assuming dxil version reported was
  the one it should expect to be supported by the validator, since that
  represents the compiler version.  The validator version constrains the
  dxil version supported by the validator, not the compiler version.
  See comments in the test for details.

* Fix error reporting in ValidationTest::RewriteAssemblyToText

* Fix tests for translated structs and hostlayout name change.
2021-05-26 20:17:50 -07:00
Greg Roth 6999a51fe9
Update legacy structs during compile (#3659)
Instead of bailing out when compiling libraries without full 16-bit
support enabled, we update the struct type for legacy layouts and
replace the associated ops to the new types where necessary.

This results in converted types named with a leading "dx." prefix that
is an array type which often isn't expected in validation where it newly
shows up, so a change there to permit these types to pass.

As an incidental, remove function annotations when appropriate
regardless of full 16-bit enabling. There was no reason to make this
depend on that setting.

Adapt tests to the new types. Library targets may now produce a
dx.alignment* type instead of the user-specified type.

The prefix was confusing code that assumed it meant it was a builtin
type. Removing it allows reverting some of the hacky changes to evade
the problems that caused.

also fixes a couple mistakes in DxilLowerCreateHandleForLib and corrects
redundant inclusion of dxilmodule and module in params to
UpdateStructTypeForLegacyLayout

alignment.legacy wasn't really describing the current intent of the
modified type. Since the type is altered to match the layout of the
host, it's here renamed "hostlayout."

Fixes #3058
2021-05-25 13:12:26 -07:00
Tex Riddell 002f2e1db5
Fix bugs with ConstantBuffer resource object usage (#3796)
ConstantBuffer<> and TextureBuffer<> resource objects were not being
handled when the objects themselves were used instead of just reading from
them.  Examples are passing to/from functions, but also simply an extra
layer of ParenExpr.  For simple ParenExpr case, it's easy to just drill
through, but this isn't possible for other cases.  More temps need to be
potentially marked, so MarkRetTemp/MarkCallArgumentTemp is unified into
MarkPotentialResourceTemp which is also used for temp created during
EmitAggExprToLValue.  CBuffer init code in FinishCodeGen also needed
fixing.  When replacing resource users with subscript operator, users of
the actual resource object need the original HL resource type, which is
constructed through the HL HandleToResCast and stored to an alloca for
pointer users.

Fixed MutateResourceToHandle pass for CBV/TBV, and for HandleToResCast
case.

Fixed PatchTBufferLoad issues with AnnotateHandle and library cases.

Also added a pass to cleanup doubled AnnotateHandle calls leftover after
inlining.

Along the way, noticed a global init translation bug potentially impacting
the library case, but don't yet have fix implemented, or a specific test
case hitting this.

Also noticed that there's a whole special case for empty cbuffer that gets
created, but I don't think it's actually necessary.  Other code may need
adjusting, but it should be fine to skip emiting of the special opaque-
typed global value for the empty, unused cbuffer.  Added some FIXME
comments for this, but have not tried to make this change yet.
2021-05-24 12:55:03 -07:00
Vishal Sharma 742657ade4
Add option to override semantic defines (#3766) 2021-05-11 21:43:15 -07:00
Greg Roth 61bd18526d
Allow variable offsets to gathers (#3764)
Mostly reverts the change that added an error when offsets were not
immediate or out of range for gather operations. More research suggests
this error was not required and it broke some existing shaders

Fixes #3738
2021-05-11 17:04:58 -07:00
Adam Yang 9a8816ba73
Added an pdb writer overload that doesn't take any input blobs (#3715) 2021-04-28 15:13:17 -07:00
Xiang Li bd38504d5e
Add -dumprs to dxa. (#3703) 2021-04-21 15:31:44 -07:00
Xiang Li 6775e94ef1
Bump shader model to 6.7 (#3679) 2021-04-10 12:24:49 -07:00
Xiang Li 5fa34d1fd6
Save root sig for entry for lib. (#3669)
* Save root sig for entry for lib.
2021-04-07 21:32:17 -07:00
Vishal Sharma 3daa429525
Update BaseAlignLog2 field in ResourceProperties for StructuredBuffer (#3652) 2021-04-01 04:55:31 -07:00
Greg Roth cf135fa88b
Allow removal of trivially dead convergent marker (#3640)
Failing to remove this because it is marked as having side effects so it
can prevent unwanted code movement resulted in trivially dead code being
retained unnecessarily because the marker isn't removed until after dead
code elimination. By allowing its removal when the operation that needed
it has been removed so it has no users, this dead code can be
eliminated.
2021-03-29 17:54:28 -07:00
Helena Kotas 555ca24474
Add load library error to dxc exception handler; add header with exception error codes (#3639)
* Add load library error to dxc exception handler
* Add header with exception error codes
2021-03-26 23:37:41 -07:00
Greg Roth 6b44d611f7
convert recoverable exceptions to c++ (#3636)
Instead of raising structured exceptions for unreachable and fatal
errors, raising c++ exceptions allows returning an error code and
getting a useful message instead of requiring a structured exception
handler to catch it.

Add cast failure assert
2021-03-26 19:56:42 -07:00
Tex Riddell 6244ab8337
Validator/Dxil version error improvements (#3623)
- Move validator/dxil version checks up-front
  These should fail first rather than side effects of trying to validate
  details of a version we don't support.
- Improve message for unsupported validator or dxil version
  These errors are most likely if compiling separately from validation
  and failing to override the validator version properly, or running on
  an external validator that doesn't support a newer dxil.
- Use dxil version from metadata for DxilModule when loading,
  rather than just setting it to minimum based on shader model.
- Remove TODO from validator messages that shouldn't be there
2021-03-25 14:03:31 -07:00
Helena Kotas 53b2ad9ffd
Add d3d12TokenizedProgramFormat.hpp header from the Windows Driver kit (#3617)
* Add d3d12TokenizedProgramFormat.hpp header from the Windows Driver kit.

The header is now open source under the University of Illinois Open Source License.
This change reduces the DX compiler projects dependencies on WDK to TAEF testing
framework only. That means the project can be built without WDK if tests are
excluded from the build (HLSL_INCLUDE_TESTS cmake option to OFF).

Fixes #2965
2021-03-25 12:19:38 -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 9b475a7fa3
Add dxc exception handler (#3604)
The most common cause of internal compiler errors are access violations
or stack overflows. This registers an exception handler in dxc.exe for
these cases that are otherwise unhandled. It prints a simple message
for these errors and passes the exception along.

In case this is unwanted for some reason, a hidden disabling flag is
added as well.

Adds LLVM builtin exceptions for assert, fatal, and unreachable. Adds a
default message for exceptions not explicitly addressed.

Alters behavior of llvm_unreachable so it always raises an exception
regardless of compiler support for unreachable hints.

Reports errors using fputs instead of std::cerr to ensure that no
allocation is necessary. Custom output is performed in a static array
that is output with fputs.
2021-03-18 20:37:21 -07:00
Adam Yang e8372b9b9a
Fixed arg pairs not correct for old source in module pdbs (#3599) 2021-03-18 01:33:06 -07:00
Adam Yang 640c9af748
Added way for caller to replace args in PDB utils (#3595) 2021-03-17 12:38:11 -07:00
Xiang Li de09119850
Add -link to dxc. (#3577)
* Add -link to dxc.
2021-03-15 09:09:58 -07:00
Tex Riddell 0b686f347b
FileChecker improvements: VFS, %dxl, FileCheck -D, error reporting (#3576)
- VFS captures output files for duration of test, enabling:
- %dxl test IDxcLinker
- add -D to FileCheck args to supply defined variables
- report failing RUN command when not consumed by FileCheck or XFail
2021-03-14 22:13:26 -07:00
Michael Haidl 1db765ea9c
DXC extension for DXR Payload Access Qualifiers (#3171)
This extension adds qualifiers for payload structures accompanied with semantic checks and code generation. This feature is opt-in for SM 6.6 libraries.  The information added by the developer is stored in the DXIL type system and a new metadata node is emitted during code generation. The metadata is not necessary for correct translation of DXIL, so it may be safely ignored, but it provides hints to unlock potential optimizations in payload storage between DXR shader stages.
2021-03-14 18:31:40 -07:00
Adam Yang 92e3f2a6be
Fixed a bug reading version string from PDB. Implemented IDxcVersionInfo3 for DxcCompiler. (#3570) 2021-03-12 19:35:15 -08:00
Xiang Li 48b2c4611a
Support -export-shaders-only for linker. (#3571)
* Support -export-shaders-only for linker.
2021-03-11 23:49:28 -08:00
Adam Yang 95850daf8f
Made -Zs the flag for slim PDB. Added -Qpdb_in_private. (#3541) 2021-03-09 19:06:52 -08:00
Tex Riddell 5bdf3574bc
Revert "Report error for unsupported types of SV semantics (#3043)" (#3532)
This reverts commit bece3d4faf.

Revert system value type checking code due to regressions.
Will re-merge once it's fully verified fixed.
2021-03-02 21:24:25 -08:00
Greg Roth 3bd5f9ccfa
Errors on non-immediate load/gather offsets (#3283)
Gather operations that take four separate offsets are meant to allow for
programmable, non-immediate values. This removes them from the immediate
and range validations by giving the immediate versions their own opcodes
For these intrinsics and loads, errors are generated when offsets are non-literal
or out of range. These largely use the slightly altered validation paths that the
sample intrinsics use.

Reword error when texture access offsets are not immediates to be
more all encompassing and grammatical.

Incidentally remove duplicate shaders being used for the validation
test from the old directory while identical copies in the validation
directory went unused. Redirected validation test to the appropriate
copies. This is consistent with the test shader re-org's stated intent

Sample operations have a maximum of 3 args, but gather has a maximum of
two since it always operates on 2D images. So gather operations only
pass in two offset args to the offset validation, which resulted in an
invalid access.

Rather than adding a specialized condition to evade this, just iterate
over the number of elements in the array. For sample it will be 3 and
for gather 2 and it will still check for expected undefined args
appropriately.

For the offset legalization pass, the opcode is used to determine the
start and end of the offset args

Only produce the loop unroll suggestion when within a loop

Base error line on call instruction instead of source of the offset

Sort by location in source when possible and remove duplicates

Adapt tests to verify and match these changes

Fixes #2590
Fixes #2713
2021-03-02 18:42:09 -08:00
Tex Riddell 19360a8fa6
Validate CBuffer size to max of 65536 bytes (#3507) 2021-03-02 16:34:35 -08:00
Adam Yang a7770e66eb
Added IDxcVersionInfo3 for custom version string (#3517) 2021-03-02 15:19:04 -08:00
Adam Yang c7d8ac5793
Added recompile function on PdbUtils that just hands back compilation result. (#3529) 2021-03-02 15:18:44 -08: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 62f390cb58
Set shader flags for dynamic resources (#3521)
Set shader flags for resource and sampler descriptor heap indexing based
on the CreateHandleFromHeap call and its ShaderHeap argument
2021-02-27 10:37:57 -07:00
Greg Roth 3f9db446e7
Correct 64-bit atomics on heap resource flags (#3520)
Left a few out
2021-02-26 22:58:33 -08:00
Greg Roth c3f9997709
64-bit atomics usage resource flags (#3518)
When a resource comes from a binding, we can't determine if it is on a
heap or not, so we set a flag on it to let the runtime sort it out.

When a resource comes from the heap directly, we know it's on the heap
so we set the shader flag to check for platform support.
2021-02-26 19:55:59 -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
Vishal Sharma bece3d4faf
Report error for unsupported types of SV semantics (#3043) 2021-02-25 16:38:12 -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 b63b179587
Fixed pdbutils recompilation failure when the main file is in a relative path. (#3486) 2021-02-23 00:10:41 -08:00
Greg Roth 72e46b3709
Fix crashing from null elements producing errors (#3487)
Under certain rare circumstances, it is possible for errors to be
reported for function or global variables that are null.

This eliminates the absolute necessity for a non-null function or GV by
passing in the context needed to report any error. It also avoids some
of the cases where trying to get a debug function would give a null
which would replace the non-null function.
2021-02-22 14:56:54 -08:00
Jaebaek Seo f913bde7d0
[spirv] support optional use of base vertex instance (#3478)
In DX12, `SV_InstanceID` always counts from 0. On the other hand,
Vulkan `gl_InstanceIndex` starts from the first instance. Thus it
doesn't emulate actual DX12 shader behavior. To make it equivalent,
we can set `SV_InstanceID = gl_InstanceIndex - gl_BaseInstance`.
However, it can break the existing working shaders (i.e., compatibility
issue). We want to provide an option for users to choose what they
exactly want by `SV_InstanceID`. This commit adds
`-fvk-support-nonzero-base-instance` option. If it is enabled, it emits
`SV_InstanceID = gl_InstanceIndex - gl_BaseInstance`. Otherwise,
`SV_InstanceID = gl_InstanceIndex`.
2021-02-19 14:30:39 -05:00
Adam Yang 98ddd699de
Added shader reflection part to source-only PDB. (#3467) 2021-02-18 13:32:13 -08:00
Adam Yang 38e4ec9593
Added an internal interface to set a compiler on PdbUtils. (#3452) 2021-02-11 12:39:37 -08:00
Helena Kotas 6e4e1f8b93
Enable and fix warnings on execution tests (#3424)
* Move warning enabling pragma to cpp files before includes and fixed warning that popped up
Whitespace change in ShaderOpArithTable.xml

* Enable and fix warnings on execution tests

* One more warning
2021-02-03 11:46:10 -08:00
Adam Yang 01135442bb
Fixed the parameter for QuadReadLaneAt incorrectly being const (#3421) 2021-02-01 15:44:12 -08:00