Skip to content

Commit

Permalink
easyvolcap: fixing slow upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dendenxu committed Apr 6, 2024
1 parent a45bc20 commit 5709559
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions easyvolcap/runners/volumetric_video_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,12 @@ def init_glfw(self):

# Create a windowed mode window and its OpenGL context
window = glfw.create_window(self.W, self.H, self.window_title, None, None)
if window is None:
glfw.terminate()
log(red('Could not initialize window'))
raise RuntimeError('Failed to initialize window in glfw')

# Setting up the window
glfw.make_context_current(window)
glfw.swap_interval(self.use_vsync) # disable vsync

Expand All @@ -1478,10 +1484,5 @@ def init_glfw(self):
height, width = icon.shape[:2]
glfw.set_window_icon(window, 1, [width, height, pixels]) # set icon for the window

if not window:
glfw.terminate()
log(red('Could not initialize window'))
raise RuntimeError('Failed to initialize window in glfw')

self.window = window
cfg.window = window # MARK: GLOBAL VARIABLE
7 changes: 4 additions & 3 deletions easyvolcap/utils/gl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def init_texture(self):

def copy_to_texture(self, image: torch.Tensor, x: int = 0, y: int = 0, w: int = 0, h: int = 0):
if not self.use_quad_cuda:
self.upload_to_texture(image)
self.upload_to_texture(image, x, y, w, h)
return

if not hasattr(self, 'cu_tex'):
Expand Down Expand Up @@ -647,7 +647,7 @@ def upload_to_texture(self, ptr: np.ndarray, x: int = 0, y: int = 0, w: int = 0,
ptr = ptr.detach().cpu().numpy() # slow sync and copy operation # MARK: SYNC

gl.glBindTexture(gl.GL_TEXTURE_2D, self.tex)
gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, x, y, w, h, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, ptr[y:h, x:w]) # to gpu, might slow down?
gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, x, y, w, h, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, ptr) # to gpu, might slow down?

@property
def verts_data(self): # a heavy copy operation
Expand Down Expand Up @@ -1319,9 +1319,10 @@ def init_gl_buffers(self, v: int = 0, f: int = 0):
try:
self.cu_vbo = CHECK_CUDART_ERROR(cudart.cudaGraphicsGLRegisterBuffer(self.vbo, flags))
except RuntimeError as e:
log(red(f'Your system does not support CUDA-GL interop, please use pytorch3d\'s implementation instead'))
log(red(f'Your system does not support CUDA-GL interop, will use pytorch3d\'s implementation instead'))
log(red(f'This can be done by specifying {blue("model_cfg.sampler_cfg.use_cudagl=False model_cfg.sampler_cfg.use_diffgl=False")} at the end of your command'))
log(red(f'Note that this implementation is extremely slow, we recommend running on a native system that support the interop'))
log(red(f'An alternative is to install diff_point_rasterization and use the approximated tile-based rasterization, enabled by the `render_gs` switch'))
# raise RuntimeError(str(e) + ": This unrecoverable, please read the error message above")
raise e

Expand Down

0 comments on commit 5709559

Please sign in to comment.