Commit d6f6721c authored by Laszlo Agocs's avatar Laszlo Agocs

vk: avoid validation warning when testing depth tex.

parent 94cc78fe
......@@ -254,6 +254,11 @@ void TriangleOnCubeRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resou
mvp.scale(0.5f);
mvp.rotate(m_rotation, 1, 0, 0);
resourceUpdates->updateDynamicBuffer(m_ubuf, 0, 64, mvp.constData());
if (DEPTH_TEXTURE) {
// m_tex is basically undefined here, be nice and transition the layout properly at least
resourceUpdates->prepareTextureForUse(m_tex, QRhiResourceUpdateBatch::TextureRead);
}
}
void TriangleOnCubeRenderer::queueOffscreenPass(QRhiCommandBuffer *cb)
......
......@@ -275,6 +275,11 @@ void QRhiResourceUpdateBatch::uploadTexture(QRhiTexture *tex, const QImage &imag
uploadTexture(tex, {{{{{ image }}}}});
}
void QRhiResourceUpdateBatch::prepareTextureForUse(QRhiTexture *tex, TexturePrepareFlags flags)
{
d->texturePrepares.append({ tex, flags });
}
QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch()
{
auto nextFreeBatch = [this]() -> QRhiResourceUpdateBatch * {
......@@ -311,6 +316,7 @@ void QRhiResourceUpdateBatchPrivate::free()
dynamicBufferUpdates.clear();
staticBufferUploads.clear();
textureUploads.clear();
texturePrepares.clear();
rhi->resUpdPoolMap.clearBit(poolIndex);
poolIndex = -1;
......
......@@ -801,6 +801,12 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::SurfaceImportFlags)
class Q_RHI_EXPORT QRhiResourceUpdateBatch // sort of a command buffer for copy type of operations
{
public:
enum TexturePrepareFlag {
TextureRead = 1 << 0,
TextureWrite = 1 << 1
};
Q_DECLARE_FLAGS(TexturePrepareFlags, TexturePrepareFlag)
~QRhiResourceUpdateBatch();
// Puts the batch back to the pool without any processing.
void release();
......@@ -812,6 +818,10 @@ public:
void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc);
void uploadTexture(QRhiTexture *tex, const QImage &image);
// This is not normally needed, textures that have an upload or are used
// with a TextureRenderTarget will be fine without it. May be more relevant later.
void prepareTextureForUse(QRhiTexture *tex, TexturePrepareFlags flags);
private:
QRhiResourceUpdateBatch(QRhiImplementation *rhi);
Q_DISABLE_COPY(QRhiResourceUpdateBatch)
......@@ -820,6 +830,8 @@ private:
friend class QRhi;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiResourceUpdateBatch::TexturePrepareFlags)
struct Q_RHI_EXPORT QRhiInitParams
{
};
......
......@@ -153,9 +153,20 @@ struct QRhiResourceUpdateBatchPrivate
QRhiTextureUploadDescription desc;
};
struct TexturePrepare {
TexturePrepare() { }
TexturePrepare(QRhiTexture *tex_, QRhiResourceUpdateBatch::TexturePrepareFlags flags_)
: tex(tex_), flags(flags_)
{ }
QRhiTexture *tex = nullptr;
QRhiResourceUpdateBatch::TexturePrepareFlags flags;
};
QVector<DynamicBufferUpdate> dynamicBufferUpdates;
QVector<StaticBufferUpload> staticBufferUploads;
QVector<TextureUpload> textureUploads;
QVector<TexturePrepare> texturePrepares;
QRhiResourceUpdateBatch *q = nullptr;
QRhiImplementation *rhi = nullptr;
......@@ -169,6 +180,7 @@ struct QRhiResourceUpdateBatchPrivate
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::DynamicBufferUpdate, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::StaticBufferUpload, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureUpload, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TexturePrepare, Q_MOVABLE_TYPE);
template<typename T>
struct QRhiBatchedBindings
......
......@@ -1305,6 +1305,9 @@ void QRhiVulkan::beginPass(QRhiRenderTarget *rt,
break;
}
// No copies or image layout transitions allowed after this point (up until
// endPass) as we are going to begin the renderpass.
QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb);
cbD->currentTarget = rt;
......@@ -1688,6 +1691,18 @@ void QRhiVulkan::commitResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
}
for (const QRhiResourceUpdateBatchPrivate::TexturePrepare &u : ud->texturePrepares) {
if (u.flags.testFlag(QRhiResourceUpdateBatch::TextureRead)) {
QVkTexture *utexD = QRHI_RES(QVkTexture, u.tex);
if (utexD->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
imageBarrier(cb, u.tex,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
}
}
}
ud->free();
}
......
vk, d3d: verify no-color-just-depth again
mtl: cubemaps
mtl: targeting cubemap faces
mtl: cbuffers, textures, samplers set should be batched too
......@@ -44,6 +43,8 @@ bytecode for metal?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
vk: im.layout transition missing when no upload, no render to (or is the case invalid?)
vk, d3d: verify no-color-just-depth again
preservecolor applies to which att. (all -> fix mtl)
mtl: depth tex
mtl: mrt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment