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

866 Коммитов

Автор SHA1 Сообщение Дата
Tex Riddell 25307b4c22
Remove unused type annotations (#4689)
Types no longer in use, potentially due to type translation, are still kept
around just because they are referenced in the type annotation metadata.

This change adds a method DxilModule::RemoveUnusedTypeAnnotations() that
removes any type annotations not used by resources or function arguments
or return types.  Types outside this set should no longer need any type
annotations.  This will get rid of extra unused types often left over in
final dxil before.
2022-09-28 13:46:02 -07:00
Tex Riddell 87c30cf38f
Remove ResourceAttribute metadata node from DxilFieldAnnotation (#4671)
Currently, ResourceAttribute is only used to capture resource type information during CodeGen for the annotate handle generated during AddOpcodeParamForIntrinsic.

Going through a metadata node is totally unnecessary, just adding code and complexity.

This change just stores the DxilResourceProperties instead, renaming `*ResourceAttribute` methods to `*ResourceProperties`.
This change also emits the resource properties to new field annotaion metadata in validator version 1.8+ to preserve through serialization.
2022-09-28 13:43:49 -07:00
Joshua Batista dc5949e167
Pull ReplaceDisassemblyText out of DXCTestUtils.cpp (#4687)
ReplaceDisassemblyText dependency on llvm removed in the case that a regex is unnecessary to replace text in the disassembly.
2022-09-27 11:44:29 -07:00
Adam Yang 1eea5457de
Fixed a crash with cbuffer lowering with new poison value mechanism (#4684)
There was a crash when CBuffer vector subscript uses a non-literal index but is replaced with Constant in the optimizer before CBuffer load is lowerd. The CBuffer lowering code expects the constant to be within bounds, since it's translating the GEP to extractvalue. The out of bounds subscript is not correct and should cause an error, but ONLY if it actually exists in the final DXIL.

This change adds a way to emit error that only get emitted if the associated code is not removed by the end of compilation. Instead of emitting an error right away, emit a poison value with line number and error message instead and have it used by the problematic code. If the problematic code is not removed by the end of compilation, then this poison value would also be there, and it's safe to emit a real error based on it.
2022-09-27 11:39:36 -07:00
Tex Riddell 69e6a84ed1
Remove arbitrary run line length limit (#4685)
A very strange sequence of copying the run line to a stack char array of
size 300, where it would not even null-terminate the line if it hit the
limit, seems totally unnecessary, since it's dealing with std::strings
in the first place.
This would truncate and pick up garbage from the stack in the stored run
line when length >= 300 characters - causing the test to fail, of course.
Perhaps some of this is an artifact of some older version of the code.

In any case, this change removes the extra copying step and simply uses
the entire std::string result from std::getline() instead.
2022-09-27 11:07:14 -07:00
Tex Riddell ecf4e0a5c4
RDAT: Revert default to MaxRecordSize for tables (#4682)
On second thought, it's safer to default to the initial version, letting
code that writes to RDAT set strides for newer record versions it actually
uses, rather than breaking RDAT writing code at runtime when versioned
updates are added to the structures.
2022-09-22 16:51:29 -07:00
Tex Riddell 6c7ad3ed90
Add RDAT::RecordTraits::MaxRecordSize to default to newest version (#4680)
Added MaxRecordSize calling DerivedRecordSize that gets specialized for each base in RDAT_STRUCT_TABLE_DERIVED macro to call the derived MaxRecordStride. The most-derived version of DerivedRecordSize will use the default implementation, which is the size of that type.
2022-09-22 07:51:06 +00:00
Adam Yang 826ff8ea4f
Added new DxilPDBInfo definition (#4669)
- Added new PDBI part for PDBs to eventually replace SRCI
- Added new IDxcPdbUtils2 that can read PDBI
- Removed all functionalities to do with GetFullPDB (and its tests)
2022-09-19 02:38:31 -07:00
Adam Yang 8d6100fc60
Separated RDAT creation code into its own library (#4662)
- Pulled out RDAT writing from DxilContainerAssembly into its own helper DxilRDATBuilder
- Changed the way RawBytesPart deduplicates inputs. Instead of using the pointer address, use the data's content as keys in a hash table, then writing it to the final buffer in the order they were inserted.
2022-09-16 15:49:38 -07:00
Chris B b49ecd10ee
Add option to force disabling debug info (#4645)
This is (admittedly) a little hacky. DXC spends a lot of compile time
updating debug information because we always generate it so that we can
generate diagnostics for late-running validation.

This patch adds a new flag -fdisable-loc-tracking, which disables
generating debug locations if the user is not generating debug info.

This flag results in about a 15% compile time improvement on a pessimistic
test case. YMMV.
2022-09-16 16:36:16 -05:00
Adam Yang de70ea29bc
Pulled the zlib compression code into a library (#4660) 2022-09-15 22:43:07 -07:00
Greg Fischer 8d34bcf59d
[SPIRV] Do not include input file in DebugEntryPoint args (#4650) 2022-09-15 17:31:13 -07:00
Nathan Gauër d6eb722516
build: fix include in header files. (#4652)
Building DXC with another build system revealed that some includes
were dependent on headers only available by chance. Adding missing
headers.

Signed-off-by: Nathan Gauër <brioche@google.com>

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-09-15 16:00:29 +02:00
Joshua Batista 0daadd0bc9
Isnormal hlktest (#4505)
* isnan test works on sm 66

* isnan test works on sm 60

* builds fine

* passing, replacement successful

* running without nv adapter works!

* start planning for bit ops

* bit ops compilation done

* prevent const expr eval by forcing dynamic indexing in for loop in xml

* attempt to change callback fn to use dxc over d3d blobs, breaks build

* changed part picker to pick from correct blob, defined IDxc by including dxilcontainer in exectest, etc, test passes

* remove gbv, and pblob=null assertion

* remove once-used functions, comment out double-type cases

* add generic shader callback function, make root signature reassembly optional

* clarify comment on expected results array

* fix problem with accurately translating semantics as a result of removing CompileAndRewriteAssemblyToText

* Use resource init callback to allow inputs to be defined in exectest cpp

* float input, uint output works, test passes

* clean up the xml

* make test multithreaded

* change unsigned int to uint, more conventional

* address PR feedback

* create container builder only when necessary

* remove boolean param determining whether or not root sig is in xml, fix up shader assembly code

* whitespace changes to restart appveyor
2022-09-02 16:15:19 -07:00
Xiang Li 8bf2b087c2
Change /P to match cl.exe /P behavior. (#4624)
/P will write to InputFile.i
/P -Fi filename will write to filename.
/P filename still work with warning.
2022-08-31 22:07:30 -04:00
Greg Roth 38b746c1c3
Initialize all DxilModule members (#4617)
m_bResMayAlias was not initialized, leading to intermittent failures
when it was not explicitly set. The only functional change here is
setting that variable to eliminate that volatility. The other changes
are to move the setting of these simple typed variables to the header to
make it less likely taht future added members will suffer the same fate.

Also in the process, I couldn't resist removing an unused variable added
along with the Payload Access Qualifiers in error and moving the private
methods out of the middle of all the variable members.

Fixes #4616
2022-08-25 19:02:10 -04:00
Nathan V. Morrical 44c767c8e3
[SPIRV] Add support for vk::RawBufferStore (#4573)
* initial code stubbed in to get vk raw buffer store working

* adding in additional intrinsic to support custom alignment of store

* altering test, forgot to add template argument

* some changes to unit test, though not sure checks are correct... and then added support for bool

* updating unit test, correcting some mistakes with the checks

* more changes to unit test

* removing addr variable to see if thats causing tests to fail

* fixing tests

* Updating documentation

* Small typo fix in docs
2022-08-13 13:56:16 -04:00
Jakub Kuderski 24ea9e83d2
Treat matrix load/stores as column major in raw buffers (#4526)
Assume that matrices are stored in the column major order in raw
buffers, e.g., `ByteAddressBuffer` and `RWByteAddressBuffer`.

Add a new flag,`-fspv-use-legacy-buffer-matrix-order`, so that shaders
that depend on the previous matrix order (row major) can opt-out of this
change.

Fixes: https://github.com/microsoft/DirectXShaderCompiler/issues/3370
2022-06-24 17:29:49 -04:00
Natalie Chouinard 20ddfe85f1
[dxil2spv] Remove dxil2spv prototype (#4512)
Revert "[dxil2spv] Print missing runtime errors (#4481)"

This reverts commit 7f8f9acc89.

Revert "[dxil2spv] Command line parsing and output file (#4454)"

This reverts commit 2e49e6809b.

Revert "[dxil2spv] Add additional error checking (#4440)"

This reverts commit 3c1918e21e.

Revert "[dxil2spv] Add FileCheck testing (#4431)"

This reverts commit d6cec44c6f.

Revert "[dxil2spv] Translate DXIL constants to SPIR-V (#4426)"

This reverts commit f00b3c285d.

Revert "[dxil2spv] Translate SV_Position to BuiltIn::Position (#4423)"

This reverts commit b292f9482b.

Revert "[dxil2spv] Translate extractValue and bufferStore (#4404)"

This reverts commit 1d2a68fb3e.

Revert "[dxil2spv] Translate createHandle and bufferLoad (#4389)"

This reverts commit 316b849cfa.

Revert "[dxil2spv] Support shl instruction (#4388)"

This reverts commit 1039a872b7.

Revert "[dxil2spv] Fix build warning (#4371)"

This reverts commit 7ecebb30ef.

Revert "[dxil2spv] Add support for dx.op.threadId (#4354)"

This reverts commit c248a1ee89.

Revert "[dxil2spv] Add initial compute shader support (#4345)"

This reverts commit c701ece61c.

Revert "[dxil2spv] Add error checking to file tests (#4344)"

This reverts commit 9f70135012.

Revert "[dxil2spv] Add passthrough vertex shader and test (#4337)"

This reverts commit c99f5a540e.

Revert "[dxil2spv] SPIR-V validation and related fixes (#4328)"

This reverts commit 495871898e.

Revert "[dxil2spv] Implement simple entry function creation (#4323)"

This reverts commit c29a0c7384.

Revert "[dxil2spv] Read file directly into llvm::MemoryBuffer (#4304)"

This reverts commit aa26bfd052.

Revert "[dxil2spv] Add stage IO variables (#4271)"

This reverts commit 2d5f1863a6.

Revert "[dxil2spv] Add CompilerInstance object (#4229)"

This reverts commit e4cf4867f7.

Revert "[dxil2spv] Add initial testing (#4222)"

This reverts commit c3a61b1cd3.

Revert "[dxil2spv] Construct minimal SPIR-V module (#4216)"

This reverts commit e3da12e19d.

Revert "[dxil2spv] Add basic dxil2spv CI test (#4209)"

This reverts commit 57d4d2b8f1.

Revert "Add initial dxil2spv executable (#4199)"

This reverts commit c45db48d56.
2022-06-16 11:03:52 -04:00
Jakub Kuderski e20926ae2e
[spir-v] Add option to print SPIR-V between passes (#4503)
This debug/development option matches the `--print-all` flag in
spirv-opt or `--print-after-all`/`--print-before-all` in llvm's opt.

The new option can be enabled with `-fspv-print-all`.
2022-06-03 15:41:02 -04:00
Tex Riddell 73c96bfb3c
Add inline GetBlobAsUtf16 methods for back-compat (#4490) 2022-05-31 17:21:53 -07:00
Greg Roth caec6aaf9e
Disallow illegal Atomic targets + propagate consts (#4453)
This change does a few things.

First and foremost, it disallows a number of illegal destination
parameters to atomic operations. This includes SRVs and other const
 values, non-groupshared and non-resource variables, members of
typed resources, and bitfield members of any resource.

In addition, this correctly propagates const information so that they
can be properly rejected and also the information is reflected.
This involves the consolidation and earlier detection of a number of
these failures as well as an expansion of that detection.
Also adds validation checks that the targets are not const and either
UAVs or groupshared address space.

The const errors are produced in clang and manifest as overload
mismatches. The errors for member access of typed buffers, bitfields,
or non-groupshared and non-UAV destinations are generated
as part of the lowering operation. This is where they were before
and easier to replicate though they would be better in codegen.
In some cases, existing errors were moved earlier in the process
and the logic to generate them simplified.

Add compilation and verifier tests for all.

Also adds validation errors for const destination targets and other
invalid targets and tests for the same.

In order to make those tests, I had to give locations to the function
candidate notes for function builtins. This changed a single verifier
test that depended on the locationless notes.

These tests make use of const groupshared variables that are of
questionable utility, but are valid for now.

Incidentally enhances some existing atomics tests to use a more
complex sequence of references and subscripts.

Finally incidentally added some foolproofing for mistakenly comparing
opcodes without taking into account the "table" or namespace that
they belonged to by changing some utility functions in Sema to require
the table as well as the opcode to produce results.

Fixes #4319
Fixes #4377
Fixes #4437
2022-05-16 21:26:21 -07:00
JiaoluAMD 50c0199c17
[spirv] Add FixFuncCallArguments options (#4439)
1) promotion of spirv-opt `FixFuncCallArgumentsPass`
2) add tests for the FixFuncCallArguments for the compute shader and
   export linkage shaders
2022-05-13 14:39:08 -04:00
Natalie Chouinard d6cec44c6f
[dxil2spv] Add FileCheck testing (#4431)
Add FileCheck testing to dxil2spv, and a first static vertex shader test case to test #4426. Also includes documentation for how to add additional tests, and replaces the existing WholeFileTestFixture with regular FileCheck.
2022-05-05 13:20:25 -04:00
Tex Riddell bc3c2db697
Fix interface breaks in IDxcUtils and IDxcLibrary from GetBlobAsWide (#4419)
GetBlobAsWide was added as a new method to the existing interfaces,
but the existing GetBlobAsUtf16 should have simply been renamed to
GetBlobAsWide instead, since that's what GetBlobAsUtf16 actually did.
Otherwise interface compatibility is broken between builds/releases.

If we want to add a GetBlobAsUtf16 which guarantees UTF16 across platforms,
we can add that in a future interface revision.
2022-04-27 12:08:40 -07:00
Tex Riddell e138888302
Dedup semantic names in IO signature parts for valver 1.7 (#4406)
Create new NameOffsetMap that uses StringRef to prevent identical strings from being duplicated. Old behavior is maintained when earlier validator version set by using a *_nodedup map that continues to use a pointer to allow duplicates as previous validators did.
2022-04-21 15:02:36 -07:00
Adam Yang 88d88ae365
Taught DxilValueCache to handle complex switch statements. (#4403)
- Taught DxilValueCache to handle switch statements where each case has more than just a single block.
- Fixed `DxilValueCache::ResetUnknowns` just setting value association to nullptr, which was entirely incorrect. Now it correctly deletes the value association that have been marked as unknown.
- Deleted the idea of 'AlwaysReachable' from DxilValueCache, which is unused, ill-defined, and potentially dangerous.
- Improved the dump function for 'DxilValueCache' for better debugging.
2022-04-21 11:53:45 -07:00
Natalie Chouinard 787245f28f
[SPIR-V] Add option to rename SPIR-V entry point (#4390)
Allow renaming the SPIR-V entry point name from the default HLSL entry
point name with `-fspv-entrypoint-name`.

Fixes #2972
Fixes #4356
2022-04-20 16:04:56 -04:00
Adam Yang 51e69b822d
Moved DxilEraseDeadRegions to after DxilRemoveDeadBlocks (#4397) 2022-04-19 15:09:28 -07:00
Adam Yang 3aaf42a042
Added a pass to use GVN to remove redundant branches without doing code motion. (#4383) 2022-04-12 13:34:27 -07:00
Adam Yang c0676c7ca1
Handling dbg.value pointer case in O1. (#4375) 2022-04-05 12:07:07 -07:00
Natalie Chouinard 68dd2877d7
[SPIR-V] Allow Vulkan 1.1 with SPIR-V 1.4 as a target environment (#4364)
Since we check for the "SPIR-V 1.4 (under Vulkan 1.1 semantics)"
minimum target environment for ray tracing extension use, this change
allows it to be now configured as a target-env via command line options.
Some out of date documentation target environments is also updated,
and improvements are made to version checking to use enums rather
than string comparisons.

Fixes #4313
2022-03-31 16:11:00 -04:00
Jaebaek Seo ad4ebb7d51
[spirv] support signature packing (#4361)
Currently, DXC assigns new locations for each stage variable. When there
are lots of stage variables, the number of locations we use can exceed the
maximum location limit. This commit uses `Component` decoration to pack
signature and reduce the number of locations DXC uses.
2022-03-31 15:38:33 -04:00
Grace Jennings b420332e68
Added a DXC_OUT_REMARKS output kind for display include process (#4336)
* Added a DXC_OUT_REMARKS kind that prints to stdout in dxc.
Moving -Vi and -H displayed include process from warnings to DXC_OUT_REMARKS.

* Adding a Compiler Test to check DXC_OUT_REMARKS output text
2022-03-23 13:28:16 -07:00
Jeff Noyle 90152bd9a7
Pix hull shader debug (#4342)
A couple of minor changes to support PIX shader debugging for hull shaders generated by the 11on12 mapping layer for DXBC originals.

Co-authored-by: Jeff Noyle <jeffno@ntdev.microsoft.com>
2022-03-23 08:51:48 -07:00
Greg Roth 14bc8dab53
Implement Integer Sampling (#4329)
Add support for integer sampling as part of advanced texture ops in
Shader Model 6.7. This includes adding static border colors and allowing
integer resource types to be used by all Sample* operations through
Sema, Dxil generation, and validation when 6.7 is available.

Adds root signature compilation and filecheck testing.
2022-03-15 19:05:00 -07:00
Chris B fb873d0a14
Clean up debug preprocessor macros (#4305)
* Clean up debug preprocessor macros

This change removes the `DBG` macro value in favor of `NDEBUG`, and
also converts many uses of `_DEBUG` with `NDEBUG`.

_DEBUG is set by MSVC when debug information generation is enabled.
NDEBUG is set by CMake debug configurations and by LLVM on all
configurations when `LLVM_ENABLE_ASSERTIONS` is set.

Aligning with LLVM's NDEBUG usage allows a consistent pattern
throughout the codebase.

* Address PR feedback
2022-03-02 14:55:24 -06:00
Tex Riddell 3889cc3fdf
[linux] Fix incorrect REGDB_E_CLASSNOTREG value (#4241)
REGDB_E_CLASSNOTREG was defined to 1, which is a success code for HRESULT.
This value is returned when trying to create an unsupported object with DxcCreateInstance.
Since create appears to have succeeded, it would lead to a deref of a null pointer - segfault.
2022-02-22 09:33:51 -08:00
Adam Yang 2ec23bcaea
Delete dbg.declare in scopes where the alloca is unused (#4272) 2022-02-17 16:59:44 -08:00
Xiang Li e98f8cbc8b
Support resource array in UpdateStructTypeForLegacyLayout on lib profile. (#4266) 2022-02-16 10:33:47 -08:00
Xiang Li d9a790e252
WriteSemanticDefines before clang codeGen to update codeGen option (#4261)
* WriteSemanticDefines before clang codeGen to update codeGen option based on HLSLOptimizationToggles.
2022-02-15 13:29:13 -08:00
Tex Riddell b338314f6e
Implement Shader Model 6.7 (#4260)
Shader Model 6.7 is still a work in progress.
Thanks to multiple contributors at Microsoft for this work.

Added support for additional advanced texture operations, including:
Raw Gather, Programmable Offsets, SampleCmpLevel, and RWTexture2DMSAA.

Added new QuadAny/QuadAll intrinsics to help with writing quad-uniform control flow.

Added [WaveOpsIncludeHelperLanes] pixel shader entry attribute, changing the
behavior of wave ops to treat helper lanes as active lanes.
2022-02-15 11:38:42 -08:00
Greg Roth 75224d820f
Rename UTF16 to Wide (#4242)
In many cases, systems where wchar was represented as 32-bits were being
referred to by types and variables affixed with "utf16" or similar. To
avoid confusion, this renames all such places to "wide".

In a few cases, the conversion were explicitly 16-bit, which wasn't the
intent.
2022-02-14 15:24:40 -05:00
Chris B cb5bb213d8
Refactor HLSLVersion to enum (#4238)
* Refactor HLSLVersion to enum

This change converts HLSLVersion to an enum type `hlsl::LangStd`. Most
of the change is a mechanical appending `hlsl::LangStd::v` to the
integers we previously compared for version checks.

Additionally this change does the following:
* Adds a parseHLSLVersion function to unify parsing code
* Parsing code is converted to an llvm::StringSwitch over the possible
values instead of converting to integer
* Added enum value for `vLatest` so that changing the latest version is
done in one place
* Added enum value for `v202x` which parses from 202x to allow new
language features a place to land

* Updates based on PR feedback
2022-02-10 20:41:55 -06:00
Xiang Li 4452103355
Change getPassName return type to StringRef. (#4247) 2022-02-10 14:14:43 -08:00
Grace Jennings 979cc4a276
Support -setprivate, -setrootsignature, and -Qstrip_priv to compile API (#4230)
* Adding /setprivate, /setrootsignature, and /Qstrip_priv to compile API calls

* Adding setprivate to initial container serialization, change warning to error

* Removed unused variable

* Adding private data blob last, because no gaurantee of aligned size

* Add error messages for conflicting private options
2022-02-08 13:36:55 -08:00
Tex Riddell 0c49f28ebd
Allow unaligned private data size, by keeping it at end of container. (#4239)
Since all other blob parts are expected to be aligned, make sure we always add private data at the end of the container.
Update DxcContainerBuilder to keep private data at the end as well.
2022-02-08 12:14:41 -08:00
Tex Riddell 9d03a00fd7
Fix DxilProgramSignature size alignment. (#4237)
- Maintain compatibility for validator version < 1.7.
- DxilContainerWriter_impl verifies size alignment for all parts, unless created with bUnaligned=true, used for backward compatibility.
- DxilValidation uses NewProgramSignatureWriter(), so bUnaligned is based on validator version in module.
2022-02-07 15:41:54 -08:00
Xiang Li 662a62a8de
Change type of Sentinel to PHINode since it will be PHINode. (#4228) 2022-02-03 13:35:18 -08:00
Xiang Li 392d5b5f3f
Merge resource props for global resource. (#4211)
* Merge resource props for global resource.
2022-01-31 17:23:06 -08:00
Adam Yang dc5eac8d0d
Remove redundant dbg.value instructions (#4182) 2022-01-24 20:22:55 -08:00
Jaebaek Seo 29874c9247
[spirv] support vk::ext_execution_mode_id(..) (#4190)
As a part of HLSL version of GL_EXT_spirv_intrinsics, this commit adds
`vk::ext_execution_mode_id(..)` intrinsic function. In addition, it allows users
to enable capabilites and extensions via `vk::ext_execution_mode[_id](..)`
using `[[vk::ext_capability(..)]]` and `[[vk::ext_extension(..)]]`.

Related to #3919
2022-01-21 14:08:45 -05:00
Greg Roth 437ae1e5b6
Re-enable a swath of DXIL tests for *nix builds (#3888)
These were disabled at a point that the DXC CI didn't reject builds for
failing on Linux, now that they do, we can enable these tests sure in
the knowledge that any changes to them that break on Linux will be
detected and fixed quickly

Fixed *nix error code return. The previous caused an infinite loop of retries.
This definition more accurately identifies the error that has occurred as not
benefiting from repeated attempts

Skip tests and filechecker elements that entirely depend on reflection or
linker interfaces that aren't implemented on *nix yet.

Correct capitalization in a few places to satisfy a case-sensitive filesystem

Detect directories from test include handler. *nix virtual filesystem will try to
load the file using the include handler when performing stat() on a directory.
The test include handler is pretty basic and would provide the next file, leaving
it without a file to offer when the real include came along.
By detecting a name that looks like a dir and returning failure, it
correctly indicates that the file isn't found by the handler and saves
the virtual file for when its needed.

Don't mark non-debug builds as such. The DEBUG define determines which
tests get run. Some of which depend on consistencies that can only be relied
upon in debug builds. So DEBUG is disabled for all non-debug builds.

Correct free of new() memory. Incidental regex allocations were changed for
HLSL to use the global new() operator, but were still freed using the standard
free(), but replacing the default free() with regex_free() allows the default new()
operator to be paired with the default delete() operator

Correct misnamed test flag. The *nix flag was mistakenly called InputFile instead
of InputPath. By renaming it, the ManualFile test can target a specific HLSL file.

Fix misused ArrayRef in legacy GV replacement. The replacement of the GV with
the legacy form used in libraries collected the arguments into an arrayref without
an array to ref, which caused garbage in release builds. Also moved to using end
vars for loops where the elements can get deleted during the loop.

Fix *nix conversion to utf8. When an unknown codepage is found, it tries to convert
to utf16, but that isn't' actually helpful for *nix for a shader codepage derived from
the BOM, which is correctly identified as utf32
2022-01-20 13:53:47 -08:00
Adam Yang 13553274a8
Added debug option to print-after specific passes (#4196) 2022-01-20 00:53:46 -08:00
Jaebaek Seo 46c9735528
Fix build failure caused by clang version 11.1.0 in Linux (#4191)
Add `HAVE_MALLINFO2` flag and use `mallinfo2` instead of `mallinfo`
when `HAVE_MALLINFO2` flag is enabled.
2022-01-18 16:34:06 -05:00
Jaebaek Seo 833aee5446
[spirv] use OpDemoteToHelperInvocation for discard in vk1.3 (#4162)
In Vulkan1.3/SPIR-V1.6, we default OpDemoteToHelperInvocation
instruction for the discard statement. Unlike previous Vulkan versions,
we do not need to enable SPV_EXT_demote_to_helper_invocation extension.

This commit enables `-fspv-target-env=vulkan1.3` flag, but supporting
Vulkan1.3/SPIR-V1.6 is still WIP.
2022-01-05 09:59:01 -05:00
Jaebaek Seo ff270c74b8
Enable printing dependencies of compilation target (#4017)
This commit adds `-M, -MF, -MD` options to print dependencies of
compilation target.

For example, when a HLSL file X includes Y, Z, W files,

$ ./bin/dxc -M -T ps_6_0 -E main X

will print:
X
Y
Z
W

The first line i.e., X is the name of the main compilation target.
Following lines are dependencies for X.

`-MF<file_path>` and `-MD` are the same as the ones supported by Clang.
See https://clang.llvm.org/docs/ClangCommandLineReference.html#dependency-file-generation
2021-12-21 13:42:30 -05:00
Grace Jennings 44b1f00caa
Extend encoding option to specify source encoding (#4109)
Extended current encoding option to also set a default encoding for source files. Includes support for UTF-8 and UTF-16 encoded sources with and without BOMs. The default encoding will be used for the main source file when there is no BOM and the DxcBuffer encoding is not specified. The default encoding will be used for included source files with no BOM.
2021-12-06 11:40:23 -08:00
Joshua Batista d424d2012c
Made nologo option hidden (#4127) 2021-12-06 11:31:41 -08:00
Adam Yang 2f5dec316b
All source files in PDBs interpreted as UTF8 (#4111) 2021-12-02 12:43:48 -08:00
Preston Hamlin 4b4b52ac0c
Fix TextureGatherCmp operand typo (#4075) 2021-11-18 13:12:54 -08:00
JiaoluAMD 552b11b43d
[SPIRV] Add support vk::ext_execution_mode (#4086)
Add support
* vk::ext_execution_mode
* [[vk::ext_storage_class(uint storage_class)]]

This is part of PRs for the
https://github.com/microsoft/DirectXShaderCompiler/issues/3919
2021-11-18 10:21:41 -05:00
Yuriy O'Donnell f836555907
[spirv] Add Vk::RawBufferLoad intrinsic (#4069)
* Only support raw buffer (i.e. HLSL ByteAddressBuffer) style loads of single uint-s
* Always use 4 byte alignment for loads (same as HLSL ByteAddressBuffer)
* Add PhysicalStorageBufferAddresses capability and KHR_physical_storage_buffer extension when needed
* Promote memory addressing model to PhysicalStorageBuffer64 when needed
* Add custom alignment support to SpirvLoad
* Add createUnaryOp() overload that takes SpirvType
* Add getPhysicalStorageBufferType()
* Add documentation and a test case for the new intrinsic
2021-11-17 15:41:54 -05:00
Xiang Li 7d0f3c30ff
Change VectorType to FixedVectorType to help move to newer llvm. (#4085) 2021-11-16 16:56:57 -08:00
Tex Riddell 110a5be03d
Remove LTO and ArgumentPromotion passes (#4078)
LTO was unused, and ArgumentPromotion would not have any effect on DXIL
until you use noinline, and it might decompose HLSL/DXIL objects, which
could break things.
2021-11-12 18:46:58 -08:00
Xiang Li 7c04a557dd
Support phi on dynamic resource. (#4052)
* Support phi on dynamic resource.
2021-11-05 12:43:54 -07:00
Chris B 6ee2b1c9c6
Add back HlslIntrinsicOp.h (#4062)
This header is also packaged up as part of the interface for handling
DXIL, so it needs to live in-tree.
2021-11-04 19:44:55 -05:00
Chris B 39d6e7fc55
Require Windows 7 Everywhere (#4057)
Some of the LLVM APIs were expecting Windows XP support, while other
places in the code were going with whatever your SDK configured.
This should get things consistent and avoid mismatches in the Windows
headers.
2021-11-03 10:58:04 -05:00
Chris B 6cf0a6f7df
Automate generating of intrinsic code (#4001)
* Automate generating of intrinsic code

This change removes generated code for HLSL and DXIL intrinsics and
sets up the build system so that it will generate the code and
automatically regenerate it on changes to any of the generation scripts
or input files.

* Covering the last few generated files

* Move namespace priting into hctgen

I somehow missed that the open namespace was in manual code and the
close was in the generated code...

* Fix pix passes generator

* Work around missing autocrlf on Windows checkout

*shakes fist* AppVeyor...

* Actually pass through --force-lf
2021-11-02 13:43:47 -05:00
Adam Yang ce6d208234
Added -binding-table-define (#4044) 2021-11-01 18:46:13 -07:00
Greg Fischer 4652250d54
Add Shader.DebugInfo.100 support for DebugSourceContinued (#4030) 2021-10-27 12:28:01 -04:00
Chris B 0a0ed9f50b
Make it possible to enable building LLVM & Clang unit tests (#4020)
* Changes to get LLVM unit tests building

This change gets the LLVM unit tests building again and running through
LIT via the `check-llvm-unit` target.

This change does not have the tests passing! Subsequent changes will
get the unit tests passing. This change also disables some tests where
the LLVM code is no longer used and making those tests work will
require substantial effort.

* Changes to get Clang unit tests building

This change gets the Clang unit tests building again and running
through LIT via the `check-clang-unit` target.

This change does not have the tests passing! Subsequent changes will
get the unit tests passing. This change also disables some tests where
the Clang code is no longer used and making those tests work will
require substantial effort.

* A few extra Windows fixes

This adds some missing APIs to the Windows Filesystem code and adds an
option to hctbuild to enable building the LLVM & Clang unit tests.

* Disable libClangFormat tests

These tests are a bit gnarly to repair... unless we really start using
the format library we probably just want to disable these tests.
2021-10-20 12:32:45 -05:00
Greg Fischer 5f35caa480
[spirv] Add support for NonSemantic.Shader.DebugInfo.100 generation (#4006)
This commit generally only adds those instructions that intersect with
OpenCL.DebugInfo.100, although it does also add generation of
new DebugFunctionDefinition to tie DebugFunction to function.

Co-authored-by: baldurk <baldurk@baldurk.org>
2021-10-19 14:40:59 -04:00
Xiang Li e39defba07
Add rewrite pass to create global cb. (#4000)
* Add rewrite pass to create global cb.
2021-10-15 14:41:25 -07:00
Chris B b392672be3
Fix llvm::BitVector::resize (#4008)
This bug has been latent for a long time, and was exposed by getting
the unit tests running again. When resizing the buffer we were not
copying all the bits. That's bad...
2021-10-14 15:18:03 -05:00
Adam Yang 029634871a
-Zs now appears next to Zi in the help text (#3996) 2021-10-11 16:45:17 -07:00
Adam Yang 6a3ae13ff4
Od fixes sep2021 (#3990) 2021-10-05 03:28:21 -07:00
Jeff Noyle d23ede6fc5
PIX: Changes to run PIX passes on libraries. Also add raygen shader debugging prolog (#3985)
These changes are a result of prototype work in PIX to support shader debugging for DXR,, which was an exercise to figure out how to support libraries in general in PIX. These changes are the result. It's all about iterating over all the library functions, rather than "the" entry point function.
In addition, to have something concrete to submit to a driver, there's the addition of codegen for the shader debugging "prolog", which chooses at runtime whether or not to emit instrumentation data for a given shader invocation based on its (in this case) thread id. This last is not yet ready for production in PIX, in that it is necessary but not sufficient to enable DXR shader debugging.
2021-10-04 15:37:50 -07:00
Greg Roth c26f369b5c
Enable -HV 2021 (#3982)
Enables the associated feature flags when 2021 is selected. Also adds a
feature flag for bitfields.

Add to all feature tests a variant that uses -HV 2021

Made some small changes to a template test that relied on vector
operands with binary logical operators
2021-09-29 19:00:44 -07:00
Chris B 8a1e9700e2
[NFC] Add additional helper methods for DXT::ResourceKind (#3975)
* Added `IsAnyTextureArray`, `IsAnyTextureCube`, and `IsArrayKind`
helper
methods.
* Added test case for all non-trival `Is...(ResouceKind)` methods
2021-09-29 15:17:47 -05:00
Adam Yang abbcb9f14e
Fixed an assert when a dxil error happens with global variable (#3974) 2021-09-28 10:09:28 -07:00
Greg Roth f008085313
Merge pull request #3968 from microsoft/merge-hlsl2021-master
Merge hlsl2021 master
2021-09-23 10:51:09 -06:00
Tex Riddell 538c203a5b
Fix bugs in signature reflection, add signatures to dumper and tests (#3961)
- Fix Barycentric system value translation
- Increment Register for array elements
- Add signature dumping to D3DReflectionDumper, plus other minor fixes
- Dump PatchConstantParameters when mesh shader
2021-09-21 14:13:00 -07:00
Greg Roth 693103f39d Merge remote-tracking branch 'origin/master' into hlsl-2021 2021-09-17 14:39:31 -07:00
Jaebaek Seo 555f813c4f
[spirv] add -fspv-reduce-load-size option (#3931)
Since loading a big object takes the memory pressure, reduction of the
load size can have some performance benefit. In particular, it is
useful for mobile GPUs. `-fspv-reduce-load-size` removes
OpLoad/OpCompositeExtract of struct/array types by running spirv-opt
--reduce-load-size pass.

Fixes #3889
2021-09-07 23:32:16 -04:00
Xiang Li 5ae4b02c38
Fix issue when updateCounter for dynamic resource, also remove createHandleForLib on handle type when not a library. (#3935) 2021-09-07 10:24:42 -07:00
Adam Yang 2bc41323ff
Added binding table file to specify resource binding (#3843) 2021-08-26 11:56:36 -07:00
Jaebaek Seo 7793f5d3c1
Initial support of operator overloading (#3859) 2021-08-26 12:26:12 -04:00
Grace Jennings 0c2c998326
Add --version flag to print dxc version info (#3912)
* basic -version flag from -? flag

* now --version and added to -? text
2021-08-24 09:53:13 -07:00
Jeff Noyle 5d63d48f44
PIX: Add thread ID to amplification shader payload (#3904)
This change is required to enable PIX to reconstruct mesh shader output data correctly. Without knowing the thread id of the AS thread that launched the mesh shader threads, we don't know which probably-a-mesh to attribute each MS's output to.
2021-08-13 14:04:46 -07:00
Tex Riddell 9c504e3754
Add -enable-short-circuit option for operators &&, ||, :? (#3892) 2021-08-06 20:59:13 -07:00
Tex Riddell cb6b85c6f9
-strict-udt-casting prevents implicit casts between unrelated structs (#3891) 2021-08-02 18:38:52 -07:00
Greg Roth 6d2d19a179 Merge remote-tracking branch 'origin/master' into hlsl2021 2021-06-17 12:39:25 -07:00
Jeff Noyle ec7e332308
PIX: Check SM66 handle types for dynamic indexing (#3819)
While working on another issue I noticed that I had forgotten these cases.
(PIX uses this pass to detect non-constant indexing into resource arrays in order to decide if it should run the whole "shader access tracking" pass to check for out-of-range access etc. So it was failing to detect dynamic indexing and so could choose not to run the SAT pass.)
2021-06-11 14:50:24 -07:00
Atte Seppälä 12b81409bb
Remove execinfo.h include in WinAdapter.h (#3797)
This small change makes it possible to build and use
DirectXShaderCompiler on Android, at least on arm64-v8a.

execinfo.h does not exist in Android toolchain. However it is
only used by clang-hlsl-tests which can be disabled from the build.

CaptureStackBackTrace is not used in any files
compiled in non-Windows builds. This is because CompilerTest.cpp,
where it was used, is disabled from non-Windows build at the moment.

Co-authored-by: Atte Seppälä <atte.seppala@ul.com>
2021-05-27 15:51:23 -07:00
Tex Riddell e6ba792e2d
Fold bitcast-to-base into GEP in MergeGepUse, plus refactor and resource fixes (#3801)
* Fold bitcast-to-base into GEP in MergeGepUse, plus refactor

  - Fixes case where bitcast isn't eliminated under -Od.
  - Fix issue with constant GEP path that was unintentionally using GEP
    from failed prior branch.
  - Change to worklist pattern, which simplifies things.
  - One case wasn't handled, which was going to complicate code:
    GEP -> bitcast -> GEP would combine bitcast -> GEP, but not combine
    outer GEP with the new one.
  - Add dxilutil::TryReplaceBaseCastWithGep that simply replaces if it matches.

* Fix cbuffer layouts when resources are in structs

  - keep track of resources in type annotation information
  - fix cbuffer packing locations for things around resources
  - when translating struct for legacy:
    - remove resource fields from struct types
    - properly replace HLSL type
  - remove unused structs and annotations
  - don't produce type annotations for silly things
  - fix other random bugs found along the way

* Fix ValidateVersionNotAllowed test issue with external validator

  It turns out the test wasn't correct in assuming dxil version reported was
  the one it should expect to be supported by the validator, since that
  represents the compiler version.  The validator version constrains the
  dxil version supported by the validator, not the compiler version.
  See comments in the test for details.

* Fix error reporting in ValidationTest::RewriteAssemblyToText

* Fix tests for translated structs and hostlayout name change.
2021-05-26 20:17:50 -07:00
Marijn Suijten 0669cbfaf5
[Linux] Import some LLVM fixes for GCC warnings (#3794)
Original LLVM changes included in this change:

* DxcSupport/dxcmem: Fix clang dtor-name warning

   ../lib/DxcSupport/dxcmem.cpp:46:55: warning: ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~' [-Wdtor-name]
       g_ThreadMallocTls->llvm::sys::ThreadLocal<IMalloc>::~ThreadLocal();
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
                                                         ::ThreadLocal

* Fix few g++ 8 warning with non obvious copy object operations

Reviewers: dblaikie, dexonsmith

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D50296

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339367 91177308-0d34-0410-b5e6-96231b3b80d8

Picked from: 425788d8b5.patch

* Disable GCC 9's -Winit-list-lifetime warning in ArrayRef

Summary:
This is a new warning which fires when one stores a reference to the
initializer_list contents in a way which may outlive the
initializer_list which it came from. In llvm this warning is triggered
whenever someone uses the initializer_list ArrayRef constructor.

This is indeed a dangerous thing to do (I myself was bitten by that at
least once), but it is not more dangerous than calling other ArrayRef
constructors with temporary objects -- something which we are used to
and have accepted as a tradeoff for ArrayRef's efficiency.

Currently, this warnings generates so much output that it completely
obscures any actionable warnings, so this patch disables it.

Reviewers: rnk, aaron.ballman

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70122

Picked from: 6c2151bf4c.patch

Co-authored-by: David Carlier <devnexen@gmail.com>
Co-authored-by: Pavel Labath <pavel@labath.sk>
2021-05-26 19:09:51 -07:00
Greg Roth 6999a51fe9
Update legacy structs during compile (#3659)
Instead of bailing out when compiling libraries without full 16-bit
support enabled, we update the struct type for legacy layouts and
replace the associated ops to the new types where necessary.

This results in converted types named with a leading "dx." prefix that
is an array type which often isn't expected in validation where it newly
shows up, so a change there to permit these types to pass.

As an incidental, remove function annotations when appropriate
regardless of full 16-bit enabling. There was no reason to make this
depend on that setting.

Adapt tests to the new types. Library targets may now produce a
dx.alignment* type instead of the user-specified type.

The prefix was confusing code that assumed it meant it was a builtin
type. Removing it allows reverting some of the hacky changes to evade
the problems that caused.

also fixes a couple mistakes in DxilLowerCreateHandleForLib and corrects
redundant inclusion of dxilmodule and module in params to
UpdateStructTypeForLegacyLayout

alignment.legacy wasn't really describing the current intent of the
modified type. Since the type is altered to match the layout of the
host, it's here renamed "hostlayout."

Fixes #3058
2021-05-25 13:12:26 -07:00
Tex Riddell 002f2e1db5
Fix bugs with ConstantBuffer resource object usage (#3796)
ConstantBuffer<> and TextureBuffer<> resource objects were not being
handled when the objects themselves were used instead of just reading from
them.  Examples are passing to/from functions, but also simply an extra
layer of ParenExpr.  For simple ParenExpr case, it's easy to just drill
through, but this isn't possible for other cases.  More temps need to be
potentially marked, so MarkRetTemp/MarkCallArgumentTemp is unified into
MarkPotentialResourceTemp which is also used for temp created during
EmitAggExprToLValue.  CBuffer init code in FinishCodeGen also needed
fixing.  When replacing resource users with subscript operator, users of
the actual resource object need the original HL resource type, which is
constructed through the HL HandleToResCast and stored to an alloca for
pointer users.

Fixed MutateResourceToHandle pass for CBV/TBV, and for HandleToResCast
case.

Fixed PatchTBufferLoad issues with AnnotateHandle and library cases.

Also added a pass to cleanup doubled AnnotateHandle calls leftover after
inlining.

Along the way, noticed a global init translation bug potentially impacting
the library case, but don't yet have fix implemented, or a specific test
case hitting this.

Also noticed that there's a whole special case for empty cbuffer that gets
created, but I don't think it's actually necessary.  Other code may need
adjusting, but it should be fine to skip emiting of the special opaque-
typed global value for the empty, unused cbuffer.  Added some FIXME
comments for this, but have not tried to make this change yet.
2021-05-24 12:55:03 -07:00
Adam Yang 37e802cd07
Fixed some debug locations with line 0 (#3784) 2021-05-20 04:30:26 -07:00
Vishal Sharma 742657ade4
Add option to override semantic defines (#3766) 2021-05-11 21:43:15 -07:00
Greg Roth 61bd18526d
Allow variable offsets to gathers (#3764)
Mostly reverts the change that added an error when offsets were not
immediate or out of range for gather operations. More research suggests
this error was not required and it broke some existing shaders

Fixes #3738
2021-05-11 17:04:58 -07:00
Adam Yang b44890fe1e
Fixed linker not putting subprogram of inlined functions into CU (#3716) 2021-05-03 12:31:14 -07:00
Adam Yang 9a8816ba73
Added an pdb writer overload that doesn't take any input blobs (#3715) 2021-04-28 15:13:17 -07:00
Helena Kotas af088513ab Merge of branch 'master' of https://github.com/Microsoft/DirectXShaderCompiler into merge-master-hlsl-2021 2021-04-21 17:25:59 -07:00
Xiang Li bd38504d5e
Add -dumprs to dxa. (#3703) 2021-04-21 15:31:44 -07:00
Xiang Li 6775e94ef1
Bump shader model to 6.7 (#3679) 2021-04-10 12:24:49 -07:00
Xiang Li 5fa34d1fd6
Save root sig for entry for lib. (#3669)
* Save root sig for entry for lib.
2021-04-07 21:32:17 -07:00
Adam Yang 1f6d1facbf
Fixed a potential codegen difference with Zi (#3665) 2021-04-06 13:36:03 -07:00
Vishal Sharma 3daa429525
Update BaseAlignLog2 field in ResourceProperties for StructuredBuffer (#3652) 2021-04-01 04:55:31 -07:00
Adam Yang c8123cf7f7
Fixed a bug in pdb where -W[...] type options are split into two tokens (#3646) 2021-03-30 14:26:11 -07:00
Greg Roth cf135fa88b
Allow removal of trivially dead convergent marker (#3640)
Failing to remove this because it is marked as having side effects so it
can prevent unwanted code movement resulted in trivially dead code being
retained unnecessarily because the marker isn't removed until after dead
code elimination. By allowing its removal when the operation that needed
it has been removed so it has no users, this dead code can be
eliminated.
2021-03-29 17:54:28 -07:00
Helena Kotas 555ca24474
Add load library error to dxc exception handler; add header with exception error codes (#3639)
* Add load library error to dxc exception handler
* Add header with exception error codes
2021-03-26 23:37:41 -07:00
Greg Roth 6b44d611f7
convert recoverable exceptions to c++ (#3636)
Instead of raising structured exceptions for unreachable and fatal
errors, raising c++ exceptions allows returning an error code and
getting a useful message instead of requiring a structured exception
handler to catch it.

Add cast failure assert
2021-03-26 19:56:42 -07:00
Tex Riddell 6244ab8337
Validator/Dxil version error improvements (#3623)
- Move validator/dxil version checks up-front
  These should fail first rather than side effects of trying to validate
  details of a version we don't support.
- Improve message for unsupported validator or dxil version
  These errors are most likely if compiling separately from validation
  and failing to override the validator version properly, or running on
  an external validator that doesn't support a newer dxil.
- Use dxil version from metadata for DxilModule when loading,
  rather than just setting it to minimum based on shader model.
- Remove TODO from validator messages that shouldn't be there
2021-03-25 14:03:31 -07:00
Helena Kotas 53b2ad9ffd
Add d3d12TokenizedProgramFormat.hpp header from the Windows Driver kit (#3617)
* Add d3d12TokenizedProgramFormat.hpp header from the Windows Driver kit.

The header is now open source under the University of Illinois Open Source License.
This change reduces the DX compiler projects dependencies on WDK to TAEF testing
framework only. That means the project can be built without WDK if tests are
excluded from the build (HLSL_INCLUDE_TESTS cmake option to OFF).

Fixes #2965
2021-03-25 12:19:38 -07:00
Adam Yang 78cf9bde8f
Added deleted constructor for null type for StringRef (#3618) 2021-03-24 18:08:38 -07:00
Adam Yang 86104f415f
Internal validator error messages don't need /Zi anymore. (#3606) 2021-03-20 19:21:26 -07:00
Greg Roth 9b475a7fa3
Add dxc exception handler (#3604)
The most common cause of internal compiler errors are access violations
or stack overflows. This registers an exception handler in dxc.exe for
these cases that are otherwise unhandled. It prints a simple message
for these errors and passes the exception along.

In case this is unwanted for some reason, a hidden disabling flag is
added as well.

Adds LLVM builtin exceptions for assert, fatal, and unreachable. Adds a
default message for exceptions not explicitly addressed.

Alters behavior of llvm_unreachable so it always raises an exception
regardless of compiler support for unreachable hints.

Reports errors using fputs instead of std::cerr to ensure that no
allocation is necessary. Custom output is performed in a static array
that is output with fputs.
2021-03-18 20:37:21 -07:00
Adam Yang e8372b9b9a
Fixed arg pairs not correct for old source in module pdbs (#3599) 2021-03-18 01:33:06 -07:00
Adam Yang 640c9af748
Added way for caller to replace args in PDB utils (#3595) 2021-03-17 12:38:11 -07:00
Xiang Li de09119850
Add -link to dxc. (#3577)
* Add -link to dxc.
2021-03-15 09:09:58 -07:00
Tex Riddell 0b686f347b
FileChecker improvements: VFS, %dxl, FileCheck -D, error reporting (#3576)
- VFS captures output files for duration of test, enabling:
- %dxl test IDxcLinker
- add -D to FileCheck args to supply defined variables
- report failing RUN command when not consumed by FileCheck or XFail
2021-03-14 22:13:26 -07:00
Michael Haidl 1db765ea9c
DXC extension for DXR Payload Access Qualifiers (#3171)
This extension adds qualifiers for payload structures accompanied with semantic checks and code generation. This feature is opt-in for SM 6.6 libraries.  The information added by the developer is stored in the DXIL type system and a new metadata node is emitted during code generation. The metadata is not necessary for correct translation of DXIL, so it may be safely ignored, but it provides hints to unlock potential optimizations in payload storage between DXR shader stages.
2021-03-14 18:31:40 -07:00
Adam Yang 92e3f2a6be
Fixed a bug reading version string from PDB. Implemented IDxcVersionInfo3 for DxcCompiler. (#3570) 2021-03-12 19:35:15 -08:00
Xiang Li 48b2c4611a
Support -export-shaders-only for linker. (#3571)
* Support -export-shaders-only for linker.
2021-03-11 23:49:28 -08:00
Adam Yang 95850daf8f
Made -Zs the flag for slim PDB. Added -Qpdb_in_private. (#3541) 2021-03-09 19:06:52 -08:00
Greg Roth 226a660a15
Merge pull request #3538 from microsoft/master
merge branch 'master' into hlsl-2021
2021-03-04 15:32:56 -07:00
Tim Corringham a342872a17
Template support (#3533)
Template support for HLSL
- can be enabled using command line option -enable-templates
- supports both function templates and aggregate templates
- support is more or less equivalent to that in C++98
- use of template features and syntax introduced by C++11 or later may
  not be handled gracefully

Co-authored-by: Tim Corringham <tcorring@amd.com>
2021-03-03 11:16:53 -08:00
Tex Riddell 5bdf3574bc
Revert "Report error for unsupported types of SV semantics (#3043)" (#3532)
This reverts commit bece3d4faf.

Revert system value type checking code due to regressions.
Will re-merge once it's fully verified fixed.
2021-03-02 21:24:25 -08:00
Greg Roth 3bd5f9ccfa
Errors on non-immediate load/gather offsets (#3283)
Gather operations that take four separate offsets are meant to allow for
programmable, non-immediate values. This removes them from the immediate
and range validations by giving the immediate versions their own opcodes
For these intrinsics and loads, errors are generated when offsets are non-literal
or out of range. These largely use the slightly altered validation paths that the
sample intrinsics use.

Reword error when texture access offsets are not immediates to be
more all encompassing and grammatical.

Incidentally remove duplicate shaders being used for the validation
test from the old directory while identical copies in the validation
directory went unused. Redirected validation test to the appropriate
copies. This is consistent with the test shader re-org's stated intent

Sample operations have a maximum of 3 args, but gather has a maximum of
two since it always operates on 2D images. So gather operations only
pass in two offset args to the offset validation, which resulted in an
invalid access.

Rather than adding a specialized condition to evade this, just iterate
over the number of elements in the array. For sample it will be 3 and
for gather 2 and it will still check for expected undefined args
appropriately.

For the offset legalization pass, the opcode is used to determine the
start and end of the offset args

Only produce the loop unroll suggestion when within a loop

Base error line on call instruction instead of source of the offset

Sort by location in source when possible and remove duplicates

Adapt tests to verify and match these changes

Fixes #2590
Fixes #2713
2021-03-02 18:42:09 -08:00
Tex Riddell 19360a8fa6
Validate CBuffer size to max of 65536 bytes (#3507) 2021-03-02 16:34:35 -08:00
Adam Yang a7770e66eb
Added IDxcVersionInfo3 for custom version string (#3517) 2021-03-02 15:19:04 -08:00
Adam Yang c7d8ac5793
Added recompile function on PdbUtils that just hands back compilation result. (#3529) 2021-03-02 15:18:44 -08:00
Greg Roth 1ca779732f
Correct atomics on heap usage for libs (#3525)
The previous shader flag code failed to account for the library-specific
handle creation function
2021-02-28 16:02:44 -08:00
Greg Roth 62f390cb58
Set shader flags for dynamic resources (#3521)
Set shader flags for resource and sampler descriptor heap indexing based
on the CreateHandleFromHeap call and its ShaderHeap argument
2021-02-27 10:37:57 -07:00
Greg Roth 3f9db446e7
Correct 64-bit atomics on heap resource flags (#3520)
Left a few out
2021-02-26 22:58:33 -08:00
Greg Roth c3f9997709
64-bit atomics usage resource flags (#3518)
When a resource comes from a binding, we can't determine if it is on a
heap or not, so we set a flag on it to let the runtime sort it out.

When a resource comes from the heap directly, we know it's on the heap
so we set the shader flag to check for platform support.
2021-02-26 19:55:59 -08:00
Greg Roth deacf03358
Add used by atomics resource flag (#3513)
To identify resources that are used in 64-bit atomics operations in order to catch invalid use of heap resources
2021-02-26 11:25:28 -08:00
Vishal Sharma bece3d4faf
Report error for unsupported types of SV semantics (#3043) 2021-02-25 16:38:12 -08:00
Greg Roth 5fbaf73466
Error for groupshared outside of compute (#3472)
groupshared variables shouldn't be allowed outside of compute and
compute-like shaders. This adds a validation error when such
variables are used.

Add shader mask where groupshared are used

Correct several tests that used groupshared incorrectly

Incidental fix to atomics tests where the special case initializations
might have allowed the threads that failed to write to proceed
before the write took place and read the improperly initialized values

Changed up the assignments to avoid write collisions and be more
readable

Fixes #2603, #2677
2021-02-24 15:22:29 -08:00
Adam Yang b63b179587
Fixed pdbutils recompilation failure when the main file is in a relative path. (#3486) 2021-02-23 00:10:41 -08:00
Greg Roth 72e46b3709
Fix crashing from null elements producing errors (#3487)
Under certain rare circumstances, it is possible for errors to be
reported for function or global variables that are null.

This eliminates the absolute necessity for a non-null function or GV by
passing in the context needed to report any error. It also avoids some
of the cases where trying to get a debug function would give a null
which would replace the non-null function.
2021-02-22 14:56:54 -08:00
Jaebaek Seo f913bde7d0
[spirv] support optional use of base vertex instance (#3478)
In DX12, `SV_InstanceID` always counts from 0. On the other hand,
Vulkan `gl_InstanceIndex` starts from the first instance. Thus it
doesn't emulate actual DX12 shader behavior. To make it equivalent,
we can set `SV_InstanceID = gl_InstanceIndex - gl_BaseInstance`.
However, it can break the existing working shaders (i.e., compatibility
issue). We want to provide an option for users to choose what they
exactly want by `SV_InstanceID`. This commit adds
`-fvk-support-nonzero-base-instance` option. If it is enabled, it emits
`SV_InstanceID = gl_InstanceIndex - gl_BaseInstance`. Otherwise,
`SV_InstanceID = gl_InstanceIndex`.
2021-02-19 14:30:39 -05:00
Adam Yang 98ddd699de
Added shader reflection part to source-only PDB. (#3467) 2021-02-18 13:32:13 -08:00
Adam Yang 38e4ec9593
Added an internal interface to set a compiler on PdbUtils. (#3452) 2021-02-11 12:39:37 -08:00
Helena Kotas 6e4e1f8b93
Enable and fix warnings on execution tests (#3424)
* Move warning enabling pragma to cpp files before includes and fixed warning that popped up
Whitespace change in ShaderOpArithTable.xml

* Enable and fix warnings on execution tests

* One more warning
2021-02-03 11:46:10 -08:00
Adam Yang 6cd93dfe40
Added option to not generate nops (#3419) 2021-02-01 15:57:53 -08:00
Adam Yang 01135442bb
Fixed the parameter for QuadReadLaneAt incorrectly being const (#3421) 2021-02-01 15:44:12 -08:00
Tex Riddell 3b99af518d
Implement fallback path for IsHelper on SM < 6.6 (#3408) 2021-01-29 11:05:05 -08:00