[Mesa-dev] [PATCH] clover: Refuse to create context with invalid properties
Jan Vesely
jan.vesely at rutgers.edu
Tue Oct 22 05:11:58 CEST 2013
the specs say that clCreateContext reutrns error
"if platform value specified in properties is not a valid platform"
The orignal approach fials if invalid valu other than NULL pointer is provided.
Fixes piglit cl-api-create-context.
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
src/gallium/state_trackers/clover/api/context.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/gallium/state_trackers/clover/api/context.cpp b/src/gallium/state_trackers/clover/api/context.cpp
index 7b020a6..67adf8f 100644
--- a/src/gallium/state_trackers/clover/api/context.cpp
+++ b/src/gallium/state_trackers/clover/api/context.cpp
@@ -34,14 +34,19 @@ clCreateContext(const cl_context_properties *d_props, cl_uint num_devs,
void *user_data, cl_int *r_errcode) try {
auto props = obj<property_list_tag>(d_props);
auto devs = objs(d_devs, num_devs);
+ cl_platform_id platform;
+ cl_uint num_platforms;
if (!pfn_notify && user_data)
throw error(CL_INVALID_VALUE);
+
+ int ret = clGetPlatformIDs(1, &platform, &num_platforms);
+ if (ret || !num_platforms)
+ throw error(CL_INVALID_PLATFORM);
for (auto &prop : props) {
- if (prop.first == CL_CONTEXT_PLATFORM)
- obj(prop.second.as<cl_platform_id>());
- else
+ if (prop.first != CL_CONTEXT_PLATFORM ||
+ prop.second.as<cl_platform_id>() != platform)
throw error(CL_INVALID_PROPERTY);
}
--
1.8.3.1
More information about the mesa-dev
mailing list