@@ -40,15 +40,15 @@ def __init__(self,
4040 init_buffer_size : int = 32768 ,
4141 init_texture_size : List [int ] = [512 , 512 ],
4242 dtype : str = torch .float , # +5-10 fps on 3060, not working too well with flame_salmon
43- tex_dtype : str = torch .half , # +5-10 fps on 3060, not working too well with flame_salmon
43+ tex_dtype : str = torch .uint8 , # +5-10 fps on 3060, not working too well with flame_salmon
4444
4545 # DEBUG: whether to write back to cuda in offline rendering mode, only used for speed tests
4646 offline_writeback : bool = True ,
4747 ):
4848 self .attr_sizes = [3 , 3 , 3 , 4 ] # verts, cov6, rgba4
4949 self .dtype = getattr (torch , dtype ) if isinstance (dtype , str ) else dtype
5050 self .tex_dtype = getattr (torch , tex_dtype ) if isinstance (tex_dtype , str ) else tex_dtype
51- self .gl_tex_dtype = gl .GL_RGBA16F if self .tex_dtype == torch .half else gl .GL_RGBA32F
51+ self .gl_tex_dtype = gl .GL_RGBA16F if self .tex_dtype == torch .half else gl .GL_RGBA32F if self . tex_dtype == torch . float else gl . GL_RGBA8
5252 self .gl_attr_dtypes = [gl .GL_FLOAT if self .dtype == torch .float else gl .GL_HALF_FLOAT ] * len (self .attr_sizes )
5353 self .uniforms = dotdict () # uniform values
5454
@@ -63,7 +63,7 @@ def __init__(self,
6363 self .resize_buffers (init_buffer_size )
6464 self .resize_textures (* init_texture_size )
6565
66- log (bold (f'[FAST GAUSS] GSplatContextManager initialized with attribute dtype: { self .dtype } , texture dtype: { self .tex_dtype } , offline rendering: { self .offline_rendering } , buffer size: { init_buffer_size } , texture size: { init_texture_size } ' ))
66+ log (bold (f'[FAST GAUSS] GSplatContextManager initialized with attribute dtype: { self .dtype } , texture dtype: { self .tex_dtype } , offline rendering: { self .offline_rendering } , vertex buffer size: { init_buffer_size } , render buffer size: { init_texture_size } ' ))
6767
6868 if not self .offline_rendering :
6969 log (bold ('[FAST GAUSS] Using online rendering mode, in this mode, calling the rendering function of fast_gauss will write directly to the currently bound framebuffer' ))
@@ -199,7 +199,7 @@ def init_textures(self, H: int, W: int):
199199 # Init the texture (call the resizing function), will simply allocate empty memory
200200 # The internal format describes how the texture shall be stored in the GPU. The format describes how the format of your pixel data in client memory (together with the type parameter).
201201 gl .glBindRenderbuffer (gl .GL_RENDERBUFFER , self .rbo_rgba )
202- gl .glRenderbufferStorage (gl .GL_RENDERBUFFER , gl . GL_RGBA8 , W , H )
202+ gl .glRenderbufferStorage (gl .GL_RENDERBUFFER , self . gl_tex_dtype , W , H ) # faster if using rgba8
203203 gl .glBindRenderbuffer (gl .GL_RENDERBUFFER , self .rbo_atth )
204204 gl .glRenderbufferStorage (gl .GL_RENDERBUFFER , gl .GL_DEPTH_COMPONENT , W , H )
205205
@@ -228,15 +228,15 @@ def resize_textures(self, H: int, W: int): # analogy to update_gl_buffers
228228 if H > self .max_H or W > self .max_W : # max got updated
229229 if H > self .max_H : self .max_H = int (H * 1.05 )
230230 if W > self .max_W : self .max_W = int (W * 1.05 )
231- if not init : log (bold ('[FAST GAUSS] Resizing textures to:' ), int (H ), int (W ))
231+ if not init : log (bold ('[FAST GAUSS] Resizing render buffers to:' ), int (H ), int (W ))
232232 self .init_textures (self .max_H , self .max_W )
233233
234234 def resize_buffers (self , v : int = 0 ):
235235 init = False
236236 if not hasattr (self , 'max_verts' ): self .max_verts = 0 ; init = True
237237 if v > self .max_verts :
238238 if v > self .max_verts : self .max_verts = int (v * 1.05 )
239- if not init : log (bold ('[FAST GAUSS] Resizing buffers to:' ), int (v ))
239+ if not init : log (bold ('[FAST GAUSS] Resizing vertex buffers to:' ), int (v ))
240240 self .init_gl_buffers (self .max_verts )
241241
242242 @torch .no_grad ()
@@ -353,8 +353,12 @@ def render(self, xyz3: torch.Tensor, cov6: torch.Tensor, rgb3: torch.Tensor, occ
353353 CHECK_CUDART_ERROR (cudart .cudaGraphicsUnmapResources (1 , cu_tex , stream ))
354354
355355 if rgba_map .dtype != xyz3 .dtype :
356- warn_once (yellow (f'Using texture dtype { rgba_map .dtype } , expected { xyz3 .dtype } for the output, will cast to { xyz3 .dtype } ' ))
357- rgba_map = rgba_map .to (xyz3 .dtype )
356+ warn_once (yellow (f'[FAST GAUSS] Using render buffer dtype { rgba_map .dtype } , expected { xyz3 .dtype } for the output, will cast to { xyz3 .dtype } ' ))
357+ if not torch .is_floating_point (rgba_map ):
358+ warn_once (yellow (f'[FAST GAUSS] Using a non-floating-point render buffer dtype: { rgba_map .dtype } , this might cause some precision loss' ))
359+ rgba_map = rgba_map / torch .iinfo (rgba_map .dtype ).max # should be 255 for uint8
360+ else :
361+ rgba_map = rgba_map .to (xyz3 .dtype )
358362
359363 return rgba_map # H, W, 4
360364 else :
0 commit comments