summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-08-22 08:02:52 -0700
committerAlyssa Rosenzweig <[email protected]>2019-08-22 13:31:39 -0700
commiteeebf5c2dfbf68e8db5a9926bba7ae55ed7c1b54 (patch)
tree5efb6afacfd5857b70caeeda839a72fdaf171f4c /src
parentf4678f3c620d52b55522494e306196e8047f8136 (diff)
panfrost: Remove vertex buffer offset from its size
The offset is added to the base address, so we need to subtract it from the size to maintain the same end address and thus prevent a buffer overflow: end_address = start_address + size start_address' = start_address + offset size' = size - offset end_address' = start_address' + size' = (start_address + offset) + (size - offset) = (start_address + size) + (offset - offset) = start_address + size = end_address QED. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/panfrost/pan_instancing.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gallium/drivers/panfrost/pan_instancing.c b/src/gallium/drivers/panfrost/pan_instancing.c
index 30023725b2e..e5a1e7cfae3 100644
--- a/src/gallium/drivers/panfrost/pan_instancing.c
+++ b/src/gallium/drivers/panfrost/pan_instancing.c
@@ -292,7 +292,7 @@ panfrost_emit_vertex_data(struct panfrost_job *batch)
* will be adjusted back when we fixup the src_offset in
* mali_attr_meta */
- mali_ptr raw_addr = panfrost_vertex_buffer_address(ctx, vbi);
+ mali_ptr raw_addr = rsrc->bo->gpu + buf->buffer_offset;
mali_ptr addr = raw_addr & ~63;
unsigned chopped_addr = raw_addr - addr;
@@ -302,7 +302,10 @@ panfrost_emit_vertex_data(struct panfrost_job *batch)
/* Set common fields */
attrs[k].elements = addr;
attrs[k].stride = buf->stride;
- attrs[k].size = rsrc->base.width0;
+
+ /* Since we advanced the base pointer, we shrink the buffer
+ * size */
+ attrs[k].size = rsrc->base.width0 - buf->buffer_offset;
/* We need to add the extra size we masked off (for
* correctness) so the data doesn't get clamped away */