Apply the SPIRV-Tools validator to generated SPIR-V.
| 154 | |
| 155 | // Apply the SPIRV-Tools validator to generated SPIR-V. |
| 156 | void 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. |
| 185 | void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, |
no test coverage detected