Skip to content

Commit 0c8b132

Browse files
authored
Merge pull request godotengine#114416 from blueskythlikesclouds/adreno-5xx-crash-fix
Implement workaround for GPU driver crash on Adreno 5XX.
2 parents 20b67f3 + 3ef93dc commit 0c8b132

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

drivers/vulkan/rendering_device_driver_vulkan.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,14 @@ Error RenderingDeviceDriverVulkan::initialize(uint32_t p_device_index, uint32_t
16071607
const uint32_t reset_descriptor_pool_fixed_driver_begin = VK_MAKE_VERSION(512u, 671u, 0u);
16081608
linear_descriptor_pools_enabled = physical_device_properties.driverVersion < reset_descriptor_pool_broken_driver_begin || physical_device_properties.driverVersion > reset_descriptor_pool_fixed_driver_begin;
16091609
}
1610+
1611+
// Workaround a driver bug on Adreno 5XX GPUs that causes a crash when
1612+
// there are empty descriptor set layouts placed between non-empty ones.
1613+
adreno_5xx_empty_descriptor_set_layout_workaround =
1614+
physical_device_properties.vendorID == RenderingContextDriver::Vendor::VENDOR_QUALCOMM &&
1615+
physical_device_properties.deviceID >= 0x5000000 &&
1616+
physical_device_properties.deviceID < 0x6000000;
1617+
16101618
frame_count = p_frame_count;
16111619

16121620
// Copy the queue family properties the context already retrieved.
@@ -3973,13 +3981,26 @@ RDD::ShaderID RenderingDeviceDriverVulkan::shader_create_from_container(const Re
39733981

39743982
// Descriptor sets.
39753983
if (error_text.is_empty()) {
3984+
// For Adreno 5XX driver bug.
3985+
VkDescriptorSetLayoutBinding placeholder_binding = {};
3986+
placeholder_binding.binding = 0;
3987+
placeholder_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
3988+
placeholder_binding.descriptorCount = 1;
3989+
placeholder_binding.stageFlags = VK_SHADER_STAGE_ALL;
3990+
39763991
for (uint32_t i = 0; i < shader_refl.uniform_sets.size(); i++) {
39773992
// Empty ones are fine if they were not used according to spec (binding count will be 0).
39783993
VkDescriptorSetLayoutCreateInfo layout_create_info = {};
39793994
layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
39803995
layout_create_info.bindingCount = vk_set_bindings[i].size();
39813996
layout_create_info.pBindings = vk_set_bindings[i].ptr();
39823997

3998+
// ...not so fine on Adreno 5XX.
3999+
if (adreno_5xx_empty_descriptor_set_layout_workaround && layout_create_info.bindingCount == 0) {
4000+
layout_create_info.bindingCount = 1;
4001+
layout_create_info.pBindings = &placeholder_binding;
4002+
}
4003+
39834004
VkDescriptorSetLayout layout = VK_NULL_HANDLE;
39844005
res = vkCreateDescriptorSetLayout(vk_device, &layout_create_info, VKC::get_allocation_callbacks(VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT), &layout);
39854006
if (res) {

drivers/vulkan/rendering_device_driver_vulkan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ class RenderingDeviceDriverVulkan : public RenderingDeviceDriver {
511511
TightLocalVector<BufferInfo const *, uint32_t> dynamic_buffers;
512512
};
513513

514+
bool adreno_5xx_empty_descriptor_set_layout_workaround = false;
515+
514516
public:
515517
virtual UniformSetID uniform_set_create(VectorView<BoundUniform> p_uniforms, ShaderID p_shader, uint32_t p_set_index, int p_linear_pool_index) override final;
516518
virtual void linear_uniform_set_pools_reset(int p_linear_pool_index) override final;

0 commit comments

Comments
 (0)