From a7d3be78ce2e4b330a068ae17998646459f9bb25 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 8 Oct 2020 06:11:35 +1000 Subject: [PATCH] clover: don't call validate spirv at all if not needed Suggested on irc seems like a good plan. Reviewed-by: Pierre Moreau Reviewed-by: Daniel Stone Part-of: --- src/gallium/frontends/clover/spirv/invocation.cpp | 9 +++------ src/gallium/frontends/clover/spirv/invocation.hpp | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gallium/frontends/clover/spirv/invocation.cpp b/src/gallium/frontends/clover/spirv/invocation.cpp index 2249895802f..fde8e992bb8 100644 --- a/src/gallium/frontends/clover/spirv/invocation.cpp +++ b/src/gallium/frontends/clover/spirv/invocation.cpp @@ -678,7 +678,7 @@ clover::spirv::compile_program(const std::vector &binary, bool validate) { std::vector source = spirv_to_cpu(binary); - if (!is_valid_spirv(source, dev.device_version(), r_log, validate)) + if (validate && !is_valid_spirv(source, dev.device_version(), r_log)) throw build_error(); if (!check_capabilities(dev, source, r_log)) @@ -781,8 +781,7 @@ clover::spirv::link_program(const std::vector &modules, bool clover::spirv::is_valid_spirv(const std::vector &binary, const std::string &opencl_version, - std::string &r_log, - bool validate) { + std::string &r_log) { auto const validator_consumer = [&r_log](spv_message_level_t level, const char *source, const spv_position_t &position, const char *message) { @@ -794,8 +793,6 @@ clover::spirv::is_valid_spirv(const std::vector &binary, spvtools::SpirvTools spvTool(target_env); spvTool.SetMessageConsumer(validator_consumer); - if (!validate) - return true; return spvTool.Validate(reinterpret_cast(binary.data()), binary.size() / 4u); } @@ -840,7 +837,7 @@ clover::spirv::supported_versions() { bool clover::spirv::is_valid_spirv(const std::vector &/*binary*/, const std::string &/*opencl_version*/, - std::string &/*r_log*/, bool /*validate*/) { + std::string &/*r_log*/) { return false; } diff --git a/src/gallium/frontends/clover/spirv/invocation.hpp b/src/gallium/frontends/clover/spirv/invocation.hpp index 5fa76cf4c9c..3153e6d11a7 100644 --- a/src/gallium/frontends/clover/spirv/invocation.hpp +++ b/src/gallium/frontends/clover/spirv/invocation.hpp @@ -38,7 +38,7 @@ namespace clover { // warnings and errors are appended to |r_log|. bool is_valid_spirv(const std::vector &binary, const std::string &opencl_version, - std::string &r_log, bool validate = true); + std::string &r_log); // Creates a clover module out of the given SPIR-V binary. module compile_program(const std::vector &binary,