It is unclear what should happen if an input parameter on a function is
marked as precise. I am choosing to propagate it to the actual
parameters.
Note that it is not wrong to propagate precise more than we should since
it will only stop some optimizations.
The `createStageVars` function is very large, and difficult to fix. In
support of two bug fixes, I want to refactor the function so try to make
the code cleaner.
This change will try to keep the exact same functionality. I believe
their could be further simplification after this if needed.
This PR improves the experience for profilers and debuggers that consume
SPIR-V produced by dxc. When debugging information is output,
additionally note the beginning of the internally generated wrapper
function. This will assign all parameter setup to the entry point
declaration, providing context to the user of a shader profiler or
debugger.
While emitting diagnostic notes about conversions, the code for checking
`OutConversions` was not included in the loop. This caused an OOB when
`I >= NumConversions`. Normally, this does not affect anything (other
than not emitting the diagnostics for `OutConversions`), since most of
the time `OutConversions[I].isBad()` happens to return false. However,
in some cases when `OutConversions[I].isBad()` is true, calling
`DiagnoseBadConversion()` on the invalid entry will crash.
FindD3D12.cmake sets WIN10_SDK_VERSION to
CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION; however, this latter variable
is only defined when using a Visual Studio CMake generator. When using
Ninja instead, for example, this variable will be empty, and
WIN10_SDK_VERSION will remain unset.
This change detects when CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION and
attempts to retrieve the latest SDK by listing directories under
${WIN10_SDK_PATH}/Include.
Convert the moved shaders to lit FileCheck test.
5 shaders not used by runFileTest are also converted and left in
CodeGenSPIRV with CodeGenSPIRV folder enabled for lit.
Now all shaders are converted to lit.
Will move all files back to CodeGenSPIRV and delete CodeGenSPIRV_Lit
next.
Fail to find DIASDK when using VisualStudio "Open a local folder". Both
VS_DIA_INC_PATH and VSWHERE_LATEST are empty. But MSVC_DIA_SDK_DIR is
set correctly.
Add MSVC_DIA_SDK_DIR/include as hint for DIASDK_INCLUDE_DIR.
For hlsl intrinsics with variadic argument lists (in my case: printf),
the number of param modifiers and function arguments did not match,
resulting in segfaults when creating a FunctionProtoType. The presumed
oversight: The paramsMods was made twice as large as intended, by first
resizing to the expected number of arguments, and then pushing back the
same number of arguments again. A fix that seems to resolve this issue
comes with this PR. Please have a look.
Edit: The suggested modifications do not feel as if they are the proper
way to handle modParams initialization. They only defuse the issue I had
with printf. If you think this issue needs a better solution and/or a
proper bug report before suggesting a PR, please let me know - and
please apologize in case I opened up a PR too early.
In parallel builds of DXC, hctgen.py in particuilar would sometimes
throw an exception from os.makedirs because the directory would already
exist. The conditional check for file existence introduces a race when
running the script in parallel. Fix this, and all other cases where such
conditional checks were done, by using the `exist_ok = True` argument.
Convert the moved shaders to lit FileCheck test.
5 shaders not used by runFileTest are also converted and left in CodeGenSPIRV with CodeGenSPIRV folder enabled for lit.
Will move all files back to CodeGenSPIRV and delete CodeGenSPIRV_Lit next.
`ext_extension` and `ext_capability` can only be added to functions at
the moment. This PR enables adding them to variable declarations, so
that using the variable results in the extensions and capabilities being
added to the module. This is useful for the builtin variable syntax
proposed in https://github.com/microsoft/hlsl-specs/pull/129.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
These changes allow us to use DXC as as CMake subproject (via
add_subdirectory).
Commit comments from each commit:
===
cmake: allow CMAKE_INSTALL_RPATH to be defined in superproject on APPLE
platforms
As on Linux, allow CMAKE_INSTALL_RPATH to be defined in a CMake
superproject.
===
cmake: Allow LLVM_ENABLE_ASSERTIONS=OFF to disable assertions in Debug
builds
Currently, this flag is only used to enable assertions in non-Debug
builds, but is not respected in Debug builds. That is, if set to false,
Debug builds will still assert. This change fixes that.
Note that by default, LLVM_ENABLE_ASSERTIONS is true in Debug builds, so
unless it's explicitly set to false, this is a no-op for most people.
===
cmake: Allow DIRECTX_HEADERS_INCLUDE_DIR to be defined from superproject
Useful for when DXC is included as a subdirectory. In Dawn/Chrome, we
use our own mirror of DirectX-Headers instead of checking out the repo's
submodules, so we need to override this variable.
The misplacement of that "return" in DxilDebugInstrumentation.cpp meant
that a thread would continue to the following call to
addStepDebugEntryValue, even if pix_dxil::PixDxilReg::FromInst had
failed (i.e. returned false), which means that RegNum is not valid
(although initialized to 0).
This meant that PIX was instrumenting a bunch of void-return DXIL
instructions that it shouldn't have.
Didn't think to test that it WASN'T instrumenting instructions, but
herein is added a test to do just that.
Since `ConstantBuffer` is now lowered in `LowerTypeVisitor`, lower
`push_constant` and `shader_record_*` with `ConstantBuffer` types there
as well.
Fixes#5808.
When the codegen fails, it shows an error, but the SPIR-V validation
still runs. Because the generation fails, the generated SPIR-V code
could be invalid without it being a compiler bug. But the validation
error message could confuse the user as it says this is a DXC bug.
Signed-off-by: Nathan Gauër <brioche@google.com>
NodeInputRecordProps is used in this file, but the corresponding header
is not directly included. This breaks out build.
Signed-off-by: Nathan Gauër <brioche@google.com>
This PR moves over some more diagnostics from CGHLSLMS.cpp. Some
diagnostics are moved into DiagnoseEntryAttrAllowedOnStage, to
specifically diagnose when an attribute appears on a shader stage that
it shouldn't appear on. Other diagnostics that are covered in Sema are
removed in CGHLSLMS.
Fixes#5990
---------
Co-authored-by: Chris B <cbieneman@microsoft.com>
Emit an explicit error message when HLSL `ResourceDescriptorHeap` or
`SamplerDescriptorHeap` are used with `-spirv` as they are not yet
supported.
Fixes#5913
There was an arbitrary limit to set the maximum number of locations to
64.
This commit allows the set to be resized, to allow arbitrarily large
location indices.
Curiously, one test, vk.location.large.hlsl started to fail. This test
assumed 123456 was an invalid location. From the SPIR-V spec, I don't
think this is true, as it only days Location should be an arbitraty
number.
In addition, it seems like this test was triggering an out-of-bound
access, which is now solved. Only drawback: we now end-up with a 123456
sized bitset.
I believe this is OK, as WHY would someone only require this index.
Fixes#3735
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
Interlock* functions takes output parameters. Because HLSL had no real
concept of references, this is allowed:
```
int value;
takeAnOutput(value);
```
This weirdness makes using `isLValue()` to validate output parameters a
bit tricky. If a function returns a local array, and we take the
subscript of this r-value, the r-value is now marked as l-value, but
this shouldn't be allowed.
This forces us to walk the expression, and add heuristics to determine
if the output parameter is valid or not. Not pretty, but I think this is
required until HLSL gets proper references.
Fixes#5772
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
In the test added by ba90e249d "Remove InsertAddrSpaceCastIfRequired
which is redundant (#5862)" we have a check line for a `dx.hl.op` that
refers to an opcode. Since the HL opcodes aren't stable, we should avoid
that.
I had a couple of test updates that should have gone in my previous PR
but got left out due to me forgetting, due to a two-week mental context
switch :-). The new test adds some useful regression testing, so here it
is.
Got a couple reasons to do this: 1) so that users can step over the last
value assignment and actually see that value in the debugger and 2) so
that I can easily distinguish the final instruction in DXR traces
wherein two different function's traces might be intermingled in the
debug output data in PIX's UAV.
Fix issues hit when apply format.
1. tmp diff file is not opened binary form, don't need to encode.
2. add contents write to "Check code formatting" workflow for commit and
push change.
3. put main branch to different path to avoid issue when checkout head
branch to same path.
- In `DxilPipelineStateValidation.h`, add `PSVRuntimeInfo3` derived from
`PSVRuntimeInfo2`, containing one `uint32_t EntryFunctionName` member.
- Update `MAX_PSV_VERSION` and `RuntimeInfoSize()` for new version.
- Add pointer to `DxilPipelineStateValidation` and assign in
`ReadOrWrite` along with other versioned pointers.
- Add `DxilPipelineStateValidation::GetEntryFunctionName()` accessor to
look up name in string table.
- Update PSV0 versioning to key off validator version 1.8 in
`DxilContainerAssembler.cpp`
- Add entry name to string table and set `EntryFunctionName` to offset.
- Add initialization to DxilPSVWriter members
- Add asserts in DxilPSVWriter::write() to ensure buffer sizes not
changed after m_PSVInitInfo is set.
- Add test to DxilContainerTest, adding/updating common functions as
needed
Note: Testing the HS passthrough case revealed problems blocking that
scenario.
Filed issue #6001 to track this.
Fixes#5944