From 45bae0046a3e792ae20c572c863a5347d8ac594b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 21 Mar 2026 23:14:34 +0300 Subject: [PATCH] vk: Add support for basic SDF rendering - Does not support scaled coordinates yet --- rpcs3/Emu/RSX/VK/VKOverlays.cpp | 21 +++++++++++++++++++-- rpcs3/Emu/RSX/VK/VKOverlays.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.cpp b/rpcs3/Emu/RSX/VK/VKOverlays.cpp index 55daab4a90..c555e7a341 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.cpp +++ b/rpcs3/Emu/RSX/VK/VKOverlays.cpp @@ -510,7 +510,7 @@ namespace vk glsl::input_type_push_constant, 0, 0, - glsl::push_constant_ref {.offset = 68, .size = 12 } + glsl::push_constant_ref {.offset = 68, .size = 60 } ) ); return result; @@ -527,6 +527,10 @@ namespace vk // 68: uint fragment_config; // 72: float timestamp; // 76: float blur_intensity; + // 80: vec4 sdf_params; + // 96: vec2 sdf_origin; + // 104: vec2 reserved; + // 112: vec4 sdf_border_color; f32 push_buf[32]; // 1. Vertex config (00 - 63) @@ -557,13 +561,24 @@ namespace vk .texture_mode(m_texture_type) .clip_fragments(m_clip_enabled) .pulse_glow(m_pulse_glow) + .set_sdf(m_sdf_config.func) .get(); push_buf[0] = std::bit_cast(frag_config); push_buf[1] = m_time; push_buf[2] = m_blur_strength; + push_buf[3] = m_sdf_config.hx; + push_buf[4] = m_sdf_config.hy; + push_buf[5] = m_sdf_config.br; + push_buf[6] = m_sdf_config.bw; + push_buf[7] = m_sdf_config.cx; + push_buf[8] = m_sdf_config.cy; + push_buf[9] = 0.f; + push_buf[10] = 0.f; - vkCmdPushConstants(cmd, program->layout(), VK_SHADER_STAGE_FRAGMENT_BIT, 68, 12, push_buf); + std::memcpy(push_buf + 11, m_sdf_config.border_color.rgba, 16); + + vkCmdPushConstants(cmd, program->layout(), VK_SHADER_STAGE_FRAGMENT_BIT, 68, 60, push_buf); } void ui_overlay_renderer::set_primitive_type(rsx::overlays::primitive_type type) @@ -644,6 +659,8 @@ namespace vk m_clip_region = command.config.clip_rect; m_disable_vertex_snap = command.config.disable_vertex_snap; + m_sdf_config = command.config.sdf_config; + vk::image_view* src = nullptr; switch (command.config.texture_ref) { diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.h b/rpcs3/Emu/RSX/VK/VKOverlays.h index 414c7c4945..de2c218ebe 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.h +++ b/rpcs3/Emu/RSX/VK/VKOverlays.h @@ -132,6 +132,8 @@ namespace vk areaf m_clip_region; coordf m_viewport; + rsx::overlays::compiled_resource::sdf_config_t m_sdf_config{}; + std::vector> resources; std::unordered_map> font_cache; std::unordered_map> view_cache;