From a49446c9e993404380151001a082c3ae5122ee7c Mon Sep 17 00:00:00 2001 From: Ani Date: Sun, 30 May 2021 15:10:46 +0100 Subject: [PATCH] Replace gsl::span for std::span (c++20) (#7531) * Replace gsl::span for std::span (c++20) * Replace gsl::byte with std::byte Co-authored-by: Bevan Weiss --- .gitmodules | 4 --- 3rdparty/CMakeLists.txt | 6 ----- 3rdparty/span | 1 - Utilities/span.h | 2 -- buildfiles/msvc/rpcs3_default.props | 2 +- rpcs3/Crypto/utils.cpp | 4 +-- rpcs3/Emu/CMakeLists.txt | 5 ++-- rpcs3/Emu/Cell/Modules/cellGame.cpp | 5 ++-- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 6 ++--- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 5 ++-- rpcs3/Emu/Cell/lv2/sys_prx.cpp | 4 +-- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 26 +++++++++---------- rpcs3/Emu/RSX/Common/BufferUtils.h | 9 +++---- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 26 +++++++++---------- rpcs3/Emu/RSX/Common/TextureUtils.h | 6 ++--- rpcs3/Emu/RSX/Common/texture_cache.h | 4 +-- rpcs3/Emu/RSX/GL/GLRenderTargets.cpp | 4 ++- rpcs3/Emu/RSX/GL/GLTexture.cpp | 4 +-- rpcs3/Emu/RSX/Program/ProgramStateCache.h | 4 +-- .../Emu/RSX/Program/program_state_cache2.hpp | 2 +- rpcs3/Emu/RSX/RSXThread.cpp | 4 +-- rpcs3/Emu/RSX/RSXThread.h | 6 ++--- rpcs3/Emu/RSX/VK/VKRenderTargets.cpp | 2 +- rpcs3/Emu/RSX/VK/VKRenderTargets.h | 2 ++ rpcs3/Emu/RSX/VK/VKTexture.cpp | 2 +- rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp | 6 +++-- rpcs3/rpcs3.vcxproj | 6 ++--- rpcs3/rpcs3qt/rsx_debugger.cpp | 12 +++++---- 28 files changed, 82 insertions(+), 87 deletions(-) delete mode 160000 3rdparty/span delete mode 100644 Utilities/span.h diff --git a/.gitmodules b/.gitmodules index bd9ac2bfd5..798e037b2a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -60,10 +60,6 @@ path = 3rdparty/FAudio url = https://github.com/FNA-XNA/FAudio.git ignore = dirty -[submodule "3rdparty/span"] - path = 3rdparty/span - url = https://github.com/tcbrindle/span - ignore = dirty [submodule "3rdparty/curl"] path = 3rdparty/curl/curl url = https://github.com/curl/curl.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index e13783bbfa..279d169bcc 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -148,11 +148,6 @@ else() endif() -# span -add_library(3rdparty_span INTERFACE) -target_include_directories(3rdparty_span INTERFACE span/include) - - # stblib add_library(3rdparty_stblib INTERFACE) target_include_directories(3rdparty_stblib INTERFACE stblib/include) @@ -370,7 +365,6 @@ add_library(3rdparty::hidapi ALIAS 3rdparty_hidapi) add_library(3rdparty::libpng ALIAS ${LIBPNG_TARGET}) add_library(3rdparty::cereal ALIAS 3rdparty_cereal) add_library(3rdparty::opengl ALIAS 3rdparty_opengl) -add_library(3rdparty::span ALIAS 3rdparty_span) add_library(3rdparty::stblib ALIAS 3rdparty_stblib) add_library(3rdparty::discordRPC ALIAS 3rdparty_discordRPC) add_library(3rdparty::alsa ALIAS ${ALSA_TARGET}) diff --git a/3rdparty/span b/3rdparty/span deleted file mode 160000 index 9d7559aabd..0000000000 --- a/3rdparty/span +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9d7559aabdebf569cab3480a7ea2a87948c0ae47 diff --git a/Utilities/span.h b/Utilities/span.h deleted file mode 100644 index 6276c0b0b2..0000000000 --- a/Utilities/span.h +++ /dev/null @@ -1,2 +0,0 @@ -#define TCB_SPAN_NAMESPACE_NAME gsl -#include diff --git a/buildfiles/msvc/rpcs3_default.props b/buildfiles/msvc/rpcs3_default.props index 7f5418ab72..90a88c1b55 100644 --- a/buildfiles/msvc/rpcs3_default.props +++ b/buildfiles/msvc/rpcs3_default.props @@ -3,7 +3,7 @@ - .\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\hidapi\hidapi;..\3rdparty\Optional;..\3rdparty\xxhash + .\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\hidapi\hidapi;..\3rdparty\Optional;..\3rdparty\xxhash $(SolutionDir)lib\$(Configuration)-$(Platform)\ $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\ diff --git a/rpcs3/Crypto/utils.cpp b/rpcs3/Crypto/utils.cpp index 465504aa76..1eb02b727f 100644 --- a/rpcs3/Crypto/utils.cpp +++ b/rpcs3/Crypto/utils.cpp @@ -9,12 +9,12 @@ #include #include #include "Utilities/StrUtil.h" -#include "Utilities/span.h" #include "Utilities/File.h" #include #include #include +#include // Auxiliary functions (endian swap, xor). @@ -132,7 +132,7 @@ char* extract_file_name(const char* file_path, char real_file_name[CRYPTO_MAX_PA v.remove_prefix(pos + 1); } - gsl::span r(real_file_name, CRYPTO_MAX_PATH); + std::span r(real_file_name, CRYPTO_MAX_PATH); strcpy_trunc(r, v); return real_file_name; } diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index bce53588b7..5ff512f455 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -62,8 +62,7 @@ target_include_directories(rpcs3_emu PUBLIC "${CMAKE_SOURCE_DIR}") target_link_libraries(rpcs3_emu PUBLIC - 3rdparty::pugixml - 3rdparty::span) + 3rdparty::pugixml) if(MSVC) set_source_files_properties("../../Utilities/JIT.cpp" PROPERTIES COMPILE_FLAGS /GR-) @@ -505,7 +504,7 @@ target_link_libraries(rpcs3_emu 3rdparty::vulkan 3rdparty::glew 3rdparty::libusb 3rdparty::wolfssl PRIVATE - 3rdparty::span 3rdparty::xxhash + 3rdparty::xxhash ) if(APPLE) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index bb9596ab06..4824623f2d 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -15,10 +15,11 @@ #include "Loader/PSF.h" #include "Utilities/StrUtil.h" -#include "Utilities/span.h" #include "util/init_mutex.hpp" #include "util/asm.hpp" +#include + LOG_CHANNEL(cellGame); template<> @@ -1151,7 +1152,7 @@ error_code cellGameGetParamString(s32 id, vm::ptr buf, u32 bufsize) cellGame.warning("cellGameGetParamString(): id=%d was not found", id); } - gsl::span dst(buf.get_ptr(), bufsize); + std::span dst(buf.get_ptr(), bufsize); strcpy_trunc(dst, value); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 5d0928e9e2..dc427e1f1d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -15,11 +15,11 @@ #include "Loader/PSF.h" #include "Utilities/StrUtil.h" -#include "Utilities/span.h" #include "Utilities/date_time.h" #include #include +#include #include "util/asm.hpp" @@ -1654,7 +1654,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v if (dotpos) { // Copy file name - gsl::span dst(name, dotpos + 1); + std::span dst(name, dotpos + 1); strcpy_trunc(dst, file_path); // Allow multiple '.' even though sysutil_check_name_string does not @@ -1691,7 +1691,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v if (file_path.size() > dotpos + 1) { // Copy file extension - gsl::span dst(name, file_path.size() - dotpos); + std::span dst(name, file_path.size() - dotpos); strcpy_trunc(dst, file_path.operator std::string_view().substr(dotpos + 1)); // Allow '_' at start even though sysutil_check_name_string does not diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 187fc2da5e..5a9054ea5a 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -10,7 +10,8 @@ #include "Utilities/StrUtil.h" #include "Utilities/lockless.h" -#include "Utilities/span.h" + +#include LOG_CHANNEL(cellSysutil); @@ -385,7 +386,7 @@ error_code cellSysutilGetSystemParamString(CellSysutilParamId id, vm::ptr cellSysutil.error("cellSysutilGetSystemParamString: Unknown ParamId 0x%x", id); } - gsl::span dst(buf.get_ptr(), copy_size); + std::span dst(buf.get_ptr(), copy_size); strcpy_trunc(dst, param_str); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index e120d62511..7ab9da8de5 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -10,10 +10,10 @@ #include "Emu/Cell/ErrorCodes.h" #include "Crypto/unedat.h" #include "Utilities/StrUtil.h" -#include "Utilities/span.h" #include "sys_fs.h" #include "sys_process.h" #include "sys_memory.h" +#include extern std::shared_ptr ppu_load_prx(const ppu_prx_object&, const std::string&, s64); extern void ppu_unload_prx(const lv2_prx& prx); @@ -805,7 +805,7 @@ error_code _sys_prx_get_module_info(ppu_thread& ppu, u32 id, u64 flags, vm::ptr< pOpt->info->all_segments_num = ::size32(prx->segs); if (pOpt->info->filename) { - gsl::span dst(pOpt->info->filename.get_ptr(), pOpt->info->filename_size); + std::span dst(pOpt->info->filename.get_ptr(), pOpt->info->filename_size); strcpy_trunc(dst, prx->name); } diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 4fe6ff599d..27fa5a70dd 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -51,13 +51,13 @@ 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) + std::span as_span_workaround(std::span unformated_span) { return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } template - gsl::span as_const_span(gsl::span unformated_span) + std::span as_const_span(std::span unformated_span) { return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } @@ -583,7 +583,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, bool swap_endianness) +void write_vertex_array_data_to_buffer(std::span raw_dst_span, std::span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride, bool swap_endianness) { ensure((vector_element_count > 0)); const u32 src_read_stride = rsx::get_vertex_type_size_on_host(type, vector_element_count); @@ -665,7 +665,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); + std::span dst_span = as_span_workaround(raw_dst_span); for (u32 i = 0; i < count; ++i) { u32 src_value; @@ -782,7 +782,7 @@ namespace template static - std::tuple upload_untouched(gsl::span> src, gsl::span dst) + std::tuple upload_untouched(std::span> src, std::span dst) { T min_index, max_index; u32 written; @@ -955,7 +955,7 @@ namespace template static - std::tuple upload_untouched(gsl::span> src, gsl::span dst, T restart_index, bool skip_restart) + std::tuple upload_untouched(std::span> src, std::span dst, T restart_index, bool skip_restart) { T min_index = index_limit(); T max_index = 0; @@ -1015,7 +1015,7 @@ namespace }; template - std::tuple upload_untouched(gsl::span> src, gsl::span dst, rsx::primitive_type draw_mode, bool is_primitive_restart_enabled, u32 primitive_restart_index) + std::tuple upload_untouched(std::span> src, std::span dst, rsx::primitive_type draw_mode, bool is_primitive_restart_enabled, u32 primitive_restart_index) { if (!is_primitive_restart_enabled) { @@ -1039,7 +1039,7 @@ namespace } template - std::tuple expand_indexed_triangle_fan(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index) + std::tuple expand_indexed_triangle_fan(std::span> src, std::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index) { const T invalid_index = index_limit(); @@ -1091,7 +1091,7 @@ namespace } template - std::tuple expand_indexed_quads(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index) + std::tuple expand_indexed_quads(std::span> src, std::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index) { T min_index = index_limit(); T max_index = 0; @@ -1252,8 +1252,8 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, namespace { 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(std::span dst, + std::span> src, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::function& expands) { @@ -1286,8 +1286,8 @@ namespace } } -std::tuple write_index_array_data_to_buffer(gsl::span dst_ptr, - gsl::span src_ptr, +std::tuple write_index_array_data_to_buffer(std::span dst_ptr, + std::span src_ptr, rsx::index_array_type type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::function& expands) { diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 3524b44384..1ce46091ad 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -1,13 +1,14 @@ #pragma once -#include "Utilities/span.h" #include "../gcm_enums.h" +#include + /** * 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, bool swap_endianness); +void write_vertex_array_data_to_buffer(std::span raw_dst_span, std::span src_ptr, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride, bool swap_endianness); /* * If primitive mode is not supported and need to be emulated (using an index buffer) returns false. @@ -34,7 +35,7 @@ u32 get_index_type_size(rsx::index_array_type type); * Returns min/max index found during the process and the number of valid indices written to the buffer. * 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(std::span dst, std::span src, rsx::index_array_type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::function& expands); @@ -61,5 +62,3 @@ template void stream_data_to_memory_swapped_u32(void *dst, const void *src, u32 vertex_count, u8 stride); template bool stream_data_to_memory_swapped_and_compare_u32(void *dst, const void *src, u32 size); - - diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index e0064b4988..081f6adab2 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -11,13 +11,13 @@ 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) + std::span as_span_workaround(std::span unformated_span) { return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } template - gsl::span as_const_span(gsl::span unformated_span) + std::span as_const_span(std::span unformated_span) { return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } @@ -25,7 +25,7 @@ namespace // 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(std::span dst, std::span src) { static_assert(std::is_convertible::value, "Cannot convert source and destination span type."); std::copy(src.begin(), src.end(), dst.begin()); @@ -41,7 +41,7 @@ namespace struct copy_unmodified_block { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block, u32 src_pitch_in_block) + static void copy_mipmap_level(std::span dst, std::span src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block, u32 src_pitch_in_block) { static_assert(sizeof(T) == sizeof(U), "Type size doesn't match."); @@ -86,7 +86,7 @@ struct copy_unmodified_block_swizzled // NOTE: Pixel channel types are T (out) and const U (in). V is the pixel block type that consumes one whole pixel. // e.g 4x16-bit format can use u16, be_t, u64 as arguments template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) + static void copy_mipmap_level(std::span dst, std::span src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) { if (std::is_same::value && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border) { @@ -131,7 +131,7 @@ struct copy_unmodified_block_swizzled } } - gsl::span src_span = tmp; + std::span src_span = tmp; copy_unmodified_block::copy_mipmap_level(dst, src_span, words_per_block, width_in_block, row_count, depth, border, dst_pitch_in_block, padded_width); } } @@ -140,7 +140,7 @@ struct copy_unmodified_block_swizzled struct copy_unmodified_block_vtc { 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(std::span dst, std::span src, u16 width_in_block, u16 row_count, u16 depth, u32 /*dst_pitch_in_block*/, u32 /*src_pitch_in_block*/) { static_assert(sizeof(T) == sizeof(U), "Type size doesn't match."); u32 row_element_count = width_in_block * row_count; @@ -201,7 +201,7 @@ struct copy_unmodified_block_vtc struct copy_decoded_rb_rg_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(std::span dst, std::span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block, u32 src_pitch_in_block) { static_assert(sizeof(T) == 4, "Type size doesn't match."); @@ -248,7 +248,7 @@ struct copy_decoded_rb_rg_block struct copy_rgb655_block { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block, u32 src_pitch_in_block) + static void copy_mipmap_level(std::span dst, std::span src, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block, u32 src_pitch_in_block) { static_assert(sizeof(T) == 2, "Type size doesn't match."); @@ -280,7 +280,7 @@ struct copy_rgb655_block struct copy_rgb655_block_swizzled { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) + static void copy_mipmap_level(std::span dst, std::span src, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) { u32 padded_width, padded_height; if (border) @@ -299,7 +299,7 @@ struct copy_rgb655_block_swizzled rsx::convert_linear_swizzle_3d(src.data(), tmp.data(), padded_width, padded_height, depth); - gsl::span src_span = tmp; + std::span src_span = tmp; copy_rgb655_block::copy_mipmap_level(dst, src_span, width_in_block, row_count, depth, border, dst_pitch_in_block, padded_width); } }; @@ -434,7 +434,7 @@ namespace const u32 slice_sz = src_pitch_in_block * block_size_in_bytes * full_height_in_block * depth; current_subresource_layout.pitch_in_block = src_pitch_in_block; - current_subresource_layout.data = gsl::span(texture_data_pointer + offset_in_src, slice_sz); + current_subresource_layout.data = std::span(texture_data_pointer + offset_in_src, slice_sz); offset_in_src += slice_sz; miplevel_width_in_texel = std::max(miplevel_width_in_texel / 2, 1); @@ -598,7 +598,7 @@ namespace rsx return get_subresources_layout_impl(texture); } - texture_memory_info upload_texture_subresource(gsl::span dst_buffer, const rsx::subresource_layout& src_layout, int format, bool is_swizzled, texture_uploader_capabilities& caps) + texture_memory_info upload_texture_subresource(std::span dst_buffer, const rsx::subresource_layout& src_layout, int format, bool is_swizzled, texture_uploader_capabilities& caps) { u16 w = src_layout.width_in_block; u16 h = src_layout.height_in_block; diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index a50e0800f4..aa39ccf227 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -1,8 +1,8 @@ #pragma once #include "../RSXTexture.h" -#include "Utilities/span.h" +#include #include namespace rsx @@ -156,7 +156,7 @@ namespace rsx struct subresource_layout { - gsl::span data; + std::span data; u16 width_in_texel; u16 height_in_texel; u16 width_in_block; @@ -211,7 +211,7 @@ namespace rsx std::vector get_subresources_layout(const rsx::fragment_texture &texture); std::vector get_subresources_layout(const rsx::vertex_texture &texture); - texture_memory_info upload_texture_subresource(gsl::span dst_buffer, const subresource_layout &src_layout, int format, bool is_swizzled, texture_uploader_capabilities& caps); + texture_memory_info upload_texture_subresource(std::span dst_buffer, const subresource_layout &src_layout, int format, bool is_swizzled, texture_uploader_capabilities& caps); 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/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index f42bf50788..f6b59a0ab3 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -2669,7 +2669,7 @@ namespace rsx subres.height_in_block = subres.height_in_texel = image_height; subres.pitch_in_block = full_width; subres.depth = 1; - subres.data = { vm::_ptr(image_base), static_cast::index_type>(src.pitch * image_height) }; + subres.data = { vm::_ptr(image_base), static_cast::size_type>(src.pitch * image_height) }; subresource_layout.push_back(subres); const u32 gcm_format = helpers::get_sized_blit_format(src_is_argb8, dst_is_depth_surface, is_format_convert); @@ -2801,7 +2801,7 @@ namespace rsx subres.height_in_block = subres.height_in_texel = dst_dimensions.height; subres.pitch_in_block = pitch_in_block; subres.depth = 1; - subres.data = { vm::get_super_ptr(dst_base_address), static_cast::index_type>(dst.pitch * dst_dimensions.height) }; + subres.data = { vm::get_super_ptr(dst_base_address), static_cast::size_type>(dst.pitch * dst_dimensions.height) }; subresource_layout.push_back(subres); cached_dest = upload_image_from_cpu(cmd, rsx_range, dst_dimensions.width, dst_dimensions.height, 1, 1, dst.pitch, diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 7d724d9b3a..d149462289 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -2,6 +2,8 @@ #include "GLGSRender.h" #include "Emu/RSX/rsx_methods.h" +#include + color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_format color_format) { //color format @@ -418,7 +420,7 @@ void gl::render_target::load_memory(gl::command_context& cmd) subres.height_in_block = subres.height_in_texel = surface_height * samples_y; subres.pitch_in_block = rsx_pitch / get_bpp(); subres.depth = 1; - subres.data = { vm::get_super_ptr(base_addr), static_cast::index_type>(rsx_pitch * surface_height * samples_y) }; + subres.data = { vm::get_super_ptr(base_addr), static_cast::size_type>(rsx_pitch * surface_height * samples_y) }; // TODO: MSAA support if (g_cfg.video.resolution_scale_percent == 100 && spp == 1) [[likely]] diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index b13ec530a7..25211e7426 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -654,7 +654,7 @@ namespace gl image_memory_requirements mem_info; pixel_buffer_layout mem_layout; - gsl::span dst_buffer = staging_buffer; + std::span dst_buffer = staging_buffer; void* out_pointer = staging_buffer.data(); u8 block_size_in_bytes = rsx::get_format_block_size_in_bytes(format); u64 image_linear_size; @@ -693,7 +693,7 @@ namespace gl { const u64 row_pitch = rsx::align2(layout.width_in_block * block_size_in_bytes, caps.alignment); image_linear_size = row_pitch * layout.height_in_block * layout.depth; - dst_buffer = { reinterpret_cast(upload_scratch_mem.map(buffer::access::write)), image_linear_size }; + dst_buffer = { reinterpret_cast(upload_scratch_mem.map(buffer::access::write)), image_linear_size }; } auto op = upload_texture_subresource(dst_buffer, layout, format, is_swizzled, caps); diff --git a/rpcs3/Emu/RSX/Program/ProgramStateCache.h b/rpcs3/Emu/RSX/Program/ProgramStateCache.h index c34dcf97ba..54b12fcb1c 100644 --- a/rpcs3/Emu/RSX/Program/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.h @@ -5,9 +5,9 @@ #include "Utilities/mutex.h" #include "util/logs.hpp" -#include "Utilities/span.h" #include "util/fnv_hash.hpp" +#include #include enum class SHADER_TYPE @@ -398,7 +398,7 @@ public: std::forward(args)...); // Other arguments } - void fill_fragment_constants_buffer(gsl::span dst_buffer, const RSXFragmentProgram& fragment_program, bool sanitize = false) const; + void fill_fragment_constants_buffer(std::span dst_buffer, const RSXFragmentProgram& fragment_program, bool sanitize = false) const; void clear() { diff --git a/rpcs3/Emu/RSX/Program/program_state_cache2.hpp b/rpcs3/Emu/RSX/Program/program_state_cache2.hpp index 88606c5da0..9dc1e4f132 100644 --- a/rpcs3/Emu/RSX/Program/program_state_cache2.hpp +++ b/rpcs3/Emu/RSX/Program/program_state_cache2.hpp @@ -6,7 +6,7 @@ #include "util/asm.hpp" template -void program_state_cache::fill_fragment_constants_buffer(gsl::span dst_buffer, const RSXFragmentProgram &fragment_program, bool sanitize) const +void program_state_cache::fill_fragment_constants_buffer(std::span dst_buffer, const RSXFragmentProgram &fragment_program, bool sanitize) const { const auto I = m_fragment_shader_cache.find(fragment_program); if (I == m_fragment_shader_cache.end()) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 9058acfcc5..c0ad5a04c5 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -17,12 +17,12 @@ #include "Overlays/overlay_perf_metrics.h" #include "Program/GLSLCommon.h" #include "Utilities/date_time.h" -#include "Utilities/span.h" #include "Utilities/StrUtil.h" #include "util/cereal.hpp" #include "util/asm.hpp" +#include #include #include #include @@ -892,7 +892,7 @@ namespace rsx return t + timestamp_subvalue; } - gsl::span thread::get_raw_index_array(const draw_clause& draw_indexed_clause) const + std::span thread::get_raw_index_array(const draw_clause& draw_indexed_clause) const { if (!element_push_buffer.empty()) { diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 3524de5fc1..c02d4781b4 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -191,7 +191,7 @@ namespace rsx rsx::vertex_base_type type; u8 attribute_size; u8 stride; - gsl::span data; + std::span data; u8 index; bool is_be; }; @@ -216,7 +216,7 @@ namespace rsx struct draw_indexed_array_command { - gsl::span raw_index_buffer; + std::span raw_index_buffer; }; struct draw_inlined_array @@ -853,7 +853,7 @@ namespace rsx flags32_t read_barrier(u32 memory_address, u32 memory_range, bool unconditional); virtual void sync_hint(FIFO_hint hint, void* args); - gsl::span get_raw_index_array(const draw_clause& draw_indexed_clause) const; + std::span get_raw_index_array(const draw_clause& draw_indexed_clause) const; std::variant get_draw_command(const rsx::rsx_state& state) const; diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp index 062325647b..632b174318 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp @@ -223,7 +223,7 @@ namespace vk subres.height_in_block = subres.height_in_texel = surface_height * samples_y; subres.pitch_in_block = rsx_pitch / get_bpp(); subres.depth = 1; - subres.data = { vm::get_super_ptr(base_addr), static_cast::index_type>(rsx_pitch * surface_height * samples_y) }; + subres.data = { vm::get_super_ptr(base_addr), static_cast::size_type>(rsx_pitch * surface_height * samples_y) }; if (g_cfg.video.resolution_scale_percent == 100 && spp == 1) [[likely]] { diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index edce352fea..c82c5d390e 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -11,6 +11,8 @@ #include "vkutils/image.h" #include "vkutils/scratch.h" +#include + namespace vk { void resolve_image(vk::command_buffer& cmd, vk::viewable_image* dst, vk::viewable_image* src); diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 75980ede46..cb71fb615c 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -918,7 +918,7 @@ namespace vk check_caps = false; } - gsl::span mapped{ static_cast(mapped_buffer), image_linear_size }; + std::span mapped{ static_cast(mapped_buffer), image_linear_size }; opt = upload_texture_subresource(mapped, layout, format, is_swizzled, caps); upload_heap.unmap(); diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 4a48c45de4..15e0d1c377 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -4,6 +4,8 @@ #include "../rsx_methods.h" #include "vkutils/buffer_object.h" +#include + namespace vk { VkPrimitiveTopology get_appropriate_topology(rsx::primitive_type mode, bool &requires_modification) @@ -143,7 +145,7 @@ namespace VkDeviceSize offset_in_index_buffer = m_index_buffer_ring_info.alloc<4>(upload_size); void* buf = m_index_buffer_ring_info.map(offset_in_index_buffer, upload_size); - gsl::span dst; + std::span dst; std::vector tmp; if (emulate_restart) { @@ -152,7 +154,7 @@ namespace } else { - dst = gsl::span(static_cast(buf), upload_size); + dst = std::span(static_cast(buf), upload_size); } /** diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index e78d9582ee..b40dda073c 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -62,12 +62,12 @@ true - ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib + ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) - ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib + ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib @@ -1406,4 +1406,4 @@ - \ No newline at end of file + diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 1057258b9e..ff490d45be 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -13,6 +13,8 @@ #include #include +#include + enum GCMEnumTypes { CELL_GCM_ENUM, @@ -24,7 +26,7 @@ constexpr auto qstr = QString::fromStdString; namespace { template - gsl::span as_const_span(gsl::span unformated_span) + std::span as_const_span(std::span unformated_span) { return{ reinterpret_cast(unformated_span.data()), unformated_span.size_bytes() / sizeof(T) }; } @@ -412,7 +414,7 @@ namespace return std::bit_cast(raw); } - std::array get_value(gsl::span orig_buffer, rsx::surface_color_format format, usz idx) + std::array get_value(std::span orig_buffer, rsx::surface_color_format format, usz idx) { switch (format) { @@ -471,7 +473,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, usz width, usz height) noexcept + u8* convert_to_QImage_buffer(rsx::surface_color_format format, std::span orig_buffer, usz width, usz height) noexcept { u8* buffer = static_cast(std::malloc(width * height * 4)); if (!buffer || width == 0 || height == 0) @@ -521,7 +523,7 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[0].empty()) { - const gsl::span orig_buffer = draw_call.depth_stencil[0]; + const std::span orig_buffer = draw_call.depth_stencil[0]; u8* buffer = static_cast(std::malloc(4ULL * width * height)); if (draw_call.state.surface_depth_fmt() == rsx::surface_depth_format::z24s8) @@ -562,7 +564,7 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[1].empty()) { - const gsl::span orig_buffer = draw_call.depth_stencil[1]; + const std::span orig_buffer = draw_call.depth_stencil[1]; u8* buffer = static_cast(std::malloc(4ULL * width * height)); for (u32 row = 0; row < height; row++)