summaryrefslogtreecommitdiff
path: root/src/amd/vulkan/radv_meta_buffer.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2020-09-22 08:55:38 +0200
committerMarge Bot <eric+marge@anholt.net>2020-09-23 07:14:15 +0000
commit22a08da7370e581d71a8c19dee028be4c7c07a86 (patch)
tree7c42828e2223bde9808327cfd56b749e94070ae0 /src/amd/vulkan/radv_meta_buffer.c
parenteccc73ff780da0380067690f81ca9db93d67b66c (diff)
radv: add support for CmdCopyBuffer2KHR()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6813>
Diffstat (limited to 'src/amd/vulkan/radv_meta_buffer.c')
-rw-r--r--src/amd/vulkan/radv_meta_buffer.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c
index 51c24d9e052..17cdf796a6b 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -448,6 +448,31 @@ void radv_CmdFillBuffer(
fillSize, data);
}
+static void
+copy_buffer(struct radv_cmd_buffer *cmd_buffer,
+ struct radv_buffer *src_buffer,
+ struct radv_buffer *dst_buffer,
+ const VkBufferCopy2KHR *region)
+{
+ bool old_predicating;
+
+ /* VK_EXT_conditional_rendering says that copy commands should not be
+ * affected by conditional rendering.
+ */
+ old_predicating = cmd_buffer->state.predicating;
+ cmd_buffer->state.predicating = false;
+
+ radv_copy_buffer(cmd_buffer,
+ src_buffer->bo,
+ dst_buffer->bo,
+ src_buffer->offset + region->srcOffset,
+ dst_buffer->offset + region->dstOffset,
+ region->size);
+
+ /* Restore conditional rendering. */
+ cmd_buffer->state.predicating = old_predicating;
+}
+
void radv_CmdCopyBuffer(
VkCommandBuffer commandBuffer,
VkBuffer srcBuffer,
@@ -457,26 +482,32 @@ void radv_CmdCopyBuffer(
{
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
RADV_FROM_HANDLE(radv_buffer, src_buffer, srcBuffer);
- RADV_FROM_HANDLE(radv_buffer, dest_buffer, destBuffer);
- bool old_predicating;
-
- /* VK_EXT_conditional_rendering says that copy commands should not be
- * affected by conditional rendering.
- */
- old_predicating = cmd_buffer->state.predicating;
- cmd_buffer->state.predicating = false;
+ RADV_FROM_HANDLE(radv_buffer, dst_buffer, destBuffer);
for (unsigned r = 0; r < regionCount; r++) {
- uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset;
- uint64_t dest_offset = dest_buffer->offset + pRegions[r].dstOffset;
- uint64_t copy_size = pRegions[r].size;
-
- radv_copy_buffer(cmd_buffer, src_buffer->bo, dest_buffer->bo,
- src_offset, dest_offset, copy_size);
+ VkBufferCopy2KHR copy = {
+ .sType = VK_STRUCTURE_TYPE_BUFFER_COPY_2_KHR,
+ .srcOffset = pRegions[r].srcOffset,
+ .dstOffset = pRegions[r].dstOffset,
+ .size = pRegions[r].size,
+ };
+
+ copy_buffer(cmd_buffer, src_buffer, dst_buffer, &copy);
}
+}
- /* Restore conditional rendering. */
- cmd_buffer->state.predicating = old_predicating;
+void radv_CmdCopyBuffer2KHR(
+ VkCommandBuffer commandBuffer,
+ const VkCopyBufferInfo2KHR* pCopyBufferInfo)
+{
+ RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
+ RADV_FROM_HANDLE(radv_buffer, src_buffer, pCopyBufferInfo->srcBuffer);
+ RADV_FROM_HANDLE(radv_buffer, dst_buffer, pCopyBufferInfo->dstBuffer);
+
+ for (unsigned r = 0; r < pCopyBufferInfo->regionCount; r++) {
+ copy_buffer(cmd_buffer, src_buffer, dst_buffer,
+ &pCopyBufferInfo->pRegions[r]);
+ }
}
void radv_CmdUpdateBuffer(