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

632 Коммитов

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

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

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

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

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

Resolves #2203

* Remove explicit marking of DxcThreadMalloc hidden

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

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

* Deletes copy and move ctors and assignment

* stores the allocator in the TLS slot.

* DxcSwapThreadMalloc should be able to install a null allocator

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

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

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

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

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

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

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

In HLSL, these are exposed as:

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

In DXIL, these are exposed as:

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

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

Scalarization of vector types occur as per the existing wave intrinsics.
For WaveMatch, the match is performed on each scalar and the results
are combined with bitwise AND. For WaveMultiPrefix, the operation is
performed on each scalar and combined into an aggregate.
2019-02-25 14:42:43 -08:00
Tex Riddell 5cdb20b28e Clean up addrspacecast from final shader code
- add addrspace stress test and addrspace inst test
- add ll test for cleanup pass targeting paths that may be difficult to
  hit from HLSL
- fix handling of base-class bitcast cast for structured buffer
- handle addrspacecast in SimplifyBitCast during CodeGen
2019-02-24 02:36:22 -08:00
Tex Riddell a7abe5959a Merge branch '19h1-fixes' into 19h1-fixes-on-master 2019-02-20 12:31:07 -08:00
Tex Riddell df3fd179a0 Merge branch 'fix-struct-param-5' into 19h1-fixes 2019-02-20 01:49:57 -08:00
Tex Riddell b4bb5795cd Fix some argument passing and groupshared bad codegen and crashes
- set address space for groupshared QualType and fix downstream effects
Fix:
- double LValue expression emit for in aggregate arguments
- in agg param modifying caller's value instead of copy
- groupshared matrix support in HLMatrixLower
- groupshared base class member access
- groupshared matrix member casting in class method

Still in need of more fixes and tests:
- incomplete array and auto dimensions from initializer

Argument handling still needs overhaul.  This fix retains old behavior, even
when not quite correct to avoid worse regressions.  Objects are not copied
in, aggregate LValueToRValue cast expr is emitted as LValues instead of
RValues because RValue emit path doesn't have HLSL changes necessary to handle
certain cases, such as derived-to-base cast.
2019-02-20 00:51:25 -08:00
Tristan Labelle 32fe0936b7
Update the HLMatrixLower pass to make it deterministic and correct
Updates the HLMatrixLower pass logic to eliminate the nondeterminism and randomly bogus codegen that came from iterating over a pointer-keyed map and modification of that map during the iteration. The new approach does a single pass on every instruction consuming or producing matrices, replacing it by its vector equivalent. Any consumed matrix is replaced by a temporary mat-to-vec translation stub, and any formerly produced matrix is emitted as a temporary vec-to-mat translation stub. Stubs get cleared as both ends of a consumer-producer dependency get lowered.
2019-02-16 21:21:24 -08:00
Tristan Labelle dc318ee472 Rewrote the HLMatrixLower pass to make it deterministic and correct. 2019-02-16 17:07:56 -08:00
Tex Riddell 1fccba0362 Merge remote-tracking branch 'ms/19h1-rel' into dxil-1-5 2019-02-11 13:44:43 -08:00
Lei Zhang f8c493f577 [spirv] Add support for VK_EXT_scalar_block_layout
Ref: https://github.com/KhronosGroup/Vulkan-Docs/issues/854
2019-02-08 13:46:44 -05:00
Ehsan Nasiri 1f32d35d21 [spirv] Minimally working compiler using v2. 2019-02-08 13:46:44 -05:00
Xiang Li 27a7bf4b0b
Add a simple GVNHoist to reduce dxil code size. (#1897)
* Add a simple GVNHoist to reduce dxil code size.

* Add res_may_alias option.
2019-01-31 14:21:54 -08:00
Tristan Labelle a7ee78049e
De-duplicate numerical conversions code (#1885)
Lots of different code in CGHLSLMS.cpp did numerical conversions in slightly different ways, most of them forgetting to take into account bools. This change introduces a single ConvertScalarOrVector function which handles both and updates code to use it. This implied a partial rewrite of const init list handling code because they lost the QualType information necessary to properly cast. They were also not handling register/memory representations properly so that got fixed it at the same time.
2019-01-29 16:53:32 -08:00
Xiang Li c2e744dcf4
Enable sroa for hlsl to remove static indexing array. (#1893) 2019-01-28 16:26:22 -08:00
John Porto 0b192a0aa0
Adds a PIX pass for assigning register IDs to dxil values. (#1827)
* Adds a PIX pass for assigning register IDs to dxil values.
2019-01-10 08:09:43 -08:00
Tristan Labelle 20c61bc577
Fixed sign and abs intrinsics on unsigned operands. (#1825)
Makes abs(uint) a no-op and sign(uint) equivalent to uint != 0, matching the correct FXC behavior.
2019-01-08 08:05:03 -08:00
Tristan Labelle 8c7dde57c5
Fix use-after-free due to by-value Twine parameters. (#1775)
llvm::Twines are dangerous. When concatenated, they store a pointer to their operands to defer the actual string concatenation as long as possible. Hence every Twine being concatenated must be kept alive. FormatMessageWithoutLocation took a twine by value, concatenated, and returned the result. This means that the concatenation pointed to the by-value argument, which gets destroyed when the function returns.
2018-12-14 15:34:23 -08:00
Adam Yang 51c6cfb01c
Created custom unroll pass to optionally include certain exit blocks. (#1752) 2018-12-11 14:04:46 -08:00
Tristan Labelle 9e20d1d856
Fix use-after-free in parameter SROA (#1746)
The parameter SROA's LowerMemcpy function deletes the memcpy and bitcast instructions after it has processed them. However, higher up the stack we created an IRBuilder pointing to the first non-alloca instruction, which happens to be the bitcast being deleted. Hence any further use of that IRBuilder will crash.

The solution is to delay creating the IRBuilder until after LowerMemcpy, since the rest of the code is well-behaved with respect to instruction deletion (ie it defers them to the end).
2018-12-03 15:19:35 -08:00
Tristan Labelle 8226092fd7
Change in-memory representation of bool vectors to use i32's (#1742)
This change fixes an inconsistency between scalar and vector bools, where the formers were stored as i32s in memory (as opposed to i1s in registers) while the latter remained <n x i1>s. This lead to a number of crashes in more complex bool scenarios where scalar and vector element types were expected to match.

The solution is to extend Clang's strategy for scalar bools to vector of bools. Clang relies on three key functions to deal with differences between register and memory type representations which are special-cased for bools and now also for bool vectors. Several HLSL code additions did not properly leverage those functions and this was addressed wherever possible, in some cases removing the need for special cases for bools.

To deal with matrices, a similar concept of register/memory representation was introduced in the matrix lowering code and the lowering passes were updated accordingly.
2018-12-03 13:28:22 -08:00
Tex Riddell 51db8e386d Add SM 6.5 / DXIL 1.5
- switch to binary search for ShaderModel::Get
2018-11-27 23:30:12 -08:00
Tristan Labelle 685b2afa84
Added support for pre-SM5.1 resource allocation algorithm (#1687)
Added front-end `-flegacy-resource-reservation` to control behavior (added automatically for SM <= 5.0)
Added an error for unbounded resources used with `-flegacy-resource-reservation`
Added a mechanism for `DxilModule` to preserve intermediate options during its passes but not in the final DXIL
Changed `HLModule` to not remove unreferenced `DxilResources` but rather make their symbol UndefValue
Fixed assumptions of `DxilResources` having a valid `GlobalVariable`
Added reserved resource range gather pass before elimination of unused resources (if SM <= 5.0)
Changed resource allocation to account for reserved ranges
2018-11-20 12:01:08 -08:00
Lei Zhang 7a2a95e36c
[spirv] Add support for VK_EXT_scalar_block_layout (#1716)
Ref: https://github.com/KhronosGroup/Vulkan-Docs/issues/854
2018-11-20 11:24:57 -05:00
Tristan Labelle 02260b1a8b
Better support for D3D12_SHADER_DESC reflection. (#1704)
Implemented filling out fields related to shader stage properties.
2018-11-15 15:52:22 -08:00
Tex Riddell 9b75d0fc6d
Fix subobject raw bytes storage; don't point into RDAT for reflection (#1710)
* Fix subobject raw bytes storage; don't point into RDAT for reflection

DxilSubobject:
- combine string and raw bytes storage in m_BytesStorage
- use StringRef as key, since memcmp is used with explicit length

DxilRuntimeReflection:
- add m_BytesMap for local unique copy of raw bytes in RDAT
  to prevent pointing into RDAT blob for root sig
- clean up some insertion patterns

* Rename Get[SubobjectString/RawBytes] to Intern[String/RawBytes]
2018-11-14 20:36:52 -08:00
Tex Riddell 92b779d40a
Fix missing hitgroup type in DxilRuntimeReflection (#1707) 2018-11-13 15:43:13 -08:00
Tex Riddell fbe1371aae
Fix Validation for RDAT and other issues with Subobjects (#1706)
- re-serialize module when changed by removing either subobjects or
  root signature metadata
- improve error detection/handling for loading/creating subobjects
- load subobjects from RDAT if not in DxilModule for RDAT comparison
- fix subobjects missing from desc in DxilRuntimeReflection
- default ReducibilityAnalysis to pass so it doesn't fail when no
  functions are present
- report error on subobject if validator (< 1.4) will not accept
  them, so they will not be captured
- container validation for required/disallowed parts for libraries
2018-11-13 14:49:32 -08:00
Tex Riddell bbf1b89f18
DxilSubobjectDesc: Reorder Name/Kind for runtime alignment (#1696) 2018-11-12 16:53:33 -08:00
Helena Kotas d75f96aabb
HitGroup subobject changes (#1688)
- Replace HitGroup subobject by TriangleHitGroup and ProcedurePrimitiveHitGroup
- Add internal HitGroupType enum that maps to D3D12_HIT_GROUP_TYPE
- Add corresponding HitGroupType field to metadata, RDAT and reflection
2018-11-09 17:50:04 -08:00
Tristan Labelle 90ed5a43a4
Remove unsupported /O4 option from help text. (#1662) 2018-11-08 14:16:24 -08:00
Helena Kotas b7d1c195c5
Add root signature flags (#1663)
* Add root signature flags

- Add LOCAL_ROOT_SIGNATURE flag in RootFlags
- Add DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS flag in DescriptorTable
- New DxilRootSignatureCompilationFlags argument on Compile/ParseRootSignature
  to specify whether the root signature is local or global.

* Fix root signature flag issues, add cmd test for root sig from define
2018-11-02 23:52:32 -07:00
Helena Kotas 637e6d2d7b
Add Subobjects to compiler front end (#1645)
- Add HLSL subobject classes to clang and enable their initialization
  via initialization lists.
- Translate declared subobjects and add to DXIL module.
- Fix bugs in subobject metadata serialization and disasm.
- Preserve original input string in root signature subobject.
- Remove unused IsHlslObjectType method from CGHLSLRuntime.
- Remove unnecessary collection of global strings in CGHLSLRuntime
- Change type printer to report 'literal string' for constant char arrays.
2018-11-01 11:43:57 -07:00
Tex Riddell 254b8853be
Fix dependency on HL/DxilModule from llvm::Module (#1651)
- use function pointers for HL/DxilModule remove function callbacks
- move ReducibilityAnalysis to llvm/Analysis
2018-10-31 19:18:28 -07:00
Tex Riddell baba32dcb0
Remove using namespace llvm from DxilSubobject.h (#1649) 2018-10-31 17:10:24 -07:00
Xiang Li 0df5e31b43
Only propagate WaveSensitive when target BB not post dom current BB. (#1648) 2018-10-31 16:30:27 -07:00
Tex Riddell 3f671b38fd
Fix #1629 - crash when using NonUniformResourceIndex (#1646)
Fix crash caused by NonUniformSet being invalidated before use
Instead of using NonUniformSet, defer lowering of
NonUniformResourceIndex until last, then mark all GEPs that use
the incoming value.

This will mark all uses of the value used in NonUniformResourceIndex
as non-uniform, including indexing that was not marked non-uniform,
if it ends up being the same index.  This matches the prior behavior,
and avoids loss of non-unifom metadata when merging GEPs, but could
be considered not quite correct, although the difference in indexing
would probably not have been intentional.
2018-10-30 13:40:11 -07:00
Tex Riddell 64bec9de53
Add DxilContainerReader and refactor PSV/RDAT into DxilContainer lib (#1642) 2018-10-29 17:54:05 -07:00
Tex Riddell 3af4373a34
Fix string interning for Subobjects (#1640)
* Fix string interning for Subobjects

* DxilRuntimeReflection: Remove dependency on llvm/ADT/STLExtras.h
- This file is meant to be included in other projects that do not include
  llvm headers or libs, so it must avoid those dependencies.

* Avoid unnecessary strlen operations in GetSubobjectString

* StringStorage/RawBytesStorage: use pair of unique_ptr and size
2018-10-29 11:30:16 -07:00
Lei Zhang efb45575db
Resolve compiler warnings on Linux and macOS (#1628)
* Removed unused functions and fields
* Turned off switch enumeration value not handled warnings
* Fixed initialization issues
2018-10-25 11:08:12 -04:00
Tex Riddell 4a942586f8
Merge pull request #1621 from tex3d/dxil-subobjects
Add Subobjects: classes, metadata, serialization, reflection, disasm
2018-10-24 11:44:51 -07:00
Lei Zhang 0fdb0fdbc3 Specialize std::hash in namespace std 2018-10-24 09:36:09 -04:00
Lei Zhang b107c06d97 Compile DxilLibraryReflection.inl on Linux and macOS 2018-10-24 09:09:56 -04:00
Tex Riddell 56ceb7faef Move struct defs outside union to avoid warning [-Wnested-anon-types] 2018-10-23 20:20:24 -07:00
Tex Riddell 262e94ee5a Address feedback, remove unused extra RDAT version. 2018-10-23 14:31:41 -07:00
Tex Riddell ecb4e3b4bb Add SV_ShadingRate plus optional feature flag
- Move/fix flag collection based on signature properties to be computed
  per entry function (including for libraries)
2018-10-22 20:25:12 -07:00
Tex Riddell 79bc013b4d Add dot2add and dot4add_*8packed intrinsics 2018-10-22 20:21:55 -07:00
Tex Riddell 64af6c0e5d Update to DXIL 1.4 and Shader Model 6.4 2018-10-22 16:35:38 -07:00
Tex Riddell 9678588269 Add Subobjects: classes, metadata, serialization, reflection, disasm 2018-10-19 01:02:34 -07:00
Xiang Li 16a5f94ab2
Move DxilRootSignature to its own directory. (#1609)
* Move DxilRootSignature to its own directory.
* Move DxilContainer into its own directory.
* Move DxilLoadMetadata into DxilUtil.
2018-10-17 18:46:43 -07:00
Xiang Li 016e70532e
Move pix pass into DxilPIXPasses. (#1605)
* Move pix pass into DxilPIXPasses.
2018-10-16 21:38:33 -07:00
Xiang Li 4df08af7c0
Move DxilModule into DXIL directory. (#1599)
* Move DxilModule into DXIL directory.
2018-10-16 00:28:35 -07:00
Tex Riddell 9ffa90c1e8
Fix line endings and add .gitattributes for default eol normalization (#1597) 2018-10-15 12:55:26 -07:00
Xiang Li 362defac90
Code cleanup. (#1596) 2018-10-12 15:40:54 -07:00
Xiang Li c9a4a44714
Split DxilViewIdState::Compute into DxilViewIdStateBuilder. (#1595) 2018-10-12 13:25:19 -07:00
Xiang Li 1661bf8de6
Code cleanup. (#1592)
* Code cleanup.
1. Move IsHLSLObjectType to dxilutil.
2. Add IsAnyTexture(Kind ResourceKind) to DxilResource.
3. Add SetMinPrecision for DxilTypeSystem and DxilOperation.
2018-10-11 18:37:07 -07:00
Ehsan d0008e6a41
[linux-port] Add definition of strnicmp for Linux. (#1567)
Usage of strnicmp was recently added to the code base, and causes the
Linux builds to fail. This should fix it.
2018-09-25 17:24:59 -04:00
Vishal Sharma 953ba46999
Implement Fxc's mul-only code gen pattern for pow function (#1564) 2018-09-24 21:08:31 -07:00
Helena Kotas 7f6667cd88
Support obsolete semantics with -Gec flag (#1552)
* Support obsolete semantics with -Gec flag

Shaders with obsoleted semantics now compile with -Gec flag. Each
semantic will trigger a warning and be remapped to the current name.

The obsolete semantics & remappings introduced in this change are:

POSITION -> SV_Position (VS output)
VPOS     -> SV_Position (PS input)
COLOR    -> SV_Target   (PS output)
DEPTH    -> SV_Depth    (PS output)

* Switch to case insensitive compare; add tests

* Address code review feedback
2018-09-21 17:19:32 -07:00
Tex Riddell da5c6ac202 Fix nested DxilSigPoint macros in way compatible with generated table 2018-09-18 23:49:31 -07:00
Tex Riddell 82337009a4 Revert "[linux-port] Fix nested macro expansion issue."
This reverts commit 8ea0608ed5.
2018-09-18 20:11:32 -07:00
Ehsan Nasiri b86e5efe1b [linux-port] 'auto' not allowed in lambda parameter.
It is allowed starting C++14, but C++11 is assumed currently.
2018-09-18 10:44:36 -04:00
Ehsan Nasiri 8ea0608ed5 [linux-port] Fix nested macro expansion issue. 2018-09-18 10:44:35 -04:00
Tex Riddell 89697bbad5 Merge branch 'master' into dxr-master
# Conflicts:
#	include/dxc/HLSL/DxilUtil.h
#	lib/DxcSupport/HLSLOptions.cpp
#	lib/HLSL/DxilUtil.cpp
#	tools/clang/lib/CodeGen/CGHLSLMS.cpp
#	tools/clang/unittests/HLSL/DxilContainerTest.cpp
2018-09-12 22:28:35 -07:00
Lei Zhang 8425998506
Fix declaration of IDxcRewriter2 cross-platform uuidof (#1541) 2018-09-12 17:01:20 -04:00
Helena Kotas 4afbc6897d
IDxcRewriter2 interface; change RewriterTest to report errors (#1529)
* IDxcRewriter2 interface; change RewriterTest to report errors

Added IDxcRewriter2 interface with method RewriteWithOptions that allows
setting compiler flags for the rewrite. The current IDxcRewrite methods
use HLSL Version 2015 only. RewriteWithOptions allows changing that
and other compiler options.

Modified RewriterTest to report compilation errors. Changed data of existing
tests that started failing because of this change.

Fixed DeadLoopFail test.
2018-09-11 12:31:52 -07:00
Vishal Sharma afff6a3c51
Enable write to global vars with /Gec flag and HLSLVersion <= 2016 (#1526) 2018-09-07 19:51:39 -07:00
Ehsan a2085d4491
[linux-port] Do not use llvm DynamicLibrary in dxcapi.use.h (#1527)
Fixes #1525

This CL changes dxcapi.use.h back to what it was before the Linux-port work. It does, however, add a snippet into it to redirect FreeLibrary to dlcose, LoadLibraryW to dlopen, and GetProcAddress to dlsym for non-Windows platforms.
2018-09-06 10:20:10 -04:00
Lei Zhang 14bcc3f6a7
[spirv] Add option to ignore emulated feature warnings (#1522)
Some HLSL features does not have direct mapping to SPIR-V, instead
we emulate them using lots of SPIR-V instructions. Because they
can cause performance hit, the compiler warns by default. This
commit add an option, -Wno-vk-emulated-features, to let developers
turn off such warnings.
2018-08-30 16:54:34 -04:00
Ehsan a2bb5d400e
[spirv] Cleanup of cl option handling for SPIRV. (#1521) 2018-08-30 13:58:19 -04:00
Lei Zhang 81b3451b4a
[spirv] Add mechanism for fine-grained control of debug info (#1518)
Added a new command-line option: -fspv-debug=<category>, where
category can be file, source, line, and tool, to give developers
fine-grained control of what debug information they want in
the generated SPIR-V code.
2018-08-29 11:11:30 -04:00
Xiang Li adeabbffb0
Use std::atomic. (#1506)
* Use std::atomic.
llvm::sys::Atomic* was removed in upstream llvm.

* Use list-initialization rather than copy initialization.

Fixes the build failure on Linux.

There's a full discussion about this subject here:
https://stackoverflow.com/questions/21708606/why-does-an-in-place-member-initialization-use-a-copy-constructor-in-c11
2018-08-21 10:46:39 -07:00
Lei Zhang 05cda8da2a
[spirv] Add support for -fvk-bind-register (#1480)
format: -fvk-bind-register <type-number> <space> <binding> <set>

Also created a short alias for it: -vkbr.

This option gives the ultimate manual control of descriptor
assignment. It requires:

* All resources are annotated with :register() in the source code
* -fvk-bind-register is specified for every resource

It overrules all other mechanisms.
It cannot be used together with -fvk-{u|b|s|t}-shift.
2018-08-03 07:36:18 -04:00
Greg Roth d82f291490 [linux-port] Silence lost const warnings (#1477)
CreateBlobWithEncodingFromPinned is unlike any of the other
CreateBlob* functions in that its pText argument is a non-const
byte pointer. All the others use const void pointer for this
same parameter. Because the parameter is not const, in many cases
const pointers need to have their const qualifier cast off to be
used for this parameter in spite of the fact that the next level
call passes it to a const pointer. This produces a bunch of
warnings in places where its used.

By changing the variable to const void, there is less unnecessary
casting, fewer warnings, no change in behavior, and a clearer
external indication of the way it is used by the function from the
prototype.
2018-08-02 16:41:37 -04:00
Greg Roth 988499d872 [linux-port] Better match Windows char conversion (#1479)
Windows char conversion functions differ from the std methods in
a few ways. Windows ignores null terminators when lengths are
provided, length limits represent character lengths not byte sizes,
the current linux implementation ignores codepages, but the files
used in many HLSL tests are in iso 8859-1 not utf8. So some
differentiation is needed.

This solves all but one of the above problems. To limit conversion
by source characters instead of solely the size of the output
buffer, where necessary, a temporary buffer is created to hold the
source string that corresponds to the provided character length and
a null terminator is appended to make the std:: conversion stop there.
If there is a null terminator there already, this is skipped for
performance purposes. Such is often the case.

To respect the codepage parameter, it is converted to the corresponding
locale string and setlocale is used to temporarily set the locale
accordingly and set it back afterwards.

The aspect that is missed is that the Windows conversion functions
will happily blow past a null terminating character if the length
specified encompasses it. This is rare enough in general, and unlikely
in the way these functions are used in the source base.

corrects one errant non-breaking space character that found its way
into an HLSL file that the std:: conversion choked on. It didn't seem
to serve any purpose anyway.
2018-08-02 13:03:43 -04:00
Lei Zhang 474954a6ea
[spirv] Update mapping manual w.r.t. debugging and options (#1475) 2018-08-01 10:49:51 -04:00
Greg Roth 28e4dd76da [linux-port] Enable extensiontest for Unix (#1478)
Enable the UUID for IDxcLangExtensions so its interface can be
properly queried. Sundry const, semicolon, and override warning
eliminating changes that might have been included in the larger
corresponding changes had this test not been an afterthought.
2018-08-01 07:50:11 -04:00
Tex Riddell 178ffd1d71 Merged PR 113: Add -default-linkage option and export keyword
Add -default-linkage option and export keyword
2018-07-31 20:38:39 +00:00
Ehsan 90103b38c2
[spirv] Expose -Oconfig for running custom optimizer recipes (#1466) 2018-07-31 13:49:19 -04:00
Tex Riddell 2330c74b1a Merge remote-tracking branch 'ms/master' into user/texr/integrate-master
# Conflicts:
#	tools/clang/tools/dxcompiler/dxcompilerobj.cpp
#	tools/clang/unittests/HLSL/ValidationTest.cpp
#	tools/clang/unittests/HLSL/VerifierTest.cpp
2018-07-26 17:17:36 -07:00
Tex Riddell ec4219002e Merge branch 'rtmaster' into user/texr/integrate-master 2018-07-26 16:07:02 -07:00
Tex Riddell fec1adb90e Merged PR 110: Validate raytracing shader properties and RDAT blob part
Validate raytracing shader properties and RDAT blob part

- no signatures for ray tracing shader functions
- payload/params/attribute sizes are >= argument type allocation sizes
- RDAT is bit-identical to RDAT generated
- Minor fix for CS: should not have input signature elements either.
- update val version comment
- Prevent strange behavior with library target and entry point not empty.
- remove DXASSERT in LoadDxilMetadata (validation should catch this case)
2018-07-26 22:44:51 +00:00
Tex Riddell 7fe628800d Merged PR 108: Validate function params for libraries.
Validate function params for libraries.
2018-07-25 19:02:59 +00:00
Greg Roth d155df144a [linux-port] Enable DXIsenseTest on Unix (#1446)
Mostly required converting simple member function definitions
to include the TEST_F macro, which works for either gtest or taef,
but is optional for the latter.

Fixed an additional bug with the Linux implementation of CComPtr
which contained a single virtual function, which causes the compiler
to add a vtable pointer to each object created. This is fine most of
the time, but when it is cast to another kind of pointer and attempts
to increment it as that type instead of CComPtr, it doesn't account
for the bytes that the vtable pointer take up.

By simply removing the sole virtual qualifier on the destructor,
which was on the destructor, the vtable pointer is omitted and the
cast and increment works. The CComPtrBase destructor prototype is
shown to not be virtual in Windows documentation.
2018-07-25 14:51:15 -04:00
Lei Zhang f40667e931
[spirv] Rename -fvk-invert-w to -fvk-use-dx-position-w (#1448) 2018-07-24 20:46:14 -04:00
Tex Riddell 156c45dd42 Merged PR 107: Add lib_6_x for offline linking only and -export-shaders-only
Add lib_6_x for offline linking only and -export-shaders-only

- Add lib_6_x target for offline linking use only
- Implement -export-shaders-only to limit function exports to shaders on lib targets
- Fix disable validation case downgrading Dxil as if valver is 1.0
2018-07-24 02:12:11 +00:00
Xiang_Li (XBox) 94157e54ab Merged PR 105: update handle validation.
update handle validation.
2018-07-21 01:54:30 +00:00
Tex Riddell b6f8cbc420 Add lib_6_x target for offline linking use only 2018-07-20 18:31:37 -07:00
Tex Riddell 2d8c68a055 Implement -export-shaders-only 2018-07-20 18:31:05 -07:00
Lei Zhang ef6c9eff15
[spirv] Add -fvk-invert-w (#1429)
This option reciprocates (multiplicatively inverts) SV_Position.w
after reading it from stage input in PS. This is used to accommodate
the difference between Vulkan and DirectX.
2018-07-19 10:34:51 -04:00
Tex Riddell 071b568f69 Merge remote-tracking branch 'ms/master' into user/texr/integrate-master
# Conflicts:
#	lib/HLSL/DxilContainerReflection.cpp
2018-07-18 12:35:15 -07:00
Tex Riddell ca77440693 Merge branch 'rtmaster' into user/texr/integrate-master 2018-07-17 21:23:48 -07:00
Greg Roth db8e3511c5 [linux-port] restore mistakenly removed sysallocs (#1433)
In rebasing the heap change, I mistakenly removed the sysallocstringlen
and sysfreestring functions. This restores them.
2018-07-17 22:03:59 -04:00
Tex Riddell f805234c9b Add ObjectToWorld/WorldToObject 3x4 and 4x3 intrinsics
- left original ObjectToWorld/WorldToObject for prototype compat.
2018-07-17 14:03:50 -07:00
Tex Riddell 433ae70a2e Add RayFlag and HitKind to DxilConstants.h, add HIT_KIND_NONE. 2018-07-17 13:47:03 -07:00
Greg Roth c24c9de9f8 [linux-port] Unix Heap* allocation implementation (#1428)
Heap allocation functions were previously partially implemented via
a few macros that provided some of the functionality.

This replaces those macros with a more expansive implementation of
the interface as defined in Microsoft documents. Simple structs are
used to store pointer and size implementation, enabling queries of
allocation sized from pointers, putting an upper limit on the total
amount of memory allocated by the given heap, retrieving a
default heap for the process, and freeing of all heap memory at the
time of heap destruction.

Most flags are unsupported save ZERO_MEMORY. Heap creation includes
an initial size that is meant to preallocate memory and make latter
allocations more efficient. This does not support that. Still for
the usages in the code base, this should appear externally to be
a fully functional implementation.

Includes a macro for CaptureStackBackTrace as well for CompilerTest
2018-07-17 14:46:57 -04:00
Greg Roth 597376b4b1 [linux-port] Enhance FS interface support (#1420)
There are various points where system functions are called via
OS-specific wrappers beginning with llvm::sys::fs. As part of the
development of the HLSL shader compiler, some of the microsoft
versions were altered to call into a further abstraction via the
MSFileSystem interface. In certain cases, this allows non-existent
"included" files to be accessed with the outward appearance of being
real files. However, many of these changes were missed by the Unix
abstraction. This adds them in with the facilitator of adding a few
functions to the MSFilesystem abstraction that better match Unix
system calls.

Needed for various tests that provide fake source files to compile
and include fake headers from within HLSL code. Otherwise, these
files are not found because they are not on the filesystem.

The Unix-like methods are added because in cases where the current
filesystem abstraction just calls the system calls directly, the
windows-style accesses were cumbersome and incomplete. Tablegen
and some tests make use of these simpler implementations.
2018-07-17 12:50:42 -04:00
Greg Roth a292aedbaa [linux-port] Enable intellisense classes for Unix (#1430)
Several HLSL tests, notably VerifierTest, require intellisense classes
To get these working on Unix platforms, we need to add support.
This involves mostly exposing the instance creation, the UUID, and
adding the right headers.

Additionally adds definitions of a couple UUIDs that were declared
but previously not defined. These are also useful for HLSL tests.
2018-07-17 12:32:01 -04:00
Greg Roth 0fa00bb37e [linux-port] Win adapter changes for HLSL tests (#1415)
* [linux-port] Win adapter changes for HLSL tests

A number of Windows-specific features are present in the HLSL tests
as well as driver features that had to be enabled to get those tests
running, notably intellisense classes.

This change adds to the existing WinAdapter and WinFunctions files
to include the features needed for these additions to driver and tests.
They cover a lot of ground, but mostly consist of memory allocation
and string changes, because you can never have enough ways to
allocate memory and manipulate strings.

An incidental change is to the existing CreateFileW implementation
to retry a file if the error indicated it was interrupted. This was
taken from the LLVM Path.inc implementation for Unix.
2018-07-17 09:19:40 -04:00
Tex Riddell 95c382de3f Merge branch 'master' into user/texr/integrate-master
# Conflicts:
#	lib/HLSL/DxilContainerReflection.cpp
#	tools/clang/tools/CMakeLists.txt
#	tools/clang/unittests/CMakeLists.txt
2018-07-13 15:01:10 -07:00
Tex Riddell 734accbce5 Merged PR 100: Eliminate phi on resources/handles for library
Eliminate phi on resources/handles for library

- ensure all handles use only one global resource
- replace resource path with indices into global resource
- replace resource alloca with index allocas
- AddCreateHandleForPhiNodeAndSelect now unnecessary, deleted
- error on resources in library function params or return
- mark entry clones as internal linkage since they could contain params
  that are not allowed for libraries.
- fix MarkUavUpdateCounter - handle nested GEP
- disallow static resource use from exported library functions
- add/update tests
- detect undef resource paths that would otherwise be lost (FailUndefResource)
- set internal linkage for HL intrinsic function bodies so they aren't processed with user functions
- Rename legalize [static] resource use passes to DxilPromote(Local|Static)Resources
- Remove various dead code paths for resources, such as:
  GenerateParamDxilResourceHandles, RemoveLocalDxilResourceAllocas,
  lower handle cast, non-promotable error (may translate to index allocas)
- force resource GVs to external constant with no initializer
2018-07-13 02:04:31 +00:00
Greg Roth 051a7b639e [linux-port] Correct char convert size in/out (#1411)
MultiByteToWideChar and WideCharToMultiByte were returning -1 on
failure, which caused failures to be ignored. When successful, they
were returning the number of characters converted excluding the
terminating null character because that's what the std:: functions
used for the implementation do. Both are inconsistent with the
original Windows implementations.

Simply adding one to the return value works in all cases save those
where the number of characters converted was limited by the parameter
In this case, the number of characters converted doesn't include
the terminating null. So no addition is warrented.

Added addition errors in keeping with the function descriptions.

The CW2A conversion class left out the terminating null character
when calculating the max size of the converted string.
2018-07-10 16:57:21 -04:00
Christopher Wallis 74520bb662 Merged PR 98: Adding a DxrFallbackCompiler.dll containing IDxcDxrFallbackCompiler implementation + tests
This adds an isolated component *IDxcDxrFallbackCompiler*  that is used by the D3D12 Raytracing Fallback Compiler. The component is responsible for linking together DXR shaders into a state machine capable of emulating function invocations including recursion, patching HLSL intrinsics, export renaming, and emulating Shader Record support. This component is compiled to a DxrFallbackCompiler.dll that gets consumedd with D3D12 Raytracing Fallback Compiler apps.

For deeper implementation details, I will be fleshing out lib\DxrFallback\readme.md

Some leftover work still required:

1. Currently the Fallback Layer tests compile to an exe that must be manually run. This should be refactored to conform with existing DXIL unittests.
2018-06-29 23:43:40 +00:00
Ehsan e8d5eb0111
[linux-port] Enables the DXC main on Unix. (#1384) 2018-06-27 15:00:26 -04:00
Greg Roth eacaf5a58c [macos-port] Allow dxc and tests to run on mac (#1383)
The REGEX_H define prevented the inclusion of an Apple system header.
Not coincidentally, the same header regex_impl.h was derived from.

Prevent Apple warning by splitting macro args with an #else. Add HLSL
change comments too which were missing from the start.

Search for libdxcompiler.dylib instead of .so on Apple.

MacOS resolves symbols differently from Linux. Linux takes the first
valid resolution and then uses it wherever it is referenced. MacOS
more similar to Windows, favors symbols that are local to the
compilation unit.

This comes into play where functions set static globals such as
the malloc tls and the IMalloc contained there. The dxc binary
initializes these. For Linux, that's enough because all calls
resolve to the ones from this binary because they are encountered
first. MacOS calls that originate from within the dynamic library
resolve to the local functions, which don't have their globals
initialized. To initialize them, we need to do what is done in
DLLMain in DXCompiler.cpp.

Performing these calls results in duplicate initializations on Linux
unless the calls in question are given visibility hidden. This is
the default on Windows, but not on Unix OSes.
2018-06-27 13:42:23 -04:00
Ehsan 9337fd2ef5
[linux-port] Enable cross-platform interfaces. (#1377)
As described #1342, this change makes it possible for interfaces to
compile on other platforms, without making any intrusive changes.
2018-06-26 17:45:21 -04:00
Greg Roth 3670c1372d [linux-port] Use cross-platform dynamic lib load (#1380)
LLVM includes a DynamicLibrary class that works on multiple platforms
Rather than ifdefing between dlopen for non-Windows and LoadLibraryW
on Windows, using this class allows us to abstract platform differences
while using the same code.

Changed DxilLibInitialize to attempt to initialize dxil.dll so the
smart mutex inside the dynamic library object uses the same IMalloc
as the other ManagedStatic objects so they can all be freed in order.
2018-06-26 17:33:14 -04:00
Ehsan f8f0bfcf0b
[linux-port] FileSystem and IO. (#1374)
Some interactions with the FileSystem are not used by any API and are
therefore not implemented for Unix at the moment. We have put assertions in
place to make it easy to spot if any of those methods are ever used.
2018-06-26 15:05:08 -04:00
Ehsan 4799c6ce50
[linux-port] Enable some code. Disable some code. (#1372)
Some code originally in llvm/clang was commented out, and was replaced
with Windows-specific implementation. In this change we bring back some
of those.

Also disabled some code that is not relevant any more.

And a few minor improvements towards cross-platform compilation.
2018-06-25 20:15:54 -04:00
Ehsan 285490211f
[linux-port] Complete the Windows adapter code. (#1358)
This change completes the necessary adapter code needed to enable
cross-platform compilation.

Discussion on the design/implementation of these are in issue #1341 and
isuee #1342.

In addition to the adapter classes/structs, there exists usages of
Windows-specific functions in the codebase. In some cases, we won't need
to compile/run some of those methods on non-Windows platforms. For the
few cases where we do, we have implemented equivalent functionality in
WindowsFunctions.cpp.
2018-06-25 16:04:13 -04:00
Ehsan f7cd091e93
[linux-port] Add MultiByte<->WideChar methods. (#1357) 2018-06-23 21:43:39 -04:00
Tex Riddell 6663dac50f Merge branch 'master' into user/texr/integrate-master
# Conflicts:
#	lib/HLSL/DxilContainerAssembler.cpp
#	lib/HLSL/DxilGenerationPass.cpp
#	lib/HLSL/DxilLinker.cpp
#	lib/HLSL/DxilModule.cpp
#	lib/HLSL/DxilOperations.cpp
#	lib/HLSL/DxilTypeSystem.cpp
#	lib/HLSL/DxilValidation.cpp
#	lib/HLSL/HLMatrixLowerPass.cpp
#	lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp
2018-06-22 12:05:49 -07:00
Tex Riddell e9d8bd9831 Merged PR 96: Add shader mask and min SM to RDAT
Add shader mask and min SM to RDAT
- add OP::GetMinShaderModelAndMask to compute mask and min SM
- account for ops that can be translated during linking
- update PS ops that could be allowed in library functions
- update min SM with newer optional feature flags

Fix AV in TranslateHLSubscript for typed buffer with struct element
2018-06-22 00:31:08 +00:00
Greg Roth ae615d47a8 [linux-port] Eliminate warnings on release builds (#1361)
A number of warnings unique to release buildsi persist. Some of these
same errors were fixed earlier for debug builds.

DXASSERT_LOCALVAR still took a variadic macro on release builds.
Fixes 85 clang warnings

Expressions used only as conditionals for asserts were not properly
dummied out with (void) cast.
Fixes 7 clang warnings

Variables used only in asserts dummied out.
Fixes 27 clang warnings

Potential uninitilized uses of variables assigned in switches/ifs.
fixes 5 clang warnings

put braces around empty else statements
11 gcc warnings
2018-06-21 10:46:30 -04:00
Tex Riddell 41ed85892d Remove unused OP::ComputeMinShaderModelAndMask for function 2018-06-21 00:59:56 -07:00
Tex Riddell ee550a4b53 Add shader mask and min SM to RDAT
- add OP::GetMinShaderModelAndMask to compute mask and min SM
- account for ops that can be translated during linking
- update PS ops that could be allowed in library functions
- update min SM with newer optional feature flags
2018-06-20 21:40:28 -07:00
Xiang_Li (XBox) 4ade2fccc0 Merged PR 92: Enable ValidateResourceDxilOp for lib profile.
Enable ValidateResourceDxilOp for lib profile.
2018-06-20 18:53:19 +00:00
Lei Zhang 94ec193042
Add IDxcVersionInfo2 for querying Git commit info (#1304)
This will give users a way to know the commit from which a DXC
library/binary was built from, so that they can compare different
libraries/binaries and report bugs easily.

dxc.exe now also prints the commit info using this new interface
method. It uses the following format:

  (dev;<commit-count>-<commit-hash>)
2018-06-20 11:35:48 -04:00
Ehsan 5bf6dd1840
[linux-port] Minor changes towards cross-platform compilation. (#1352) 2018-06-19 10:36:53 -04:00
Ehsan 180ea63ba0
[linux-port] Introduce Windows "adapter" headers (#1314)
In this CL, we have introduced the "WinAdapter.h" header file.

This file includes declarations and definitions that will enable compilation of the code base on non-Windows platforms. These include:

* Disabling SAL annotations for non-Windows platforms.
* Defining some Windows-specifc macros that are not defined on other platforms.
* Defining Windows-specific types that are used throughout the codebase for non-Windows platforms.

This file is currently not complete. As we go forward, we will add more classes/structs/type definitions to this file for specific purposes. The contents of this file is completely disabled (#ifdef'd away) for Windows, and do not affect Windows compilation in any way.  For the most part, this is our way of enabling compilation of the codebase on non-Windows platforms without making invasive changes to the existing cpp files, and without hindering any future development. Moreover, I have added the #include of this file for all the locations that will need it for successful Linux compilation.
2018-06-17 11:31:21 -04:00
Tex Riddell 9a2a731b7b Fix regressions with entry props/sigs and UseMinPrecision flag
- Make sure entry/signature data is available once SetShaderModel() is
  called for shader targets (not for library).
- Add bUseMinPrecision flag to SetShaderModel() since the global switch
  is needed at that point.
- Remove SetUseMinPrecision() since it should be set in SetShaderModel()
  and should not be changed.
- Modify DxilModule loading to initialize UseMinPrecision flag correctly
  for entry signatures, and fix signature copy constructor.
- Remove DxilModule level entry property duplicates, use the
  DxilFunctionProps instead, except where useful (GS stream mask),
  and make sure these are always available/in-sync.
- Fix various code accessing properties that don't match target
- Fix various ordering issues causing bugs in properties
- Don't duplicate functions to strip them of parameters when they have
  already been stripped (linker hits this).
2018-06-12 15:29:39 -07:00
Tex Riddell d37f956c70 Merged PR 86: Finalize OpCode changes for Dxil 1.3 / SM 6.3
Finalize OpCode changes for Dxil 1.3 / SM 6.3

- Rename CreateHandleFromResourceStructForLib to CreateHandleForLib
- Add PrimitiveIndex
- Add final NumOp[Codes|Classes]_Dxil_1_3 values
- Fix legal shader stage set for PrimitiveID
2018-06-09 00:22:19 +00:00
Greg Roth 6121df782a [linux-port] Correct problematic initializations (#1321)
Regardless of the order of variables placed in a constructor
member initializer list, the variables are initialized in the
order they are listed in the class or struct. This can cause
issues where the assignment of one variable depends on the other.
For this reason, a warning is produced if the member variables
are listed in a different order. This change moves the member
initializer lists into the order they were being initialized.
Fixes 23 clang and 24 gcc warnings.

Initialization of members of a larger aggregate type may benefit
from braces to clarify which variables are expected to go where.
At the same time, scalars should not be so segregated. This places
or removes such braces wherever appropriate.
Fixes 144 clang warnings
2018-06-08 07:19:20 +08:00
Greg Roth a88cc5d133 [linux-port] de-const variables not used as const (#1331)
pParameters and pStaticSamplers were both marked const in spite of
the qualifier being cast off at nearly every usage. So they lose
their const. If you're the target of memcpy or memset, you are
not const.
Fixes 12 gcc and 12 clang warnings
2018-06-07 13:04:20 -04:00
Xiang_Li (XBox) 2adce9a983 Merged PR 80: Merge EntrySignature and FunctionProps together.
Merge EntrySignature and FunctionProps together.
2018-06-07 02:04:03 +00:00
Tex Riddell c37d554d1e Merged PR 83: Integration fixes.
Integration fixes.

- Remove unused constructor from FunctionTableReader
- Remove hlsl::Exception dependency from DxilRuntimeReflection.inl
- Fix field size sizeof(RuntimeDataFunctionInfo) in legacy loader
- Add __cdecl to raw_ostream::operator<<(...) for ios_base change
- Move string constant definitions to from CGHLSLMS to DxilModule, since
  they are required by HLSL.lib, and that shouldn't depend on clang CodeGen.
2018-06-06 01:05:40 +00:00
Xiang_Li (XBox) 4491b6230b Merged PR 82: Fix matrix array as parameter for external function.
Fix matrix array as parameter for external function.
2018-06-02 02:45:59 +00:00
Tex Riddell df033577ee Merged PR 79: DxilRuntimeData updates for final data layout
- Revise DxilRuntimeData for versioning support and robustness.
- Rename DxilRuntimeReflection desc structures.
- Add size checking to DxilRuntimeData/Reflection
- CheckedReader/CheckedWriter to catch potential problems
- Backward compatible reader for prerelease RDAT format
- Rewrite IndexArraysPart and avoid duplicate index arrays
- Always start string buffer with null for empty string at offset 0
2018-06-01 19:41:10 +00:00
Greg Roth 0987e48b56 [linux-port] Fix DXASSERT warnings (#1322)
The various DXASSERT macros produced a number of different warnings.
The most obvious was providing an empty string for a macro expecting
a message. Substituting in the _NOMSG macro fixes this.
Fixes 13 clang warnings.

A trickier problem for GCC and Clang is a variadic macro that is
provided no variadic arguments. Both Clang and GCC will avoid
errors by using the ##__VA_ARGS__ non-standard behavior, but it's
not an ideal solution. It turns out there aren't that many DXASSERT
macros that actually take variadic arguments. So I added an _ARGS
variant and replaced those instances with that. An ancillary benefit
is that non variadic asserts can present a message with the assert.
Fixes 583 clang warnings and 582 gcc warnings.

In what I expect was an earlier attempt to overload the DXASSERT
macro, it was defined twice each time with a different number of args.
Sadly, macros can't be overloaded, so this just produced more errors.
Fixes 69 clang warnings and 69 gcc warnings.

Finally, I removed the user declaration of std::error_code because
it is defined in a standard header <system_error>. Because clang was
including that header some places, it saw it as a redefinition. But
the Linux version is a struct and windows is a class. So nothing we
put here can make everyone happy. It doesn't really fit with this
change except for in proximity but doesn't fit anywhere else either.
Fixes 52 clang warnings
2018-05-31 15:27:06 -04:00
Xiang Li c410b52fad Add shader stage limitation for Raytracing intrinsic. 2018-05-31 11:20:49 -07:00
Greg Roth 8ccd639869 [linux-port] Fix anonymous struct warnings (#1329)
A most pervasive warning from a minimal amount of code. The Wintypes
header included an anonymous struct in the form of LARGE_INTEGER
which is specified by Microsoft, but the actual MS header includes
another struct in the union for environments that don't want
anonymous structs. Given the minimal usage, I think this can
qualify. Microsoft's own headers will exclude the anonymous struct
in favor of the named one if NONAMELESSSTRUCT is defined before
windows.h. To prevent future uses of the anonymous part of LARGE_
INTEGER, this defines that in WinIncludes.h.
Fixes 148 clang and 148 gcc warnings.
2018-05-31 13:27:55 -04:00
Greg Roth 1fafc7bc77 [linux-port] Correct const casts (#1324)
There are a lot of cases where const is carelessly cast off. Some
of them lead to really dramatic changes in multiple interfaces to
fix properly. This is instead a subset of cases where const was
disrespected, often for no apparent reason at all. likely just a
mistake in type casting.

Fixes 88 gcc and 88 clang warnings.
2018-05-30 16:14:59 -04:00
Greg Roth 5267dff556 [linux-port] Mark all overridden methods (#1319)
Clang produces a warning when a method that overrides another is
not marked with the override keyword. Adding the keyword has no
effect on overridden functions, but it is good practice to mark
all methods intended to override as such because if they fail to
do so, the keyword will produce an error.

Fixes 78 Clang warnings.
2018-05-30 09:07:16 -04:00
Greg Roth df8f1cb289 [linux-port] Scalar initialization warnings (#1316)
There is the possibility of a few variables being used without
initialization, which causes some warnings.
Fixes 2 clang warnings

GCC worries that assigning a variable to the result of an
assignment of that same variable may be undefined. It's a silly
thing to do anyway. So it's removed.
Fixes 1 gcc warning.

GCC is quite sure that Interp is too small to hold values of up
to 9 with only 4 bits. Perhaps because the RHS is a variable of
8 bits.
Fixes 47 gcc warnings
2018-05-30 08:51:05 -04:00
Greg Roth 7a87a51ac9 [linux-port] Remove extra semicolons (#1317)
Terminating classes may create a muscle memory for typing a
semicolon after a left-justified closed brace. Whatever the reason
to GCC's chagrine there were many functions ended with unnecessary
semicolons. Each one caused a warning. This removes them.

Fixes 285 GCC warnings
2018-05-30 06:36:14 -04:00
Greg Roth 6ddc8622d9 [linux-port] More compile improvement (helps GCC). (#1310)
GCC has what seems to me to be a bug where it disapproves of the members
of a member struct of class OP having the same name as a type imported
by "using". It's the only compiler with the issue and I don't see any real
conflict, but it's easier to placate it than to fix GCC. GCC
claims its ambiguous. Making the member variables lowercase fixes
this neatly.

Removed some PointerStatus:: prefixes from references within the
class itself which upsets GCC.

HLSL changes excluded Transforms/Instrumentation directory entirely
including BoundsChecking. However it didn't excluder one reference
to a function declared there in BackendUtil that fails to link on GCC.
The function that references the missing BoundsChecking function
is static and not used anywhere with current settings. So it's not
considered a symbol to be linked by MSVC or clang, but GCC insists.
2018-05-29 15:29:47 -04:00
Greg Roth 7ad425a495 [linux-port] Use llvm::sys::Atomic* (#1309)
InterlockedIncrement and InterlockedDecrement are atomic operations to
increment or decrement the value pointed to by the pointer parameter and
return the same.

There are already platform abstractions available to LLVM in Atomics.h.
This change leverages them to implement the same functionality in a
platform-agnostic way. Mostly it's just a matter of swapping
InterlockedIncrement for AtomicIncrement.
2018-05-24 18:04:50 -04:00
Greg Roth 772f1af14d [linux-port] Compile improvements (helps gcc). (#1307)
GCC5 has a few limitations that later versions do not. The
most pervasive issue is the confusion of scoped operators on enum
names when the name of the enum is shared with a local variable.

The only other issue concerns intialization of a union containing
structs and how many curly braces is enough.
2018-05-24 16:32:06 -04:00
Tex Riddell 8db08cb21e Merged PR 74: Add -exports export1[[,export2,...]=internal][;...] for lib target
Add -exports export1[[,export2,...]=internal][;...] for lib target

- Remove IDxcLinker::LinkWithExports, use -exports option instead
- Added renaming/cloning support to linker
- Added validation and tests
- Fix AV in DxilPreparePasses when patch constant function is shared

ID3D12LibraryReflection:
- Fix shader input type for typed buffer and dimension for tbuffer
- Deterministic function order by name
2018-05-23 06:48:01 +00:00
Tex Riddell a26681c807 Merge branch 'master' into rtmaster
# Conflicts:
#	lib/HLSL/DxilGenerationPass.cpp
#	lib/HLSL/DxilValidation.cpp
#	tools/clang/tools/dxcompiler/dxclinker.cpp
2018-05-22 20:52:03 -07:00
Greg Roth 18610e744c [linux-port] Fix a handful of warnings in headers (#1299)
Just a few warning conditions in a handful of common headers
was producing pages and pages of warning messages. By fixing them,
the output spew is reduced significantly.

Static variables in a header produce a separate variable for every
file that includes it. In many of these, these variables were unused.
Instead, variables used in multiple files should be defined only
once in a source file and declared as extern in the header.

Many unsigned variables were checked to be greater than zero and less
than 3 in HlslTypes.h. If they were somehow assigned a negative
value, it would appear as much greater than 3 in unsigned form.
So we can just check that they are less than or equal to 3.

In Type.h, parammods_begin() was casting its return value to the
proper pointer, but without const, producing an error. The best
part is that the function returned a const pointer. The cast was
just wrong. Adding const silences the warning.
2018-05-18 14:13:55 -04:00
Lei Zhang 8c6d72a2a7
[spirv] Add option to ignore warnings on features without Vulkan support (#1289)
Added -Wno-vk-ignored-features to suppress warnings on features
that are ignored because of no Vulkan support. Examples include
cbuffer member initializer.
2018-05-16 14:32:30 -04:00
Xiang Li 5b41cf7090
Change llvm.dbg.contents into dx.source.contents. (#1287)
1. Change llvm.dbg.contents into dx.source.contents.
2. Fix crash when SemanticIndexVec is empty.
3. Fix case Utf8StringVector is reallocated in MainArgs::operator=(const MainArgs &other).
2018-05-15 14:43:03 -07:00
Ehsan c42d6b558c
Avoid defining types in anonymous union. (#1284)
Fix Linux compile error:
types cannot be declared in an anonymous union.
2018-05-14 13:49:55 -04:00
Tex Riddell ae9f78ff15 Add DxilResourceFlags to DxilRuntimeReflection for UAV Counter/GC/ROV. 2018-05-11 18:44:29 -07:00
Tex Riddell 8335fe4251 Convert DxilRuntimeReflection to pure virtual interface
- removes stl dependency from header
- change namespace from hlsl::DXIL::RDAT to hlsl::RDAT
- use enum class for RuntimeDataPartType to avoid name collisions
- bit of cleanup
2018-05-11 14:19:36 -07:00
Greg Roth 99bbd867d5 Unknown variable in SpanAllocator::Find (#1274)
MSVC is very forgiving of crimes committed in templated functions
and methods of templated classes that never actually get instantiated.
Consequently, the fact that the public variant of Find in SpanAllocator
referenced an unknown variable, seemingly as a copy paste error
was left unnoted. Other compilers are not so magnanimous.

The call to the private version of Find() takes an iterator. The
public Find() searches through the known spans to find the one just
past the range requested by the current pos and size. If it reaches
the end, then the span can be placed at the end safely. If it
fits before some other span, overlap needs to be checked. If the
new span would overlap it's neighbor, another location is needed.
It makes sense to start looking for that location after the end
of the neighbor whose span you just treaded on. So passing the
next iterator into the private Find() makes sense.
2018-05-10 22:40:50 -07:00
Greg Roth 41091e7767 [linux-port] Use standard int literal suffixes (#1276)
Replaces -i64 suffixes with -LL which are said to be equivalent by
MSDN. Both should result in 64 bit behavior.

Additionally, I dropped a superfluous repetition of the class name
on the CheckVectorConditional method of HLSLExternalSource. By all
rights, it should be its own change, but it gets lonely so it came
along for the ride. The repeated class name made some compilers
unhappy and losing it doesn't bother anyone.
2018-05-10 22:39:11 -07:00
Greg Roth 88dd5b61b9 Correct preprocessor dependent expansion (#1270)
The DxilSigPoint.inl file depends on an esoteric distinction in how
different preprocessors expand macros included as parameters to
other macros.

When a macro receives another macro as its argument, different
preprocessors expand these parameter macros differently. MSVC
defers expanding the macro until the macros taking parameters
have been completely expanded. GCC and others expand the parameter
macro just as soon as it can.

At issue is the expansion of the three _## macros: _41, _50, and
_61 which expand to ,#,# respectively. These macros can be passed
into an initial macro that plugs them directly into a function that
takes multiple parameters without issue with any preprocessor.
Regardless of when the _## macro is expanded, it will be interpretted
correctly as passing multiple arguments to the function.

If the _## macro is passed into a parameterized macro that passes
it to another such parameterized macro that takes a single argument,
preprocessor inconsistencies come into play. If the preprocessor
expands the _## macro immediately, instead of passing the parameter
macro directly into the second paramaterized macro, the expansion
of the parameter macro will be passed in, which will be
interpretted as passing multiple arguments to a single-parameter
macro and an error will reseult. If the _## macro is not expanded
until the end, then it is expanded only for the final multi-
parameter function call as the author expected.

The simplest example of this is something like this:

define AB 1,2
define SEC(args) (args)
define FIRST(args) SEC(args)
  FIRST(_AB);

A preprocessor that delays expansion of _AB will expand thus:

FIRST(_AB) => SEC(_AB) => (_AB) => (1,2)

whereas an early expanding preprocessor will expand thus:

FIRST(_AB) => SEC(_AB) => SEC(1,2) => ERROR! SEC only takes 1 arg!

Some of the details of the example might be slightly off, but the
important thing is that the parameter gets expanded at different
times.

The solution to this is to complicate this already long macro.
The middle macro that introduces the opportunity for the _##
macros to be expanded early is DO_ROW, which doesn't do much
except allow for the larger data entry macro, DO_INTERPRETATION_TABLE
to be a bit shorter and simpler. By eliminating DO_ROW and
shortening the DO macro to D, the large table specifying behaviors
is only a little wider and harder to read and it no longer depends
on this inconsistent element of preprocessor behavior.

(I really hope that made sense. I wish I could come up with a
simpler explanation or solution. If any have suggestions for
either, I would be happy to adopt either. Feel free to email me.)

No functional change. Inching further toward cross-platform.
2018-05-10 13:30:02 -04:00
Tex Riddell 817d526250 Fix bad pointers for DXIL_FUNCTION::Resources
- Add all resources up front
- Add resource map to look up DXIL_RESOURCE ptr from Class&ID
- Add resource pointers looked up to function's resource ptr list
- Use pointer to function's resource ptr list, rather than the original
  array used for global storage.
2018-05-04 19:34:28 -07:00
Ehsan d63be91f5c
Minor fixes that make the compilers happier. (#1258)
CDxcTMHeapPtr templated with 2 classes does not exist.

A code block has also been moved so that the caller function knows about
the existence of the callee function. Previous code order is not allowed
by some compilers.
2018-05-03 09:46:19 -04:00
Tex Riddell 8bdf2fef5f Merged PR 69: Add -auto-binding-space option enabling auto-binding for lib targets
Add -auto-binding-space option enabling auto-binding for lib targets

- Added DxilAllocateResourcesForLib pass to allow auto-binding any unbound
resources in a DxcOptimizer pass.
2018-05-02 17:50:41 +00:00
Lei Zhang c82edd6c5f
Change SAL __override to C++11 override (#1212) 2018-04-26 15:18:56 -04:00
Tex Riddell 912e1bc819 Merged PR 67: Fix reflection of raytracing acceleration structure resource. 2018-04-24 21:22:53 +00:00
Lei Zhang 23be4804b6
[spirv] Remove -fvk-ignore-unused-resources (#1246) 2018-04-24 14:47:28 -04:00
Tex Riddell 00302c4dfe DxilRuntimeReflection: avoid possibility of wstring::data() invalidation 2018-04-19 18:48:18 -07:00
Ehsan 8df58eaf32
Fix PSVSemanticIndexes::Get function return value. (#1231)
The value obtained by calling table.Get was not actually returned.
2018-04-18 13:03:04 -04:00
Tex Riddell 5ab102a352 Merge branch 'master' into rtmaster 2018-04-16 15:25:53 -07:00
Lei Zhang a4491dd439
[spirv] Support shifting all sets with -fvk-*-shift N all (#1224) 2018-04-13 15:40:44 -04:00
Young Kim 0777a7a020 Merge branch 'master' into rtmaster 2018-04-10 16:47:47 -07:00
Tex Riddell 0021e993a2 Merged PR 56: Avoid inserting other insts before allocas in several passes.
Avoid inserting other insts before allocas in several passes.

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

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

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

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

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

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

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

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

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1005
2018-02-09 14:31:12 -05:00
Xiang Li ce0bddfc43 Support debug info for linking. 2018-02-08 14:34:10 -08:00
Xiang Li 247f74a647 Support link to lib. 2018-02-07 19:34:26 -08:00
Xiang Li c6915bcccd Support nonUniform. 2018-02-07 14:02:43 -08:00
Tex Riddell 8beb970b51 OP::GetTypeName - use struct name for UDT and return StringRef 2018-02-07 12:28:12 -08:00
Xiang Li fdb8161ccb 1. Not replace local/static resource to handle for lib.
2. Not SROA on resource.
3. avoid unpack for resource.
4. Use value type for createHandleForLib.
5. Move all scalar global resource load to the beginning of function.
   This will stop other pass do optimizations on the loads of scalar global resource.
6. Not remove local resource for lib.
2018-02-06 19:30:24 -08:00
Xiang Li fdf2c31ca6 1. Fix IgnoreHit and AcceptHitAndEndSearch.
2. Support init list for RayDesc.
3. Remove range_id for lib.
4. Update some test.
2018-02-05 18:51:47 -08:00
Xiang Li dc3ad5efe5 Lower createHandelForLib.
TODO: fix nonUniform, resource array fails and remove LinkInfo.
2018-02-05 17:54:08 -08:00
Xiang Li 519938f12e Lower HLCreateHandle into CreateHandleFromResourceStructForLib. 2018-02-05 17:54:07 -08:00
Tex Riddell 15cd5f16e6 Matrix lowering for functions with UDT params preserved.
- Keep track of patch constant functions for later identification
- functions that require input/output signature processing identified
  with IsEntryThatUsesSignatures
- update lib_rt.hlsl intrinsics and naming
2018-02-05 17:54:07 -08:00
Xiang Li 69bc49ffe4 Support System Value retrieval functions. 2018-02-05 17:54:07 -08:00
Xiang Li c45aa784ac Add AcceptHitAndEndSearch, CallShader, CommitHitAndStopRay and change ReportIntersection into ReportHit.
Also change RayTracingAccelerationStructure into RaytracingAccelerationStructure.
2018-02-05 17:54:06 -08:00
Xiang Li eb4b0ae768 Support user define type for dxil operation.
Add RayTracingAccelerationStructure to dxil resource.
Lower ReportIntersection and TraceRay.
2018-02-05 17:54:05 -08:00