Show 100% for the shader step only when the last shader is built.

The shader step's progress event rounded its share to four decimals, and the launcher shows the whole percent below it: 42,140 of 42,142 shaders built read as 100% while a long driver compile was still running. The event now carries the share as computed, so the bar stays at 99% until the count is complete. The test feeds the last counts of a 100,000-shader build and fails with the rounding.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 22:59:03 -05:00
parent 093cf949df
commit f017849e2b
2 changed files with 8 additions and 4 deletions

View File

@@ -1627,9 +1627,10 @@ class MakeGameTest(Tmp):
'for d in (0, 50, 100):\n'
' print(f"prepare-shaders: progress translate {d} 100", flush=True)\n'
' time.sleep(0.05)\n'
'print("prepare-shaders: progress build 10 100", flush=True)\n'
'print("prepare-shaders: progress build 10000 100000", flush=True)\n'
'time.sleep(0.6)\n'
'print("prepare-shaders: progress build 100 100", flush=True)\n')
'for d in (99998, 99999, 100000):\n'
' print(f"prepare-shaders: progress build {d} 100000", flush=True)\n')
for name, value in (('KIT', kit), ('EVENTS', True), ('SHADER_BEAT_S', 0.1), ('SHADER_STALL_S', 0.3)):
self.addCleanup(setattr, self.mg, name, getattr(self.mg, name))
setattr(self.mg, name, value)
@@ -1650,7 +1651,10 @@ class MakeGameTest(Tmp):
self.assertTrue(any(d.startswith("Reading the game's shaders") for d in details))
self.assertIn('Translated 50 of 100 shaders', details)
self.assertGreaterEqual(sum(1 for e in events if e['fraction'] == 0.55), 2) # heartbeats while the build waits
self.assertTrue(any(d.startswith('Built 10 of 100') and 'still running' in d for d in details))
self.assertTrue(any(d.startswith('Built 10,000 of 100,000') and 'still running' in d for d in details))
for done in ('99,998', '99,999'):
event = next(e for e in events if e['detail'].startswith(f'Built {done} of 100,000'))
self.assertEqual(int(event['fraction'] * 100), 99)
self.assertEqual([e['fraction'] for e in events if e['detail'] == 'Translated 50 of 100 shaders'][0], 0.25)
def test_a_build_only_run_fills_the_whole_bar(self):

View File

@@ -1773,7 +1773,7 @@ def shader_progress(phase, done, total, quiet_s, elapsed_s, build_only=False):
if quiet_s >= SHADER_STALL_S:
detail += (f'. No change for {int(quiet_s) // 60} min, but it is still running: one large shader can take '
'a while')
return {'step': 'shaders', 'fraction': round(fraction, 4), 'detail': detail}
return {'step': 'shaders', 'fraction': fraction, 'detail': detail}
# In the game's shader-cache/: the translator identities its translations are of, newest first (runtime/gfx_shader.c,