From 0f1735d0df96e662c3e36df5d785e890c9caade1 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 22 Feb 2026 20:26:26 +0300 Subject: [PATCH] gl: Add support for subviews --- rpcs3/Emu/RSX/GL/glutils/image.cpp | 28 ++++++++++++++++++++++++++++ rpcs3/Emu/RSX/GL/glutils/image.h | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/GL/glutils/image.cpp b/rpcs3/Emu/RSX/GL/glutils/image.cpp index bb6439cc05..7dbd7fc254 100644 --- a/rpcs3/Emu/RSX/GL/glutils/image.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/image.cpp @@ -318,6 +318,34 @@ namespace gl } } + texture_view* texture_view::as(GLenum format) + { + if (format == this->m_view_format) + { + return this; + } + + auto self = m_root_view ? m_root_view : this; + if (auto found = self->m_subviews.find(format); + found != self->m_subviews.end()) + { + return found->second.get(); + } + + GLenum swizzle_argb[4] = + { + component_swizzle[3], + component_swizzle[0], + component_swizzle[1], + component_swizzle[2], + }; + + auto view = std::make_unique(m_image_data, m_target, format, swizzle_argb, m_aspect_flags); + auto ret = view.get(); + self->m_subviews.emplace(format, std::move(view)); + return ret; + } + void texture_view::bind(gl::command_context& cmd, GLuint layer) const { cmd->bind_texture(layer, m_target, m_id); diff --git a/rpcs3/Emu/RSX/GL/glutils/image.h b/rpcs3/Emu/RSX/GL/glutils/image.h index 6617caa54c..4112d833c7 100644 --- a/rpcs3/Emu/RSX/GL/glutils/image.h +++ b/rpcs3/Emu/RSX/GL/glutils/image.h @@ -353,7 +353,10 @@ namespace gl GLenum m_aspect_flags = 0; texture* m_image_data = nullptr; - GLenum component_swizzle[4] {}; + GLenum component_swizzle[4]{}; + + std::unordered_map> m_subviews; + texture_view* m_root_view = nullptr; texture_view() = default; @@ -395,6 +398,8 @@ namespace gl virtual ~texture_view(); + texture_view* as(GLenum format); + GLuint id() const { return m_id;