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

686 Коммитов

Автор SHA1 Сообщение Дата
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
Tex Riddell 3b99af518d
Implement fallback path for IsHelper on SM < 6.6 (#3408) 2021-01-29 11:05:05 -08:00
Greg Roth f68dfb5092
Add hidden option to disable lifetime markers (#3406)
Intended for debugging and workarounds
2021-01-28 19:54:16 -08:00
Xiang Li 48a661e490
Remove DxilCondenseResourcesPass. (#3386) 2021-01-22 23:49:34 -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
Tex Riddell 7c9e487afd
Implement IsHelperLane() (#3382) 2021-01-22 12:45:18 -08:00
Xiang Li 797d4b8adc
Mutate resource to handle for shader model 6.6+. (#3374)
* Mutate resource to handle for sm_6_6+.

* Use bitcast to save global symbol and HLSL type for DxilResourceBase.
2021-01-21 17:16:06 -08:00
Adam Yang 2b8ef5b57e
Removed source from debug module. Support slim PDB. (#3348) 2021-01-20 12:25:28 -08:00
Xiang Li ac60ae1f4d
Add annotateHandle when link lower shader model to shader model 6.6. (#3368)
* Add annotateHandle when link lower shader model to shader model 6.6.
2021-01-19 18:15:58 -08:00
Xiang Li 83e538ecc3
Use IsEntry when LowerStaticGlobalIntoAlloca. (#3353) 2021-01-13 16:14:09 -08:00
Xiang Li 4dd6ff6b83
Add getElementStride to DxilResourceProperties. (#3312)
* Add getElementStride to DxilResourceProperties.
2020-12-12 17:21:28 -08:00
Vishal Sharma b0820241c1
Update validation rule info in hctdb.py (#3311) 2020-12-10 17:27:07 -08:00
Adam Yang 4d40670ef3
Fixed writing to RWTexture generating a load and store for each component (#3304) 2020-12-07 22:51:53 -08:00
Jesse Natalie 555fad0bc6
Add UINT8 typedef to WinAdapter.h (#3302) 2020-12-04 19:20:14 -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
Adam Yang 747ee519eb
Added new PDB interface (#3288) 2020-12-02 14:25:09 -08:00
Ehsan d7bb9ee170
Introduce the implicit 'vk' namespace (#3133)
* [spirv] Introduce the implicit 'vk' namespace

If any of these are used for DXIL code generation, the compiler will
report an error about the unknown "vk" namespace.

* [spirv] Introduce vk::ReadClock intrinsic.

The following Vulkan specific intrinsic functions are added:

```hlsl
uint64_t vk::ReadClock(in uint32 scope);
```

Also the following Vulkan-specific implicit constants are added:

```
vk::CrossDeviceScope; // defined as uint 0
vk::DeviceScope       // defined as uint 1
vk::WorkgroupScope    // defined as uint 2
vk::SubgroupScope     // defined as uint 3
vk::InvocationScope   // defined as uint 4
vk::QueueFamilyScope  // defined as uint 5
```

Sample usage looks as follows:

```hlsl
uint64_t clock = vk::ReadClock(vk::WorkgroupScope);
```

If any of these are used for DXIL code generation, the compiler will
report an error about the unknown "vk" namespace.

* [spirv] Add documentation.

* Address code review comments.

* Test: Validate vk namespace is not allowed for dxil.

* Fix usage of DXASSERT.

* Move ValidateVkNamespaceNotAllowed test to HlslFileCheck.
2020-12-01 14:04:14 -06:00
Marijn Suijten af14220b45
[linux-port] Support full IID comparison on GCC (#3062)
The fallback layer for GCC currently uses pointer comparison to match
IIDs as uuid tagging for types is not supported.
Thus, when an external program dlopens libdxcompiler and calls
with a proper REFIID these will not match internal pointers and result
in E_NOINTERFACE.

Note that the reverted patches before this commit alleviated the
situation somewhat by replacing the pointer with a hash of the interface
name. While this again grants a stable value to be used when called from
external binaries these (usually FFI wrappers) now need to understand
whether the library has been compiled with full IID support (as a binary
compiled with Clang has no such limitations), and then pass the hash
anywhere they'd otherwise pass an IID.

WIP: Not all IIDs are added yet, which requires the extra "empty-GUID"
check in IsEqualIID.
2020-11-20 15:18:05 -08:00
Marijn Suijten 11e04d8d2b
Remove unnecessary whitespace in files touched by #3062 (#3272) 2020-11-19 14:22:42 -08:00
rkarrenberg 489c2e4d32
Move force-zero-store-lifetimes flag to help-hidden, remove accidental check from test. (#3264) 2020-11-17 04:56:52 -07:00
rkarrenberg eaa7f95d07
Enable generation of llvm.lifetime.start/.end intrinsics (#3034)
* Enable generation of llvm.lifetime.start/.end intrinsics.

- Remove HLSL change from CGDecl.cpp::EmitLifetimeStart() that disabled
- generation of lifetime markers in the front end.
- Enable generation of lifetime intrinsics when inlining functions
- (PassManagerBuilder.cpp).
- Both of these cover a different set of situations that can lead to
- inefficient code without lifetime intrinsics (see examples below):
  - Assume a struct is created inside a loop but some or all of its
    fields are only initialized conditionally before the struct is being
    used. If the alloca of that struct does not receive lifetime intrinsics
    before being lowered to SSA its definition will effectively be hoisted
    out of the loop, which changes the original semantics: Since the
    initialization is conditional, the correct SSA form for this code
    requires a phi node in the loop header that persists the value of the
    struct field throughout different iterations because the compiler
    doesn't know anymore that the field can't be initialized in a different
    iteration than when it is used.
  - If the lifetime of an alloca in a function is the entire function it
    doesn't need lifetime intrinsics. However, when inlining that function,
    the alloca's lifetime will then suddenly span the entire caller, causing
    similar issues as described above.
- For backwards compatibility, replace lifetime.start/.end intrinsics
  with a store of undef in DxilPreparePasses.cpp, or, for validator
  version < 1.6, with a store of 0 (undef store is disallowed). This is
  slightly inconvenient but achieves the same goal as the lifetime
  intrinsics. The zero initialization is actually the current manual
  workaround for developers that hit one of the above issues.
- Allow lifetime intrinsics to pass DXIL validation.
- Allow undef stores to pass DXIL validation.
- Allow bitcast to i8* to pass DXIL validation.
- Make various places in the code aware of lifetime intrinsics and their
- related bitcasts to i8*.
- Adjust ScalarReplAggregatesHLSL so it generates new intrinsics for
  each element once a structure is broken up. Also make sure that lifetime
  intrinsics are removed when replacing one pointer by another upon seeing
  a memcpy. This is required to prevent a pointer accidentally
  "inheriting" wrong lifetimes.
- Adjust PromoteMemoryToRegister to treat an existing lifetime.start
- intrinsic as a definition.
- Since lifetime intrinsics require a cleanup, the logic in
  CGStmt.cpp:EmitBreakStmt() had to be changed: EmitHLSLCondBreak() now
  returns the generated BranchInst. That branch is then passed into
  EmitBranchThroughCleanup(), which uses it instead of creating a new one.
  This way, the cleanup is generated correctly and the wave handling also
  still works as intended.
- Adjust a number of tests that now behave slightly differently.
  memcpy_preuser.hlsl was actually exhibiting exactly the situation
  explained above and relied on the struct definition of "oStruct" to be
  hoisted out to produce the desired IR. And entry_memcpy() in
  cbuf_memcpy_replace.hlsl required an explicit initialization: With
  lifetime intrinsics, the original code correctly collapsed to returning
  undef. Without lifetime intrinsics, the compiler could not prove this.
  With proper initialization, the test now has the intended effect, even
  though the collapsing to undef could be a desireable test for lifetime
  intrinsics.

Example 1:

Original code:
for( ;; ) {
  func();
  MyStruct s;
  if( c ) {
    s.x = ...;
    ... = s.x;
  }
  ... = s.x;
}

Without lifetime intrinsics, this is equivalent to:
MyStruct s;
for( ;; ) {
  func();
  if( c ) {
    s.x = ...;
    ... = s.x;
  }
  ... = s.x;
}

After SROA, we now have a value live across the function call, which will cause a spill:
for( ;; ) {
  x_p = phi( undef, x_p2 );
  func();
  if( c ) {
    x1 = ...;
    ... = x1;
  }
  x_p2 = phi( x_p, x1 );
  ... = x_p2;
}

Example 2:

void consume(in Data data);
void expensiveComputation();

bool produce(out Data data) {
    if (condition) {
        data = ...; // <-- conditional assignment of out-qualified parameter
        return true;
    }
    return false; // <-- out-qualified parameter left uninitialized
}
void foo(int N) {
    for (int i=0; i<N; ++i) {
        Data data;
        bool valid = produce(data); // <-- generates a phi to prior iteration's value when inlined. There should be none
        if (valid)
            consume(data);
        expensiveComputation(); // <-- said phi is alive here, inflating register pressure
    }
}

* Implement lifetime intrinsic execution test.

- Test SM 6.0, 6.3, and 6.5. The 6.5 test behaves exactly the same way
  as 6.3, it is meant a placeholder for 6.6.
- Test validator versions 1.5 and 1.6.
- Abstract a few things in the ExecutionTest infrastructure to enable
  better code sharing, e.g. for lib compilation.

* Make memcpy replacement conservative by removing lifetimes of both src and dst. Add regression test for this case.

* Allow to force replacing lifetime intrinsics by zeroinitializer stores via compile option.

* Fix regression where lifetimes caused code that was not cleaned up properly.

- Add SROA and Jump Threading passes as early in the optimization
  pipeline as possible without interfering with lowering. These two are
  required to fully remove redundant code due to insertion of cleanup blocks
  for lifetimes. Previously, SROA ran much too late, and Jump Threading
  was disabled everywhere.
- A side effect of this is that we can now have unstructured control
  flow more often. This also breaks one test that was originally written
  when a part of SimplifyCFG that could also create unstructured control
  flow was disabled. That part is still disabled, but jump threading has
  the same effect. I don't know why unstructured control flow is a
  problem for the optimization pipeline.
- Add a regression test that requires the two phases to be cleaned up properly.
- Disable the simplifycfg test which now fails even though simplifycfg
  still does what it should.

* Disable lifetime intrinsics for SM < 6.6, add flag to enable explicitly.

- Add missing default value for unrelated option StructurizeLoopExitsForUnroll.
- Re-enable simplify cfg test disabled in a previous commit.
2020-11-16 15:48:05 -08:00
Marijn Suijten 2ade6f84d6
Linux: Implement prefix-counted BSTR allocation in SysAllocStringLen (#3250)
While this prefix may be an implementation detail the BSTR type
guarantees to be able to store NULL values without accidentally
truncating the string, hence its length must be available to replace the
usual NULL terminator.  This string length in bytes is stored in the
four bytes preceding a BSTR pointer [1], whose value can be retrieved
using SysStringLen.

This commit implements the type in the same way in WinAdapter such that
users of the functions returning a BSTR (currently only in dxcisense)
can expect and use the type in the same way on Linux as they would on
Windows.
While this function and type currently only seem to be involved in names
and logging where NULLs are unlikely, it is good practice to mirror the
Windows type exactly for future-proofing.

Besides, SysAllocStringLen does not specify anything about taking
ownership of strIn so the realloc here is wrong either way.

[1]: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/automat/bstr
2020-11-12 11:01:41 -06:00
Adam Yang 3be547b67c
Fixing store undef later in the compilation. (#3212) 2020-10-20 21:15:49 -07:00
Adam Yang e6b313b6ab
remove-dead-blocks handles switch. Split resource array before finalize. (#3184) 2020-10-15 13:05:39 -07:00
Adam Yang d8dec0efd7
Fixed some cases where O0 fails compilation (#3205)
- Fixed value tracking for dxil intrinsics
- Fixed some selects holding on to invalid resource uses
- Fixed some cases where unused globals hold on to invalid resource uses
- Fixed some cases where stores of undefs stick around
2020-10-14 22:41:03 -07:00
Jeff Noyle b85f1affc6
impl (#3200)
Co-authored-by: Jeff Noyle <jeffno@ntdev.microsoft.com>
2020-10-13 17:09:09 -07:00
Helena Kotas c565b3d20b
Cleanup and minor changes to improve integration with internal projects (#3199)
* Cleanup and minor changes to improve integration with internal projects

Adds -Debug option to hcttest.cmd

* Case insensitive compare for -Debug and -Release flags in hctbuild and hcttest
2020-10-13 16:22:50 -07:00
Greg Roth 754e99b405
Revert "Optimize compile times by not skipping allocas (#3168)" (#3183)
This reverts commit 9459577e8f.
2020-10-05 16:23:12 -07:00
Greg Roth 9459577e8f
Optimize compile times by not skipping allocas (#3168)
Instead of skipping past allocas whenever inserting a new insruction,
which ate up a lot of compilation time, they are inserted at the default
insertion point.

The result is that allocas that would have coallesced just after the
global load an input loads are dispersed throughout the commands. So as
part of dxil finalization, the allocas are moved to the beginning of the
entry block of each function. This results in some minor changes to a
couple tests due to the allocas preceding the loads.
2020-09-29 18:11:28 -07:00
Jaebaek Seo 7f985ff472
[spirv] generate OpenCL.DebugInfo.100 instructions (#3155)
OpenCL.DebugInfo.100
is a SPIR-V extended instruction set that provides DWARF style debug information.
This PR allows DXC SPIR-V backend to generate the rich HLSL debug information
using OpenCL.DebugInfo.100 instructions.
2020-09-22 16:50:29 -04: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
Tex Riddell b3df129d1e
Refactor PSV code for improved maintainability and error handling (#3115) 2020-09-08 19:14:12 -07:00
Tex Riddell bba76d6619
Fix vs2019 build warnings for custom build items (#3114)
This should fix the warnings that have this pattern:

warning MSB8065: Custom build for item "...\tmpdxcetw.h.rule" succeeded,
but specified output "...\include\dxc\tracing\dxc\tracing\tmpdxcetw.h"
has not been created. This may cause incremental build to work incorrectly.
2020-09-04 16:21:53 -07:00
Adam Yang 5d6674ad0a
Hoist exits out of loops when unrolling to make code structured. (#3103) 2020-09-04 13:57:36 -07:00
David Peixotto 55b9194ccc
Modify the extension mechansim to handle custom lowering for resource… (#3081)
* Modify the extension mechansim to handle custom lowering for resource methods

The goal is to allow resource extension intrinsics to be handled the same way
as the core hlsl resource intrinsics.

Specifically, we want to support:

 1. Multiple hlsl overloads map to a single dxil intrinsic
 2. The hlsl overloads can take different parameters for a given resource type
 3. The hlsl overloads are not consistent across different resource types

To achieve these goals we need a more complex mechanism for describing how
to translate the high-level arguments to arguments for a dxil function.

This commit implements custom lowering by allowing the mapping from high-level
args to dxil args to be specified as extra information along with the
lowering strategy.

The custom lowering info describes this lowering using the following format.

* Add missing virtual destructors
2020-08-12 14:13:44 -07:00
Greg Roth efc14a6c40
Sundry code cleanups (#3073)
refactor usage of resourceparams to just use RP

create common way of extracting res properties

make getoverloadtype static

so it can be used to determine version
requirements

Disallow literals where not included

Previously, whether an intrinsic parameter type included an entry for
literals or not, a literal was permitted to be cast to it.

By moving up the explicit per-param check to before this cast takes
place, these implicit casts won't be added
2020-08-12 08:16:12 -07:00
Adam Yang c684cc0421
Added mechanism for extra file outputs (#3060) 2020-08-03 13:25:19 -07:00
Greg Roth cb0191d8db
Correct codegenoption assigning from semantic defines (#3061)
For structurize-returns, the codegenopts assigned were a copy of those
the compiler possesses. This is by design in clang as explicitly stated
in comments. As a result, when the compiler codegenopts are updated, the
codegenmodule's are not.

By adding the ability to query the optimization enables from the hlsl
extension helper, these options can be reflected.

Additionally, the structurize-returns flag would have required a define
with a '-' in it, which isn't possible. So now it converts between '_'
for defines and '-' for options, which is consistent with how other
flags are interpretted.

Adds a unit test similar to that of disable gvn that makes a simple
check to verify that the resturn structurization is enabled.
2020-08-01 19:53:24 -06:00
Greg Roth 6971d25e1e
Restrict parameters to Interlocked* Intrinsics (#3057)
Because the defined types of Interlocked* Parameters do not restrict
type casting, they can result in late errors that cause crashes due to
reference params with casts that aren't actually respected by dxil
generation.

By constraining the parameters as they should be, instead of crashes, we
get errors.

Fixes #2077
Fixes #2483
2020-07-28 12:56:50 -07:00
Greg Roth 41e5ba4448
Modify structurize returns option to use opt-enable (#3052)
This conforms to the established -opt-enable -opt-disable flag standard
to enable this optimization as well as tying in with the semantic
defines mechanism.
2020-07-27 22:19:45 -07:00
Adam Yang 9db52a7f01
Added hidden option to print after all passes (#3051) 2020-07-23 11:09:54 -07:00
Greg Roth 92328d817a
Propagate CodeGen Options and Semantic Defines (#3040)
Adds to -opt-enable and -opt-select flags to the -opt-disable flag and
broadens the utility of all by storing the settings as strings instead
of booleans. -opt-select requires a parameter indicating the setting
name and another indicating the value.

options are repesented as lowercase until they are converted into
semantic defines in metadata. presence of semantic define prefixes
is no longer assumed when trying to write semantic defines to
metadata.

Semantic defines with the user-specified prefix will be propagated to
the corresponding -opt-<enable|disable|select> CodeGen option. 
This allows either way of specifying these options to have the
same effect.

Adds two tests to verify that semantic defines will be
detectable as codegen flags. Another verifies that correct errors are
produced for contradictory flags.
2020-07-21 08:50:42 -07:00
Dan Ginsburg e93ab88f7d
Add -fvk-auto-shift-bindings that applies -fvk-*-shift bindings to re… (#2959)
* Add -fvk-auto-shift-bindings that applies -fvk-*-shift bindings to resources that do not have explicit register assignments.  Closes #2956
* For resources that don't have an explicit register binding, first categorize their registerType using new method DeclResultIdMapper::getImplicitRegisterType.
* When finding automatic binding indices for implicit register bindings, pass an optional shift to useNextBinding.
* Change getNextBindingChunk() to handle finding the next binding range given a bindingShift

* Fix regression with binding numbers causing AppVeyor failure and also fix crash I ran into in my own testing in getImplicitRegisterType() if the getSpirvInstr() did not have an AstResultType.

* Address review comments.

* Update documentation

Co-authored-by: Ehsan Nasiri <ehsannas@gmail.com>
2020-07-13 09:49:27 -05:00
Xiang Li 4211802b9a
Support -line-directive in dxr. (#3027)
* Support -line-directive in dxr.
2020-07-08 15:07:23 -07:00
Greg Roth a5843199c5
Enable warnings as errors for clang builds (#3012)
This fixes up the last of the clang errors that are unique to clang 10.
These take two forms, First, indentation that might indicate the mistaken
impression that a line is within an unbraced conditional block produces
a warning and is corrected in a few places. Second, a warning is
produced when a class has one of copy constructor or assignment operator
explicitly defined and the other left to implicit definition. The
solution is generally to add a definition with the = default assignment.

Finally, this adds the -Werror flag to all clang builds to keep the
build warnings clean and detect flaws that can affect all builds and
platforms.
2020-07-02 08:28:23 -07:00
David Peixotto b27351da66
Preserve precise metadata when replacing instructions in transformations (#3010)
We were not correctly preserving precise metadata when replacing instructions
in various transformations. This caused precise metadata to be dropped
when one a precise instruction was replaced with a non-precise instruction.

For example, given the two equivalent mul expressions

    float x = mul(a, b)
    precise float y = mul(a, b)
    z = x + y

GVN would replace `y` with `x` in the computation of `z`. This caused x to
be computed in non-precise mode.

The fix is to make sure we combine known dxil metadata when replacing instructions.
2020-06-30 09:57:08 -07:00
Greg Roth 29759a8942
Fix remaining Clang warnings (#3008)
Many of these take the form of removing unused member variables and
unused functions. Where they were truly unused, I removed them. Where
they were only used in asserts, I hid them for the release builds. Where
the code in question was original to LLVM, I didn't remove so much as
comment out the offending code. In most cases these changes are
counterparts to already excluded code for HLSL.

A few cases concern indexing or type matches. Where relevant, I lifted
the same solutions in the current source of the llvm project.

I altered the fix made recently to LinkAllPasses.h. Instead of just
disabling the warning, I used the temporary variables that the current
llvm project uses to avoid having to cast null pointers.
2020-06-29 19:24:52 -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
Tex Riddell e0cb412916
Add resource rename pass, dx op overload fix (#2986)
- Add method to DxilModule to rename resources based on a prefix,
  preventing resource merging during linking.
- Also one to rename by binding if desired.
- Add pass to access this resource renaming.
- Fix dxil intrinsic overload names when type disambiguation causes
  types with same name to be renamed with .0+ suffix, but intrinsic
  names remain in collision.
- Handle colliding intrinsic names with unique types in linker.
2020-06-19 15:33:58 -07:00
Xiang Li 19ef31e860
Add IDxcLangExtensions2 to set target triple. (#2981)
* Add IDxcLangExtensions2 to set target triple.
2020-06-18 09:42:49 -07:00
Xiang Li 136f2e7989
Structurize control flow for functions which has multiple returns. (#2968)
* Structuize control flow for functions which has multiple returns.
2020-06-11 00:07:43 -07:00
Greg Roth 5f3ee4b904
Add hidden flag to disable optimization passes (#2962)
It can be helpful to disable an optimization pass or set of passes in
select circumstances. This adds the ability to disable the gvn pass
only, but introduces a way to disable various passes just by accepting
the chosen string to represent them in HLSLOptions and using the
DisablePasses values to determine when a pass needs to be left out in
PassManagerBuilder.
2020-06-10 18:01:04 -07:00
Tex Riddell b59671accf
Use HlslDataDir for DxilConv instead of DxilConvDataDir (#2961)
This was using a define before a header to change the option name.
An inline function used the define when adding the path to a filename.
Unfortunately, this header was included from multiple places with
different values defined for the variable name, and it seems that
sheer luck made it work for a while, even when called from a cpp
file that would have had it defined differently.
2020-06-09 20:19:38 -07:00
Tex Riddell a6b6c26d77
Add option to dump FileCheck input to directory for diffing (#2949) 2020-06-08 14:43:57 -07:00
Greg Roth 0af56b4ab9
Clarify assignment of undefined value to UAV (#2941)
The validation error message for when one or more of the components of a
storeBuffer (or similar) operation are undefined was terribly confusing
to anyone not developing the compiler. It mentioned mask mismatches when
one of the masks was generated based on which operands were undefined.

This changes the error message when the flaw results from the user under-
specifying the copied variable to simply state that the assignment involves
undefined values. If the masks mismatch because the type-based mask didn't
expect values that the user somehow defined, the original error message
results as this is likely a compiler error.

In addition, this consolidates some of the mask checking for rawbuffer,
texture, and generic buffer storage.
2020-06-08 13:04:15 -07: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
Greg Roth ce645d1c11
Improve location reporting for validation errors (#2938)
This strips the previous method of error reporting from DxilValidation
in favor of the DxilUtil methods. With these comes a new way to find
location information for those associated with functions or globals.
Instruction reporting is slightly changed in that the asm informtion
including the instruction and its block is added as a note so as to not
clutter up the line with the error and hlsl location.

For the most part, the existing EmitError* functions were retained, but
their implementation was changed to largely format inputs for the
dxilutil:: function and call it.

Errors that had clear associations with instructions, functions, or
globals had their emitting functions changed to variants that had this
information. The result is error message with as much location
information as is available.

In some cases, functions that implicitly added format arguments where
removed in favor of explicit formatted error calls that are clearer.

* Avoid directory duplication in DIFile MD

Change #2030 prevented the duplication of the directory for filenames
with full paths. However the same problem exists for relative paths that
include directories. This results in duplicate DIFile entries and
confusing error message outputs for Global Variables.

This skips the original code which was meant to prepend the directory
name since our filenames always have that information already.

* Validation error message text changes

This includes a number of different changes to validation error
messages. Some correct grammar. Some add a format argument to the
message for better information. Many of them just add a period to the
end of the error message for consistency and to allow the "Use /Zi"
message to be tagged on the end without jumbling the output.

* Enhancements for Dxil DiagnosticInfo and DxilUtil

Introduce *OnContext diagnostic reporting for messages that don't
clearly adhere to any instruction, global, or function. Also includes
the ability to add a note to supplement an earlier diagnostic.

Add function to DiagnosticInfo. This provides a fallback option for
printing location information when debug info isn't available. At least
we can print the function where the issue occurs.

For GV errors, we can't depend on the module having a dxil module in it.
Debug modules don't get the dxil part cloned. The only use of it was the
potentially cached debuginfofinder. Lacking it, we can just create it on
the fly.

Corrected the format of the output for DiagnosticInfoDxil::print. In
addition to minor fixups, when the diagnostic is a remark or note, it
doesn't need the "Use /Zi" prompt.

DxilLoopUnroll has its own diagnostics reporting. This adds the
associated function for the messages.

* Add function location information for interp mode error

This is to satisfy a specific request for line information for this
specific error. It got left out of the original batch, but it's
important enough for a followon.
2020-06-02 18:26:36 -07:00
Xiang Li 7e780aef6f
Fix crash when remove unused globals in rewriter and support remove types. (#2933) 2020-05-30 22:41:39 -07:00
Adam Yang 598f1d14bf
Simplifying branches to reduce complexity of cfg. (#2931) 2020-05-30 14:06:19 -07:00
Tex Riddell ee442e01bc
Support instruction counts in reflection (#2930) 2020-05-29 20:09:29 -07:00
Tex Riddell 86073a3b0b
Reflection Fixes: SB layout in lib, 16 and 64 bit types, tbuffer, more (#2916) 2020-05-29 08:17:40 -07:00
Xiang Li 3562970cd8
Add DxilLoopDeletion to remove unused loops. (#2927) 2020-05-29 08:13:43 -07:00
Greg Roth dda777009a
Better post-CG error formats using custom diaginfo (#2925)
The existing diagnosticinfo and handler relied on a token for the source
location that isn't available to these locations. By creating
specialized versions, we can retrieve the information from where it is
available and convert it to the source location ID that allows the usage
of the existing diagnostic output complete with code snippets

Add tests that check for line numbers or -Zi
2020-05-28 15:05:29 -07:00
Adam Yang 0d3210d3c8
Fixed debugger jumping around. Got rid of preserve value. (#2893) 2020-05-23 14:31:00 -07:00
Tex Riddell 28d88dfa75
Allow SV_CullPrimitive on PS input, resolve to false (#2900) 2020-05-20 22:23:09 -07:00
Ehsan 00a8233c30
Support for printf intrinsic (#2829)
* Frontend changes for supporting printf.

* [spirv] Add support for printf using SPV_KHR_non_semantic_info.

* Address code review comments.

* [spirv] Address SPIR-V backend comments.
2020-05-07 16:42:15 -05:00
Tex Riddell f2880572dc
Use SmallMapVector for deterministic ordering from GetOpFuncList (#2857) 2020-04-29 19:54:40 -07:00
Greg Roth a0196bcc22
Use Attribute to designate wave-sensitive intrinsics (#2853)
* Use Attribute to designate wave-sensitive intrinsics

This adds an intrinsic attribute to indicate wave-sensitivity that can
be indicated in gen_intrin_main.txt. This and other attributes are
passed along through function representations and lowerings. The
wave-sensitivity needs to be maintained specifically through SROA passes
since it is used by the CleanupDxbreak pass that comes after them.

Specifically this is done to allow extension intrinsics to indicate
wave-sensitivity, but the same mechanism is now used for builtin
intrinsics.

Most intrinsics get a mostly nameless function to represent them between
Codegen and dxilgen. This allows any that have the same prototype to
share the same function. For wave-sensitive intrinsics, they need a
different function or else the attrubute would be similarly shared with
intrinsics matching the prototype. So a minor change is made to their
function names to prevent this.

Adds testing for all these ops and a dummy extension one.
2020-04-28 18:19:51 -07:00
Adam Yang 5c64108bcc
Optimized bitcode loading. Added function to only materialize named MD. (#2854) 2020-04-28 14:04:19 -07:00
Minmin Gong 002ed9737e
Fix the "unused function" warning caused by UuidStrHash (#2848) 2020-04-25 12:26:28 -05:00
Xiang Li 49310e2b2c
Skip copy-in/copy-out for constant global variables. (#2836)
* Skip copy-in/copy-out for constant global variables.

* Enable copy for noinline.
TODO: analysis for global variable alias with parameter.

* Use SetVector and skip resource when copy.

* Disable mayAliasWithGlobal because optimization already covered case not replace when have alias.
When replace const global to a normal value has store, mark it non-constant.
2020-04-23 19:08:03 -07:00
Jeff Noyle 35769dabe1
Pix source-to-instruction offsets (#2835)
This is a direct implementation of a new API for PIX that shortcuts the large and unwieldy (and not-really-working-well) DIA equivalent to find the set of instructions that correspond to a given source location.
2020-04-17 17:21:42 -07:00
Xiang Li 8b92463c32
Add -precise-output (#2827) 2020-04-13 22:24:09 -07:00
Greg Roth 7d665725a8
Add simplify to DxilValueCache for dx.break() (#2803)
* Add simplify to DxilValueCache for dx.break()

To allow loop unrolling, call instructions that reference dx.break()
are given a constant true boolean simplification in DxilValueCache.

This required making the constant string available by moving it into
Analysis.

As an incidental change, I corrected the spelling of simplify in a
couple cases.
2020-04-10 00:40:14 -07:00
Tex Riddell a408139dac
Make remove-unused-globals remove non-static globals (#2809)
- Add support for rewriter (dxr) to FileCheckerTest
- Add test for removing globals
2020-04-03 17:26:04 -07:00
Greg Roth d3af7f1237
Conditionalize breaks to keep them in loops (#2795)
* Conditionalize breaks to keep them in loops

This introduces dx.break, a temporary builtin that is applied as a
condition to any unconditional break in order to keep the basic block
inside the loop. Because it remains in the loop, operations that depend
on wave operations inside the loop will be able to get the right values.

Such builtins have to be added at finishcodegen time or else clang
throws an error for an undefined function. Consequently, the creation of
these is split in two. First the branch is created with just a
constant true conditional. Then at finishcodegen, it is converted to the
result of the dx.break() builtin.

By using the result of a temporary builtin function, the optimization
passes don't touch the false conditional like they might if we started
with the global constant. 

Normal break blocks don't need this conditional, but we don't know that
at code generation. So a later pass identifies break blocks with wave
sensitive operations that depend on wave ops that are inside the loop they
are breaking out of and preserves those conditionals while removing all
the rest.

As part of dxil finalization, the dx.break() function is removed and all
branches that depended on it are made to depend on function-local
loads and compares of a global variable dx.break.cond.

The DxBreak Fixup pass depends on dxil-mem2reg. It is placed immediately
after to allow as many optimizations to go as they would without this
change in shaders that don't have any wave ops.
2020-03-30 19:02:04 -07:00
nicebyte 34de0e3fd9
Fix incorrect UUIDs on Linux (#2796)
When using libdxcompiler.so, UUIDs of classes don't match
because on Linux a UUID is effectively an address of a
static member variable.

This change replaces UUIDs with a consistent value -
a hash of the class name.
2020-03-30 13:36:10 -05:00
Greg Roth 78b58851fd
Print Lines or "add -Zi" on error messages (#2782)
* Print Lines or "add -Zi" on error messages

This change adds to the existing EmitErrorOnInstruction functionality in
dxilutil to include EmitErrorOnFunction and EmitErrorOnGlobalVariable.
Each derives line number information from the metadata of these objects
if available. If it isn't available, the error or warning messages are
still printed, but an additional suggestion to add a -Zi flag is added.
2020-03-23 22:04:01 -07:00
Jeff Noyle 816f3141d4
PIX: Add new API to retrieve info about compilation options (macros, target profile etc) (#2758)
This lets PIX call a much better-matched API than DIA to retrieve these things.
2020-03-10 13:11:55 -07:00
Greg Roth 1809c25dce
[linux] Initialize m_count for IUnknown (#2757)
The Linux adapter code includes an implementation of the IUnknown
interface that contains m_count to keep track of the reference counts.
That variable is used extensively, but is not initialized.

Complaints about use before initialization due to this make up the
overwhelming majority of the complaints Valgrind makes against DXC on
Linux. Adding a constructor makes IUnknown no longer an interface,
but the build doesn't seem to care.
2020-03-09 11:32:28 -07:00
Jeff Noyle 481657a0ce
Update to correct(er) SAL (#2735)
PIX's code-analysis pass complained about the SAL in this file. These changes make it happy.
2020-03-05 16:37:03 -08:00
Tex Riddell ccd45ba40b
Rewriter: improvements plus extract uniforms to global scope (#2730)
- Added rewriter functions for extracting uniforms into global scope
- Will not work if name collides (namespaces have bugs)
- Values under cbuffer _Params, resources outside (more bugs)
- Added rewriter HLSLOptions and support all through RewriteWithOptions
- Refactored dxr.exe to use HLSLOptions and RewriteWithOptions
- Exposed Write*VersionInfo functions from dxclib
- Fixed issue with External[Lib/Fn] for version printing.
2020-03-04 21:27:07 -08:00
Greg Roth 08f3100f25
Increase scan limit for DSE, add option (#2725)
* Increase scan limit for DSE, add option

Due to the large number of fields in a struct passed to an exported
function, the number of useless loads and stores exceeded the builtin
limit, which left a lot of them in. This increases the default limit
from 100 to 500 and adds a hidden parameter -memdep-block-scan-limit to
set it to whatever is needed for future workarounds.

The Dead Store Elimination pass examines stores to see if they are
unneeded. If it finds no uses between the store and the original load,
it eliminates both, but if it has to exceed the instruction limit to get
there, it gives up and leaves it in just in case.
2020-03-04 15:50:01 -08:00
Adam Yang 227c8e6f5a
Added instructions to preserve intermediate values of computations. (#2721) 2020-03-03 00:29:42 -08: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
John Porto 63a3b45067
Adds the DxcPixDxilDebugInfo interface and friends. (#2715)
* Adds the DxcPixDxilDebugInfo interface and friends.

* Modifies the entrypoints to require InParam/OutParam for pointers, as well as CheckNotNull them

* Removes S_FALSE for happier Jeff

* Fixes broken test

* returns E_POINTER for nullptrs

* Returns S_FALSE from UnAlias for non-aliasing types.

* fails GetName for arrays

* Addresses CR comments
2020-02-25 17:50:23 -08:00
Tex Riddell 367dd44879
Fix outputs -Fre, -Fsh, -Frs, and -Fc with -Fh (#2716)
- Fix output naming for StringRef
- Support /Fc when /Fh is provided
- Fix root sig strip flag
- Create root sig stream output
- Validate -Frs root sig output for signing with DXIL.dll
- Move outputs under valHR success branch
- Add test for -Fre, -Fsh, -Frs, and -Fc with -Fh
- Rework hcttestcmds.cmd completely: checks a lot more stuff and is way more robust,
  while being much easier to read, add to, and maintain, I hope.
2020-02-25 11:02:48 -08:00
Jeff Noyle eb33030b03
Pix mesh shader output instrumentation (#2709)
This is a pass for PIX that adds instructions to write mesh shader output (vertices and indices) to a UAV for later ingestion by PIX in order to present a view of that output.
2020-02-21 10:25:34 -08:00
John Porto 6eb0e070fb
Adds pass for converting calls to dbg.value to dbg.declare (#2706)
* Adds pass for converting calls to dbg.value to dbg.declare

* fixes travis build breaks

* addresses CR comments
2020-02-20 09:13:07 -08:00
Xiang Li 4098229583
Code cleanup. (#2708)
* Code cleanup.
2020-02-19 16:41:11 -08:00
Xiang Li 8156151a58
Update name and fix nonuniformindex. (#2697)
* Add nonUniformIndex for CreateHandleFromHeap and change name to CreateResourceFromHeap.

* Check group when lower CreateResourceFromHeap.
2020-02-14 15:24:36 -08:00
Adam Yang b33846a03c
Using DxilValueCache for unroll. (#2694) 2020-02-13 15:46:00 -08:00
Xiang Li 91fe12f0eb
Add GetResourceFromHeap. (#2691)
Add GetResourceFromHeap for hlsl.
For Dxil, add CreateHandleFromHeap and AnnotateHandle.

All handles ( createHandle, createHandleForLib, createHandleFromHeap ) must be annotated with AnnotateHandle before use.

TODO: add AnnotateHandle for pix passes.
            cleanup code about resource.
2020-02-12 21:50:02 -08:00
Helena Kotas a42ffbf491
DXBC to DXIL Converter + unit tests (#2685)
Includes dxilconv-specific DXIL optimization passes added to opt.exe tool.
2020-02-11 12:07:26 -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
Adam Yang 7a8c4a20da
Fixed incorrect PHI value in DxilValueCache. Also using it in a few more places. (#2668) 2020-01-30 17:27:22 -08:00
Greg Roth c9b1465954
Fix crash when using precise matrix with -Od (#2670)
* Fix crash when using precise matrix with -Od

To flag a variable as precise, a dx.attribute.precise call is inserted.
In the case of matrices, this becomes a problem if it persists too long
due to validation errors because the matrix is never lowered. When we
reach the HLMatrixLowerPass, the matrix can be lowered to vector. This
change detects when the precise call is applied to a matrix, lowers the
parameters and replaces the call with one taking a vector instead.
The call is necessary to keep the precise informaton across function
calls.

Adds variante of precise tests. precise/matrix.hlsl is modified by
matrix_od.hlsl to take the -Od parameter.
precise/propagate_to_producers_interproc.hlsl is modified to use
matrices since an earlier fix for this bug caused a regression when this
alteration was made.

Fixes #2189
2020-01-29 22:33:38 -07:00
Tex Riddell 32168eac84
Add pragma control for diagnostics and option printing (#2656)
* Add pragma control for diagnostics and option printing
* Test converting warning to error with #pragma dxc diagnostic error "..."
* Support options: -f[no-]diagnostics-show-option and -W[no-]<warning>
2020-01-27 18:07:03 -08:00
Xiang Li 2f440d0462
Move wave sensitive check from validation into DxilValidateWaveSensit… (#2640)
* Move wave sensitive check from validation into DxilValidateWaveSensitivity pass.
2020-01-10 13:43:01 -08:00
Xiang Li 9e5bd8b870
Bump to shader model 6.6 (#2631) 2020-01-06 11:04:44 -08:00
Xiang Li 9c89a1c2c6
Make shader model related code generated. (#2629)
* Make shader model related code generated.
2019-12-30 12:37:07 -08:00
Tex Riddell d356a8bc54
Fix incorrect definition for DXC_PART_REFLECTION_DATA in dxcapi.h (#2605)
* Fix incorrect definition for DXC_PART_REFLECTION_DATA in dxcapi.h

* Add test for reflection stripping and create reflection when stripped.

- Test stripping of reflection with public API
- Create reflection when stripped should not crash, but provides little
  actual info.  This tests a fix made previously in that area.
2019-11-27 13:19:34 -08:00
Tex Riddell 005576d73d
Merge pull request #2596 from tex3d/fix-val-ver
Fix validator version and metadata compatibility issues.
2019-11-20 19:21:09 -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 540104fc0e SV_ShadingRate should be allowed in MSPOut
- removed _65 from MS stages, since that's handled by the shader target.
2019-11-20 11:58:17 -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
Xiang Li 94460c988b
Support register binding on resource in cbuffer. (#2582) 2019-11-11 12:03:06 -08:00
Xiang Li 462253a263
Clear register binding for resource in cbuffer. (#2580)
TODO: use correct register binding if exist.
2019-11-08 12:56:44 -08:00
amarpMSFT 42a511cb77
Add missing intrinsics to query InstanceContributionToHitGroupIndex via RayQuery (#2578)
* Add Candidate_ and Committed_InstanceContributionToHitGroupIndex() intrinsics to RayQuery object
2019-11-07 13:16:36 -08:00
Tex Riddell 0513758aee
Fix header/reflection for RTAS/FeedbackTexture (#2549)
- Make header no longer conflict with officially added shader input types
- Replace uses with last enum +1/+2 to make compatible with prev SDKs
- Add reflection Test for FeedbackTexture2D[Array]
2019-10-24 17:27:27 -07:00
Tex Riddell 6eb541244a Lower vector/matrix early for UDT ptrs used directly such as Payload 2019-10-22 09:48:19 -07:00
Tex Riddell 6357448a38 Update type validation to support legal UDT case.
New Rules:
outer type may be: [ptr to][1 dim array of]( UDT struct | scalar )
inner type (UDT struct member) may be: [N dim array of]( UDT struct | scalar )
scalar type may be: ( float(16|32|64) | int(16|32|64) )

- Disallow pointers to pointers, and pointers in structs
- Disallow multi-dim arrays at top-level, but allow within struct
2019-10-22 09:48:19 -07:00
Tex Riddell f383b21be9 Add HLLowerUDT: early UDT ptr lowering for direct use in final Dxil
- DispatchMesh and other intrinsics that use UDT ptr directly need
  this to prevent copying and reconstruction, as well as prevent vectors
  and HL matrices from being used in final Dxil.
2019-10-22 09:48:19 -07:00
Tex Riddell a6a28a34bc
Fix lowering for all TextureCube[Array] Sample* and Gather* overloads (#2535)
* Fix lowering for all TextureCube[Array] Sample* and Gather* overloads

* Fix offsets for Gather test for change to i32 0 from i32 undef

- When not specifying immediate offsets when they can apply,
  we used to provide undef, but we should have been using zero.
2019-10-19 13:28:54 -07:00
Tex Riddell f5a75b4e4c
Update PSVSemanticKind for SV_ShadingRate and SV_CullPrimitive. (#2532) 2019-10-17 15:38:56 -07:00
Xiang Li 0bd0afe693
const folding on dxil.convergent.marker. (#2523) 2019-10-16 16:56:03 -07:00
Adam Yang 97ec60accd
Added pass to remove regions with no escaping values or side effects. (#2508)
* Erase dead region

* Pass dependencies

* Simpler heuristic, only checking that Begin dominates End and End post dominates Begin

* Small cleanups. No longer iterating whole block to find PHIs

* A few optimizations. Fixed infinite loops caused by self-loops
2019-10-08 15:45:22 -07:00
Tex Riddell 2a01c58f73
Fix RayQuery allocation for CSE, DCE, statics, arrays, and lifetimes (#2469)
Fixes problems like:
- extra AllocateRayQuery calls, or improper location (for lifetime)
- proper array support
- static global RayQuery

This RayQuery allocation changes:
- Add a constructor to RayQuery
- Set init sequence to use constructor in InitializeInitSequenceForHLSL, just for RayQuery
- For array: modify EmitCXXAggrConstructorCall to
  - loop over index instead of pointer to allow SROA of RayQuery struct
  - mark the loop as HlslForceUnroll
- Add hidden flag for HL intrinsics to allow internal intrinsic not produced
  by HLSL directly - mangle name so it can't be matched during parse.
- Add hidden HL AllocateRayQuery intrinsic
- Translate constructor call on ptr to HL AllocateRayQuery intrinsic call producing handle i32 during FinishCodeGen
- Translate RayQuery ptr to load i32 handle value for intrinsic methods during SROA_HLSL
- Flatten RayDesc for TraceRayInline
  (otherwise /Od fails validation since RayDesc type may still be present)
- No longer skip RayQuery for SROA_HLSL
- Update lowering for AllocateRayQuery, i32 handle, and flattened RayDesc
- Remove ReadNone attribute from AllocateRayQuery to prevent incorrect CSE optimizations
- Manually cleanup unused RayQuery allocations
2019-09-27 12:50:43 -07:00
Tex Riddell 8a65c18d93
Refactor useful code from DxilTranslateRawBuffer into dxilutil (#2487) 2019-09-25 09:08:00 -07:00
Tex Riddell 9e16e99895
Change SV_CullPrimitive to NotPacked (#2462) 2019-09-17 12:38:15 -07:00
Tex Riddell 2bf23d3edf
Fix SampleLevel lowering for Cube/CubeArray (#2449) 2019-09-05 14:05:06 -07:00
Tex Riddell 114080aaec
Merge pull request #2416 from tex3d/sep-reflect
Merge separate refleciton and validator 1.4 compatibility fixes
2019-08-22 12:08:44 -07:00
Jaebaek Seo 75e5f76a55
Update CLSID scope (#2420)
Some clang versions report compiler errors because of constants
definition for CLSID saying that 'selectany' can only be applied
to data items with external linkage. This commit let only MS VS
build use "__declspec(selectany)".
2019-08-21 14:05:08 -04:00
Tex Riddell 171b98ff05 Merge branch 'sep-reflect-merge' into sep-reflect 2019-08-20 17:39:42 -07:00
Tex Riddell 16bb46f69d -validator-version: use '.', fix typo, complete linker support 2019-08-20 17:38:46 -07:00
Tex Riddell 0f23b6946c Merge remote-tracking branch 'ms/master' into sep-reflect 2019-08-19 00:43:25 -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 4ac7d8d584 Fix -validator-version issue, add tests
- default should be UINT_MAX, not zero, since zero is used
- compare validator version against target profile minimum for error
- add back implicit -Vd for lib_6_1/2 in CompileWithDebug since
  target profile is supplied outside options, so option validation
  would not know to fail without -Vd.
- add tests for various cases
2019-08-16 20:52:23 -07:00
Tex Riddell a11fad7b86 Put HelpHidden on correct option 2019-08-14 16:27:14 -07:00
Jaebaek Seo 982d8fcc25
Support UUID for clang build (#2404)
Linux build emulated UUID because of the lack of UUID support, but
clang indeed supports it. This CL allows clang to use UUID.
2019-08-14 13:41:27 -04:00
Ehsan 922ef652fa
[spirv] Add option to flatten array of resources. (#2397)
* [spirv] Add option to flatten array of resources.

Current SPIR-V code generation uses 1 binding number for an array of
resources (e.g. an array of textures). However, the DX side uses one
binding number per array element. The newly added
'-fspv-flatten-resource-arrays' changes the SPIR-V backend behavior to
use one binding number per array element, and uses spirv-opt to flatten
the array.

TODO: Add a test where the array is passed around.
TODO: Test this works with steven's PR and proper results are produced.

* [spirv] Update tests to include array of samplers.

* [spirv] Take early exit condition out of the loop.

* [spirv] Add documentation for the new cmd option.

* [spirv] Invoke CreateDescriptorScalarReplacementPass when needed.

* [spirv] address code review comments.
2019-08-14 09:45:01 -04:00
Tex Riddell ed53d1e5b0 Strip reflection from DXIL part when /Qstrip_reflect
- hide temporary /Qstrip_reflect_from_dxil option (it will always strip
  reflection from DXIL in the future)
2019-08-12 20:19:39 -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 5894e7ab66 return bool changed from DxilModule::StripReflection 2019-08-12 16:15:52 -07:00
Tex Riddell 4234a9ae53 Add CB Usage to metadata, compute in hlsl-dxil-lower-handle-for-lib 2019-08-12 15:32:17 -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 f0bab7f861 Make MetadataHelper validator version aware
- use current validator version for adding template type metadata,
  rather than min for shader model.
2019-08-12 15:20:51 -07:00
Tex Riddell 406f537b49 Add -validator-version override
- remove auto-Vd on lib < 6.3, since this is already required to be
  explicit by option parsing.
2019-08-12 15:20:51 -07:00
Tex Riddell f1633a93f0 Added to CoreOption: /Fo /Fe /P /Qstrip_rootsignature /setrootsignature 2019-08-12 15:20:51 -07:00
Tex Riddell 4599bd7588 Remove DxilRuntimeData::InitFromRDAT_Prerelease 2019-08-12 15:20:50 -07:00
Tex Riddell 6e99295bdc DxilConstants.h: Add CompareVersions and StateObjectFlags 1.4 valid mask 2019-08-12 14:35:37 -07:00
Tex Riddell c8f7a6c970
Allow [Get/Set]NumThreads on Mesh/Amplification shaders (#2393) 2019-08-05 19:45:24 -07:00
czw831024 5fca2b49e1 add DXIL tests to verify mesh shader's output size and payload plus output size 2019-08-01 12:21:45 -07:00
Tex Riddell c012b4d0f5
Fix intrinsic arguments for WriteSamplerFeedback operations (#2387)
- Align coord dimensions with Sample for future flexibility and alignment
- Fix ddx and ddy arguments to support the correct number of dimensions
- Rewrite lowering, using SamplerHelper
- Clean up SampleHelper a bit, adding additional asserts/checks
- Set components to zero for default offset, not undef
2019-07-30 18:34:19 -07:00
Tristan Labelle 1156209ad6
Fix nondeterminism sources in the linker. (#2383) 2019-07-29 14:33:33 -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