[Mesa-dev] [PATCH 09/12] intel: Refactor selection of miptree's internal formats
Chad Versace
chad.versace at linux.intel.com
Thu Feb 28 15:45:13 PST 2013
Extract from intel_miptree_create() the logic for selecting
intel_mipmap_tree::format and ::etc_format into a new function,
intel_miptree_select_formats(). No behavioral change.
Now, intel_miptree_create() is short enough to be understandable.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 72 ++++++++++++++++----------
1 file changed, 44 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index ce07abf..e3eae11 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -333,59 +333,75 @@ intel_miptree_choose_tiling(struct intel_context *intel,
return I915_TILING_NONE;
}
-struct intel_mipmap_tree *
-intel_miptree_create(struct intel_context *intel,
- GLenum target,
- gl_format format,
- GLuint first_level,
- GLuint last_level,
- GLuint width0,
- GLuint height0,
- GLuint depth0,
- bool expect_accelerated_upload,
- GLuint num_samples,
- bool force_y_tiling)
+/**
+ * \brief Helper function for intel_miptree_create().
+ *
+ * The \a orig_format is that passed to intel_miptree_create().
+ */
+static void
+intel_miptree_select_formats(gl_format orig_format,
+ gl_format *mt_format,
+ gl_format *etc_format)
{
- struct intel_mipmap_tree *mt;
- gl_format tex_format = format;
- gl_format etc_format = MESA_FORMAT_NONE;
- GLuint total_width, total_height;
-
- switch (format) {
+ switch (orig_format) {
case MESA_FORMAT_ETC1_RGB8:
- format = MESA_FORMAT_RGBX8888_REV;
+ *mt_format = MESA_FORMAT_RGBX8888_REV;
break;
case MESA_FORMAT_ETC2_RGB8:
- format = MESA_FORMAT_RGBX8888_REV;
+ *mt_format = MESA_FORMAT_RGBX8888_REV;
break;
case MESA_FORMAT_ETC2_SRGB8:
case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
- format = MESA_FORMAT_SARGB8;
+ *mt_format = MESA_FORMAT_SARGB8;
break;
case MESA_FORMAT_ETC2_RGBA8_EAC:
case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
- format = MESA_FORMAT_RGBA8888_REV;
+ *mt_format = MESA_FORMAT_RGBA8888_REV;
break;
case MESA_FORMAT_ETC2_R11_EAC:
- format = MESA_FORMAT_R16;
+ *mt_format = MESA_FORMAT_R16;
break;
case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
- format = MESA_FORMAT_SIGNED_R16;
+ *mt_format = MESA_FORMAT_SIGNED_R16;
break;
case MESA_FORMAT_ETC2_RG11_EAC:
- format = MESA_FORMAT_GR1616;
+ *mt_format = MESA_FORMAT_GR1616;
break;
case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
- format = MESA_FORMAT_SIGNED_GR1616;
+ *mt_format = MESA_FORMAT_SIGNED_GR1616;
break;
default:
/* Non ETC1 / ETC2 format */
+ *mt_format = orig_format;
break;
}
- etc_format = (format != tex_format) ? tex_format : MESA_FORMAT_NONE;
- mt = intel_miptree_create_layout(intel, target, format,
+ if (*mt_format == orig_format)
+ *etc_format = MESA_FORMAT_NONE;
+ else
+ *etc_format = orig_format;
+}
+
+struct intel_mipmap_tree *
+intel_miptree_create(struct intel_context *intel,
+ GLenum target,
+ gl_format format,
+ GLuint first_level,
+ GLuint last_level,
+ GLuint width0,
+ GLuint height0,
+ GLuint depth0,
+ bool expect_accelerated_upload,
+ GLuint num_samples,
+ bool force_y_tiling)
+{
+ struct intel_mipmap_tree *mt;
+ GLuint total_width, total_height;
+ gl_format mt_format, etc_format;
+
+ intel_miptree_select_formats(format, &mt_format, &etc_format);
+ mt = intel_miptree_create_layout(intel, target, mt_format,
first_level, last_level, width0,
height0, depth0,
false, num_samples);
--
1.8.1.2
More information about the mesa-dev
mailing list