diff options
author | Jonathan Marek <[email protected]> | 2019-12-16 10:00:20 -0500 |
---|---|---|
committer | Jonathan Marek <[email protected]> | 2019-12-16 13:13:53 -0500 |
commit | d4676d7a166ab7e01f62c7453a80aa74d80ab5f9 (patch) | |
tree | d3fa27c65e5758954d77b278c4c7a61ae26f8ddf /src/freedreno/vulkan | |
parent | 8d893a2071fbfd4b4c2f2922cfd9369696c78e3a (diff) |
turnip: implement CmdFillBuffer/CmdUpdateBuffer
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r-- | src/freedreno/vulkan/tu_meta_buffer.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/tu_meta_buffer.c b/src/freedreno/vulkan/tu_meta_buffer.c index 98a73413cf2..ea764c5790e 100644 --- a/src/freedreno/vulkan/tu_meta_buffer.c +++ b/src/freedreno/vulkan/tu_meta_buffer.c @@ -1,4 +1,6 @@ #include "tu_private.h" +#include "tu_blit.h" +#include "tu_cs.h" void tu_CmdFillBuffer(VkCommandBuffer commandBuffer, @@ -7,6 +9,27 @@ tu_CmdFillBuffer(VkCommandBuffer commandBuffer, VkDeviceSize fillSize, uint32_t data) { + TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer); + TU_FROM_HANDLE(tu_buffer, buffer, dstBuffer); + + if (fillSize == VK_WHOLE_SIZE) + fillSize = buffer->size - dstOffset; + + tu_bo_list_add(&cmd->bo_list, buffer->bo, MSM_SUBMIT_BO_WRITE); + + tu_blit(cmd, &(struct tu_blit) { + .dst = { + .fmt = VK_FORMAT_R32_UINT, + .va = tu_buffer_iova(buffer) + dstOffset, + .width = fillSize / 4, + .height = 1, + .samples = 1, + }, + .layers = 1, + .clear_value[0] = data, + .type = TU_BLIT_CLEAR, + .buffer = true, + }); } void @@ -16,4 +39,37 @@ tu_CmdUpdateBuffer(VkCommandBuffer commandBuffer, VkDeviceSize dataSize, const void *pData) { + TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer); + TU_FROM_HANDLE(tu_buffer, buffer, dstBuffer); + + tu_bo_list_add(&cmd->bo_list, buffer->bo, MSM_SUBMIT_BO_WRITE); + + struct ts_cs_memory tmp; + VkResult result = tu_cs_alloc(cmd->device, &cmd->sub_cs, DIV_ROUND_UP(dataSize, 64), 64, &tmp); + if (result != VK_SUCCESS) { + cmd->record_result = result; + return; + } + + memcpy(tmp.map, pData, dataSize); + + tu_blit(cmd, &(struct tu_blit) { + .dst = { + .fmt = VK_FORMAT_R32_UINT, + .va = tu_buffer_iova(buffer) + dstOffset, + .width = dataSize / 4, + .height = 1, + .samples = 1, + }, + .src = { + .fmt = VK_FORMAT_R32_UINT, + .va = tmp.iova, + .width = dataSize / 4, + .height = 1, + .samples = 1, + }, + .layers = 1, + .type = TU_BLIT_COPY, + .buffer = true, + }); } |