From f6802a5aac49f6161d60e9b3e761093e292f2fc4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 1 Sep 2020 15:16:24 +0200 Subject: rhi: Sanity check the srb in debug builds Instead of cryptic assertions and crashes depending on the backend, show some useful warnings (in debug builds only) when one tries to create an srb with a list where there are duplicated bindings. (a mistake that happens relatively often during the development of frameworks, such as Quick 3D, on top) Change-Id: If1b50a2e8165b001878ad566e048f146e636514f Reviewed-by: Andy Nichols --- src/gui/rhi/qrhivulkan.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/rhi/qrhivulkan.cpp') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 28463398bb..b172a8b16b 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -6155,6 +6155,10 @@ bool QVkShaderResourceBindings::create() if (layout) destroy(); + QRHI_RES_RHI(QRhiVulkan); + if (!rhiD->sanityCheckShaderResourceBindings(this)) + return false; + for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) descSets[i] = VK_NULL_HANDLE; @@ -6187,7 +6191,6 @@ bool QVkShaderResourceBindings::create() layoutInfo.bindingCount = uint32_t(vkbindings.count()); layoutInfo.pBindings = vkbindings.constData(); - QRHI_RES_RHI(QRhiVulkan); VkResult err = rhiD->df->vkCreateDescriptorSetLayout(rhiD->dev, &layoutInfo, nullptr, &layout); if (err != VK_SUCCESS) { qWarning("Failed to create descriptor set layout: %d", err); -- cgit v1.2.3