summaryrefslogtreecommitdiff
path: root/drivers/vulkan/rendering_device_vulkan.cpp
diff options
context:
space:
mode:
authorrsjtdrjgfuzkfg <public@rsjtdrjgfuzkfg.com>2020-10-25 00:56:54 +0200
committerrsjtdrjgfuzkfg <public@rsjtdrjgfuzkfg.com>2020-10-25 22:32:10 +0100
commitb1f95e150e8066f0132bf90b3aab598a5b67ecdf (patch)
tree3190e45d5c99f4c7fbe065516e9ea736b1cc12d4 /drivers/vulkan/rendering_device_vulkan.cpp
parent6c173e2f7ffdb972ec3754b3d78fe51bfbfb4f22 (diff)
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.
Diffstat (limited to 'drivers/vulkan/rendering_device_vulkan.cpp')
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp4
1 files changed, 3 insertions, 1 deletions
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<ShaderStageData> &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;