summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-13 05:21:39 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-13 05:21:39 +0000
commite2ce5c693d11b348ee56d7e4357df77ab9d3bcde (patch)
tree5cebddeffd87d0cb7845d1a9c988f4115808b25a /Graphics/GraphicsEngineVulkan
parentMoved Features member of EngineCreateInfo struct to fix misalignment error on... (diff)
downloadDiligentCore-e2ce5c693d11b348ee56d7e4357df77ab9d3bcde.tar.gz
DiligentCore-e2ce5c693d11b348ee56d7e4357df77ab9d3bcde.zip
Vk backend: fixed detection of enabled/disabled features
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.hpp3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp17
-rw-r--r--Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp41
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp3
5 files changed, 39 insertions, 31 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.hpp b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.hpp
index d4a6bcb6..3f06cb0e 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.hpp
@@ -209,6 +209,8 @@ public:
VkPipelineStageFlags GetEnabledGraphicsShaderStages() const { return m_EnabledGraphicsShaderStages; }
+ const VkPhysicalDeviceFeatures& GetEnabledFeatures() const { return m_EnabledFeatures; }
+
private:
VulkanLogicalDevice(VkPhysicalDevice vkPhysicalDevice,
const VkDeviceCreateInfo& DeviceCI,
@@ -226,6 +228,7 @@ private:
VkDevice m_VkDevice = VK_NULL_HANDLE;
const VkAllocationCallbacks* const m_VkAllocator;
VkPipelineStageFlags m_EnabledGraphicsShaderStages = 0;
+ const VkPhysicalDeviceFeatures m_EnabledFeatures;
};
} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
index 4dee23de..35db310b 100644
--- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
@@ -238,14 +238,17 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E
// Enable mesh shader extension.
bool MeshShadersSupported = false;
#ifdef VK_NV_mesh_shader
- VkPhysicalDeviceMeshShaderFeaturesNV MeshShaderFeats = PhysicalDevice->GetExtFeatures().MeshShader;
-
- if (SupportsFeatures2 && PhysicalDevice->IsExtensionSupported(VK_NV_MESH_SHADER_EXTENSION_NAME))
+ if (EngineCI.Features.MeshShaders != DEVICE_FEATURE_STATE_DISABLED)
{
- MeshShadersSupported = true;
- DeviceExtensions.push_back(VK_NV_MESH_SHADER_EXTENSION_NAME);
- *NextExt = &MeshShaderFeats;
- NextExt = &MeshShaderFeats.pNext;
+ VkPhysicalDeviceMeshShaderFeaturesNV MeshShaderFeats = PhysicalDevice->GetExtFeatures().MeshShader;
+
+ if (SupportsFeatures2 && PhysicalDevice->IsExtensionSupported(VK_NV_MESH_SHADER_EXTENSION_NAME))
+ {
+ MeshShadersSupported = true;
+ DeviceExtensions.push_back(VK_NV_MESH_SHADER_EXTENSION_NAME);
+ *NextExt = &MeshShaderFeats;
+ NextExt = &MeshShaderFeats.pNext;
+ }
}
#endif
diff --git a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
index f56f58f2..fb09687b 100644
--- a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
@@ -48,12 +48,12 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk,
VkCommandBuffer vkCmdBuff;
pRenderDeviceVk->AllocateTransientCmdPool(CmdPool, vkCmdBuff, "Transient command pool to reset queries before first use");
- const auto& deviceFeatures = PhysicalDevice.GetFeatures();
+ const auto& EnabledFeatures = LogicalDevice.GetEnabledFeatures();
for (Uint32 QueryType = QUERY_TYPE_UNDEFINED + 1; QueryType < QUERY_TYPE_NUM_TYPES; ++QueryType)
{
- if ((QueryType == QUERY_TYPE_OCCLUSION && !deviceFeatures.occlusionQueryPrecise) ||
- (QueryType == QUERY_TYPE_PIPELINE_STATISTICS && !deviceFeatures.pipelineStatisticsQuery))
+ if ((QueryType == QUERY_TYPE_OCCLUSION && !EnabledFeatures.occlusionQueryPrecise) ||
+ (QueryType == QUERY_TYPE_PIPELINE_STATISTICS && !EnabledFeatures.pipelineStatisticsQuery))
continue;
// clang-format off
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index 01ef7447..863197bb 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -159,13 +159,14 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
for (Uint32 fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)
m_TextureFormatsInfo[fmt].Supported = true; // We will test every format on a specific hardware device
- auto& Features = m_DeviceCaps.Features;
- const auto& vkDeviceFeatures = m_PhysicalDevice->GetFeatures();
- const auto& vkExtFeatures = m_PhysicalDevice->GetExtFeatures();
+ auto& Features = m_DeviceCaps.Features;
+ const auto& vkExtFeatures = m_PhysicalDevice->GetExtFeatures();
// May be unused if extensions are disabled.
(void)(vkExtFeatures);
+ const auto& vkEnabledFeatures = m_LogicalVkDevice->GetEnabledFeatures();
+
auto GetFeatureState = [](VkBool32 vkFeatureState) //
{
return vkFeatureState != VK_FALSE ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED;
@@ -173,30 +174,30 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
Features.SeparablePrograms = DEVICE_FEATURE_STATE_ENABLED;
Features.IndirectRendering = DEVICE_FEATURE_STATE_ENABLED;
- Features.WireframeFill = GetFeatureState(vkDeviceFeatures.fillModeNonSolid);
+ Features.WireframeFill = GetFeatureState(vkEnabledFeatures.fillModeNonSolid);
Features.MultithreadedResourceCreation = DEVICE_FEATURE_STATE_ENABLED;
Features.ComputeShaders = DEVICE_FEATURE_STATE_ENABLED;
- Features.GeometryShaders = GetFeatureState(vkDeviceFeatures.geometryShader);
- Features.Tessellation = GetFeatureState(vkDeviceFeatures.tessellationShader);
+ Features.GeometryShaders = GetFeatureState(vkEnabledFeatures.geometryShader);
+ Features.Tessellation = GetFeatureState(vkEnabledFeatures.tessellationShader);
Features.BindlessResources = DEVICE_FEATURE_STATE_ENABLED;
- Features.OcclusionQueries = GetFeatureState(vkDeviceFeatures.occlusionQueryPrecise);
+ Features.OcclusionQueries = GetFeatureState(vkEnabledFeatures.occlusionQueryPrecise);
Features.BinaryOcclusionQueries = DEVICE_FEATURE_STATE_ENABLED;
Features.TimestampQueries = DEVICE_FEATURE_STATE_ENABLED;
Features.DurationQueries = DEVICE_FEATURE_STATE_ENABLED;
- Features.PipelineStatisticsQueries = GetFeatureState(vkDeviceFeatures.pipelineStatisticsQuery);
- Features.DepthBiasClamp = GetFeatureState(vkDeviceFeatures.depthBiasClamp);
- Features.DepthClamp = GetFeatureState(vkDeviceFeatures.depthClamp);
- Features.IndependentBlend = GetFeatureState(vkDeviceFeatures.independentBlend);
- Features.DualSourceBlend = GetFeatureState(vkDeviceFeatures.dualSrcBlend);
- Features.MultiViewport = GetFeatureState(vkDeviceFeatures.multiViewport);
- Features.TextureCompressionBC = GetFeatureState(vkDeviceFeatures.textureCompressionBC);
- Features.VertexPipelineUAVWritesAndAtomics = GetFeatureState(vkDeviceFeatures.vertexPipelineStoresAndAtomics);
- Features.PixelUAVWritesAndAtomics = GetFeatureState(vkDeviceFeatures.fragmentStoresAndAtomics);
- Features.TextureUAVExtendedFormats = GetFeatureState(vkDeviceFeatures.shaderStorageImageExtendedFormats);
+ Features.PipelineStatisticsQueries = GetFeatureState(vkEnabledFeatures.pipelineStatisticsQuery);
+ Features.DepthBiasClamp = GetFeatureState(vkEnabledFeatures.depthBiasClamp);
+ Features.DepthClamp = GetFeatureState(vkEnabledFeatures.depthClamp);
+ Features.IndependentBlend = GetFeatureState(vkEnabledFeatures.independentBlend);
+ Features.DualSourceBlend = GetFeatureState(vkEnabledFeatures.dualSrcBlend);
+ Features.MultiViewport = GetFeatureState(vkEnabledFeatures.multiViewport);
+ Features.TextureCompressionBC = GetFeatureState(vkEnabledFeatures.textureCompressionBC);
+ Features.VertexPipelineUAVWritesAndAtomics = GetFeatureState(vkEnabledFeatures.vertexPipelineStoresAndAtomics);
+ Features.PixelUAVWritesAndAtomics = GetFeatureState(vkEnabledFeatures.fragmentStoresAndAtomics);
+ Features.TextureUAVExtendedFormats = GetFeatureState(vkEnabledFeatures.shaderStorageImageExtendedFormats);
#ifdef VK_NV_mesh_shader
// All devices that support mesh shaders also support task shaders, so it is not necessary to use two separate features.
- Features.MeshShaders = GetFeatureState(vkExtFeatures.MeshShader.meshShader != VK_FALSE && vkExtFeatures.MeshShader.taskShader != VK_FALSE);
+ Features.MeshShaders = GetFeatureState(EngineCI.Features.MeshShaders != DEVICE_FEATURE_STATE_DISABLED && vkExtFeatures.MeshShader.meshShader != VK_FALSE && vkExtFeatures.MeshShader.taskShader != VK_FALSE);
#else
Features.MeshShaders = DEVICE_FEATURE_STATE_DISABLED;
#endif
@@ -217,13 +218,13 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
TexCaps.Texture2DMSSupported = True;
TexCaps.Texture2DMSArraySupported = True;
TexCaps.TextureViewSupported = True;
- TexCaps.CubemapArraysSupported = vkDeviceFeatures.imageCubeArray;
+ TexCaps.CubemapArraysSupported = vkEnabledFeatures.imageCubeArray;
auto& SamCaps = m_DeviceCaps.SamCaps;
SamCaps.BorderSamplingModeSupported = True;
- SamCaps.AnisotropicFilteringSupported = vkDeviceFeatures.samplerAnisotropy;
+ SamCaps.AnisotropicFilteringSupported = vkEnabledFeatures.samplerAnisotropy;
SamCaps.LODBiasSupported = True;
}
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
index 29a8a836..5b720fd7 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
@@ -50,7 +50,8 @@ VulkanLogicalDevice::~VulkanLogicalDevice()
VulkanLogicalDevice::VulkanLogicalDevice(VkPhysicalDevice vkPhysicalDevice,
const VkDeviceCreateInfo& DeviceCI,
const VkAllocationCallbacks* vkAllocator) :
- m_VkAllocator{vkAllocator}
+ m_VkAllocator{vkAllocator},
+ m_EnabledFeatures{*DeviceCI.pEnabledFeatures}
{
auto res = vkCreateDevice(vkPhysicalDevice, &DeviceCI, vkAllocator, &m_VkDevice);
CHECK_VK_ERROR_AND_THROW(res, "Failed to create logical device");