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

407 Коммитов

Автор SHA1 Сообщение Дата
Tristan Labelle 088c3cf27b Fix debug info for the return value of resource vector loads. 2019-03-15 16:44:30 -07: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
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
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
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 e9dac9bd79
Fix implicit unique_ptr to bool conversion error when compiling with GCC. (#1720) 2018-11-19 16:19:19 -08: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
Tex Riddell 532368e9a1
Fix remaining HLModule/DxilModule dependencies from llvm::Module, etc. (#1656)
- Use one callback for global removal - Function and GlobalValue use this
- Share callback for HLModule and DxilModule, transfer is handled by
  setting callback on construction and checking pointer before clearing
2018-11-01 16:38:33 -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