summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
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/GraphicsEngineVulkan
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/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp39
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp2
2 files changed, 39 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index ccbc8e5f..87bb60e2 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -155,7 +155,44 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
m_DeviceCaps.DevType = RENDER_DEVICE_TYPE_VULKAN;
m_DeviceCaps.MajorVersion = 1;
m_DeviceCaps.MinorVersion = 0;
- m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE;
+
+ auto& AdapterInfo = m_DeviceCaps.AdapterInfo;
+
+ const auto& DeviceProps = m_PhysicalDevice->GetProperties();
+
+ AdapterInfo.Vendor = VendorIdToAdapterVendor(DeviceProps.vendorID);
+ AdapterInfo.Type = ADAPTER_TYPE_HARDWARE;
+ AdapterInfo.DeviceLocalMemory = 0;
+ AdapterInfo.HostVisibileMemory = 0;
+ AdapterInfo.UnifiedMemory = 0;
+
+ const auto& MemoryProps = m_PhysicalDevice->GetMemoryProperties();
+ for (uint32_t heap = 0; heap < MemoryProps.memoryHeapCount; ++heap)
+ {
+ const auto& HeapInfo = MemoryProps.memoryHeaps[heap];
+ if (HeapInfo.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
+ {
+ bool IsUnified = false;
+ for (uint32_t type = 0; type < MemoryProps.memoryTypeCount; ++type)
+ {
+ const auto& MemTypeInfo = MemoryProps.memoryTypes[type];
+ if (MemTypeInfo.heapIndex != heap)
+ continue;
+ constexpr auto UnifiedMemoryFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
+ if ((MemTypeInfo.propertyFlags & UnifiedMemoryFlags) == UnifiedMemoryFlags)
+ {
+ IsUnified = true;
+ break;
+ }
+ }
+ (IsUnified ? AdapterInfo.UnifiedMemory : AdapterInfo.DeviceLocalMemory) += static_cast<Uint64>(HeapInfo.size);
+ }
+ else
+ {
+ AdapterInfo.HostVisibileMemory += static_cast<Uint64>(HeapInfo.size);
+ }
+ }
+
for (Uint32 fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)
m_TextureFormatsInfo[fmt].Supported = true; // We will test every format on a specific hardware device
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index c16010d8..a094f014 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -81,7 +81,7 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters,
{
auto* pDXComiler = pRenderDeviceVk->GetDxCompiler();
VERIFY_EXPR(pDXComiler != nullptr && pDXComiler->IsLoaded());
- pDXComiler->Compile(CreationAttribs, VulkanDefine, nullptr, &m_SPIRV, CreationAttribs.ppCompilerOutput);
+ pDXComiler->Compile(CreationAttribs, ShaderVersion{}, VulkanDefine, nullptr, &m_SPIRV, CreationAttribs.ppCompilerOutput);
}
break;