From 7240cbfdab493517d1faf6da055f09761ebdef00 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 15 Mar 2026 19:55:17 +0300 Subject: [PATCH] rsx/overlays: Implement arrow rendering --- rpcs3/Emu/RSX/Overlays/overlay_arrow.h | 47 ++++++++++++++++++++++++++ rpcs3/Emu/RSX/Overlays/overlay_utils.h | 46 +++++++++++++++++++++++++ rpcs3/emucore.vcxproj | 1 + rpcs3/emucore.vcxproj.filters | 3 ++ 4 files changed, 97 insertions(+) create mode 100644 rpcs3/Emu/RSX/Overlays/overlay_arrow.h diff --git a/rpcs3/Emu/RSX/Overlays/overlay_arrow.h b/rpcs3/Emu/RSX/Overlays/overlay_arrow.h new file mode 100644 index 0000000000..596bced284 --- /dev/null +++ b/rpcs3/Emu/RSX/Overlays/overlay_arrow.h @@ -0,0 +1,47 @@ +#pragma once + +#include "overlay_controls.h" + +namespace rsx::overlays +{ + template + requires (Anchor >= 0 && Anchor < 4 && Base >= 0 && Base < 4 && Edge0 >= 0 && Edge0 < 4 && Edge1 >= 0 && Edge1 < 4) + struct arrow_base : public overlay_element + { + compiled_resource& get_compiled() override + { + if (is_compiled()) + { + return compiled_resources; + } + + overlay_element::get_compiled(); + + m_vertex_cache.resize(3); + m_vertex_cache[0] = compiled_resources.draw_commands[0].verts[Anchor]; + m_vertex_cache[1] = compiled_resources.draw_commands[0].verts[Base]; + m_vertex_cache[2] = compiled_resources.draw_commands[0].verts[Edge0] + compiled_resources.draw_commands[0].verts[Edge1]; + m_vertex_cache[2] /= 2; + compiled_resources.draw_commands[0].verts.swap(m_vertex_cache); + compiled_resources.draw_commands[0].config.primitives = overlays::primitive_type::triangle_strip; + + m_is_compiled = true; + return compiled_resources; + } + + private: + std::vector m_vertex_cache; + }; + + struct arrow_up : public arrow_base<2, 3, 0, 1> + {}; + + struct arrow_down : public arrow_base<0, 1, 2, 3> + {}; + + struct arrow_left : public arrow_base<1, 2, 3, 0> + {}; + + struct arrow_right : public arrow_base<3, 0, 1, 2> + {}; +} diff --git a/rpcs3/Emu/RSX/Overlays/overlay_utils.h b/rpcs3/Emu/RSX/Overlays/overlay_utils.h index cab0e1a598..aaa70f09a3 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_utils.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_utils.h @@ -95,6 +95,52 @@ struct vertex values[2] -= other.values[2]; values[3] -= other.values[3]; } + + void operator /= (const vertex& other) + { + values[0] /= other.values[0]; + values[1] /= other.values[1]; + values[2] /= other.values[2]; + values[3] /= other.values[3]; + } + + void operator /= (float rhs) + { + values[0] /= rhs; + values[1] /= rhs; + values[2] /= rhs; + values[3] /= rhs; + } + + void operator *= (const vertex& other) + { + values[0] *= other.values[0]; + values[1] *= other.values[1]; + values[2] *= other.values[2]; + values[3] *= other.values[3]; + } + + void operator *= (float rhs) + { + values[0] *= rhs; + values[1] *= rhs; + values[2] *= rhs; + values[3] *= rhs; + } + + vertex operator + (const vertex& other) const + { + vertex result = *this; + result += other; + return result; + } + + vertex operator - (const vertex& other) const + { + vertex result = *this; + result -= other; + return result; + } }; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 5834917530..7253171856 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -711,6 +711,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 952607794f..a5a5825f44 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -2869,6 +2869,9 @@ Emu\GPU\RSX\Overlays + + Emu\GPU\RSX\Overlays +