Skip to content

Commit

Permalink
Vulkan: Fix ´vkCmdDrawIndexed´ crash on Adreno 5XX devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex2782 committed Jul 29, 2024
1 parent 705b7a0 commit 10c4a32
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions drivers/vulkan/rendering_context_driver_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ void RenderingContextDriverVulkan::_check_driver_workarounds(const VkPhysicalDev
p_device_properties.deviceID >= 0x6000000 && // Adreno 6xx
p_device_properties.driverVersion < VK_MAKE_VERSION(512, 503, 0) &&
r_device.name.find("Turnip") < 0;

// Workaround for the Adreno 5XX family of devices.
//
//TODO:'vkCmdDrawIndexed' crash / 'RENDER_GRAPH_REORDER' ......
//
//TODO: check 'driverVersion'?
// no crash on Fujitsu F-01L - Adreno (TM) 506, Vulkan 1.0.61, driverVersion = 54185879
r_device.workarounds.disable_render_graph_reorder =
r_device.vendor == VENDOR_QUALCOMM &&
p_device_properties.deviceID >= 0x5000000 && // Adreno 5xx
p_device_properties.deviceID <= 0x5999999;

//r_device.workarounds.disable_render_graph_reorder = true; //TODO: Dev-TEST, remove later
}

bool RenderingContextDriverVulkan::_use_validation_layers() const {
Expand Down
1 change: 1 addition & 0 deletions servers/rendering/rendering_context_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RenderingContextDriver {

struct Workarounds {
bool avoid_compute_after_draw = false;
bool disable_render_graph_reorder = false;
};

struct Device {
Expand Down
7 changes: 6 additions & 1 deletion servers/rendering/rendering_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5244,7 +5244,7 @@ void RenderingDevice::_end_frame() {

// The command buffer must be copied into a stack variable as the driver workarounds can change the command buffer in use.
RDD::CommandBufferID command_buffer = frames[frame].draw_command_buffer;
draw_graph.end(RENDER_GRAPH_REORDER, RENDER_GRAPH_FULL_BARRIERS, command_buffer, frames[frame].command_buffer_pool);
draw_graph.end(render_graph_reorder, RENDER_GRAPH_FULL_BARRIERS, command_buffer, frames[frame].command_buffer_pool);
driver->command_buffer_end(command_buffer);
driver->end_segment();
}
Expand Down Expand Up @@ -6560,6 +6560,11 @@ RenderingDevice::RenderingDevice() {
if (singleton == nullptr) {
singleton = this;
}

render_graph_reorder = RENDER_GRAPH_REORDER;
if (get_device_workarounds().disable_render_graph_reorder) {
render_graph_reorder = false;
}
}

/*****************/
Expand Down
2 changes: 2 additions & 0 deletions servers/rendering/rendering_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class RenderingDevice : public RenderingDeviceCommons {
uint32_t staging_buffer_block_size = 0;
uint64_t staging_buffer_max_size = 0;
bool staging_buffer_used = false;
bool render_graph_reorder = true; // will be overwritten in the constructor, see description for '#define RENDER_GRAPH_REORDER'

enum StagingRequiredAction {
STAGING_REQUIRED_ACTION_NONE,
Expand Down Expand Up @@ -830,6 +831,7 @@ class RenderingDevice : public RenderingDeviceCommons {
public:
RenderingContextDriver *get_context_driver() const { return context; }

const RenderingContextDriver::Workarounds &get_device_workarounds() const { return device.workarounds; };
const RDD::Capabilities &get_device_capabilities() const { return driver->get_capabilities(); }

bool has_feature(const Features p_feature) const;
Expand Down

0 comments on commit 10c4a32

Please sign in to comment.