diff options
author | Dave Airlie <airlied@redhat.com> | 2021-08-05 16:34:51 +1000 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-08-09 19:16:29 +0000 |
commit | 773f0461031085d80f0c220ddec99cc03000fd3c (patch) | |
tree | 2a91ed932f7cd8d0d1d0fd27b0a00d287397dbd7 | |
parent | 3106a340a01cf4a760d828e38d560ed6044e100a (diff) |
clover: return CL_INVALID_PLATFORM properly.
If the platform isn't clover platform return an error,
Fixes CTS api negative_get_platform_info
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12225>
-rw-r--r-- | src/gallium/frontends/clover/api/context.cpp | 2 | ||||
-rw-r--r-- | src/gallium/frontends/clover/api/platform.cpp | 10 | ||||
-rw-r--r-- | src/gallium/frontends/clover/api/program.cpp | 6 | ||||
-rw-r--r-- | src/gallium/frontends/clover/core/platform.hpp | 2 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/gallium/frontends/clover/api/context.cpp b/src/gallium/frontends/clover/api/context.cpp index 1618756e672..65464bcde06 100644 --- a/src/gallium/frontends/clover/api/context.cpp +++ b/src/gallium/frontends/clover/api/context.cpp @@ -40,7 +40,7 @@ clCreateContext(const cl_context_properties *d_props, cl_uint num_devs, for (auto &prop : props) { if (prop.first == CL_CONTEXT_PLATFORM) - obj(prop.second.as<cl_platform_id>()); + find_platform(prop.second.as<cl_platform_id>()); else throw error(CL_INVALID_PROPERTY); } diff --git a/src/gallium/frontends/clover/api/platform.cpp b/src/gallium/frontends/clover/api/platform.cpp index f9b90dfb556..9b38c3c4871 100644 --- a/src/gallium/frontends/clover/api/platform.cpp +++ b/src/gallium/frontends/clover/api/platform.cpp @@ -49,12 +49,20 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id *rd_platforms, return CL_SUCCESS; } +platform &clover::find_platform(cl_platform_id d_platform) +{ + /* this error is only added in CL2.0 */ + if (d_platform != desc(_clover_platform)) + throw error(CL_INVALID_PLATFORM); + return obj(d_platform); +} + cl_int clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param, size_t size, void *r_buf, size_t *r_size) try { property_buffer buf { r_buf, size, r_size }; - auto &platform = obj(d_platform); + auto &platform = find_platform(d_platform); switch (param) { case CL_PLATFORM_PROFILE: diff --git a/src/gallium/frontends/clover/api/program.cpp b/src/gallium/frontends/clover/api/program.cpp index d67613f1883..f5971248f43 100644 --- a/src/gallium/frontends/clover/api/program.cpp +++ b/src/gallium/frontends/clover/api/program.cpp @@ -22,6 +22,7 @@ #include "api/util.hpp" #include "core/program.hpp" +#include "core/platform.hpp" #include "spirv/invocation.hpp" #include "util/u_debug.h" @@ -466,8 +467,11 @@ clUnloadCompiler() { } CLOVER_API cl_int -clUnloadPlatformCompiler(cl_platform_id d_platform) { +clUnloadPlatformCompiler(cl_platform_id d_platform) try { + find_platform(d_platform); return CL_SUCCESS; +} catch (error &e) { + return e.get(); } CLOVER_API cl_int diff --git a/src/gallium/frontends/clover/core/platform.hpp b/src/gallium/frontends/clover/core/platform.hpp index ba4fccc3e3d..983d4e6aa99 100644 --- a/src/gallium/frontends/clover/core/platform.hpp +++ b/src/gallium/frontends/clover/core/platform.hpp @@ -50,6 +50,8 @@ namespace clover { cl_version version; std::vector<intrusive_ref<device>> devs; }; + + platform &find_platform(cl_platform_id d_platform); } #endif |