New feature flag ShaderFeatureInfo_SampleCmpGradientOrBias = 0x80000000
and
ShaderFeatureInfo_ExtendedCommandInfo = 0x100000000 were added.
They will be set when SampleCmpBias/Grad startInstance/VertexLocation
exists.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
In DxcPixLiveVariables.cpp,
UniqueScopeForInlinedFunctions::AscendScopeHierarchy tries to keep track
of a variable's scope and the scope at which its containing function was
inlined, if any.
This scope duo has to be the same in two places for things to work out:
the scopes inferred from dbg.declare, and then again when the scope
hierarchy is ascended in order to discover all variables accessible from
a given point in the program.
AscendScopeHierarchy was forgetting to update the inlined part of the
scope, resulting in, for example, PIX's debugger losing track of
variables outside of, for example, a for loop, even though the code can
see those variables at that point.
Just setting the inlined scope to be the same as the function scope
fixes this problem.
(In addition to these new tests, existing PIX tests exercise this
situation happily)
The IsRay() function defined in the ShaderModel class can be misleading.
It is included in a set of functions that are used to test whether or
not the shader in question was targeted to a specific shader stage.
However, it is impossible for a shader to be targeted to, say, the
"raygeneration" stage, or any other stages associated with the kinds
that the IsRay() function checks for. Like the "node" shader kind, a
shader can only have these shader kinds if the associated attribute is
found on the function declaration. To prevent confusion, and to keep the
Is*() functions inside the ShaderModel class restricted to only those
targetable shader stages, the IsRay() function can be removed. This PR
comes as a response to #6008
The ExtractRecordStructFromArray intrinsic is left over dead code that
should be removed. This PR removes the intrinsic from existence. In the
cases where this intrinsic was used, DefaultSubscript is used instead.
Moved from #5893 to target the main branch instead.
Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/5351
- 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
Turn off clang formatting for `RDAT_LibraryTypes.inl` and
`RDAT_SubobjectTypes.inl`. Macro indentation makes these files easier to
read.
This PR was created in 2 steps:
1. `RDAT_LibraryTypes.inl` and `RDAT_SubobjectTypes.inl` were reverted
to the version `64348c7e~1` The commit
64348c7eec is the first that started
preparing the code base for clang formatting. Except for that there were
no functional commits done to these files since then.
2. `//clang-format off` and a comment with explanation was added to the
top of these files
- Reorganize part and table IDs to move shader info after ver 1.8
- Move NodeShaderInfo into RuntimeDataFunctionInfo2 shader info union,
since it is mutually exclusive with other shader types
- Remove RuntimeDataFunctionInfo3
- Re-organize RDAT_LibraryTypes into 3 sections by versioning
- Format unformatted section of RDAT_LibraryTypes due to typo
- Add indentation to make definitions easier to read and disable
clang-format for RDAT_LibraryTypes.inl and RDAT_SubobjectTypes.inl
- Include Node in ShaderStageFlags for 1.8+
- Added some explicit scopes due to VS IDE thinking they were ambiguous
- RDATDumper: Don't try to visit or print null records
- Fix reflection tests:
- tests meant to check shader info use: -Vd -validator-version 0.0
- use regex for record strides for versioning robustness
- update ShaderStageFlags to include Node
- use regex for RuntimeDataFunctionInfo name for versioning robustness
- remove shader info CHECKs for cases not meant to test that
Fixes#5900
Fix module loading and validation issues
There are a couple interacting issues:
1. When RefreshCache occurs, it doesn't fill in the m_pResRetType cache.
- This is because in GetOpFunc, if it finds a function matching the
expected name, it simply returns that, skipping function type
construction.
- This causes a validation error if CheckAccessFullyMapped is validated
before a function that calls it. This depends on the order of
function declarations/definitions in the module.
- The solution is to move the check after type construction, and verify
that the function type matches expectations as well.
2. When RefreshCache() and FixOverloadNames() was called from
DxilOperations
constructor, the m_LowPrecisionMode has not yet been set, leading to
incorrect overload types when allowing function type construction to
proceed in GetOpFunc before looking for a matching function by name.
- This leads to an incorrect type for 16-bit CBufRet type being used.
- The solution is to move RefreshCache() and FixOverloadNames() calls
to after we actually know the m_LowPrecisionMode, so that the correct
types may be constructed.
Rename hlsl::OP::SetMinPrecision to InitWithMinPrecision to make clear
what's being done.
Added validation tests to verify the fixes.
Fixed validation test that produced invalid DXIL op function signature.
Fix HLModule not setting min-precision mode when loading from metadata.
Fixes#5879
This commit fixes a crash in the compiler when lowering a groupshared
variable with a multi-dimensional array type. The root cause of the bug
was that we had a nested gep expression that could not be merged into a
single gep because of an intervening addrspacecast.
The `MultiDimArrayToOneDimArray` pass flattens the multi-dimension
global variables to a single dimension. It relies on the `MergeGepUse`
function to flatten any nested geps into a single gep that fully
dereferences a scalar element.
The fix is to modify the `MergeGepUse` function to look through
addrspacecast instructions when trying to merge geps. We can now merge
geps like
gep(addrspacecast(gep(p0, gep_args0)) to p1*, gep_args1)
into
addrspacecast(gep(p0, gep_args0+gep_args1) to p1*)
We also added a call to `removeDeadConstantUsers` before flattening
multi-dimension globals because we can have some dead constants hanging
around after merging geps and these constants should be ignored by the
flattening pass.
DXIL doesn't support the bswap intrinsic, normally a backend would lower
this intrinsic to something else, in this case we don't have a backend
so we just end up generating invalid DXIL.
The solution here is to disable bswap matching when targeting DXIL.
Fixes#5104
1. printf format mismatch.
2. avoid cast from CComPtr<IncludeHandlerVFSOverlayForTest> to
CComPtr<IDxcIncludeHandler>.
3. fix signed unsigned mismatch.
4. fix order of fields in constructor.
5. add override for override methods.
6. port
01f4209631
7. add copy assignment operator to avoid
-Wdeprecated-copy-with-user-provided-copy
8. disable -Wignored-qualifiers for taef header WexTestClass.h.
9. remove unused fields.
10. add -clang-cl for hctbuild.
Header changes to make Direct3D WSL build work:
- Move non-WIN32 IMalloc definition back to `WinAdapter.h` (it was there
until commit 44f8833938)
- Define DEFINE_ENUM_FLAG_OPERATORS only if it was not already defined
- Merge ACCESS_FLAG AccessFlags and SYNC_FLAG SyncFlags into new
BARRIER_SEMANTIC_FLAG SemanticFlags according to spec update
- Update lowering, DxilValidation, and tests
- Delete now-redundant validation tests
Fixes#5780
1. add noexcept for methods with __declspec(nothrow)
2. add override for override methods.
3. add const when cast const ptr for a const argument.
4. change 0 to 0u for immediate to avoid signed unsigned mismatch.
1. fix order of fields in constructor.
2. fix compare warning for type mismatch by cast to same type.
3. use {} instead of {0} when initialize to all zero.
4. add override for override methods.
This PR moves the wavesize diagnostics over to sema, and adjusts them so
that the error messages are clearer and so that wavesize attributes are
allowed on library shaders.
Fixes#5374
1. signed unisgned compare warning.
Fixed by change 1 into 1u. Or cast directly.
2. writeable string.
Use const char/wchar_t * instead of char/wchar_t*.
3. lost const when cast.
Add const.
This change applies clang-format to all of the sources added in DXC that
were not part of the original LLVM/Clang 3.7 release when DXC forked.
This provides consistent code formatting across the codebase.
Fixes#5591.
This integrates formatting generated sources with clang-format with the
hctgen generation process.
This change makes a few small adjustments to how the build-time header
generation works. This change, disables automated build-time generation
for C++ sources if you don't have clang-format available on your system.
CMake can automatically detect clang-format installed as part of Visual
Studio, or based on your PATH. You can also explicitly set
`CLANG_FORMAT_EXE` when configuring to manually override. **Developers
on macOS** will need to install clang-format manually and place it on
their path to generate DXC's generated sources.
If clang-format cannot be found and `HLSL_COPY_GENERATED_SOURCES` is On
a fatal error will be reported at configuration time.
This change _does not_ make clang-format a requirement to build DXC, but
it does make it a requirement if you are modifying the generated
sources.
AllocVFSIncludeHandler was returning it's IUnknown object by Detach()ing
from a CComPtr, then assiging to CComPtr. This would result in the
object have a ref count of 2, and when the second CComPtr destructed, it
would go down to 1, and leak memory.
The fix is to return the object as a CComPtr; however, with Clang, this
failed to compile because it finds no conversion from a CComPtr of child
class type to a CComPtr of base class type. This compiles fine on MSVC,
so I debugged it, and realized that MSVC compiles this as first a
conversion to T*, then a constructor call. I suspect MSVC is wrong here.
In any case, this change adds a template conversion constructor to
CComPtr, very much like the existing template assignment operator.
This PR will automatically add the target profile shader stage as a
HLSLShader attribute to the function declaration that represents the
entry point. If the entry point doesn't exist (in the case of library
shaders), then this behavior won't happen.
Fixes#5626
`DxilRuntimeReflection.h` uses `size_t`, which is defined by
`<cstddef>`.
`dxcutil.h` uses `hlsl::SerializeDxilFlags` by value whcih is declared
in `DxilContainer.h`.
`D3DReflectionStrings.h` relies on windows tyoes like `LPCSTR`. It also
includes `D3DReflection.h`, which in turn includes `d3d12shader.h` (from
DirectXHeaders), which relies on basically the whole `WinAdapter.h`.
I've included `WInAdapter.h` in both `D3DReflectionStrings.h` and
`D3DReflection.h` to make both headers indipendently resilient.
Add -Wno-unused-parameter -Wno-unknown-pragams -Wno-switch which are
enabled for clang in linux build.
Fix
-Wimplicit-fallthrough
-Wconstant-logical-operand (Thanks patch from Chris)
-Wunused-function
-Wunused-variable
-Wtrigraphs
-Wnonportable-include-path
Still more warnings to be fixed.
We don't keep these annotations up to date or rely on them, so to
simplify our platform layering and ease code formatting this change
removes all the SAL annotations from internal APIs. This change also
replaces most `_Analysis_Assme_(...)` annotations with `assert(...)`.
One `_Analysis_Assume_` in ParseDecl.cpp needed to be updated because it
was incorrect. The code was `_Analysis_Assume_(assert(name.size() >
sizeof("space"));`. When converted to an `assert` it fired in our test
suite because the sizeof a string literal includes the null terminator,
but the size of a StringRef does not.
A few of the `_Analysis_Assume_` annotations were removed because they
didn't make sense (like the ones inside the `DXASSERT` implementation,
and a few others were removed to avoid introducing additional header or
linkage dependencies.
This change does not introduce any functional or behavioral changes.
Add dxcutil::ComputeSerializeDxilFlags to share code with linker
Use refactored ComputeSerializeDxilFlags in DxcCompiler::Compile()
---------
Co-authored-by: Tex Riddell <texr@microsoft.com>
including `WinIncludes.h` here pulls in a bunch of dependencies like ATL
even though we really don't need those in this header. Given that the
only things we're using that include for is to use LPCWSTR and LPCVOID
spellings in a way that works on both windows and unix, just expand
those macros to their definitions instead.
This change fixes a few of the most awful clang-format missteps in the
codebase. I'm not intending to fix all the things clang-format will do
something bad with, just a few of the worst ones.
Further formatting fixups can be done after the clang-format change goes
in.
One more batch of NFC changes to get DXC ready to clang-format. This
change disables clang-format of some include blocks and breaks other
include blocks into groups. With this change all of the sources in DXC
can be clang-formatted and will continue to build on all supported
platforms.
A downstream consumer requires the use of custom function lowering using
a json string as well as methods. For instance, a direct memory load not
based on a resource.
This change prepares DXC sources to be ready to clang-format. This
change adds annotations to skip formatting parts of the code that will
break if clang-format modifies them due to include ordering or generated
C++. It also adds missing include and forward declarations where
clang-formatting resulted in moving things around that caused code
breakages.