From 4b4ce8dc015d97d98ba809d2c29d28fc2ab357fe Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 3 Apr 2018 16:56:11 +0100 Subject: [PATCH] Until proper support is added, prevent crashes by decaying VB formats * Unfortunately some formats are *only* supported through VB fixed-func inputs, and not through any other access (like texel buffer access). * As a result, it's invalid for us to just create buffer views using these formats to read from, so we will need to read-back the data to the CPU, decode and unpack to another format that is supported, and then re-upload. In some cases this might be extremely complex (e.g. 64-bit wide formats that have no easily supported fallback). * In the meantime, we just re-write the format to R8G8B8A8_UNORM. It will return the wrong data, but will at least not crash. --- renderdoc/driver/vulkan/vk_postvs.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 708fbc8b0..104bca4c7 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -1375,6 +1375,16 @@ void VulkanReplay::InitPostVSBuffers(uint32_t eventId) VK_WHOLE_SIZE, }; + if((m_pDriver->GetFormatProperties(attrDesc.format).bufferFeatures & + VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT) == 0) + { + RDCERR( + "Format %s doesn't support texel buffers! Replacing with safe but broken format, for " + "now. This will require a CPU readback and unpack to properly fix.", + ToStr(attrDesc.format).c_str()); + info.format = VK_FORMAT_R8G8B8A8_UNORM; + } + m_pDriver->vkCreateBufferView(dev, &info, NULL, &vbuffers[attr].view); attrIsInstanced.resize(RDCMAX(attrIsInstanced.size(), size_t(attr + 1)));