Skip to content

Commit

Permalink
the device buffer is bigger than what we really need, don't return an…
Browse files Browse the repository at this point in the history
… image pixel buffer that big: slice it to the size of the actual pixel data

git-svn-id: https://xpra.org/svn/Xpra/trunk@16457 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 22, 2017
1 parent e3a04c1 commit 4d66fa2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/xpra/codecs/nvfbc/fbc_capture_win.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ cdef class NvFBC_CUDACapture:
cdef double start = monotonic_time()
#allocate CUDA device memory:
if not self.cuda_device_buffer:
#TODO: choose a better size
self.cuda_device_buffer = driver.mem_alloc(self.max_buffer_size)
log("max_buffer_size=%#x, cuda device buffer=%s", self.max_buffer_size, self.cuda_device_buffer)
#cuda_device_buffer, stride = self.cuda_device.mem_alloc_pitch(4096, 2160, 16)
Expand Down Expand Up @@ -759,10 +760,12 @@ class CUDAImageWrapper(ImageWrapper):
#size = self.rowstride*self.height*len(self.pixel_format)
self.cuda_context.push()
size = self.buffer_size
#TODO: download just pixel_len bytes, not the whole buffer... (which may be quite a lot bigger)
host_buffer = driver.pagelocked_empty(size, dtype=numpy.byte)
driver.memcpy_dtoh(host_buffer, self.cuda_device_buffer)
elapsed = monotonic_time()-start
self.pixels = host_buffer.tostring()
pixel_len = self.rowstride*self.height
self.pixels = host_buffer[:pixel_len].tobytes()
self.downloaded = True
elapsed = monotonic_time()-start
log("may_download() from %s to %s, size=%s, elapsed=%ims - %iMB/s", self.cuda_device_buffer, host_buffer, size, int(1000*elapsed), size/elapsed/1024/1024)
Expand Down

0 comments on commit 4d66fa2

Please sign in to comment.