Signed-off-by: Pierre Moreau <pierre.mor...@free.fr> --- src/gallium/state_trackers/clover/api/program.cpp | 35 ++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 9d59668f8f..5f5971078d 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -22,6 +22,8 @@ #include "api/util.hpp" #include "core/program.hpp" +#include "spirv/invocation.hpp" +#include "spirv/spirv_utils.h" #include "util/u_debug.h" #include <sstream> @@ -92,22 +94,35 @@ clCreateProgramWithBinary(cl_context d_ctx, cl_uint n, // Deserialize the provided binaries, std::vector<std::pair<cl_int, module>> result = map( - [](const unsigned char *p, size_t l) -> std::pair<cl_int, module> { + [](const unsigned char *p, size_t l, device &dev) -> std::pair<cl_int, module> { if (!p || !l) return { CL_INVALID_VALUE, {} }; - try { - std::stringbuf bin( { (char*)p, l } ); - std::istream s(&bin); - - return { CL_SUCCESS, module::deserialize(s) }; - - } catch (std::istream::failure &e) { - return { CL_INVALID_BINARY, {} }; + if (spirv_is_binary_spirv(reinterpret_cast<const char *>(p))) { + if (!dev.supports_ir(PIPE_SHADER_IR_SPIRV)) + return { CL_INVALID_BINARY, {} }; + + try { + std::string log; + return { CL_SUCCESS, spirv::process_program(p, l, true, log) }; + } catch (build_error &e) { + return { CL_INVALID_BINARY, {} }; + } + } else { + try { + std::stringbuf bin( { (char*)p, l } ); + std::istream s(&bin); + + return { CL_SUCCESS, module::deserialize(s) }; + + } catch (std::istream::failure &e) { + return { CL_INVALID_BINARY, {} }; + } } }, range(binaries, n), - range(lengths, n)); + range(lengths, n), + devs); // update the status array, if (r_status) -- 2.12.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev