MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / SpirvToolsValidate

Function SpirvToolsValidate

SPIRV/SpvTools.cpp:156–182  ·  view source on GitHub ↗

Apply the SPIRV-Tools validator to generated SPIR-V.

Source from the content-addressed store, hash-verified

154
155// Apply the SPIRV-Tools validator to generated SPIR-V.
156void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
157 spv::SpvBuildLogger* logger, bool prelegalization)
158{
159 // validate
160 spv_context context = spvContextCreate(MapToSpirvToolsEnv(intermediate.getSpv(), logger));
161 spv_const_binary_t binary = { spirv.data(), spirv.size() };
162 spv_diagnostic diagnostic = nullptr;
163 spv_validator_options options = spvValidatorOptionsCreate();
164 spvValidatorOptionsSetRelaxBlockLayout(options, intermediate.usingHlslOffsets());
165 spvValidatorOptionsSetBeforeHlslLegalization(options, prelegalization);
166 spvValidatorOptionsSetScalarBlockLayout(options, intermediate.usingScalarBlockLayout());
167 spvValidatorOptionsSetWorkgroupScalarBlockLayout(options, intermediate.usingScalarBlockLayout());
168 spvValidatorOptionsSetAllowOffsetTextureOperand(options, intermediate.usingTextureOffsetNonConst());
169 spvValidatorOptionsSetAllowVulkan32BitBitwise(options, true);
170 spvValidateWithOptions(context, options, &binary, &diagnostic);
171
172 // report
173 if (diagnostic != nullptr) {
174 logger->error("SPIRV-Tools Validation Errors");
175 logger->error(diagnostic->error);
176 }
177
178 // tear down
179 spvValidatorOptionsDestroy(options);
180 spvDiagnosticDestroy(diagnostic);
181 spvContextDestroy(context);
182}
183
184// Apply the SPIRV-Tools optimizer to generated SPIR-V. HLSL SPIR-V is legalized in the process.
185void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,

Callers 1

GlslangToSpvFunction · 0.85

Calls 7

MapToSpirvToolsEnvFunction · 0.85
usingHlslOffsetsMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected