diff options
author | Gurchetan Singh <[email protected]> | 2018-11-09 16:40:03 -0800 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2018-12-19 13:29:16 +0100 |
commit | 2a44acc83b9cefe98c35927b85411cac3108fc65 (patch) | |
tree | 9307a0a89b6302c2760fe9020c7b3e2eafdb09c1 /src/gallium/drivers/virgl/virgl_texture.c | |
parent | f749229a8e16df4e88e2a1d30895f7741b91f1fd (diff) |
virgl: move vrend_get_tex_image_offset to common code
Will be reused.
Reviewed-by: Elie Tournier <[email protected]>
Diffstat (limited to 'src/gallium/drivers/virgl/virgl_texture.c')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_texture.c | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c index 7eba476ff3a..c9d8e541f7d 100644 --- a/src/gallium/drivers/virgl/virgl_texture.c +++ b/src/gallium/drivers/virgl/virgl_texture.c @@ -94,31 +94,6 @@ static void virgl_init_temp_resource_from_box(struct pipe_resource *res, } } -static unsigned -vrend_get_tex_image_offset(const struct virgl_texture *res, - unsigned level, unsigned layer) -{ - const struct pipe_resource *pres = &res->base.u.b; - const unsigned hgt = u_minify(pres->height0, level); - const unsigned nblocksy = util_format_get_nblocksy(pres->format, hgt); - unsigned offset = res->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 * res->metadata.stride[level]; - } - else if (pres->target == PIPE_TEXTURE_1D_ARRAY) { - offset += layer * res->metadata.stride[level]; - } - else { - assert(layer == 0); - } - - return offset; -} - static void *virgl_texture_transfer_map(struct pipe_context *ctx, struct pipe_resource *resource, unsigned level, @@ -179,7 +154,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx, trans->base.stride = ((struct virgl_texture*)trans->resolve_tmp)->metadata.stride[level]; trans->base.layer_stride = trans->base.stride * nblocksy; } else { - offset = vrend_get_tex_image_offset(vtex, level, box->z); + offset = virgl_resource_offset(&vtex->base.u.b, &vtex->metadata, level, box->z); offset += box->y / util_format_get_blockheight(format) * trans->base.stride + box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); |