From 4ef3b3e0b98d36083cb330c6b386feb51421b811 Mon Sep 17 00:00:00 2001 From: Andrey Tuganov Date: Tue, 28 Feb 2017 11:53:47 -0500 Subject: [PATCH] Refactored validation_state, added new types - validation_state.cpp uses functions from opcode.h instead of in-place switches which need to be updated. - added new spirv 1.1 type declaration opcodes to a 'is op type declaration' switch in opcode.cpp. --- source/opcode.cpp | 2 ++ source/val/validation_state.cpp | 71 ++++++----------------------------------- 2 files changed, 11 insertions(+), 62 deletions(-) diff --git a/source/opcode.cpp b/source/opcode.cpp index ac87c70..d0f1ef1 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -255,6 +255,8 @@ int32_t spvOpcodeGeneratesType(SpvOp op) { case SpvOpTypeReserveId: case SpvOpTypeQueue: case SpvOpTypePipe: + case SpvOpTypePipeStorage: + case SpvOpTypeNamedBarrier: return true; default: // In particular, OpTypeForwardPointer does not generate a type, diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp index 4f1cb7d..d125c8c 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -16,6 +16,7 @@ #include +#include "opcode.h" #include "val/basic_block.h" #include "val/construct.h" #include "val/function.h" @@ -74,39 +75,12 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) { } break; case kLayoutTypes: + if (spvOpcodeGeneratesType(op) || spvOpcodeIsConstant(op)) { + out = true; + break; + } switch (op) { - case SpvOpTypeVoid: - case SpvOpTypeBool: - case SpvOpTypeInt: - case SpvOpTypeFloat: - case SpvOpTypeVector: - case SpvOpTypeMatrix: - case SpvOpTypeImage: - case SpvOpTypeSampler: - case SpvOpTypeSampledImage: - case SpvOpTypeArray: - case SpvOpTypeRuntimeArray: - case SpvOpTypeStruct: - case SpvOpTypeOpaque: - case SpvOpTypePointer: - case SpvOpTypeFunction: - case SpvOpTypeEvent: - case SpvOpTypeDeviceEvent: - case SpvOpTypeReserveId: - case SpvOpTypeQueue: - case SpvOpTypePipe: case SpvOpTypeForwardPointer: - case SpvOpConstantTrue: - case SpvOpConstantFalse: - case SpvOpConstant: - case SpvOpConstantComposite: - case SpvOpConstantSampler: - case SpvOpConstantNull: - case SpvOpSpecConstantTrue: - case SpvOpSpecConstantFalse: - case SpvOpSpecConstant: - case SpvOpSpecConstantComposite: - case SpvOpSpecConstantOp: case SpvOpVariable: case SpvOpLine: case SpvOpNoLine: @@ -119,6 +93,10 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) { case kLayoutFunctionDeclarations: case kLayoutFunctionDefinitions: // NOTE: These instructions should NOT be in these layout sections + if (spvOpcodeGeneratesType(op) || spvOpcodeIsConstant(op)) { + out = false; + break; + } switch (op) { case SpvOpCapability: case SpvOpExtension: @@ -137,38 +115,7 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) { case SpvOpGroupDecorate: case SpvOpGroupMemberDecorate: case SpvOpDecorationGroup: - case SpvOpTypeVoid: - case SpvOpTypeBool: - case SpvOpTypeInt: - case SpvOpTypeFloat: - case SpvOpTypeVector: - case SpvOpTypeMatrix: - case SpvOpTypeImage: - case SpvOpTypeSampler: - case SpvOpTypeSampledImage: - case SpvOpTypeArray: - case SpvOpTypeRuntimeArray: - case SpvOpTypeStruct: - case SpvOpTypeOpaque: - case SpvOpTypePointer: - case SpvOpTypeFunction: - case SpvOpTypeEvent: - case SpvOpTypeDeviceEvent: - case SpvOpTypeReserveId: - case SpvOpTypeQueue: - case SpvOpTypePipe: case SpvOpTypeForwardPointer: - case SpvOpConstantTrue: - case SpvOpConstantFalse: - case SpvOpConstant: - case SpvOpConstantComposite: - case SpvOpConstantSampler: - case SpvOpConstantNull: - case SpvOpSpecConstantTrue: - case SpvOpSpecConstantFalse: - case SpvOpSpecConstant: - case SpvOpSpecConstantComposite: - case SpvOpSpecConstantOp: out = false; break; default: -- 2.7.4