From b1f95e150e8066f0132bf90b3aab598a5b67ecdf Mon Sep 17 00:00:00 2001 From: rsjtdrjgfuzkfg Date: Sun, 25 Oct 2020 00:56:54 +0200 Subject: Fix crash in RenderingDeviceVulkan::shader_create This commit moves the declaration of a local variable to ensure its scope survives long enough; at least in some versions of GCC and LLVM the associated memory was freed too early and thus caused issues ranging from black screens to crashes. --- drivers/vulkan/rendering_device_vulkan.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 41b9c33d7f..92d7906b6c 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -4312,8 +4312,10 @@ RID RenderingDeviceVulkan::shader_create(const Vector &p_stages } pipeline_layout_create_info.pSetLayouts = layouts.ptr(); + // Needs to be declared in this outer scope, otherwise it may not outlive its assignment + // to pipeline_layout_create_info. + VkPushConstantRange push_constant_range; if (push_constant.push_constant_size) { - VkPushConstantRange push_constant_range; push_constant_range.stageFlags = push_constant.push_constants_vk_stage; push_constant_range.offset = 0; push_constant_range.size = push_constant.push_constant_size; -- cgit v1.2.3