aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/freedreno_resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_resource.h')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index b16e5a2781c..1d3931b2a03 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -156,17 +156,22 @@ fd_resource_slice(struct fd_resource *rsc, unsigned level)
return &rsc->slices[level];
}
+static inline uint32_t
+fd_resource_layer_stride(struct fd_resource *rsc, unsigned level)
+{
+ if (rsc->layer_first)
+ return rsc->layer_size;
+ else
+ return fd_resource_slice(rsc, level)->size0;
+}
+
/* get offset for specified mipmap level and texture/array layer */
static inline uint32_t
fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer)
{
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
- unsigned offset;
- if (rsc->layer_first) {
- offset = slice->offset + (rsc->layer_size * layer);
- } else {
- offset = slice->offset + (slice->size0 * layer);
- }
+ unsigned offset = slice->offset;
+ offset += fd_resource_layer_stride(rsc, level) * layer;
debug_assert(offset < fd_bo_size(rsc->bo));
return offset + rsc->offset;
}