[Mesa-dev] [PATCH 1/4] mesa: add texture target field to ChooseTextureFormat() driver hook
Brian Paul
brianp at vmware.com
Fri Aug 24 07:53:05 PDT 2012
This will let us choose the actual hardware format depending on the
type of texture.
---
src/mesa/main/dd.h | 11 +++++++----
src/mesa/main/texformat.c | 4 ++--
src/mesa/main/texformat.h | 4 ++--
src/mesa/main/teximage.c | 5 +++--
src/mesa/main/texobj.c | 3 ++-
src/mesa/state_tracker/st_format.c | 4 ++--
src/mesa/state_tracker/st_format.h | 3 ++-
src/mesa/state_tracker/st_manager.c | 2 +-
8 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 226897b..a91e808 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -189,12 +189,15 @@ struct dd_function_table {
/*@{*/
/**
- * Choose actual hardware texture format given the user-provided source
- * image format and type and the desired internal format. In some
- * cases, srcFormat and srcType can be GL_NONE.
+ * Choose actual hardware texture format given the texture target, the
+ * user-provided source image format and type and the desired internal
+ * format. In some cases, srcFormat and srcType can be GL_NONE.
+ * Note: target may be GL_TEXTURE_CUBE_MAP, but never
+ * GL_TEXTURE_CUBE_MAP_[POSITIVE/NEGATIVE]_[XYZ].
* Called by glTexImage(), etc.
*/
- gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat,
+ gl_format (*ChooseTextureFormat)( struct gl_context *ctx,
+ GLenum target, GLint internalFormat,
GLenum srcFormat, GLenum srcType );
/**
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 275e69e..57f5352 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -61,8 +61,8 @@
* will typically override this function with a specialized version.
*/
gl_format
-_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
- GLenum format, GLenum type )
+_mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
+ GLint internalFormat, GLenum format, GLenum type)
{
(void) format;
(void) type;
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index 3cf0921..71af9ca 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -32,8 +32,8 @@
struct gl_context;
extern gl_format
-_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
- GLenum format, GLenum type );
+_mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
+ GLint internalFormat, GLenum format, GLenum type);
#endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 8ec48eb..59b38de 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2035,7 +2035,7 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
/* check image size against compression block size */
{
gl_format texFormat =
- ctx->Driver.ChooseTextureFormat(ctx, proxy_format,
+ ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format,
choose_format, choose_type);
GLuint bw, bh;
@@ -2797,7 +2797,8 @@ _mesa_choose_texture_format(struct gl_context *ctx,
}
/* choose format from scratch */
- f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
+ f = ctx->Driver.ChooseTextureFormat(ctx, texObj->Target, internalFormat,
+ format, type);
ASSERT(f != MESA_FORMAT_NONE);
return f;
}
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 2b2dccf..638e418 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -783,7 +783,8 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
texObj->Sampler.MinFilter = GL_NEAREST;
texObj->Sampler.MagFilter = GL_NEAREST;
- texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA,
+ texFormat = ctx->Driver.ChooseTextureFormat(ctx, target,
+ GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE);
/* need a loop here just for cube maps */
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 962b092..404b041 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1631,8 +1631,8 @@ st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
* Called via ctx->Driver.ChooseTextureFormat().
*/
gl_format
-st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
- GLenum format, GLenum type)
+st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
+ GLint internalFormat, GLenum format, GLenum type)
{
boolean want_renderable =
internalFormat == 3 || internalFormat == 4 ||
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 7cf92eb..2eef2c0 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -63,7 +63,8 @@ st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
GLenum format, GLenum type, GLboolean renderable);
extern gl_format
-st_ChooseTextureFormat(struct gl_context * ctx, GLint internalFormat,
+st_ChooseTextureFormat(struct gl_context * ctx, GLenum target,
+ GLint internalFormat,
GLenum format, GLenum type);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index c050048..df73d0e 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -533,7 +533,7 @@ st_context_teximage(struct st_context_iface *stctxi,
else
internalFormat = GL_RGB;
- texFormat = st_ChooseTextureFormat(ctx, internalFormat,
+ texFormat = st_ChooseTextureFormat(ctx, target, internalFormat,
GL_BGRA, GL_UNSIGNED_BYTE);
_mesa_init_teximage_fields(ctx, texImage,
--
1.7.3.4
More information about the mesa-dev
mailing list