diff --git a/3rdparty/GSL b/3rdparty/GSL index fc5fce4f4f..2b8d20425e 160000 --- a/3rdparty/GSL +++ b/3rdparty/GSL @@ -1 +1 @@ -Subproject commit fc5fce4f4f8d64fbda523d1b0d55115f5ca68774 +Subproject commit 2b8d20425e990c5a3e9a0158e2cedacbcdf9e522 diff --git a/Utilities/GSL.h b/Utilities/GSL.h index 6d4df0873f..1ca9d77f92 100644 --- a/Utilities/GSL.h +++ b/Utilities/GSL.h @@ -4,7 +4,7 @@ #pragma push_macro("new") #undef new -#include +#include #pragma pop_macro("new") #undef Expects #undef Ensures diff --git a/rpcs3-tests/ps3-rsx-common.cpp b/rpcs3-tests/ps3-rsx-common.cpp index 960bef8ff0..c1246a7861 100644 --- a/rpcs3-tests/ps3-rsx-common.cpp +++ b/rpcs3-tests/ps3-rsx-common.cpp @@ -10,6 +10,6 @@ TEST_CLASS(rsx_common) std::vector dest_buffer(2200); std::vector src_buffer(100000); // Big enough - write_vertex_array_data_to_buffer(gsl::span(dest_buffer), src_buffer.data(), 0, 550, rsx::vertex_base_type::ub256, 4, 20, 4); + write_vertex_array_data_to_buffer(gsl::multi_span(dest_buffer), src_buffer.data(), 0, 550, rsx::vertex_base_type::ub256, 4, 20, 4); } }; diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index a653e182a4..26be4b64e1 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -9,7 +9,7 @@ namespace // FIXME: GSL as_span break build if template parameter is non const with current revision. // Replace with true as_span when fixed. template - gsl::span as_span_workaround(gsl::span unformated_span) + gsl::multi_span as_span_workaround(gsl::multi_span unformated_span) { return{ (T*)unformated_span.data(), ::narrow(unformated_span.size_bytes() / sizeof(T)) }; } @@ -360,7 +360,7 @@ namespace } } -void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride) +void write_vertex_array_data_to_buffer(gsl::multi_span raw_dst_span, gsl::multi_span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride) { verify(HERE), (vector_element_count > 0); const u32 src_read_stride = rsx::get_vertex_type_size_on_host(type, vector_element_count); @@ -435,7 +435,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::s } case rsx::vertex_base_type::cmp: { - gsl::span dst_span = as_span_workaround(raw_dst_span); + gsl::multi_span dst_span = as_span_workaround(raw_dst_span); for (u32 i = 0; i < count; ++i) { be_t src_value; @@ -456,7 +456,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::s namespace { template -std::tuple upload_untouched(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index) +std::tuple upload_untouched(gsl::multi_span> src, gsl::multi_span dst, bool is_primitive_restart_enabled, T primitive_restart_index) { T min_index = -1; T max_index = 0; @@ -483,7 +483,7 @@ std::tuple upload_untouched(gsl::span> src, gsl::span // FIXME: expanded primitive type may not support primitive restart correctly template -std::tuple expand_indexed_triangle_fan(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index) +std::tuple expand_indexed_triangle_fan(gsl::multi_span> src, gsl::multi_span dst, bool is_primitive_restart_enabled, T primitive_restart_index) { T min_index = -1; T max_index = 0; @@ -500,7 +500,7 @@ std::tuple expand_indexed_triangle_fan(gsl::span> src, gs size_t dst_idx = 0; while (src.size() > 2) { - gsl::span> tri_indexes = src.subspan(0, 2); + gsl::multi_span> tri_indexes = src.subspan(0, 2); T index1 = tri_indexes[0]; if (is_primitive_restart_enabled && index1 == primitive_restart_index) { @@ -533,7 +533,7 @@ std::tuple expand_indexed_triangle_fan(gsl::span> src, gs // FIXME: expanded primitive type may not support primitive restart correctly template -std::tuple expand_indexed_quads(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index) +std::tuple expand_indexed_quads(gsl::multi_span> src, gsl::multi_span dst, bool is_primitive_restart_enabled, T primitive_restart_index) { T min_index = -1; T max_index = 0; @@ -543,7 +543,7 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl::span size_t dst_idx = 0; while (!src.empty()) { - gsl::span> quad_indexes = src.subspan(0, 4); + gsl::multi_span> quad_indexes = src.subspan(0, 4); T index0 = quad_indexes[0]; if (is_primitive_restart_enabled && index0 == primitive_restart_index) { @@ -714,8 +714,8 @@ namespace // TODO: Unify indexed and non indexed primitive expansion ? template - std::tuple write_index_array_data_to_buffer_impl(gsl::span dst, - gsl::span> src, + std::tuple write_index_array_data_to_buffer_impl(gsl::multi_span dst, + gsl::multi_span> src, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, std::function expands) { @@ -743,8 +743,8 @@ namespace } } -std::tuple write_index_array_data_to_buffer(gsl::span dst, - gsl::span src, +std::tuple write_index_array_data_to_buffer(gsl::multi_span dst, + gsl::multi_span src, rsx::index_array_type type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, std::function expands) { @@ -752,10 +752,10 @@ std::tuple write_index_array_data_to_buffer(gsl::span dst, { case rsx::index_array_type::u16: return write_index_array_data_to_buffer_impl(as_span_workaround(dst), - gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); + gsl::as_multi_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); case rsx::index_array_type::u32: return write_index_array_data_to_buffer_impl(as_span_workaround(dst), - gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); + gsl::as_multi_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); } fmt::throw_exception("Unknown index type" HERE); } diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 0bcf7bd4b8..c514ac7122 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include @@ -10,7 +10,7 @@ * Write count vertex attributes from src_ptr. * src_ptr array layout is deduced from the type, vector element count and src_stride arguments. */ -void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride); +void write_vertex_array_data_to_buffer(gsl::multi_span raw_dst_multi_span, gsl::multi_span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride); /* * If primitive mode is not supported and need to be emulated (using an index buffer) returns false. @@ -32,7 +32,7 @@ u32 get_index_type_size(rsx::index_array_type type); * Returns min/max index found during the process. * The function expands index buffer for non native primitive type if expands(draw_mode) return true. */ -std::tuple write_index_array_data_to_buffer(gsl::span dst, gsl::span src, +std::tuple write_index_array_data_to_buffer(gsl::multi_span dst, gsl::multi_span src, rsx::index_array_type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, std::function expands); diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index b3cb6562a3..4386407016 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -296,7 +296,7 @@ public: return 0; } - void fill_fragment_constants_buffer(gsl::span dst_buffer, const RSXFragmentProgram &fragment_program) const + void fill_fragment_constants_buffer(gsl::multi_span dst_buffer, const RSXFragmentProgram &fragment_program) const { const auto I = m_fragment_shader_cache.find(fragment_program); if (I == m_fragment_shader_cache.end()) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 3301cb45bf..df40afb99a 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/Memory/vm.h" #include "TextureUtils.h" #include "../RSXThread.h" @@ -7,18 +7,18 @@ namespace { - // FIXME: GSL as_span break build if template parameter is non const with current revision. - // Replace with true as_span when fixed. + // FIXME: GSL as_multi_span break build if template parameter is non const with current revision. + // Replace with true as_multi_span when fixed. template - gsl::span as_span_workaround(gsl::span unformated_span) + gsl::multi_span as_multi_span_workaround(gsl::multi_span unformated_multi_span) { - return{ (T*)unformated_span.data(), ::narrow(unformated_span.size_bytes() / sizeof(T)) }; + return{ (T*)unformated_multi_span.data(), ::narrow(unformated_multi_span.size_bytes() / sizeof(T)) }; } // TODO: Make this function part of GSL // Note: Doesn't handle overlapping range detection. template - constexpr void copy(gsl::span dst, gsl::span src) + constexpr void copy(gsl::multi_span dst, gsl::multi_span src) { static_assert(std::is_convertible::value, "Cannot convert source and destination span type."); verify(HERE), (dst.size() == src.size()); @@ -28,7 +28,7 @@ namespace struct copy_unmodified_block { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block, u32 src_pitch_in_block) + static void copy_mipmap_level(gsl::multi_span dst, gsl::multi_span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block, u32 src_pitch_in_block) { size_t row_element_count = dst_pitch_in_block; static_assert(sizeof(T) == sizeof(U), "Type size doesn't match."); @@ -40,13 +40,13 @@ struct copy_unmodified_block struct copy_unmodified_block_swizzled { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block) + static void copy_mipmap_level(gsl::multi_span dst, gsl::multi_span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block) { std::unique_ptr temp_swizzled(new U[width_in_block * row_count]); for (int d = 0; d < depth; ++d) { rsx::convert_linear_swizzle((void*)src.subspan(d * width_in_block * row_count).data(), temp_swizzled.get(), width_in_block, row_count, true); - gsl::span swizzled_src{ temp_swizzled.get(), ::narrow(width_in_block * row_count) }; + gsl::multi_span swizzled_src{ temp_swizzled.get(), ::narrow(width_in_block * row_count) }; for (int row = 0; row < row_count; ++row) copy(dst.subspan((row + d * row_count) * dst_pitch_in_block, width_in_block), swizzled_src.subspan(row * width_in_block, width_in_block)); } @@ -96,7 +96,7 @@ namespace u32 src_pitch_in_block = padded_row ? suggested_pitch_in_bytes / block_size_in_bytes : miplevel_width_in_block; current_subresource_layout.pitch_in_bytes = src_pitch_in_block; - current_subresource_layout.data = gsl::span(texture_data_pointer + offset_in_src, src_pitch_in_block * block_size_in_bytes * miplevel_height_in_block * depth); + current_subresource_layout.data = gsl::multi_span(texture_data_pointer + offset_in_src, src_pitch_in_block * block_size_in_bytes * miplevel_height_in_block * depth); result.push_back(current_subresource_layout); offset_in_src += miplevel_height_in_block * src_pitch_in_block * block_size_in_bytes * depth; @@ -199,7 +199,7 @@ std::vector get_subresources_layout(const rsx::vertex_te return get_subresources_layout_impl(texture); } -void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of) +void upload_texture_subresource(gsl::multi_span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of) { u16 w = src_layout.width_in_block; u16 h = src_layout.height_in_block; @@ -215,9 +215,9 @@ void upload_texture_subresource(gsl::span dst_buffer, const rsx_subre case CELL_GCM_TEXTURE_B8: { if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; } @@ -237,9 +237,9 @@ void upload_texture_subresource(gsl::span dst_buffer, const rsx_subre case CELL_GCM_TEXTURE_X16: { if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; } @@ -249,33 +249,33 @@ void upload_texture_subresource(gsl::span dst_buffer, const rsx_subre case CELL_GCM_TEXTURE_D8R8G8B8: { if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; } case CELL_GCM_TEXTURE_Y16_X16: case CELL_GCM_TEXTURE_Y16_X16_FLOAT: case CELL_GCM_TEXTURE_X32_FLOAT: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_COMPRESSED_DXT1: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_COMPRESSED_DXT23: case CELL_GCM_TEXTURE_COMPRESSED_DXT45: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_multi_span_workaround(dst_buffer), gsl::as_multi_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; default: diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index ca44dd7afb..ca40e72468 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -7,7 +7,7 @@ struct rsx_subresource_layout { - gsl::span data; + gsl::multi_span data; u16 width_in_block; u16 height_in_block; u16 depth; @@ -29,7 +29,7 @@ size_t get_placed_texture_storage_size(const rsx::vertex_texture &texture, size_ std::vector get_subresources_layout(const rsx::fragment_texture &texture); std::vector get_subresources_layout(const rsx::vertex_texture &texture); -void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of); +void upload_texture_subresource(gsl::multi_span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of); u8 get_format_block_size_in_bytes(int format); u8 get_format_block_size_in_texel(int format); diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 2090e7f093..f8910839a7 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "Utilities/GSL.h" #include "../GCM.h" @@ -81,14 +81,14 @@ namespace rsx * that generates command to download the given surface to some mappable buffer. * - a member function static issue_depth_download_command that does the same for depth surface * - a member function static issue_stencil_download_command that does the same for stencil surface - * - a member function gsl::span map_downloaded_buffer(download_buffer_object, ...) that maps a download_buffer_object + * - a member function gsl::multi_span map_downloaded_buffer(download_buffer_object, ...) that maps a download_buffer_object * - a member function static unmap_downloaded_buffer that unmaps it. */ template struct surface_store { template - void copy_pitched_src_to_dst(gsl::span dest, gsl::span src, size_t src_pitch_in_bytes, size_t width, size_t height) + void copy_pitched_src_to_dst(gsl::multi_span dest, gsl::multi_span src, size_t src_pitch_in_bytes, size_t width, size_t height) { for (int row = 0; row < height; row++) { @@ -363,7 +363,7 @@ namespace rsx if (std::get<0>(m_bound_render_targets[i]) == 0) continue; - gsl::span raw_src = Traits::map_downloaded_buffer(download_data[i], std::forward(args)...); + gsl::multi_span raw_src = Traits::map_downloaded_buffer(download_data[i], std::forward(args)...); size_t src_pitch = utility::get_aligned_pitch(color_format, ::narrow(width)); size_t dst_pitch = utility::get_packed_pitch(color_format, ::narrow(width)); @@ -382,14 +382,14 @@ namespace rsx case surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x32: { - gsl::span> dst_span{ (be_t*)result[i].data(), ::narrow(dst_pitch * height / sizeof(be_t)) }; - copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); + gsl::multi_span> dst_multi_span{ (be_t*)result[i].data(), ::narrow(dst_pitch * height / sizeof(be_t)) }; + copy_pitched_src_to_dst(dst_multi_span, gsl::as_multi_span(raw_src), src_pitch, width, height); break; } case surface_color_format::b8: { - gsl::span dst_span{ (u8*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u8)) }; - copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); + gsl::multi_span dst_multi_span{ (u8*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u8)) }; + copy_pitched_src_to_dst(dst_multi_span, gsl::as_multi_span(raw_src), src_pitch, width, height); break; } case surface_color_format::g8b8: @@ -397,21 +397,21 @@ namespace rsx case surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5: { - gsl::span> dst_span{ (be_t*)result[i].data(), ::narrow(dst_pitch * height / sizeof(be_t)) }; - copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); + gsl::multi_span> dst_multi_span{ (be_t*)result[i].data(), ::narrow(dst_pitch * height / sizeof(be_t)) }; + copy_pitched_src_to_dst(dst_multi_span, gsl::as_multi_span(raw_src), src_pitch, width, height); break; } // Note : may require some big endian swap case surface_color_format::w32z32y32x32: { - gsl::span dst_span{ (u128*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u128)) }; - copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); + gsl::multi_span dst_multi_span{ (u128*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u128)) }; + copy_pitched_src_to_dst(dst_multi_span, gsl::as_multi_span(raw_src), src_pitch, width, height); break; } case surface_color_format::w16z16y16x16: { - gsl::span dst_span{ (u64*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u64)) }; - copy_pitched_src_to_dst(dst_span, gsl::as_span(raw_src), src_pitch, width, height); + gsl::multi_span dst_multi_span{ (u64*)result[i].data(), ::narrow(dst_pitch * height / sizeof(u64)) }; + copy_pitched_src_to_dst(dst_multi_span, gsl::as_multi_span(raw_src), src_pitch, width, height); break; } @@ -440,28 +440,28 @@ namespace rsx if (depth_format == surface_depth_format::z24s8) stencil_data = std::move(Traits::issue_stencil_download_command(std::get<1>(m_bound_depth_stencil), width, height, std::forward(args)...)); - gsl::span depth_buffer_raw_src = Traits::map_downloaded_buffer(depth_data, std::forward(args)...); + gsl::multi_span depth_buffer_raw_src = Traits::map_downloaded_buffer(depth_data, std::forward(args)...); if (depth_format == surface_depth_format::z16) { result[0].resize(width * height * 2); - gsl::span dest{ (u16*)result[0].data(), ::narrow(width * height) }; - copy_pitched_src_to_dst(dest, gsl::as_span(depth_buffer_raw_src), row_pitch, width, height); + gsl::multi_span dest{ (u16*)result[0].data(), ::narrow(width * height) }; + copy_pitched_src_to_dst(dest, gsl::as_multi_span(depth_buffer_raw_src), row_pitch, width, height); } if (depth_format == surface_depth_format::z24s8) { result[0].resize(width * height * 4); - gsl::span dest{ (u32*)result[0].data(), ::narrow(width * height) }; - copy_pitched_src_to_dst(dest, gsl::as_span(depth_buffer_raw_src), row_pitch, width, height); + gsl::multi_span dest{ (u32*)result[0].data(), ::narrow(width * height) }; + copy_pitched_src_to_dst(dest, gsl::as_multi_span(depth_buffer_raw_src), row_pitch, width, height); } Traits::unmap_downloaded_buffer(depth_data, std::forward(args)...); if (depth_format == surface_depth_format::z16) return result; - gsl::span stencil_buffer_raw_src = Traits::map_downloaded_buffer(stencil_data, std::forward(args)...); + gsl::multi_span stencil_buffer_raw_src = Traits::map_downloaded_buffer(stencil_data, std::forward(args)...); result[1].resize(width * height); - gsl::span dest{ (u8*)result[1].data(), ::narrow(width * height) }; - copy_pitched_src_to_dst(dest, gsl::as_span(stencil_buffer_raw_src), align(width, 256), width, height); + gsl::multi_span dest{ (u8*)result[1].data(), ::narrow(width * height) }; + copy_pitched_src_to_dst(dest, gsl::as_multi_span(stencil_buffer_raw_src), align(width, 256), width, height); Traits::unmap_downloaded_buffer(stencil_data, std::forward(args)...); return result; } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp index 8ee853cd1d..da5e3e9612 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp @@ -1,4 +1,4 @@ -#ifdef _MSC_VER +#ifdef _MSC_VER #include "stdafx.h" #include "stdafx_d3d12.h" @@ -165,7 +165,7 @@ namespace void* mapped_buffer = m_buffer_data.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); - gsl::span mapped_buffer_span = { + gsl::multi_span mapped_buffer_span = { (gsl::byte*)mapped_buffer, gsl::narrow_cast(buffer_size)}; write_vertex_array_data_to_buffer(mapped_buffer_span, vertex_array.data, vertex_count, vertex_array.type, vertex_array.attribute_size, vertex_array.stride, element_size); @@ -284,8 +284,8 @@ namespace } std::tuple, size_t> upload_inlined_vertex_array( - gsl::span vertex_attribute_infos, - gsl::span inlined_array_raw_data, d3d12_data_heap& ring_buffer_data, + gsl::multi_span vertex_attribute_infos, + gsl::multi_span inlined_array_raw_data, d3d12_data_heap& ring_buffer_data, ID3D12Resource* vertex_buffer_placement, ID3D12GraphicsCommandList* command_list) { // We can't rely on vertex_attribute_infos strides here so compute it @@ -320,7 +320,7 @@ namespace void* mapped_buffer = ring_buffer_data.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); - gsl::span dst = {(gsl::byte*)mapped_buffer, buffer_size}; + gsl::multi_span dst = {(gsl::byte*)mapped_buffer, buffer_size}; for (u32 i = 0; i < element_count; i++) { auto subdst = dst.subspan(i * element_size, element_size); @@ -407,7 +407,7 @@ namespace void* mapped_buffer = m_buffer_data.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); u32 min_index, max_index; - gsl::span dst{ + gsl::multi_span dst{ reinterpret_cast(mapped_buffer), ::narrow(buffer_size)}; std::tie(min_index, max_index) = diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h index 6b1da86704..eecb0af360 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h @@ -256,7 +256,7 @@ struct render_target_traits } static - gsl::span map_downloaded_buffer(const std::tuple, HANDLE> &sync_data, + gsl::multi_span map_downloaded_buffer(const std::tuple, HANDLE> &sync_data, gsl::not_null, gsl::not_null, d3d12_data_heap &readback_heap, resource_storage&) { size_t offset; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index 9cf2e25836..500ffc6ad0 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -107,7 +107,7 @@ namespace { size_t mip_level = 0; void *mapped_buffer_ptr = texture_buffer_heap.map(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); - gsl::span mapped_buffer{ (gsl::byte*)mapped_buffer_ptr, ::narrow(buffer_size) }; + gsl::multi_span mapped_buffer{ (gsl::byte*)mapped_buffer_ptr, ::narrow(buffer_size) }; std::vector input_layouts = get_subresources_layout(texture); u8 block_size_in_bytes = get_format_block_size_in_bytes(format); u8 block_size_in_texel = get_format_block_size_in_texel(format); diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index 164ae7934d..b7c447c174 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "GLGSRender.h" #include "../rsx_methods.h" #include "../Common/BufferUtils.h" @@ -40,7 +40,7 @@ namespace return std::make_tuple(element_count, mapping.second); } - std::tuple upload_index_buffer(gsl::span raw_index_buffer, void *ptr, rsx::index_array_type type, rsx::primitive_type draw_mode, const std::vector>& first_count_commands, u32 initial_vertex_count) + std::tuple upload_index_buffer(gsl::multi_span raw_index_buffer, void *ptr, rsx::index_array_type type, rsx::primitive_type draw_mode, const std::vector>& first_count_commands, u32 initial_vertex_count) { u32 min_index, max_index, vertex_draw_count = initial_vertex_count; @@ -50,7 +50,7 @@ namespace u32 type_size = ::narrow(get_index_type_size(type)); u32 block_sz = vertex_draw_count * type_size; - gsl::span dst{ reinterpret_cast(ptr), ::narrow(block_sz) }; + gsl::multi_span dst{ reinterpret_cast(ptr), ::narrow(block_sz) }; std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, raw_index_buffer, type, draw_mode, rsx::method_registers.restart_index_enabled(), rsx::method_registers.restart_index(), first_count_commands, [](auto prim) { return !gl::is_primitive_native(prim); }); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index d0ce583330..1f7ebe5654 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -869,7 +869,7 @@ namespace rsx return get_system_time() * 1000; } - gsl::span thread::get_raw_index_array(const std::vector >& draw_indexed_clause) const + gsl::multi_span thread::get_raw_index_array(const std::vector >& draw_indexed_clause) const { if (element_push_buffer.size()) { @@ -898,7 +898,7 @@ namespace rsx return{ ptr + first * type_size, count * type_size }; } - gsl::span thread::get_raw_vertex_buffer(const rsx::data_array_format_info& vertex_array_info, u32 base_offset, const std::vector>& vertex_ranges) const + gsl::multi_span thread::get_raw_vertex_buffer(const rsx::data_array_format_info& vertex_array_info, u32 base_offset, const std::vector>& vertex_ranges) const { u32 offset = vertex_array_info.offset(); u32 address = base_offset + rsx::get_address(offset & 0x7fffffff, offset >> 31); @@ -947,7 +947,7 @@ namespace rsx const rsx::register_vertex_data_info& info = state.register_vertex_info[index]; const u8 element_size = info.size * sizeof(u32); - gsl::span vertex_src = { (const gsl::byte*)vertex_push_buffers[index].data.data(), vertex_push_buffers[index].vertex_count * element_size }; + gsl::multi_span vertex_src = { (const gsl::byte*)vertex_push_buffers[index].data.data(), vertex_push_buffers[index].vertex_count * element_size }; result.push_back(vertex_array_buffer{ info.type, info.size, element_size, vertex_src, index }); continue; } diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 960c1bd8db..6c9bbeca94 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -65,7 +65,7 @@ namespace rsx rsx::vertex_base_type type; u8 attribute_size; u8 stride; - gsl::span data; + gsl::multi_span data; u8 index; }; @@ -97,7 +97,7 @@ namespace rsx */ std::vector> ranges_to_fetch_in_index_buffer; - gsl::span raw_index_buffer; + gsl::multi_span raw_index_buffer; }; struct draw_inlined_array @@ -263,8 +263,8 @@ namespace rsx virtual void clear_zcull_stats(u32 /*type*/) {} virtual u32 get_zcull_stats(u32 /*type*/) { return UINT16_MAX; } - gsl::span get_raw_index_array(const std::vector >& draw_indexed_clause) const; - gsl::span get_raw_vertex_buffer(const rsx::data_array_format_info&, u32 base_offset, const std::vector>& vertex_ranges) const; + gsl::multi_span get_raw_index_array(const std::vector >& draw_indexed_clause) const; + gsl::multi_span get_raw_vertex_buffer(const rsx::data_array_format_info&, u32 base_offset, const std::vector>& vertex_ranges) const; std::vector> get_vertex_buffers(const rsx::rsx_state& state, const std::vector>& vertex_ranges, const u64 consumed_attrib_mask) const; diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index 8fd7052cb9..e89575c901 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "stdafx.h" #include "VKHelpers.h" @@ -311,7 +311,7 @@ namespace rsx return nullptr; } - gsl::span map_downloaded_buffer(download_buffer_object, ...) + gsl::multi_span map_downloaded_buffer(download_buffer_object, ...) { return{ (gsl::byte*)nullptr, 0 }; } diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 3253fd7b05..f1a008f1d2 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -161,7 +161,7 @@ namespace vk size_t offset_in_buffer = upload_heap.alloc<512>(image_linear_size); void *mapped_buffer = upload_buffer->map(offset_in_buffer, image_linear_size); - gsl::span mapped{ (gsl::byte*)mapped_buffer, ::narrow(image_linear_size) }; + gsl::multi_span mapped{ (gsl::byte*)mapped_buffer, ::narrow(image_linear_size) }; upload_texture_subresource(mapped, layout, format, is_swizzled, 256); upload_buffer->unmap(); diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 385bbe515f..291bd849f5 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -146,7 +146,7 @@ namespace */ u32 min_index, max_index; std::tie(min_index, max_index) = write_index_array_data_to_buffer( - gsl::span(static_cast(buf), index_count * type_size), + gsl::multi_span(static_cast(buf), index_count * type_size), command.raw_index_buffer, index_type, rsx::method_registers.current_draw_clause.primitive, rsx::method_registers.restart_index_enabled(), diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 17719ad5c9..9eca1be009 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -452,18 +452,18 @@ void Buffer::mouseDoubleClickEvent(QMouseEvent* event) namespace { - std::array get_value(gsl::span orig_buffer, rsx::surface_color_format format, size_t idx) + std::array get_value(gsl::multi_span orig_buffer, rsx::surface_color_format format, size_t idx) { switch (format) { case rsx::surface_color_format::b8: { - u8 value = gsl::as_span(orig_buffer)[idx]; + u8 value = gsl::as_multi_span(orig_buffer)[idx]; return{ value, value, value }; } case rsx::surface_color_format::x32: { - be_t stored_val = gsl::as_span>(orig_buffer)[idx]; + be_t stored_val = gsl::as_multi_span>(orig_buffer)[idx]; u32 swapped_val = stored_val; f32 float_val = (f32&)swapped_val; u8 val = float_val * 255.f; @@ -473,19 +473,19 @@ namespace case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: { - auto ptr = gsl::as_span(orig_buffer); + auto ptr = gsl::as_multi_span(orig_buffer); return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] }; } case rsx::surface_color_format::a8r8g8b8: case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: { - auto ptr = gsl::as_span(orig_buffer); + auto ptr = gsl::as_multi_span(orig_buffer); return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] }; } case rsx::surface_color_format::w16z16y16x16: { - auto ptr = gsl::as_span(orig_buffer); + auto ptr = gsl::as_multi_span(orig_buffer); f16 h0 = f16(ptr[4 * idx]); f16 h1 = f16(ptr[4 * idx + 1]); f16 h2 = f16(ptr[4 * idx + 2]); @@ -511,7 +511,7 @@ namespace /** * Return a new buffer that can be passed to QImage. */ - u8* convert_to_QImage_buffer(rsx::surface_color_format format, gsl::span orig_buffer, size_t width, size_t height) noexcept + u8* convert_to_QImage_buffer(rsx::surface_color_format format, gsl::multi_span orig_buffer, size_t width, size_t height) noexcept { unsigned char* buffer = (unsigned char*)malloc(width * height * 4); for (u32 i = 0; i < width * height; i++) @@ -557,7 +557,7 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[0].empty()) { - gsl::span orig_buffer = draw_call.depth_stencil[0]; + gsl::multi_span orig_buffer = draw_call.depth_stencil[0]; unsigned char *buffer = (unsigned char *)malloc(width * height * 4); if (draw_call.state.surface_depth_fmt() == rsx::surface_depth_format::z24s8) @@ -566,7 +566,7 @@ void rsx_debugger::OnClickDrawCalls() { for (u32 col = 0; col < width; col++) { - u32 depth_val = gsl::as_span(orig_buffer)[row * width + col]; + u32 depth_val = gsl::as_multi_span(orig_buffer)[row * width + col]; u8 displayed_depth_val = 255 * depth_val / 0xFFFFFF; buffer[4 * col + 0 + width * row * 4] = displayed_depth_val; buffer[4 * col + 1 + width * row * 4] = displayed_depth_val; @@ -581,7 +581,7 @@ void rsx_debugger::OnClickDrawCalls() { for (u32 col = 0; col < width; col++) { - u16 depth_val = gsl::as_span(orig_buffer)[row * width + col]; + u16 depth_val = gsl::as_multi_span(orig_buffer)[row * width + col]; u8 displayed_depth_val = 255 * depth_val / 0xFFFF; buffer[4 * col + 0 + width * row * 4] = displayed_depth_val; buffer[4 * col + 1 + width * row * 4] = displayed_depth_val; @@ -598,14 +598,14 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[1].empty()) { - gsl::span orig_buffer = draw_call.depth_stencil[1]; + gsl::multi_span orig_buffer = draw_call.depth_stencil[1]; unsigned char *buffer = (unsigned char *)malloc(width * height * 4); for (u32 row = 0; row < height; row++) { for (u32 col = 0; col < width; col++) { - u8 stencil_val = gsl::as_span(orig_buffer)[row * width + col]; + u8 stencil_val = gsl::as_multi_span(orig_buffer)[row * width + col]; buffer[4 * col + 0 + width * row * 4] = stencil_val; buffer[4 * col + 1 + width * row * 4] = stencil_val; buffer[4 * col + 2 + width * row * 4] = stencil_val;