From 891290abd9be8df35224d6d1927e5554c0a894d9 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Wed, 3 May 2023 22:27:58 +0300 Subject: [PATCH] code: Move slot vector to common --- src/common/CMakeLists.txt | 1 + .../rasterizer_cache => common}/slot_vector.h | 10 +++++----- src/video_core/CMakeLists.txt | 1 - .../rasterizer_cache/rasterizer_cache.cpp | 2 -- .../rasterizer_cache/rasterizer_cache_base.h | 4 ++-- src/video_core/rasterizer_cache/surface_base.h | 1 + src/video_core/rasterizer_cache/surface_params.h | 6 +++++- src/video_core/rasterizer_cache/utils.h | 16 ++++------------ 8 files changed, 18 insertions(+), 23 deletions(-) rename src/{video_core/rasterizer_cache => common}/slot_vector.h (96%) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 4784d60db..9efb1eac1 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -100,6 +100,7 @@ add_library(citra_common STATIC scope_exit.h settings.cpp settings.h + slot_vector.h serialization/atomic.h serialization/boost_discrete_interval.hpp serialization/boost_flat_set.h diff --git a/src/video_core/rasterizer_cache/slot_vector.h b/src/common/slot_vector.h similarity index 96% rename from src/video_core/rasterizer_cache/slot_vector.h rename to src/common/slot_vector.h index ba02f2ab5..9a383f2a0 100644 --- a/src/video_core/rasterizer_cache/slot_vector.h +++ b/src/common/slot_vector.h @@ -5,15 +5,15 @@ #pragma once #include +#include #include #include #include #include - #include "common/assert.h" #include "common/common_types.h" -namespace VideoCore { +namespace Common { struct SlotId { static constexpr u32 INVALID_INDEX = std::numeric_limits::max(); @@ -144,11 +144,11 @@ private: std::vector free_list; }; -} // namespace VideoCore +} // namespace Common template <> -struct std::hash { - size_t operator()(const VideoCore::SlotId& id) const noexcept { +struct std::hash { + size_t operator()(const Common::SlotId& id) const noexcept { return std::hash{}(id.index); } }; diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index e67cc7f6f..547ed2d22 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -42,7 +42,6 @@ add_library(video_core STATIC rasterizer_cache/rasterizer_cache.h rasterizer_cache/rasterizer_cache_base.h rasterizer_cache/sampler_params.h - rasterizer_cache/slot_vector.h rasterizer_cache/surface_base.cpp rasterizer_cache/surface_base.h rasterizer_cache/surface_params.cpp diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.cpp b/src/video_core/rasterizer_cache/rasterizer_cache.cpp index 391273236..3f83d1a3a 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.cpp +++ b/src/video_core/rasterizer_cache/rasterizer_cache.cpp @@ -10,8 +10,6 @@ MICROPROFILE_DEFINE(RasterizerCache_CopySurface, "RasterizerCache", "CopySurface MP_RGB(128, 192, 64)); MICROPROFILE_DEFINE(RasterizerCache_UploadSurface, "RasterizerCache", "UploadSurface", MP_RGB(128, 192, 64)); -MICROPROFILE_DEFINE(RasterizerCache_ValidateSurface, "RasterizerCache", "ValidateSurface", - MP_RGB(32, 64, 192)); MICROPROFILE_DEFINE(RasterizerCache_DownloadSurface, "RasterizerCache", "DownloadSurface", MP_RGB(128, 192, 64)); MICROPROFILE_DEFINE(RasterizerCache_Invalidation, "RasterizerCache", "Invalidation", diff --git a/src/video_core/rasterizer_cache/rasterizer_cache_base.h b/src/video_core/rasterizer_cache/rasterizer_cache_base.h index a6a31ef46..126805bbf 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache_base.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache_base.h @@ -211,8 +211,8 @@ private: std::unordered_map texture_cube_cache; tsl::robin_pg_map, Common::IdentityHash> page_table; std::unordered_map samplers; - SlotVector slot_surfaces; - SlotVector slot_samplers; + Common::SlotVector slot_surfaces; + Common::SlotVector slot_samplers; SurfaceMap dirty_regions; PageMap cached_pages; std::vector remove_surfaces; diff --git a/src/video_core/rasterizer_cache/surface_base.h b/src/video_core/rasterizer_cache/surface_base.h index 17781a73b..9be06e0df 100644 --- a/src/video_core/rasterizer_cache/surface_base.h +++ b/src/video_core/rasterizer_cache/surface_base.h @@ -6,6 +6,7 @@ #include #include "video_core/rasterizer_cache/surface_params.h" +#include "video_core/rasterizer_cache/utils.h" namespace VideoCore { diff --git a/src/video_core/rasterizer_cache/surface_params.h b/src/video_core/rasterizer_cache/surface_params.h index f44a14955..74f880d2a 100644 --- a/src/video_core/rasterizer_cache/surface_params.h +++ b/src/video_core/rasterizer_cache/surface_params.h @@ -4,11 +4,15 @@ #pragma once +#include +#include "common/math_util.h" #include "video_core/custom_textures/custom_format.h" -#include "video_core/rasterizer_cache/utils.h" +#include "video_core/rasterizer_cache/pixel_format.h" namespace VideoCore { +using SurfaceInterval = boost::icl::right_open_interval; + constexpr std::size_t MAX_PICA_LEVELS = 8; class SurfaceParams { diff --git a/src/video_core/rasterizer_cache/utils.h b/src/video_core/rasterizer_cache/utils.h index 9b6e76ff0..678e27aba 100644 --- a/src/video_core/rasterizer_cache/utils.h +++ b/src/video_core/rasterizer_cache/utils.h @@ -4,21 +4,17 @@ #pragma once -#include #include -#include #include "common/hash.h" #include "common/math_util.h" +#include "common/slot_vector.h" #include "common/vector_math.h" -#include "video_core/rasterizer_cache/pixel_format.h" -#include "video_core/rasterizer_cache/slot_vector.h" +#include "video_core/regs_texturing.h" namespace VideoCore { -using SurfaceInterval = boost::icl::right_open_interval; - -using SurfaceId = SlotId; -using SamplerId = SlotId; +using SurfaceId = Common::SlotId; +using SamplerId = Common::SlotId; /// Fake surface ID for null surfaces constexpr SurfaceId NULL_SURFACE_ID{0}; @@ -28,15 +24,11 @@ constexpr SurfaceId NULL_SURFACE_CUBE_ID{1}; constexpr SamplerId NULL_SAMPLER_ID{0}; struct Offset { - constexpr auto operator<=>(const Offset&) const noexcept = default; - u32 x = 0; u32 y = 0; }; struct Extent { - constexpr auto operator<=>(const Extent&) const noexcept = default; - u32 width = 1; u32 height = 1; };