Add support for KHR_ray_{query,tracing} extensions (#3235)
Update validator for SPV_KHR_ray_tracing.
* Added handling for new enum types
* Add SpvScopeShaderCallKHR as a valid scope
* update spirv-headers
Co-authored-by: alelenv <alele@nvidia.com>
Co-authored-by: Torosdagli <ntorosda@amd.com>
Co-authored-by: Tobias Hector <tobias.hector@amd.com>
Co-authored-by: Steven Perron <stevenperron@google.com>
diff --git a/DEPS b/DEPS
index e13ca0d..c3e78a2 100644
--- a/DEPS
+++ b/DEPS
@@ -6,7 +6,7 @@
'effcee_revision': 'cd25ec17e9382f99a895b9ef53ff3c277464d07d',
'googletest_revision': 'f2fb48c3b3d79a75a88a99fba6576b25d42ec528',
're2_revision': '5bd613749fd530b576b890283bfb6bc6ea6246cb',
- 'spirv_headers_revision': 'a17e17e36da44d2cd1740132ecd7a8cb078f1d15',
+ 'spirv_headers_revision': 'f8bf11a0253a32375c32cad92c841237b96696c0',
}
deps = {
diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h
index 21a9608..03c7d1b 100644
--- a/include/spirv-tools/libspirv.h
+++ b/include/spirv-tools/libspirv.h
@@ -1,4 +1,6 @@
-// Copyright (c) 2015-2016 The Khronos Group Inc.
+// Copyright (c) 2015-2020 The Khronos Group Inc.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -165,6 +167,12 @@
SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS, // SPIR-V Sec 3.29
SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO, // SPIR-V Sec 3.30
SPV_OPERAND_TYPE_CAPABILITY, // SPIR-V Sec 3.31
+ SPV_OPERAND_TYPE_RAY_FLAGS, // SPIR-V Sec 3.RF
+ SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION, // SPIR-V Sec 3.RQIntersection
+ SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE, // SPIR-V Sec
+ // 3.RQCommitted
+ SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE, // SPIR-V Sec
+ // 3.RQCandidate
// Set 5: Operands that are a single word bitmask.
// Sometimes a set bit indicates the instruction requires still more operands.
diff --git a/source/binary.cpp b/source/binary.cpp
index 0463061..f16bf52 100644
--- a/source/binary.cpp
+++ b/source/binary.cpp
@@ -1,4 +1,6 @@
-// Copyright (c) 2015-2016 The Khronos Group Inc.
+// Copyright (c) 2015-2020 The Khronos Group Inc.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -633,6 +635,10 @@
case SPV_OPERAND_TYPE_GROUP_OPERATION:
case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO:
+ case SPV_OPERAND_TYPE_RAY_FLAGS:
+ case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION:
+ case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE:
+ case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE:
case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
diff --git a/source/disassemble.cpp b/source/disassemble.cpp
index 4b3972b..af30ce0 100644
--- a/source/disassemble.cpp
+++ b/source/disassemble.cpp
@@ -1,4 +1,6 @@
-// Copyright (c) 2015-2016 The Khronos Group Inc.
+// Copyright (c) 2015-2020 The Khronos Group Inc.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -277,6 +279,10 @@
case SPV_OPERAND_TYPE_GROUP_OPERATION:
case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO:
+ case SPV_OPERAND_TYPE_RAY_FLAGS:
+ case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION:
+ case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE:
+ case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE:
case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
diff --git a/source/opcode.cpp b/source/opcode.cpp
index b38b5d4..80fe3b3 100644
--- a/source/opcode.cpp
+++ b/source/opcode.cpp
@@ -1,4 +1,6 @@
-// Copyright (c) 2015-2016 The Khronos Group Inc.
+// Copyright (c) 2015-2020 The Khronos Group Inc.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -333,6 +335,9 @@
case SpvOpTypeNamedBarrier:
case SpvOpTypeAccelerationStructureNV:
case SpvOpTypeCooperativeMatrixNV:
+ // case SpvOpTypeAccelerationStructureKHR: covered by
+ // SpvOpTypeAccelerationStructureNV
+ case SpvOpTypeRayQueryProvisionalKHR:
return true;
default:
// In particular, OpTypeForwardPointer does not generate a type,
diff --git a/source/operand.cpp b/source/operand.cpp
index 3042606..755ad6a 100644
--- a/source/operand.cpp
+++ b/source/operand.cpp
@@ -1,4 +1,6 @@
-// Copyright (c) 2015-2016 The Khronos Group Inc.
+// Copyright (c) 2015-2020 The Khronos Group Inc.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -216,6 +218,14 @@
return "kernel profiling info";
case SPV_OPERAND_TYPE_CAPABILITY:
return "capability";
+ case SPV_OPERAND_TYPE_RAY_FLAGS:
+ return "ray flags";
+ case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION:
+ return "ray query intersection";
+ case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE:
+ return "ray query committed intersection type";
+ case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE:
+ return "ray query candidate intersection type";
case SPV_OPERAND_TYPE_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
return "image";
@@ -323,6 +333,10 @@
case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO:
case SPV_OPERAND_TYPE_CAPABILITY:
+ case SPV_OPERAND_TYPE_RAY_FLAGS:
+ case SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION:
+ case SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE:
+ case SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE:
case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
diff --git a/source/opt/ir_context.cpp b/source/opt/ir_context.cpp
index 7bca29b..72993fd 100644
--- a/source/opt/ir_context.cpp
+++ b/source/opt/ir_context.cpp
@@ -385,6 +385,8 @@
SpvOpTypeSampler,
SpvOpTypeSampledImage,
SpvOpTypeAccelerationStructureNV,
+ SpvOpTypeAccelerationStructureKHR,
+ SpvOpTypeRayQueryProvisionalKHR,
SpvOpTypeArray,
SpvOpTypeRuntimeArray,
SpvOpTypeStruct,
diff --git a/source/opt/local_access_chain_convert_pass.cpp b/source/opt/local_access_chain_convert_pass.cpp
index 1921596..e5cdc24 100644
--- a/source/opt/local_access_chain_convert_pass.cpp
+++ b/source/opt/local_access_chain_convert_pass.cpp
@@ -378,6 +378,7 @@
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NV_ray_tracing",
+ "SPV_KHR_ray_query",
"SPV_EXT_fragment_invocation_density",
});
}
diff --git a/source/opt/local_single_block_elim_pass.cpp b/source/opt/local_single_block_elim_pass.cpp
index aebbd00..a465483 100644
--- a/source/opt/local_single_block_elim_pass.cpp
+++ b/source/opt/local_single_block_elim_pass.cpp
@@ -255,6 +255,7 @@
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NV_ray_tracing",
+ "SPV_KHR_ray_query",
"SPV_EXT_fragment_invocation_density",
"SPV_EXT_physical_storage_buffer",
});
diff --git a/source/opt/local_single_store_elim_pass.cpp b/source/opt/local_single_store_elim_pass.cpp
index d6beeab..4c71ce1 100644
--- a/source/opt/local_single_store_elim_pass.cpp
+++ b/source/opt/local_single_store_elim_pass.cpp
@@ -118,6 +118,7 @@
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NV_ray_tracing",
+ "SPV_KHR_ray_query",
"SPV_EXT_fragment_invocation_density",
"SPV_EXT_physical_storage_buffer",
});
diff --git a/source/opt/reflect.h b/source/opt/reflect.h
index 8106442..51d23a7 100644
--- a/source/opt/reflect.h
+++ b/source/opt/reflect.h
@@ -46,6 +46,8 @@
return (opcode >= SpvOpTypeVoid && opcode <= SpvOpTypeForwardPointer) ||
opcode == SpvOpTypePipeStorage || opcode == SpvOpTypeNamedBarrier ||
opcode == SpvOpTypeAccelerationStructureNV ||
+ opcode == SpvOpTypeAccelerationStructureKHR ||
+ opcode == SpvOpTypeRayQueryProvisionalKHR ||
opcode == SpvOpTypeCooperativeMatrixNV;
}
inline bool IsConstantInst(SpvOp opcode) {
diff --git a/source/val/validate_builtins.cpp b/source/val/validate_builtins.cpp
index 7623d49..d86c91e 100644
--- a/source/val/validate_builtins.cpp
+++ b/source/val/validate_builtins.cpp
@@ -2263,8 +2263,11 @@
spv_result_t BuiltInsValidator::ValidateVertexIdOrInstanceIdAtDefinition(
const Decoration& decoration, const Instruction& inst) {
const SpvBuiltIn label = SpvBuiltIn(decoration.params()[0]);
- bool allow_instance_id = _.HasCapability(SpvCapabilityRayTracingNV) &&
- label == SpvBuiltInInstanceId;
+ bool allow_instance_id =
+ (_.HasCapability(SpvCapabilityRayTracingNV) ||
+ _.HasCapability(SpvCapabilityRayTracingProvisionalKHR)) &&
+ label == SpvBuiltInInstanceId;
+
if (spvIsVulkanEnv(_.context()->target_env) && !allow_instance_id) {
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< "Vulkan spec doesn't allow BuiltIn VertexId/InstanceId "
@@ -3085,7 +3088,8 @@
case SpvBuiltInWorldToObjectNV:
case SpvBuiltInHitTNV:
case SpvBuiltInHitKindNV:
- case SpvBuiltInIncomingRayFlagsNV: {
+ case SpvBuiltInIncomingRayFlagsNV:
+ case SpvBuiltInRayGeometryIndexKHR: {
// No validation rules (for the moment).
break;
}
diff --git a/source/val/validate_memory.cpp b/source/val/validate_memory.cpp
index bff8b20..1e1a38d 100644
--- a/source/val/validate_memory.cpp
+++ b/source/val/validate_memory.cpp
@@ -1,4 +1,6 @@
// Copyright (c) 2018 Google LLC.
+// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
+// reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -533,7 +535,9 @@
if (!IsAllowedTypeOrArrayOfSame(
_, pointee,
{SpvOpTypeImage, SpvOpTypeSampler, SpvOpTypeSampledImage,
- SpvOpTypeAccelerationStructureNV})) {
+ SpvOpTypeAccelerationStructureNV,
+ SpvOpTypeAccelerationStructureKHR,
+ SpvOpTypeRayQueryProvisionalKHR})) {
return _.diag(SPV_ERROR_INVALID_ID, inst)
<< "UniformConstant OpVariable <id> '" << _.getIdName(inst->id())
<< "' has illegal type.\n"
@@ -542,6 +546,8 @@
<< "are used only as handles to refer to opaque resources. Such "
<< "variables must be typed as OpTypeImage, OpTypeSampler, "
<< "OpTypeSampledImage, OpTypeAccelerationStructureNV, "
+ "OpTypeAccelerationStructureKHR, "
+ "OpTypeRayQueryProvisionalKHR, "
<< "or an array of one of these types.";
}
}
diff --git a/source/val/validate_scopes.cpp b/source/val/validate_scopes.cpp
index 473d6e8..ea3ebcb 100644
--- a/source/val/validate_scopes.cpp
+++ b/source/val/validate_scopes.cpp
@@ -32,6 +32,7 @@
case SpvScopeSubgroup:
case SpvScopeInvocation:
case SpvScopeQueueFamilyKHR:
+ case SpvScopeShaderCallKHR:
return true;
case SpvScopeMax:
break;
diff --git a/test/operand_capabilities_test.cpp b/test/operand_capabilities_test.cpp
index 1195597..addb08a 100644
--- a/test/operand_capabilities_test.cpp
+++ b/test/operand_capabilities_test.cpp
@@ -82,6 +82,13 @@
SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3 \
} \
}
+#define CASE4(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4) \
+ { \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
+ SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3, \
+ SpvCapability##CAP4 \
+ } \
+ }
#define CASE5(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4, CAP5) \
{ \
SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
@@ -491,8 +498,8 @@
CASE1(BUILT_IN, BuiltInCullDistance, CullDistance), // Bug 1407, 15234
CASE1(BUILT_IN, BuiltInVertexId, Shader),
CASE1(BUILT_IN, BuiltInInstanceId, Shader),
- CASE3(BUILT_IN, BuiltInPrimitiveId, Geometry, Tessellation,
- RayTracingNV),
+ CASE4(BUILT_IN, BuiltInPrimitiveId, Geometry, Tessellation,
+ RayTracingNV, RayTracingProvisionalKHR),
CASE2(BUILT_IN, BuiltInInvocationId, Geometry, Tessellation),
CASE2(BUILT_IN, BuiltInLayer, Geometry, ShaderViewportIndexLayerEXT),
CASE2(BUILT_IN, BuiltInViewportIndex, MultiViewport, ShaderViewportIndexLayerEXT), // Bug 15234
diff --git a/test/opt/ir_builder.cpp b/test/opt/ir_builder.cpp
index f800ca4..cb234e0 100644
--- a/test/opt/ir_builder.cpp
+++ b/test/opt/ir_builder.cpp
@@ -408,7 +408,7 @@
TEST_F(IRBuilderTest, AccelerationStructureNV) {
const std::string text = R"(
-; CHECK: OpTypeAccelerationStructureNV
+; CHECK: OpTypeAccelerationStructureKHR
OpCapability Shader
OpCapability RayTracingNV
OpExtension "SPV_NV_ray_tracing"
diff --git a/test/opt/type_manager_test.cpp b/test/opt/type_manager_test.cpp
index 743d0b6..fdae2ef 100644
--- a/test/opt/type_manager_test.cpp
+++ b/test/opt/type_manager_test.cpp
@@ -1063,7 +1063,7 @@
; CHECK: OpTypeForwardPointer [[uniform_ptr]] Uniform
; CHECK: OpTypePipeStorage
; CHECK: OpTypeNamedBarrier
-; CHECK: OpTypeAccelerationStructureNV
+; CHECK: OpTypeAccelerationStructureKHR
; CHECK: OpTypeCooperativeMatrixNV [[f32]] [[uint24]] [[uint24]] [[uint24]]
OpCapability Shader
OpCapability Int64
diff --git a/test/val/val_memory_test.cpp b/test/val/val_memory_test.cpp
index 22761cc..b32867b 100644
--- a/test/val/val_memory_test.cpp
+++ b/test/val/val_memory_test.cpp
@@ -57,8 +57,9 @@
"Variables identified with the UniformConstant storage class "
"are used only as handles to refer to opaque resources. Such "
"variables must be typed as OpTypeImage, OpTypeSampler, "
- "OpTypeSampledImage, OpTypeAccelerationStructureNV, or an "
- "array of one of these types."));
+ "OpTypeSampledImage, OpTypeAccelerationStructureNV, "
+ "OpTypeAccelerationStructureKHR, OpTypeRayQueryProvisionalKHR, "
+ "or an array of one of these types."));
}
TEST_F(ValidateMemory, VulkanUniformConstantOnOpaqueResourceGood) {
@@ -110,8 +111,9 @@
"Variables identified with the UniformConstant storage class "
"are used only as handles to refer to opaque resources. Such "
"variables must be typed as OpTypeImage, OpTypeSampler, "
- "OpTypeSampledImage, OpTypeAccelerationStructureNV, or an "
- "array of one of these types."));
+ "OpTypeSampledImage, OpTypeAccelerationStructureNV, "
+ "OpTypeAccelerationStructureKHR, OpTypeRayQueryProvisionalKHR, "
+ "or an array of one of these types."));
}
TEST_F(ValidateMemory, VulkanUniformConstantOnOpaqueResourceArrayGood) {
diff --git a/utils/check_copyright.py b/utils/check_copyright.py
index b228300..4467a32 100755
--- a/utils/check_copyright.py
+++ b/utils/check_copyright.py
@@ -34,10 +34,11 @@
'Pierre Moreau',
'Samsung Inc',
'André Perez Maselco',
- 'Vasyl Teliman']
+ 'Vasyl Teliman',
+ 'Advanced Micro Devices, Inc.']
CURRENT_YEAR='2020'
-YEARS = '(2014-2016|2015-2016|2016|2016-2017|2017|2017-2019|2018|2019|2020)'
+YEARS = '(2014-2016|2015-2016|2015-2020|2016|2016-2017|2017|2017-2019|2018|2019|2020)'
COPYRIGHT_RE = re.compile(
'Copyright \(c\) {} ({})'.format(YEARS, '|'.join(AUTHORS)))