@@ -1065,13 +1065,14 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
10651065#endif
10661066
10671067 if (data.size ()) {
1068+ const bool use_general_in_copy_queues = driver->api_trait_get (RDD::API_TRAIT_USE_GENERAL_IN_COPY_QUEUES);
1069+ const RDD::TextureLayout dst_layout = use_general_in_copy_queues ? RDD::TEXTURE_LAYOUT_GENERAL : RDD::TEXTURE_LAYOUT_COPY_DST_OPTIMAL;
10681070 for (uint32_t i = 0 ; i < format.array_layers ; i++) {
1069- _texture_initialize (id, i, data[i], immediate_flush);
1071+ _texture_initialize (id, i, data[i], dst_layout, immediate_flush);
10701072 }
10711073
10721074 if (texture.draw_tracker != nullptr ) {
1073- // Draw tracker can assume the texture will be in copy destination.
1074- texture.draw_tracker ->usage = RDG::RESOURCE_USAGE_COPY_TO;
1075+ texture.draw_tracker ->usage = use_general_in_copy_queues ? RDG::RESOURCE_USAGE_GENERAL : RDG::RESOURCE_USAGE_COPY_TO;
10751076 }
10761077 }
10771078
@@ -1420,7 +1421,7 @@ uint32_t RenderingDevice::_texture_alignment(Texture *p_texture) const {
14201421 return least_common_multiple (alignment, driver->api_trait_get (RDD::API_TRAIT_TEXTURE_TRANSFER_ALIGNMENT));
14211422}
14221423
1423- Error RenderingDevice::_texture_initialize (RID p_texture, uint32_t p_layer, const Vector<uint8_t > &p_data, bool p_immediate_flush) {
1424+ Error RenderingDevice::_texture_initialize (RID p_texture, uint32_t p_layer, const Vector<uint8_t > &p_data, RDD::TextureLayout p_dst_layout, bool p_immediate_flush) {
14241425 Texture *texture = texture_owner.get_or_null (p_texture);
14251426 ERR_FAIL_NULL_V (texture, ERR_INVALID_PARAMETER);
14261427
@@ -1454,7 +1455,6 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons
14541455 TransferWorker *transfer_worker = nullptr ;
14551456 const uint8_t *read_ptr = p_data.ptr ();
14561457 uint8_t *write_ptr = nullptr ;
1457- const RDD::TextureLayout copy_dst_layout = driver->api_trait_get (RDD::API_TRAIT_USE_GENERAL_IN_COPY_QUEUES) ? RDD::TEXTURE_LAYOUT_GENERAL : RDD::TEXTURE_LAYOUT_COPY_DST_OPTIMAL;
14581458 for (uint32_t pass = 0 ; pass < 2 ; pass++) {
14591459 const bool copy_pass = (pass == 1 );
14601460 if (copy_pass) {
@@ -1477,7 +1477,7 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons
14771477 tb.texture = texture->driver_id ;
14781478 tb.dst_access = RDD::BARRIER_ACCESS_COPY_WRITE_BIT;
14791479 tb.prev_layout = RDD::TEXTURE_LAYOUT_UNDEFINED;
1480- tb.next_layout = copy_dst_layout ;
1480+ tb.next_layout = p_dst_layout ;
14811481 tb.subresources .aspect = texture->barrier_aspect_flags ;
14821482 tb.subresources .mipmap_count = texture->mipmaps ;
14831483 tb.subresources .base_layer = p_layer;
@@ -1524,7 +1524,7 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons
15241524 copy_region.texture_subresources .layer_count = 1 ;
15251525 copy_region.texture_offset = Vector3i (0 , 0 , z);
15261526 copy_region.texture_region_size = Vector3i (logic_width, logic_height, 1 );
1527- driver->command_copy_buffer_to_texture (transfer_worker->command_buffer , transfer_worker->staging_buffer , texture->driver_id , copy_dst_layout , copy_region);
1527+ driver->command_copy_buffer_to_texture (transfer_worker->command_buffer , transfer_worker->staging_buffer , texture->driver_id , p_dst_layout , copy_region);
15281528 }
15291529
15301530 staging_local_offset += to_allocate;
@@ -1543,7 +1543,7 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons
15431543 RDD::TextureBarrier tb;
15441544 tb.texture = texture->driver_id ;
15451545 tb.src_access = RDD::BARRIER_ACCESS_COPY_WRITE_BIT;
1546- tb.prev_layout = copy_dst_layout ;
1546+ tb.prev_layout = p_dst_layout ;
15471547 tb.next_layout = RDD::TEXTURE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
15481548 tb.subresources .aspect = texture->barrier_aspect_flags ;
15491549 tb.subresources .mipmap_count = texture->mipmaps ;
@@ -8407,4 +8407,5 @@ static_assert(ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_STORAGE_IMAGE_READ,
84078407static_assert (ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_STORAGE_IMAGE_READ_WRITE, RDG::RESOURCE_USAGE_STORAGE_IMAGE_READ_WRITE));
84088408static_assert (ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_ATTACHMENT_COLOR_READ_WRITE, RDG::RESOURCE_USAGE_ATTACHMENT_COLOR_READ_WRITE));
84098409static_assert (ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_ATTACHMENT_DEPTH_STENCIL_READ_WRITE, RDG::RESOURCE_USAGE_ATTACHMENT_DEPTH_STENCIL_READ_WRITE));
8410+ static_assert (ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_GENERAL, RDG::RESOURCE_USAGE_GENERAL));
84108411static_assert (ENUM_MEMBERS_EQUAL(RD::CALLBACK_RESOURCE_USAGE_MAX, RDG::RESOURCE_USAGE_MAX));
0 commit comments