Skip to content

Commit d478b86

Browse files
authored
Merge branch 'main' to staging-sm6.9 (#7328)
Conflicts: both modified: include/dxc/DXIL/DxilConstants.h both modified: include/dxc/DXIL/DxilOperations.h both modified: lib/DXIL/DxilOperations.cpp both modified: lib/DxilValidation/DxilValidation.cpp both modified: lib/HLSL/DxilLinker.cpp both added: lib/HLSL/DxilScalarizeVectorLoadStores.cpp both modified: lib/HLSL/HLOperationLower.cpp both modified: tools/clang/lib/Sema/SemaHLSL.cpp both added: tools/clang/test/CodeGenDXIL/hlsl/intrinsics/buffer-load-stores-sm69.hlsl both added: tools/clang/test/CodeGenDXIL/hlsl/types/longvec-operators-cs.hlsl both added: tools/clang/test/DXILValidation/vector-validation.hlsl both modified: utils/hct/hctdb.py both modified: utils/hct/hctdb_instrhelp.py
2 parents 73c4208 + f69f281 commit d478b86

91 files changed

Lines changed: 5628 additions & 2177 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* @microsoft/hlsl-release
1+
# Uncomment the next line in release branches after ask-mode begins
2+
# * @microsoft/hlsl-release

CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ if(POLICY CMP0022)
1717
cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
1818
endif()
1919

20-
if (POLICY CMP0051)
21-
# CMake 3.1 and higher include generator expressions of the form
22-
# $<TARGETLIB:obj> in the SOURCES property. These need to be
23-
# stripped everywhere that access the SOURCES property, so we just
24-
# defer to the OLD behavior of not including generator expressions
25-
# in the output for now.
26-
cmake_policy(SET CMP0051 OLD)
27-
endif()
28-
2920
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
3021
set(cmake_3_2_USES_TERMINAL)
3122
else()

CONTRIBUTING.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,32 @@ Before submitting a feature or substantial code contribution please discuss it w
4040

4141
### Coding guidelines
4242

43-
The coding, style, and general engineering guidelines follow those described in the docs/CodingStandards.rst. For additional guidelines in code specific to HLSL, see the docs/HLSLChanges.rst file.
43+
The coding, style, and general engineering guidelines follow those described in the [LLVM Coding Standards](docs/CodingStandards.rst). For additional guidelines in code specific to HLSL, see the [HLSL Changes](docs/HLSLChanges.rst) docs.
4444

4545
DXC has adopted a clang-format requirement for all incoming changes to C and C++ files. PRs to DXC should have the *changed code* clang formatted to the LLVM style, and leave the remaining portions of the file unchanged. This can be done using the `git-clang-format` tool or IDE driven workflows. A GitHub action will run on all PRs to validate that the change is properly formatted.
4646

47+
#### Applying LLVM Standards
48+
49+
All new code contributed to DXC should follow the LLVM coding standards.
50+
51+
Note that the LLVM Coding Standards have a golden rule:
52+
53+
> **If you are extending, enhancing, or bug fixing already implemented code, use the style that is already being used so that the source is uniform and easy to follow.**
54+
55+
The golden rule should continue to be applied to places where DXC is self-consistent. A good example is DXC's common use of `PascalCase` instead of `camelCase` for APIs in some parts of the HLSL implementation. In any place where DXC is not self-consistent new code should follow the LLVM Coding Standard.
56+
57+
A good secondary rule to follow is:
58+
59+
> **When in doubt, follow LLVM.**
60+
61+
Adopting LLVM's coding standards provides a consistent set of rules and guidelines to hold all contributions to. This allows patch authors to clearly understand the expectations placed on contributions, and allows reviewers to have a bar to measure contributions against. Aligning with LLVM by default ensures the path of least resistance for everyone.
62+
63+
Since many of the LLVM Coding Standards are not enforced automatically we rely on code reviews to provide feedback and ensure contributions align with the expected coding standards. Since we rely on reviewers for enforcement and humans make mistakes, please keep in mind:
64+
65+
> **Code review is a conversation.**
66+
67+
It is completely reasonable for a patch author to question feedback and provide additional context about why something was done the way it was. Reviewers often see narrow slices in diffs rather than the full context of a file or part of the compiler, so they may not always provide perfect feedback. This is especially true with the application of the "golden rule" since it depends on understanding a wider context.
68+
4769
### Documenting Pull Requests
4870

4971
Pull request descriptions should have the following format:

docs/SPIR-V.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ Supported extensions
320320
* SPV_KHR_maximal_reconvergence
321321
* SPV_KHR_float_controls
322322
* SPV_NV_shader_subgroup_partitioned
323+
* SPV_KHR_quad_control
323324

324325
Vulkan specific attributes
325326
--------------------------
@@ -4008,6 +4009,8 @@ Quad ``QuadReadAcrossX()`` ``OpGroupNonUniformQuadSwap``
40084009
Quad ``QuadReadAcrossY()`` ``OpGroupNonUniformQuadSwap``
40094010
Quad ``QuadReadAcrossDiagonal()`` ``OpGroupNonUniformQuadSwap``
40104011
Quad ``QuadReadLaneAt()`` ``OpGroupNonUniformQuadBroadcast``
4012+
Quad ``QuadAny()`` ``OpGroupNonUniformQuadAnyKHR``
4013+
Quad ``QuadAll()`` ``OpGroupNonUniformQuadAllKHR``
40114014
N/A ``WaveMatch()`` ``OpGroupNonUniformPartitionNV``
40124015
Multiprefix ``WaveMultiPrefixSum()`` ``OpGroupNonUniform*Add`` ``PartitionedExclusiveScanNV``
40134016
Multiprefix ``WaveMultiPrefixProduct()`` ``OpGroupNonUniform*Mul`` ``PartitionedExclusiveScanNV``
@@ -4016,6 +4019,11 @@ Multiprefix ``WaveMultiPrefixBitOr()`` ``OpGroupNonUniformLogicalOr`` `
40164019
Multiprefix ``WaveMultiPrefixBitXor()`` ``OpGroupNonUniformLogicalXor`` ``PartitionedExclusiveScanNV``
40174020
============= ============================ =================================== ==============================
40184021

4022+
``QuadAny`` and ``QuadAll`` will use the ``OpGroupNonUniformQuadAnyKHR`` and
4023+
``OpGroupNonUniformQuadAllKHR`` instructions if the ``SPV_KHR_quad_control``
4024+
extension is enabled. If it is not, they will fall back to constructing the
4025+
value using multiple calls to ``OpGroupNonUniformQuadBroadcast``.
4026+
40194027
The Implicit ``vk`` Namespace
40204028
=============================
40214029

include/dxc/DXIL/DxilConstants.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,6 @@ inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) {
487487
// Enumeration for operations specified by DXIL
488488
enum class OpCode : unsigned {
489489
//
490-
RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer
491-
RawBufferVectorStore =
492-
304, // writes to a RWByteAddressBuffer or RWStructuredBuffer
493490
Reserved0 = 226, // Reserved
494491
Reserved1 = 227, // Reserved
495492
Reserved10 = 236, // Reserved
@@ -901,8 +898,11 @@ enum class OpCode : unsigned {
901898
GetDimensions = 72, // gets texture size information
902899
RawBufferLoad = 139, // reads from a raw buffer and structured buffer
903900
RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer
904-
TextureLoad = 66, // reads texel data without any filtering or sampling
905-
TextureStore = 67, // reads texel data without any filtering or sampling
901+
RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer
902+
RawBufferVectorStore =
903+
304, // writes to a RWByteAddressBuffer or RWStructuredBuffer
904+
TextureLoad = 66, // reads texel data without any filtering or sampling
905+
TextureStore = 67, // reads texel data without any filtering or sampling
906906
TextureStoreSample = 225, // stores texel data at specified sample index
907907

908908
// Sampler Feedback
@@ -1046,7 +1046,6 @@ enum class OpCode : unsigned {
10461046
NumOpCodes_Dxil_1_6 = 222,
10471047
NumOpCodes_Dxil_1_7 = 226,
10481048
NumOpCodes_Dxil_1_8 = 258,
1049-
NumOpCodes_Dxil_1_9 = 305,
10501049

10511050
NumOpCodes = 305 // exclusive last value of enumeration
10521051
};
@@ -1060,8 +1059,6 @@ enum class OpCode : unsigned {
10601059
// Groups for DXIL operations with equivalent function templates
10611060
enum class OpCodeClass : unsigned {
10621061
//
1063-
RawBufferVectorLoad,
1064-
RawBufferVectorStore,
10651062
Reserved,
10661063

10671064
// Amplification shader instructions
@@ -1284,6 +1281,8 @@ enum class OpCodeClass : unsigned {
12841281
GetDimensions,
12851282
RawBufferLoad,
12861283
RawBufferStore,
1284+
RawBufferVectorLoad,
1285+
RawBufferVectorStore,
12871286
TextureLoad,
12881287
TextureStore,
12891288
TextureStoreSample,
@@ -1361,7 +1360,6 @@ enum class OpCodeClass : unsigned {
13611360
NumOpClasses_Dxil_1_6 = 149,
13621361
NumOpClasses_Dxil_1_7 = 153,
13631362
NumOpClasses_Dxil_1_8 = 174,
1364-
NumOpClasses_Dxil_1_9 = 179,
13651363

13661364
NumOpClasses = 179 // exclusive last value of enumeration
13671365
};
@@ -1422,6 +1420,12 @@ const unsigned kRawBufferLoadElementOffsetOpIdx = 3;
14221420
const unsigned kRawBufferLoadMaskOpIdx = 4;
14231421
const unsigned kRawBufferLoadAlignmentOpIdx = 5;
14241422

1423+
// RawBufferVectorLoad.
1424+
const unsigned kRawBufferVectorLoadHandleOpIdx = 1;
1425+
const unsigned kRawBufferVectorLoadIndexOpIdx = 2;
1426+
const unsigned kRawBufferVectorLoadElementOffsetOpIdx = 3;
1427+
const unsigned kRawBufferVectorLoadAlignmentOpIdx = 4;
1428+
14251429
// RawBufferStore
14261430
const unsigned kRawBufferStoreHandleOpIdx = 1;
14271431
const unsigned kRawBufferStoreIndexOpIdx = 2;
@@ -1433,6 +1437,13 @@ const unsigned kRawBufferStoreVal3OpIdx = 7;
14331437
const unsigned kRawBufferStoreMaskOpIdx = 8;
14341438
const unsigned kRawBufferStoreAlignmentOpIdx = 9;
14351439

1440+
// RawBufferVectorStore
1441+
const unsigned kRawBufferVectorStoreHandleOpIdx = 1;
1442+
const unsigned kRawBufferVectorStoreIndexOpIdx = 2;
1443+
const unsigned kRawBufferVectorStoreElementOffsetOpIdx = 3;
1444+
const unsigned kRawBufferVectorStoreValOpIdx = 4;
1445+
const unsigned kRawBufferVectorStoreAlignmentOpIdx = 5;
1446+
14361447
// TextureStore.
14371448
const unsigned kTextureStoreHandleOpIdx = 1;
14381449
const unsigned kTextureStoreCoord0OpIdx = 2;

include/dxc/DXIL/DxilOperations.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ class OP {
162162

163163
static bool IsDxilOpExtendedOverload(OpCode C);
164164

165-
// Return true if the overload name for this operation may be constructed
166-
// based on a type name that may not represent the same type in different
167-
// modules.
165+
// Return true if the overload name suffix for this operation may be
166+
// constructed based on a user-defined or user-influenced type name
167+
// that may not represent the same type in different linked modules.
168168
static bool MayHaveNonCanonicalOverload(OpCode OC);
169169

170170
private:

include/dxc/DxilPIXPasses/DxilPIXPasses.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ModulePass *createDxilDebugInstrumentationPass();
2727
ModulePass *createDxilShaderAccessTrackingPass();
2828
ModulePass *createDxilPIXAddTidToAmplificationShaderPayloadPass();
2929
ModulePass *createDxilPIXDXRInvocationsLogPass();
30+
ModulePass *createDxilNonUniformResourceIndexInstrumentationPass();
3031

3132
void initializeDxilAddPixelHitInstrumentationPass(llvm::PassRegistry &);
3233
void initializeDxilDbgValueToDbgDeclarePass(llvm::PassRegistry &);
@@ -41,5 +42,7 @@ void initializeDxilShaderAccessTrackingPass(llvm::PassRegistry &);
4142
void initializeDxilPIXAddTidToAmplificationShaderPayloadPass(
4243
llvm::PassRegistry &);
4344
void initializeDxilPIXDXRInvocationsLogPass(llvm::PassRegistry &);
45+
void initializeDxilNonUniformResourceIndexInstrumentationPass(
46+
llvm::PassRegistry &);
4447

4548
} // namespace llvm

include/dxc/HlslIntrinsicOp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ enum class IntrinsicOp {
231231
IOP_VkReadClock = 223,
232232
IOP_Vkext_execution_mode = 224,
233233
IOP_Vkext_execution_mode_id = 225,
234+
IOP_Vkreinterpret_pointer_cast = 360,
235+
IOP_Vkstatic_pointer_cast = 361,
236+
MOP_GetBufferContents = 362,
234237
MOP_Append = 226,
235238
MOP_RestartStrip = 227,
236239
MOP_CalculateLevelOfDetail = 228,
@@ -366,7 +369,7 @@ enum class IntrinsicOp {
366369
IOP_usign = 355,
367370
MOP_InterlockedUMax = 356,
368371
MOP_InterlockedUMin = 357,
369-
Num_Intrinsics = 360,
372+
Num_Intrinsics = 363,
370373
};
371374
inline bool HasUnsignedIntrinsicOpcode(IntrinsicOp opcode) {
372375
switch (opcode) {

include/dxc/WinAdapter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
#define _countof(a) (sizeof(a) / sizeof(*(a)))
5252

5353
// If it is GCC, there is no UUID support and we must emulate it.
54-
#ifndef __clang__
54+
// Clang support depends on the -fms-extensions compiler flag.
55+
#if !defined(__clang__) || !defined(_MSC_EXTENSIONS)
5556
#define __EMULATE_UUID 1
5657
#endif // __clang__
5758

0 commit comments

Comments
 (0)