Add optional CLContext argument to VisionIpcClient (#510)

* Add optional CLContext argument to VisionIpcClient

* Remove CL_DEVICE_TYPE_DEFAULT
This commit is contained in:
Mitchell Goff 2023-08-03 14:37:35 -07:00 committed by GitHub
parent 774bf79f4d
commit a5378db82d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -8,7 +8,12 @@ from libc.stdint cimport uint32_t, uint64_t
from libcpp cimport bool, int
cdef extern from "cereal/visionipc/visionbuf.h":
struct _cl_device_id
struct _cl_context
struct _cl_mem
ctypedef _cl_device_id * cl_device_id
ctypedef _cl_context * cl_context
ctypedef _cl_mem * cl_mem
cdef enum VisionStreamType:

View File

@ -2,6 +2,11 @@
#cython: language_level=3
from .visionipc cimport VisionBuf as cppVisionBuf
from .visionipc cimport cl_device_id, cl_context
cdef class CLContext:
cdef cl_device_id device_id
cdef cl_context context
cdef class VisionBuf:
cdef cppVisionBuf * buf

View File

@ -98,8 +98,11 @@ cdef class VisionIpcClient:
cdef cppVisionIpcClient * client
cdef VisionIpcBufExtra extra
def __cinit__(self, string name, VisionStreamType stream, bool conflate):
self.client = new cppVisionIpcClient(name, stream, conflate, NULL, NULL)
def __cinit__(self, string name, VisionStreamType stream, bool conflate, CLContext context = None):
if context:
self.client = new cppVisionIpcClient(name, stream, conflate, context.device_id, context.context)
else:
self.client = new cppVisionIpcClient(name, stream, conflate, NULL, NULL)
def __dealloc__(self):
del self.client