From 4365e955d8d4e19b38adf00fba834cf82ebad7e1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Dec 2019 13:13:16 -0800 Subject: [PATCH] turnip: Add a helper function for getting tu_buffer iovas. Easier than remembering to add all 3 offsets. Reviewed-by: Jonathan Marek --- src/freedreno/vulkan/tu_descriptor_set.c | 6 ++---- src/freedreno/vulkan/tu_meta_copy.c | 2 +- src/freedreno/vulkan/tu_private.h | 6 ++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/freedreno/vulkan/tu_descriptor_set.c b/src/freedreno/vulkan/tu_descriptor_set.c index 0998161edc0..70fa3cfe3d2 100644 --- a/src/freedreno/vulkan/tu_descriptor_set.c +++ b/src/freedreno/vulkan/tu_descriptor_set.c @@ -688,9 +688,8 @@ static void write_buffer_descriptor(struct tu_device *device, const VkDescriptorBufferInfo *buffer_info) { TU_FROM_HANDLE(tu_buffer, buffer, buffer_info->buffer); - uint64_t va = buffer->bo->iova; - va += buffer_info->offset + buffer->bo_offset; + uint64_t va = tu_buffer_iova(buffer) + buffer_info->offset; dst[0] = va; dst[1] = va >> 32; @@ -706,13 +705,12 @@ static void write_dynamic_buffer_descriptor(struct tu_device *device, const VkDescriptorBufferInfo *buffer_info) { TU_FROM_HANDLE(tu_buffer, buffer, buffer_info->buffer); - uint64_t va = buffer->bo->iova; + uint64_t va = tu_buffer_iova(buffer) + buffer_info->offset; unsigned size = buffer_info->range; if (buffer_info->range == VK_WHOLE_SIZE) size = buffer->size - buffer_info->offset; - va += buffer_info->offset + buffer->bo_offset; range->va = va; range->size = size; diff --git a/src/freedreno/vulkan/tu_meta_copy.c b/src/freedreno/vulkan/tu_meta_copy.c index e51b31275f0..d316884eeef 100644 --- a/src/freedreno/vulkan/tu_meta_copy.c +++ b/src/freedreno/vulkan/tu_meta_copy.c @@ -208,7 +208,7 @@ tu_blit_buffer(struct tu_buffer *buffer, return (struct tu_blit_surf) { .fmt = format, .tile_mode = TILE6_LINEAR, - .va = buffer->bo->iova + buffer->bo_offset + info->bufferOffset, + .va = tu_buffer_iova(buffer) + info->bufferOffset, .pitch = pitch, .layer_size = (info->bufferImageHeight ?: info->imageExtent.height) * pitch / vk_format_get_blockwidth(format) / vk_format_get_blockheight(format), .width = info->imageExtent.width, diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 6387fa50501..813ff0cc1ea 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -665,6 +665,12 @@ struct tu_buffer VkDeviceSize bo_offset; }; +static inline uint64_t +tu_buffer_iova(struct tu_buffer *buffer) +{ + return buffer->bo->iova + buffer->bo_offset; +} + enum tu_dynamic_state_bits { TU_DYNAMIC_VIEWPORT = 1 << 0, -- 2.30.2