summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2021-06-24 19:09:12 -0700
committerGravatar GitHub2021-06-24 19:09:12 -0700
commitb9c2732121e2594a64d1141807c7d5bd0f317d0f (patch)
tree700ab748e15d1e7d5cf7f58f2cbac133b7a84915 /src/video_core
parentMerge pull request #6522 from Morph1984/pragma (diff)
parentcommon: Replace common_sizes into user-literals (diff)
downloadyuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.gz
yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.xz
yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.zip
Merge pull request #6519 from Wunkolo/mem-size-literal
common: Replace common_sizes into user-literals
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h11
-rw-r--r--src/video_core/renderer_opengl/gl_stream_buffer.h5
-rw-r--r--src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp8
-rw-r--r--src/video_core/renderer_vulkan/vk_stream_buffer.cpp5
-rw-r--r--src/video_core/texture_cache/texture_cache.h12
5 files changed, 27 insertions, 14 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 6d04d00da..9d726a6fb 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -16,9 +16,9 @@
16 16
17#include <boost/container/small_vector.hpp> 17#include <boost/container/small_vector.hpp>
18 18
19#include "common/common_sizes.h"
20#include "common/common_types.h" 19#include "common/common_types.h"
21#include "common/div_ceil.h" 20#include "common/div_ceil.h"
21#include "common/literals.h"
22#include "common/microprofile.h" 22#include "common/microprofile.h"
23#include "common/scope_exit.h" 23#include "common/scope_exit.h"
24#include "common/settings.h" 24#include "common/settings.h"
@@ -48,8 +48,11 @@ constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8;
48constexpr u32 NUM_STORAGE_BUFFERS = 16; 48constexpr u32 NUM_STORAGE_BUFFERS = 16;
49constexpr u32 NUM_STAGES = 5; 49constexpr u32 NUM_STAGES = 5;
50 50
51using namespace Common::Literals;
52
51template <typename P> 53template <typename P>
52class BufferCache { 54class BufferCache {
55
53 // Page size for caching purposes. 56 // Page size for caching purposes.
54 // This is unrelated to the CPU page size and it can be changed as it seems optimal. 57 // This is unrelated to the CPU page size and it can be changed as it seems optimal.
55 static constexpr u32 PAGE_BITS = 16; 58 static constexpr u32 PAGE_BITS = 16;
@@ -66,8 +69,8 @@ class BufferCache {
66 69
67 static constexpr BufferId NULL_BUFFER_ID{0}; 70 static constexpr BufferId NULL_BUFFER_ID{0};
68 71
69 static constexpr u64 EXPECTED_MEMORY = Common::Size_512_MB; 72 static constexpr u64 EXPECTED_MEMORY = 512_MiB;
70 static constexpr u64 CRITICAL_MEMORY = Common::Size_1_GB; 73 static constexpr u64 CRITICAL_MEMORY = 1_GiB;
71 74
72 using Maxwell = Tegra::Engines::Maxwell3D::Regs; 75 using Maxwell = Tegra::Engines::Maxwell3D::Regs;
73 76
@@ -96,7 +99,7 @@ class BufferCache {
96 }; 99 };
97 100
98public: 101public:
99 static constexpr u32 DEFAULT_SKIP_CACHE_SIZE = 4096; 102 static constexpr u32 DEFAULT_SKIP_CACHE_SIZE = 4_KiB;
100 103
101 explicit BufferCache(VideoCore::RasterizerInterface& rasterizer_, 104 explicit BufferCache(VideoCore::RasterizerInterface& rasterizer_,
102 Tegra::Engines::Maxwell3D& maxwell3d_, 105 Tegra::Engines::Maxwell3D& maxwell3d_,
diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.h b/src/video_core/renderer_opengl/gl_stream_buffer.h
index 6dbb6bfba..2e67922a6 100644
--- a/src/video_core/renderer_opengl/gl_stream_buffer.h
+++ b/src/video_core/renderer_opengl/gl_stream_buffer.h
@@ -12,12 +12,15 @@
12#include <glad/glad.h> 12#include <glad/glad.h>
13 13
14#include "common/common_types.h" 14#include "common/common_types.h"
15#include "common/literals.h"
15#include "video_core/renderer_opengl/gl_resource_manager.h" 16#include "video_core/renderer_opengl/gl_resource_manager.h"
16 17
17namespace OpenGL { 18namespace OpenGL {
18 19
20using namespace Common::Literals;
21
19class StreamBuffer { 22class StreamBuffer {
20 static constexpr size_t STREAM_BUFFER_SIZE = 64 * 1024 * 1024; 23 static constexpr size_t STREAM_BUFFER_SIZE = 64_MiB;
21 static constexpr size_t NUM_SYNCS = 16; 24 static constexpr size_t NUM_SYNCS = 16;
22 static constexpr size_t REGION_SIZE = STREAM_BUFFER_SIZE / NUM_SYNCS; 25 static constexpr size_t REGION_SIZE = STREAM_BUFFER_SIZE / NUM_SYNCS;
23 static constexpr size_t MAX_ALIGNMENT = 256; 26 static constexpr size_t MAX_ALIGNMENT = 256;
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp
index 7a1232497..0412b5234 100644
--- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp
+++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp
@@ -12,6 +12,7 @@
12#include "common/assert.h" 12#include "common/assert.h"
13#include "common/bit_util.h" 13#include "common/bit_util.h"
14#include "common/common_types.h" 14#include "common/common_types.h"
15#include "common/literals.h"
15#include "video_core/renderer_vulkan/vk_scheduler.h" 16#include "video_core/renderer_vulkan/vk_scheduler.h"
16#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" 17#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
17#include "video_core/vulkan_common/vulkan_device.h" 18#include "video_core/vulkan_common/vulkan_device.h"
@@ -19,12 +20,15 @@
19 20
20namespace Vulkan { 21namespace Vulkan {
21namespace { 22namespace {
23
24using namespace Common::Literals;
25
22// Maximum potential alignment of a Vulkan buffer 26// Maximum potential alignment of a Vulkan buffer
23constexpr VkDeviceSize MAX_ALIGNMENT = 256; 27constexpr VkDeviceSize MAX_ALIGNMENT = 256;
24// Maximum size to put elements in the stream buffer 28// Maximum size to put elements in the stream buffer
25constexpr VkDeviceSize MAX_STREAM_BUFFER_REQUEST_SIZE = 8 * 1024 * 1024; 29constexpr VkDeviceSize MAX_STREAM_BUFFER_REQUEST_SIZE = 8_MiB;
26// Stream buffer size in bytes 30// Stream buffer size in bytes
27constexpr VkDeviceSize STREAM_BUFFER_SIZE = 128 * 1024 * 1024; 31constexpr VkDeviceSize STREAM_BUFFER_SIZE = 128_MiB;
28constexpr VkDeviceSize REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS; 32constexpr VkDeviceSize REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS;
29 33
30constexpr VkMemoryPropertyFlags HOST_FLAGS = 34constexpr VkMemoryPropertyFlags HOST_FLAGS =
diff --git a/src/video_core/renderer_vulkan/vk_stream_buffer.cpp b/src/video_core/renderer_vulkan/vk_stream_buffer.cpp
index a09fe084e..7b4875d0e 100644
--- a/src/video_core/renderer_vulkan/vk_stream_buffer.cpp
+++ b/src/video_core/renderer_vulkan/vk_stream_buffer.cpp
@@ -10,6 +10,7 @@
10 10
11#include "common/alignment.h" 11#include "common/alignment.h"
12#include "common/assert.h" 12#include "common/assert.h"
13#include "common/literals.h"
13#include "video_core/renderer_vulkan/vk_scheduler.h" 14#include "video_core/renderer_vulkan/vk_scheduler.h"
14#include "video_core/renderer_vulkan/vk_stream_buffer.h" 15#include "video_core/renderer_vulkan/vk_stream_buffer.h"
15#include "video_core/vulkan_common/vulkan_device.h" 16#include "video_core/vulkan_common/vulkan_device.h"
@@ -19,6 +20,8 @@ namespace Vulkan {
19 20
20namespace { 21namespace {
21 22
23using namespace Common::Literals;
24
22constexpr VkBufferUsageFlags BUFFER_USAGE = 25constexpr VkBufferUsageFlags BUFFER_USAGE =
23 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | 26 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT |
24 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; 27 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
@@ -26,7 +29,7 @@ constexpr VkBufferUsageFlags BUFFER_USAGE =
26constexpr u64 WATCHES_INITIAL_RESERVE = 0x4000; 29constexpr u64 WATCHES_INITIAL_RESERVE = 0x4000;
27constexpr u64 WATCHES_RESERVE_CHUNK = 0x1000; 30constexpr u64 WATCHES_RESERVE_CHUNK = 0x1000;
28 31
29constexpr u64 PREFERRED_STREAM_BUFFER_SIZE = 256 * 1024 * 1024; 32constexpr u64 PREFERRED_STREAM_BUFFER_SIZE = 256_MiB;
30 33
31/// Find a memory type with the passed requirements 34/// Find a memory type with the passed requirements
32std::optional<u32> FindMemoryType(const VkPhysicalDeviceMemoryProperties& properties, 35std::optional<u32> FindMemoryType(const VkPhysicalDeviceMemoryProperties& properties,
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index e7f8478b4..84530a179 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -19,9 +19,8 @@
19#include <boost/container/small_vector.hpp> 19#include <boost/container/small_vector.hpp>
20 20
21#include "common/alignment.h" 21#include "common/alignment.h"
22#include "common/common_funcs.h"
23#include "common/common_sizes.h"
24#include "common/common_types.h" 22#include "common/common_types.h"
23#include "common/literals.h"
25#include "common/logging/log.h" 24#include "common/logging/log.h"
26#include "common/settings.h" 25#include "common/settings.h"
27#include "video_core/compatible_formats.h" 26#include "video_core/compatible_formats.h"
@@ -59,6 +58,7 @@ using VideoCore::Surface::PixelFormat;
59using VideoCore::Surface::PixelFormatFromDepthFormat; 58using VideoCore::Surface::PixelFormatFromDepthFormat;
60using VideoCore::Surface::PixelFormatFromRenderTargetFormat; 59using VideoCore::Surface::PixelFormatFromRenderTargetFormat;
61using VideoCore::Surface::SurfaceType; 60using VideoCore::Surface::SurfaceType;
61using namespace Common::Literals;
62 62
63template <class P> 63template <class P>
64class TextureCache { 64class TextureCache {
@@ -79,8 +79,8 @@ class TextureCache {
79 /// Sampler ID for bugged sampler ids 79 /// Sampler ID for bugged sampler ids
80 static constexpr SamplerId NULL_SAMPLER_ID{0}; 80 static constexpr SamplerId NULL_SAMPLER_ID{0};
81 81
82 static constexpr u64 DEFAULT_EXPECTED_MEMORY = Common::Size_1_GB; 82 static constexpr u64 DEFAULT_EXPECTED_MEMORY = 1_GiB;
83 static constexpr u64 DEFAULT_CRITICAL_MEMORY = Common::Size_2_GB; 83 static constexpr u64 DEFAULT_CRITICAL_MEMORY = 2_GiB;
84 84
85 using Runtime = typename P::Runtime; 85 using Runtime = typename P::Runtime;
86 using Image = typename P::Image; 86 using Image = typename P::Image;
@@ -400,8 +400,8 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
400 minimum_memory = 0; 400 minimum_memory = 0;
401 } else { 401 } else {
402 // on OGL we can be more conservatives as the driver takes care. 402 // on OGL we can be more conservatives as the driver takes care.
403 expected_memory = DEFAULT_EXPECTED_MEMORY + Common::Size_512_MB; 403 expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB;
404 critical_memory = DEFAULT_CRITICAL_MEMORY + Common::Size_1_GB; 404 critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB;
405 minimum_memory = expected_memory; 405 minimum_memory = expected_memory;
406 } 406 }
407} 407}