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

896 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li ae9b762a30
[SM68] Add feature flag for SampleCmpBias/Grad and StartInstance/VertexLocation (#6164)
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>
2024-01-20 04:01:56 +00:00
Helena Kotas 6d8645f985
Add DXIL 1.8 op code cap and move WaveMatrix intrisics to SM 6.9 (#6163)
Adds max opcode value for DXIL 1.8 and moves WaveMatrix intrinsics into
future shader model 6.9.

Contributes to #6133
Related to #6125
2024-01-20 01:34:49 +00:00
Jeff Noyle 4b5db1c765
PIX: Fix scope ascension for variable lookup (#6091)
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)
2023-12-06 09:33:40 -08:00
Joshua Batista f171ae8d7b
[NFC] Remove misleading function (#6088)
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
2023-12-02 01:22:42 +00:00
Joshua Batista ab4c4e50db
Remove ExtractRecordStructFromArray intrinsic (#6025)
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
2023-11-30 17:06:40 -08:00
Tex Riddell 3db94d17a8
Add EntryFunctionName to PSV0 data (#5946)
- 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
2023-11-16 20:52:55 +00:00
Xiang Li 668ecf2c09
[Linux] Enable PDBUtil test for Linux build (#5942)
Added CComBSTR::Length for WinAdapter.

Use VERIFY_ARE_EQUAL_WSTR to verify CComBSTR.

Use UTF8 for Linux test.

This is for #5877
2023-11-09 14:16:14 -05:00
Helena Kotas 19fd70ae19 Merge branch 'main' of https://github.com/Microsoft/DirectXShaderCompiler into sm68 2023-11-08 15:28:29 -08:00
Helena Kotas 0e3de8736a
Turn off clang formatting for RDAT_LibraryTypes.inl and RDAT_SubobjectTypes.inl (#5986)
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
2023-11-08 15:03:28 -08:00
Helena Kotas 01cedea8b5 Addressing code review feedback
- remove unused "class." parsing
- use llvm_unreachable instead of DXASSERT
- remove priority 2 from WaveMatrix execution tests
- use StringSwitch in validator arg parsing
- remove unused lit configs
2023-11-08 08:26:53 -08:00
Helena Kotas 3e25309846 clang-format 2023-11-06 11:29:51 -08:00
Helena Kotas 96bb59b95a Merge branch 'main' into merge-from-main-11-2-no3 2023-11-02 14:25:31 -07:00
Tex Riddell 8377726642
Fix RDAT table versioning for ver 1.8 (#5943)
- 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
2023-11-02 00:37:02 +00:00
Tex Riddell 52ace1c57c
Fix module loading and validation issues (#5880)
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
2023-11-01 12:32:06 -07:00
Xiang Li 3d1b501290
Add SV_BaseVertexLocation and SV_StartInstanceLocation to VSIn (#5770)
New VS Input semantics SV_BaseVertexLocation and
SV_StartInstanceLocation are added for
BaseVertexLocation and StartInstanceLocation of
https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-drawindexedinstanced

Also added DXIL operation for these 2 input semantics.

Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/2907
2023-10-31 14:43:37 -04:00
Xiang Li e496555aae
[Linux] Enable PixTest for Linux (#5945)
DxilDia is enabled for Linux with only
DxcPixLiveVariables_FragmentIterator enabled for PixTest.

Enabled PixTest for Linux build.

This is for #5877
2023-10-31 12:49:44 -04:00
David Peixotto 481090a822
[bug] Fix crash when lowering multi-dimension groupshared variable (#5895)
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.
2023-10-23 11:00:36 -07:00
Chris B ffd4fee5e1
[Instcombine] Disable bswap match for DXIL (#5899)
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
2023-10-20 13:31:00 -05:00
Joshua Batista 5eaf7a7c2e
Remove implicit record to struct cast intrinsic (#5871)
The ImplicitRecordToStructCast intrinsic is left over dead code that
should be removed. This PR removes the intrinsic from existence.
Partially addresses
https://github.com/microsoft/DirectXShaderCompiler/issues/5351
2023-10-18 10:21:43 -07:00
Xiang Li 956fa34b4f
[ClangCL] Cleanup rest clang-cl warnings (#5847)
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.
2023-10-16 19:40:51 +00:00
Greg Roth 2123869930 Merge branch 'main' of into staging-sm-6.8 2023-10-12 10:41:37 -07:00
Tex Riddell 50e0126788
Support globallycoherent RWDispatchNodeInputRecord (#5816)
- Add GloballyCoherent flag to NodeIOFlags
- Fix NodeFlags::IsOutputNode; add IsRecord, IsOutput, IsOutputRecord
- Improve globallycoherent diagnostic
- Update and add tests

Fixes #5813
2023-10-11 23:13:49 +00:00
Helena Kotas f14b0cc8c2
Direct3D WSL build header changes (#5843)
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
2023-10-10 16:15:17 -07:00
Tex Riddell deeb8225fa
Update Barrier intrinsic to merge ACCESS and SYNC flags (#5825)
- 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
2023-10-10 15:30:53 -07:00
Xiang Li 039094228e
[ClangCL] Fix warning for rest part except clang. (#5705)
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.
2023-10-09 16:59:01 -04:00
Xiang Li dd8a287bec
[ClangCL] fix warning in DxbcConverter (#5694)
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.
2023-10-09 16:58:37 -04:00
Joshua Batista 20f305c96c
Allow wavesize attribute on library shaders (#5758)
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
2023-09-26 17:49:22 -07:00
Natalie Chouinard cb6a65415f
Add missing StringRef include (#5774)
This missing include is causing some downstream build failures.
2023-09-25 09:16:40 -04:00
Xiang Li 1a4a01b368
[ClangCL] Fix warnings on PixTest.cpp (#5689)
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.
2023-09-22 15:31:16 -04:00
Xiang Li 2325bc539c
Add SampleCmpBias and SampleCmpGrad (#5716)
1. Add DXIL opcode for SampleCmpBias and SampleCmpGrad.
Merged from https://github.com/microsoft/DirectXShaderCompiler/pull/5562

2. Add hlsl intrinsic for  SampleCmpBias and SampleCmpGrad.
3. Lower the intrinsic to DXIL.

This is for https://github.com/microsoft/hlsl-specs/issues/30
Fixes #5560

---------

Co-authored-by: Greg Roth <grroth@microsoft.com>
2023-09-20 20:31:55 -04:00
Chris Bieneman 2169fc1c27 Merge remote-tracking branch 'origin/main' into cbieneman/clang-format-6.8 2023-09-19 09:37:40 -05:00
Chris Bieneman 325096a001 Merge commit 'd949f78f69c0620fdba7320c2014424f4ecdd14f' into cbieneman/clang-format-6.8 2023-09-19 09:35:16 -05:00
Chris B 37ed613864
[NFC] Clang-format DXC sources (#5602)
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.
2023-09-19 07:49:22 -05:00
Greg Roth eb252f0f33
Merge branch 'main' into 'staging-sm-6.8' (#5741)
Conflicts mostly to do with removing SAL annotations

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
Co-authored-by: Helena Kotas <hekotas@microsoft.com>
Co-authored-by: Xiang Li <python3kgae@outlook.com>
Co-authored-by: Chris B <cbieneman@microsoft.com>
Co-authored-by: Justin Bogner <mail@justinbogner.com>
Co-authored-by: Steven Perron <stevenperron@google.com>
Co-authored-by: Cassandra Beckley <cbeckley@google.com>
Co-authored-by: Natalie Chouinard <1953083+sudonatalie@users.noreply.github.com>
Co-authored-by: Jeff Noyle <jeffno@microsoft.com>
Co-authored-by: Nathan Gauër <brioche@google.com>
Co-authored-by: Tex Riddell <texr@microsoft.com>
Co-authored-by: r-a-sattarov <51679282+r-a-sattarov@users.noreply.github.com>
Co-authored-by: David Peixotto <davpeix@microsoft.com>
Co-authored-by: Joshua Batista <jbatista@microsoft.com>
Co-authored-by: Antonio Maiorano <amaiorano@google.com>
Co-authored-by: Minmin Gong <gongminmin@msn.com>
2023-09-18 22:01:12 -07:00
Chris B 2431f3f0a5
[NFC] Integrate clang-format to hctgen (#5732)
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.
2023-09-18 21:10:30 -05:00
Antonio Maiorano 906fc46f52
Fix ASAN memory leak in FileChecker (#5718)
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.
2023-09-18 10:32:04 -04:00
Joshua Batista a79a8a0726
Add profile target shader attribute to entry point function declaration (#5627)
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
2023-09-14 16:33:38 -07:00
Chris B 7cd613bda7
[NFC] Add missing includes in reflection headers (#5715)
`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.
2023-09-14 20:37:50 +00:00
Xiang Li 67fde16627
[CLANG_CL] Fix clang-cl warnings (#5660)
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.
2023-09-14 13:25:46 -04:00
Chris B 3266a87f9a
[NFC] Remove SAL annotations from internal APIs (#5639)
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.
2023-09-14 08:59:49 -05:00
Joshua Batista 034ed24f5b
[DCE] Move output complete removal code later to DCE (#5620)
Elimination of incorrect output complete calls was located in an awkward
spot. The code has been moved over to DCE.
Fixes #5363
2023-09-13 13:34:30 -07:00
Helena Kotas 67fd9dd84e
Update DXC help default language version (#5677)
The current default language version is 2021.
2023-09-11 09:59:26 -07:00
Xiang Li a9d9e65be8
[NFC] Add dxcutil::ComputeSerializeDxilFlags to share code with linker (#5334)
Add dxcutil::ComputeSerializeDxilFlags to share code with linker

Use refactored ComputeSerializeDxilFlags in DxcCompiler::Compile()

---------

Co-authored-by: Tex Riddell <texr@microsoft.com>
2023-09-08 14:44:22 +00:00
Greg Roth af42292ab4 Merge 'main' into 'staging-sm-6.8' 2023-09-05 16:28:25 -07:00
Justin Bogner 1a3c179775
Avoid extra dependencies in the DxilRuntimeReflection header. NFC (#5645)
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.
2023-09-01 14:36:50 -07:00
Chris B 989a3a0bde
[NFC] Fix most egregious clang-format missteps (#5642)
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.
2023-09-01 12:33:30 -05:00
Justin Bogner a88709aa3c
Add `-print-before` and `-print-before-all` flags (#5590)
These match `-print-after` and `-print-after-all`, and are needed if we
want the opt pipeline view to work in compiler explorer.
2023-08-25 14:15:00 -07:00
Chris B 578114efb9
[NFC] Update DXC sources for clang-format (#5593)
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.
2023-08-24 13:55:19 -05:00
Brian Favela ce8268a51d
Custom extensions to enable lowering for non-resource based functions (#5579)
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.
2023-08-23 20:29:06 +00:00
Chris B 64348c7eec
[NFC] Prepare DXC sources for clang-format (#5571)
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.
2023-08-23 15:15:21 -05:00