Update SPIR-V Dependencies to match Dawn requirements
This commit is contained in:
committed by
bridgewaterrobbie
parent
17091df8dc
commit
a937362ccc
100
third_party/spirv-tools/source/opcode.cpp
vendored
100
third_party/spirv-tools/source/opcode.cpp
vendored
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2015-2022 The Khronos Group Inc.
|
||||
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
|
||||
// reserved.
|
||||
// Modifications Copyright (C) 2020-2024 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.
|
||||
@@ -102,7 +102,7 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env,
|
||||
const auto version = spvVersionForTargetEnv(env);
|
||||
for (uint64_t opcodeIndex = 0; opcodeIndex < table->count; ++opcodeIndex) {
|
||||
const spv_opcode_desc_t& entry = table->entries[opcodeIndex];
|
||||
// We considers the current opcode as available as long as
|
||||
// We consider the current opcode as available as long as
|
||||
// 1. The target environment satisfies the minimal requirement of the
|
||||
// opcode; or
|
||||
// 2. There is at least one extension enabling this opcode.
|
||||
@@ -110,13 +110,34 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env,
|
||||
// Note that the second rule assumes the extension enabling this instruction
|
||||
// is indeed requested in the SPIR-V code; checking that should be
|
||||
// validator's work.
|
||||
if (((version >= entry.minVersion && version <= entry.lastVersion) ||
|
||||
entry.numExtensions > 0u || entry.numCapabilities > 0u) &&
|
||||
nameLength == strlen(entry.name) &&
|
||||
!strncmp(name, entry.name, nameLength)) {
|
||||
// NOTE: Found out Opcode!
|
||||
*pEntry = &entry;
|
||||
return SPV_SUCCESS;
|
||||
if ((version >= entry.minVersion && version <= entry.lastVersion) ||
|
||||
entry.numExtensions > 0u || entry.numCapabilities > 0u) {
|
||||
// Exact match case.
|
||||
if (nameLength == strlen(entry.name) &&
|
||||
!strncmp(name, entry.name, nameLength)) {
|
||||
*pEntry = &entry;
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
// Lack of binary search really hurts here. There isn't an easy filter to
|
||||
// apply before checking aliases since we need to handle promotion from
|
||||
// vendor to KHR/EXT and KHR/EXT to core. It would require a sure-fire way
|
||||
// of dropping suffices. Fortunately, most lookup are based on token
|
||||
// value.
|
||||
//
|
||||
// If this was a binary search we could iterate between the lower and
|
||||
// upper bounds.
|
||||
if (entry.numAliases > 0) {
|
||||
for (uint32_t aliasIndex = 0; aliasIndex < entry.numAliases;
|
||||
aliasIndex++) {
|
||||
// Skip Op prefix. Should this be encoded in the table instead?
|
||||
const auto alias = entry.aliases[aliasIndex] + 2;
|
||||
const size_t aliasLength = strlen(alias);
|
||||
if (nameLength == aliasLength && !strncmp(name, alias, nameLength)) {
|
||||
*pEntry = &entry;
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +154,8 @@ spv_result_t spvOpcodeTableValueLookup(spv_target_env env,
|
||||
const auto beg = table->entries;
|
||||
const auto end = table->entries + table->count;
|
||||
|
||||
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {},
|
||||
false, false, 0, nullptr, ~0u, ~0u};
|
||||
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {}, 0,
|
||||
{}, false, false, 0, nullptr, ~0u, ~0u};
|
||||
|
||||
auto comp = [](const spv_opcode_desc_t& lhs, const spv_opcode_desc_t& rhs) {
|
||||
return lhs.opcode < rhs.opcode;
|
||||
@@ -189,6 +210,7 @@ const char* spvOpcodeString(const uint32_t opcode) {
|
||||
spv_opcode_desc_t needle = {"", static_cast<spv::Op>(opcode),
|
||||
0, nullptr,
|
||||
0, {},
|
||||
0, {},
|
||||
false, false,
|
||||
0, nullptr,
|
||||
~0u, ~0u};
|
||||
@@ -225,6 +247,7 @@ int32_t spvOpcodeIsSpecConstant(const spv::Op opcode) {
|
||||
case spv::Op::OpSpecConstantFalse:
|
||||
case spv::Op::OpSpecConstant:
|
||||
case spv::Op::OpSpecConstantComposite:
|
||||
case spv::Op::OpSpecConstantCompositeReplicateEXT:
|
||||
case spv::Op::OpSpecConstantOp:
|
||||
return true;
|
||||
default:
|
||||
@@ -238,13 +261,18 @@ int32_t spvOpcodeIsConstant(const spv::Op opcode) {
|
||||
case spv::Op::OpConstantFalse:
|
||||
case spv::Op::OpConstant:
|
||||
case spv::Op::OpConstantComposite:
|
||||
case spv::Op::OpConstantCompositeReplicateEXT:
|
||||
case spv::Op::OpConstantSampler:
|
||||
case spv::Op::OpConstantNull:
|
||||
case spv::Op::OpConstantFunctionPointerINTEL:
|
||||
case spv::Op::OpConstantStringAMDX:
|
||||
case spv::Op::OpSpecConstantTrue:
|
||||
case spv::Op::OpSpecConstantFalse:
|
||||
case spv::Op::OpSpecConstant:
|
||||
case spv::Op::OpSpecConstantComposite:
|
||||
case spv::Op::OpSpecConstantCompositeReplicateEXT:
|
||||
case spv::Op::OpSpecConstantOp:
|
||||
case spv::Op::OpSpecConstantStringAMDX:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -272,7 +300,10 @@ int32_t spvOpcodeIsComposite(const spv::Op opcode) {
|
||||
case spv::Op::OpTypeMatrix:
|
||||
case spv::Op::OpTypeArray:
|
||||
case spv::Op::OpTypeStruct:
|
||||
case spv::Op::OpTypeRuntimeArray:
|
||||
case spv::Op::OpTypeCooperativeMatrixNV:
|
||||
case spv::Op::OpTypeCooperativeMatrixKHR:
|
||||
case spv::Op::OpTypeCooperativeVectorNV:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -282,17 +313,23 @@ int32_t spvOpcodeIsComposite(const spv::Op opcode) {
|
||||
bool spvOpcodeReturnsLogicalVariablePointer(const spv::Op opcode) {
|
||||
switch (opcode) {
|
||||
case spv::Op::OpVariable:
|
||||
case spv::Op::OpUntypedVariableKHR:
|
||||
case spv::Op::OpAccessChain:
|
||||
case spv::Op::OpInBoundsAccessChain:
|
||||
case spv::Op::OpUntypedAccessChainKHR:
|
||||
case spv::Op::OpUntypedInBoundsAccessChainKHR:
|
||||
case spv::Op::OpFunctionParameter:
|
||||
case spv::Op::OpImageTexelPointer:
|
||||
case spv::Op::OpCopyObject:
|
||||
case spv::Op::OpAllocateNodePayloadsAMDX:
|
||||
case spv::Op::OpSelect:
|
||||
case spv::Op::OpPhi:
|
||||
case spv::Op::OpFunctionCall:
|
||||
case spv::Op::OpPtrAccessChain:
|
||||
case spv::Op::OpUntypedPtrAccessChainKHR:
|
||||
case spv::Op::OpLoad:
|
||||
case spv::Op::OpConstantNull:
|
||||
case spv::Op::OpRawAccessChainNV:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -302,11 +339,16 @@ bool spvOpcodeReturnsLogicalVariablePointer(const spv::Op opcode) {
|
||||
int32_t spvOpcodeReturnsLogicalPointer(const spv::Op opcode) {
|
||||
switch (opcode) {
|
||||
case spv::Op::OpVariable:
|
||||
case spv::Op::OpUntypedVariableKHR:
|
||||
case spv::Op::OpAccessChain:
|
||||
case spv::Op::OpInBoundsAccessChain:
|
||||
case spv::Op::OpUntypedAccessChainKHR:
|
||||
case spv::Op::OpUntypedInBoundsAccessChainKHR:
|
||||
case spv::Op::OpFunctionParameter:
|
||||
case spv::Op::OpImageTexelPointer:
|
||||
case spv::Op::OpCopyObject:
|
||||
case spv::Op::OpRawAccessChainNV:
|
||||
case spv::Op::OpAllocateNodePayloadsAMDX:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -339,10 +381,16 @@ int32_t spvOpcodeGeneratesType(spv::Op op) {
|
||||
case spv::Op::OpTypeNamedBarrier:
|
||||
case spv::Op::OpTypeAccelerationStructureNV:
|
||||
case spv::Op::OpTypeCooperativeMatrixNV:
|
||||
case spv::Op::OpTypeCooperativeMatrixKHR:
|
||||
case spv::Op::OpTypeCooperativeVectorNV:
|
||||
// case spv::Op::OpTypeAccelerationStructureKHR: covered by
|
||||
// spv::Op::OpTypeAccelerationStructureNV
|
||||
case spv::Op::OpTypeRayQueryKHR:
|
||||
case spv::Op::OpTypeHitObjectNV:
|
||||
case spv::Op::OpTypeUntypedPointerKHR:
|
||||
case spv::Op::OpTypeNodePayloadArrayAMDX:
|
||||
case spv::Op::OpTypeTensorLayoutNV:
|
||||
case spv::Op::OpTypeTensorViewNV:
|
||||
return true;
|
||||
default:
|
||||
// In particular, OpTypeForwardPointer does not generate a type,
|
||||
@@ -380,6 +428,7 @@ bool spvOpcodeIsLoad(const spv::Op opcode) {
|
||||
case spv::Op::OpImageSampleProjExplicitLod:
|
||||
case spv::Op::OpImageSampleProjDrefImplicitLod:
|
||||
case spv::Op::OpImageSampleProjDrefExplicitLod:
|
||||
case spv::Op::OpImageSampleFootprintNV:
|
||||
case spv::Op::OpImageFetch:
|
||||
case spv::Op::OpImageGather:
|
||||
case spv::Op::OpImageDrefGather:
|
||||
@@ -531,6 +580,8 @@ bool spvOpcodeIsNonUniformGroupOperation(spv::Op opcode) {
|
||||
case spv::Op::OpGroupNonUniformQuadBroadcast:
|
||||
case spv::Op::OpGroupNonUniformQuadSwap:
|
||||
case spv::Op::OpGroupNonUniformRotateKHR:
|
||||
case spv::Op::OpGroupNonUniformQuadAllKHR:
|
||||
case spv::Op::OpGroupNonUniformQuadAnyKHR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -704,6 +755,17 @@ bool spvOpcodeIsImageSample(const spv::Op opcode) {
|
||||
case spv::Op::OpImageSparseSampleExplicitLod:
|
||||
case spv::Op::OpImageSparseSampleDrefImplicitLod:
|
||||
case spv::Op::OpImageSparseSampleDrefExplicitLod:
|
||||
case spv::Op::OpImageSampleFootprintNV:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool spvIsExtendedInstruction(const spv::Op opcode) {
|
||||
switch (opcode) {
|
||||
case spv::Op::OpExtInst:
|
||||
case spv::Op::OpExtInstWithForwardRefsKHR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -749,6 +811,7 @@ bool spvOpcodeIsAccessChain(spv::Op opcode) {
|
||||
case spv::Op::OpInBoundsAccessChain:
|
||||
case spv::Op::OpPtrAccessChain:
|
||||
case spv::Op::OpInBoundsPtrAccessChain:
|
||||
case spv::Op::OpRawAccessChainNV:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -771,3 +834,16 @@ bool spvOpcodeIsBit(spv::Op opcode) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool spvOpcodeGeneratesUntypedPointer(spv::Op opcode) {
|
||||
switch (opcode) {
|
||||
case spv::Op::OpUntypedVariableKHR:
|
||||
case spv::Op::OpUntypedAccessChainKHR:
|
||||
case spv::Op::OpUntypedInBoundsAccessChainKHR:
|
||||
case spv::Op::OpUntypedPtrAccessChainKHR:
|
||||
case spv::Op::OpUntypedInBoundsPtrAccessChainKHR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user