diff --git a/src/panfrost/lib/pan_buffer.c b/src/panfrost/lib/pan_buffer.c index 70d187569ff..69cbeeea919 100644 --- a/src/panfrost/lib/pan_buffer.c +++ b/src/panfrost/lib/pan_buffer.c @@ -49,17 +49,28 @@ GENX(pan_buffer_texture_emit)(const struct pan_buffer_view *bview, unsigned stride = util_format_get_blocksize(bview->format); uint32_t hw_fmt = GENX(pan_format_from_pipe_format)(bview->format)->hw; + /* The base address has shr(6) applied so we need to use the offset of the + * attribute to get the last 6 bits. + */ + uint64_t base = bview->base & ~0x3f; + uint32_t offset = bview->base & 0x3f; + pan_pack(out_buf, ATTRIBUTE_BUFFER, cfg) { cfg.type = MALI_ATTRIBUTE_TYPE_1D; - cfg.pointer = bview->base; + cfg.pointer = base; cfg.stride = stride; - cfg.size = bview->width_el * stride + bview->offset; + /* The ATTRIBUTE_BUFFER.size specifies the size of the buffer starting + * at ATTRIBUTE_BUFFER.pointer and and ATTRIBUTE.offset specifies an + * offset into that window. If we're going to use it to offset the base + * of the buffer, we need to increase the size as well. + */ + cfg.size = bview->width_el * stride + offset; } pan_pack(out_attrib, ATTRIBUTE, cfg) { cfg.format = hw_fmt; - cfg.offset = bview->offset; - cfg.offset_enable = bview->offset != 0; + cfg.offset = offset; + cfg.offset_enable = offset != 0; } } diff --git a/src/panfrost/lib/pan_desc.h b/src/panfrost/lib/pan_desc.h index fd4c4da96eb..db5b6588ad3 100644 --- a/src/panfrost/lib/pan_desc.h +++ b/src/panfrost/lib/pan_desc.h @@ -20,7 +20,6 @@ struct pan_buffer_view { } astc; unsigned width_el; uint64_t base; - uint32_t offset; }; struct pan_compute_dim { diff --git a/src/panfrost/vulkan/panvk_vX_buffer_view.c b/src/panfrost/vulkan/panvk_vX_buffer_view.c index f8d0627f77a..dafda6fa614 100644 --- a/src/panfrost/vulkan/panvk_vX_buffer_view.c +++ b/src/panfrost/vulkan/panvk_vX_buffer_view.c @@ -49,26 +49,14 @@ panvk_per_arch(CreateBufferView)(VkDevice _device, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; if (buffer->vk.usage & tex_usage_mask) { -#if PAN_ARCH >= 9 struct pan_buffer_view bview = { .format = pfmt, .width_el = view->vk.elements, .base = panvk_buffer_gpu_ptr(buffer, pCreateInfo->offset), }; - +#if PAN_ARCH >= 9 GENX(pan_buffer_texture_emit)(&bview, &view->descs.buf); #else - /* Bifrost requires the base address to be 64 byte aligned and passes the - * remaing offset through the Attribute Descriptor. */ - uint64_t aligned_offset = pCreateInfo->offset & ~0x3f; - uint32_t remainder_offset = pCreateInfo->offset & 0x3f; - struct pan_buffer_view bview = { - .format = pfmt, - .width_el = view->vk.elements, - .base = panvk_buffer_gpu_ptr(buffer, aligned_offset), - .offset = remainder_offset, - }; - GENX(pan_buffer_texture_emit)(&bview, &view->descs.attrib_buf, &view->descs.attrib); #endif