nv2a/vk: Flush/barrier on texture upload

This commit is contained in:
Matt Borgerson 2024-07-29 17:25:37 -07:00 committed by mborgerson
parent 6171e40c39
commit bc066fdea9
1 changed files with 24 additions and 1 deletions

View File

@ -545,13 +545,31 @@ static void upload_texture_image(PGRAPHState *pg, int texture_idx,
region++;
}
}
assert(buffer_offset <= texture_data_size);
assert(buffer_offset <= r->storage_buffers[BUFFER_STAGING_SRC].buffer_size);
vmaFlushAllocation(r->allocator,
r->storage_buffers[BUFFER_STAGING_SRC].allocation, 0,
VK_WHOLE_SIZE);
vmaUnmapMemory(r->allocator,
r->storage_buffers[BUFFER_STAGING_SRC].allocation);
// FIXME: Use nondraw. Need to fill and copy tex buffer at once
VkCommandBuffer cmd = pgraph_vk_begin_single_time_commands(pg);
VkBufferMemoryBarrier host_barrier = {
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT,
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.buffer = r->storage_buffers[BUFFER_STAGING_SRC].buffer,
.size = VK_WHOLE_SIZE
};
vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_HOST_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 1,
&host_barrier, 0, NULL);
pgraph_vk_transition_image_layout(pg, cmd, binding->image, vkf.vk_format,
binding->current_layout,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
@ -974,6 +992,11 @@ static void create_dummy_texture(PGRAPHState *pg)
r->storage_buffers[BUFFER_STAGING_SRC].allocation,
(void *)&mapped_memory_ptr));
memset(mapped_memory_ptr, 0xff, texture_data_size);
vmaFlushAllocation(r->allocator,
r->storage_buffers[BUFFER_STAGING_SRC].allocation, 0,
VK_WHOLE_SIZE);
vmaUnmapMemory(r->allocator,
r->storage_buffers[BUFFER_STAGING_SRC].allocation);