mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-16 04:09:07 +00:00
rsx: Replace use of small vectors with simple_array
This commit is contained in:
parent
ecc0fe4678
commit
a3e6bdd8e4
29
rpcs3/Emu/RSX/Common/reverse_ptr.hpp
Normal file
29
rpcs3/Emu/RSX/Common/reverse_ptr.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <util/types.hpp>
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
// Generic reverse pointer primitive type for fast reverse iterators
|
||||
template <typename Ty>
|
||||
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; }
|
||||
};
|
||||
}
|
||||
@ -4,6 +4,8 @@
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
|
||||
#include "reverse_ptr.hpp"
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
template <typename Ty>
|
||||
@ -13,6 +15,8 @@ namespace rsx
|
||||
public:
|
||||
using iterator = Ty*;
|
||||
using const_iterator = const Ty*;
|
||||
using reverse_iterator = reverse_pointer<Ty>;
|
||||
using const_reverse_iterator = reverse_pointer<const Ty>;
|
||||
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<const Ty&> auto predicate) const
|
||||
{
|
||||
for (auto it = begin(); it != end(); ++it)
|
||||
|
||||
@ -7,7 +7,7 @@ namespace rsx
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
std::vector<u8> get_rtt_indexes(surface_target color_target)
|
||||
simple_array<u8> get_rtt_indexes(surface_target color_target)
|
||||
{
|
||||
switch (color_target)
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ namespace rsx
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
std::vector<u8> get_rtt_indexes(surface_target color_target);
|
||||
simple_array<u8> 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<std::pair<u32, surface_type>>
|
||||
surface_ranged_map& data) -> rsx::simple_array<std::pair<u32, surface_type>>
|
||||
{
|
||||
std::vector<std::pair<u32, surface_type>> result;
|
||||
rsx::simple_array<std::pair<u32, surface_type>> 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<std::pair<u32, surface_type>> surface_info;
|
||||
simple_array<std::pair<u32, surface_type>> 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<surface_overlap_info>& sections, const rsx::address_range32& range)
|
||||
int remove_duplicates_fast_impl(rsx::simple_array<surface_overlap_info>& sections, const rsx::address_range32& range)
|
||||
{
|
||||
// Range tests to check for gaps
|
||||
std::list<utils::address_range32> m_ranges;
|
||||
@ -697,7 +697,7 @@ namespace rsx
|
||||
return removed_count;
|
||||
}
|
||||
|
||||
void remove_duplicates_fallback_impl(std::vector<surface_overlap_info>& sections, const rsx::address_range32& range)
|
||||
void remove_duplicates_fallback_impl(rsx::simple_array<surface_overlap_info>& 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<Args>(extra_params)...);
|
||||
}
|
||||
|
||||
std::tuple<std::vector<surface_type>, std::vector<surface_type>>
|
||||
std::tuple<simple_array<surface_type>, simple_array<surface_type>>
|
||||
find_overlapping_set(const utils::address_range32& range) const
|
||||
{
|
||||
std::vector<surface_type> color_result, depth_result;
|
||||
simple_array<surface_type> 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 <typename commandbuffer_type>
|
||||
std::vector<surface_overlap_info> 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<surface_overlap_info> 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<surface_overlap_info> result;
|
||||
std::vector<std::pair<u32, bool>> dirty;
|
||||
rsx::simple_array<surface_overlap_info> result;
|
||||
rsx::simple_array<std::pair<u32, bool>> dirty;
|
||||
|
||||
const auto surface_internal_pitch = (required_width * required_bpp);
|
||||
|
||||
@ -1236,7 +1236,7 @@ namespace rsx
|
||||
return result;
|
||||
}
|
||||
|
||||
void check_for_duplicates(std::vector<surface_overlap_info>& sections)
|
||||
void check_for_duplicates(rsx::simple_array<surface_overlap_info>& sections)
|
||||
{
|
||||
utils::address_range32 test_range;
|
||||
for (const auto& section : sections)
|
||||
|
||||
@ -143,7 +143,7 @@ namespace rsx
|
||||
struct deferred_subresource : image_section_attributes_t
|
||||
{
|
||||
image_resource_type external_handle = 0;
|
||||
std::vector<copy_region_descriptor> sections_to_copy;
|
||||
rsx::simple_array<copy_region_descriptor> 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<section_storage_type*> surfaces_to_inherit;
|
||||
rsx::simple_array<section_storage_type*> 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 <bool check_unlocked = false>
|
||||
std::vector<section_storage_type*> find_texture_from_range(const address_range32 &test_range, u32 required_pitch = 0, u32 context_mask = 0xFF)
|
||||
simple_array<section_storage_type*> find_texture_from_range(const address_range32 &test_range, u32 required_pitch = 0, u32 context_mask = 0xFF)
|
||||
{
|
||||
std::vector<section_storage_type*> results;
|
||||
simple_array<section_storage_type*> 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<copy_region_descriptor> sections(6);
|
||||
rsx::simple_array<copy_region_descriptor> 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<copy_region_descriptor> sections;
|
||||
rsx::simple_array<copy_region_descriptor> sections;
|
||||
sections.resize(desc.depth);
|
||||
for (u16 n = 0; n < desc.depth; ++n)
|
||||
{
|
||||
@ -1894,8 +1894,8 @@ namespace rsx
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<typename SurfaceStoreType::surface_overlap_info> overlapping_fbos;
|
||||
std::vector<section_storage_type*> overlapping_locals;
|
||||
simple_array<typename SurfaceStoreType::surface_overlap_info> overlapping_fbos;
|
||||
simple_array<section_storage_type*> 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)
|
||||
overlapping_locals.erase_if([](const auto& e)
|
||||
{
|
||||
return e->is_dirty() || (e->get_context() != rsx::texture_upload_context::blit_engine_dst);
|
||||
}),
|
||||
overlapping_locals.end()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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<copy_region_descriptor> sections;
|
||||
rsx::simple_array<copy_region_descriptor> 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]]
|
||||
|
||||
@ -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<typename commandbuffer_type, typename section_storage_type, typename copy_region_type, typename surface_store_list_type>
|
||||
void gather_texture_slices(
|
||||
commandbuffer_type& cmd,
|
||||
std::vector<copy_region_type>& out,
|
||||
rsx::simple_array<copy_region_type>& out,
|
||||
const surface_store_list_type& fbos,
|
||||
const std::vector<section_storage_type*>& local,
|
||||
const rsx::simple_array<section_storage_type*>& local,
|
||||
const image_section_attributes_t& attr,
|
||||
u16 count, bool /*is_depth*/)
|
||||
{
|
||||
@ -737,7 +738,7 @@ namespace rsx
|
||||
template <typename sampled_image_descriptor, typename commandbuffer_type, typename surface_store_list_type, typename section_storage_type>
|
||||
sampled_image_descriptor merge_cache_resources(
|
||||
commandbuffer_type& cmd,
|
||||
const surface_store_list_type& fbos, const std::vector<section_storage_type*>& local,
|
||||
const surface_store_list_type& fbos, const rsx::simple_array<section_storage_type*>& local,
|
||||
const image_section_attributes_t& attr,
|
||||
const size3f& scale,
|
||||
texture_dimension_extended extended_dimension,
|
||||
@ -852,7 +853,7 @@ namespace rsx
|
||||
|
||||
template<typename sampled_image_descriptor, typename copy_region_descriptor_type>
|
||||
bool append_mipmap_level(
|
||||
std::vector<copy_region_descriptor_type>& sections, // Destination list
|
||||
rsx::simple_array<copy_region_descriptor_type>& 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
|
||||
|
||||
@ -158,7 +158,7 @@ namespace gl
|
||||
|
||||
if (copy)
|
||||
{
|
||||
std::vector<copy_region_descriptor> region =
|
||||
rsx::simple_array<copy_region_descriptor> 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<copy_region_descriptor>& sources) const
|
||||
void texture_cache::copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const rsx::simple_array<copy_region_descriptor>& sources) const
|
||||
{
|
||||
const auto dst_bpp = dst_image->pitch() / dst_image->width();
|
||||
const auto dst_aspect = dst_image->aspect();
|
||||
|
||||
@ -356,7 +356,7 @@ namespace gl
|
||||
baseclass::on_section_resources_destroyed();
|
||||
}
|
||||
|
||||
void sync_surface_memory(const std::vector<cached_texture_section*>& surfaces)
|
||||
void sync_surface_memory(const rsx::simple_array<cached_texture_section*>& 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<copy_region_descriptor>& sources) const;
|
||||
void copy_transfer_regions_impl(gl::command_context& cmd, gl::texture* dst_image, const rsx::simple_array<copy_region_descriptor>& sources) const;
|
||||
|
||||
gl::texture* get_template_from_collection_impl(const std::vector<copy_region_descriptor>& sections_to_transfer) const
|
||||
gl::texture* get_template_from_collection_impl(const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy,
|
||||
const rsx::texture_channel_remap_t& remap_vector) override
|
||||
{
|
||||
const auto mipmaps = ::narrow<u8>(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<copy_region_descriptor> region =
|
||||
rsx::simple_array<copy_region_descriptor> region =
|
||||
{{
|
||||
.src = src,
|
||||
.xform = rsx::surface_transform::identity,
|
||||
|
||||
@ -302,7 +302,7 @@ namespace vk
|
||||
{
|
||||
dma_sync(true);
|
||||
|
||||
std::vector<VkBufferCopy> copy;
|
||||
rsx::simple_array<VkBufferCopy> 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<copy_region_descriptor>& sections_to_transfer) const
|
||||
void texture_cache::copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_transfer) const
|
||||
vk::image* texture_cache::get_template_from_collection_impl(const rsx::simple_array<copy_region_descriptor>& sections_to_transfer) const
|
||||
{
|
||||
if (sections_to_transfer.size() == 1) [[likely]]
|
||||
{
|
||||
@ -714,7 +714,7 @@ namespace vk
|
||||
|
||||
if (copy)
|
||||
{
|
||||
std::vector<copy_region_descriptor> region =
|
||||
rsx::simple_array<copy_region_descriptor> 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector)
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector)
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector)
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector)
|
||||
const rsx::simple_array<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector)
|
||||
{
|
||||
const auto mipmaps = ::narrow<u8>(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<copy_region_descriptor> region =
|
||||
rsx::simple_array<copy_region_descriptor> region =
|
||||
{ {
|
||||
.src = src,
|
||||
.xform = rsx::surface_transform::identity,
|
||||
|
||||
@ -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<u8>(range.start);
|
||||
auto out_data = std::vector<u8>(tiled_region.tile->size);
|
||||
auto out_data = rsx::simple_array<u8>(tiled_region.tile->size);
|
||||
rsx::tile_texel_data<u32>(
|
||||
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<u8> tmp_data(rsx_pitch * height);
|
||||
rsx::simple_array<u8> 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<cached_texture_section*>& surfaces)
|
||||
void sync_surface_memory(const rsx::simple_array<cached_texture_section*>& 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<copy_region_descriptor>& sections_to_transfer) const;
|
||||
void copy_transfer_regions_impl(vk::command_buffer& cmd, vk::image* dst, const rsx::simple_array<copy_region_descriptor>& sections_to_transfer) const;
|
||||
|
||||
vk::image* get_template_from_collection_impl(const std::vector<copy_region_descriptor>& sections_to_transfer) const;
|
||||
vk::image* get_template_from_collection_impl(const rsx::simple_array<copy_region_descriptor>& sections_to_transfer) const;
|
||||
|
||||
std::unique_ptr<vk::viewable_image> 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override;
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override;
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override;
|
||||
const rsx::simple_array<copy_region_descriptor>& 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<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override;
|
||||
const rsx::simple_array<copy_region_descriptor>& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) override;
|
||||
|
||||
void release_temporary_subresource(vk::image_view* view) override;
|
||||
|
||||
|
||||
@ -214,4 +214,20 @@ namespace rsx
|
||||
EXPECT_EQ(arr[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SimpleArray, ReverseIterator)
|
||||
{
|
||||
rsx::simple_array<int> arr{ 1, 2, 3, 4, 5 };
|
||||
rsx::simple_array<int> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user