Skip to content

Commit bef6468

Browse files
Dan Brownyavn
andcommitted
Add SPV_AMDX_shader_enqueue version 2 support
* Update SPIRV-Headers Co-authored-by: Dan Brown <daniel.brown@amd.com> Co-authored-by: Maciej Jesionowski <maciej.jesionowski@amd.com>
1 parent fcf994a commit bef6468

19 files changed

+154
-15
lines changed

DEPS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vars = {
1414

1515
're2_revision': '6dcd83d60f7944926bfd308cc13979fc53dd69ca',
1616

17-
'spirv_headers_revision': 'd92cf88c371424591115a87499009dfad41b669c',
17+
'spirv_headers_revision': '07ddb1c0f1ffa929262d4568481a692bb0fb1535',
1818
}
1919

2020
deps = {
@@ -37,4 +37,3 @@ deps = {
3737
Var('github') + '/KhronosGroup/SPIRV-Headers.git@' +
3838
Var('spirv_headers_revision'),
3939
}
40-

source/name_mapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) 2016 Google Inc.
2+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
3+
// reserved.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");
46
// you may not use this file except in compliance with the License.
@@ -241,6 +243,10 @@ spv_result_t FriendlyNameMapper::ParseInstruction(
241243
SaveName(result_id,
242244
std::string("_runtimearr_") + NameForId(inst.words[2]));
243245
break;
246+
case spv::Op::OpTypeNodePayloadArrayAMDX:
247+
SaveName(result_id,
248+
std::string("_payloadarr_") + NameForId(inst.words[2]));
249+
break;
244250
case spv::Op::OpTypePointer:
245251
SaveName(result_id, std::string("_ptr_") +
246252
NameForEnumOperand(SPV_OPERAND_TYPE_STORAGE_CLASS,

source/opcode.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2015-2022 The Khronos Group Inc.
2-
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
3-
// reserved.
2+
// Modifications Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All
3+
// rights reserved.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.
@@ -265,12 +265,14 @@ int32_t spvOpcodeIsConstant(const spv::Op opcode) {
265265
case spv::Op::OpConstantSampler:
266266
case spv::Op::OpConstantNull:
267267
case spv::Op::OpConstantFunctionPointerINTEL:
268+
case spv::Op::OpConstantStringAMDX:
268269
case spv::Op::OpSpecConstantTrue:
269270
case spv::Op::OpSpecConstantFalse:
270271
case spv::Op::OpSpecConstant:
271272
case spv::Op::OpSpecConstantComposite:
272273
case spv::Op::OpSpecConstantCompositeReplicateEXT:
273274
case spv::Op::OpSpecConstantOp:
275+
case spv::Op::OpSpecConstantStringAMDX:
274276
return true;
275277
default:
276278
return false;
@@ -318,6 +320,7 @@ bool spvOpcodeReturnsLogicalVariablePointer(const spv::Op opcode) {
318320
case spv::Op::OpFunctionParameter:
319321
case spv::Op::OpImageTexelPointer:
320322
case spv::Op::OpCopyObject:
323+
case spv::Op::OpAllocateNodePayloadsAMDX:
321324
case spv::Op::OpSelect:
322325
case spv::Op::OpPhi:
323326
case spv::Op::OpFunctionCall:
@@ -344,6 +347,7 @@ int32_t spvOpcodeReturnsLogicalPointer(const spv::Op opcode) {
344347
case spv::Op::OpImageTexelPointer:
345348
case spv::Op::OpCopyObject:
346349
case spv::Op::OpRawAccessChainNV:
350+
case spv::Op::OpAllocateNodePayloadsAMDX:
347351
return true;
348352
default:
349353
return false;
@@ -382,6 +386,7 @@ int32_t spvOpcodeGeneratesType(spv::Op op) {
382386
case spv::Op::OpTypeRayQueryKHR:
383387
case spv::Op::OpTypeHitObjectNV:
384388
case spv::Op::OpTypeUntypedPointerKHR:
389+
case spv::Op::OpTypeNodePayloadArrayAMDX:
385390
return true;
386391
default:
387392
// In particular, OpTypeForwardPointer does not generate a type,

source/opt/fix_storage_class.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) 2019 Google LLC
2+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
3+
// reserved.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");
46
// you may not use this file except in compliance with the License.
@@ -99,6 +101,7 @@ bool FixStorageClass::PropagateStorageClass(Instruction* inst,
99101
case spv::Op::OpCopyMemorySized:
100102
case spv::Op::OpVariable:
101103
case spv::Op::OpBitcast:
104+
case spv::Op::OpAllocateNodePayloadsAMDX:
102105
// Nothing to change for these opcode. The result type is the same
103106
// regardless of the storage class of the operand.
104107
return false;
@@ -319,6 +322,7 @@ uint32_t FixStorageClass::WalkAccessChainType(Instruction* inst, uint32_t id) {
319322
switch (type_inst->opcode()) {
320323
case spv::Op::OpTypeArray:
321324
case spv::Op::OpTypeRuntimeArray:
325+
case spv::Op::OpTypeNodePayloadArrayAMDX:
322326
case spv::Op::OpTypeMatrix:
323327
case spv::Op::OpTypeVector:
324328
case spv::Op::OpTypeCooperativeMatrixKHR:

source/opt/ir_context.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) 2017 Google Inc.
2+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
3+
// reserved.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");
46
// you may not use this file except in compliance with the License.
@@ -539,6 +541,7 @@ void IRContext::AddCombinatorsForCapability(uint32_t capability) {
539541
(uint32_t)spv::Op::OpTypeHitObjectNV,
540542
(uint32_t)spv::Op::OpTypeArray,
541543
(uint32_t)spv::Op::OpTypeRuntimeArray,
544+
(uint32_t)spv::Op::OpTypeNodePayloadArrayAMDX,
542545
(uint32_t)spv::Op::OpTypeStruct,
543546
(uint32_t)spv::Op::OpTypeOpaque,
544547
(uint32_t)spv::Op::OpTypePointer,

source/opt/local_access_chain_convert_pass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2017 The Khronos Group Inc.
22
// Copyright (c) 2017 Valve Corporation
33
// Copyright (c) 2017 LunarG Inc.
4+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
5+
// reserved.
46
//
57
// Licensed under the Apache License, Version 2.0 (the "License");
68
// you may not use this file except in compliance with the License.
@@ -430,7 +432,8 @@ void LocalAccessChainConvertPass::InitExtensions() {
430432
"SPV_NV_bindless_texture", "SPV_EXT_shader_atomic_float_add",
431433
"SPV_EXT_fragment_shader_interlock",
432434
"SPV_KHR_compute_shader_derivatives", "SPV_NV_cooperative_matrix",
433-
"SPV_KHR_cooperative_matrix", "SPV_KHR_ray_tracing_position_fetch"});
435+
"SPV_KHR_cooperative_matrix", "SPV_KHR_ray_tracing_position_fetch",
436+
"SPV_AMDX_shader_enqueue"});
434437
}
435438

436439
bool LocalAccessChainConvertPass::AnyIndexIsOutOfBounds(

source/opt/local_single_block_elim_pass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2017 The Khronos Group Inc.
22
// Copyright (c) 2017 Valve Corporation
33
// Copyright (c) 2017 LunarG Inc.
4+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
5+
// reserved.
46
//
57
// Licensed under the Apache License, Version 2.0 (the "License");
68
// you may not use this file except in compliance with the License.
@@ -238,6 +240,7 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
238240
"SPV_AMD_gcn_shader",
239241
"SPV_KHR_shader_ballot",
240242
"SPV_AMD_shader_ballot",
243+
"SPV_AMDX_shader_enqueue",
241244
"SPV_AMD_gpu_shader_half_float",
242245
"SPV_KHR_shader_draw_parameters",
243246
"SPV_KHR_subgroup_vote",

source/opt/local_single_store_elim_pass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2017 The Khronos Group Inc.
22
// Copyright (c) 2017 Valve Corporation
33
// Copyright (c) 2017 LunarG Inc.
4+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
5+
// reserved.
46
//
57
// Licensed under the Apache License, Version 2.0 (the "License");
68
// you may not use this file except in compliance with the License.
@@ -144,7 +146,8 @@ void LocalSingleStoreElimPass::InitExtensionAllowList() {
144146
"SPV_KHR_compute_shader_derivatives",
145147
"SPV_NV_cooperative_matrix",
146148
"SPV_KHR_cooperative_matrix",
147-
"SPV_KHR_ray_tracing_position_fetch"});
149+
"SPV_KHR_ray_tracing_position_fetch",
150+
"SPV_AMDX_shader_enqueue"});
148151
}
149152
bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) {
150153
std::vector<Instruction*> users;

source/opt/scalar_replacement_pass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) 2017 Google Inc.
2+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
3+
// reserved.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");
46
// you may not use this file except in compliance with the License.
@@ -671,7 +673,8 @@ bool ScalarReplacementPass::CheckTypeAnnotations(
671673
for (auto inst :
672674
get_decoration_mgr()->GetDecorationsFor(typeInst->result_id(), false)) {
673675
uint32_t decoration;
674-
if (inst->opcode() == spv::Op::OpDecorate) {
676+
if (inst->opcode() == spv::Op::OpDecorate ||
677+
inst->opcode() == spv::Op::OpDecorateId) {
675678
decoration = inst->GetSingleWordInOperand(1u);
676679
} else {
677680
assert(inst->opcode() == spv::Op::OpMemberDecorate);

source/opt/type_manager.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) 2016 Google Inc.
2+
// Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
3+
// reserved.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");
46
// you may not use this file except in compliance with the License.
@@ -803,6 +805,14 @@ Type* TypeManager::RecordIfTypeDefinition(const Instruction& inst) {
803805
return type;
804806
}
805807
break;
808+
case spv::Op::OpTypeNodePayloadArrayAMDX:
809+
type = new NodePayloadArray(GetType(inst.GetSingleWordInOperand(0)));
810+
if (id_to_incomplete_type_.count(inst.GetSingleWordInOperand(0))) {
811+
incomplete_types_.emplace_back(inst.result_id(), type);
812+
id_to_incomplete_type_[inst.result_id()] = type;
813+
return type;
814+
}
815+
break;
806816
case spv::Op::OpTypeStruct: {
807817
std::vector<const Type*> element_types;
808818
bool incomplete_type = false;
@@ -940,7 +950,8 @@ void TypeManager::AttachDecoration(const Instruction& inst, Type* type) {
940950
if (!IsAnnotationInst(opcode)) return;
941951

942952
switch (opcode) {
943-
case spv::Op::OpDecorate: {
953+
case spv::Op::OpDecorate:
954+
case spv::Op::OpDecorateId: {
944955
const auto count = inst.NumOperands();
945956
std::vector<uint32_t> data;
946957
for (uint32_t i = 1; i < count; ++i) {

0 commit comments

Comments
 (0)