summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhivulkan.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-10-10 00:39:50 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-11 10:58:53 +0200
commit22de21a26c6c8329448dc2108a0c0063a13f77f4 (patch)
treec49f517587ab1e6dbe4faa426e2b04539e81b610 /src/gui/rhi/qrhivulkan.cpp
parent8c9dfd7914472585f4fd0519f6f2a278225c3658 (diff)
rhi: vk: Skip buffer/texture registration on read-after-read
Change-Id: I22027cfc227d3c09e446d193e6b2903b8df34eb2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhivulkan.cpp')
-rw-r--r--src/gui/rhi/qrhivulkan.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index ccb2c002b3..9edc2cc64f 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -3923,9 +3923,15 @@ void QRhiVulkan::trackedRegisterBuffer(QRhiPassResourceTracker *passResTracker,
QRhiPassResourceTracker::BufferStage stage)
{
QVkBuffer::UsageState &u(bufD->usageState[slot]);
+ const VkAccessFlags newAccess = toVkAccess(access);
+ const VkPipelineStageFlags newStage = toVkPipelineStage(stage);
+ if (u.access == newAccess && u.stage == newStage) {
+ if (!accessIsWrite(access))
+ return;
+ }
passResTracker->registerBuffer(bufD, slot, &access, &stage, toPassTrackerUsageState(u));
- u.access = toVkAccess(access);
- u.stage = toVkPipelineStage(stage);
+ u.access = newAccess;
+ u.stage = newStage;
}
void QRhiVulkan::trackedRegisterTexture(QRhiPassResourceTracker *passResTracker,
@@ -3934,10 +3940,17 @@ void QRhiVulkan::trackedRegisterTexture(QRhiPassResourceTracker *passResTracker,
QRhiPassResourceTracker::TextureStage stage)
{
QVkTexture::UsageState &u(texD->usageState);
+ const VkAccessFlags newAccess = toVkAccess(access);
+ const VkPipelineStageFlags newStage = toVkPipelineStage(stage);
+ const VkImageLayout newLayout = toVkLayout(access);
+ if (u.access == newAccess && u.stage == newStage && u.layout == newLayout) {
+ if (!accessIsWrite(access))
+ return;
+ }
passResTracker->registerTexture(texD, &access, &stage, toPassTrackerUsageState(u));
- u.layout = toVkLayout(access);
- u.access = toVkAccess(access);
- u.stage = toVkPipelineStage(stage);
+ u.layout = newLayout;
+ u.access = newAccess;
+ u.stage = newStage;
}
void QRhiVulkan::recordTransitionPassResources(QVkCommandBuffer *cbD, const QRhiPassResourceTracker &tracker)
@@ -4272,6 +4285,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
{
QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb);
Q_ASSERT(cbD->recordingPass != QVkCommandBuffer::NoPass);
+ QRhiPassResourceTracker &passResTracker(cbD->passResTrackers[cbD->currentPassResTrackerIndex]);
QVkGraphicsPipeline *gfxPsD = QRHI_RES(QVkGraphicsPipeline, cbD->currentGraphicsPipeline);
QVkComputePipeline *compPsD = QRHI_RES(QVkComputePipeline, cbD->currentComputePipeline);
@@ -4291,7 +4305,6 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) {
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data();
QVkShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[descSetIdx][i]);
- QRhiPassResourceTracker &passResTracker(cbD->passResTrackers[cbD->currentPassResTrackerIndex]);
switch (b->type) {
case QRhiShaderResourceBinding::UniformBuffer:
{