From 93dfd3a8ca6f4a8a072eb17931df9d44d720f068 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Wed, 8 Jul 2026 01:45:35 +0300 Subject: [PATCH] rsx: Minor refactor to prep for surface cache access to texture cache helpers --- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 42 ++++++++++++++++++++ rpcs3/Emu/RSX/Common/TextureUtils.h | 18 +++++++++ rpcs3/Emu/RSX/Common/texture_cache_helpers.h | 15 ------- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 96b9e3e8bb..e30fc922f4 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -1703,6 +1703,48 @@ namespace rsx } } + rsx::surface_color_format get_compatible_surface_color_format(u32 gcm_format) + { + switch (gcm_format) + { + case CELL_GCM_TEXTURE_R5G6B5: + return rsx::surface_color_format::r5g6b5; + case CELL_GCM_TEXTURE_A8R8G8B8: + return rsx::surface_color_format::a8b8g8r8; + case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: + return rsx::surface_color_format::w16z16y16x16; + case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: + return rsx::surface_color_format::w32z32y32x32; + case CELL_GCM_TEXTURE_A1R5G5B5: + return rsx::surface_color_format::x1r5g5b5_o1r5g5b5; + case CELL_GCM_TEXTURE_B8: + return rsx::surface_color_format::b8; + case CELL_GCM_TEXTURE_G8B8: + return rsx::surface_color_format::g8b8; + case CELL_GCM_TEXTURE_X32_FLOAT: + return rsx::surface_color_format::x32; + default: + fmt::throw_exception("Unhandled surface format 0x%x", gcm_format); + } + } + + rsx::surface_depth_format2 get_compatible_surface_depth_format(u32 gcm_format) + { + switch (gcm_format) + { + case RSX_FORMAT_CLASS_DEPTH16_UNORM: + return rsx::surface_depth_format2::z16_uint; + case RSX_FORMAT_CLASS_DEPTH24_UNORM_X8_PACK32: + return rsx::surface_depth_format2::z24s8_uint; + case RSX_FORMAT_CLASS_DEPTH16_FLOAT: + return rsx::surface_depth_format2::z16_float; + case RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32: + return rsx::surface_depth_format2::z24s8_float; + default: + fmt::throw_exception("Invalid depth format 0x%x", gcm_format); + } + } + u32 get_max_depth_value(rsx::surface_depth_format2 format) { return get_format_block_size_in_bytes(format) == 2 ? 0xFFFF : 0xFFFFFF; diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 31f43432dc..8477ee0ee1 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -284,6 +284,21 @@ namespace rsx usz alignment; }; + struct image_section_attributes_t + { + u32 address; + u32 gcm_format; + u32 pitch; + u16 width; + u16 height; + u16 depth; + u16 mipmaps; + u16 slice_h; + u8 bpp; + bool swizzled; + bool edge_clamped; + }; + /** * Get size to store texture in a linear fashion. * Storage is assumed to use a rowPitchAlignment boundary for every row of texture. @@ -350,6 +365,9 @@ namespace rsx std::pair get_compatible_gcm_format(rsx::surface_color_format format); std::pair get_compatible_gcm_format(rsx::surface_depth_format2 format); + rsx::surface_color_format get_compatible_surface_color_format(u32 gcm_format); + rsx::surface_depth_format2 get_compatible_surface_depth_format(u32 gcm_format); + format_class classify_format(rsx::surface_depth_format2 format); format_class classify_format(u32 gcm_format); diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index 510dc3f136..5c16aa30bd 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -46,21 +46,6 @@ namespace rsx blit_image_static, // Variant of the copy command that does scaling instead of copying }; - struct image_section_attributes_t - { - u32 address; - u32 gcm_format; - u32 pitch; - u16 width; - u16 height; - u16 depth; - u16 mipmaps; - u16 slice_h; - u8 bpp; - bool swizzled; - bool edge_clamped; - }; - struct blit_op_result { bool succeeded = false;