diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-08-28 15:18:44 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-08 09:41:27 +0200 |
commit | ee702d94368140618fc4777a0e247219a28d39c8 (patch) | |
tree | e48c9b7cceec01c67add7fcf51a011497fd3b7ea /examples/quick | |
parent | 76bec768a5bf9ff29fdc439cbe5a85d36590a6df (diff) |
Make vulkanunderqml work and update docs
What we are doing for now is setting ExternalContentsInPass always.
This way vulkanunderqml works as expected. For applications that do
not integrate external rendering this means that there is now an
additional secondary command buffer per render pass, but we can
live with this for now.
Later (Qt 6) there should be a way to declare this (that the application
will want to issue native rendering stuff) up front in QQuickWindow or
somewhere.
Change-Id: I736741f9b0eee2f8295b046bacdce862e6a546f5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp index f2e3d8fe3a..3f2067a803 100644 --- a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp +++ b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp @@ -228,10 +228,6 @@ void SquircleRenderer::mainPassRecordingStart() const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); QSGRendererInterface *rif = m_window->rendererInterface(); - VkCommandBuffer cb = *reinterpret_cast<VkCommandBuffer *>( - rif->getResource(m_window, QSGRendererInterface::CommandListResource)); - Q_ASSERT(cb); - VkDeviceSize ubufOffset = stateInfo->currentFrameSlot * m_allocPerUbuf; void *p = nullptr; VkResult err = m_devFuncs->vkMapMemory(m_dev, m_ubufMem, ubufOffset, m_allocPerUbuf, 0, &p); @@ -243,6 +239,16 @@ void SquircleRenderer::mainPassRecordingStart() m_window->beginExternalCommands(); + // Must query the command buffer _after_ beginExternalCommands(), this is + // actually important when running on Vulkan because what we get here is a + // new secondary command buffer, not the primary one. + VkCommandBuffer cb = *reinterpret_cast<VkCommandBuffer *>( + rif->getResource(m_window, QSGRendererInterface::CommandListResource)); + Q_ASSERT(cb); + + // Do not assume any state persists on the command buffer. (it may be a + // brand new one that just started recording) + m_devFuncs->vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline); VkDeviceSize vbufOffset = 0; @@ -317,6 +323,9 @@ void SquircleRenderer::init(int framesInFlight) // For simplicity we just use host visible buffers instead of device local + staging. + VkPhysicalDeviceProperties physDevProps; + m_funcs->vkGetPhysicalDeviceProperties(m_physDev, &physDevProps); + VkPhysicalDeviceMemoryProperties physDevMemProps; m_funcs->vkGetPhysicalDeviceMemoryProperties(m_physDev, &physDevMemProps); @@ -379,7 +388,7 @@ void SquircleRenderer::init(int framesInFlight) // watch out for the buffer offset aligment requirement, which may be as // large as 256 bytes. - m_allocPerUbuf = aligned(UBUF_SIZE, memReq.alignment); + m_allocPerUbuf = aligned(UBUF_SIZE, physDevProps.limits.minUniformBufferOffsetAlignment); bufferInfo.size = framesInFlight * m_allocPerUbuf; bufferInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |