diff options
author | Gurchetan Singh <[email protected]> | 2018-11-30 14:31:36 -0800 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2018-12-19 13:29:16 +0100 |
commit | 13626b46f12eaa5ffb6c3eb72eea755e739b0b01 (patch) | |
tree | fad6509ccd9d5fcc085266a89bb44a09555b3338 /src/gallium | |
parent | 2a44acc83b9cefe98c35927b85411cac3108fc65 (diff) |
virgl: store layer_stride in metadata
Reviewed-by: Elie Tournier <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.h | 1 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index b252be1ba33..fa589187f84 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -115,7 +115,7 @@ void virgl_init_context_resource_functions(struct pipe_context *ctx) void virgl_resource_layout(struct pipe_resource *pt, struct virgl_resource_metadata *metadata) { - unsigned level; + unsigned level, nblocksy; unsigned width = pt->width0; unsigned height = pt->height0; unsigned depth = pt->depth0; @@ -131,11 +131,12 @@ void virgl_resource_layout(struct pipe_resource *pt, else slices = pt->array_size; + nblocksy = util_format_get_nblocksy(pt->format, height); metadata->stride[level] = util_format_get_stride(pt->format, width); + metadata->layer_stride[level] = nblocksy * metadata->stride[level]; metadata->level_offset[level] = buffer_size; - buffer_size += (util_format_get_nblocksy(pt->format, height) * - slices * metadata->stride[level]); + buffer_size += slices * metadata->layer_stride[level]; width = u_minify(width, 1); height = u_minify(height, 1); @@ -152,15 +153,13 @@ unsigned virgl_resource_offset(struct pipe_resource *pres, struct virgl_resource_metadata *metadata, unsigned level, unsigned layer) { - const unsigned hgt = u_minify(pres->height0, level); - const unsigned nblocksy = util_format_get_nblocksy(pres->format, hgt); unsigned offset = metadata->level_offset[level]; if (pres->target == PIPE_TEXTURE_CUBE || pres->target == PIPE_TEXTURE_CUBE_ARRAY || pres->target == PIPE_TEXTURE_3D || pres->target == PIPE_TEXTURE_2D_ARRAY) { - offset += layer * nblocksy * metadata->stride[level]; + offset += layer * metadata->layer_stride[level]; } else if (pres->target == PIPE_TEXTURE_1D_ARRAY) { offset += layer * metadata->stride[level]; diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h index 1a43e5ddc5d..5faedb47866 100644 --- a/src/gallium/drivers/virgl/virgl_resource.h +++ b/src/gallium/drivers/virgl/virgl_resource.h @@ -40,6 +40,7 @@ struct virgl_resource_metadata { unsigned long level_offset[VR_MAX_TEXTURE_2D_LEVELS]; unsigned stride[VR_MAX_TEXTURE_2D_LEVELS]; + unsigned layer_stride[VR_MAX_TEXTURE_2D_LEVELS]; uint32_t total_size; }; |