summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-24 02:38:45 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-24 02:38:45 +0000
commit5ebcd32a284a7c2cc79e4a88349d66b392f13d52 (patch)
treed47274650a8fcd2d5064dd5af4985406e78cd80f /Graphics/GraphicsEngineVulkan
parentBinding null sampler handler when no sampler is assigned to texture SRV and n... (diff)
downloadDiligentCore-5ebcd32a284a7c2cc79e4a88349d66b392f13d52.tar.gz
DiligentCore-5ebcd32a284a7c2cc79e4a88349d66b392f13d52.zip
Disabling requested vulkand device features if they are not supported by physical device
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h1
-rw-r--r--Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp48
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp7
3 files changed, 36 insertions, 20 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
index df31c2e1..7056268f 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
@@ -47,6 +47,7 @@ namespace VulkanUtilities
static constexpr uint32_t InvalidMemoryTypeIndex = static_cast<uint32_t>(-1);
uint32_t GetMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties)const;
const VkPhysicalDeviceProperties& GetProperties() const {return m_Properties;}
+ const VkPhysicalDeviceFeatures& GetFeatures() const {return m_Features; }
private:
VulkanPhysicalDevice(VkPhysicalDevice vkDevice);
diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
index 7f5a4fee..40db1ccf 100644
--- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
@@ -83,7 +83,7 @@ public:
/// the contexts will be written. Immediate context goes at
/// position 0. If EngineCI.NumDeferredContexts > 0,
/// pointers to the deferred contexts are written afterwards.
-void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& EngineCI,
+void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _EngineCI,
IRenderDevice** ppDevice,
IDeviceContext** ppContexts)
{
@@ -91,6 +91,8 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En
if( !ppDevice || !ppContexts )
return;
+ EngineVkCreateInfo EngineCI = _EngineCI;
+
#if 0
for (Uint32 Type = Vk_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; Type < Vk_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++Type)
{
@@ -125,6 +127,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En
auto vkDevice = Instance->SelectPhysicalDevice();
auto PhysicalDevice = VulkanUtilities::VulkanPhysicalDevice::Create(vkDevice);
+ const auto& PhysicalDeviceFeatures = PhysicalDevice->GetFeatures();
// If an implementation exposes any queue family that supports graphics operations,
// at least one queue family of at least one physical device exposed by the implementation
@@ -151,20 +154,35 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En
DeviceCreateInfo.queueCreateInfoCount = 1;
DeviceCreateInfo.pQueueCreateInfos = &QueueInfo;
VkPhysicalDeviceFeatures DeviceFeatures = {};
- DeviceFeatures.depthBiasClamp = EngineCI.EnabledFeatures.depthBiasClamp ? VK_TRUE : VK_FALSE;
- DeviceFeatures.fillModeNonSolid = EngineCI.EnabledFeatures.fillModeNonSolid ? VK_TRUE : VK_FALSE;
- DeviceFeatures.depthClamp = EngineCI.EnabledFeatures.depthClamp ? VK_TRUE : VK_FALSE;
- DeviceFeatures.independentBlend = EngineCI.EnabledFeatures.independentBlend ? VK_TRUE : VK_FALSE;
- DeviceFeatures.samplerAnisotropy = EngineCI.EnabledFeatures.samplerAnisotropy ? VK_TRUE : VK_FALSE;
- DeviceFeatures.geometryShader = EngineCI.EnabledFeatures.geometryShader ? VK_TRUE : VK_FALSE;
- DeviceFeatures.tessellationShader = EngineCI.EnabledFeatures.tessellationShader ? VK_TRUE : VK_FALSE;
- DeviceFeatures.dualSrcBlend = EngineCI.EnabledFeatures.dualSrcBlend ? VK_TRUE : VK_FALSE;
- DeviceFeatures.multiViewport = EngineCI.EnabledFeatures.multiViewport ? VK_TRUE : VK_FALSE;
- DeviceFeatures.imageCubeArray = EngineCI.EnabledFeatures.imageCubeArray ? VK_TRUE : VK_FALSE;
- DeviceFeatures.textureCompressionBC = EngineCI.EnabledFeatures.textureCompressionBC ? VK_TRUE : VK_FALSE;
- DeviceFeatures.vertexPipelineStoresAndAtomics = EngineCI.EnabledFeatures.vertexPipelineStoresAndAtomics ? VK_TRUE : VK_FALSE;
- DeviceFeatures.fragmentStoresAndAtomics = EngineCI.EnabledFeatures.fragmentStoresAndAtomics ? VK_TRUE : VK_FALSE;
- DeviceFeatures.shaderStorageImageExtendedFormats = EngineCI.EnabledFeatures.shaderStorageImageExtendedFormats ? VK_TRUE : VK_FALSE;
+
+#define ENABLE_FEATURE(Feature)\
+ if (EngineCI.EnabledFeatures.Feature)\
+ { \
+ if (PhysicalDeviceFeatures.Feature) \
+ DeviceFeatures.Feature = VK_TRUE; \
+ else \
+ { \
+ LOG_WARNING_MESSAGE("Requested device feature " #Feature " is not supported by the physical device and will be disabled");\
+ EngineCI.EnabledFeatures.Feature = false; \
+ } \
+ }
+
+ ENABLE_FEATURE(depthBiasClamp)
+ ENABLE_FEATURE(fillModeNonSolid)
+ ENABLE_FEATURE(depthClamp)
+ ENABLE_FEATURE(independentBlend)
+ ENABLE_FEATURE(samplerAnisotropy)
+ ENABLE_FEATURE(geometryShader)
+ ENABLE_FEATURE(tessellationShader)
+ ENABLE_FEATURE(dualSrcBlend)
+ ENABLE_FEATURE(multiViewport)
+ ENABLE_FEATURE(imageCubeArray)
+ ENABLE_FEATURE(textureCompressionBC)
+ ENABLE_FEATURE(vertexPipelineStoresAndAtomics)
+ ENABLE_FEATURE(fragmentStoresAndAtomics)
+ ENABLE_FEATURE(shaderStorageImageExtendedFormats)
+#undef ENABLE_FEATURE
+
DeviceCreateInfo.pEnabledFeatures = &DeviceFeatures; // NULL or a pointer to a VkPhysicalDeviceFeatures structure that contains
// boolean indicators of all the features to be enabled.
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index 2870b0d4..e31acc55 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -126,11 +126,8 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters*
for(int fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)
m_TextureFormatsInfo[fmt].Supported = true; // We will test every format on a specific hardware device
-#if PLATFORM_MACOS || PLATFORM_IOS
- // MoltenVK does not support geometry shaders and tessellation
- m_DeviceCaps.bGeometryShadersSupported = False;
- m_DeviceCaps.bTessellationSupported = False;
-#endif
+ m_DeviceCaps.bGeometryShadersSupported = EngineCI.EnabledFeatures.geometryShader;
+ m_DeviceCaps.bTessellationSupported = EngineCI.EnabledFeatures.tessellationShader;
}
RenderDeviceVkImpl::~RenderDeviceVkImpl()