Skip to content
Snippets Groups Projects
Commit db650343 authored by Marko Bencun's avatar Marko Bencun
Browse files

get_gl_sharing_context_properties parsing

parent 580a44c2
No related branches found
No related tags found
No related merge requests found
......@@ -232,7 +232,9 @@ def _parse_context_properties(properties):
# TODO: without ctypes?
import ctypes
val = (ctypes.cast(value, ctypes.c_void_p)).value
props.append(0 if val is None else val)
if val is None:
raise LogicError("Context", status_code.INVALID_VALUE, "You most likely have not initialized OpenGL properly.")
props.append(val)
else:
raise RuntimeError("Context", status_code.INVALID_VALUE, "invalid context property")
props.append(0)
......@@ -412,7 +414,8 @@ def _generic_info_to_python(info):
ret = list(value)
else:
ret = value[0]
_lib._free(info.value)
if info.dontfree == 0:
_lib._free(info.value)
return ret
class Kernel(_Common):
......
......@@ -76,6 +76,7 @@
PYOPENCL_CALL_GUARDED(clGet##WHAT##Info, \
(FIRST_ARG, SECOND_ARG, sizeof(param_value), &param_value, 0)); \
generic_info info; \
info.dontfree = 0; \
info.opaque_class = CLASS_##TYPEU; \
info.type = "void *"; \
if (param_value) \
......@@ -93,6 +94,7 @@
ar[i] = new pyopencl::CLS(VEC[i]); \
} \
generic_info info; \
info.dontfree = 0; \
info.opaque_class = CLASS_##CLSU; \
info.type = _copy_str(std::string("void*[") + tostring(VEC.size()) + "]"); \
info.value = (void**)ar; \
......@@ -111,6 +113,7 @@
(FIRST_ARG, SECOND_ARG, param_value_size, \
param_value, &param_value_size)); \
generic_info info; \
info.dontfree = 0; \
info.opaque_class = CLASS_NONE; \
info.type = "char*"; \
info.value = (void*)param_value; \
......@@ -123,6 +126,7 @@
PYOPENCL_CALL_GUARDED(clGet##WHAT##Info, \
(FIRST_ARG, SECOND_ARG, sizeof(param_value), param_value, 0)); \
generic_info info; \
info.dontfree = 0; \
info.opaque_class = CLASS_NONE; \
info.type = #TYPE"*"; \
info.value = (void*)param_value; \
......@@ -136,6 +140,7 @@
ar[i] = VEC[i]; \
} \
generic_info info; \
info.dontfree = 0; \
info.opaque_class = CLASS_NONE; \
info.type = _copy_str(std::string(#TYPE"[") + tostring(VEC.size()) + "]"); \
info.value = (void*)ar; \
......@@ -783,6 +788,7 @@ generic_info get_info(cl_device_info param_name) const
if(key == 0)
break;
generic_info info;
info.dontfree = 0;
info.opaque_class = CLASS_NONE;
switch (key)
{
......@@ -806,6 +812,8 @@ generic_info get_info(cl_device_info param_name) const
#endif
info.type = "intptr_t *";
info.value = (void*)result[i+1];
// we do not own this object
info.dontfree = 1;
break;
#endif
......
......@@ -23,6 +23,7 @@ typedef struct {
class_t opaque_class;
const char *type;
void *value;
int dontfree;
} generic_info;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment