Skip to content

Commit 494da24

Browse files
committed
Merge pull request godotengine#114982 from blueskythlikesclouds/d3d12-uav-clear-sync-fix
Fix buffers in D3D12 not getting cleared with the right usage.
2 parents d127bf4 + 0757960 commit 494da24

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

servers/rendering/rendering_device_graph.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,12 +1651,20 @@ void RenderingDeviceGraph::add_buffer_clear(RDD::BufferID p_dst, ResourceTracker
16511651
int32_t command_index;
16521652
RecordedBufferClearCommand *command = static_cast<RecordedBufferClearCommand *>(_allocate_command(sizeof(RecordedBufferClearCommand), command_index));
16531653
command->type = RecordedCommand::TYPE_BUFFER_CLEAR;
1654-
command->self_stages = RDD::PIPELINE_STAGE_COPY_BIT;
16551654
command->buffer = p_dst;
16561655
command->offset = p_offset;
16571656
command->size = p_size;
16581657

1659-
ResourceUsage usage = RESOURCE_USAGE_COPY_TO;
1658+
ResourceUsage usage;
1659+
if (driver_clears_with_copy_engine) {
1660+
command->self_stages = RDD::PIPELINE_STAGE_COPY_BIT;
1661+
usage = RESOURCE_USAGE_COPY_TO;
1662+
} else {
1663+
// If the driver is uncapable of using the copy engine for clearing the buffer (e.g. D3D12), we must transition it to storage buffer read/write usage.
1664+
command->self_stages = RDD::PIPELINE_STAGE_CLEAR_STORAGE_BIT;
1665+
usage = RESOURCE_USAGE_STORAGE_BUFFER_READ_WRITE;
1666+
}
1667+
16601668
_add_command_to_graph(&p_dst_tracker, &usage, 1, command_index, command);
16611669
}
16621670

0 commit comments

Comments
 (0)