in mujoco_py/mjbatchrenderer.pyx [0:0]
def map(self):
""" Map OpenGL buffer to CUDA for reading. """
if not self._use_cuda:
raise CudaNotEnabledError()
elif self._cuda_buffers_are_mapped:
return # just make it a no-op
self._cuda_context.push()
self._cuda_rgb_mapping = self._cuda_rgb_pbo.map()
ptr, self._cuda_rgb_buf_size = (
self._cuda_rgb_mapping.device_ptr_and_size())
assert ptr is not None and self._cuda_rgb_buf_size > 0
if self._cuda_rgb_ptr is None:
self._cuda_rgb_ptr = ptr
# There doesn't seem to be a guarantee from the API that the
# pointer will be the same between mappings, but empirically
# this has been true. If this isn't true, we need to modify
# the interface to MjBatchRenderer to make this clearer to user.
# So, hopefully we won't hit this assert.
assert self._cuda_rgb_ptr == ptr, (
"Mapped CUDA rgb buffer pointer %d doesn't match old pointer %d" %
(ptr, self._cuda_rgb_ptr))
if self._depth:
self._cuda_depth_mapping = self._cuda_depth_pbo.map()
ptr, self._cuda_depth_buf_size = (
self._cuda_depth_mapping.device_ptr_and_size())
assert ptr is not None and self._cuda_depth_buf_size > 0
if self._cuda_depth_ptr is None:
self._cuda_depth_ptr = ptr
assert self._cuda_depth_ptr == ptr, (
"Mapped CUDA depth buffer pointer %d doesn't match old pointer %d" %
(ptr, self._cuda_depth_ptr))
self._cuda_buffers_are_mapped = True