aboutsummaryrefslogtreecommitdiff
path: root/source/val/validate_extensions.cpp
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2021-01-27 16:38:38 -0800
committerGitHub <noreply@github.com>2021-01-27 19:38:38 -0500
commitb812fd634ea5ff307c374fb2b6340169f7db8b16 (patch)
treeb398ef072d90ac79765bca23f6000b89627513aa /source/val/validate_extensions.cpp
parentcc81f53d3d6146638b302694d319a580e4d88f70 (diff)
downloadSPIRV-Tools-b812fd634ea5ff307c374fb2b6340169f7db8b16.tar.gz
Validate SPV_KHR_workgroup_memory_explicit_layout (#4128)
* Validate SPV_KHR_workgroup_memory_explicit_layout * Check if SPIR-V is at least 1.4 to use the extension. * Check if either only Workgroup Blocks or only Workgroup non-Blocks are used. * Check that if more than one Workgroup Block is used, variables are decorated with Aliased. * Check layout decorations for Workgroup Blocks. * Implicitly use main capability if the ...8BitAccess or ...16BitAccess are used. * Allow 8-bit and 16-bit types when ...8BitAccess and ...16BitAccess are used respectively. * Update SPIRV-Headers dependency Bump it to include SPV_KHR_workgroup_memory_explicit_layout. * Add option to validate Workgroup blocks with scalar layout Validate the equivalent of scalarBlockLayout for Workgroup storage class Block variables from SPV_KHR_workgroup_memory_explicit_layout. Add option to the API and command line tool.
Diffstat (limited to 'source/val/validate_extensions.cpp')
-rw-r--r--source/val/validate_extensions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/val/validate_extensions.cpp b/source/val/validate_extensions.cpp
index af6ae2b7..dc8c0243 100644
--- a/source/val/validate_extensions.cpp
+++ b/source/val/validate_extensions.cpp
@@ -27,6 +27,7 @@
#include "source/latest_version_glsl_std_450_header.h"
#include "source/latest_version_opencl_std_header.h"
#include "source/opcode.h"
+#include "source/spirv_constant.h"
#include "source/spirv_target_env.h"
#include "source/val/instruction.h"
#include "source/val/validate.h"
@@ -685,6 +686,20 @@ bool IsDebugVariableWithIntScalarType(ValidationState_t& _,
} // anonymous namespace
+spv_result_t ValidateExtension(ValidationState_t& _, const Instruction* inst) {
+ if (_.version() < SPV_SPIRV_VERSION_WORD(1, 4)) {
+ std::string extension = GetExtensionString(&(inst->c_inst()));
+ if (extension ==
+ ExtensionToString(kSPV_KHR_workgroup_memory_explicit_layout)) {
+ return _.diag(SPV_ERROR_WRONG_VERSION, inst)
+ << "SPV_KHR_workgroup_memory_explicit_layout extension "
+ "requires SPIR-V version 1.4 or later.";
+ }
+ }
+
+ return SPV_SUCCESS;
+}
+
spv_result_t ValidateExtInstImport(ValidationState_t& _,
const Instruction* inst) {
const auto name_id = 1;
@@ -3124,6 +3139,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
spv_result_t ExtensionPass(ValidationState_t& _, const Instruction* inst) {
const SpvOp opcode = inst->opcode();
+ if (opcode == SpvOpExtension) return ValidateExtension(_, inst);
if (opcode == SpvOpExtInstImport) return ValidateExtInstImport(_, inst);
if (opcode == SpvOpExtInst) return ValidateExtInst(_, inst);