diff --git a/src/core/gpu.h b/src/core/gpu.h index 2ef99145c..c29e04739 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -412,16 +412,27 @@ protected: virtual void DrawRendererStats(bool is_idle_frame); // These are **very** approximate. - ALWAYS_INLINE void AddDrawTriangleTicks(u32 width, u32 height, bool textured, bool shaded) + ALWAYS_INLINE void AddDrawTriangleTicks(u32 width, u32 height, bool shaded, bool textured, bool semitransparent) { -#if 0 - const u32 draw_ticks = static_cast((std::abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) + 1u) / 2u); -#else - const u32 draw_ticks = ((width + 2) / 3) * height; -#endif - AddCommandTicks(draw_ticks); + const u32 average_width = ((width + 2) / 3); + u32 ticks_per_row = average_width; + if (textured) + ticks_per_row += average_width; + if (semitransparent || m_GPUSTAT.check_mask_before_draw) + ticks_per_row += (average_width + 1u) / 2u; + + AddCommandTicks(ticks_per_row * height); + } + ALWAYS_INLINE void AddDrawRectangleTicks(u32 width, u32 height, bool textured, bool semitransparent) + { + u32 ticks_per_row = width; + if (textured) + ticks_per_row += width; + if (semitransparent || m_GPUSTAT.check_mask_before_draw) + ticks_per_row += (width + 1u) / 2u; + + AddCommandTicks(ticks_per_row * height); } - ALWAYS_INLINE void AddDrawRectangleTicks(u32 width, u32 height, bool textured) { AddCommandTicks(width * height); } ALWAYS_INLINE void AddDrawLineTicks(u32 width, u32 height, bool shaded) { AddCommandTicks(std::max(width, height)); } HostDisplay* m_host_display = nullptr; diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 95d21ce62..569e49c45 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -241,7 +241,8 @@ void GPU_HW::LoadVertices() static_cast(std::clamp(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u; m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom); - AddDrawTriangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.texture_enable, rc.shading_enable); + AddDrawTriangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.shading_enable, rc.texture_enable, + rc.transparency_enable); std::memcpy(m_batch_current_vertex_ptr, vertices.data(), sizeof(BatchVertex) * 3); m_batch_current_vertex_ptr += 3; @@ -271,7 +272,8 @@ void GPU_HW::LoadVertices() static_cast(std::clamp(max_y_123, m_drawing_area.top, m_drawing_area.bottom)) + 1u; m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom); - AddDrawTriangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.texture_enable, rc.shading_enable); + AddDrawTriangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.shading_enable, rc.texture_enable, + rc.transparency_enable); AddVertex(vertices[2]); AddVertex(vertices[1]); @@ -367,7 +369,7 @@ void GPU_HW::LoadVertices() static_cast(std::clamp(pos_y + rectangle_height, m_drawing_area.top, m_drawing_area.bottom)) + 1u; m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom); - AddDrawRectangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.texture_enable); + AddDrawRectangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.texture_enable, rc.transparency_enable); } break; diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index bfb7a2131..a129088d8 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -433,7 +433,7 @@ void GPU_SW::DrawTriangle(const SWVertex* v0, const SWVertex* v1, const SWVertex max_x = std::clamp(max_x, static_cast(m_drawing_area.left), static_cast(m_drawing_area.right)); min_y = std::clamp(min_y, static_cast(m_drawing_area.top), static_cast(m_drawing_area.bottom)); max_y = std::clamp(max_y, static_cast(m_drawing_area.top), static_cast(m_drawing_area.bottom)); - AddDrawTriangleTicks(max_x - min_x + 1, max_y - min_y + 1, texture_enable, shading_enable); + AddDrawTriangleTicks(max_x - min_x + 1, max_y - min_y + 1, shading_enable, texture_enable, transparency_enable); // compute per-pixel increments const s32 a01 = py0 - py1, b01 = px1 - px0; @@ -539,7 +539,7 @@ void GPU_SW::DrawRectangle(s32 origin_x, s32 origin_y, u32 width, u32 height, u8 const u32 clip_bottom = static_cast(std::clamp(start_y + static_cast(height), m_drawing_area.top, m_drawing_area.bottom)) + 1u; - AddDrawRectangleTicks(clip_right - clip_left, clip_bottom - clip_top, texture_enable); + AddDrawRectangleTicks(clip_right - clip_left, clip_bottom - clip_top, texture_enable, transparency_enable); } for (u32 offset_y = 0; offset_y < height; offset_y++)