From a3e6bdd8e4ef77bdc7baf89f959d6726cca6c287 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 20 Jul 2025 19:59:32 +0300 Subject: [PATCH] rsx: Replace use of small vectors with simple_array --- rpcs3/Emu/RSX/Common/reverse_ptr.hpp | 29 +++++++++++++ rpcs3/Emu/RSX/Common/simple_array.hpp | 44 ++++++++++++++++++++ rpcs3/Emu/RSX/Common/surface_store.cpp | 2 +- rpcs3/Emu/RSX/Common/surface_store.h | 28 ++++++------- rpcs3/Emu/RSX/Common/texture_cache.h | 38 ++++++++--------- rpcs3/Emu/RSX/Common/texture_cache_helpers.h | 9 ++-- rpcs3/Emu/RSX/GL/GLTextureCache.cpp | 4 +- rpcs3/Emu/RSX/GL/GLTextureCache.h | 16 +++---- rpcs3/Emu/RSX/VK/VKTextureCache.cpp | 18 ++++---- rpcs3/Emu/RSX/VK/VKTextureCache.h | 18 ++++---- rpcs3/tests/test_simple_array.cpp | 16 +++++++ 11 files changed, 154 insertions(+), 68 deletions(-) create mode 100644 rpcs3/Emu/RSX/Common/reverse_ptr.hpp diff --git a/rpcs3/Emu/RSX/Common/reverse_ptr.hpp b/rpcs3/Emu/RSX/Common/reverse_ptr.hpp new file mode 100644 index 0000000000..18235aad4a --- /dev/null +++ b/rpcs3/Emu/RSX/Common/reverse_ptr.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +namespace rsx +{ + // Generic reverse pointer primitive type for fast reverse iterators + template + class reverse_pointer + { + Ty* ptr = nullptr; + + public: + reverse_pointer() = default; + reverse_pointer(Ty* val) + : ptr(val) + {} + + reverse_pointer& operator++() { ptr--; return *this; } + reverse_pointer operator++(int) { return reverse_pointer(ptr--); } + reverse_pointer& operator--() { ptr++; return *this; } + reverse_pointer operator--(int) { reverse_pointer(ptr++); } + + bool operator == (const reverse_pointer& other) const { return ptr == other.ptr; } + + Ty* operator -> () const { return ptr; } + Ty& operator * () const { return *ptr; } + }; +} diff --git a/rpcs3/Emu/RSX/Common/simple_array.hpp b/rpcs3/Emu/RSX/Common/simple_array.hpp index 033994547d..00bc7602a6 100644 --- a/rpcs3/Emu/RSX/Common/simple_array.hpp +++ b/rpcs3/Emu/RSX/Common/simple_array.hpp @@ -4,6 +4,8 @@ #include #include +#include "reverse_ptr.hpp" + namespace rsx { template @@ -13,6 +15,8 @@ namespace rsx public: using iterator = Ty*; using const_iterator = const Ty*; + using reverse_iterator = reverse_pointer; + using const_reverse_iterator = reverse_pointer; using value_type = Ty; private: @@ -382,6 +386,46 @@ namespace rsx return _data ? _data + _size : nullptr; } + const_iterator cbegin() const + { + return _data; + } + + const_iterator cend() const + { + return _data ? _data + _size : nullptr; + } + + reverse_iterator rbegin() + { + return reverse_iterator(end()); + } + + reverse_iterator rend() + { + return reverse_iterator(begin()); + } + + const_reverse_iterator rbegin() const + { + return const_reverse_iterator(cend()); + } + + const_reverse_iterator rend() const + { + return const_reverse_iterator(cbegin()); + } + + const_reverse_iterator crbegin() const + { + return const_reverse_iterator(cend()); + } + + const_reverse_iterator crend() const + { + return const_reverse_iterator(cbegin()); + } + bool any(std::predicate auto predicate) const { for (auto it = begin(); it != end(); ++it) diff --git a/rpcs3/Emu/RSX/Common/surface_store.cpp b/rpcs3/Emu/RSX/Common/surface_store.cpp index 43f4b4161f..68e8bd9c62 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.cpp +++ b/rpcs3/Emu/RSX/Common/surface_store.cpp @@ -7,7 +7,7 @@ namespace rsx { namespace utility { - std::vector get_rtt_indexes(surface_target color_target) + simple_array get_rtt_indexes(surface_target color_target) { switch (color_target) { diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 4c884c3615..0bccd9fd32 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -14,7 +14,7 @@ namespace rsx { namespace utility { - std::vector get_rtt_indexes(surface_target color_target); + simple_array get_rtt_indexes(surface_target color_target); u8 get_mrt_buffers_count(surface_target color_target); usz get_aligned_pitch(surface_color_format format, u32 width); usz get_packed_pitch(surface_color_format format, u32 width); @@ -245,9 +245,9 @@ namespace rsx void intersect_surface_region(command_list_type cmd, u32 address, surface_type new_surface, surface_type prev_surface) { auto scan_list = [&new_surface, address](const rsx::address_range32& mem_range, - surface_ranged_map& data) -> std::vector> + surface_ranged_map& data) -> rsx::simple_array> { - std::vector> result; + rsx::simple_array> result; for (auto it = data.begin_range(mem_range); it != data.end(); ++it) { auto surface = Traits::get(it->second); @@ -314,7 +314,7 @@ namespace rsx } } - std::vector> surface_info; + simple_array> surface_info; if (list1.empty()) { surface_info = std::move(list2); @@ -629,7 +629,7 @@ namespace rsx invalidated_resources.push_back(std::move(storage)); } - int remove_duplicates_fast_impl(std::vector& sections, const rsx::address_range32& range) + int remove_duplicates_fast_impl(rsx::simple_array& sections, const rsx::address_range32& range) { // Range tests to check for gaps std::list m_ranges; @@ -697,7 +697,7 @@ namespace rsx return removed_count; } - void remove_duplicates_fallback_impl(std::vector& sections, const rsx::address_range32& range) + void remove_duplicates_fallback_impl(rsx::simple_array& sections, const rsx::address_range32& range) { // Originally used to debug crashes but this function breaks often enough that I'll leave the checks in for now. // Safe to remove after some time if no asserts are reported. @@ -866,10 +866,10 @@ namespace rsx std::forward(extra_params)...); } - std::tuple, std::vector> + std::tuple, simple_array> find_overlapping_set(const utils::address_range32& range) const { - std::vector color_result, depth_result; + simple_array color_result, depth_result; utils::address_range32 result_range; if (m_render_targets_memory_range.valid() && @@ -916,8 +916,8 @@ namespace rsx u64 src_offset, dst_offset, write_length; auto block_length = block_range.length(); - auto all_data = std::move(color_data); - all_data.insert(all_data.end(), depth_stencil_data.begin(), depth_stencil_data.end()); + auto& all_data = color_data; + all_data += depth_stencil_data; if (all_data.size() > 1) { @@ -1088,10 +1088,10 @@ namespace rsx } template - std::vector get_merged_texture_memory_region(commandbuffer_type& cmd, u32 texaddr, u32 required_width, u32 required_height, u32 required_pitch, u8 required_bpp, rsx::surface_access access) + rsx::simple_array get_merged_texture_memory_region(commandbuffer_type& cmd, u32 texaddr, u32 required_width, u32 required_height, u32 required_pitch, u8 required_bpp, rsx::surface_access access) { - std::vector result; - std::vector> dirty; + rsx::simple_array result; + rsx::simple_array> dirty; const auto surface_internal_pitch = (required_width * required_bpp); @@ -1236,7 +1236,7 @@ namespace rsx return result; } - void check_for_duplicates(std::vector& sections) + void check_for_duplicates(rsx::simple_array& sections) { utils::address_range32 test_range; for (const auto& section : sections) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 91e41e6179..877600ac18 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -143,7 +143,7 @@ namespace rsx struct deferred_subresource : image_section_attributes_t { image_resource_type external_handle = 0; - std::vector sections_to_copy; + rsx::simple_array sections_to_copy; texture_channel_remap_t remap; deferred_request_command op = deferred_request_command::nop; u32 external_ref_addr = 0; @@ -491,10 +491,10 @@ namespace rsx virtual section_storage_type* create_nul_section(commandbuffer_type&, const address_range32 &rsx_range, const image_section_attributes_t& attrs, const GCM_tile_reference& tile, bool memory_load) = 0; virtual void set_component_order(section_storage_type& section, u32 gcm_format, component_order expected) = 0; virtual void insert_texture_barrier(commandbuffer_type&, image_storage_type* tex, bool strong_ordering = true) = 0; - virtual image_view_type generate_cubemap_from_images(commandbuffer_type&, u32 gcm_format, u16 size, const std::vector& sources, const texture_channel_remap_t& remap_vector) = 0; - virtual image_view_type generate_3d_from_2d_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, u16 depth, const std::vector& sources, const texture_channel_remap_t& remap_vector) = 0; - virtual image_view_type generate_atlas_from_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, const texture_channel_remap_t& remap_vector) = 0; - virtual image_view_type generate_2d_mipmaps_from_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, const texture_channel_remap_t& remap_vector) = 0; + virtual image_view_type generate_cubemap_from_images(commandbuffer_type&, u32 gcm_format, u16 size, const rsx::simple_array& sources, const texture_channel_remap_t& remap_vector) = 0; + virtual image_view_type generate_3d_from_2d_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, u16 depth, const rsx::simple_array& sources, const texture_channel_remap_t& remap_vector) = 0; + virtual image_view_type generate_atlas_from_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, const rsx::simple_array& sections_to_copy, const texture_channel_remap_t& remap_vector) = 0; + virtual image_view_type generate_2d_mipmaps_from_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, const rsx::simple_array& sections_to_copy, const texture_channel_remap_t& remap_vector) = 0; virtual void update_image_contents(commandbuffer_type&, image_view_type dst, image_resource_type src, u16 width, u16 height) = 0; virtual bool render_target_format_is_compatible(image_storage_type* tex, u32 gcm_format) = 0; virtual void prepare_for_dma_transfers(commandbuffer_type&) = 0; @@ -652,7 +652,7 @@ namespace rsx } // Resync any exclusions that do not require flushing - std::vector surfaces_to_inherit; + rsx::simple_array surfaces_to_inherit; for (auto& surface : data.sections_to_exclude) { if (surface->get_context() != texture_upload_context::framebuffer_storage) @@ -1187,9 +1187,9 @@ namespace rsx } template - std::vector find_texture_from_range(const address_range32 &test_range, u32 required_pitch = 0, u32 context_mask = 0xFF) + simple_array find_texture_from_range(const address_range32 &test_range, u32 required_pitch = 0, u32 context_mask = 0xFF) { - std::vector results; + simple_array results; for (auto It = m_storage.range_begin(test_range, full_range, check_unlocked); It != m_storage.range_end(); It++) { @@ -1731,7 +1731,7 @@ namespace rsx } case deferred_request_command::cubemap_unwrap: { - std::vector sections(6); + rsx::simple_array sections(6); for (u16 n = 0; n < 6; ++n) { sections[n] = @@ -1761,7 +1761,7 @@ namespace rsx } case deferred_request_command::_3d_unwrap: { - std::vector sections; + rsx::simple_array sections; sections.resize(desc.depth); for (u16 n = 0; n < desc.depth; ++n) { @@ -1894,8 +1894,8 @@ namespace rsx } } - std::vector overlapping_fbos; - std::vector overlapping_locals; + simple_array overlapping_fbos; + simple_array overlapping_locals; auto fast_fbo_check = [&]() -> sampled_image_descriptor { @@ -1966,14 +1966,10 @@ namespace rsx if (!overlapping_locals.empty()) { // Remove everything that is not a transfer target - overlapping_locals.erase - ( - std::remove_if(overlapping_locals.begin(), overlapping_locals.end(), [](const auto& e) - { - return e->is_dirty() || (e->get_context() != rsx::texture_upload_context::blit_engine_dst); - }), - overlapping_locals.end() - ); + overlapping_locals.erase_if([](const auto& e) + { + return e->is_dirty() || (e->get_context() != rsx::texture_upload_context::blit_engine_dst); + }); } if (!options.prefer_surface_cache) @@ -2411,7 +2407,7 @@ namespace rsx // 1. Only 2D images will invoke this routine // 2. The image has to have been generated on the GPU (fbo or blit target only) - std::vector sections; + rsx::simple_array sections; const bool use_upscaling = (result.upload_context == rsx::texture_upload_context::framebuffer_storage && g_cfg.video.resolution_scale_percent != 100); if (!helpers::append_mipmap_level(sections, result, attributes, 0, use_upscaling, attributes)) [[unlikely]] diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index dfe4cb5ee9..52f6ff5591 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -1,6 +1,7 @@ #pragma once #include "../rsx_utils.h" +#include "simple_array.hpp" #include "TextureUtils.h" namespace rsx @@ -249,9 +250,9 @@ namespace rsx template void gather_texture_slices( commandbuffer_type& cmd, - std::vector& out, + rsx::simple_array& out, const surface_store_list_type& fbos, - const std::vector& local, + const rsx::simple_array& local, const image_section_attributes_t& attr, u16 count, bool /*is_depth*/) { @@ -737,7 +738,7 @@ namespace rsx template sampled_image_descriptor merge_cache_resources( commandbuffer_type& cmd, - const surface_store_list_type& fbos, const std::vector& local, + const surface_store_list_type& fbos, const rsx::simple_array& local, const image_section_attributes_t& attr, const size3f& scale, texture_dimension_extended extended_dimension, @@ -852,7 +853,7 @@ namespace rsx template bool append_mipmap_level( - std::vector& sections, // Destination list + rsx::simple_array& sections, // Destination list const sampled_image_descriptor& level, // Descriptor for the image level being checked const image_section_attributes_t& attr, // Attributes of image level u8 mipmap_level, // Level index diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp index f3103dac5c..c2b0e3c252 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp @@ -158,7 +158,7 @@ namespace gl if (copy) { - std::vector region = + rsx::simple_array region = {{ .src = src, .xform = rsx::surface_transform::coordinate_transform, @@ -183,7 +183,7 @@ namespace gl return dst->get_view(remap); } - void texture_cache::copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const std::vector& sources) const + void texture_cache::copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const rsx::simple_array& sources) const { const auto dst_bpp = dst_image->pitch() / dst_image->width(); const auto dst_aspect = dst_image->aspect(); diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index f3b37e7f27..486087d56a 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -356,7 +356,7 @@ namespace gl baseclass::on_section_resources_destroyed(); } - void sync_surface_memory(const std::vector& surfaces) + void sync_surface_memory(const rsx::simple_array& surfaces) { auto rtt = gl::as_rtt(vram_texture); rtt->sync_tag(); @@ -480,9 +480,9 @@ namespace gl } } - void copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const std::vector& sources) const; + void copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const rsx::simple_array& sources) const; - gl::texture* get_template_from_collection_impl(const std::vector& sections_to_transfer) const + gl::texture* get_template_from_collection_impl(const rsx::simple_array& sections_to_transfer) const { if (sections_to_transfer.size() == 1) [[likely]] { @@ -534,7 +534,7 @@ namespace gl GL_TEXTURE_2D, gcm_format, x, y, w, h, 1, 1, remap_vector, true); } - gl::texture_view* generate_cubemap_from_images(gl::command_context& cmd, u32 gcm_format, u16 size, const std::vector& sources, const rsx::texture_channel_remap_t& remap_vector) override + gl::texture_view* generate_cubemap_from_images(gl::command_context& cmd, u32 gcm_format, u16 size, const rsx::simple_array& sources, const rsx::texture_channel_remap_t& remap_vector) override { auto _template = get_template_from_collection_impl(sources); auto result = create_temporary_subresource_impl(cmd, _template, GL_NONE, GL_TEXTURE_CUBE_MAP, gcm_format, 0, 0, size, size, 1, 1, remap_vector, false); @@ -543,7 +543,7 @@ namespace gl return result; } - gl::texture_view* generate_3d_from_2d_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, u16 depth, const std::vector& sources, const rsx::texture_channel_remap_t& remap_vector) override + gl::texture_view* generate_3d_from_2d_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, u16 depth, const rsx::simple_array& sources, const rsx::texture_channel_remap_t& remap_vector) override { auto _template = get_template_from_collection_impl(sources); auto result = create_temporary_subresource_impl(cmd, _template, GL_NONE, GL_TEXTURE_3D, gcm_format, 0, 0, width, height, depth, 1, remap_vector, false); @@ -552,7 +552,7 @@ namespace gl return result; } - gl::texture_view* generate_atlas_from_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, + gl::texture_view* generate_atlas_from_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override { auto _template = get_template_from_collection_impl(sections_to_copy); @@ -562,7 +562,7 @@ namespace gl return result; } - gl::texture_view* generate_2d_mipmaps_from_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, + gl::texture_view* generate_2d_mipmaps_from_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override { const auto mipmaps = ::narrow(sections_to_copy.size()); @@ -587,7 +587,7 @@ namespace gl void update_image_contents(gl::command_context& cmd, gl::texture_view* dst, gl::texture* src, u16 width, u16 height) override { - std::vector region = + rsx::simple_array region = {{ .src = src, .xform = rsx::surface_transform::identity, diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp index fc1efb3533..45094cf4e3 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp @@ -302,7 +302,7 @@ namespace vk { dma_sync(true); - std::vector copy; + rsx::simple_array copy; copy.reserve(transfer_height); u32 dst_offset = dma_mapping.first; @@ -398,7 +398,7 @@ namespace vk m_cached_memory_size = 0; } - void texture_cache::copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const std::vector& sections_to_transfer) const + void texture_cache::copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const rsx::simple_array& sections_to_transfer) const { const auto dst_aspect = dst->aspect(); const auto dst_bpp = vk::get_format_texel_width(dst->format()); @@ -585,7 +585,7 @@ namespace vk return mapping; } - vk::image* texture_cache::get_template_from_collection_impl(const std::vector& sections_to_transfer) const + vk::image* texture_cache::get_template_from_collection_impl(const rsx::simple_array& sections_to_transfer) const { if (sections_to_transfer.size() == 1) [[likely]] { @@ -714,7 +714,7 @@ namespace vk if (copy) { - std::vector region = + rsx::simple_array region = { { .src = source, .xform = rsx::surface_transform::coordinate_transform, @@ -750,7 +750,7 @@ namespace vk } vk::image_view* texture_cache::generate_cubemap_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 size, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) { auto _template = get_template_from_collection_impl(sections_to_copy); auto result = create_temporary_subresource_view_impl(cmd, _template, VK_IMAGE_TYPE_2D, @@ -785,7 +785,7 @@ namespace vk } vk::image_view* texture_cache::generate_3d_from_2d_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, u16 depth, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) { auto _template = get_template_from_collection_impl(sections_to_copy); auto result = create_temporary_subresource_view_impl(cmd, _template, VK_IMAGE_TYPE_3D, @@ -820,7 +820,7 @@ namespace vk } vk::image_view* texture_cache::generate_atlas_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) { auto _template = get_template_from_collection_impl(sections_to_copy); auto result = create_temporary_subresource_view_impl(cmd, _template, VK_IMAGE_TYPE_2D, @@ -858,7 +858,7 @@ namespace vk } vk::image_view* texture_cache::generate_2d_mipmaps_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) { const auto mipmaps = ::narrow(sections_to_copy.size()); auto _template = get_template_from_collection_impl(sections_to_copy); @@ -905,7 +905,7 @@ namespace vk void texture_cache::update_image_contents(vk::command_buffer& cmd, vk::image_view* dst_view, vk::image* src, u16 width, u16 height) { - std::vector region = + rsx::simple_array region = { { .src = src, .xform = rsx::surface_transform::identity, diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index 8bbd131fe5..786eb51270 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -301,7 +301,7 @@ namespace vk if (const auto tiled_region = rsx::get_current_renderer()->get_tiled_memory_region(range)) { auto real_data = vm::get_super_ptr(range.start); - auto out_data = std::vector(tiled_region.tile->size); + auto out_data = rsx::simple_array(tiled_region.tile->size); rsx::tile_texel_data( out_data.data(), real_data, @@ -325,7 +325,7 @@ namespace vk // Read-modify-write to avoid corrupting already resident memory outside texture region void* data = get_ptr(range.start); - std::vector tmp_data(rsx_pitch * height); + rsx::simple_array tmp_data(rsx_pitch * height); std::memcpy(tmp_data.data(), data, tmp_data.size()); switch (gcm_format) @@ -366,7 +366,7 @@ namespace vk rsx_pitch = pitch; } - void sync_surface_memory(const std::vector& surfaces) + void sync_surface_memory(const rsx::simple_array& surfaces) { auto rtt = vk::as_rtt(vram_texture); rtt->sync_tag(); @@ -445,9 +445,9 @@ namespace vk VkComponentMapping apply_component_mapping_flags(u32 gcm_format, rsx::component_order flags, const rsx::texture_channel_remap_t& remap_vector) const; - void copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const std::vector& sections_to_transfer) const; + void copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const rsx::simple_array& sections_to_transfer) const; - vk::image* get_template_from_collection_impl(const std::vector& sections_to_transfer) const; + vk::image* get_template_from_collection_impl(const rsx::simple_array& sections_to_transfer) const; std::unique_ptr find_cached_image(VkFormat format, u16 w, u16 h, u16 d, u16 mipmaps, VkImageType type, VkImageCreateFlags create_flags, VkImageUsageFlags usage, VkSharingMode sharing); @@ -462,16 +462,16 @@ namespace vk u16 x, u16 y, u16 w, u16 h, const rsx::texture_channel_remap_t& remap_vector) override; vk::image_view* generate_cubemap_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 size, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; vk::image_view* generate_3d_from_2d_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, u16 depth, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; vk::image_view* generate_atlas_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; vk::image_view* generate_2d_mipmaps_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, - const std::vector& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; + const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override; void release_temporary_subresource(vk::image_view* view) override; diff --git a/rpcs3/tests/test_simple_array.cpp b/rpcs3/tests/test_simple_array.cpp index 916284a6cd..d101dd0a0b 100644 --- a/rpcs3/tests/test_simple_array.cpp +++ b/rpcs3/tests/test_simple_array.cpp @@ -214,4 +214,20 @@ namespace rsx EXPECT_EQ(arr[i], i + 1); } } + + TEST(SimpleArray, ReverseIterator) + { + rsx::simple_array arr{ 1, 2, 3, 4, 5 }; + rsx::simple_array arr2{ 5, 4, 3, 2, 1 }; + + int rindex = 0; + int sum = 0; + for (auto it = arr.rbegin(); it != arr.rend(); ++it, ++rindex) + { + EXPECT_EQ(*it, arr2[rindex]); + sum += *it; + } + + EXPECT_EQ(sum, 15); + } }