[vulkan] Make QFV_PacketCopyBuffer take destination offset

It's useful being able to update a subregion of a buffer (needed for the
quad drawing changes).
This commit is contained in:
Bill Currie 2023-01-11 11:32:05 +09:00
parent b310ece7bd
commit c8afad4d3d
4 changed files with 15 additions and 7 deletions

View file

@ -35,7 +35,8 @@ qfv_packet_t *QFV_PacketAcquire (qfv_stagebuf_t *stage);
void *QFV_PacketExtend (qfv_packet_t *packet, size_t size); void *QFV_PacketExtend (qfv_packet_t *packet, size_t size);
void QFV_PacketSubmit (qfv_packet_t *packet); void QFV_PacketSubmit (qfv_packet_t *packet);
struct qfv_bufferbarrier_s; struct qfv_bufferbarrier_s;
void QFV_PacketCopyBuffer (qfv_packet_t *packet, VkBuffer dstBuffer, void QFV_PacketCopyBuffer (qfv_packet_t *packet,
VkBuffer dstBuffer, VkDeviceSize offset,
const struct qfv_bufferbarrier_s *dstBarrier); const struct qfv_bufferbarrier_s *dstBarrier);
struct qfv_imagebarrier_s; struct qfv_imagebarrier_s;
void QFV_PacketCopyImage (qfv_packet_t *packet, VkImage dstImage, void QFV_PacketCopyImage (qfv_packet_t *packet, VkImage dstImage,

View file

@ -284,20 +284,27 @@ QFV_PacketSubmit (qfv_packet_t *packet)
} }
void void
QFV_PacketCopyBuffer (qfv_packet_t *packet, VkBuffer dstBuffer, QFV_PacketCopyBuffer (qfv_packet_t *packet,
VkBuffer dstBuffer, VkDeviceSize offset,
const qfv_bufferbarrier_t *dstBarrier) const qfv_bufferbarrier_t *dstBarrier)
{ {
qfv_devfuncs_t *dfunc = packet->stage->device->funcs; qfv_devfuncs_t *dfunc = packet->stage->device->funcs;
qfv_bufferbarrier_t bb = bufferBarriers[qfv_BB_Unknown_to_TransferWrite]; qfv_bufferbarrier_t bb = bufferBarriers[qfv_BB_Unknown_to_TransferWrite];
bb.barrier.buffer = dstBuffer; bb.barrier.buffer = dstBuffer;
bb.barrier.offset = offset;
bb.barrier.size = packet->length; bb.barrier.size = packet->length;
dfunc->vkCmdPipelineBarrier (packet->cmd, bb.srcStages, bb.dstStages, dfunc->vkCmdPipelineBarrier (packet->cmd, bb.srcStages, bb.dstStages,
0, 0, 0, 1, &bb.barrier, 0, 0); 0, 0, 0, 1, &bb.barrier, 0, 0);
VkBufferCopy copy_region = { packet->offset, 0, packet->length }; VkBufferCopy copy_region = {
.srcOffset = packet->offset,
.dstOffset = offset,
.size = packet->length,
};
dfunc->vkCmdCopyBuffer (packet->cmd, packet->stage->buffer, dstBuffer, dfunc->vkCmdCopyBuffer (packet->cmd, packet->stage->buffer, dstBuffer,
1, &copy_region); 1, &copy_region);
bb = *dstBarrier; bb = *dstBarrier;
bb.barrier.buffer = dstBuffer; bb.barrier.buffer = dstBuffer;
bb.barrier.offset = offset;
bb.barrier.size = packet->length; bb.barrier.size = packet->length;
dfunc->vkCmdPipelineBarrier (packet->cmd, bb.srcStages, bb.dstStages, dfunc->vkCmdPipelineBarrier (packet->cmd, bb.srcStages, bb.dstStages,
0, 0, 0, 1, &bb.barrier, 0, 0); 0, 0, 0, 1, &bb.barrier, 0, 0);

View file

@ -227,7 +227,7 @@ generate_quad_indices (qfv_stagebuf_t *staging, qfv_resobj_t *ind_buffer)
// mark end of primitive // mark end of primitive
*ind++ = -1; *ind++ = -1;
} }
QFV_PacketCopyBuffer (packet, ind_buffer->buffer.buffer, QFV_PacketCopyBuffer (packet, ind_buffer->buffer.buffer, 0,
&bufferBarriers[qfv_BB_TransferWrite_to_IndexRead]); &bufferBarriers[qfv_BB_TransferWrite_to_IndexRead]);
QFV_PacketSubmit (packet); QFV_PacketSubmit (packet);
} }
@ -243,7 +243,7 @@ generate_slice_indices (qfv_stagebuf_t *staging, qfv_resobj_t *ind_buffer)
ind[i + 18] = i + 8; ind[i + 18] = i + 8;
} }
ind[8] = ind[17] = ~0; ind[8] = ind[17] = ~0;
QFV_PacketCopyBuffer (packet, ind_buffer->buffer.buffer, QFV_PacketCopyBuffer (packet, ind_buffer->buffer.buffer, 0,
&bufferBarriers[qfv_BB_TransferWrite_to_IndexRead]); &bufferBarriers[qfv_BB_TransferWrite_to_IndexRead]);
QFV_PacketSubmit (packet); QFV_PacketSubmit (packet);
} }
@ -1446,7 +1446,7 @@ Vulkan_Draw_AddFont (font_t *rfont, vulkan_ctx_t *ctx)
.uv = {(u + w) * s, (v + h) * t }, .uv = {(u + w) * s, (v + h) * t },
}; };
} }
QFV_PacketCopyBuffer (packet, glyph_data->buffer.buffer, QFV_PacketCopyBuffer (packet, glyph_data->buffer.buffer, 0,
&bufferBarriers[qfv_BB_TransferWrite_to_UniformRead]); &bufferBarriers[qfv_BB_TransferWrite_to_UniformRead]);
QFV_PacketSubmit (packet); QFV_PacketSubmit (packet);

View file

@ -292,7 +292,7 @@ translucent_clear (qfv_renderframe_t *rFrame)
qfv_transtate_t *state = QFV_PacketExtend (packet, 2 * sizeof (*state)); qfv_transtate_t *state = QFV_PacketExtend (packet, 2 * sizeof (*state));
*state = (qfv_transtate_t) { 0, tctx->maxFragments }; *state = (qfv_transtate_t) { 0, tctx->maxFragments };
__auto_type bb = &bufferBarriers[qfv_BB_TransferWrite_to_ShaderRW]; __auto_type bb = &bufferBarriers[qfv_BB_TransferWrite_to_ShaderRW];
QFV_PacketCopyBuffer (packet, tframe->state, bb); QFV_PacketCopyBuffer (packet, tframe->state, 0, bb);
QFV_PacketSubmit (packet); QFV_PacketSubmit (packet);
} }