[Mesa-dev] [PATCH 3/9] i915: Use L8A8 instead of I8 to simulate A8 on gen2
ville.syrjala at linux.intel.com
ville.syrjala at linux.intel.com
Wed Aug 6 11:56:33 PDT 2014
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Gen2 doesn't support the A8 texture format. Currently the driver
substitutes it with I8, but that results in incorrect RGB values.
Use A8L8 instead. We end up wasting a bit of memory, but at least
we should get the correct results.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72819
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80050
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38873
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
src/mesa/drivers/dri/i915/i830_texstate.c | 2 --
src/mesa/drivers/dri/i915/i915_context.c | 3 ++-
src/mesa/drivers/dri/i915/intel_tex_image.c | 22 ++++++++++++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c
index 58d3356..b1414c7 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -47,8 +47,6 @@ translate_texture_format(GLuint mesa_format)
return MAPSURF_8BIT | MT_8BIT_L8;
case MESA_FORMAT_I_UNORM8:
return MAPSURF_8BIT | MT_8BIT_I8;
- case MESA_FORMAT_A_UNORM8:
- return MAPSURF_8BIT | MT_8BIT_I8; /* Kludge! */
case MESA_FORMAT_L8A8_UNORM:
return MAPSURF_16BIT | MT_16BIT_AY88;
case MESA_FORMAT_B5G6R5_UNORM:
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 7f43896..3fd571d 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -109,7 +109,8 @@ intel_init_texture_formats(struct gl_context *ctx)
ctx->TextureFormatSupported[MESA_FORMAT_B5G5R5A1_UNORM] = true;
ctx->TextureFormatSupported[MESA_FORMAT_B5G6R5_UNORM] = true;
ctx->TextureFormatSupported[MESA_FORMAT_L_UNORM8] = true;
- ctx->TextureFormatSupported[MESA_FORMAT_A_UNORM8] = true;
+ if (intel->gen == 3)
+ ctx->TextureFormatSupported[MESA_FORMAT_A_UNORM8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_I_UNORM8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_L8A8_UNORM] = true;
diff --git a/src/mesa/drivers/dri/i915/intel_tex_image.c b/src/mesa/drivers/dri/i915/intel_tex_image.c
index 57674b9..be9a4ff 100644
--- a/src/mesa/drivers/dri/i915/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i915/intel_tex_image.c
@@ -14,6 +14,7 @@
#include "main/texobj.h"
#include "main/teximage.h"
#include "main/texstore.h"
+#include "main/texformat.h"
#include "intel_context.h"
#include "intel_mipmap_tree.h"
@@ -362,9 +363,30 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
image->tile_x, image->tile_y);
}
+static mesa_format intel_choose_tex_format(struct gl_context *ctx,
+ GLenum target,
+ GLint internalFormat,
+ GLenum format, GLenum type)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ switch (internalFormat) {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ /* no A8 on gen2 :( */
+ if (intel->gen == 2)
+ return MESA_FORMAT_L8A8_UNORM;
+ /* fall through */
+ default:
+ return _mesa_choose_tex_format(ctx, target, internalFormat, format, type);
+ }
+}
+
void
intelInitTextureImageFuncs(struct dd_function_table *functions)
{
functions->TexImage = intelTexImage;
+ functions->ChooseTextureFormat = intel_choose_tex_format;
functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
}
--
1.8.5.5
More information about the mesa-dev
mailing list