summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-17 06:37:13 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-17 06:37:13 +0000
commit5046c0ae9c0c951d47a3396791c71e94d193c1ce (patch)
tree7a379cf3fcf0697f4eb7a28b0d02ba89c090f212 /Graphics/GraphicsEngineVulkan
parentUpdated draw test command reference image to be quad instead of a triangle (diff)
downloadDiligentCore-5046c0ae9c0c951d47a3396791c71e94d193c1ce.tar.gz
DiligentCore-5046c0ae9c0c951d47a3396791c71e94d193c1ce.zip
Enabled draw command reference in Vulkan
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h16
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp9
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp42
5 files changed, 45 insertions, 31 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
index 52051652..8fd3c38a 100644
--- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
@@ -91,6 +91,9 @@ public:
/// Implementation of IRenderDeviceVk::GetVkDevice().
virtual VkDevice GetVkDevice() override final { return m_LogicalVkDevice->GetVkDevice(); }
+ /// Implementation of IRenderDeviceVk::GetVkPhysicalDevice().
+ virtual VkPhysicalDevice GetVkPhysicalDevice() override final { return m_PhysicalDevice->GetVkDeviceHandle(); }
+
/// Implementation of IRenderDeviceVk::CreateTextureFromVulkanImage().
virtual void CreateTextureFromVulkanImage(VkImage vkImage, const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture) override final;
@@ -117,10 +120,12 @@ public:
DescriptorPoolManager& GetDynamicDescriptorPool() { return m_DynamicDescriptorPool; }
std::shared_ptr<const VulkanUtilities::VulkanInstance> GetVulkanInstance() const { return m_VulkanInstance; }
- const VulkanUtilities::VulkanPhysicalDevice& GetPhysicalDevice() const { return *m_PhysicalDevice; }
- const VulkanUtilities::VulkanLogicalDevice& GetLogicalDevice() { return *m_LogicalVkDevice; }
- FramebufferCache& GetFramebufferCache() { return m_FramebufferCache; }
- RenderPassCache& GetRenderPassCache() { return m_RenderPassCache; }
+
+ const VulkanUtilities::VulkanPhysicalDevice& GetPhysicalDevice() const { return *m_PhysicalDevice; }
+ const VulkanUtilities::VulkanLogicalDevice& GetLogicalDevice() { return *m_LogicalVkDevice; }
+
+ FramebufferCache& GetFramebufferCache() { return m_FramebufferCache; }
+ RenderPassCache& GetRenderPassCache() { return m_RenderPassCache; }
VulkanUtilities::VulkanMemoryAllocation AllocateMemory(const VkMemoryRequirements& MemReqs, VkMemoryPropertyFlags MemoryProperties)
{
@@ -129,7 +134,8 @@ public:
VulkanUtilities::VulkanMemoryManager& GetGlobalMemoryManager() { return m_MemoryMgr; }
VulkanDynamicMemoryManager& GetDynamicMemoryManager() { return m_DynamicMemoryManager; }
- void FlushStaleResources(Uint32 CmdQueueIndex);
+
+ void FlushStaleResources(Uint32 CmdQueueIndex);
private:
virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) override final;
diff --git a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
index 785950a3..bf216af3 100644
--- a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
@@ -42,6 +42,9 @@ public:
/// Returns logical Vulkan device handle
virtual VkDevice GetVkDevice() = 0;
+ /// Returns physical Vulkan device
+ virtual VkPhysicalDevice GetVkPhysicalDevice() = 0;
+
/// Returns the fence value that will be signaled by the GPU command queue next
virtual Uint64 GetNextFenceValue(Uint32 QueueIndex) = 0;
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 3eb7851d..23315a6a 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -145,9 +145,9 @@ static std::vector<uint32_t> StripReflection(const std::vector<uint32_t>& Origin
return StrippedSPIRV;
}
-PipelineStateVkImpl ::PipelineStateVkImpl(IReferenceCounters* pRefCounters,
- RenderDeviceVkImpl* pDeviceVk,
- const PipelineStateDesc& PipelineDesc) :
+PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceVkImpl* pDeviceVk,
+ const PipelineStateDesc& PipelineDesc) :
TPipelineStateBase{pRefCounters, pDeviceVk, PipelineDesc},
m_SRBMemAllocator{GetRawAllocator()}
{
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 8ad01c6b..2fb5e2d6 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -63,8 +63,13 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters,
}
else
{
- auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pRenderDeviceVk->GetDeviceCaps(), TargetGLSLCompiler::glslang, "#define TARGET_API_VULKAN 1\n");
- m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(), static_cast<int>(GLSLSource.length()), CreationAttribs.ppCompilerOutput);
+ auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pRenderDeviceVk->GetDeviceCaps(),
+ TargetGLSLCompiler::glslang,
+ "#define TARGET_API_VULKAN 1\n");
+
+ m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(),
+ static_cast<int>(GLSLSource.length()),
+ CreationAttribs.ppCompilerOutput);
}
if (m_SPIRV.empty())
diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
index 13c090e0..3ebe8579 100644
--- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
@@ -276,20 +276,20 @@ TextureVkImpl ::TextureVkImpl(IReferenceCounters* pRefCounters,
}
VERIFY_EXPR(subres == pInitData->NumSubresources);
- VkBufferCreateInfo VkStaginBuffCI = {};
- VkStaginBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- VkStaginBuffCI.pNext = nullptr;
- VkStaginBuffCI.flags = 0;
- VkStaginBuffCI.size = uploadBufferSize;
- VkStaginBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
- VkStaginBuffCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- VkStaginBuffCI.queueFamilyIndexCount = 0;
- VkStaginBuffCI.pQueueFamilyIndices = nullptr;
+ VkBufferCreateInfo VkStagingBuffCI = {};
+ VkStagingBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ VkStagingBuffCI.pNext = nullptr;
+ VkStagingBuffCI.flags = 0;
+ VkStagingBuffCI.size = uploadBufferSize;
+ VkStagingBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ VkStagingBuffCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ VkStagingBuffCI.queueFamilyIndexCount = 0;
+ VkStagingBuffCI.pQueueFamilyIndices = nullptr;
std::string StagingBufferName = "Upload buffer for '";
StagingBufferName += m_Desc.Name;
StagingBufferName += '\'';
- VulkanUtilities::BufferWrapper StagingBuffer = LogicalDevice.CreateBuffer(VkStaginBuffCI, StagingBufferName.c_str());
+ VulkanUtilities::BufferWrapper StagingBuffer = LogicalDevice.CreateBuffer(VkStagingBuffCI, StagingBufferName.c_str());
VkMemoryRequirements StagingBufferMemReqs = LogicalDevice.GetBufferMemoryRequirements(StagingBuffer);
VERIFY(IsPowerOfTwo(StagingBufferMemReqs.alignment), "Alignment is not power of 2!");
@@ -395,12 +395,12 @@ TextureVkImpl ::TextureVkImpl(IReferenceCounters* pRefCounters,
}
else if (m_Desc.Usage == USAGE_STAGING)
{
- VkBufferCreateInfo VkStaginBuffCI = {};
+ VkBufferCreateInfo VkStagingBuffCI = {};
- VkStaginBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- VkStaginBuffCI.pNext = nullptr;
- VkStaginBuffCI.flags = 0;
- VkStaginBuffCI.size = GetStagingDataOffset(m_Desc, m_Desc.ArraySize, 0);
+ VkStagingBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ VkStagingBuffCI.pNext = nullptr;
+ VkStagingBuffCI.flags = 0;
+ VkStagingBuffCI.size = GetStagingDataOffset(m_Desc, m_Desc.ArraySize, 0);
// clang-format off
DEV_CHECK_ERR((m_Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == CPU_ACCESS_READ ||
@@ -410,13 +410,13 @@ TextureVkImpl ::TextureVkImpl(IReferenceCounters* pRefCounters,
VkMemoryPropertyFlags MemProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
if (m_Desc.CPUAccessFlags & CPU_ACCESS_READ)
{
- VkStaginBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+ VkStagingBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
MemProperties |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
SetState(RESOURCE_STATE_COPY_DEST);
}
else if (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE)
{
- VkStaginBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ VkStagingBuffCI.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
// VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bit specifies that the host cache management commands vkFlushMappedMemoryRanges
// and vkInvalidateMappedMemoryRanges are NOT needed to flush host writes to the device or make device writes visible
// to the host (10.2)
@@ -426,14 +426,14 @@ TextureVkImpl ::TextureVkImpl(IReferenceCounters* pRefCounters,
else
UNEXPECTED("Unexpected CPU access");
- VkStaginBuffCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- VkStaginBuffCI.queueFamilyIndexCount = 0;
- VkStaginBuffCI.pQueueFamilyIndices = nullptr;
+ VkStagingBuffCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ VkStagingBuffCI.queueFamilyIndexCount = 0;
+ VkStagingBuffCI.pQueueFamilyIndices = nullptr;
std::string StagingBufferName = "Staging buffer for '";
StagingBufferName += m_Desc.Name;
StagingBufferName += '\'';
- m_StagingBuffer = LogicalDevice.CreateBuffer(VkStaginBuffCI, StagingBufferName.c_str());
+ m_StagingBuffer = LogicalDevice.CreateBuffer(VkStagingBuffCI, StagingBufferName.c_str());
VkMemoryRequirements StagingBufferMemReqs = LogicalDevice.GetBufferMemoryRequirements(m_StagingBuffer);
VERIFY(IsPowerOfTwo(StagingBufferMemReqs.alignment), "Alignment is not power of 2!");