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

925 Коммитов

Автор SHA1 Сообщение Дата
Cooper Partin 6103dd1854
Add compiler option -Qsource_in_debug_module for embedding source in debug builds to documented help text (#6597)
This commit adds the compiler option (-Qsource_in_debug_module) to the
help text.

New help text output below:

```
Utility Options:
  -dumpbin              Load a binary file rather than compiling
  -extractrootsignature Extract root signature from shader bytecode (must be used with /Fo <file>)
  -getprivate <file>    Save private data from shader blob
  -link                 Link list of libraries provided in <inputs> argument separated by ';'
  -P                    Preprocess to file
  -Qembed_debug         Embed PDB in shader container (must be used with /Zi)
  -Qsource_in_debug_module
                        Embed source info in PDB
  -Qstrip_debug         Strip debug information from 4_0+ shader bytecode  (must be used with /Fo <file>)
  -Qstrip_priv          Strip private data from shader bytecode  (must be used with /Fo <file>)
  -Qstrip_reflect       Strip reflection data from shader bytecode  (must be used with /Fo <file>)
  -Qstrip_rootsignature Strip root signature data from shader bytecode  (must be used with /Fo <file>)
  -setprivate <file>    Private data to add to compiled shader blob
  -setrootsignature <file>
                        Attach root signature to shader bytecode
  -verifyrootsignature <file>
                        Verify shader bytecode with root signature
```

fixes #6028

---------

Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
2024-05-08 08:55:07 -07:00
Greg Roth 1c66c4d798
Disable non-legacy cbuffer flags (#6559)
These flags had some effect on load code generation, but never worked
right and were not tested in the DXC compiler let alone with drivers.
This removes any notion of the flags beyond option processing and
produces a warning message that the flag is not supported and will be
ignored. The flags are both not listed in help anymore either. A simple
OptionsTest and lit test verify that the warning message is produced for either
flag and existing tests that used the flag are updated or removed.

Incidentally fixed the capitalization of an existing options warning message.

Fixes #6306
2024-04-23 11:59:49 -07:00
Tex Riddell fe393e09d7
Add barrier MemoryTypeFlags and SemanticFlags diagnostics (#6513)
Context-specific diagnostics are warnings with DefaultError, since in
theory they could be dead code at this stage.

There were some changes to existing Sema diagnostic hooks along the way.

SemaHLSLDiagnoseTU.cpp - HLSLMethodCallDiagnoseVisitor
- extend to non-method calls and pass CallExpr
- instead of skipping when call reached from multiple entry/export
functions, pass locallyVisited flag for skipping of redundant diags not
dependent on entry properties.
- use llvm::SmallPtrSet for DiagnosticCalls
- capture launch type for entry and pass it down

Replace DiagnoseHLSLMethodCall hook with CheckHLSLFunctionCall:

Move hook into Sema::CheckFunctionCall in SemaChecking.cpp to be general
to either a function call or a method call.
Refactor existing code in DiagnoseHLSLMethodCall into
CheckFinishedCrossGroupSharingCall called in the hook for this method.
Add CheckBarrierCall for context-free flag validity check, called by
CheckHLSLFunctionCall.

Refactor CalculateLOD checking into more generic parts, dispatched based
on IntrinsicOp from top-level DiagnoseReachableHLSLCall function.

Switch to using new note: "entry function defined here", instead of
"declared here".

Fix intrinsic checking to use IsBuiltinTable on the intrinsic
attribute's group.

**Preparation Changes**
While these could be broken out, the barrier diagnostic changes are
dependent on them, and testing for some of these is dependent on the
other parts of the barrier diagnostic changes.

Correct errors in tests, check MaxRecords for EmptyNodeOutput in AST
Note that Barrier(..., 3) means SemanticFlags: GroupSync | GroupScope.
These are only valid in a shader with a visible group, and GroupSync on
memory with at least group scope, so they have been changed to 0 in
specific cases in these tests.

Make DiagnoseSVForLaunchType a static function, add FIXME notes.

Use StringRef for IsBuiltinTable, compare strings instead of pointers.

Fix FileCheckerTest for -verify output.

New ShaderModel::HasVisibleGroup uses ShaderKind and NodeLaunchType to
determine whether shader type has a visible group.
2024-04-10 14:44:37 -07:00
Cooper Partin 422a60e6d0
Update locale setting logic to support UTF-8 only for Apple and Linux distros (#6488)
This commit fixes the setlocale( ) logic to include the UTF-8 supported
string value for Mariner distros.

It also introduces a new RAII class `ScopedLocale' which ensure that the
locale setting is set/reset during string conversion operations.

Fixes: #6201

---------

Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
Co-authored-by: cooppunix <cooppunix&mariner.com>
2024-04-10 10:04:32 -07:00
Natalie Chouinard 122464aeef
Require valid outputcontrolpoints on Hull shader (#6196)
According to the documentation: "A hull shader is implemented with an
HLSL function, and has the following properties: [...] The shader output
is between 1 and 32 control points".


https://learn.microsoft.com/en-us/windows/win32/direct3d11/direct3d-11-advanced-stages-tessellation#hull-shader-stage

This change adds a check to verify that the outputcontrolpoints
attribute is set on Hull shaders and has an argument in the valid range.

Fixes #3733 (by making the error consistent between backends)
2024-03-25 13:41:12 -04:00
Natalie Chouinard 8de82c9415
[SPIR-V] Add support for Denorm Mode (#6435)
The -denorm option allows the shader to select the desired behavior with
respect to denormal values.

Note that this can't take advantage of the SPIRV-Tools capability
trimming pass for the same reasons as described in:
https://github.com/microsoft/DirectXShaderCompiler/pull/6248#discussion_r1481073348

Fixes #6434
2024-03-25 11:42:53 +01:00
Antonio Maiorano dab30b929a
Disable "downcast of address" UBSAN runtime error (#6448)
This is a temporary workaround until we fix:
https://github.com/microsoft/DirectXShaderCompiler/issues/6446

This should allow us to enable asan/ubsan checks:
https://github.com/microsoft/DirectXShaderCompiler/pull/6428

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-22 15:57:21 -04:00
Cooper Partin 3704efb2bc
Implement -ftime-trace-granularity option to set time granularity value for the time profiler (#6381)
This commit adds a new optional -ftime-trace-granularity option that is
already implemented in llvm-project. This change is a surgical port of
an existing feature from the upstream llvm-project repo into the DXC
codebase.

The following commits in the llvm-project repo were copied and followed
for this change. Clean cherry picks were not possible due to the
differences in repos like change of file locations and other dependant
changes made in the repo.

*** Adds the granularity configuration setting ***
'Time profiler: small fixes and optimizations'
Commit: 26536728591d5fdac373ef535ae122b873f73292

*** Wires up the commandline option -ftime-trace-granularity to the
TraceProfiler code ***
'[Support] Fix -ftime-trace-granularity option'
Commit: 4fdcabf259c4ab94654e6cd5d95d0e0313159c70

Fixes #6372

---------

Signed-off-by: Cooper Partin <coopp@ntdev.microsoft.com>
Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-05 09:02:15 -08:00
Tex Riddell 66ba5a1529
Add alignment to NodeRecordType including DXIL metadata update (#6279)
This change adds NodeRecordType alignment field to RDAT to make it
possible to validate pointer and stride alignment in the runtime.

This includes a change to DXIL metadata to preserve the record alignment
without requiring recovery by looking for GetNodeRecordPtr.

Fixes #6270
2024-02-29 11:22:56 -08:00
Jonas Meyer f0970beaf8
Expose clang option `-fdiagnostics-format=` in dxc (#6357)
This change exposes the clang 3.7 `-fdiagnostics-format=` flag in DXC with supported values `clang`, `msvc`, `mdvc-fallback`, and `vi`.

This option allows having DXC output diagnostic messages in string formats that are recognized natively by Visual Studio.

Resolves #6160 & #1811, both of which had been closed as not planned.
2024-02-27 12:18:42 -06:00
Jannik Silvanus 16d43a5fa8
Fix crash in dominator tree construction used by DiagnoseRaytracingPayloadAccess (#5605)
Fix crash if a RayGen shader contains a `while(true)` loop, caused by
dominator tree construction not ignoring `nullptr` successor AST nodes
which occur in this case.

Also add regression test case.

Fixes #5035.

Co-authored-by: Jannik Silvanus <jasilvanus@users.noreply.github.com>
2024-02-21 11:50:38 -08:00
Tex Riddell 2314d06cfe
New barrier DXIL Op fixes for Validation and RDAT function compatibility info (#6291)
Fix barrier allowed ops and flags by shader kind

New barrier operations lacked validation and for RDAT info: had
incorrect min target and shader stage flags.

- Identify barrier DXIL operations with new `is_barrier` in `hctdb.py`
and generated `OP::IsDxilOpBarrier`.
- Identify when a barrier op requires shader stage with group
(compute-like stage), or when it requires node memory.
- Add new `OptFeatureInfo_RequiresGroup` to identify function only
compatible with a shader stage with a visible group for access to
groupshared memory or use of group sync.
- Translate to original `BarrierMode` when compatible; adds
`BarrierMode::Invalid` to identify invalid cases.
- Account for `DXIL::MemoryTypeFlags::AllMemory` being allowed and
auto-masked by driver.
- Properly set min shader model and compatible shader stage flags.
- Validate barrier for shader stage.
- Added new barriers to counters which were missing.

Adressing parts of: #6256 and #6292
Fixes #6266
2024-02-20 10:44:34 -08:00
Adam Yang 4bfe9c8136
Fixed PdbUtils not actually normalizing the file paths (#6317)
There was a typo in dxcpdbutils where the normalized file path wasn't
actually being used. This change fixes that and adds thorough testing
for the DxcPdbUtils path normalization. Also fixed another case where
`/dir/my_file` gets normalized to `.\\dir\my_file`.
2024-02-17 01:01:07 +00:00
Tex Riddell df588beb48
NFC: Fix DXIL op is_const for Barrier and node create handle ops (#6280)
DXIL operations should use is_const=True for constant arguments. This
allows for convenience methods to retrieve the constant value, and could
(should, but currently doesn't) result in validation that the argument
is constant.

`BarrierByNodeRecordHandle` SemanticFlags argument must be constant.
`MetadataIdx` for both `createNodeOutputHandle` and
`CreateNodeInputRecordHandle` must be constant.
2024-02-15 15:45:45 -08:00
Jeff Noyle 446da195b4
PIX: Optimize debug instrumentation for fewest emitted instructions (#6281)
This change switches from instrumentation per instruction to
instrumentation per basic block. Furthermore, not every instruction in a
basic block needs to write debug data to the output UAV- it's enough to
know that the basic block was entered, as long as the calling
application can figure out what instructions were in that block. To
support that knowledge, the pass now emits a text "precis" of each basic
block.

Also, the previous branchless UAV bounds enforcement was replaced with
something similar that emits fewer instructions at the cost of a larger
UAV. This tradeoff is WELL worth it.

Additionally, the debug pass used to add extra blocks in order to
solidify the arguments to phi instructions. This work was unnecessary,
and added a lot of complexity to the resulting instrumented shader. The
debugger application is only interested in the value of the phi itself
and the actual value produced via the actual preceding edge.
 
Full details are in the comments in the code.

This change reduces driver-side compilation overhead from "overnight" to
2 minutes on a 160k-instruction shader.
2024-02-13 08:08:22 -08:00
Tex Riddell 627e400dea
NFC: Fix switch with missing default case in DxilShaderModel.cpp (#6288)
This missing default case statement would cause build break when
compiling with additional warning settings, such as /W4 /WX in VC++.

Fixes #6287.
2024-02-13 01:42:59 +00:00
Adam Yang 30f45bcf0f
Added a ground truth path normalization. (#6213)
This change adds a ground truth path normalization helper:
- All slashes are changed to system native (`\` for windows, `/` for all
others)
- All repeated slashes are removed (except for leading slashes, so
windows UNC paths are not broken)
- All relative paths (including the main file, and ones that begin with
`..`) are prepended with `./` or `.\` if not already

The path normalization is applied in the following places:
- Main file path in dxcompilerobj
- Paths passed into IDxcIncludeHandler
- Paths written into all DI* debug info
- Paths written into dx.content metadata and Pdb SourceInfo
- All paths loaded up by DxcPdbUtils

The reason for this change is to make it easier to tools authors to
implement recompilation (example: PIX edit-and-continue). When the paths
in all the above places match, the files can be matched with a normal
string equal instead of having to path normalization.
2024-02-12 16:47:39 -08:00
Tex Riddell b3be6f2522
Correct metadata load for NodeRecordType for robustness (#6277)
Metadata loading for node record properties assumed fixed positions for
values in a (key,value) property list, skipping and ignoring the keys.

This was not correct, fragile, and not the intended implementation of
the key,value property pattern.

There is no functional change, but this makes the loader robust to
additional properties instead of crashing or loading the wrong thing.

Fixes #6276
2024-02-12 19:26:48 +00:00
Joshua Batista cadf3bfed1
[Sema] Add final touches to wave size range implementation (#6202)
Upon further discussion, the team has agreed that in certain degenerate
cases, the current diagnostics are insufficient.
In the case that min == max in the wave size range attribute, a
defaultError warning should be emitted. Additionally, there should be an
explicit way to handle the case where 0,0,0 is passed to the wavesize
range attribute.
This PR directly handles and tests both of these cases.
Fixes #6161

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-02-10 02:15:59 +00:00
Tex Riddell 9c518dbd94
RDAT: Check flags and WaveSize for min SM; fix flag detection and merging (#6207)
Add ShaderKind::Last_1_8 for shader mask
Add shader model comments before flag groupings in DxilConstants.h and DxilShaderFlags.

Add missing flag checks for min shader model in RDAT function info. Move ShaderCompatInfo computation into DxilModule, propagate callee info.

Move computation of shader model requirements based on flags into DxilModule. Finalize requirements for entry functions in AdjustMinimumShaderModelAndFlags.

Fixes for function level flag tracking:
- DerivativesInMeshAndAmpShaders: use flag to track deriv use, then adjust for entry functions.
- hasUAVs: based on resource use in function instead of global resources.
- WriteableMSAATextures: based on use in function instead of global resources.
  - Also catch cases for dynamic res from any use by looking at create/annotate handle, not just the TextureStoreSample op.
- RaytracingTier1_1: move module-level detection to CollectShaderFlagsForModule
- Marked deriv and quad ops as being supported in node.
- Fixed SampleCmpBias to be considered gradient op.
- Update RDAT definitions to dump more useful info for testing

Fixes #6218.
2024-02-09 17:14:12 -08:00
Nathan Gauër 9c82723d3f
[SPIR-V] Add fspv-enable-maximal-reconvergence opt (#6248)
This option is not enabled by default. When enabled, this option adds
the MaximallyReconvergesKHR execution mode to the module, and the
associated extension.

Related to #6222

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-02-08 14:13:55 -05:00
Tex Riddell 2ae63c9383
NFC: Resolve PRERELEASE-TODO cases related to deep RDAT validation (#6226)
These TODOs were intended for if we were to implement deep RDAT
validation rather than relying on the exact binary comparison.

This isn't happening for SM 6.8, so these are no longer
PRERELEASE-TODOs.

The comment in RDAT_Macros.inl didn't really belong there in the first
place, so I removed it.

Fixes #5699.
2024-02-06 15:48:01 -08:00
Jeff Noyle a23d58663f
WinPIX: Changes to support bitfields in PIX's shader debugger (#6219)
Two related sets of changes:
1) Modify the value-to-declare pass to tolerate bitfields, which are
detected by their habit of being smaller than the type in which they are
contained. The pass produces dbg.declare statements that map each HLSL
variable to some storage. With bitfields, that mapping becomes
many-to-one, because many bitfields can be stored in the same basic
type. Most of the changes are to preserve the size of the bitfield as
the code descends the type hierarchy into the underlying basic type,
which is what motivates these new "type overrride" parameters to some
functions. Complications to watch out for are min16 types, which may or
may not be their own purpose-made (16-bit) types depending on whether or
not they are enabled.
2) Modify the PIX debug-info API to return enough data to PIX to allow
it to extract (by bit shifting) a bitfield from the underlying type.
This bit is also about preserving knowledge of the field's size as
opposed to its containing type's size, hence the new dxcapi
interface/method.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-02-02 09:44:32 -08:00
Steve Urquhart 74e3256484
[SPIRV] Always provide original source to debug (#6085)
This PR improves the experience for debugging tools that consume SPIR-V
produced by passing in-memory strings to dxcompiler.dll. When dxc.exe is
used, OpSource and OpDebugSource are populated by reading original
source from the filesystem. dxcompiler.dll users instead find their
input string is preprocessed, which is confusing behavior.
Contrary to the leading comment in the code this change modifies,
debugging tools do not want preprocessed source. Such tools show and
allow editing of include files. If everything is pasted into a single
source string, finding what to edit is difficult. Editing the
preprocessed source has the additional complication that a user would
have to edit also the #line markers, which is hard to get right
manually. In the preprocessed source, all comments are lost, which makes
it hard to read the code. Finally in preprocessed source, all macros and
code under conditional compilation are lost. That will make it
impossible to modify those parts in an edit.

Co-authored-by: Steve Urquhart <stevur01@ntd.nintendo.com>
2024-02-02 10:19:49 -05:00
Helena Kotas 83b41f97c2
Recognize 'Microsoft Basic Render Driver' in execution tests (#6234)
Recognize 'Microsoft Basic Render Driver' in execution tests as a valid
adapter name equivalent to WARP.
2024-01-31 22:44:09 +00:00
Antonio Maiorano acd8117142
Fix empty control statement warnings when asserts are diabled on MSVC (#6197)
When asserts are disabled (LLVM_ENABLE_ASSERTIONS=0), DXASSERT* macros
are defined to nothing, resulting in no statements followed by a
semicolon. This results in:

warning C4390: ';': empty controlled statement found; is this the
intent?

Which fails because warnings are treated as errors.

Fix by adding the standard "do {} while(0)". Also opportunistically
remove the extra semicolon for non-WIN32 builds.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-01-24 16:10:01 -05:00
Xiang Li 79a290e719
[Sema] Not report error when invalid intrinsic call is not used. (#6140)
Added DiagnoseUsedHLSLMethodCall which only report error when the
MethodCall is used.
DiagnoseUsedHLSLMethodCall is used in DiagnoseTranslationUnit. 
In DiagnoseTranslationUnit, traverse all visited functions in call
graph, diagnose illegal intrinsic call inside these functions.

Shader kind is also checked in DiagnoseUsedHLSLMethodCall.

Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/5855

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-01-23 19:51:24 -08:00
Tex Riddell dcb618a2f1
Fix bad WaveSize non-range PSV0 and improve things (#6172)
PSV0 MaximumExpectedWaveLaneCount was incorrectly set to 0 for
non-range.

Create struct for WaveSize in DxilFunctionProps.h.
Centralize encoding and validation logic there.
Use validation logic in both SemaHLSL and DxilValidation.

Remove test requiring newer shader model in CodeGenHLSL.
Add comprehensive test for compute and node, cs and lib targets, SM 6.6
and 6.8, testing ast, metadata and RDAT.
Add PSV0 tests to catch incorrect runtime data.

Update validation rules and test for more cases.
2024-01-22 17:28:26 -08:00
Joshua Batista 00e170f348
Implement wave size range (#6167)
Wave Size should be able to take a range of possible wavesizes. This PR
aims to implement what is described in this spec:
https://github.com/microsoft/hlsl-specs/pull/149/files

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-01-20 06:16:03 +00:00
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