MCPcopy
hub / github.com/zju3dv/4K4D / upload_to_texture

Method upload_to_texture

easyvolcap/utils/gl_utils.py:643–650  ·  view source on GitHub ↗
(self, ptr: np.ndarray, x: int = 0, y: int = 0, w: int = 0, h: int = 0)

Source from the content-addressed store, hash-verified

641 CHECK_CUDART_ERROR(cudart.cudaGraphicsUnmapResources(1, self.cu_tex, torch.cuda.current_stream().cuda_stream))
642
643 def upload_to_texture(self, ptr: np.ndarray, x: int = 0, y: int = 0, w: int = 0, h: int = 0):
644 w = w or self.W
645 h = h or self.H
646 if isinstance(ptr, torch.Tensor):
647 ptr = ptr.detach().cpu().numpy() # slow sync and copy operation # MARK: SYNC
648
649 gl.glBindTexture(gl.GL_TEXTURE_2D, self.tex)
650 gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, x, y, w, h, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, ptr) # to gpu, might slow down?
651
652 @property
653 def verts_data(self): # a heavy copy operation

Callers 4

copy_to_textureMethod · 0.95
test_gl_tex_blitFunction · 0.95
test_gl_quad_blitFunction · 0.95
test_gl_quad_drawFunction · 0.95

Calls 2

numpyMethod · 0.80
cpuMethod · 0.80

Tested by 3

test_gl_tex_blitFunction · 0.76
test_gl_quad_blitFunction · 0.76
test_gl_quad_drawFunction · 0.76