From b5b8cf574d730f4c0caab90a2518b2c1950f0344 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 6 Nov 2015 16:04:28 +0100 Subject: [PATCH] Handle GLSL (not SPIR-V) being passed to shader module create. * We can't analyse or reflect it at all, but we should at least pass it through. * Currently invalid but there will probably be extensions that allow this, whether or not we'll allow them is a different matter. --- renderdoc/driver/vulkan/vk_info.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index f63a73751..85624ddc7 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -330,8 +330,16 @@ void VulkanCreationInfo::ImageView::Init(VulkanResourceManager *resourceMan, con void VulkanCreationInfo::ShaderModule::Init(VulkanResourceManager *resourceMan, const VkShaderModuleCreateInfo* pCreateInfo) { - RDCASSERT(pCreateInfo->codeSize % sizeof(uint32_t) == 0); - ParseSPIRV((uint32_t *)pCreateInfo->pCode, pCreateInfo->codeSize/sizeof(uint32_t), spirv); + const uint32_t SPIRVMagic = 0x07230203; + if(pCreateInfo->codeSize < 4 || memcmp(pCreateInfo->pCode, &SPIRVMagic, sizeof(SPIRVMagic))) + { + RDCWARN("Shader not provided with SPIR-V"); + } + else + { + RDCASSERT(pCreateInfo->codeSize % sizeof(uint32_t) == 0); + ParseSPIRV((uint32_t *)pCreateInfo->pCode, pCreateInfo->codeSize/sizeof(uint32_t), spirv); + } spirv.MakeReflection(&reflTemplate, &mapping); }