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

632 Коммитов

Автор SHA1 Сообщение Дата
Tex Riddell 00302c4dfe DxilRuntimeReflection: avoid possibility of wstring::data() invalidation 2018-04-19 18:48:18 -07:00
Ehsan 8df58eaf32
Fix PSVSemanticIndexes::Get function return value. (#1231)
The value obtained by calling table.Get was not actually returned.
2018-04-18 13:03:04 -04:00
Tex Riddell 5ab102a352 Merge branch 'master' into rtmaster 2018-04-16 15:25:53 -07:00
Lei Zhang a4491dd439
[spirv] Support shifting all sets with -fvk-*-shift N all (#1224) 2018-04-13 15:40:44 -04:00
Young Kim 0777a7a020 Merge branch 'master' into rtmaster 2018-04-10 16:47:47 -07:00
Tex Riddell 0021e993a2 Merged PR 56: Avoid inserting other insts before allocas in several passes.
Avoid inserting other insts before allocas in several passes.

- Improve code that creates allocas/non-allocas to keep allocas first
- Add helper functions to dxilutil
- Use name AllocaBuilder for CreateAlloca for clarity
2018-04-10 23:33:41 +00:00
Young Kim 0bc25bd790 Revert dxilpipelinestatevalidation namespaces 2018-04-10 12:31:30 -07:00
Lei Zhang 0a8b8c4e1d
[spirv] Rename -fvk-use-glsl-layout to -fvk-use-gl-layout (#1206)
GLSL as a shading language does not define the layout rules for
std140/std430; the OpenGL graphics environment defines that.

This is also more consistent with -fvk-use-dx-layout.
2018-04-10 10:25:26 -04:00
Young Kim 33a8ad5130 Merged PR 61: Implement DxilRuntimeRefleciton API for runtime
DxilRuntimeReflection uses RDATTableReader to obtain information about the library. InitFromRDAT call will allocate all memory required to get DXIL_LIBRARY_DESC.
2018-04-10 00:08:50 +00:00
Lei Zhang 99c142be0b
[spirv] Add support for DX layout rules (#1198)
These layout rules can be turned on with -fvk-use-dx-layout.
For both cbuffer/tbuffer and structured buffers.
2018-04-08 12:50:57 -04:00
Ehsan 2a0b7c49fd
[spirv] Add -fspv-target-env command line option. (#1187)
* [spirv] Add -fspv-target-env command line option.

The valid values for this option currently are:
vulkan1.0
vulkan1.1

If no target environment is specified, vulkan1.0 is used as default.
2018-04-03 09:12:51 -04:00
Xiang Li 357803d342
Don't sink sample coordinate into control flow. (#1188) 2018-03-29 16:33:59 -07:00
Lei Zhang 241d32c810
[spirv] Allow explicitly controlling SPIR-V extensions (#1151)
Added FeatureManager to record all extensions specified from
the command-line and emit error if trying to use one not permitted.

Added command-line option -fspv-extension= to specify
whitelisted extensions.
2018-03-27 17:42:16 -04:00
Lei Zhang 236cdc1cdf
Hook up --help-hidden with PrintHelp() (#1060)
We have defined --help-hidden in HLSLOptions.td but the compiler
is not set up to respect it. This commit hooks up them.
2018-03-27 12:08:11 -04:00
Shawn Farkas 368aead044
Add an isAlwaysUniform property to instructions (#1168)
Add an isAlwaysUniform property to instructions
2018-03-21 18:51:00 -07:00
Lei Zhang 0d8a15a61a
[spirv] Better reflection support via new extensions (#1111)
This commit uses the HlslCounterBufferGOOGLE decoration to link
the main RW/Append/Consume StructuredBuffer with its associated
counter buffer. It also uses HLSLSemanticGOOGLE to decorate
stage IO variables with their semantic strings from the source code.
2018-03-17 13:05:31 -04:00
Tex Riddell 81f8b8c3a2 Avoid inserting other insts before allocas in several passes.
- Improve code that creates allocas/non-allocas to keep allocas first
- Add helper functions to dxilutil
- Use name AllocaBuilder for CreateAlloca for clarity
2018-03-15 17:41:42 -07:00
Xiang Li d66d48721f
Set default input control point count to 1. (#1135) 2018-03-13 11:06:30 -07:00
Tex Riddell cb5f27c080 Merge branch 'master' into user/texr/rt-merge-rebase 2018-03-12 13:11:12 -07:00
Tex Riddell c842450dfd
DxcOpts: init flags, FileCheckerTest: fix error handling for ReadDxcOpts. (#1126) 2018-03-12 12:57:03 -07:00
Tex Riddell 571ff78e00
DPF on llvm_assert. (#1115) 2018-03-12 12:55:31 -07:00
Lei Zhang 70990344ed
[spirv] Implement relaxed layout for vector types (#1092)
Based on GLSL std140/std430 layout rules, relaxed layout allows
using vector's element type's alignment as the vector types's
alignment, so that we can pack a float value and a float3 value
tightly. This is the default right now.

Also add an option, -fvk-use-glsl-layout, to turn off the relaxed
layout for vectors and use conventional GLSL std140/std430 layout
rules.
2018-03-12 10:21:54 -04:00
Young Kim 799331737d Merged PR 38: Cleanup RDAT Table, fixing resource dependency, and adding function dependency 2018-03-10 01:57:20 +00:00
Tex Riddell f8e1af0417 Merge branch 'master' into user/texr/rt-merge-rebase 2018-03-09 00:55:21 -08:00
Xiang Li 277bb0bce3
Use memcpy when cast cbuffer constant into static global. (#1125) 2018-03-08 22:34:46 -08:00
Young Kim 20067a37fe Merged PR 35: Merge user/kiyoung/function-feature-flag to user/texr/rt-merge-rebase
- Refactoring ShaderFlag out of DxilModule
- Have Shader Flag per function on RDAT blob
2018-03-08 01:59:39 +00:00
Tex Riddell bff194564f Merged PR 33: Fix break due to mismatched use of const in Props/Signature Map keys.
Fix break due to mismatched use of const in Props/Signature Map keys.
2018-03-06 18:18:29 +00:00
Xiang_Li (XBox) 88de36b2f5 Merged PR 31: Support select chain in TranslateHLCreateHandle.
Support select chain in TranslateHLCreateHandle.
2018-03-05 23:07:47 +00:00
Young Kim 0a098d7cbb Merged PR 28: Add RDAT blob for library targets and add its reader 2018-02-26 23:51:39 +00:00
Tex Riddell 914c040b14 Merged PR 26: Fix intrinsic names to match spec.
Fix intrinsic names to match spec.

- PrimitiveIndex still maps to low level dx.op.primitiveID
2018-02-21 21:51:20 +00:00
Tex Riddell 6e6f8dbdf6 Merged PR 24: Require payload/attribute/param structs for ray shaders. (MD CHANGE)
Require payload/attribute/param structs for ray shaders. (MD CHANGE)
2018-02-21 21:50:39 +00:00
Xiang_Li (XBox) 4a0950ea79 Merged PR 27: Keep resource global in LLVMUsed and remove in RemoveResourceSymbols
- prevents GV removal while resource still points to it
2018-02-20 23:09:36 +00:00
Xiang Li 47958a9410 Support export when link to library. 2018-02-16 17:48:53 -08:00
Tex Riddell 520f06d442 change *_USER_DEFINE_TYPE to *_USER_DEFINED_TYPE 2018-02-13 15:46:32 -08:00
Tex Riddell ca260c3891 Fix line endings. 2018-02-12 18:17:52 -08:00
Tex Riddell 7d145d64d5 Merge branch 'master' into user/texr/rt-merge-rebase 2018-02-12 17:51:50 -08:00
Young Kim 2af98c8a43
Bump up version number. (#1066)
bump up version to SM6.3 and DXIL1.3
2018-02-12 13:27:48 -08:00
Lei Zhang 7dbfa84a14
Add an option to allow pre-expand token-pasting (##) operands (#1065)
The fxc compiler evaluates both operands before performing the
token-pasting operation. But the default Clang way is to follow
C standard, which token-pastes operands as-is, without any
pre-expanding.

This commit adds support for the fxc behavior via the command
line option: -flegacy-macro-expansion.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1005
2018-02-09 14:31:12 -05:00
Xiang Li ce0bddfc43 Support debug info for linking. 2018-02-08 14:34:10 -08:00
Xiang Li 247f74a647 Support link to lib. 2018-02-07 19:34:26 -08:00
Xiang Li c6915bcccd Support nonUniform. 2018-02-07 14:02:43 -08:00
Tex Riddell 8beb970b51 OP::GetTypeName - use struct name for UDT and return StringRef 2018-02-07 12:28:12 -08:00
Xiang Li fdb8161ccb 1. Not replace local/static resource to handle for lib.
2. Not SROA on resource.
3. avoid unpack for resource.
4. Use value type for createHandleForLib.
5. Move all scalar global resource load to the beginning of function.
   This will stop other pass do optimizations on the loads of scalar global resource.
6. Not remove local resource for lib.
2018-02-06 19:30:24 -08:00
Xiang Li fdf2c31ca6 1. Fix IgnoreHit and AcceptHitAndEndSearch.
2. Support init list for RayDesc.
3. Remove range_id for lib.
4. Update some test.
2018-02-05 18:51:47 -08:00
Xiang Li dc3ad5efe5 Lower createHandelForLib.
TODO: fix nonUniform, resource array fails and remove LinkInfo.
2018-02-05 17:54:08 -08:00
Xiang Li 519938f12e Lower HLCreateHandle into CreateHandleFromResourceStructForLib. 2018-02-05 17:54:07 -08:00
Tex Riddell 15cd5f16e6 Matrix lowering for functions with UDT params preserved.
- Keep track of patch constant functions for later identification
- functions that require input/output signature processing identified
  with IsEntryThatUsesSignatures
- update lib_rt.hlsl intrinsics and naming
2018-02-05 17:54:07 -08:00
Xiang Li 69bc49ffe4 Support System Value retrieval functions. 2018-02-05 17:54:07 -08:00
Xiang Li c45aa784ac Add AcceptHitAndEndSearch, CallShader, CommitHitAndStopRay and change ReportIntersection into ReportHit.
Also change RayTracingAccelerationStructure into RaytracingAccelerationStructure.
2018-02-05 17:54:06 -08:00
Xiang Li eb4b0ae768 Support user define type for dxil operation.
Add RayTracingAccelerationStructure to dxil resource.
Lower ReportIntersection and TraceRay.
2018-02-05 17:54:05 -08:00
Xiang Li bc2e19b771 Support TraceRay and ReportIntersection which has user-define param at front-end. 2018-02-05 17:54:04 -08:00
Tex Riddell 9a3bbb6603 Support SV_RayPayload and SV_IntersectionAttributes 2018-02-05 17:52:21 -08:00
Tex Riddell e9ce3e97d1 Add RT shader types for function attribution in lib target. 2018-02-05 17:52:21 -08:00
Tex Riddell c225dead63
Merge types in linker, and recognize class.matrix.* type for library. (#1033) 2018-01-31 13:47:05 -08:00
Tex Riddell acf2bc48d9
Set !dx.valver in Linker (#1031) 2018-01-31 13:45:54 -08:00
Young Kim 1e97116e9f
Fix countbits, reversebits, firstbitlow intrinsics for int16 types (#1037)
Fix countbits, reversebits, firstbitlow intrinsics for int16 types
2018-01-30 14:29:10 -08:00
Jeff Noyle 004c681a97
Move PIX options out of DxilGenerationPass.*, use option string properly, reduce header usage (#1022)
* Clean up option usage, includes, and move PIX passes to their own header

* move utils to header

* use radix, pass proper default
2018-01-26 15:43:44 -08:00
Lei Zhang fa1e7cddd0
[spirv] Add SubpassInput(MS) and vk::input_attachment_index (#1000)
Two new Vulkan specific intrinsic resource types, SubpassInput and
SubpassInputMS, are introduced to provide a way to use subpass inputs
in Vulkan. Their signatures:

template<typename T>
class SubpassInput {
  T SubpassLoad();
};

template<typename T>
class SubpassInputMS {
  T SubpassLoad(int sample);
};

T can be a scalar or vector type.

If compiled without ENABLE_SPIRV_CODEGEN, the compiler will report
unknown type name for SubpassInput(MS). If compiled with SPIR-V
CodeGen and trying to use SubpassInput(MS) in DXIL CodeGen, the
compiler will report an error saying the type is Vulkan-specific.

A new Vulkan-specific attribute, vk::input_attachment_index is
introduced to provide a way to set the input attachment index for
SubpassInput(MS) objects.
2018-01-20 17:16:39 -05:00
Jeff Noyle ad3e51b1dd
New pass for PIX "shader access tracking" (#998)
* py changes

* checkpoint

* wrong overloads for a couple ops

* Correct out-of-range checking

* test

* RTV

* Add shader access tracking and reportage of dynamically indexed registers

* Uniquify and encode proper register index!

* remove unncessary noise

* rename a var
2018-01-19 14:47:06 -08:00
Lei Zhang f9d613b795
[spirv] Add support for -fvk-invert-y (#967)
This is to accommodate Vulkan's coordinate system, which is different
from DX's.
2018-01-08 11:42:47 -05:00
Xiang Li b816c124f1
Support resource select for lib profile. (#940) 2017-12-20 10:47:29 -08:00
Xiang Li ba844c25fe
Support local resource array which don't have dynamic indexing. (#938) 2017-12-19 15:29:11 -08:00
Young Kim ecdde943f7
Fix microcom and build issues, add missing .rc files
- fix microcom.h macros to allow for custom constructor and other issues
- fix 32/64-bit build issues in ShaderOpTest
- add missing .rc files for dxl, dxlib_sample, and dxc_batch
2017-12-14 18:38:53 -08:00
Young Kim 6c998fda25
- Add int16, uint16 execution tests (#920)
- Add enable-16-bit-types argument to half test shaders
2017-12-14 11:33:59 -08:00
Xiang Li 0790e03364
Remove stacksave and stackstore. (#914) 2017-12-12 18:50:01 -08:00
Young Kim 4904266822
Code Cleanup for Execution Tests (#879)
- Cleaning up execution test
- Generating xml test file from the script and hctdb
- Fixing hctdb categories for unsigned int
- Adding more execution tests (Fadd, FSub, FMul, FDiv, Add, Sub, SDiv)
2017-12-05 15:17:50 -08:00
Lei Zhang 5de265fddb
[spirv] Add support for ignoring unused resources (#875)
Added a new command line option -fvk-ignore-unused-resources
to avoid emitting SPIR-V code for resources defined but not statically
referenced by the call tree of the entry point in question.
2017-12-05 12:21:55 -05:00
Lei Zhang 05057495e8
[spirv] Adopt new changes in SPIRV-Tools (#846)
Uses the legalization pass recipe from SPIRV-Tools.

Also change -fcgl to disable both legalization and optimization.

Validation on some tests are turned off because of new image
instruction checking in SPIRV-Tools. Enabling them is a TODO.
2017-11-23 22:30:49 -05:00
Young Kim 77594e8624
Change rangeID parameter for CreateHandle to const (#833) 2017-11-20 20:04:54 -08:00
Lei Zhang 0b309e9faf
[spirv] Add CL option to disable SPIR-V legalization (#814)
/fcgl is reused in SPIR-V CodeGen for disabling SPIR-V legalization.
2017-11-17 11:44:44 -05:00
Young Kim 289d09e700
Bitcast for 16bit types (#817)
This change adds bitcast intrinsics for 16bit types (asfloat16, asint, asuint)
2017-11-16 11:38:56 -08:00
Young Kim 3cad152a90
Template argument for byteaddressbuffer load store (#804)
This change removes new Load variations (LoadHalf, LoadFloat, etc) for RWByteAddressBuffer/ByteAddressBuffer methods and add templated Load intrinsics. This templated Load only works on scalar or vector types, and its variations (Load2, Load3, Load4, etc) do not work with templates and work as it did before (only storing uints). For Store operation, you can store any scalar or vector types of up to 16 bytes, while prior to 2018 Store only supported storing uint scalar.
2017-11-15 18:47:12 -08:00
Young Kim 5016218962
Fix dxc help message (#813) 2017-11-15 14:08:54 -08:00
Young Kim a48d81fcac
New scalar types (#792)
This change is to add fixed width scalar types in HLSL 2018.
These types are: int16_t, uint16_t, int32_t, uint32_t, float16_t, float32_t, and float64_t.
Prior HLSL versions do not support these fixed width types.

This change also renames /no-min-precision command line option to /enable-16bit-types. int16_t and uint16_t are only allowed with this mode.
2017-11-13 15:03:19 -08:00
Young Kim 2c140f795c
RawBufferLoad and new methods for ByteAddressBuffer (#762)
This change is an extension of float16 support. We are adding LoadHalf, LoadFloat, and LoadDouble method to byte address buffer so that users can access data from byte address buffer by these types. Also starting shader model 6.2, we are mapping byte address buffer and structure buffer load/store operations to RawBufferLoad/Store to differentiate raw buffer load from typed buffer load. Unlike BufferLoad for typed buffers, RawBufferLoad for min precision types will not have its min precision values as its return types, but their actual scalar size in buffer (i.e rawBufferLoad.i32 for min16int and rawBufferLoad.f32 for min16float). RawBufferLoad/Store contains additional parameters, where mask was required for correct status behavior for CheckAccessFullyMapped, and alignment is for relative alignment for future potential benefit for backend.
2017-11-07 18:15:19 -08:00
Young Kim 8c55bbbe6d
Denorm to function attribute (#764)
- Denorm mode to function attribute not function annotation
- Adding validation rule for fp32-denorm-mode



* Fix from comments
2017-11-06 18:09:14 -08:00
Xiang Li d8cefeb1ba
Make sure status only used by CheckAccessFullyMapped. (#763)
* Make sure status only used by CheckAccessFullyMapped.
2017-11-03 18:12:15 -07:00
Young Kim ce9d6267a5 DataLayout String and ConstantBuffer Offset Fix (#727)
This change is to update correct target data layout for DXIL. Now that we have a scalar type of size less than dwords, we need to correctly print string data layout to determine non-packed structure layout.

This change also fixes alignments issues with ConstantBuffer as it was having different CG path from cbuffer.
2017-10-26 14:51:50 -07:00
Adam Yang 946e0b3922 Merge pull request #726 from adam-yang/test
Using IMalloc::Free instead of delete for Release.
2017-10-23 11:26:39 -07:00
Lei Zhang 8702f97dff [spirv] Add support for four register number shifting options (#720)
Added the following four command line options to shift register
number for Vulkan:

* -fvk-b-shift
* -fvk-t-shift
* -fvk-s-shift
* -fvk-u-shift

These options are used to avoid assigning the same binding
number to more than one resources.
2017-10-20 19:37:11 -07:00
Adam Yang edae151c04 Added back in the Tread Malloc guard 2017-10-20 15:17:59 -07:00
Adam Yang 2fea86ac2b Using IMalloc::Free instead of delete for Release. 2017-10-20 14:42:05 -07:00
Marcelo Lopez Ruiz 64f3b34995 Adds support for pipeline restart (#683)
* Adds support for pause/resume in pipeline.
* Adds 0.0 as the validator version to indicate no validation should occur.
* Moves module parsing from dxcompiler down to HLSL library.
* Adds support for optimizer to process a DXIL part.
* Adds a form with designer support for the interactive optimizer.
2017-10-11 14:04:24 -07:00
Jeff Noyle b06a8153ff Shader debug instrumentation (#680)
See the comment in DxilDebugInstrumentation.cpp for a summary of how this-all works. Basically: instrument all instructions to output "trace" info to a UAV so that a debugger can reconstruct the execution of the shader and offer a debugger-like experience.
2017-10-09 15:30:29 -07:00
Young Kim 028a08a6a9 Code Cleanup for syncing with Windows (#651) 2017-09-26 09:45:43 -07:00
Young Kim a05ef74c88 ViewID validation fix: ignore element interpolation since normal signature matching ignores it. (#618) 2017-09-13 15:21:18 -07:00
Young Kim 223a885613 Group Signature Elements by Element Width (#610)
This change is to enforce the new constraint on signature packing: pack signature elements by data width. Before we introduce fp16 type, every element was assumed to reserve 32 bits. Since we are introducing a new 16 bit data type, we need a new way to enforce signature rules.

After discussions we decided that it would be nice to pack elements based on data width. However, we are still enforcing the rule that each row contains up to 4 elements, regardless of the size. This way, depending on the hardware support drivers can optimize packing signatures, while on DXIL level we maintain the assumption that there are 4 elements per row. We are also still constraining on the total number of rows to be 32 for now. This can be changed in the future if people find this limit to be an issue.
2017-09-06 11:04:33 -07:00
Young Kim b89c21d25b Fp16 constant buffer and shader flag (#575)
This change is to support fp16 on constant buffer.
We are still keeping a row pitch of 4 dwords. So we can fit up to 8 halfs in one row.
Dword data types will be aligned to dword address space for efficiency. We are also introducing new flags "use native low precision" if we have low precision type present and /no-min-precision option is enabled.
2017-08-21 15:06:45 -07:00
Xiang Li 99af88f63b Update oprand name for BFI. 2017-08-18 15:12:49 -07:00
Lei Zhang 0e0e014232 [spirv] Add CL option for stage I/O location assignment order (#578)
A new CL option -fvk-stage-io-order={alpha|decl} is added to
control the order for assigning stage I/O location numbers.
The default is also changed to declaration order (decl) instead
of alphabetical order (alpha).

Also extended testing fixtures to support additional CL options.
2017-08-17 20:59:45 -07:00
Xiang Li 8c4f2db67e Add -NoLineDirectives to ignore #line. (#550) 2017-08-11 14:55:45 -07:00
Young Kim eacdff2a5c Support FP16 (#471)
This change is the initial step for supporting fp16.

Support half type with /no-min-precision option. This switch can be moved to other master switch in the future as we refine our spec for half support. 
min16float will be treated as half with warnings.
Fix compiler test to take additional arguments, and fix regression tests.
TODO: we need to make decisions on what triggers low precision instead of min precision. Also need to change signature packing and constant buffers for half.
2017-08-10 10:19:43 -07:00
Xiang Li 3f866d5e70 Use lazy load for linking. (#527) 2017-08-07 12:14:24 -07:00
Xiang Li 13665a2673 Bug fixes. (#511)
1. Support empty struct as call arg.
2. Define _ATL_DECLSPEC_ALLOCATOR for older atlbase.h
3. Fix typo in SROA_Parameter_HLSL::preprocessArgUsedInCall for use AllocaBuilder when need RetBuilder.
2017-08-02 17:11:44 -07:00
Tex Riddell 705c3348e4 Add operand index enum and set methods to instruction helpers (#430)
* Add operand index enum and set methods to instruction helpers

* hctdb_instrhelp.py: Use namedtuple for llvm_type_map values.
2017-07-31 13:33:51 -07:00
Xiang Li 36ba7ac534 Add HLDeadFunctionEliminationPass. 2017-07-29 10:27:18 -07:00
Xiang Li 46e47f01e5 Refactoring DxilEmitMetadata pass. 2017-07-29 10:27:18 -07:00
Xiang Li a318eb6106 Support return of resource for library.
1. Don't check hasMulticomponentUAVLoads for lib.
2. Skip mem2reg for unpromotable handle alloca for lib.
3. Support find resource attribute from function call.
4. Avoid unpack for dxil types.
5. Add resource attribute for fieldAnnotation.
2017-07-29 10:27:18 -07:00
Tex Riddell c9beb84c51 Fix ViewID state for flow control and consistent ViewID detection (#484)
* Fix ViewID state for flow control and consistent ViewID detection

1. Different ways of determining ViewID usage led to assert or crash.
Use DxilModule flag to guarantee consistency.  But this required
splitting DxilEmitMetadata pass into two passes, one that finalizes
the module and computes flags run before ComputeViewIdState, and one
that simply writes the metadata.

2. storeOutput in flow control with values not dependent on that flow,
such as literals, would not pick up control flow dependence.
Fix by picking up control flow dependence on storeOutput instructions,
not just the value being written.

* Fix control depenence computation

There was a bug in the implementation of the control dependence algorithm.
We were incorrectly iterating over all descendents in the postdom tree where
the algorithm should only iterate over immediate children.
2017-07-28 11:51:15 -07:00
Tex Riddell bcbaa611ed Add new feature info names to disassembler (#476)
- also update ShaderFeatureInfoCount and static_assert that the
count matches in disassembler
2017-07-27 16:49:02 -07:00
Jeff Noyle d3f53b7f3e "Dr PIX": Force early Z (#467)
PIX has the ability to turn on early z and show you the performance difference with and without.
This pass implements the DXIL side of it.
2017-07-27 13:34:54 -07:00
Young Kim 55667043c3 Support denorm option (#446)
This change is to support preserve denorm operations. We do this by creating dxc options and propagate them all the way to dxil metadata so that drivers can see how it should handle floats.
Currently we support three modes: any(default), preserve, and ftz

Denorm option will be of per function flag. We store this information at function annotation metadata. This means that for DXIL 1.2 we have a new structure for function annotation. The change in structure is documented on DXIL.rst
2017-07-27 10:08:14 -07:00
Xiang Li c1973d761c Code Cleanup. (#475)
Add default for switch to avoid warnings.
2017-07-26 21:35:02 -07:00
Xiang Li 96c9c0597c Code cleanup. (#469)
1. Move DxilEmitMetadata out of DxilGenerationPass.cpp
2. Move helper function out of HLModule.
2017-07-26 11:02:20 -07:00
Jeff Noyle 47226d0422 PIX: Pixel count/cost pass (#457)
The pass implements functionality for PIX for the "pixel cost", "depth complexity" and "overdraw" visualizers. You can probably infer what the pass does from the names "overdraw" and "depth complexity": For each pixel rendered it increments a corresponding counter in a UAV of a buffer that is the same size as the render target. The "pixel cost" pass does the same thing, only the increment is a weight value calculated from the total cost of the draw call, as derived from PIX's GPU-side profiling system.
2017-07-25 16:08:31 -07:00
Young Kim 4d325c78b4 Update shader model 6.2 (#435)
1. Update shader model 6.2
2. update DXIL version to 1.2 and its tests
3. Allow noalias and alias_scope metadata per instruction for validator 1.2
2017-07-19 22:00:31 -07:00
Xiang Li c6a4746212 Add rewriter option to keep user define. (#432) 2017-07-17 11:28:23 -07:00
Jeff Noyle 82fcc7ca0f (PIX) Reduce msaa to single-sample (#427)
This pass will be used in PIX for "Dr. PIX experiments", wherein a workload is re-rendered with MSAA turned off in order to get an approximate understanding of the performance impact of MSAA.
2017-07-14 13:40:49 -07:00
Jeff Noyle add0d6ec4c (PIX passes) Take constant color from CB (#426)
* maybe?

* Add a "mode" that inserts CB references too

* Add tests

* Xiang's helper to recreate meta-data

* Create CB properly

* Use actual defined constant

* CR feedback: incorrect "one or the other" assert. Unnecessary sethandle. Not accounting for CB id > 0. Test CB id > 0.
2017-07-13 21:07:03 -07:00
Xiang Li c9e9019780 Write specifiers before anonymous struct. (#423)
* Write specifiers before anonymous struct.
* Add rewrite option to mark all global variable not internal as extern.
2017-07-12 18:20:10 -07:00
Xiang Li f0c3cbd454 Resolve name collison for dxil types in BitcodeReader. (#411)
Resolve name collison for dxil types in BitcodeReader.
2017-07-10 16:28:23 -07:00
Marcelo Lopez Ruiz d5bb3089cf Add support for custom allocators (#390)
Supporting a custom allocator for dxcompiler.
Adds recovery for exceptions and out-of-memory handling.
Add custom allocator support to linker.
Fix for release-only test failure.
Removes assertion about presence of command-line option registration
2017-07-06 16:45:48 -07:00
Xiang Li 114fd223d1 Add DxilD3DCompile and DxilD3DCompile2 as example of library use. (#402)
* Add DxilD3DCompile and DxilD3DCompile2 as examle of library use.
It will compile shader into library first, then link to generate the final dxil.
If there's include used, it will compile included file into seperate lib and link all lib together.
2017-07-05 17:37:40 -07:00
Jeff Noyle fa94808e09 Remove all discard instructions (#400)
* Add remove-discards pass

* explicit lfs

* Change pass name, remove copy-pasted member enum, reduced include set

* CR feedback: better way to delete instructions, stale comment, end iterator could go stale, CHECK-NOT is a good idea.
2017-06-30 13:57:12 -07:00
Xiang Li fe1e5ccc61 Add SkipStatic to rewriter. (#394) 2017-06-29 10:43:53 -07:00
Xiang Li 1188a80e63 Remove noise intrinsic. (#392) 2017-06-28 10:35:25 -07:00
Jeff Noyle e0c24c6839 Implementation of "constant color output" pass for PIX (#371) 2017-06-27 10:11:24 -07:00
Tex Riddell 36798cf0bc Fix typo in StoreOutput outputSigId parameter (#385) 2017-06-26 16:39:19 -07:00
Xiang Li be2910df32 Support include for IDxcRewriter (#384)
* Add RewriteNoFunctionBody to IDxcRewriter.

* Support include for rewriter.

* Add rewriter to dndxc.
2017-06-26 11:46:38 -07:00
Tex Riddell 73e3ea3e48 Interpret all elements as arbitrary for ViewID packing validation (#379)
- Differentiate inputs/outputs for return code
- Use original element id for easier debugging of ViewID packing
2017-06-23 15:21:51 -07:00
Xiang Li f408830296 Add linker. 2017-06-19 15:15:44 -07:00
Xiang Li 18c0c08032 1. Remove ResIndex from ResourceLinkInfo.
2. For none library profile, remove unused functions except entry and patchconstant function.
3. Fix issue caused by lost instanceCount for GS function props.
2017-06-19 15:15:44 -07:00
Xiang Li 3f0c4e5d30 Support multiple entries in one library.
1. Save signatures for each entry.
2. Lower signatures and strip parameters for each entry.
3. Don't save function props for patch constant function.
4. Erase value from vectorEltsMap once it is used in SROA_Parameter_HLSL::replaceCastArgument and SROA_Parameter_HLSL::replaceCastParameter.
5. Remove unused member of DxilGenerationPass.
6. Fix typo when clear semantic for cloned return annotation.
2017-06-19 15:15:42 -07:00
Xiang Li 79bb311bd9 Code cleanup.
1. Add Function props for entry.
2. Create DxilEntrySignature to group DxilSignature.
3. Move generation of loadinput/storeoutput into HLSignatureLower.
2017-06-19 15:15:38 -07:00
Xiang Li ebaab67a50 Add DxilFunctionProps to DxilModule. 2017-06-19 15:14:29 -07:00
Xiang Li 0a3981b54b 1. Support flatten function decl.
2. Clone shader entry to be called by other functions.
3. Skip ComputeViewIdState for library profile.
4. Change HLFunctionProps to DxilFunctionProps for DxilModule to use.
5. Don't add .flat to flattened function name.
2017-06-19 15:14:28 -07:00
Xiang Li c1bc9d945a Add resource link info for library profile. 2017-06-19 15:14:28 -07:00
Xiang Li 8e21407ca9 Add library profile. 2017-06-19 15:14:27 -07:00
Xiang Li fba18dd59c Add copy function for DxilSignature and DxilTypeSystem. (#359)
* Add copy function for DxilSignature and DxilTypeSystem.
Also make OP::RefreshCache() public.
2017-06-16 12:27:50 -07:00
Young Kim 2c568d00db Fix Multiple Component UAV Load Flag Check (#356)
This change is to fix the bug on fixing multi component UAV Load Flag Check by iterating over UAV resources in a DxilModule and check if a given resource is 1) either texture or typed buffer and 2) multi component resource. This change also changes shader flag collection stage after all necessary passes are complete from higher level DXIL to DXIL.
2017-06-14 17:23:55 -07:00
Xiang Li e380b8e915 Add dxcutil to share code. (#350) 2017-06-12 18:00:39 -07:00
Tex Riddell f1f8997e68 ViewIDPipelineValidation fixes (#339)
- update DxilPipelineStateValidation with MaxVertexCount
- Add option to ignore indexing constraint in DxilSignatureAllocator
- Fix issues with ViewIDPipelineValidation
- Detect ViewID dependent tessfactors
- Add mode for checking expanded merged input only
- Treat expanded Clip/Cull as Arbitrary
2017-06-08 16:01:44 -07:00
David Peixotto 0ea6620342 Add pass to preserve all outputs (#326)
This commit adds a new pass that will transform all the storeOutput
instructions in the program. For each element in the output
signature we create an alloca to hold writes to the output.
We rewrite each storeOutput to store to the alloca'd location
instead. Then at each function return point we store to
each element in the output signature by reading the latest
value from the alloca'd location.

The above transformation provides the following properties
for outputs after it is run.

    1. Remove all dynamic indexing on output writes
    2. Remove multiple writes to same output location
    3. Ensure all output locations in the signature are written
2017-05-30 09:41:54 -07:00
David Peixotto 2afe446dae Update helpers for working with precise (#333)
This commit updates the `IsPrecise` helper to also check for the fast math
flags on an instruction. Now, the function will return the correct value
for any instruction. Before it only worked for intrinsic calls.

We also added three helpers for working with fast math flags.
We provide getters and setters for precise fast math flags and
a helper to say if fast math flags are preserved through serialization
and deserialization.

Finally, we added a unit test for DxilModule that we can use to ensure
that the `IsPrecise` helper returns the correct value.
2017-05-26 12:08:13 -07:00
David Peixotto 99470ad061 Make precise helper function take const pointer (#329) 2017-05-23 13:09:04 -07:00
David Peixotto 489147d88c Add support for expanding trig intrinsics (#325)
We can now expand the following intrinsics:

    Acos
    Asin
    Atan
    Hcos
    Hsin
    Htan

The expansion uses the same approximation algorithms used by the d3d compiler.
2017-05-23 08:15:59 -07:00
David Peixotto 16a3f0a881 Add helper functions for working with precise (#323)
- Get/Set precise on in instruction in DxilMDHelper
    - Get precise based on instruction/global flags in DxilModule
2017-05-22 17:16:44 -07:00
David Peixotto ab643b8345 Add getters for all ShaderFlags properties (#322) 2017-05-22 11:18:00 -07:00
Tex Riddell ec827b29a0 Add bFinalStage to ViewIDPipelineValidation (#320)
- bFinalStage indicates a non-PS stage is the final one and validation should be performed on direct outputs, rather than waiting for the next stage to merge outputs with inputs.
- Extra validation for PSV
- Treat tessfactors as dynamically indexed to prevent breaking them up
2017-05-19 18:55:17 -07:00
Tex Riddell b4fa7bc4cc Convert DoBasicQueryInterface* functions to single variadic template (#304) 2017-05-19 18:52:52 -07:00
Tex Riddell da1ad75f27 Remove <memory> dependency from DxilPipelineStateValidation.h (#314) 2017-05-19 11:17:10 -07:00
Tex Riddell 0b5ab5c87a Implement ViewIDPipelineValidation
- Update PSV data for GS multi stream out and other improvements
- Add ViewIDPipelineValidation.inl
- Refactor DxilSigPoint to .inl for easy external use
- Add Barycentrics feature flag
2017-05-18 18:00:59 -07:00
Yuri Dotsenko ff86b6b211 Support ViewID state for GS multiple streams
New serialization/deserialization for ViewID state
2017-05-18 17:59:44 -07:00
yurido1 1397b9e000 ViewID tests and fix for constants in Phi nodes. (#310) 2017-05-18 10:12:00 -07:00
Tex Riddell 261c3f8819 Add NumOpCodes_Dxil_1_1 and ComputeViewIdState pass to hctdb (#300)
Note: changed viewid_state to viewid-state for consistency
2017-05-18 02:00:17 -07:00
Tex Riddell 5234d42be1 Merge fixes from os integration 486b3dc5abee (#306)
* Change to DxilProgramSigSemantic::Barycentrics for runtime alignment
* Integrate os change e4aba062897e
  - fix in Hashing.h for thread unsafe static
* Change to DxilProgramSigSemantic::Barycentrics for runtime alignment
* Disable ViewID Debug output and initialize ViewID feature flag
* Clean up some CMakeLists.txt lib changes
2017-05-17 18:13:44 -07:00
Tex Riddell 8419a9abce Complete move to DxilSignatureAllocator.inl 2017-05-16 21:33:30 -07:00
Tex Riddell 2bedc332fb Move DxilSignatureAllocator.cpp to include/dxc/HLSL as .inl 2017-05-16 21:31:38 -07:00
Tex Riddell c7212ee216 Refactor DxilSignatureAllocator to remove DxilSignature dependencies 2017-05-16 20:13:03 -07:00
Tex Riddell c2d2cef73f Merge pull request #295 from Microsoft/dxil-v1.1
Merge ViewID, PSV data, and validator updates
2017-05-16 13:38:41 -07:00
Xiang Li 6cca464f51 Remove copy be replace dst with src. (#296)
1. Generate memcpy in EmitHLSLFlatConversionAggregateCopy if type is match.
2. If value is used as Src of memcpy, mark load instead of store.
3. Do not do replace on GEP and bitcast.
4. Delete inst instead of push into DeadInsts when safe.
     This will prevent same inst added into DeadInsts more than once.
2017-05-16 12:37:40 -07:00
Tex Riddell c95244404a Copy ViewID state to PSV data and select PSV version based on validator (#291)
* Make validator version a first-class citizen of DxilModule

* Add validator version checks to DxilContainerAssembler
- eliminates need to check validator version in dxcompilerobj.cpp

* Copy dynamic index mask and ViewID state to PSV data
- Make const version of DxilViewIDState::GetSerialized() that just returns serialized state
2017-05-12 14:27:22 -07:00
yurido1 35f727ac33 Added support for functions without arguments. (#292) 2017-05-12 12:46:01 -07:00
Xiang Li 8ce48081cf Add a pass to eliminate dynamic indexing on output. (#287)
1. Add a pass to eliminate dynamic indexing on output.
2. Fix issue in AllocateSemanticIndex where argIdx should only udpate for leaf node.
2017-05-12 11:10:58 -07:00
Tex Riddell 5cb5131b32 Update PSV data structures with ViewID dependency data and Dxil Signatures (#289)
* Update PSV with ViewID data structures
* Update PSV with signature element data and gate PSV1 on SM 6.1
* Unwrap array on primitive when assigning semantic indexes
- fix semantic index assignment for matrix and primitives
- fix some tests
- disable two tests due to AssembleToContainer fail:
  ValidationTest::SigOutOfRangeFail
  ValidationTest::SimpleGs1Fail
2017-05-10 18:17:04 -07:00
yurido1 df132d59b4 Initial implementation of ViewId state analysis. (#290) 2017-05-10 18:14:43 -07:00
Young Kim f66e8083d6 Allow two SV_Barycentrics (#282)
unlike other system value semantics, pixel shader is allowed to declare at most two input attributes with SV_Barycentrics, with one declaration uses perspective interpolation type while other one uses noperspective interpolation type.
2017-05-09 18:59:30 -07:00
Marcelo Lopez Ruiz ad76d814a4 Debug name part implementation (#264)
* Add documentation with source-level debugging with HLSL and DXIL.
* Fix trailing underscore in generate .rst documentation.
* Add container support for debug name part.
* Bump validator version to 1.1.
* Implement debug stripping in dxc, including /Fd dir-named behavior.
* Implement IDxcCompiler2 and CompileWithDebug.
2017-05-09 18:32:48 -07:00
Xiang Li 9edb1a553e Lower static global resource and local resource to handle. (#276)
1. Add ResourceToHandle pass to lower resource to handle.
2. Don't performPromotion in SROA_HLSL.
3. Add Option support for DynamicIndexingVectorToArray.
4. Fix bug in GetPassOption.
5. Replace GEP ptr, 0 with ptr in DynamicIndexingVectorToArray::ReplaceStaticIndexingOnVector.
6. Run mem2reg before DxilGenerationPass.
7.Legalize EvalOperations before change vector to array.
2017-05-05 18:31:35 -07:00
Lei Zhang 2c7a3fc39d [spirv] Add bare bone code for SPIR-V codegen (#233)
* [spirv] Add libclangSPIRV and skeleton FrontendAction for SPIR-V

* [spirv] Add -spirv into dxc for invoking EmitSPIRVAction

* [spirv] Build SPIR-V codegen conditionally

Added ENABLE_SPIRV_CODEGEN in CMake config to control the
building of SPIR-V component and wrap up SPIR-V code using it.
Also add -spirv to hctbuild to turn it on.
2017-05-05 19:39:59 -03:00
Tex Riddell da5f98bb95 Updates to DxcValidator and DxcCompiler wrt. versioning/flags (#269)
Make DxcCreateInstance load validator from dxil.dll when available
Add DxcVersionInfoFlags_Internal flag to indicate internal validator
Add DxcValidatorFlags_ModuleOnly to indicate absense of full container for validation, requiring explicit use. This will not succeed when using dxil.dll validator.
Bump Validator version
Implement IDxcVersionInfo in DxcCompiler to indicate DXIL highest version supported and debug flag for compiler separately from validator
Refactor version detection code for tests, adding dxil and validator versions
Make SystemValueTest version aware
Add version check to AttributeAtVertex and SV_Barycentrics tests.
Fix line endings for HlslTestUtils.h
2017-05-04 22:18:57 -07:00
Young Kim 13cf7d466c Update barycentric with new spec (#265)
1. Adding SV_Barycentric and removing barycentric intrinsics/dxilops
2. GetAttributeAtVertex only thakes no_interpolation attribute
3. SV_Barycentric can take any interpolation modifier except nointerpolation
4. SV_Barycentric can only have float3 type
2017-05-03 17:07:02 -07:00
Tex Riddell c0d3163ee3 Dxil versioned OpCode/Class counts, and other dxil versioning fixes (#263) 2017-05-02 14:42:05 -07:00
Tex Riddell bd6c105e9b Add ViewID slot validation for PSIn (#254) 2017-05-01 17:54:33 -07:00
Tex Riddell a581927370 Add SV_ViewID support (#251)
- Add SV_ViewID loaded from intrinsic in Dxil,
  for input to all graphics shader stages
- hctdb: rename shader_models to shader_stages,
  add shader_model for min required shader model
- Validator: validate dxil version required for shader model
- DxilModule: Add GetDxilVersion
- Set Barycentric intrinsics to SM 6.1
- Update SystemValueTest for SM 6.1
2017-04-27 14:17:31 -07:00
Young Kim 108b897f40 Barycentric init (#250)
This change is the initial step to support Barycentric coordinates for shader model 6.1 / DXIL 1.1
 - Add GetBarycentrics, GetAttributeAtVertex intrinsics and their corresponding dxil ops
 - Lowering intrinsics to dxil ops
 - Adding codegen tests for these operations
2017-04-26 12:29:48 -07:00
Tex Riddell 23082dbef2 Add HLSL 2017 (-HV 2017) option. (#245)
- Fix detection of invalid options in dxcompilerobj
2017-04-24 16:05:06 -07:00
Xiang Li bc4a68b6b4 Use SRet for struct return type. (#243)
1. Use SRet for struct return type.
2. Add SM6.1 and DXIL1.1.
2017-04-24 14:34:57 -07:00
Xiang Li e14dc5ed1b Update matrix code gen. (#234)
1. Keep major for matrix pointers.
2. Change matrix values to row major to match hlsl.
   Only ColMatLoad, RowMatrixToColMatrix and col matrix value parameter for entry function are col major matrix value.
   And should only used by ColMatStore and ColMatrixToRowMatrix.
2017-04-21 11:56:37 -07:00
Xiang Li 4c22ec7802 Prepare to support handle as parameter. (#231)
1. Add resource attribute to FieldAnnotation.
2. Find resource arribute from Argument in FindCreateHandleResourceBase.
3. Remove limitation handle must be instruction.
4. Add HandleToResCast to help lower resource parameter to handle parameter.
2017-04-19 11:33:33 -07:00
Young Kim c50dd745d2 Add partial derivative test cases for pixel shaders (#220)
This change is to add another execution test case for partial derivative operations specific to pixel shaders.
The way we did this is by passing in the texture resource to the shader and taking the partial derivatives of these texture values.
Test is assuming the arithmetic precision of 1 ulp for derivative operations.

This change also has some changes on existing execution test
 - enable passing in Texture2D resource type as a default heap
 - reading primitive topology from XML file
 - clean up data driven tests: use DirectX Math structures and removing unused structures
2017-04-18 06:45:14 -07:00
Lei Zhang c9f8438d90 Remove unnecessary const qualifier on return type (#221)
This solves compiler warnings given by -Wignored-qualifiers.
2017-04-13 14:41:08 -07:00
David Peixotto 76a4288913 Support lowering extensions directly to dxil (#217)
This commit adds the 'dxil' strategy for lowering extensions. This
strategy will change the extension call into a call to a dxil intrinsic.
This is useful for targeting dxil intrinsics that are not exposed in hlsl.
2017-04-13 10:19:00 -07:00
Lei Zhang 7008b2ad52 Add default virtual destructors for virtual classes (#218)
This fixes compiler warnings generated by -Wnon-virtual-dtor.
2017-04-12 14:21:01 -07:00
Lei Zhang 8c6ba6716b Upgrade SAL annotations in some source files (#197) 2017-04-12 12:39:41 -07:00
Young Kim e5265cc7ee Adding Execution Tests for ShaderOp Arithmetic operations (#207)
This change is to add execution tests for individual DXIL arithmetic operations.

Using TAEF's data-driven model to group operations by the type/number of operands for each instructions. (unary/binary operators for float/int/uint types)
Updating DXIL.rst for these instructions.
Update hctdb.py to enable internal links for DXIL instructions.
2017-04-12 00:14:00 -07:00
Lei Zhang 26d48613ba No need to qualify methods with class name in class body (#198) 2017-04-11 09:03:46 -07:00
Lei Zhang 892e7953fd Match filename cases (#199) 2017-04-10 22:52:10 -07:00
Lei Zhang 900f072920 Fix missing $ before CMAKE_CURRENT_SOURCE_DIR (#192)
Thanks for the fix!
2017-04-07 13:56:56 -07:00
Marcelo Lopez Ruiz 254f253b14 Move unused global tracing flags into single usage, closes #157. (#185)
* Move unused global tracing flags into single usage, closes #157.

Normalizes API-provided names to include at least a current-relative
directory, simplifying file lookups. There are still restrictions on
how expressive include handlers enable the virtual file system to be,
these should be documented on the project wiki.

Handle some errors in BeginSourceFile paths where include handlers may
cause early errors, before compilation execution can begin.

Removes the prior scheme for directory handles, where the same handle
would be returned for any parent directory.

Future improvements would be to expand dxc paths before calling into
dxcompiler, and/or to fully implement OS API calls from console apps.

Improve hcttest to describe build config better and not override env var.
2017-04-07 12:02:20 -07:00
David Peixotto b0fd2d3949 Use opcode class to guide constant folding possibilities (#191)
This change modifies dxil constant folding to use the opcode class when
deciding if a dxil function can be constant folded. We now require a
DxilModule to be available when constant folding dxil functions.

To ensure that the dxil module is available we add a new pass that loads a
dxil module from metadata if it does not exist. We use the new pass in the
dxopt tests for constant folding.
2017-04-06 17:42:42 -07:00
David Peixotto deec58372a Ensure the cached Function->OpCodeClass map is updated (#186)
* Ensure the cached Function->OpCodeClass map is updated

The original goal of this change was to use opcode class for deciding when we
can perform constant folding on a function.

We maintain a mapping from Function* to OpCodeClass inside the OP class.
We wanted to use this map in constant folding to decide if we can constant
fold a function to avoid string comparison on the function names.

However, it turns out that the DxilModule is not always available during
constant folding of dxil calls so we cannot use the map inside of OP. The
change contains a few bug fixes and improvements that came out of trying
to get opcode class working inside constant folding.

  1. Use opcode class in dxil constant folding where possible.
  2. Make sure the opcode cache is refreshed properly.
  3. Remove 64-bit test for bfi.
  4. Add equality comparison for the ShaderModel class.

When switching to use the opcode class for constant folding, we discovered
that our test for 64-bit bfi is invalid. There is no 64-bit overload for
bfi in dxil, so the test we had written was not legal dxil. This change
removes the 64-bit test for bfi constant prop.
2017-04-06 13:48:27 -07:00
Xiang Li 73e76ff294 Use mad for matrix mul. (#184) 2017-04-05 10:39:56 -07:00
Marcelo Lopez Ruiz a528d7bd86 Remove use of dynamic_cast, use dyn_cast instead. (#183)
Remove use of dynamic_cast, use dyn_cast instead.
2017-04-05 02:28:20 +01:00
David Peixotto ae69cf0a58 Add constant folding for dxil intrinsics (#179)
This commit adds the ability to constant fold dxil intrinsics when
all inputs are constant. We reuse the llvm constant folding
infrastructure and add special cases for calls to dxil intrinsics.
2017-04-04 09:15:19 -07:00
Xiang Li 2b4f3e4801 Support resource inside cbuffer. (#175) 2017-03-30 12:06:21 -07:00
Xiang Li a3306bff1d Lower resource to createHandle at clang code gen. (#163)
* Lower resource to createHandle at clang code gen.
1. A HL createHandle will have 1 or 2 parameters.
   For  uav/srv/sampler, 1 parameter. 1 is the resource load from resource ptr.
   For cbuffer, 2 parameter. 1 is the same. 2 is for dynamic indexing on array of cbuffers.
   uav/srv/sampler don't have 2 is because all the use of them is on builtin methods. Resource on methods is scalar.
   createHandle function will have metadata to save the resource information like class/kind/type/...

2. Added 2 more passes DxilLegalizeResourceUsePass DxilLegalizeStaticResourceUsePass to remove load/store on local/static resource.
   Also make sure HL createHandle don't have phi operand.

3. For DxilGenerationPass,  Dxil createHandle will be generated after GenerateDxilOperations.
   And HLObjectOperationLowerHelper now get RK/RC from MetadataAsValue argument of HL createHandle.
2017-03-28 18:43:59 -07:00
Marcelo Lopez Ruiz f9401736a6 Fix memory leaks and improve build (#156)
* Remove clang header generation from the build

These headers aren't used by the compiler nor by HLSL program.

* Remove references to clang-headers and redundant discard test.

* Fix a few leaks to make tests pass with AppVerifier.
2017-03-27 20:59:05 +01:00
David Peixotto db78f0400a Translate extension name when no replication is needed (#127)
Previously, If an extension uses the replication lowering strategy
and a non-vector overload was chosen we would return the function
un-modified. This change makes sure that we still use the
custom lowering name for the extension if one was specified.
2017-03-13 13:36:45 -07:00
David Peixotto 67685d9660 Expand macros in root signature and semantic defines (#122)
This commit adds a standalone class for expanding macros and uses it
to for root signature and semantic define processing. Previously,
we were using the raw macro value instead of the expanded value
so something like:

    #define MYRS "DescriptorTable(SRV(t0))"
    #define RS   MYRS

would fail to compile the root signature with an entry point of
RS because it would get a root signature value of MYRS instead
of the expanded value. Similarly, for semantic defines we were
saving the non-expanded value into the bitcode.

This commit also adds a new flag that is used to specify that
the root signature should be read from a #define. So compiling
with `-rootsig-define RS` will read the root signature from
a `#define RS ...` in the source. The -roosig-define flag
takes precedence over a root signature annotation in the souce.
2017-03-07 11:34:23 -08:00
Xiang Li 38586597b9 Support -T rootsig_1_0/rootsig_1_1. (#112) 2017-03-01 17:00:45 -08:00
Xiang Li 843b64b320 Check exist function match dxil operation function when refresh operation fucntion cache. (#108) 2017-02-27 16:32:41 -08:00
Xiang Li 19952dbf73 Avoid iterate on map which use point as key to make sure output is the same. (#104) 2017-02-24 10:10:32 -08:00
Xiang Li 73b6f95a40 Legalize sample offset when optimization is disabled. (#97) 2017-02-18 00:46:17 -08:00
Tex Riddell 51898662c9 Close #75 - Pack prefix-stable by default (#90)
* Implement prefix-stable packing and make this the default.
* Add signature packing options -pack_prefix_stable and -pack_optimized.
2017-02-14 18:22:54 -08:00
yurido1 459fa804b8 Fix includes for no-STL version. (#12) 2017-02-08 13:24:30 -08:00
Xiang Li cb0ba446c1 Fix validation bugs. (#10) 2017-02-07 22:18:10 -08:00
Young Kim b238ed36c3 Dxc fix verifyrootsignature option (#6)
* Dxc fix verifyrootsignature option

- distinguish stream type (stdout, stderr) when printing to console
- verifyrootsignature option returns correct errorlevel depending on its result
- adding more test cases to hcttest for verifyrootsignature option
- enable verifyrootsignature option when dxil.dll not present

* Fixes from review

- Change parameters for writing to consoles from File* to DWORD
- Change comment when dxil.dll does not exist
2017-02-07 17:02:14 -08:00
Tex Riddell f6d4581fc6 Merge branch 'integration' into val 2017-02-07 13:03:53 -08:00
Tex Riddell 74049c5852 Integrate: Fix to CATCH_CPP_ASSIGN_HRESULT and validation of named metadata 2017-02-07 13:02:37 -08:00
Young Kim 3a24e158ef Fixing Dxc Options (#4)
* Clean up dxc options:

setrootsignature, setprivate :
 Allow replacing existing rootsignature or private data and make a new container with new parts
(e.g dxc /dumpbin private.dxil /setprivate private.data /Fo private.new.dxil)

extractrootsignature:
Make it back compatible with fxc by returning dxil container with RTS0 part only and having the user to provide /Fo option.

Other Options:
For unimplemented options that was from fxc, ignore those options and proceed given operation.
For unimplemented options that was not from fxc, remove them for now.
Add more test cases for dxc command line operations.
Fix ISenseOption flag to have valid HLSL version check for dxc (disable 2015)

* Fix Preprocess option for dxc
Fix hcttestcmd for testing invalid rootsignature
2017-02-03 15:49:45 -08:00
Tex Riddell 9fe61f42a2 Remove old kDxilRootSignatureTag. 2017-02-03 14:45:19 -08:00
Tex Riddell 0647154af0 Move Signature metadata to named node and some other cleanup. 2017-02-03 14:28:21 -08:00
Tex Riddell 2444ae3b10 Add DxcValidatorFlags_RootSignatureOnly. 2017-02-03 12:28:57 -08:00
Tex Riddell 7c2c2c5d54 More RootSignature validation fixes.
- Implement RootSignatureHandle::Deserialize()
- Fix/clean up validation usage
2017-02-03 00:08:08 -08:00
Tex Riddell 7beaa7ba54 Implement DXIL Container validation
- Implement and centralize container validation components in DxilValidation
- Strip RootSignature from module metadata before serializing to container
- Use existing DxilModule when serializing rather than constructing new one
- Add DxilModule::TryGetDxilModule for capturing diagnostics on metadata load
- Expose DxilPartWriters/DxilContainerWriter for use elsewhere (such as in validation)
2017-02-02 19:59:13 -08:00
Yuri Dotsenko 67af2429a4 Partially ported RootSignatureVerifier::VerifyShader and VerifyRootSignatureWithShaderPSV 2017-02-02 16:08:35 -08:00
Yuri Dotsenko 66ba69688e Adding root signature deserialization 2017-02-01 20:09:19 -08:00
Tex Riddell c18ed9133e Merge remote-tracking branch 'ms/dxil-v1.0' into integration 2017-02-01 15:43:43 -08:00
Tex Riddell 797548781c Integrate final opcode changes for DXIL v1.0
- Removes IAddc and ISubc
- Renames USubc to USubb
- Compacts opcodes
2017-02-01 15:22:29 -08:00
Young Kim 5a916c56d9 Adding options for dxc
- Update command line options of dxc
    (Qstrip_debug, Qstrip_priv, Qstrip_rootsignature, setrootsignature, getprivate, setprivate)
  - Add IDxcContainerBuilder API and its implementation
  - Resolve lifetime of dxil.dll on dxcompiler.dll to guarantee access of memory generated from dxil.dll
2017-01-31 17:56:38 -08:00
Xiang Li cf6f8beb4b Check Race Condition for TGSM (#48) 2017-01-30 16:09:31 -08:00
Xiang Li ac228c5aa4 Translate AddUint64. (#47) 2017-01-30 12:30:25 -08:00
Tex Riddell 3bcc42ff10 Merge branch 'master' into dxil-v1.0 2017-01-27 17:18:24 -08:00
Tex Riddell af6b2a552f fixes #37 - License cleanup. 2017-01-27 16:48:08 -08:00
Xiang Li 86b7e6ef9d Struct for normal buf (#43)
* Support sturct in none-struct buffer.

* More tests for sturct in none-struct buffer.

* Simplify the test and use them.
2017-01-27 14:42:35 -08:00
Xiang Li 664c0b6436 Change bool to i32 instead of i8. (#28) 2017-01-23 17:54:09 -08:00
David Peixotto 0f3789fb0d Support extension intrinsics on resources (#24)
This commit adds support for extension intrinsics that work as
methods on resources. For example, we could have an extension
on buffers called `MyBufferOp`

    Buffer<float2> buf;
    float2 val = buf.MyBufferOp(int2(1, 2))

To support extension methods we add a new resource lowering strategy
that does three transformations to the intrinsic call

1. Expand vectors in place in the call arguments.
2. Convert non-void return value to dx.types.ResRet.
3. Convert resource parameter to dx.types.Handle value.

For example, assuming that MyBufferOp has opcode 138. The resource
lowering strategy would convert the call as HL-dxil to dxil as
follows

    call <2 x float> MyBufferOp(i32 138, %class.Buffer %3, <2 x i32> <1 , 2> )
    ==>
    call %dx.types.ResRet.f32 MyBufferOp(i32 138, %dx.types.Handle %buf, i32 1, i32 2 )
2017-01-23 17:54:02 -08:00
Tex Riddell 220f78a557 Merge 'master' into dxil-v1.0 2017-01-20 14:11:27 -08:00
Xiang Li 5623234187 Strip function parameter for entry and patch constant function. (#20)
Strip function parameter for entry and patch constant function

* Update error message for ValidationTest::MultiDimArray

* Merge remote-tracking branch 'origin/master'

# Conflicts:
#	lib/HLSL/DxilValidation.cpp
#	tools/clang/unittests/HLSL/ValidationTest.cpp

* Update error message for ValidationTest::MultiDimArray

Update error message for ValidationTest::MultiDimArray

* Fix merge error. (#3)

* Delete local file (#4)

* Fix merge error.

* Delete local file

* Strip function parameter for entry and patch constant function. (#5)
2017-01-19 19:00:17 -08:00
Young Kim 43aebafa62 Add functions for DxilContainer (#19)
- Add function to get dxilpart by type
- Add function to get ProgramHeader given a DxilContainer
- Add unit test for functions in dxilcontainer.cpp
2017-01-19 18:10:37 -08:00
Tex Riddell 4b532ceff9 Merge branch 'master' into integration 2017-01-18 19:43:07 -08:00
Tex Riddell 69d8d3209b Integrate change to DXIL Version 1.0 2017-01-18 19:18:55 -08:00
Tex Riddell 55ba393c2c Signature packing, codegen fixes, and validation fixes and additions.
- Add DxilSignatureAllocator for signature packing
  - Fix signature validation.  Add more validation.
  - Fix and add validation tests.
  - Fix codegen for inout params with SV like SV_Coverage
  - fix m_SemanticStartIndex on DxilSignatureElement::Initialize
  - fix DxilSignatureElement::GetColsAsMask for start col == 2
  - Add diags for signature allocation failures
  - Use Regex in ValidationTest
2017-01-17 18:10:16 -08:00
David Peixotto 9451f2c0b3 Add initial support for extension intrinsics and defines (#5)
This commit adds initial support for extension intrinsics and defines, including:

-Support for recognizing hlsl extensions as new intrinsic functions.
-Support for requesting lowering of extensions.
-Support for preserving semantic defines.
-Support for validating semantic defines.

This commit adds support for hlsl extensions in the form of additional
intrisic functions and semantic defines.

We now allow a dxcompiler instance to register that it can handle
additional intrinsic functions beyond the standard hlsl intrinsics. These
new intrinsics are called extensions.  For each extension, the compiler
supplies a lowering strategy that is used by the dxcompiler to translate
from the source level intrinsic to a high-level dxil intrinsic.

We initially support the two lowering strategies: replicate and pack.
The replicate strategy will scalarize the vector elements in the call
and replicate the function call once for each element in the vector.
The pack strategy changes the vector arguments into literal struct
arguments.

We also now include support for "semantic defines". A semantic define is
a source level define whose value is preserved in the final dxil as
metatdata. The source level define can come as either a #define in
the hlsl source or a /D define from the command line.

We provide a hook to validate that a semantic define has a legal value
(for example to ensure that the value is an integer). Validation failures
can produce warnings and errors that will be emitted through the standard
clang diagnostic mechanism.

This code was originally written by marcelolr and modified by dmpots to
support packed lowering of intriniscs and validation of semantic defines.
2017-01-17 17:51:13 -08:00
Xiang Li ee0e81b047 Disable multi-dim array type and function call. (#12) 2017-01-17 13:30:42 -08:00
Xiang Li 96c0eb50ef Cleanup more Validation TODOs. 2017-01-12 17:59:37 -08:00
Xiang Li 03149de76f Cleanup more validation TODOs. 2017-01-11 10:42:48 -08:00
Xiang Li 8eb801f1fd Clean more validation TODOs. 2017-01-10 16:24:10 -08:00
Xiang Li 245a771a85 1. Clean more validation TODOs.
2. Support array of SV_Target.
2017-01-10 11:44:48 -08:00
Xiang Li 28b3ffe821 Clean more validation TODOs. 2017-01-04 13:29:28 -08:00
Marcelo Lopez Ruiz 6ee4074a4b first commit 2016-12-28 11:52:27 -08:00