diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_device.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_device.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 11 |
7 files changed, 37 insertions, 29 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index f73b0af5f..f1f7b384b 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp | |||
| @@ -136,21 +136,17 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_) | |||
| 136 | glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY); | 136 | glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | device_access_memory = []() -> u64 { | 139 | device_access_memory = [this]() -> u64 { |
| 140 | if (GLAD_GL_NVX_gpu_memory_info) { | 140 | if (device.CanReportMemoryUsage()) { |
| 141 | GLint cur_avail_mem_kb = 0; | 141 | return device.GetCurrentDedicatedVideoMemory() + 512_MiB; |
| 142 | glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb); | ||
| 143 | return static_cast<u64>(cur_avail_mem_kb) * 1_KiB; | ||
| 144 | } | 142 | } |
| 145 | return 2_GiB; // Return minimum requirements | 143 | return 2_GiB; // Return minimum requirements |
| 146 | }(); | 144 | }(); |
| 147 | } | 145 | } |
| 148 | 146 | ||
| 149 | u64 BufferCacheRuntime::GetDeviceMemoryUsage() const { | 147 | u64 BufferCacheRuntime::GetDeviceMemoryUsage() const { |
| 150 | if (GLAD_GL_NVX_gpu_memory_info) { | 148 | if (device.CanReportMemoryUsage()) { |
| 151 | GLint cur_avail_mem_kb = 0; | 149 | return device_access_memory - device.GetCurrentDedicatedVideoMemory(); |
| 152 | glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb); | ||
| 153 | return device_access_memory - static_cast<u64>(cur_avail_mem_kb) * 1_KiB; | ||
| 154 | } | 150 | } |
| 155 | return 2_GiB; | 151 | return 2_GiB; |
| 156 | } | 152 | } |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index 86a265fee..a8699f28c 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h | |||
| @@ -89,6 +89,8 @@ public: | |||
| 89 | void BindImageBuffer(Buffer& buffer, u32 offset, u32 size, | 89 | void BindImageBuffer(Buffer& buffer, u32 offset, u32 size, |
| 90 | VideoCore::Surface::PixelFormat format); | 90 | VideoCore::Surface::PixelFormat format); |
| 91 | 91 | ||
| 92 | u64 GetDeviceMemoryUsage() const; | ||
| 93 | |||
| 92 | void BindFastUniformBuffer(size_t stage, u32 binding_index, u32 size) { | 94 | void BindFastUniformBuffer(size_t stage, u32 binding_index, u32 size) { |
| 93 | const GLuint handle = fast_uniforms[stage][binding_index].handle; | 95 | const GLuint handle = fast_uniforms[stage][binding_index].handle; |
| 94 | const GLsizeiptr gl_size = static_cast<GLsizeiptr>(size); | 96 | const GLsizeiptr gl_size = static_cast<GLsizeiptr>(size); |
| @@ -155,10 +157,8 @@ public: | |||
| 155 | return device_access_memory; | 157 | return device_access_memory; |
| 156 | } | 158 | } |
| 157 | 159 | ||
| 158 | u64 GetDeviceMemoryUsage() const; | ||
| 159 | |||
| 160 | bool CanReportMemoryUsage() const { | 160 | bool CanReportMemoryUsage() const { |
| 161 | return GLAD_GL_NVX_gpu_memory_info; | 161 | return device.CanReportMemoryUsage(); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | private: | 164 | private: |
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 715cd3a48..656dd7eb0 100644 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp | |||
| @@ -13,12 +13,15 @@ | |||
| 13 | 13 | ||
| 14 | #include <glad/glad.h> | 14 | #include <glad/glad.h> |
| 15 | 15 | ||
| 16 | #include "common/literals.h" | ||
| 16 | #include "common/logging/log.h" | 17 | #include "common/logging/log.h" |
| 17 | #include "common/settings.h" | 18 | #include "common/settings.h" |
| 18 | #include "shader_recompiler/stage.h" | 19 | #include "shader_recompiler/stage.h" |
| 19 | #include "video_core/renderer_opengl/gl_device.h" | 20 | #include "video_core/renderer_opengl/gl_device.h" |
| 20 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 21 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 21 | 22 | ||
| 23 | using namespace Common::Literals; | ||
| 24 | |||
| 22 | namespace OpenGL { | 25 | namespace OpenGL { |
| 23 | namespace { | 26 | namespace { |
| 24 | constexpr std::array LIMIT_UBOS = { | 27 | constexpr std::array LIMIT_UBOS = { |
| @@ -165,6 +168,7 @@ Device::Device() { | |||
| 165 | has_sparse_texture_2 = GLAD_GL_ARB_sparse_texture2; | 168 | has_sparse_texture_2 = GLAD_GL_ARB_sparse_texture2; |
| 166 | warp_size_potentially_larger_than_guest = !is_nvidia && !is_intel; | 169 | warp_size_potentially_larger_than_guest = !is_nvidia && !is_intel; |
| 167 | need_fastmath_off = is_nvidia; | 170 | need_fastmath_off = is_nvidia; |
| 171 | can_report_memory = GLAD_GL_NVX_gpu_memory_info; | ||
| 168 | 172 | ||
| 169 | // At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive | 173 | // At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive |
| 170 | // uniform buffers as "push constants" | 174 | // uniform buffers as "push constants" |
| @@ -276,4 +280,10 @@ void main() { | |||
| 276 | })"); | 280 | })"); |
| 277 | } | 281 | } |
| 278 | 282 | ||
| 283 | u64 Device::GetCurrentDedicatedVideoMemory() const { | ||
| 284 | GLint cur_avail_mem_kb = 0; | ||
| 285 | glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &cur_avail_mem_kb); | ||
| 286 | return static_cast<u64>(cur_avail_mem_kb) * 1_KiB; | ||
| 287 | } | ||
| 288 | |||
| 279 | } // namespace OpenGL | 289 | } // namespace OpenGL |
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h index 95c2e8d38..9bb0b9148 100644 --- a/src/video_core/renderer_opengl/gl_device.h +++ b/src/video_core/renderer_opengl/gl_device.h | |||
| @@ -20,6 +20,8 @@ public: | |||
| 20 | 20 | ||
| 21 | [[nodiscard]] std::string GetVendorName() const; | 21 | [[nodiscard]] std::string GetVendorName() const; |
| 22 | 22 | ||
| 23 | u64 GetCurrentDedicatedVideoMemory() const; | ||
| 24 | |||
| 23 | u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept { | 25 | u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept { |
| 24 | return max_uniform_buffers[static_cast<size_t>(stage)]; | 26 | return max_uniform_buffers[static_cast<size_t>(stage)]; |
| 25 | } | 27 | } |
| @@ -168,6 +170,10 @@ public: | |||
| 168 | return vendor_name == "ATI Technologies Inc."; | 170 | return vendor_name == "ATI Technologies Inc."; |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 173 | bool CanReportMemoryUsage() const { | ||
| 174 | return can_report_memory; | ||
| 175 | } | ||
| 176 | |||
| 171 | private: | 177 | private: |
| 172 | static bool TestVariableAoffi(); | 178 | static bool TestVariableAoffi(); |
| 173 | static bool TestPreciseBug(); | 179 | static bool TestPreciseBug(); |
| @@ -210,6 +216,7 @@ private: | |||
| 210 | bool need_fastmath_off{}; | 216 | bool need_fastmath_off{}; |
| 211 | bool has_cbuf_ftou_bug{}; | 217 | bool has_cbuf_ftou_bug{}; |
| 212 | bool has_bool_ref_bug{}; | 218 | bool has_bool_ref_bug{}; |
| 219 | bool can_report_memory{}; | ||
| 213 | 220 | ||
| 214 | std::string vendor_name; | 221 | std::string vendor_name; |
| 215 | }; | 222 | }; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 63586d9d5..8f9a65beb 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -485,11 +485,9 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& | |||
| 485 | } | 485 | } |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | device_access_memory = []() -> u64 { | 488 | device_access_memory = [this]() -> u64 { |
| 489 | if (GLAD_GL_NVX_gpu_memory_info) { | 489 | if (device.CanReportMemoryUsage()) { |
| 490 | GLint cur_avail_mem_kb = 0; | 490 | return device.GetCurrentDedicatedVideoMemory() + 512_MiB; |
| 491 | glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb); | ||
| 492 | return static_cast<u64>(cur_avail_mem_kb) * 1_KiB; | ||
| 493 | } | 491 | } |
| 494 | return 2_GiB; // Return minimum requirements | 492 | return 2_GiB; // Return minimum requirements |
| 495 | }(); | 493 | }(); |
| @@ -510,10 +508,8 @@ ImageBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) { | |||
| 510 | } | 508 | } |
| 511 | 509 | ||
| 512 | u64 TextureCacheRuntime::GetDeviceMemoryUsage() const { | 510 | u64 TextureCacheRuntime::GetDeviceMemoryUsage() const { |
| 513 | if (GLAD_GL_NVX_gpu_memory_info) { | 511 | if (device.CanReportMemoryUsage()) { |
| 514 | GLint cur_avail_mem_kb = 0; | 512 | return device_access_memory - device.GetCurrentDedicatedVideoMemory(); |
| 515 | glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb); | ||
| 516 | return device_access_memory - static_cast<u64>(cur_avail_mem_kb) * 1_KiB; | ||
| 517 | } | 513 | } |
| 518 | return 2_GiB; | 514 | return 2_GiB; |
| 519 | } | 515 | } |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index feeeb371e..53088b66e 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <glad/glad.h> | 10 | #include <glad/glad.h> |
| 11 | 11 | ||
| 12 | #include "shader_recompiler/shader_info.h" | 12 | #include "shader_recompiler/shader_info.h" |
| 13 | #include "video_core/renderer_opengl/gl_device.h" | ||
| 13 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 14 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 14 | #include "video_core/renderer_opengl/util_shaders.h" | 15 | #include "video_core/renderer_opengl/util_shaders.h" |
| 15 | #include "video_core/texture_cache/image_view_base.h" | 16 | #include "video_core/texture_cache/image_view_base.h" |
| @@ -21,7 +22,6 @@ struct ResolutionScalingInfo; | |||
| 21 | 22 | ||
| 22 | namespace OpenGL { | 23 | namespace OpenGL { |
| 23 | 24 | ||
| 24 | class Device; | ||
| 25 | class ProgramManager; | 25 | class ProgramManager; |
| 26 | class StateTracker; | 26 | class StateTracker; |
| 27 | 27 | ||
| @@ -90,7 +90,7 @@ public: | |||
| 90 | u64 GetDeviceMemoryUsage() const; | 90 | u64 GetDeviceMemoryUsage() const; |
| 91 | 91 | ||
| 92 | bool CanReportMemoryUsage() const { | 92 | bool CanReportMemoryUsage() const { |
| 93 | return GLAD_GL_NVX_gpu_memory_info; | 93 | return device.CanReportMemoryUsage(); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) { | 96 | bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) { |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index dab5b4fe4..e142bee35 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -598,10 +598,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 598 | } | 598 | } |
| 599 | logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld); | 599 | logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld); |
| 600 | 600 | ||
| 601 | is_integrated = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) != 0; | 601 | is_integrated = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU; |
| 602 | is_virtual = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) != 0; | 602 | is_virtual = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU; |
| 603 | is_non_gpu = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_OTHER) != 0 || | 603 | is_non_gpu = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_OTHER || |
| 604 | (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_CPU) != 0; | 604 | properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU; |
| 605 | 605 | ||
| 606 | CollectPhysicalMemoryInfo(); | 606 | CollectPhysicalMemoryInfo(); |
| 607 | CollectTelemetryParameters(); | 607 | CollectTelemetryParameters(); |
| @@ -1298,7 +1298,7 @@ void Device::CollectPhysicalMemoryInfo() { | |||
| 1298 | u64 local_memory = 0; | 1298 | u64 local_memory = 0; |
| 1299 | for (size_t element = 0; element < num_properties; ++element) { | 1299 | for (size_t element = 0; element < num_properties; ++element) { |
| 1300 | const bool is_heap_local = | 1300 | const bool is_heap_local = |
| 1301 | mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT != 0; | 1301 | (mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0; |
| 1302 | if (!is_integrated && !is_heap_local) { | 1302 | if (!is_integrated && !is_heap_local) { |
| 1303 | continue; | 1303 | continue; |
| 1304 | } | 1304 | } |
| @@ -1319,7 +1319,6 @@ void Device::CollectPhysicalMemoryInfo() { | |||
| 1319 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); | 1319 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); |
| 1320 | device_access_memory = static_cast<u64>(std::max<s64>( | 1320 | device_access_memory = static_cast<u64>(std::max<s64>( |
| 1321 | std::min<s64>(available_memory - 8_GiB, 4_GiB), static_cast<s64>(local_memory))); | 1321 | std::min<s64>(available_memory - 8_GiB, 4_GiB), static_cast<s64>(local_memory))); |
| 1322 | device_initial_usage = 0; | ||
| 1323 | } | 1322 | } |
| 1324 | 1323 | ||
| 1325 | void Device::CollectToolingInfo() { | 1324 | void Device::CollectToolingInfo() { |