summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-04-28 16:30:32 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-04-30 10:13:40 +0200
commit1af7fb5ed86c659ebea53e6f0316cac008cb89ed (patch)
treeac3e6447cc98c1748c5be79850da3735bce98267 /src
parent8ddd3ee60bff1197b251feadf871fdaeb995ef3b (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gui/rhi/qrhid3d11.cpp6
-rw-r--r--src/gui/rhi/qrhivulkan.cpp14
2 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index 8336d43ff6..05ee415502 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -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) {
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index 16de7e0aea..b46b0b819c 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -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;