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

Method render_loop

easyvolcap/runners/websocket_server.py:103–124  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 def W(self, value): self.camera.W = value
102
103 def render_loop(self): # this is the main thread
104 frame_cnt = 0
105 prev_time = time.perf_counter()
106
107 while True:
108 batch = self.camera.to_batch() # fast copy of camera parameter
109 image = self.render(batch) # H, W, 4, cuda gpu tensor
110 self.stream.wait_stream(torch.cuda.current_stream()) # initiate copy after main stream has finished
111 with torch.cuda.stream(self.stream):
112 with self.lock:
113 self.image = image.to('cpu', non_blocking=True) # initiate async copy
114
115 curr_time = time.perf_counter()
116 pass_time = curr_time - prev_time
117 frame_cnt += 1
118 if pass_time > 2.0:
119 fps = frame_cnt / pass_time
120 frame_cnt = 0
121 prev_time = curr_time
122 log('Renderer FPS:', fps)
123 log('Renderer camera shape:', self.camera.H, self.camera.W)
124 log('Renderer image sum:', self.image.sum())
125
126 async def server_loop(self, websocket: websockets.WebSocket, path: str):
127 frame_cnt = 0

Callers 1

runMethod · 0.95

Calls 3

renderMethod · 0.95
to_batchMethod · 0.80
logFunction · 0.50

Tested by

no test coverage detected