GC: Address Feedback.
This commit is contained in:
parent
9edbbf2af4
commit
9872d4bc4f
|
@ -136,21 +136,17 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_)
|
||||||
glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY);
|
glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
device_access_memory = []() -> u64 {
|
device_access_memory = [this]() -> u64 {
|
||||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
if (device.CanReportMemoryUsage()) {
|
||||||
GLint cur_avail_mem_kb = 0;
|
return device.GetCurrentDedicatedVideoMemory() + 512_MiB;
|
||||||
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb);
|
|
||||||
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
|
||||||
}
|
}
|
||||||
return 2_GiB; // Return minimum requirements
|
return 2_GiB; // Return minimum requirements
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 BufferCacheRuntime::GetDeviceMemoryUsage() const {
|
u64 BufferCacheRuntime::GetDeviceMemoryUsage() const {
|
||||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
if (device.CanReportMemoryUsage()) {
|
||||||
GLint cur_avail_mem_kb = 0;
|
return device_access_memory - device.GetCurrentDedicatedVideoMemory();
|
||||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
|
|
||||||
return device_access_memory - static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
|
||||||
}
|
}
|
||||||
return 2_GiB;
|
return 2_GiB;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ public:
|
||||||
void BindImageBuffer(Buffer& buffer, u32 offset, u32 size,
|
void BindImageBuffer(Buffer& buffer, u32 offset, u32 size,
|
||||||
VideoCore::Surface::PixelFormat format);
|
VideoCore::Surface::PixelFormat format);
|
||||||
|
|
||||||
|
u64 GetDeviceMemoryUsage() const;
|
||||||
|
|
||||||
void BindFastUniformBuffer(size_t stage, u32 binding_index, u32 size) {
|
void BindFastUniformBuffer(size_t stage, u32 binding_index, u32 size) {
|
||||||
const GLuint handle = fast_uniforms[stage][binding_index].handle;
|
const GLuint handle = fast_uniforms[stage][binding_index].handle;
|
||||||
const GLsizeiptr gl_size = static_cast<GLsizeiptr>(size);
|
const GLsizeiptr gl_size = static_cast<GLsizeiptr>(size);
|
||||||
|
@ -155,10 +157,8 @@ public:
|
||||||
return device_access_memory;
|
return device_access_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetDeviceMemoryUsage() const;
|
|
||||||
|
|
||||||
bool CanReportMemoryUsage() const {
|
bool CanReportMemoryUsage() const {
|
||||||
return GLAD_GL_NVX_gpu_memory_info;
|
return device.CanReportMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -13,12 +13,15 @@
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
|
#include "common/literals.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "shader_recompiler/stage.h"
|
#include "shader_recompiler/stage.h"
|
||||||
#include "video_core/renderer_opengl/gl_device.h"
|
#include "video_core/renderer_opengl/gl_device.h"
|
||||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||||
|
|
||||||
|
using namespace Common::Literals;
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr std::array LIMIT_UBOS = {
|
constexpr std::array LIMIT_UBOS = {
|
||||||
|
@ -165,6 +168,7 @@ Device::Device() {
|
||||||
has_sparse_texture_2 = GLAD_GL_ARB_sparse_texture2;
|
has_sparse_texture_2 = GLAD_GL_ARB_sparse_texture2;
|
||||||
warp_size_potentially_larger_than_guest = !is_nvidia && !is_intel;
|
warp_size_potentially_larger_than_guest = !is_nvidia && !is_intel;
|
||||||
need_fastmath_off = is_nvidia;
|
need_fastmath_off = is_nvidia;
|
||||||
|
can_report_memory = GLAD_GL_NVX_gpu_memory_info;
|
||||||
|
|
||||||
// At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive
|
// At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive
|
||||||
// uniform buffers as "push constants"
|
// uniform buffers as "push constants"
|
||||||
|
@ -276,4 +280,10 @@ void main() {
|
||||||
})");
|
})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 Device::GetCurrentDedicatedVideoMemory() const {
|
||||||
|
GLint cur_avail_mem_kb = 0;
|
||||||
|
glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &cur_avail_mem_kb);
|
||||||
|
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
|
@ -20,6 +20,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] std::string GetVendorName() const;
|
[[nodiscard]] std::string GetVendorName() const;
|
||||||
|
|
||||||
|
u64 GetCurrentDedicatedVideoMemory() const;
|
||||||
|
|
||||||
u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept {
|
u32 GetMaxUniformBuffers(Shader::Stage stage) const noexcept {
|
||||||
return max_uniform_buffers[static_cast<size_t>(stage)];
|
return max_uniform_buffers[static_cast<size_t>(stage)];
|
||||||
}
|
}
|
||||||
|
@ -168,6 +170,10 @@ public:
|
||||||
return vendor_name == "ATI Technologies Inc.";
|
return vendor_name == "ATI Technologies Inc.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanReportMemoryUsage() const {
|
||||||
|
return can_report_memory;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool TestVariableAoffi();
|
static bool TestVariableAoffi();
|
||||||
static bool TestPreciseBug();
|
static bool TestPreciseBug();
|
||||||
|
@ -210,6 +216,7 @@ private:
|
||||||
bool need_fastmath_off{};
|
bool need_fastmath_off{};
|
||||||
bool has_cbuf_ftou_bug{};
|
bool has_cbuf_ftou_bug{};
|
||||||
bool has_bool_ref_bug{};
|
bool has_bool_ref_bug{};
|
||||||
|
bool can_report_memory{};
|
||||||
|
|
||||||
std::string vendor_name;
|
std::string vendor_name;
|
||||||
};
|
};
|
||||||
|
|
|
@ -485,11 +485,9 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device_access_memory = []() -> u64 {
|
device_access_memory = [this]() -> u64 {
|
||||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
if (device.CanReportMemoryUsage()) {
|
||||||
GLint cur_avail_mem_kb = 0;
|
return device.GetCurrentDedicatedVideoMemory() + 512_MiB;
|
||||||
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb);
|
|
||||||
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
|
||||||
}
|
}
|
||||||
return 2_GiB; // Return minimum requirements
|
return 2_GiB; // Return minimum requirements
|
||||||
}();
|
}();
|
||||||
|
@ -510,10 +508,8 @@ ImageBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 TextureCacheRuntime::GetDeviceMemoryUsage() const {
|
u64 TextureCacheRuntime::GetDeviceMemoryUsage() const {
|
||||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
if (device.CanReportMemoryUsage()) {
|
||||||
GLint cur_avail_mem_kb = 0;
|
return device_access_memory - device.GetCurrentDedicatedVideoMemory();
|
||||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
|
|
||||||
return device_access_memory - static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
|
||||||
}
|
}
|
||||||
return 2_GiB;
|
return 2_GiB;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
#include "shader_recompiler/shader_info.h"
|
#include "shader_recompiler/shader_info.h"
|
||||||
|
#include "video_core/renderer_opengl/gl_device.h"
|
||||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||||
#include "video_core/renderer_opengl/util_shaders.h"
|
#include "video_core/renderer_opengl/util_shaders.h"
|
||||||
#include "video_core/texture_cache/image_view_base.h"
|
#include "video_core/texture_cache/image_view_base.h"
|
||||||
|
@ -21,7 +22,6 @@ struct ResolutionScalingInfo;
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
class Device;
|
|
||||||
class ProgramManager;
|
class ProgramManager;
|
||||||
class StateTracker;
|
class StateTracker;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public:
|
||||||
u64 GetDeviceMemoryUsage() const;
|
u64 GetDeviceMemoryUsage() const;
|
||||||
|
|
||||||
bool CanReportMemoryUsage() const {
|
bool CanReportMemoryUsage() const {
|
||||||
return GLAD_GL_NVX_gpu_memory_info;
|
return device.CanReportMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) {
|
bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) {
|
||||||
|
|
|
@ -598,10 +598,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
||||||
}
|
}
|
||||||
logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld);
|
logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld);
|
||||||
|
|
||||||
is_integrated = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) != 0;
|
is_integrated = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
||||||
is_virtual = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) != 0;
|
is_virtual = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU;
|
||||||
is_non_gpu = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_OTHER) != 0 ||
|
is_non_gpu = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_OTHER ||
|
||||||
(properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_CPU) != 0;
|
properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
||||||
|
|
||||||
CollectPhysicalMemoryInfo();
|
CollectPhysicalMemoryInfo();
|
||||||
CollectTelemetryParameters();
|
CollectTelemetryParameters();
|
||||||
|
@ -1298,7 +1298,7 @@ void Device::CollectPhysicalMemoryInfo() {
|
||||||
u64 local_memory = 0;
|
u64 local_memory = 0;
|
||||||
for (size_t element = 0; element < num_properties; ++element) {
|
for (size_t element = 0; element < num_properties; ++element) {
|
||||||
const bool is_heap_local =
|
const bool is_heap_local =
|
||||||
mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT != 0;
|
(mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0;
|
||||||
if (!is_integrated && !is_heap_local) {
|
if (!is_integrated && !is_heap_local) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1319,6 @@ void Device::CollectPhysicalMemoryInfo() {
|
||||||
const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage);
|
const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage);
|
||||||
device_access_memory = static_cast<u64>(std::max<s64>(
|
device_access_memory = static_cast<u64>(std::max<s64>(
|
||||||
std::min<s64>(available_memory - 8_GiB, 4_GiB), static_cast<s64>(local_memory)));
|
std::min<s64>(available_memory - 8_GiB, 4_GiB), static_cast<s64>(local_memory)));
|
||||||
device_initial_usage = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::CollectToolingInfo() {
|
void Device::CollectToolingInfo() {
|
||||||
|
|
Loading…
Reference in New Issue