mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
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>
This commit is contained in:
parent
25ede1ced6
commit
5a97e3a391
2
DEPS
2
DEPS
@ -6,7 +6,7 @@ vars = {
|
||||
'effcee_revision': 'cd25ec17e9382f99a895b9ef53ff3c277464d07d',
|
||||
'googletest_revision': 'f2fb48c3b3d79a75a88a99fba6576b25d42ec528',
|
||||
're2_revision': '5bd613749fd530b576b890283bfb6bc6ea6246cb',
|
||||
'spirv_headers_revision': 'a17e17e36da44d2cd1740132ecd7a8cb078f1d15',
|
||||
'spirv_headers_revision': 'f8bf11a0253a32375c32cad92c841237b96696c0',
|
||||
}
|
||||
|
||||
deps = {
|
||||
|
@ -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 @@ typedef enum spv_operand_type_t {
|
||||
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.
|
||||
|
@ -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 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
|
||||
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:
|
||||
|
@ -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 @@ void Disassembler::EmitOperand(const spv_parsed_instruction_t& inst,
|
||||
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:
|
||||
|
@ -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 @@ int32_t spvOpcodeGeneratesType(SpvOp op) {
|
||||
case SpvOpTypeNamedBarrier:
|
||||
case SpvOpTypeAccelerationStructureNV:
|
||||
case SpvOpTypeCooperativeMatrixNV:
|
||||
// case SpvOpTypeAccelerationStructureKHR: covered by
|
||||
// SpvOpTypeAccelerationStructureNV
|
||||
case SpvOpTypeRayQueryProvisionalKHR:
|
||||
return true;
|
||||
default:
|
||||
// In particular, OpTypeForwardPointer does not generate a type,
|
||||
|
@ -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 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
|
||||
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 @@ bool spvOperandIsConcrete(spv_operand_type_t type) {
|
||||
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:
|
||||
|
@ -385,6 +385,8 @@ void IRContext::AddCombinatorsForCapability(uint32_t capability) {
|
||||
SpvOpTypeSampler,
|
||||
SpvOpTypeSampledImage,
|
||||
SpvOpTypeAccelerationStructureNV,
|
||||
SpvOpTypeAccelerationStructureKHR,
|
||||
SpvOpTypeRayQueryProvisionalKHR,
|
||||
SpvOpTypeArray,
|
||||
SpvOpTypeRuntimeArray,
|
||||
SpvOpTypeStruct,
|
||||
|
@ -378,6 +378,7 @@ void LocalAccessChainConvertPass::InitExtensions() {
|
||||
"SPV_NV_shading_rate",
|
||||
"SPV_NV_mesh_shader",
|
||||
"SPV_NV_ray_tracing",
|
||||
"SPV_KHR_ray_query",
|
||||
"SPV_EXT_fragment_invocation_density",
|
||||
});
|
||||
}
|
||||
|
@ -255,6 +255,7 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
|
||||
"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",
|
||||
});
|
||||
|
@ -118,6 +118,7 @@ void LocalSingleStoreElimPass::InitExtensionWhiteList() {
|
||||
"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",
|
||||
});
|
||||
|
@ -46,6 +46,8 @@ inline bool IsTypeInst(SpvOp opcode) {
|
||||
return (opcode >= SpvOpTypeVoid && opcode <= SpvOpTypeForwardPointer) ||
|
||||
opcode == SpvOpTypePipeStorage || opcode == SpvOpTypeNamedBarrier ||
|
||||
opcode == SpvOpTypeAccelerationStructureNV ||
|
||||
opcode == SpvOpTypeAccelerationStructureKHR ||
|
||||
opcode == SpvOpTypeRayQueryProvisionalKHR ||
|
||||
opcode == SpvOpTypeCooperativeMatrixNV;
|
||||
}
|
||||
inline bool IsConstantInst(SpvOp opcode) {
|
||||
|
@ -2263,8 +2263,11 @@ spv_result_t BuiltInsValidator::ValidateVertexIndexAtDefinition(
|
||||
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 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition(
|
||||
case SpvBuiltInWorldToObjectNV:
|
||||
case SpvBuiltInHitTNV:
|
||||
case SpvBuiltInHitKindNV:
|
||||
case SpvBuiltInIncomingRayFlagsNV: {
|
||||
case SpvBuiltInIncomingRayFlagsNV:
|
||||
case SpvBuiltInRayGeometryIndexKHR: {
|
||||
// No validation rules (for the moment).
|
||||
break;
|
||||
}
|
||||
|
@ -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 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
|
||||
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 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
|
||||
<< "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.";
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ bool IsValidScope(uint32_t scope) {
|
||||
case SpvScopeSubgroup:
|
||||
case SpvScopeInvocation:
|
||||
case SpvScopeQueueFamilyKHR:
|
||||
case SpvScopeShaderCallKHR:
|
||||
return true;
|
||||
case SpvScopeMax:
|
||||
break;
|
||||
|
@ -82,6 +82,13 @@ TEST_P(EnumCapabilityTest, Sample) {
|
||||
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 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
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
|
||||
|
@ -408,7 +408,7 @@ OpFunctionEnd
|
||||
|
||||
TEST_F(IRBuilderTest, AccelerationStructureNV) {
|
||||
const std::string text = R"(
|
||||
; CHECK: OpTypeAccelerationStructureNV
|
||||
; CHECK: OpTypeAccelerationStructureKHR
|
||||
OpCapability Shader
|
||||
OpCapability RayTracingNV
|
||||
OpExtension "SPV_NV_ray_tracing"
|
||||
|
@ -1063,7 +1063,7 @@ TEST(TypeManager, GetTypeInstructionAllTypes) {
|
||||
; CHECK: OpTypeForwardPointer [[uniform_ptr]] Uniform
|
||||
; CHECK: OpTypePipeStorage
|
||||
; CHECK: OpTypeNamedBarrier
|
||||
; CHECK: OpTypeAccelerationStructureNV
|
||||
; CHECK: OpTypeAccelerationStructureKHR
|
||||
; CHECK: OpTypeCooperativeMatrixNV [[f32]] [[uint24]] [[uint24]] [[uint24]]
|
||||
OpCapability Shader
|
||||
OpCapability Int64
|
||||
|
@ -57,8 +57,9 @@ OpFunctionEnd
|
||||
"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 @@ OpFunctionEnd
|
||||
"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) {
|
||||
|
@ -34,10 +34,11 @@ AUTHORS = ['The Khronos Group Inc.',
|
||||
'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)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user