summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-30 16:57:39 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-30 16:57:39 +0000
commit4a3803e1de2669fb546bff0396f083766fad402e (patch)
tree599d610ef4dffe28aa9cfaded09f3e8eb3e0e52c /Graphics/GraphicsEngineVulkan
parentUpdated install instructions for license.txt (diff)
downloadDiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.tar.gz
DiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.zip
Added methods to get command queue from the device context (API Version 240038)
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h11
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h1
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h22
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp2
6 files changed, 32 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 631faa64..14f9975b 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -28,7 +28,6 @@
#include <unordered_map>
#include "DeviceContextVk.h"
-#include "DeviceContextBase.h"
#include "DeviceContextNextGenBase.h"
#include "VulkanUtilities/VulkanCommandBufferPool.h"
#include "VulkanUtilities/VulkanCommandBuffer.h"
@@ -46,21 +45,25 @@
namespace Diligent
{
+class RenderDeviceVkImpl;
+
struct DeviceContextVkImplTraits
{
using BufferType = BufferVkImpl;
using TextureType = TextureVkImpl;
using PipelineStateType = PipelineStateVkImpl;
+ using DeviceType = RenderDeviceVkImpl;
+ using ICommandQueueType = ICommandQueueVk;
};
/// Implementation of the Diligent::IDeviceContext interface
-class DeviceContextVkImpl final : public DeviceContextNextGenBase< DeviceContextBase<IDeviceContextVk, DeviceContextVkImplTraits> >
+class DeviceContextVkImpl final : public DeviceContextNextGenBase<IDeviceContextVk, DeviceContextVkImplTraits>
{
public:
- using TDeviceContextBase = DeviceContextNextGenBase< DeviceContextBase<IDeviceContextVk, DeviceContextVkImplTraits> >;
+ using TDeviceContextBase = DeviceContextNextGenBase<IDeviceContextVk, DeviceContextVkImplTraits>;
DeviceContextVkImpl(IReferenceCounters* pRefCounters,
- class RenderDeviceVkImpl* pDevice,
+ RenderDeviceVkImpl* pDevice,
bool bIsDeferred,
const EngineVkCreateInfo& EngineCI,
Uint32 ContextId,
diff --git a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
index 33cf7fe1..49524f88 100644
--- a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
@@ -26,7 +26,6 @@
/// \file
/// Definition of the Diligent::ICommandQueueVk interface
-#include "vulkan.h"
#include "../../../Primitives/interface/Object.h"
namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h b/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
index 5a8880e4..a00e8372 100644
--- a/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
@@ -27,6 +27,7 @@
/// Definition of the Diligent::IDeviceContextVk interface
#include "../../GraphicsEngine/interface/DeviceContext.h"
+#include "CommandQueueVk.h"
namespace Diligent
{
@@ -53,6 +54,27 @@ public:
/// \param [in] NewAccessFlags - Access flags to set for the buffer
/// \remarks The buffer state must be known to the engine.
virtual void BufferMemoryBarrier(IBuffer *pBuffer, VkAccessFlags NewAccessFlags) = 0;
+
+ /// Locks the internal mutex and returns a pointer to the command queue that is associated with this device context.
+
+ /// \return - a pointer to ICommandQueueVk interface of the command queue associated with the context.
+ ///
+ /// \remarks Only immediate device contexts have associated command queues.
+ ///
+ /// The engine locks the internal mutex to prevent simultaneous access to the command queue.
+ /// An application must release the lock by calling IDeviceContextVk::UnlockCommandQueue()
+ /// when it is done working with the queue or the engine will not be able to submit any command
+ /// list to the queue. Nested calls to LockCommandQueue() are not allowed.
+ /// The queue pointer never changes while the context is alive, so an application may cache and
+ /// use the pointer if it does not need to prevent potential simultaneous access to the queue from
+ /// other threads.
+ ///
+ /// The engine manages the lifetimes of command queues and all other device objects,
+ /// so an application must not call AddRef/Release methods on the returned interface.
+ virtual ICommandQueueVk* LockCommandQueue() = 0;
+
+ /// Unlocks the command queue that was previously locked by IDeviceContextVk::LockCommandQueue().
+ virtual void UnlockCommandQueue() = 0;
};
}
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index 6b3a5a82..b4a7e862 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -872,7 +872,7 @@ namespace Diligent
// be destroyed before the pools are actually returned to the global pool manager.
m_DynamicDescrSetAllocator.ReleasePools(m_SubmittedBuffersCmdQueueMask);
- EndFrame(DeviceVkImpl);
+ EndFrame();
}
void DeviceContextVkImpl::Flush()
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index 221a1bea..c2086c95 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -247,7 +247,7 @@ void RenderDeviceVkImpl::ExecuteAndDisposeTransientCmdBuff(Uint32 QueueIndex, Vk
// Since transient command buffers do not count as real command buffers, submit them directly to the queue
// to avoid interference with the command buffer counter
Uint64 FenceValue = 0;
- LockCommandQueue(QueueIndex,
+ LockCmdQueueAndRun(QueueIndex,
[&](ICommandQueueVk* pCmdQueueVk)
{
FenceValue = pCmdQueueVk->Submit(SubmitInfo);
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index 5f1d5895..b311c200 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -525,7 +525,7 @@ void SwapChainVkImpl::Present(Uint32 SyncInterval)
PresentInfo.pImageIndices = &m_BackBufferIndex;
VkResult Result = VK_SUCCESS;
PresentInfo.pResults = &Result;
- pDeviceVk->LockCommandQueue(0,
+ pDeviceVk->LockCmdQueueAndRun(0,
[&PresentInfo](ICommandQueueVk* pCmdQueueVk)
{
pCmdQueueVk->Present(PresentInfo);