Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Implement workaround for "STORE_OP_DONT_CARE" crash in NVIDIA drivers.

Skyth89ab4ba0cdf6
diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp
index 85fe3a24725..edb2bf67e2d 100644
--- a/drivers/vulkan/rendering_device_driver_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp
@@ -743,6 +743,9 @@ void RenderingDeviceDriverVulkan::_check_driver_workarounds(const VkPhysicalDevi
p_device_properties.vendorID == RenderingContextDriver::Vendor::VENDOR_QUALCOMM &&
strstr(p_driver_properties->driverInfo, "Compiler Version: EV031.32.02.") != nullptr;
}
+
+ // Workaround for a bug in NVIDIA drivers where submitting a render pass with no bound pipeline and an attachment using the "Don't Care" store operation causes a crash.
+ driver_workarounds.avoid_store_op_dont_care_in_draw_list_with_no_bound_pipeline = (p_device_properties.vendorID == RenderingContextDriver::Vendor::VENDOR_NVIDIA);
}
void RenderingDeviceDriverVulkan::_get_device_properties() {
diff --git a/servers/rendering/rendering_device_commons.h b/servers/rendering/rendering_device_commons.h
index 082ea4d75a7..92846354a5a 100644
--- a/servers/rendering/rendering_device_commons.h
+++ b/servers/rendering/rendering_device_commons.h
@@ -1054,6 +1054,7 @@ public:
bool avoid_compute_after_draw = false;
bool dont_print_on_render_pipeline_creation_failure = false;
bool disable_ubershaders = false;
+ bool avoid_store_op_dont_care_in_draw_list_with_no_bound_pipeline = false;
};
////////////////////////////////////////////
diff --git a/servers/rendering/rendering_device_graph.cpp b/servers/rendering/rendering_device_graph.cpp
index 3b0f5a0d39f..336acf5cf47 100644
--- a/servers/rendering/rendering_device_graph.cpp
+++ b/servers/rendering/rendering_device_graph.cpp
@@ -1071,6 +1071,8 @@ void RenderingDeviceGraph::_add_draw_list_begin(FramebufferCache *p_framebuffer_
#if defined(DEBUG_ENABLED) || defined(DEV_ENABLED)
draw_instruction_list.breadcrumb = p_breadcrumb;
#endif
+
+ workarounds_state.bound_any_draw_list_pipeline = false;
}
void RenderingDeviceGraph::_run_secondary_command_buffer_task(const SecondaryCommandBuffer *p_secondary) {
@@ -2164,6 +2166,8 @@ void RenderingDeviceGraph::add_draw_list_bind_pipeline(RDD::PipelineID p_pipelin
instruction->type = DrawListInstruction::TYPE_BIND_PIPELINE;
instruction->pipeline = p_pipeline;
draw_instruction_list.stages = draw_instruction_list.stages | p_pipeline_stage_bits;
+
+ workarounds_state.bound_any_draw_list_pipeline = true;
}
void RenderingDeviceGraph::add_draw_list_bind_uniform_set(RDD::ShaderID p_shader, RDD::UniformSetID p_uniform_set, uint32_t set_index) {
@@ -2361,6 +2365,11 @@ void RenderingDeviceGraph::add_draw_list_end() {
command->clear_values_count = draw_instruction_list.attachment_clear_values.size();
command->trackers_count = trackers_count;
+ RDD::AttachmentStoreOp attachment_store_op_dont_care = RDD::ATTACHMENT_STORE_OP_DONT_CARE;
+ if (driver_workarounds.avoid_store_op_dont_care_in_draw_list_with_no_bound_pipeline && !workarounds_state.bound_any_draw_list_pipeline) {
+ attachment_store_op_dont_care = RDD::ATTACHMENT_STORE_OP_STORE;
+ }
+
// Initialize the load and store operations to their default behaviors. The store behavior will be modified if a command depends on the result of this render pass.
uint32_t attachment_op_count = draw_instruction_list.attachment_operations.size();
ResourceTracker **trackers = command->trackers();
@@ -2383,7 +2392,7 @@ void RenderingDeviceGraph::add_draw_list_end() {
load_ops[i] = RDD::ATTACHMENT_LOAD_OP_LOAD;
}
- store_ops[i] = resource_tracker->is_discardable ? RDD::ATTACHMENT_STORE_OP_DONT_CARE : RDD::ATTACHMENT_STORE_OP_STORE;
+ store_ops[i] = resource_tracker->is_discardable ? attachment_store_op_dont_care : RDD::ATTACHMENT_STORE_OP_STORE;
} else {
load_ops[i] = RDD::ATTACHMENT_LOAD_OP_DONT_CARE;
store_ops[i] = RDD::ATTACHMENT_STORE_OP_DONT_CARE;
diff --git a/servers/rendering/rendering_device_graph.h b/servers/rendering/rendering_device_graph.h
index 67682e94839..f9c3c1fb3fa 100644
--- a/servers/rendering/rendering_device_graph.h
+++ b/servers/rendering/rendering_device_graph.h
@@ -259,6 +259,7 @@ public:
struct WorkaroundsState {
bool draw_list_found = false;
+ bool bound_any_draw_list_pipeline = false;
};
enum AttachmentOperation {