rhi: Warn better in D3D/Vulkan for incompatible multisample resolve formats

Attempting to resolve a multisample image into a non-multisample one
is only valid when the formats are the same, as per Vulkan spec and D3D
docs.

With Vulkan, this is sometimes not fatal, some implementations can
apparently deal with some format combinations, so the problem may not be
trivial to catch, although with validation layer enabled a warning is
shown at least. To make it easier to discover, have our own warning.

Task-number: QTBUG-83707
Change-Id: I8fc87471de91cd65a445fbe8cedbf31a8295db53
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Laszlo Agocs 2020-04-28 16:30:32 +02:00
parent 8ddd3ee60b
commit 1af7fb5ed8
2 changed files with 17 additions and 3 deletions

View File

@ -1707,7 +1707,8 @@ void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resource
if (srcTexD) {
cmd.args.resolveSubRes.src = srcTexD->tex;
if (srcTexD->dxgiFormat != dstTexD->dxgiFormat) {
qWarning("Resolve source and destination formats do not match");
qWarning("Resolve source (%d) and destination (%d) formats do not match",
int(srcTexD->dxgiFormat), int(dstTexD->dxgiFormat));
continue;
}
if (srcTexD->sampleDesc.Count <= 1) {
@ -1721,7 +1722,8 @@ void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resource
} else {
cmd.args.resolveSubRes.src = srcRbD->tex;
if (srcRbD->dxgiFormat != dstTexD->dxgiFormat) {
qWarning("Resolve source and destination formats do not match");
qWarning("Resolve source (%d) and destination (%d) formats do not match",
int(srcRbD->dxgiFormat), int(dstTexD->dxgiFormat));
continue;
}
if (srcRbD->m_pixelSize != dstTexD->m_pixelSize) {

View File

@ -1219,12 +1219,24 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD,
for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) {
if (it->resolveTexture()) {
QVkTexture *rtexD = QRHI_RES(QVkTexture, it->resolveTexture());
const VkFormat dstFormat = rtexD->vkformat;
if (rtexD->samples > VK_SAMPLE_COUNT_1_BIT)
qWarning("Resolving into a multisample texture is not supported");
QVkTexture *texD = QRHI_RES(QVkTexture, it->texture());
QVkRenderBuffer *rbD = QRHI_RES(QVkRenderBuffer, it->renderBuffer());
const VkFormat srcFormat = texD ? texD->vkformat : rbD->vkformat;
if (srcFormat != dstFormat) {
// This is a validation error. But some implementations survive,
// actually. Warn about it however, because it's an error with
// some other backends (like D3D) as well.
qWarning("Multisample resolve between different formats (%d and %d) is not supported.",
int(srcFormat), int(dstFormat));
}
VkAttachmentDescription attDesc;
memset(&attDesc, 0, sizeof(attDesc));
attDesc.format = rtexD->vkformat;
attDesc.format = dstFormat;
attDesc.samples = VK_SAMPLE_COUNT_1_BIT;
attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; // ignored
attDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;