From 5028b53b49d726bf8bdf526b703e4caf85925b52 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sat, 8 Jan 2022 02:57:35 +0100 Subject: [PATCH] LibSoftGPU: Make divide-by-zero guard more explicit in stats overlay This previously assigned 1 to any divisor that was 0 which was a bit confusing --- Userland/Libraries/LibSoftGPU/Device.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 28f4ae4a38..d00ba76052 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -900,9 +900,6 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target) if (milliseconds > 500) { - if (g_num_pixels == 0) - g_num_pixels = 1; - int num_rendertarget_pixels = m_render_target->width() * m_render_target->height(); StringBuilder builder; @@ -913,9 +910,9 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target) builder.append(String::formatted("SIMD usage : {}%\n", g_num_quads > 0 ? g_num_pixels_shaded * 25 / g_num_quads : 0)); builder.append(String::formatted("Pixels : {}, Shaded: {}%, Blended: {}%, Overdraw: {}%\n", g_num_pixels, - g_num_pixels_shaded * 100 / g_num_pixels, - g_num_pixels_blended * 100 / g_num_pixels_shaded, - g_num_pixels_shaded * 100 / num_rendertarget_pixels - 100)); + g_num_pixels > 0 ? g_num_pixels_shaded * 100 / g_num_pixels : 0, + g_num_pixels_shaded > 0 ? g_num_pixels_blended * 100 / g_num_pixels_shaded : 0, + num_rendertarget_pixels > 0 ? g_num_pixels_shaded * 100 / num_rendertarget_pixels - 100 : 0)); builder.append(String::formatted("Sampler calls: {}\n", g_num_sampler_calls)); debug_string = builder.to_string();