summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-16 23:11:56 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-16 23:11:56 +0000
commit0cc841bc76eda21793f2a158b0ededad5a5ae3bf (patch)
tree39e1f2bee602263336754d990eaab557f16b98d6 /Graphics/GraphicsEngineOpenGL
parentAnother improvement to texture format tests in OpenGL (diff)
downloadDiligentCore-0cc841bc76eda21793f2a158b0ededad5a5ae3bf.tar.gz
DiligentCore-0cc841bc76eda21793f2a158b0ededad5a5ae3bf.zip
Added GPU vendor and memory size detection (API 240071), closed https://github.com/DiligentGraphics/DiligentCore/issues/144.
Fixed shader model selection in D3D12 backend
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp18
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp60
2 files changed, 54 insertions, 24 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp
index 946ef34b..afb46edb 100644
--- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp
+++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp
@@ -35,20 +35,6 @@
#include "FBOCache.hpp"
#include "TexRegionRender.hpp"
-enum class GPU_VENDOR
-{
- UNKNOWN,
- INTEL,
- ATI,
- NVIDIA,
- QUALCOMM
-};
-
-struct GPUInfo
-{
- GPU_VENDOR Vendor = GPU_VENDOR::UNKNOWN;
-};
-
namespace Diligent
{
@@ -145,8 +131,6 @@ public:
/// Implementation of IRenderDevice::IdleGPU() in OpenGL backend.
virtual void DILIGENT_CALL_TYPE IdleGPU() override final;
- const GPUInfo& GetGPUInfo() { return m_GPUInfo; }
-
FBOCache& GetFBOCache(GLContext::NativeGLContextType Context);
void OnReleaseTexture(ITexture* pTexture);
@@ -180,8 +164,6 @@ protected:
ThreadingTools::LockFlag m_FBOCacheLockFlag;
std::unordered_map<GLContext::NativeGLContextType, FBOCache> m_FBOCache;
- GPUInfo m_GPUInfo;
-
std::unique_ptr<TexRegionRender> m_pTexRegionRender;
private:
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 970dc49e..ed6c3705 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -196,17 +196,65 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
std::string Vendor = StrToLower(std::string(glstrVendor.begin(), glstrVendor.end()));
LOG_INFO_MESSAGE("GPU Vendor: ", Vendor);
+ auto& AdapterInfo = m_DeviceCaps.AdapterInfo;
+
+ AdapterInfo.Type = ADAPTER_TYPE_HARDWARE;
+ AdapterInfo.DeviceLocalMemory = 0;
+ AdapterInfo.HostVisibileMemory = 0;
+ AdapterInfo.UnifiedMemory = 0;
+
if (Vendor.find("intel") != std::string::npos)
- m_GPUInfo.Vendor = GPU_VENDOR::INTEL;
+ AdapterInfo.Vendor = ADAPTER_VENDOR_INTEL;
else if (Vendor.find("nvidia") != std::string::npos)
- m_GPUInfo.Vendor = GPU_VENDOR::NVIDIA;
+ {
+ AdapterInfo.Vendor = ADAPTER_VENDOR_NVIDIA;
+
+#ifndef GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX
+ static constexpr GLenum GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX = 0x9048;
+#endif
+
+ GLint AvailableMemoryKb = 0;
+ glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX, &AvailableMemoryKb);
+ if (glGetError() == GL_NO_ERROR)
+ {
+ AdapterInfo.DeviceLocalMemory = static_cast<Uint64>(AvailableMemoryKb) * Uint64{1024};
+ }
+ else
+ {
+ LOG_WARNING_MESSAGE("Unable to read available memory size for NVidia GPU");
+ }
+ }
else if (Vendor.find("ati") != std::string::npos ||
Vendor.find("amd") != std::string::npos)
- m_GPUInfo.Vendor = GPU_VENDOR::ATI;
- else if (Vendor.find("qualcomm"))
- m_GPUInfo.Vendor = GPU_VENDOR::QUALCOMM;
+ {
+ AdapterInfo.Vendor = ADAPTER_VENDOR_AMD;
- m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE;
+#ifndef GL_TEXTURE_FREE_MEMORY_ATI
+ static constexpr GLenum GL_TEXTURE_FREE_MEMORY_ATI = 0x87FC;
+#endif
+ // https://www.khronos.org/registry/OpenGL/extensions/ATI/ATI_meminfo.txt
+ // param[0] - total memory free in the pool
+ // param[1] - largest available free block in the pool
+ // param[2] - total auxiliary memory free
+ // param[3] - largest auxiliary free block
+ GLint MemoryParamsKb[4] = {};
+
+ glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, MemoryParamsKb);
+ if (glGetError() == GL_NO_ERROR)
+ {
+ AdapterInfo.DeviceLocalMemory = static_cast<Uint64>(MemoryParamsKb[0]) * Uint64{1024};
+ }
+ else
+ {
+ LOG_WARNING_MESSAGE("Unable to read free memory size for AMD GPU");
+ }
+ }
+ else if (Vendor.find("qualcomm"))
+ AdapterInfo.Vendor = ADAPTER_VENDOR_QUALCOMM;
+ else if (Vendor.find("arm"))
+ AdapterInfo.Vendor = ADAPTER_VENDOR_ARM;
+ else
+ AdapterInfo.Vendor = ADAPTER_VENDOR_UNKNOWN;
auto MajorVersion = m_DeviceCaps.MajorVersion;
auto MinorVersion = m_DeviceCaps.MinorVersion;