continue;
samp = _mesa_get_samplerobj(ctx, i);
- format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+ format = _mesa_texture_base_format(texObj);
key->unit[i].enabled = 1;
key->enabled_units |= (1<<i);
}
+/**
+ * Return the base format for the given texture object by looking
+ * at the base texture image.
+ * \return base format (such as GL_RGBA) or GL_NONE if it can't be determined
+ */
+GLenum
+_mesa_texture_base_format(const struct gl_texture_object *texObj)
+{
+ const struct gl_texture_image *texImage = _mesa_base_tex_image(texObj);
+
+ return texImage ? texImage->_BaseFormat : GL_NONE;
+}
+
+
static struct gl_texture_object *
invalidate_tex_image_error_check(struct gl_context *ctx, GLuint texture,
GLint level, const char *name)
extern GLuint
_mesa_total_texture_memory(struct gl_context *ctx);
+extern GLenum
+_mesa_texture_base_format(const struct gl_texture_object *texObj);
+
extern void
_mesa_unlock_context_textures( struct gl_context *ctx );
const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
struct gl_sampler_object *msamp;
- const struct gl_texture_image *teximg;
GLenum texBaseFormat;
texobj = ctx->Texture.Unit[texUnit]._Current;
texobj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
}
- teximg = _mesa_base_tex_image_const(texobj);
- texBaseFormat = teximg ? teximg->_BaseFormat : GL_RGBA;
+ texBaseFormat = _mesa_texture_base_format(texobj);
msamp = _mesa_get_samplerobj(ctx, texUnit);
static unsigned
get_texture_format_swizzle(const struct st_texture_object *stObj)
{
- const struct gl_texture_image *texImage =
- _mesa_base_tex_image_const(&stObj->base);
+ GLenum baseFormat = _mesa_texture_base_format(&stObj->base);
unsigned tex_swizzle;
- if (texImage) {
- tex_swizzle = compute_texture_format_swizzle(texImage->_BaseFormat,
+ if (baseFormat != GL_NONE) {
+ tex_swizzle = compute_texture_format_swizzle(baseFormat,
stObj->base.DepthMode,
stObj->pt->format);
}
static GLboolean
is_depth_texture(const struct gl_texture_object *tObj)
{
- GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
+ GLenum format = _mesa_texture_base_format(tObj);
return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT;
}