Skip to content

Commit

Permalink
Add optional CLContext argument to VisionIpcClient
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellgoffpc committed Aug 3, 2023
1 parent 774bf79 commit 294c3cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions visionipc/visionipc.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ from libc.stdint cimport uint32_t, uint64_t
from libcpp cimport bool, int

cdef extern from "cereal/visionipc/visionbuf.h":
cdef unsigned long CL_DEVICE_TYPE_DEFAULT

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:
Expand Down
5 changes: 5 additions & 0 deletions visionipc/visionipc_pyx.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions visionipc/visionipc_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 294c3cf

Please sign in to comment.