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

632 Коммитов

Автор SHA1 Сообщение Дата
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
Tex Riddell f6ff322db3
Add mesh shader support to RootSignature parsing/validation and fix PSV (#2363)
* Add mesh shader support to RootSignature parsing/validation
* Fix PSV so MS output topology doesn't overlap SigInputVectors
* fix PSV version code to use latest when validation disabled
2019-07-24 16:39:34 -07:00
Tex Riddell 2facceae0b
Store mesh payload in function props, fix Wave/Quad/Barrier validation (#2361)
- Compute mesh payload size before final object serialization
  - During CodeGen for MS based on payload parameter
  - During CollecShaderFlagsForModule for AS based on DispatchMesh call
- Store payload sizes in corresponding funtion properties, serializing
  these properly for HL and Dxil Modules
- Use payload sizes from function props for PSV0 data during serialization
- Validate measured and declared payload sizes, don't just fill in
  properties during validation
- Fix Wave/Quad allowed shader stages, enabling Quad* with CS-like models
- rename payloadByteSize members to payloadSizeInBytes
- Add GetMinShaderModelAndMask overload taking CallInst for additional
  detail required to produce correct SM mask for Barrier operations
2019-07-24 10:22:28 -07:00
amarpMSFT 37acf90723 add payload size to Amplification Shader metadata to mirror MS metadata (#2359) 2019-07-23 17:27:42 -07:00
Tristan Labelle 0332b4bd90
Update FeedbackTexture2D types to be templated (#2347)
- Update the HLSL syntax from FeedbackTexture2DMinLod to FeedbackTexture2D<SAMPLER_FEEDBACK_MIN_MIP>
- Update DXIL to only have two UAV types for FeedbackTexture2D[Array] and use an extra metadata field to distinguish between the sampler feedback type.
2019-07-23 12:27:05 -07:00
amarpMSFT fadbe9de8a added missing DXR 1.1 flags (#2352)
Added missing DXR 1.1 flags support + tests
2019-07-18 07:33:57 -07:00
Tristan Labelle 49a5dd63c2
Remove globalopt dependency on the name of the entrypoint (#2350)
GlobalOpt has an explicit test for a function called "main" (eww...) to enable an optimization. This updates the test to match the entry point, independent of its name.
2019-07-17 14:31:26 -07:00
amarpMSFT c41606c737 Add RaytracingPipelineConfig1 subobject to DXR (#2342) 2019-07-16 01:34:45 -07:00
Tex Riddell 397a67082e Misc cleanup during review 2019-07-12 19:19:14 -07:00
Tex Riddell 7a085056f8 Rework PIX access tracking to remove hard coded table.
Instead of hard-coding properties here, constructing every overload of
every resource method we know about, then iterating users, we:
- iterate through used intrinsic functions, collecting the ones that
  have handle parameters (resource accesses).  This will pick up all
  used overloads.
- Instead of hard coding read/write access in a table here, we use the
  function attribute which carries this same information for main resource
  operations.
- Exceptions to matching function attribute:
  GetDimensions: DescriptorRead, but commented to match prior behavior
  BufferUpdateCounter: Counter
  TraceRay[Inline]: Read, but commented to match prior behavior for now
- Then, this type of resource access is emitted for the first handle arg
- Subsequent handles are considered DescriptorRead operations,
- DescriptorRead currently just aliases to Read, but could be useful in
  the future if we want to differentiate or support GetDimensions.
2019-07-12 17:06:10 -07:00
Tex Riddell afbe50930c Merge rayquery into merge-dxil-1-5 2019-07-11 17:20:38 -07:00
Amar Patel (GRAPHICS) 4b4d5ca5f6 Merged PR 122: Add GeometryIndex() to any hit, closest hit, and intersection shaders, with raytracing_tier_1_1 feature bit 2019-07-12 00:14:59 +00:00
Tex Riddell cd9fee2291 Merge rayquery into merge-dxil-1-5 2019-07-11 17:06:38 -07:00
Tristan Labelle b7868f8081 This change implements the `FeedbackTexture2D[Array](MinLOD|Tiled)` types in HLSL and the backing `WriteSamplerFeedback[Bias|Level|Grad]` DXIL intrinsics. 2019-07-11 16:51:16 -07:00
Sahil Parmar 968fe41136 Merged PR 116: Add support for HLSL Meshlets
This PR adds support for new HLSL mesh and amplification shaders.
2019-07-11 20:19:23 +00:00
Amar Patel (GRAPHICS) 6bac49fd65 Merged PR 120: Adding RayQuery intrinsics 2019-07-11 13:49:03 +00:00
Tex Riddell 2209844cda Add RayQuery object, TraceRayInline method + template arg annotations 2019-07-09 18:55:55 -07:00
Helena Kotas c1f17ac954
Move dxclib one level up; string handling in DxilRuntimeReflection (#2308)
Move dxclib one level up / out of dxc directory
Remove unused member in DxilRuntimeData
Change DxilRuntimeReflection handling of strings to be platform independent
Fix opt tool (DxcSetThreadMallocOrDefault no longer exist)
2019-07-09 13:15:55 -07:00
Tex Riddell 03ecd7d3d7 Fix more: array[1] and unbounded cases, address feedback
- Array of [1] would crash in UpdateStructTypeForLegacyLayout
  since IsResourceArray would be false.
- Unbounded array has weird quirk in D3DCompiler reflection:
  all resources report BindCount == 0, except cbuffer reports UINT_MAX.
  Added simple unbounded cases for other resource types to verify.
- Fxc has some auto-binding bugs.
  Worked around in the test with explicit binding.
- Added suggested helper functions for strip/wrap array types.
  Used in code that's part of this change, but didn't search for other
  places to replace yet.
2019-07-06 12:49:19 -07:00
Tex Riddell b6d67a3851 Fix validation for legacy cbuffer layout
- base of struct should always be aligned - or internal bug
- offset for array member must always be aligned - (new) validation error
- alloc and verify struct layouts even when not array field
- out of bound check would have missed OOB on last array element
2019-07-05 18:27:50 -07:00
Tex Riddell f7c0da0d27 Fix type in cbuffer annotation when converting to legacy layout
Copy of original annotation would copy original struct type,
instead of one for legacy layout.  This leads to internal validation
using a different type when validating cbuffer layout than external
validation would use, since this member would be synthesized by the
key, rather than saved and restored directly.
2019-07-05 18:00:31 -07:00
Xiang Li e48c086f14
Check flatten attribute in SimplifyCFG. (#2311)
* Check flatten attribute in SimplifyCFG.
2019-07-02 16:59:13 -07:00
Tristan Labelle c0cf2018e6
Enable validation of rawbufferload/rawbufferstore (#2300)
The validation code was written for these but never ran due to this omission.
2019-07-01 18:45:53 -07:00
Tex Riddell dacb21040a
Fix PDB generation to not require embedded hash inside DxilContainer (#2272)
This would break when official DXIL.dll was used, since it would exclude
the shader hash part that the validator wouldn't recognize, and is not
required for a valid shader.  This prevented shader signing for the
output of newer compiler versions.
2019-06-19 16:03:12 -07:00
Tim Jones 1ad10b616b Add IDxcSourceLocation::GetPresumedLocation (#2240)
Add IDxcSourceLocation::GetPresumedLocation as a wrapper for clang_getPresumedLocation.

This is important for (e.g.) showing errors in the correct location in IDEs when the #line directive is used, primarily in generated code.
2019-06-10 07:00:47 -07:00
Tim Jones 9d31464b57 Expose code completion API (#2222)
Initial code completion API implementation
2019-06-04 08:01:42 -07:00
Adam Yang 2dec1cd0df
Putting debug info in PDB container (#2215) 2019-05-29 16:29:58 -07:00
Greg Roth 8ebb86399d Hide Unix symbols by default (#2213)
* Hide Unix symbols by default

Using the -fvisibility=hidden by default only exposes symbols that have
the __attribute__((visibility("default"))) attribute applied to them.
There are only a couple of functions that are meant to be exposed from
libdxcompiler. To expose the proper functions, the macros used to create
the UUIDs for class types are redefined with the attribute and
DXC_API_IMPORT is defined with the attribute above for non-windows
platforms.

Since we're hiding everything now, the portions that were explicitly
hidden to make MacOS work are removed.

This exposed a number of missing dependencies of libraries and unit
tests. Namely clang-hlsl-tests, clang-spirv-tests, and libclangCodeGen.

Resolves #2203

* Remove explicit marking of DxcThreadMalloc hidden

This was a workaround that is not longer necessary since all symbols are
hidden by default on Unix platforms now.
2019-05-29 12:56:02 -04:00
Tex Riddell 1d72beb39c
Add shader hash blob part (#2212)
- Change default to hash/name based on binary, not source
- Allow inclusion of hash/name without debug info (/Zi)
2019-05-24 17:17:12 -07:00
Tex Riddell 04fb1d6468 Merge remote-tracking branch 'ms/master' into dxil-1-5 2019-05-22 15:34:19 -07:00
John Porto c9b9676c5d
User/joporto/dxcmem refactor (#2196)
* Moves the implementation of DxcThreadMalloc to dxcmem.cpp; removes DxcSwapThreadMalloc

* Remove DxcSetThreadMalloc(OrDefault) -- they were always been used for installing the default allocator

* Deletes copy and move ctors and assignment

* stores the allocator in the TLS slot.

* DxcSwapThreadMalloc should be able to install a null allocator

* Marks the DxcThreadMalloc members as hidden (linux only)
2019-05-20 20:52:10 -07:00
Tex Riddell ba668cf13e Merge remote-tracking branch 'ms/master' into dxil-1-5 2019-05-20 11:49:53 -07:00
Tristan Labelle 347c04d51c
Split DxilGenerationPass.cpp into several files for its several passes (#2180) 2019-05-15 08:59:16 -07:00
Tristan Labelle f89e3b7150
Add support for RWRawByteBuffer.Store<T> (#2176)
Adds support for templatized RWRawByteBuffer.Store<T>. To avoid SROA making us lose the original layout of any struct arguments, a new pass runs before SROA and breaks down such cases into per-element stores. So better be careful with the likes of buf.Store(0, (int[65536])0);...
2019-05-09 11:51:38 -07:00
Tex Riddell 638d988e8f
Fix issues with -Qstrip_reflect and -Qstrip_debug (#2164)
-Qstrip_reflect would reserialize the root signature, leading to
validation failure #2162.  Fixed by moving root sig to writer to clear
from module and prevent re-serialization to metadata.

Fixed -Qstrip_debug with -Zi and no output location still embeding
debug module.
2019-05-03 08:06:31 -07:00
Ehsan 5648e43f18
[spirv] Command line option for providing $Globals binding. (#2156) 2019-05-01 18:28:14 -04:00
Adam Yang 9a0f7160e5
Fixed a host of issues with Eval intrinsics (#2144) 2019-05-01 01:59:16 -07:00
Tex Riddell 753d02595c Merge remote-tracking branch 'ms/master' into dxc-opts3
# Conflicts:
#	lib/DxilContainer/DxilContainerAssembler.cpp
2019-04-24 20:20:36 -07:00
Xiang Li 58b3d23cfc
Support Qstrip_reflect. (#2139)
* Support Qstrip_reflect.
2019-04-24 12:58:25 -07:00
Tex Riddell 69882a0394 Add -Qembed_debug, don't embed debug info by default
- New -Qembed_debug is required to embed PDB in shader container
- -Zi used without -Qembed_debug will not embed debug info anymore,
  and will issue a warning from CompileWithDebug().
- When compiling with Compile() and -Zi, -Qembed_debug is assumed
  for compatibility reasons (lots of breaks without it)
- In dxc and CompileWithDebug() -Fd implies -Qstrip_debug
- Debug name is based on -Fd, unless path ends with '\', meaning you
  want auto-naming and file written under the specified directory
- Debug name always embedded when debug info used, or -Fd used
- -Fd without -Zi just embeds debug name for CompileWithDebug(),
  still error with dxc, since it can't write to your file.
- If not embedding debug info, it doesn't get written to the container,
  only to be stripped out again.
- Fix padding for alignment in DebugName part.
- Default to DebugNameForBinary instead of DebugNameForSource if no
  DebugInfo enabled

- Also fixed missing dependency on table gen options from libclang
2019-04-19 19:57:25 -07:00
Tristan Labelle d56f6eb93f
Fix allocator issues for dxc blob allocations (#2130)
DxcCreateBlobOnHeapCopy allocated using the COM allocator and freed using the default thread allocator, leading to crashes.

But more generally, some DxcCreateBlob functions would take ownership of the passed-in buffer without also having the caller explicitly specify what IMalloc to use for deallocation, which is an error-prone pattern, so I reworked these methods a bit.

This also lead me to find some memory leaks and general memory mismanagement in the the rewriter.
2019-04-18 15:04:06 -07:00
Tex Riddell faacd80b74
Allow clip/cull elements to be declared as array [2] (#2109)
* Allow clip/cull elements to be declared as array [2]

- This approach fixes validation and packing to handle this case.
- There could be implications to runtime ViewID validation
- fix some issues found in packing related to rowsUsed result from Pack
  functions.  Make these return 0 on failure, instead of startRow.
- Split PackNext into FindNext and PackNext that uses it for greater
  flexibility.
2019-04-10 17:37:47 -07:00
Tristan Labelle ada42260b2
Fix an assert on cbuffer loads of bool vectors. (#2104)
After loading a vector from a cbuffer, we attempt moving the debug info upstream, to the individually loaded elements, assuming that they got converted into a vector by a sequence of insertelement instructions. This is not the case for bool vectors, because the insertelement sequence will be followed by a mem-to-reg conversion. Made the code more resilient to such unexpected patterns (better to lose debug info than to crash compilation).
2019-04-04 11:44:33 -07:00
Adam Yang e97fbdb85f
/Fd now sets the shader debug name to the name specified. (#2023) 2019-03-19 17:16:11 -07:00
John Porto d432a02f77
Implements DIA Interfaces for HLSL variable-value mapping. (#2050) 2019-03-19 11:46:10 -07:00
Tristan Labelle 3527762fd0
Allow optimizations to eliminate phis on undef resources before considering them errors
Some large shaders exhibit a behavior where phi nodes are created for resources, in which one of the possible incoming values is undef. This gets cleaned up later such that there are no undef resources left. However the fail-undef-resources pass has already failed compilation by that point. The fix is to change that pass to invalidate-undef-resources and replace the undefs with a special invalid value, such that we can produce an error later if still necessary, when optimization passes have been run such that temporary undef resources have been eliminated.
2019-03-18 14:27:31 -07:00
Tristan Labelle 9559442f3f Renamed from "poison" to "invalidate" 2019-03-18 12:41:07 -07:00
Tristan Labelle 0a801dae8e Moved debug values to the ResRet struct. 2019-03-18 11:00:37 -07:00
Tristan Labelle 088c3cf27b Fix debug info for the return value of resource vector loads. 2019-03-15 16:44:30 -07:00
Tristan Labelle 7c1f9f01e9 The fix. 2019-03-06 15:49:34 -08:00
Tristan Labelle f56fb3a3d0
Eliminate dxilutil::IsHLSLMatrixType in favor of HLMatrixType::isa (#1986) 2019-03-01 10:39:23 -08:00
Tex Riddell 7f7a2f1cd1
Merge pull request #1969 from Microsoft/19h1-rel
Merge 19h1-rel to master
2019-02-25 19:46:55 -08:00
Justin Holewinski bc72038998 Add support for WaveMatch and WaveMultiPrefix<Op> (#1867)
These new DXIL instructions are added to SM 6.5. The valid operations
for <Op> are:

    - BitAnd
    - BitOr
    - BitXor
    - CountBits
    - Product
    - Sum

In HLSL, these are exposed as:

    uint4 WaveMatch(<type> val)
    <type> WaveMultiPrefixBitAnd(<type> val, uint4 mask)
    <type> WaveMultiPrefixBitOr(<type> val, uint4 mask)
    <type> WaveMultiPrefixBitXor(<type> val, uint4 mask)
    uint WaveMultiPrefixCountBits(bool val, uint4 mask)
    <type> WaveMultiPrefixProduct(<type> val, uint4 mask)
    <type> WaveMultiPrefixSum(<type> val, uint4 mask)

In DXIL, these are exposed as:

    [BitAnd,BitOr,BitXor,Product,Sum]
    %dx.types.fouri32 @dx.op.waveMatch.T(i32 %opc, T %val)
    T @dx.op.waveMultiPrefixOp.T(i32 %opc, T %val, i32 %mask_x,
                                 i32 %mask_y, i32 %mask_y, i32 %mask_z,
                                 i8 %operation, i8 %signed)

    [CountBits]
    i32 @dx.op.waveMultiPrefixBitCount(i32 %opc, i1 %val, i32 %mask_x,
                                       i32 %mask_y, i32 %mask_y,
                                       i32 %mask_z)

Scalarization of vector types occur as per the existing wave intrinsics.
For WaveMatch, the match is performed on each scalar and the results
are combined with bitwise AND. For WaveMultiPrefix, the operation is
performed on each scalar and combined into an aggregate.
2019-02-25 14:42:43 -08:00
Tex Riddell 5cdb20b28e Clean up addrspacecast from final shader code
- add addrspace stress test and addrspace inst test
- add ll test for cleanup pass targeting paths that may be difficult to
  hit from HLSL
- fix handling of base-class bitcast cast for structured buffer
- handle addrspacecast in SimplifyBitCast during CodeGen
2019-02-24 02:36:22 -08:00
Tex Riddell a7abe5959a Merge branch '19h1-fixes' into 19h1-fixes-on-master 2019-02-20 12:31:07 -08:00