[Mesa-dev] [PATCH 06/27] intel: Add necessary support to decode multiple ETC2 texture formats
Anuj Phogat
anuj.phogat at gmail.com
Fri Oct 19 16:28:41 PDT 2012
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 9 ++++++---
src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 7 +++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 61ff2db..7ab147c 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -201,6 +201,7 @@ intel_miptree_create(struct intel_context *intel,
GLenum base_format;
bool wraps_etc1 = false;
bool wraps_etc2 = false;
+ gl_format etc2_format;
GLuint total_width, total_height;
if (format == MESA_FORMAT_ETC1_RGB8) {
@@ -209,6 +210,7 @@ intel_miptree_create(struct intel_context *intel,
}
if (format == MESA_FORMAT_ETC2_RGB8) {
+ etc2_format = format;
format = MESA_FORMAT_RGBX8888_REV;
wraps_etc2 = true;
}
@@ -265,6 +267,7 @@ intel_miptree_create(struct intel_context *intel,
mt->wraps_etc1 = wraps_etc1;
mt->wraps_etc2 = wraps_etc2;
+ mt->etc2_format = etc2_format;
mt->region = intel_region_alloc(intel->intelScreen,
tiling,
mt->cpp,
@@ -1292,8 +1295,8 @@ intel_miptree_map_etc2(struct intel_context *intel,
assert(map->mode & GL_MAP_WRITE_BIT);
assert(map->mode & GL_MAP_INVALIDATE_RANGE_BIT);
- map->stride = _mesa_format_row_stride(MESA_FORMAT_ETC2_RGB8, map->w);
- map->buffer = malloc(_mesa_format_image_size(MESA_FORMAT_ETC2_RGB8,
+ map->stride = _mesa_format_row_stride(mt->etc2_format, map->w);
+ map->buffer = malloc(_mesa_format_image_size(mt->etc2_format,
map->w, map->h, 1));
map->ptr = map->buffer;
}
@@ -1315,7 +1318,7 @@ intel_miptree_unmap_etc2(struct intel_context *intel,
_mesa_unpack_etc2_format(xbgr, mt->region->pitch * mt->region->cpp,
map->ptr, map->stride,
- map->w, map->h);
+ map->w, map->h, mt->etc2_format);
intel_region_unmap(intel, mt->region);
free(map->buffer);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index a1121e7..095d45b 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -197,11 +197,14 @@ struct intel_mipmap_tree
* MESA_FORMAT_Z32_FLOAT, otherwise for MESA_FORMAT_S8_Z24 objects it will be
* MESA_FORMAT_X8_Z24.
*
- * For ETC1 textures, this is MESA_FORMAT_RGBX8888_REV if the hardware
- * lacks support for ETC1. See @ref wraps_etc1.
+ * For ETC1 / ETC2 textures, this is MESA_FORMAT_RGBX8888_REV if the hardware
+ * lacks support for ETC1 / ETC2. See @ref wraps_etc1, wraps_etc2.
*/
gl_format format;
+ /** This variable stores the value of ETC2 compressed texture format */
+ gl_format etc2_format;
+
/**
* The X offset of each image in the miptree must be aligned to this. See
* the "Alignment Unit Size" section of the BSpec.
--
1.7.7.6
More information about the mesa-dev
mailing list