Skip to content

Commit 3f88438

Browse files
committed
Merge remote-tracking branch 'msft/main' into ser_dxilfromrq_patch
2 parents 59c89d1 + c940161 commit 3f88438

96 files changed

Lines changed: 9923 additions & 5111 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: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ const float kMinMipLodBias = -16.0f;
155155

156156
const unsigned kResRetStatusIndex = 4;
157157

158+
/* <py::lines('OLOAD_DIMS-TEXT')>hctdb_instrhelp.get_max_oload_dims()</py>*/
159+
// OLOAD_DIMS-TEXT:BEGIN
160+
const unsigned kDxilMaxOloadDims = 2;
161+
// OLOAD_DIMS-TEXT:END
162+
158163
enum class ComponentType : uint32_t {
159164
Invalid = 0,
160165
I1,
@@ -891,8 +896,11 @@ enum class OpCode : unsigned {
891896
GetDimensions = 72, // gets texture size information
892897
RawBufferLoad = 139, // reads from a raw buffer and structured buffer
893898
RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer
894-
TextureLoad = 66, // reads texel data without any filtering or sampling
895-
TextureStore = 67, // reads texel data without any filtering or sampling
899+
RawBufferVectorLoad = 303, // reads from a raw buffer and structured buffer
900+
RawBufferVectorStore =
901+
304, // writes to a RWByteAddressBuffer or RWStructuredBuffer
902+
TextureLoad = 66, // reads texel data without any filtering or sampling
903+
TextureStore = 67, // reads texel data without any filtering or sampling
896904
TextureStoreSample = 225, // stores texel data at specified sample index
897905

898906
// Sampler Feedback
@@ -1042,7 +1050,7 @@ enum class OpCode : unsigned {
10421050
NumOpCodes_Dxil_1_7 = 226,
10431051
NumOpCodes_Dxil_1_8 = 258,
10441052

1045-
NumOpCodes = 303 // exclusive last value of enumeration
1053+
NumOpCodes = 305 // exclusive last value of enumeration
10461054
};
10471055
// OPCODE-ENUM:END
10481056

@@ -1276,6 +1284,8 @@ enum class OpCodeClass : unsigned {
12761284
GetDimensions,
12771285
RawBufferLoad,
12781286
RawBufferStore,
1287+
RawBufferVectorLoad,
1288+
RawBufferVectorStore,
12791289
TextureLoad,
12801290
TextureStore,
12811291
TextureStoreSample,
@@ -1356,7 +1366,7 @@ enum class OpCodeClass : unsigned {
13561366
NumOpClasses_Dxil_1_7 = 153,
13571367
NumOpClasses_Dxil_1_8 = 174,
13581368

1359-
NumOpClasses = 179 // exclusive last value of enumeration
1369+
NumOpClasses = 181 // exclusive last value of enumeration
13601370
};
13611371
// OPCODECLASS-ENUM:END
13621372

@@ -1415,6 +1425,12 @@ const unsigned kRawBufferLoadElementOffsetOpIdx = 3;
14151425
const unsigned kRawBufferLoadMaskOpIdx = 4;
14161426
const unsigned kRawBufferLoadAlignmentOpIdx = 5;
14171427

1428+
// RawBufferVectorLoad.
1429+
const unsigned kRawBufferVectorLoadHandleOpIdx = 1;
1430+
const unsigned kRawBufferVectorLoadIndexOpIdx = 2;
1431+
const unsigned kRawBufferVectorLoadElementOffsetOpIdx = 3;
1432+
const unsigned kRawBufferVectorLoadAlignmentOpIdx = 4;
1433+
14181434
// RawBufferStore
14191435
const unsigned kRawBufferStoreHandleOpIdx = 1;
14201436
const unsigned kRawBufferStoreIndexOpIdx = 2;
@@ -1424,7 +1440,14 @@ const unsigned kRawBufferStoreVal1OpIdx = 5;
14241440
const unsigned kRawBufferStoreVal2OpIdx = 6;
14251441
const unsigned kRawBufferStoreVal3OpIdx = 7;
14261442
const unsigned kRawBufferStoreMaskOpIdx = 8;
1427-
const unsigned kRawBufferStoreAlignmentOpIdx = 8;
1443+
const unsigned kRawBufferStoreAlignmentOpIdx = 9;
1444+
1445+
// RawBufferVectorStore
1446+
const unsigned kRawBufferVectorStoreHandleOpIdx = 1;
1447+
const unsigned kRawBufferVectorStoreIndexOpIdx = 2;
1448+
const unsigned kRawBufferVectorStoreElementOffsetOpIdx = 3;
1449+
const unsigned kRawBufferVectorStoreValOpIdx = 4;
1450+
const unsigned kRawBufferVectorStoreAlignmentOpIdx = 5;
14281451

14291452
// TextureStore.
14301453
const unsigned kTextureStoreHandleOpIdx = 1;

include/dxc/DXIL/DxilInstructions.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8986,5 +8986,98 @@ struct DxilInst_HitObject_MakeNop {
89868986
// Metadata
89878987
bool requiresUniformInputs() const { return false; }
89888988
};
8989+
8990+
/// This instruction reads from a raw buffer and structured buffer
8991+
struct DxilInst_RawBufferVectorLoad {
8992+
llvm::Instruction *Instr;
8993+
// Construction and identification
8994+
DxilInst_RawBufferVectorLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}
8995+
operator bool() const {
8996+
return hlsl::OP::IsDxilOpFuncCallInst(
8997+
Instr, hlsl::OP::OpCode::RawBufferVectorLoad);
8998+
}
8999+
// Validation support
9000+
bool isAllowed() const { return true; }
9001+
bool isArgumentListValid() const {
9002+
if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
9003+
return false;
9004+
return true;
9005+
}
9006+
// Metadata
9007+
bool requiresUniformInputs() const { return false; }
9008+
// Operand indexes
9009+
enum OperandIdx {
9010+
arg_buf = 1,
9011+
arg_index = 2,
9012+
arg_elementOffset = 3,
9013+
arg_alignment = 4,
9014+
};
9015+
// Accessors
9016+
llvm::Value *get_buf() const { return Instr->getOperand(1); }
9017+
void set_buf(llvm::Value *val) { Instr->setOperand(1, val); }
9018+
llvm::Value *get_index() const { return Instr->getOperand(2); }
9019+
void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
9020+
llvm::Value *get_elementOffset() const { return Instr->getOperand(3); }
9021+
void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); }
9022+
llvm::Value *get_alignment() const { return Instr->getOperand(4); }
9023+
void set_alignment(llvm::Value *val) { Instr->setOperand(4, val); }
9024+
int32_t get_alignment_val() const {
9025+
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(4))
9026+
->getZExtValue());
9027+
}
9028+
void set_alignment_val(int32_t val) {
9029+
Instr->setOperand(4, llvm::Constant::getIntegerValue(
9030+
llvm::IntegerType::get(Instr->getContext(), 32),
9031+
llvm::APInt(32, (uint64_t)val)));
9032+
}
9033+
};
9034+
9035+
/// This instruction writes to a RWByteAddressBuffer or RWStructuredBuffer
9036+
struct DxilInst_RawBufferVectorStore {
9037+
llvm::Instruction *Instr;
9038+
// Construction and identification
9039+
DxilInst_RawBufferVectorStore(llvm::Instruction *pInstr) : Instr(pInstr) {}
9040+
operator bool() const {
9041+
return hlsl::OP::IsDxilOpFuncCallInst(
9042+
Instr, hlsl::OP::OpCode::RawBufferVectorStore);
9043+
}
9044+
// Validation support
9045+
bool isAllowed() const { return true; }
9046+
bool isArgumentListValid() const {
9047+
if (6 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
9048+
return false;
9049+
return true;
9050+
}
9051+
// Metadata
9052+
bool requiresUniformInputs() const { return false; }
9053+
// Operand indexes
9054+
enum OperandIdx {
9055+
arg_uav = 1,
9056+
arg_index = 2,
9057+
arg_elementOffset = 3,
9058+
arg_value0 = 4,
9059+
arg_alignment = 5,
9060+
};
9061+
// Accessors
9062+
llvm::Value *get_uav() const { return Instr->getOperand(1); }
9063+
void set_uav(llvm::Value *val) { Instr->setOperand(1, val); }
9064+
llvm::Value *get_index() const { return Instr->getOperand(2); }
9065+
void set_index(llvm::Value *val) { Instr->setOperand(2, val); }
9066+
llvm::Value *get_elementOffset() const { return Instr->getOperand(3); }
9067+
void set_elementOffset(llvm::Value *val) { Instr->setOperand(3, val); }
9068+
llvm::Value *get_value0() const { return Instr->getOperand(4); }
9069+
void set_value0(llvm::Value *val) { Instr->setOperand(4, val); }
9070+
llvm::Value *get_alignment() const { return Instr->getOperand(5); }
9071+
void set_alignment(llvm::Value *val) { Instr->setOperand(5, val); }
9072+
int32_t get_alignment_val() const {
9073+
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(5))
9074+
->getZExtValue());
9075+
}
9076+
void set_alignment_val(int32_t val) {
9077+
Instr->setOperand(5, llvm::Constant::getIntegerValue(
9078+
llvm::IntegerType::get(Instr->getContext(), 32),
9079+
llvm::APInt(32, (uint64_t)val)));
9080+
}
9081+
};
89899082
// INSTR-HELPER:END
89909083
} // namespace hlsl

0 commit comments

Comments
 (0)