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.
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.
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.
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.
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.
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.
- 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)
- 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.
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.
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>
* 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
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
* 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
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
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`.
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#4319Fixes#4377Fixes#4437
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.
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.
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.
- 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.
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
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.
* 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
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>
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.
* 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
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.
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.
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.
* 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
* 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
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.
- 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.
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
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
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.
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
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.
* 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
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.
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.
* 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
* 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.
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>
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...
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.
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
- Fix Barycentric system value translation
- Increment Register for array elements
- Add signature dumping to D3DReflectionDumper, plus other minor fixes
- Dump PatchConstantParameters when mesh shader
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
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.
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.)
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>
* 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.
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>
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
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.
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
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.
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
- 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
* 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
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.
- 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
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.
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>
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#2590Fixes#2713
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.
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
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.
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`.
* 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