[virglrenderer-devel] [PATCH 1/2] vrend: create a helper function that returns texture depth
Gurchetan Singh
gurchetansingh at chromium.org
Mon Mar 19 23:09:38 UTC 2018
This is helpful for functions that use glGetTexImage.
---
src/vrend_renderer.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 68bc932..9497a34 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -5140,6 +5140,18 @@ static int vrend_renderer_transfer_write_iov(struct vrend_context *ctx,
return 0;
}
+static uint32_t vrend_get_texture_depth(struct vrend_resource *res, uint32_t level)
+{
+ uint32_t depth = 1;
+ if (res->target == GL_TEXTURE_3D)
+ depth = u_minify(res->base.depth0, level);
+ else if (res->target == GL_TEXTURE_1D_ARRAY || res->target == GL_TEXTURE_2D_ARRAY ||
+ res->target == GL_TEXTURE_CUBE_MAP || res->target == GL_TEXTURE_CUBE_MAP_ARRAY)
+ depth = res->base.array_size;
+
+ return depth;
+}
+
static int vrend_transfer_send_getteximage(struct vrend_context *ctx,
struct vrend_resource *res,
struct iovec *iov, int num_iovs,
@@ -5151,7 +5163,6 @@ static int vrend_transfer_send_getteximage(struct vrend_context *ctx,
int elsize = util_format_get_blocksize(res->base.format);
int compressed = util_format_is_compressed(res->base.format);
GLenum target;
- uint32_t depth = 1;
uint32_t send_offset = 0;
format = tex_conv_table[res->base.format].glformat;
type = tex_conv_table[res->base.format].gltype;
@@ -5159,12 +5170,8 @@ static int vrend_transfer_send_getteximage(struct vrend_context *ctx,
if (compressed)
format = tex_conv_table[res->base.format].internalformat;
- if (res->target == GL_TEXTURE_3D)
- depth = u_minify(res->base.depth0, info->level);
- else if (res->target == GL_TEXTURE_2D_ARRAY || res->target == GL_TEXTURE_1D_ARRAY || res->target == GL_TEXTURE_CUBE_MAP_ARRAY)
- depth = res->base.array_size;
-
- tex_size = util_format_get_nblocks(res->base.format, u_minify(res->base.width0, info->level), u_minify(res->base.height0, info->level)) * util_format_get_blocksize(res->base.format) * depth;
+ tex_size = util_format_get_nblocks(res->base.format, u_minify(res->base.width0, info->level), u_minify(res->base.height0, info->level)) *
+ util_format_get_blocksize(res->base.format) * vrend_get_texture_depth(res, info->level);
if (info->box->z && res->target != GL_TEXTURE_CUBE_MAP) {
send_offset = util_format_get_nblocks(res->base.format, u_minify(res->base.width0, info->level), u_minify(res->base.height0, info->level)) * util_format_get_blocksize(res->base.format) * info->box->z;
--
2.16.2.804.g6dcf76e118-goog
More information about the virglrenderer-devel
mailing list