diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 30d4abbf8c..f940c83062 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -627,7 +627,7 @@ namespace const u32 slice_sz = src_pitch_in_block * block_size_in_bytes * full_height_in_block * miplevel_depth; current_subresource_layout.pitch_in_block = src_pitch_in_block; - current_subresource_layout.data = std::span(texture_data_pointer + offset_in_src, slice_sz); + current_subresource_layout.data = { texture_data_pointer + offset_in_src, slice_sz }; offset_in_src += slice_sz; miplevel_width_in_texel = std::max(miplevel_width_in_texel / 2, 1); @@ -825,13 +825,13 @@ namespace rsx case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: { - copy_decoded_rb_rg_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(src_layout.width_in_texel, caps.alignment), src_layout.pitch_in_block); + copy_decoded_rb_rg_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(src_layout.width_in_texel, caps.alignment), src_layout.pitch_in_block); break; } case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: { - copy_decoded_rb_rg_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(src_layout.width_in_texel, caps.alignment), src_layout.pitch_in_block); + copy_decoded_rb_rg_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(src_layout.width_in_texel, caps.alignment), src_layout.pitch_in_block); break; } @@ -839,9 +839,9 @@ namespace rsx case CELL_GCM_TEXTURE_R6G5B5: { if (is_swizzled) - copy_rgb655_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment)); + copy_rgb655_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment)); else - copy_rgb655_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_rgb655_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); break; } @@ -855,49 +855,49 @@ namespace rsx case CELL_GCM_TEXTURE_R6G5B5: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb655_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb655_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb655_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb655_to_bgra8); break; } case CELL_GCM_TEXTURE_D1R5G5B5: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_d1rgb5_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_d1rgb5_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_d1rgb5_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_d1rgb5_to_bgra8); break; } case CELL_GCM_TEXTURE_A1R5G5B5: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_a1rgb5_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_a1rgb5_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_a1rgb5_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_a1rgb5_to_bgra8); break; } case CELL_GCM_TEXTURE_A4R4G4B4: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_argb4_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_argb4_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_argb4_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_argb4_to_bgra8); break; } case CELL_GCM_TEXTURE_R5G5B5A1: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb5a1_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb5a1_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb5a1_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb5a1_to_bgra8); break; } case CELL_GCM_TEXTURE_R5G6B5: { if (is_swizzled) - convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb565_to_bgra8); + convert_16_block_32_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), &convert_rgb565_to_bgra8); else - convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb565_to_bgra8); + convert_16_block_32::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), w, h, depth, src_layout.border, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block, &convert_rgb565_to_bgra8); break; } #endif @@ -960,13 +960,13 @@ namespace rsx // PS3 uses the Nvidia VTC memory layout for compressed 3D textures. // This is only supported using Nvidia OpenGL. // Remove the VTC tiling to support ATI and Vulkan. - copy_unmodified_block_vtc::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_unmodified_block_vtc::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } else if (is_3d && !is_po2 && caps.supports_vtc_decoding) { // In this case, hardware expects us to feed it a VTC input, but on PS3 we only have a linear one. // We need to compress the 2D-planar DXT input into a VTC output - copy_linear_block_to_vtc::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_linear_block_to_vtc::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } else if (caps.supports_zero_copy) { @@ -975,7 +975,7 @@ namespace rsx } else { - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), 1, w, h, depth, 0, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), 1, w, h, depth, 0, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } break; } @@ -991,13 +991,13 @@ namespace rsx // PS3 uses the Nvidia VTC memory layout for compressed 3D textures. // This is only supported using Nvidia OpenGL. // Remove the VTC tiling to support ATI and Vulkan. - copy_unmodified_block_vtc::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_unmodified_block_vtc::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } else if (is_3d && !is_po2 && caps.supports_vtc_decoding) { // In this case, hardware expects us to feed it a VTC input, but on PS3 we only have a linear one. // We need to compress the 2D-planar DXT input into a VTC output - copy_linear_block_to_vtc::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_linear_block_to_vtc::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), w, h, depth, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } else if (caps.supports_zero_copy) { @@ -1006,7 +1006,7 @@ namespace rsx } else { - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), 1, w, h, depth, 0, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), 1, w, h, depth, 0, get_row_pitch_in_block(w, caps.alignment), src_layout.pitch_in_block); } break; } @@ -1021,7 +1021,7 @@ namespace rsx { if (is_swizzled) { - copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); + copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); } else if (caps.supports_zero_copy) { @@ -1030,7 +1030,7 @@ namespace rsx } else { - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); } } else @@ -1064,11 +1064,11 @@ namespace rsx } else if (word_size == 2) { - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); } else if (word_size == 4) { - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); } } else @@ -1076,16 +1076,16 @@ namespace rsx if (word_size == 2) { if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); + copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); else - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); } else if (word_size == 4) { if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); + copy_unmodified_block_swizzled::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block); else - copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), utils::bless>(src_layout.data), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); + copy_unmodified_block::copy_mipmap_level(dst_buffer.as_span(), src_layout.data.as_span>(), words_per_block, w, h, depth, src_layout.border, dst_pitch_in_block, src_layout.pitch_in_block); } } } diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index c4cb11b30e..7f99e21eb7 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -189,7 +189,7 @@ namespace rsx struct subresource_layout { - std::span data; + rsx::io_buffer data; u16 width_in_texel; u16 height_in_texel; u16 width_in_block; diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp index 9509894a04..f19908d764 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp @@ -700,7 +700,7 @@ namespace vk subres.width_in_block, subres.height_in_block ); - subres.data = ext_data; + subres.data = std::span(ext_data); } if (g_cfg.video.resolution_scale_percent == 100 && spp == 1) [[likely]] diff --git a/rpcs3/io_buffer.h b/rpcs3/io_buffer.h index 5f4dd32331..945bdc9c90 100644 --- a/rpcs3/io_buffer.h +++ b/rpcs3/io_buffer.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include #include @@ -18,8 +19,8 @@ namespace rsx class io_buffer { - void* m_ptr = nullptr; - usz m_size = 0; + mutable void* m_ptr = nullptr; + mutable usz m_size = 0; std::function ()> m_allocator = nullptr; @@ -27,7 +28,7 @@ namespace rsx io_buffer() = default; template - io_buffer(T& container) + io_buffer(const T& container) { m_ptr = reinterpret_cast(container.data()); m_size = container.size_bytes(); @@ -39,8 +40,18 @@ namespace rsx m_allocator = allocator; } - template - T* data() + template + io_buffer(void* ptr, T size) + : m_ptr(ptr), m_size(size) + {} + + template + io_buffer(const void* ptr, T size) + : m_ptr(const_cast(ptr)), m_size(size) + {} + + template + T* data() const { if (!m_ptr && m_allocator) { @@ -55,11 +66,11 @@ namespace rsx return m_size; } - template - std::span as_span() + template + std::span as_span() const { - const auto bytes = data(); - return { bytes, m_size / sizeof(T) }; + auto bytes = data(); + return { utils::bless(bytes), m_size / sizeof(T) }; } }; }