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

448 Коммитов

Автор SHA1 Сообщение Дата
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