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

429 Коммитов

Автор SHA1 Сообщение Дата
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
Marcelo Lopez Ruiz 60a67e6563 Fix unused var warning in release, better logging for command line tests. (#479) 2017-07-27 14:22:16 -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
Jeff Noyle d77cde2f60 Remove checks for "discard", since early-z actually works with discard! (Or rather, is well-defined with discard.) (#480) 2017-07-27 13:10:44 -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 516a70ad4c Allow nested struct in UAV. (#472) 2017-07-26 17:17:36 -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
Xiang Li 4723496f3e Not replace struct parameter to function call arg. (#466) 2017-07-25 20:42:55 -07:00
Xiang Li 87ded7ab24 Run mem2reg when linking. (#465) 2017-07-25 19:47:26 -07:00
Xiang Li 71774913f6 Minor bug fixes. (#463)
1. Support in out as inout.
2. Support function call on extern functions which don't need to flatten.
2017-07-25 17:47:04 -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
Xiang Li 9db715523f Fix arg flatten issue caused by load before init. (#447)
* Fix arg flatten issue caused by load before init.
* Refine ShaderCompatSuite.
* Remove HLFunctions has body early.
2017-07-24 18:31:45 -07:00
Xiang Li 57b583d1b1 Set resource ID in DxilLinkJob::AddResourceToDM. (#442) 2017-07-20 12:27:28 -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 faaf47daa5 Mark noalias for out parameters. (#438) 2017-07-19 11:46:56 -07:00
Lei Zhang 4ff631148d Various small code tweaks (#398) 2017-07-16 18:28:35 -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
Xiang Li 94acf99408 Support case struct parameter used as function call argument. (#429)
* Support case struct parameter used as function call argument.
Also skip input param copy.
2017-07-14 13:13:25 -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
Young Kim b952971989 Fix Typed UAV Load flag collection (#418) 2017-07-12 11:17:14 -07:00
Tex Riddell 11dd70c410 Add limited support for unbounded resource arrays in parameter list (#399)
- Fix IsHLSLResouceType typo
2017-07-11 13:07:07 -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
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
Young Kim 7f65e0f0d6 Clean up crlf and mixed line ending issues. (#391) 2017-06-29 16:26:20 -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
Young Kim 7f82a9e98c Check multi component uav on load not store operations. (#372)
Check multi component uav on load not store operations.
2017-06-22 11:54:52 -07:00
Xiang Li 25a864b578 Update doc for lib_6_1 profile.
Also fix build error caused by lost arg for DXASSERT_LOCALVAR.
2017-06-19 15:40:23 -07:00
Marcelo Lopez Ruiz e9235255b8 Fix debug flags for non-debug VS builds (#364)
The DBG define was set even for release builds.
2017-06-19 15:15:44 -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 5977eece4c Clear maps for cast before createFlattenedFunction and createFlattenedFunctionCall. 2017-06-19 15:15:43 -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 b6e876bf39 Don't change function linkage for library profile. 2017-06-19 15:14:27 -07:00
Xiang Li 8e21407ca9 Add library profile. 2017-06-19 15:14:27 -07:00
Marcelo Lopez Ruiz 8ad339c806 Fix unused variable warning in release builds. (#365) 2017-06-17 20:27:53 -07:00
Marcelo Lopez Ruiz 23f9b82096 Fix debug flags for non-debug VS builds (#364)
The DBG define was set even for release builds.
2017-06-16 19:48:13 -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
Marcelo Lopez Ruiz 667e9fecbb restore compatibility with dxil.dll 1.0 validator for typed uav loads (#363)
Add an optional extended description…
2017-06-16 00:00:42 -07:00
Xiang Li 5d16c9a661 Enable patch for validation 1.1. (#362) 2017-06-15 22:25:49 -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
Xiang Li 33f42b8bd9 Fix atomic offset for case element type of structure buffer is not structure type. (#349) 2017-06-10 13:28:32 -07:00
Tex Riddell edb9905e69 Merge integration fixes (#344)
- Fixed potential null pointer access
- make existence of external directory optional
- add DxilContainerAssembler change missing from ViewID Validation changes
- fix in ShaderOpTest.h for other build tools.
2017-06-08 18:26:21 -07:00
Xiang Li 9c8aca547a Expand tan to sin/cos in DxilExpandTrigIntrinsics. (#343) 2017-06-07 18:36:00 -07:00
Xiang Li 6c4b87efd9 Create pass for Lower static global into allocas. (#341) 2017-06-07 17:14:43 -07:00
Xiang Li 338da2aab4 Support memcpy to self. (#337) 2017-05-30 13:27: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
Xiang Li 29bc498300 Remove metadata for Validation_1_0. (#330) 2017-05-23 17:06:31 -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
Tex Riddell b4fa7bc4cc Convert DoBasicQueryInterface* functions to single variadic template (#304) 2017-05-19 18:52:52 -07:00
yurido1 2882dfac11 More ViewID tests. Support LoadInput in DS. (#316)
Closes #318.
2017-05-19 16:43:58 -07:00
Tex Riddell 3e446c89d7 Merge pull request #312 from tex3d/psv-work
Update ViewID for multiple streams and implement ViewID pipeline validation
2017-05-18 18:47:57 -07:00
Xiang Li 9ff112ceda Code cleanup. (#311)
1. Don't require entry function for flattenGlobal.
2. Don't check bForParam for flattenArgument.
3. Don't clone and remove return when replace return value with alloca.
2017-05-18 18:38:35 -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 877bc18366 DxilValidation accept more legal component types in signatures (#305)
- Fixes SV_Position must be float4 #89
- Needs additional testing and comparison of flexibility with fxc.
2017-05-17 14:35:45 -07:00
Xiang Li e5ef77995c Lower static global into allocas. (#299) 2017-05-17 10:45:48 -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
yurido1 ea746d6c3c Fixed unordered_set union logic. (#297) 2017-05-12 16:51:51 -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
Young Kim 47d21ad6c0 Fix EvalauteAttribute Intrinsics (#275)
Currently the compiler crashes when we pass in matrix or vectors with reduced dimension from the original signature element for EvalAttribute functions. This change resolves this issue by replacing allocas before we translate these function calls from DXIR to DXIL and find LoadInputs to replace correctly.
2017-05-05 15:10:46 -07: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
Xiang Li 7179f13400 Do not create phi on non-default address space. (#273) 2017-05-04 16:25:44 -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
Xiang Li d108a552de Refactoring DynamicIndexingVectorToArray to share code with MultiDimArrayToOneDimArray. (#259) 2017-05-01 11:15:32 -07:00
Xiang Li 9f437adda5 Lower memcpy before SORA a pointer. (#253)
1. Try to propagate if the pointer is only write once by the memcpy.
2. Use correct size for memcpy created in AppendBuffer::Append.
3. Ignore unused Constant user of Matrix value.
4. Replace Constant with Inst on the Instruction version of Constant.
5. When match size of memcpy, go deeper if struct only has 1 element.
   Doing this will leave memcpy be lowered at deeper level.
6. Do not replace when SimplePtrCopy, cannot decide replace is safe or not.
2017-04-28 14:42:04 -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
Xiang Li aec310b4ea Use memcpy to copy when possible in clang code gen to avoid flatten too early. (#247) 2017-04-25 13:37:06 -07:00
Xiang Li 478a433366 Disable CSE, leave it to target backend. (#246) 2017-04-24 19:19:22 -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 6bc247d4af Lower parameter (#242)
* Lower vector/matrix/resource/multi-dim array parameters to  scalars/array/handle/one-dim array.

* Code cleanup.
2017-04-21 17:47:26 -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
Xiang Li 3911371309 Fix dbg info for temp variable. (#230)
1. Remove debug info when strip function parameter from entry function.
2. Set OptLevel to 0 for -Od.
3. If optimization is disabled, always load ReturnValue.
2017-04-18 13:49:59 -07:00
Marcelo Lopez Ruiz b3eb288629 Add opt support for naming module prints and to diff them in dndxc. (#228) 2017-04-16 22:01:30 -07:00
David Peixotto 449165a52d Run constant array hoisting pass by default (#224) 2017-04-13 17:56:28 -07:00
David Peixotto 022eb5717f Add hooks for constant folding extensions (#209)
This commit adds placeholder hooks to support constant folding of
extensions.  They are defined in a separate file to make it easy to merge
changes or link in other versions. There should be no upstream changes to
these definitions.
2017-04-13 15:04: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 806fbb2bbf Fix initialization order of various class members (#211)
This solves compiler warnings given -Wreorder.
2017-04-12 13:34:28 -07:00
Lei Zhang 8c6ba6716b Upgrade SAL annotations in some source files (#197) 2017-04-12 12:39:41 -07:00
David Peixotto 0ba250e9dc Add pass to hoist constant arrays (#205)
This commit adds a new pass to hoist arrays from local to global scope
when the array only contains constant values. A local array will use
alloca and stores for initialization, but a global array uses a global
variable with a constant initializer.

The idea is that a global array with constant initializer will allow the
backend compilers to produce better code because it is much easier to see
that the array is fully constant.
2017-04-11 13:58:16 -07:00
Lei Zhang 026176362f Use typename to mark subtypes in templated class (#200) 2017-04-11 09:26:39 -07:00
Lei Zhang 8afb120125 Use llvm::make_unique instead of std::make_unique (#201)
std::make_unique is a C++14 feature.
2017-04-11 09:15:34 -07:00
Lei Zhang 892e7953fd Match filename cases (#199) 2017-04-10 22:52:10 -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
Xiang Li bd16165aa7 Keep unused pointer in TranslateHLSubscript, it will be removed in TranslateSubscriptOperation. (#188) 2017-04-06 13:56:09 -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 9e8137c54d Use high level intrinsic when lower matrix mul to make sure DXIL operation only exist when DxilModule is ready. (#189) 2017-04-06 12:36:28 -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
David Peixotto 84c30e388d Make hctdb output stable (#172) 2017-03-30 18:38:48 -07:00
Xiang Li c7db25781e Report error on invalid input/ouput type. (#176) 2017-03-30 14:12:36 -07:00
Xiang Li 2b4f3e4801 Support resource inside cbuffer. (#175) 2017-03-30 12:06:21 -07:00
Xiang Li 238c2221e2 Cast i32 col idx into i8. (#170) 2017-03-29 16:53:39 -07:00
David Peixotto 13f92a77c4 Fix #169 - Bad codegen for firstbithigh/firstbitlow (#171)
This patch changes codegen for firstbithigh and firstbitlow.

For firstbitlow we do not generate a select on the return value from the
intrinsic. The previous codegen would check if the value is 0 and return -1 if
it was. However, the FirstbitLo intrinsic will return -1 when the input is 0 so
the select is not needed. So regardless of the input value we can take the
result of the intrinsic. This would match the code produced by fxc.

For firstbithi we check the value returned from the intrinsic for -1. If
the value returned is -1 we return -1. We do this for both signed and
unsigned intrinsics. The old codegen would check the input value for
0 and so would produce wrong code when the input value was -1.

We also disable constant folding in the front end for these intrinsics.
There was a bug in the constant folding that would cause a crash and
we are adding constant folding for dxil intrinsics to the optimizer
so we should not need it explicitly in the frontend for these
intrinsics.
2017-03-29 12:38:07 -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
Xiang Li 9afb4cfcb8 Don't change bitcast (gep a, 0, 0) into bicast a for validation. (#164) 2017-03-28 17:27:31 -07:00
Tim Foley 7aa3fbd04b Generate fxc-compatible reflection type info for buffer members (#146)
* Add support for reflection on types of constant-buffer members.

This change performs a best-effort translation from the LLVM types and their DXIL annotations over to the representation exported by the current `ID3D12ShaderReflectionType` interface.

- Added missing implementation of `CShaderReflectionType` members that implement `ID3D12ShaderReflectionType`

- Added a new `CShaderReflectionType::Initialize()` that intializates the instance data from an `llvm::Type*` and its `DxilFieldAnnotation`
  - The main complexity here is a helper routine to extract the appropriate `D3D_SHADER_VARIABLE_TYPE` from an `llvm::StructType*`. The current code copies the logic used in `HLModule::IsHLSLObjectType()`; that bit of copy-paste programming may need to be refactored away.

- Call into the new logic where there had been a `TODO: create reflection type` comment before

- Know issues:
  - Leaks the `CShaderReflectionType` instances. It is probably best to just store the type of a variable directly in the `CShaderReflectionVariable`, but the existing declarations had an unowned pointer, so I expect a tiny bit of discussion is warranted about the right way to proceed.
  - Related: I did not implement the type equality test (`ID3D12ShaderReflectionType::IsEqual()`), because I don't expect it is needed by most users, and it adds complexity. A trivial implementation might store and then compare the underlying `llvm::Type` pointers, but it isn't clear to me whether the type-equality test here is supposed to consider additional properites like offsets for `struct` fields.

Fixes issue #134

* Address small-scope review feedback.

Thanks to @marcelolr for the comments. This change tries to address the simpler style/convention issues. The memory ownership fix will come next.

* Update DXBC reflection comparison tests to comapre type reflection data.

This is a small change. I added a `CompareType()` method to `DxilContainerTest` that can compare the fields of two `ID3D12ShaderReflectionType*`, and then invoked aht routine when comparing the members of reflection contstant buffers.

The comparison applies to all the simple data fields, but does *not* test:

- Anything related to inheritance, interfaces, sub-types, etc.
- Type equality tests (they aren't being implemented right now, and I don't know if most clients of the reflection API care about them)

* Fix computation of names for fxc-compatible reflection types.

Previously I'd used the name from the DXIL *field* annotation, which obviously isn't correct.
For now I just compute type names in a relatively ad hoc fashion, using the information I glean as I destructure the type.
I also don't try to be efficient, and just use `std::string` operations to concatenate on suffixes for matrices/vectors.

Not yet handled here:

- Arrays (do they get suffixed in DXBC reflection data?)
- Object types
- Any demangling required for user-defined `struct` types (is there any?)

* More fixes to fxc-compatible reflection for types.

- A matrix may show up as an LLVM array type, so we need to be careful when unwrapping outer array types to *not* count a matrix as an array.
- Be a little more overt about handling array layouts: include a note that the `Undefined` layout is being treated as column-major (the default).
- Correct name for `uint` type in reflection (apparently it reflects as `dword`)
- Remove any `struct.` prefix from user-define `struct` type names
- Apparently `struct` types are "scalar enough" that they get `Rows` and `Columns` set to 1. Need to double-check whether this should just apply to *all* non-matrix/vector types.
- Store field types with an indirection, so that type name (stored in a `std::string`) doesn't get copied/moved and thus invalidate the pointer we store in `m_Desc.Name`
- Special-case `void` so that it can have a correct name (not sure if this will matter in practice)

* Create fxc-compatible reflection types for `StructuredBuffer` element type

- This was another case where a shader reflection type was just being left `NULL`; it just didn't have a handy `TODO` comment calling it out. :)

* More fixes for fxc-compatible type reflection.

- Reflect scalar `uint` type name as `"dword"`, but not for vector/matrix (e.g., still use `"uint3"`)

- Supress checking of the `Offset` field in type reflection for element type of a structured buffer
  - Note: looking at the existing compiler output for structured buffers, there seems to be an existing (hopefully known) issue that the field offsets for `StructuredBuffer` elements don't match fxc

- Strip of prefixes from user-defined `struct` type names: `"struct."` and `"dx.alignment.legacy."`

- Try to emulate fxc behavior for computing the `Columns` field for reflection on a `struct` type
  - The behavior here doesn't seem to be documented on MSDN (it implies that `Columns` would be zero for a `struct` type)
  - From what I can tell, the desired value is something like "total number of scalar values (not counting objects) recursively contained in this `struct` type"

With these changes, the revamped `DxilContainerTest::ReflectionMatchesDXBC_`{`Checkin`,`Full`} tests pass.

* Implement memory management for fxc-compatible reflection types.

In previous changes the `CShaderReflectionType` instances were allowed to leak.
This change still heap allocates the types, but places `std::unique_ptr`s to them all into a field in the base shader reflection object.

The reason for storing the types together in one master list (rather than having, e.g., a `CShaderReflectionVariable` directly store a `unique_ptr` to its type) is to allow for the possibility of re-using identical types in cases where that is possible (e.g., two `cbuffer` fields that use the same `struct` type should be able to share the `CShaderReflectionType` instances for their nested fields).
2017-03-28 00:25:37 +01:00
Marcelo Lopez Ruiz 843be2528a Close #62: strange error output on recursive function calls (#150)
* Traverse call graph to report recursive calls in the front-end.
* Emit function declarations only as needed.
* Fix extra echo output in hctbuild help.
* Remove unused test case.
2017-03-28 00:12:55 +01: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
Xiang Li df5f52024b Make scalar static global matrix to col major. (#154) 2017-03-23 16:53:42 -07:00
Xiang Li 094dfa1746 Save imm initializer when possible. (#145)
* Save imm initializer when possible.
* Remove UpdateHLSLIncompleteArrayType which already done in SemaInit.
* Take care parent record in AddMissingCastOpsInInitList and HLSLExternalSource::GetNumBasicElements.
* Support nest init list in CaculateInitListArraySizeForHLSL.
2017-03-20 11:19:22 -07:00
Xiang Li 29a09802e3 Support array of struct when flatten types. (#143) 2017-03-15 18:08:15 -07:00
Xiang Li 8b5a14ec74 Support dynamic indexing on matrix subscript. (#140) 2017-03-15 15:02:30 -07:00
Marcelo Lopez Ruiz d7f75ac8f0 Add reducibility analysis to the list of passes and paramless ctor. (#133)
Add reducibility analysis to the list of passes and paramless ctor.

This restores the property of having all passes initialized at DLL load time, keeps the reported list of passes stable, and fixes an assertion when the DLL is loaded on a thread but the first compile invocation occurs in a different thread.
2017-03-14 17:41:11 -07:00
Young Kim efe82279fe Support Unsigned for shorthand vectors/matrices (#106)
1. enable unsigned keyword for [int,min16int,int64] vectors and matrices
   (e.g. unsigned int2 -> vector<unsigned int, 2>)
2. disable unsigned keyword as a complete type specifier
2017-03-14 17:31:03 -07:00
Marcelo Lopez Ruiz 057c354b8b Add support to dndxc for debug line lookup, restore CFG printer passes. (#130) 2017-03-13 20:53:13 -07: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
Xiang Li b63197d2e3 Fix typo in TranslateCBAddressUserLegacy. (#128) 2017-03-10 10:57:56 -08:00
Xiang Li cf8e34ec11 Support write mask for typed buf. (#126) 2017-03-09 17:09:29 -08:00
Xiang Li 7cdfa0f6a2 Support select on resource. (#124) 2017-03-08 21:01:07 -08:00
Xiang Li fc2d2154cd For vector writemask, create gep + store instead of load + shuffle + store. (#120) 2017-03-07 18:58:46 -08: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 d5dbc051f3 Replace uses of phi which has same operand for all path with the operand. (#115) 2017-03-02 12:49:48 -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 2ab6ca4359 Support static global resource. (#105) 2017-02-23 16:49:38 -08:00
Xiang Li 4cf8d75cee Use lt instead of le for clip. (#103) 2017-02-23 12:42:30 -08:00
Xiang Li 6153e6dd01 Not create phi for resClass and resID of createHandle when all operands is the same. (#101) 2017-02-23 12:42:09 -08:00
Xiang Li 73b6f95a40 Legalize sample offset when optimization is disabled. (#97) 2017-02-18 00:46:17 -08:00
Xiang Li 726c754221 Only promote local resource when has store of handle. (#87)
* Only promote local resource when has store of handle.

* Report error when cannot map local resource usage to global resource.

* Promote static resource when optimization is disabled too.

* Take care PHINode on local resource.
2017-02-15 18:16:30 -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
Xiang Li fa22112d1a Use i32 for GEP index. (#85) 2017-02-14 16:57:33 -08:00
Young Kim 6b01781e58 Fix dxc option to supress warnings. (#83)
* Fix dxc option to supress warnings.

 - Modifying option handling to enable no-warnings as expected

* Fix OutputWarnings option to enable by default
2017-02-13 11:45:43 -08:00
Xiang Li 9ea3e5f44b Enable SampleCmpLevelZero for all shader profiles. 2017-02-10 11:43:30 -08:00
Tex Riddell b8594d7ddc Fix build break from automatic merge. 2017-02-09 19:03:47 -08:00
Tex Riddell a6433c18f8 Merge pull request #76 from tex3d/integration
Integrate validation, dxc option, and other changes
2017-02-09 17:33:45 -08:00
yurido1 f9fd30a62b Added verification of root signature against shader resources. (#11)
Fixed root signature range containment bug.
Added verification of root signature against shader resources.
2017-02-08 11:51:15 -08:00
Xiang Li cb0ba446c1 Fix validation bugs. (#10) 2017-02-07 22:18:10 -08:00
Xiang Li 4fcc616d9b Keep rowIdx for array of gs input. (#72) 2017-02-07 17:47:05 -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
yurido1 edfe849282 Changed intrinsic opcode attributes for DXIL. (#9) 2017-02-07 16:59:38 -08:00
Tex Riddell 627763e563 Add tests and fix bugs with container and root signature validation (#5)
* Fix ValidateDxilBitcode PSV generation for Root Signature validation.
- also fix validation for empty patch constant signature.
* Test container and root signature validation.
* Fix DXASSERT when PC in/out patch sig mismatch HS.
2017-02-07 16:57:07 -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
Xiang Li 5091d4f189 Add default for switch to avoid warnings. (#70) 2017-02-07 11:34:34 -08:00
Tex Riddell a3e0b5828d ContainerAssembler and Validation fixes.
- zero DxilProgramSignatureElement to prevent garbage in signature
- rewrite bitcode when stripping root signature
- use correct part when reading debug module in ValidateDxilContainer
- report general error message when signature validation fails
2017-02-03 19:04:02 -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
Xiang Li 7b998429f3 Disable race condition check (#3)
* Write thread group uniform value will not cause race condition.

* Only report race condition when know the data is not uniform.

* Disable race condition check.
2017-02-03 15:37:57 -08:00
Tex Riddell 3e0e6e5e23 Fix break in HLModule. 2017-02-03 15:04:17 -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 4fbd33a449 Merge pull request #60 from tex3d/integration
Merge opcode and dxc options changes to dxil-v1.0
2017-02-03 10:58:57 -08:00
Xiang Li 4072c971dd Don't need store the return val after call. (#64) 2017-02-03 10:37:21 -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 6de3365aa2 Fix RootSignature Validation bugs. 2017-02-02 20:54:35 -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 b0936e9395 Before Tex's rebase. 2017-02-02 19:58:03 -08:00
Xiang Li f43f396598 Use i32 to fake 64bit for buffer load/store. (#63) 2017-02-02 17:48:43 -08:00
Xiang Li 199aa5a0b5 Keep debug info for handle created by local resource. (#61)
* Keep debug info for handle created by local resource.

* Add IsResourceAlloc to share code.
2017-02-02 17:00:39 -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 9c3fd76579 Fix break in DxilOperations from merge. 2017-02-01 16:12:27 -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
Xiang Li 3c7734c7da Support vector indexing on output. (#55) 2017-02-01 10:55:26 -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 aa3313c767 Fix checkin issue. (#56) 2017-01-31 12:42:45 -08:00
Xiang Li 54bb69d607 Use metadata for precise on function call. (#51) 2017-01-30 18:41:33 -08:00
Xiang Li cf6f8beb4b Check Race Condition for TGSM (#48) 2017-01-30 16:09:31 -08:00
Xiang Li 06624f8991 Only allow dxil struct on ExtractVal. (#49) 2017-01-30 14:56:00 -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 e1f6fdbc19 Put createHandle for CBuffer to entry block when possible. (#42) 2017-01-26 18:09:50 -08:00
Tex Riddell e294996b0e Merge pull request #40 from Microsoft/master
- Clean up mistakes made when fixing copyright banners.
2017-01-25 15:04:28 -08:00
Tex Riddell e077864885 Clean up mistakes made when fixing copyright banners. 2017-01-25 14:36:50 -08:00
Tex Riddell e2f5d022bb Merge pull request #27 from tex3d/integration
Integrate internal changes
- link dump methods when compiled with _DEBUG or DBG
- d3d12warp to d3d10warp in hcttest-samples.py
2017-01-25 12:36:51 -08:00
Xiang Li deb9f3fd27 Fix crash when write to geometry shader input. (#36) 2017-01-25 10:42:07 -08:00
Xiang Li 7c91399069 Use undef to save type for type annotation. (#35) 2017-01-25 10:40:58 -08:00
Tex Riddell 5e5897564a Merge branch 'master' into dxil-v1.0 2017-01-24 17:57:32 -08:00
David Peixotto f805233b49 Revert license text in banner comments to original llvm verbage (#33)
Fix #30: Revert license text in banner comments to original llvm verbage

This commit removes the Microsoft-specific copyright in llvm files
and reverts the copyright wording to the original llvm wording.

We used the following method to find the files to change:
1. Find all files in DirectXShaderCompiler that are also in llvm 3.7
2. For those files that have the Microsoft-specific copyright, revert
   it to the original llvm copyright as present in llvm 3.7
3. Revert the copyright in a few files that are not in llvm, but are
   mostly copies of files in llvm:
	lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
	lib\Transforms\Scalar\Reg2MemHLSL.cpp

Leave the Microsoft-specific copyright header in files not present
in stock llvm:

    include\dxc\*
    lib\HLSL\*
    lib\DxcSupport\*
    tools\clang\test\HLSL\*
    tools\clang\test\CodeGenHLSL\*
    tools\clang\unittests\HLSL\*
    tools\clang\unittests\HLSLHost\*
    tools\clang\tools\dxcompiler\*
    tools\clang\tools\dxa\*
    tools\clang\tools\dxc\*
    tools\clang\tools\dxopt\*
    tools\clang\tools\dxr\*
    tools\clang\tools\dxv\*
    tools\clang\tools\dotnetc\*
    utils\hct\*
    CONTRIBUTING.md
    COPYRIGHT
    LICENSE-MIT
    README.md
    cmake\modules\FindD3D12.cmake
    cmake\modules\FindDiaSDK.cmake
    cmake\modules\FindTAEF.cmake
    docs\DXIL.rst
    docs\HLSLChanges.rst
    docs\_themes\dxc-theme\layout.html
    docs\_themes\dxc-theme\theme.conf
    docs\_themes\dxc-theme\static\dxc-theme.css
    include\llvm\llvm_assert\assert.h
    include\llvm\llvm_assert\cassert
    include\llvm\Support\MSFileSystem.h
    include\llvm\Support\OacrIgnoreCond.h
    lib\MSSupport\CMakeLists.txt
    lib\MSSupport\MSFileSystemImpl.cpp
    lib\Support\assert.cpp
    lib\Support\MSFileSystemBasic.cpp
    lib\Support\Windows\MSFileSystem.inc.cpp
    lib\Transforms\Scalar\Reg2MemHLSL.cpp
    lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
    tools\clang\docs\UsingDxc.rst
    tools\clang\include\clang\AST\HlslTypes.h
    tools\clang\include\clang\Basic\BuiltinsDXIL.def
    tools\clang\include\clang\Basic\LangOptions.fixed.def
    tools\clang\include\clang\Parse\ParseHLSL.h
    tools\clang\include\clang\Sema\SemaHLSL.h
    tools\clang\lib\AST\ASTContextHLSL.cpp
    tools\clang\lib\AST\HlslTypes.cpp
    tools\clang\lib\CodeGen\CGHLSLMS.cpp
    tools\clang\lib\CodeGen\CGHLSLRuntime.cpp
    tools\clang\lib\CodeGen\CGHLSLRuntime.h
    tools\clang\lib\Frontend\Rewrite\FrontendActions_rewrite.cpp
    tools\clang\lib\Parse\HLSLRootSignature.cpp
    tools\clang\lib\Parse\HLSLRootSignature.h
    tools\clang\lib\Parse\ParseHLSL.cpp
    tools\clang\lib\Sema\gen_intrin_main_tables_15.h
    tools\clang\lib\Sema\SemaHLSL.cpp
    tools\clang\tools\d3dcomp\CMakeLists.txt
    tools\clang\tools\d3dcomp\d3dcomp.cpp
    tools\clang\tools\d3dcomp\d3dcomp.def
    tools\clang\tools\libclang\dxcisenseimpl.cpp
    tools\clang\tools\libclang\dxcisenseimpl.h
    tools\clang\tools\libclang\dxcrewriteunused.cpp
    tools\clang\tools\libclang\libclang.rc
    tools\dxexp\CMakeLists.txt
    tools\dxexp\dxexp.cpp
    tools\dxexp\LLVMBuild.txt
2017-01-24 17:54:00 -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 a96eea8581 Integrate internal changes
- link dump methods when compiled with _DEBUG or DBG
- d3d12warp to d3d10warp in hcttest-samples.py
2017-01-23 16:40:48 -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 2d3ce8ef22 Merge remote-tracking branch 'upstream/master' into integration 2017-01-19 11:21:59 -08:00
David Peixotto b4f49bb41d Improve support for hlsl extensions (#14)
This commit improves the support for intrinsics added through
the IDxcIntrinsicTable interface:

- Only rewrite unsigned opcode for builtin intrinsics
- Allow replication to work when only vector is return value
2017-01-19 09:23:52 -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 c27cd89141 Restrict shader models accepted by DxCompiler API to 6.0 (#15)
- upconvert to 6.0 in dxc.exe and d3dcompiler_dxc_bridge
  - restrict to 6.0 in dxcompiler API
  - restrict to 6.0 in DxilValidator
  - allow loading of SM < 6.0 for now on DXIL 0.7
2017-01-18 17:45:26 -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
Xiang Li 93274654a7 Check input qualifier for patch constant function. 2017-01-04 13:29:28 -08:00
Marcelo Lopez Ruiz 6ee4074a4b first commit 2016-12-28 11:52:27 -08:00