Skip to content

Commit 836012d

Browse files
committed
Merge remote-tracking branch 'ms/main' into ser_dxilaccessors_patch
2 parents 0e4bad5 + 0168df1 commit 836012d

72 files changed

Lines changed: 3013 additions & 280 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.

include/dxc/DXIL/DxilConstants.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ enum class OpCode : unsigned {
503503
ReservedA1 = 260, // reserved
504504
ReservedA2 = 261, // reserved
505505
ReservedB0 = 262, // reserved
506-
ReservedB1 = 263, // reserved
507-
ReservedB2 = 264, // reserved
508506
ReservedB28 = 290, // reserved
509507
ReservedB29 = 291, // reserved
510508
ReservedB30 = 292, // reserved
@@ -905,6 +903,11 @@ enum class OpCode : unsigned {
905903
HitObject_IsNop = 271, // Returns `true` if the HitObject represents a nop
906904
HitObject_LoadLocalRootTableConstant =
907905
288, // Returns the root table constant for this HitObject and offset
906+
HitObject_FromRayQuery = 263, // Creates a new HitObject representing a
907+
// committed hit from a RayQuery
908+
HitObject_FromRayQueryWithAttrs =
909+
264, // Creates a new HitObject representing a committed hit from a
910+
// RayQuery and committed attributes
908911
HitObject_MakeMiss = 265, // Creates a new HitObject representing a miss
909912
HitObject_MakeNop = 266, // Creates an empty nop HitObject
910913
HitObject_ObjectRayDirection =
@@ -1304,6 +1307,8 @@ enum class OpCodeClass : unsigned {
13041307
// Shader Execution Reordering
13051308
HitObject_Attributes,
13061309
HitObject_LoadLocalRootTableConstant,
1310+
HitObject_FromRayQuery,
1311+
HitObject_FromRayQueryWithAttrs,
13071312
HitObject_MakeMiss,
13081313
HitObject_MakeNop,
13091314
HitObject_SetShaderTableIndex,
@@ -1375,7 +1380,7 @@ enum class OpCodeClass : unsigned {
13751380
NumOpClasses_Dxil_1_7 = 153,
13761381
NumOpClasses_Dxil_1_8 = 174,
13771382

1378-
NumOpClasses = 185 // exclusive last value of enumeration
1383+
NumOpClasses = 187 // exclusive last value of enumeration
13791384
};
13801385
// OPCODECLASS-ENUM:END
13811386

@@ -1919,7 +1924,9 @@ enum class BarrierSemanticFlag : uint32_t {
19191924
GroupSync = 0x00000001, // GROUP_SYNC
19201925
GroupScope = 0x00000002, // GROUP_SCOPE
19211926
DeviceScope = 0x00000004, // DEVICE_SCOPE
1922-
ValidMask = 0x00000007,
1927+
LegacyFlags = 0x00000007,
1928+
ReorderScope = 0x00000008, // REORDER_SCOPE
1929+
ValidMask = 0x0000000F,
19231930
GroupFlags = GroupSync | GroupScope,
19241931
};
19251932

include/dxc/DXIL/DxilInstructions.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8850,6 +8850,69 @@ struct DxilInst_AllocateRayQuery2 {
88508850
}
88518851
};
88528852

8853+
/// This instruction Creates a new HitObject representing a committed hit from a
8854+
/// RayQuery
8855+
struct DxilInst_HitObject_FromRayQuery {
8856+
llvm::Instruction *Instr;
8857+
// Construction and identification
8858+
DxilInst_HitObject_FromRayQuery(llvm::Instruction *pInstr) : Instr(pInstr) {}
8859+
operator bool() const {
8860+
return hlsl::OP::IsDxilOpFuncCallInst(
8861+
Instr, hlsl::OP::OpCode::HitObject_FromRayQuery);
8862+
}
8863+
// Validation support
8864+
bool isAllowed() const { return true; }
8865+
bool isArgumentListValid() const {
8866+
if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
8867+
return false;
8868+
return true;
8869+
}
8870+
// Metadata
8871+
bool requiresUniformInputs() const { return false; }
8872+
// Operand indexes
8873+
enum OperandIdx {
8874+
arg_rayQueryHandle = 1,
8875+
};
8876+
// Accessors
8877+
llvm::Value *get_rayQueryHandle() const { return Instr->getOperand(1); }
8878+
void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); }
8879+
};
8880+
8881+
/// This instruction Creates a new HitObject representing a committed hit from a
8882+
/// RayQuery and committed attributes
8883+
struct DxilInst_HitObject_FromRayQueryWithAttrs {
8884+
llvm::Instruction *Instr;
8885+
// Construction and identification
8886+
DxilInst_HitObject_FromRayQueryWithAttrs(llvm::Instruction *pInstr)
8887+
: Instr(pInstr) {}
8888+
operator bool() const {
8889+
return hlsl::OP::IsDxilOpFuncCallInst(
8890+
Instr, hlsl::OP::OpCode::HitObject_FromRayQueryWithAttrs);
8891+
}
8892+
// Validation support
8893+
bool isAllowed() const { return true; }
8894+
bool isArgumentListValid() const {
8895+
if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
8896+
return false;
8897+
return true;
8898+
}
8899+
// Metadata
8900+
bool requiresUniformInputs() const { return false; }
8901+
// Operand indexes
8902+
enum OperandIdx {
8903+
arg_rayQueryHandle = 1,
8904+
arg_HitKind = 2,
8905+
arg_CommittedAttribs = 3,
8906+
};
8907+
// Accessors
8908+
llvm::Value *get_rayQueryHandle() const { return Instr->getOperand(1); }
8909+
void set_rayQueryHandle(llvm::Value *val) { Instr->setOperand(1, val); }
8910+
llvm::Value *get_HitKind() const { return Instr->getOperand(2); }
8911+
void set_HitKind(llvm::Value *val) { Instr->setOperand(2, val); }
8912+
llvm::Value *get_CommittedAttribs() const { return Instr->getOperand(3); }
8913+
void set_CommittedAttribs(llvm::Value *val) { Instr->setOperand(3, val); }
8914+
};
8915+
88538916
/// This instruction Creates a new HitObject representing a miss
88548917
struct DxilInst_HitObject_MakeMiss {
88558918
llvm::Instruction *Instr;

include/dxc/DXIL/DxilMetadataHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ class DxilMDHelper {
233233
static const unsigned kDxilStructuredBufferElementStrideTag = 1;
234234
static const unsigned kDxilSamplerFeedbackKindTag = 2;
235235
static const unsigned kDxilAtomic64UseTag = 3;
236+
static const unsigned kDxilReorderCoherentTag = 4;
236237

237238
// Type system.
238239
static const char kDxilTypeSystemMDName[];

include/dxc/DXIL/DxilOperations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class OP {
151151
static bool IsDxilOpBarrier(OpCode C);
152152
static bool BarrierRequiresGroup(const llvm::CallInst *CI);
153153
static bool BarrierRequiresNode(const llvm::CallInst *CI);
154+
static bool BarrierRequiresReorder(const llvm::CallInst *CI);
154155
static DXIL::BarrierMode TranslateToBarrierMode(const llvm::CallInst *CI);
155156
static void GetMinShaderModelAndMask(OpCode C, bool bWithTranslation,
156157
unsigned &major, unsigned &minor,

include/dxc/DXIL/DxilResource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class DxilResource : public DxilResourceBase {
6363

6464
bool IsGloballyCoherent() const;
6565
void SetGloballyCoherent(bool b);
66+
bool IsReorderCoherent() const;
67+
void SetReorderCoherent(bool b);
6668
bool HasCounter() const;
6769
void SetHasCounter(bool b);
6870

@@ -97,6 +99,7 @@ class DxilResource : public DxilResourceBase {
9799
CompType m_CompType;
98100
DXIL::SamplerFeedbackType m_SamplerFeedbackType;
99101
bool m_bGloballyCoherent;
102+
bool m_bReorderCoherent;
100103
bool m_bHasCounter;
101104
bool m_bROV;
102105
bool m_bHasAtomic64Use;

include/dxc/DXIL/DxilResourceProperties.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ struct DxilResourceProperties {
4747
uint8_t SamplerCmpOrHasCounter : 1;
4848

4949
// BYTE 2
50-
uint8_t Reserved2;
50+
uint8_t IsReorderCoherent : 1;
51+
uint8_t Reserved2 : 7;
5152

5253
// BYTE 3
5354
uint8_t Reserved3;

include/dxc/DxilContainer/RDAT_LibraryTypes.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RDAT_ENUM_START(DxilResourceFlag, uint32_t)
2222
RDAT_ENUM_VALUE(UAVRasterizerOrderedView, 1 << 2)
2323
RDAT_ENUM_VALUE(DynamicIndexing, 1 << 3)
2424
RDAT_ENUM_VALUE(Atomics64Use, 1 << 4)
25+
RDAT_ENUM_VALUE(UAVReorderCoherent, 1 << 5)
2526
RDAT_ENUM_END()
2627

2728
RDAT_ENUM_START(DxilShaderStageFlags, uint32_t)

lib/DXIL/DxilMetadataHelper.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,6 +3110,13 @@ void DxilExtraPropertyHelper::EmitUAVProperties(
31103110
DxilMDHelper::kDxilAtomic64UseTag, m_Ctx));
31113111
MDVals.emplace_back(DxilMDHelper::Uint32ToConstMD((unsigned)true, m_Ctx));
31123112
}
3113+
// Whether resource is reordercoherent.
3114+
if (DXIL::CompareVersions(m_ValMajor, m_ValMinor, 1, 9) >= 0 &&
3115+
UAV.IsReorderCoherent()) {
3116+
MDVals.emplace_back(DxilMDHelper::Uint32ToConstMD(
3117+
DxilMDHelper::kDxilReorderCoherentTag, m_Ctx));
3118+
MDVals.emplace_back(DxilMDHelper::BoolToConstMD(true, m_Ctx));
3119+
}
31133120
}
31143121

31153122
void DxilExtraPropertyHelper::LoadUAVProperties(const MDOperand &MDO,
@@ -3147,6 +3154,9 @@ void DxilExtraPropertyHelper::LoadUAVProperties(const MDOperand &MDO,
31473154
case DxilMDHelper::kDxilAtomic64UseTag:
31483155
UAV.SetHasAtomic64Use(DxilMDHelper::ConstMDToBool(MDO));
31493156
break;
3157+
case DxilMDHelper::kDxilReorderCoherentTag:
3158+
UAV.SetReorderCoherent(DxilMDHelper::ConstMDToBool(MDO));
3159+
break;
31503160
default:
31513161
DXASSERT(false, "Unknown resource record tag");
31523162
m_bExtraMetadata = true;

0 commit comments

Comments
 (0)