clover: don't call validate spirv at all if not needed
Suggested on irc seems like a good plan. Reviewed-by: Pierre Moreau <dev@pmoreau.org> Reviewed-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7051>
This commit is contained in:
@@ -678,7 +678,7 @@ clover::spirv::compile_program(const std::vector<char> &binary,
|
|||||||
bool validate) {
|
bool validate) {
|
||||||
std::vector<char> source = spirv_to_cpu(binary);
|
std::vector<char> 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();
|
throw build_error();
|
||||||
|
|
||||||
if (!check_capabilities(dev, source, r_log))
|
if (!check_capabilities(dev, source, r_log))
|
||||||
@@ -781,8 +781,7 @@ clover::spirv::link_program(const std::vector<module> &modules,
|
|||||||
bool
|
bool
|
||||||
clover::spirv::is_valid_spirv(const std::vector<char> &binary,
|
clover::spirv::is_valid_spirv(const std::vector<char> &binary,
|
||||||
const std::string &opencl_version,
|
const std::string &opencl_version,
|
||||||
std::string &r_log,
|
std::string &r_log) {
|
||||||
bool validate) {
|
|
||||||
auto const validator_consumer =
|
auto const validator_consumer =
|
||||||
[&r_log](spv_message_level_t level, const char *source,
|
[&r_log](spv_message_level_t level, const char *source,
|
||||||
const spv_position_t &position, const char *message) {
|
const spv_position_t &position, const char *message) {
|
||||||
@@ -794,8 +793,6 @@ clover::spirv::is_valid_spirv(const std::vector<char> &binary,
|
|||||||
spvtools::SpirvTools spvTool(target_env);
|
spvtools::SpirvTools spvTool(target_env);
|
||||||
spvTool.SetMessageConsumer(validator_consumer);
|
spvTool.SetMessageConsumer(validator_consumer);
|
||||||
|
|
||||||
if (!validate)
|
|
||||||
return true;
|
|
||||||
return spvTool.Validate(reinterpret_cast<const uint32_t *>(binary.data()),
|
return spvTool.Validate(reinterpret_cast<const uint32_t *>(binary.data()),
|
||||||
binary.size() / 4u);
|
binary.size() / 4u);
|
||||||
}
|
}
|
||||||
@@ -840,7 +837,7 @@ clover::spirv::supported_versions() {
|
|||||||
bool
|
bool
|
||||||
clover::spirv::is_valid_spirv(const std::vector<char> &/*binary*/,
|
clover::spirv::is_valid_spirv(const std::vector<char> &/*binary*/,
|
||||||
const std::string &/*opencl_version*/,
|
const std::string &/*opencl_version*/,
|
||||||
std::string &/*r_log*/, bool /*validate*/) {
|
std::string &/*r_log*/) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ namespace clover {
|
|||||||
// warnings and errors are appended to |r_log|.
|
// warnings and errors are appended to |r_log|.
|
||||||
bool is_valid_spirv(const std::vector<char> &binary,
|
bool is_valid_spirv(const std::vector<char> &binary,
|
||||||
const std::string &opencl_version,
|
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.
|
// Creates a clover module out of the given SPIR-V binary.
|
||||||
module compile_program(const std::vector<char> &binary,
|
module compile_program(const std::vector<char> &binary,
|
||||||
|
Reference in New Issue
Block a user