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.
* move entry point default so it doesn't assume dxilcontainer needs shader source header
* ensure override also sets entry point to default after clearing it
* address feedback, excluding tests
* add compiler test case for entry point default with Qsource_in_debug_module
* llvm: fix UB when building with sized-deletion ON
This issue can show up with compiling DXC with libasan.
It has been fixed upstream:
21c303e9ea
Signed-off-by: Nathan Gauër <brioche@google.com>
* [spirv] specify correct SPV env for disassembling
When DXC finishes generating SPIR-V, the binary is disassembled and
printed to stdout.
The target env was hardcoded to Vulkan1.1, meaning disassembly would
fail if we tried disassembling Vulkan1.2+ SPIR-V.
Fixes#4067
Signed-off-by: Nathan Gauër <brioche@google.com>
* [spirv] Fix Layer & ViewportIndex ext in 1.2+
Back in Vulkan1.1, ShaderViewportIndexLayer was required to use
SV_RenderTargetArrayIndex. This was promoted in VK1.2:
https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_shader_viewport_index_layer.html
Sadly, DXC didn't checked the target SPV environment, and always
requested the extension. This commit addresses this.
Fixes#4067
Signed-off-by: Nathan Gauër <brioche@google.com>
Signed-off-by: Nathan Gauër <brioche@google.com>
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>
This adds a new option to the build to enable link-time optimzied builds
of DXC. On Windows with MSVC this seems to give about a 4% runtime
performance boost on my one locally run test case... and on Linux I'm
seeing about 6% on that same locally run test case.
LTO/LTCG is enabled by default for "Official" builds.
It's free performance so yay :D
Version string in metadata no longer old clang string or stale
HLSL_FIXED_VER. Now it's derived from the defines in dxcversion.inc that's
generated by gen_version.py or copied from fixed version file.
Addition of toolname in latest-release.json allows for this to be changed
for every build out of a branch or project that sets this. It defaults to
"dxcoob" which matches the dxc "Out Of Box" name used for releases before.
The fixed version file can also define the HLSL_TOOL_NAME,
HLSL_LLVM_IDENT, and HLSL_VERSION_MACRO to override these.
* Skip test when using BDA, move check logic up as high as possible
* remove unused variable to prevent build breaks
* remove unnecessary log, set output settings at top matching other tests
* remove logging that somehow reappeared?
* 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
The DebugFunctionDefintion in the user's entry function called
by the wrapper is omitted. All other DebugFunctionDefinition
instructions are still generated.
This is done because inlining during legalization omits
inlining the DebugFunctionDefintion because its function
no longer exists. This results in all DebugFunctionDefinitions
being eliminated for HLSL because every function is inlined into
the wrapper function.
The solution is to generate the entry point function's
DebugFunctionDefinition in the wrapper to start with.
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
* Adding more testing for diagnostics
* Added more diagnostic testing and changed some to internal compiler errors
* cleaning up HLOperationLower.cpp and HLSignatureLower.cpp diagnostics
* Update tests and error messages
* Reverting GV mapping to user errors with TODO for tests
* Add error message var
Includes all the Raster Order Views types in the check for UAVs and add
a test that exercises all of them, verifying they can be assigned
properly.
Followon to fix#4581 for bug #4578
Fixed when there are multiple functions with loops that can't be unrolled at
the point of doing [unroll], the unroll pass crashes because it didn't clean up
memory between runs.
* [SPIRV] Do not create counter for RWStructuredBuffer by default
Defer creating counter for RWSBuffer until Inc/DecrementCounter method
is invoked.
Fixes#4569
* allow array sizes defined by min or mul ops to not be treated as variable length
* add accompanying test
* remove mul attempt because of dxil assertion
* remove mul test, add const qualifier
* add const to cast
* update variable names, update check string
* 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
vs2022 installs in a different location, so finding cmake requires a
slightly different path. Variable assignment in batch files is ugly.
Duplication of code slightly less ugly.
Mostly done by @tex3d
Also invert loop order to avoid having to repeat the loop over the
different version variants
The HLSL type system was failing to recognize the
RasterizerOrderedTexture2D type as a resource type. As a result, it was
not getting annotated properly during UAV codegen and when the time came
to assign a struct member of that type, there was no declaration to use
to do so. This resulted in a validation failure when used as a struct
member.
By simply adding it to the list of detected resource types, the
assignments are successful.
Fixes#4578
FXC permitted unbound multidimensional resource arrays such as
Texture2D<float> iAmAnArray[][3];
The DXC exception for unbound array errors when used with resources
failed to drill through any additional arrays. As did the code to create
a constant buffer view for cbuf and tbuf and the disassembler
Adds involved test for correct and incorrect usages as well as
augmenting existing tests to touch on multidimensional unbound resources
Depending on build ordering the output directory may not be created
before the output file is written. This resolves the issue by forcing
the creation.
Resolves#4570.
* [SPIRV] Fix crash when returning void
This fixes a bug where invalid SPIR-V would be emitted when returning a
void value from a void function. According to the spec, the `Value` of
`OpReturnValue` must not have type `OpTypeVoid`; therefore, `OpReturn`
will now be emitted instead.
Fixes#3596
* assert instead of branch
* test that when output of entry point function is missing semantic, the output is specified in the error message
* remove old comment
* add alternate error output message among the set of expected errors
Added a simple transformation before mem2reg to change all allocas of scalar arrays to individual scalar allocas. This could make value deduction easier in Od compilation.
SkipDxilVersion skips test if the either the DXIL version (DxCompiler) or
Validator version (DXIL.dll if external) is less than the specified version.
This message is being added in version 1.7, so the skip value needs to be
1.7 to skip unless it's version 1.7 or higher.
Fixed an assert caused by DxilDeleteDeadRegion making the incorrect assumption that loops with no outgoing values must have no PHI nodes in its exit block. Exit blocks could have phis anyways by referencing incoming values from outside the loop.
Sometimes the Clang AST does not include an implicit cast wrapper around
an integer-type condition in the ternary operator, which causes a crash
when the SPIR-V generated has a non-bool type for the
OpBranchConditional. This change checks for this case and casts the
condition to bool.
Example ASTs:
```
// | `-ConditionalOperator 0x24022c82d48 <col:10, col:19> 'bool'
// | |-ImplicitCastExpr 0x24022c82d00 <col:10> 'bool' <IntegralToBoolean>
// | | `-IntegerLiteral 0x24022c82c58 <col:10> 'literal int' 1
bool b1, b2;
bool b = 1 ? b1 : b2;
// | `-ConditionalOperator 0x1ede5137380 <col:18, col:27> 'SamplerState'
// | |-IntegerLiteral 0x1ede5137308 <col:18> 'literal int' 1
SamplerState s1, s2;
SamplerState s = 1 ? s1 : s2;
```
Fixes#3831
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
Though we may support -Gis with the SPIR-V backend in future, it is
currently not supported, so this change makes that explicit to the user
with an error message when it is used.
Related to #3331