turnip: Add a helper function for getting tu_buffer iovas.
authorEric Anholt <eric@anholt.net>
Wed, 4 Dec 2019 21:13:16 +0000 (13:13 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 5 Dec 2019 04:32:15 +0000 (20:32 -0800)
Easier than remembering to add all 3 offsets.

Reviewed-by: Jonathan Marek <jonathan@marek.ca>
src/freedreno/vulkan/tu_descriptor_set.c
src/freedreno/vulkan/tu_meta_copy.c
src/freedreno/vulkan/tu_private.h

index 0998161edc0e5e312e915a092661935206541178..70fa3cfe3d257d8aa958e7633d5a03851bff066b 100644 (file)
@@ -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;
 
index e51b31275f07501f633b433002ecc921ef7b7c1e..d316884eeefea2d339adef995b69bfddbb2b5a90 100644 (file)
@@ -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,
index 6387fa5050105aa84c834c26727d60323440534d..813ff0cc1ea6b1298faad81f527281ead1fe365c 100644 (file)
@@ -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,