live_render: skip the per-frame PNG write once a window is showing
Image.fromarray(...).save() ran on EVERY frame regardless of whether a window was already displaying it -- pure disk-I/O overhead adding to the render-vs-game latency gap. Only write PNGs when there is no window (the offline/headless case, where they are the actual output). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -184,14 +184,17 @@ def feed_more(block):
|
||||
|
||||
|
||||
def present(img, nth):
|
||||
Image.fromarray(img, 'RGB').save(os.path.join(HERE, 'live_%04d.png' % nth))
|
||||
if win is not None:
|
||||
# live window: skip the per-frame PNG write (a real disk-I/O cost
|
||||
# that was adding latency for no benefit once a window is showing)
|
||||
import pygame
|
||||
surf = pygame.surfarray.make_surface(np.transpose(img, (1, 0, 2)))
|
||||
win.blit(surf, (0, 0)); pygame.display.flip()
|
||||
for ev in pygame.event.get():
|
||||
if ev.type == pygame.QUIT:
|
||||
return False
|
||||
else:
|
||||
Image.fromarray(img, 'RGB').save(os.path.join(HERE, 'live_%04d.png' % nth))
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user