#include "mfeatures.h"
#include "colortab.h"
#include "context.h"
#include "enums.h"
#include "fbobject.h"
#include "hash.h"
#include "imports.h"
#include "macros.h"
#include "teximage.h"
#include "texstate.h"
#include "texobj.h"
#include "mtypes.h"
#include "shader/prog_instruction.h"
Internal functions | |
#define | incomplete(t, why) |
Report why a texture object is incomplete. | |
struct gl_texture_object * | _mesa_lookup_texture (GLcontext *ctx, GLuint id) |
Return the gl_texture_object for a given ID. | |
struct gl_texture_object * | _mesa_new_texture_object (GLcontext *ctx, GLuint name, GLenum target) |
Allocate and initialize a new texture object. | |
void | _mesa_initialize_texture_object (struct gl_texture_object *obj, GLuint name, GLenum target) |
Initialize a new texture object to default values. | |
static void | finish_texture_init (GLcontext *ctx, GLenum target, struct gl_texture_object *obj) |
Some texture initialization can't be finished until we know which target it's getting bound to (GL_TEXTURE_1D/2D/etc). | |
void | _mesa_delete_texture_object (GLcontext *ctx, struct gl_texture_object *texObj) |
Deallocate a texture object struct. | |
void | _mesa_copy_texture_object (struct gl_texture_object *dest, const struct gl_texture_object *src) |
Copy texture object state from one texture object to another. | |
void | _mesa_clear_texture_object (GLcontext *ctx, struct gl_texture_object *texObj) |
Clear all texture images of the given texture object. | |
static GLboolean | valid_texture_object (const struct gl_texture_object *tex) |
Check if the given texture object is valid by examining its Target field. | |
void | _mesa_reference_texobj (struct gl_texture_object **ptr, struct gl_texture_object *tex) |
Reference (or unreference) a texture object. | |
void | _mesa_test_texobj_completeness (const GLcontext *ctx, struct gl_texture_object *t) |
Examine a texture object to determine if it is complete. | |
void | _mesa_dirty_texobj (GLcontext *ctx, struct gl_texture_object *texObj, GLboolean invalidate_state) |
Mark a texture object dirty. | |
struct gl_texture_object * | _mesa_get_fallback_texture (GLcontext *ctx) |
Return pointer to a default/fallback texture. | |
Functions | |
API functions | |
void GLAPIENTRY | _mesa_GenTextures (GLsizei n, GLuint *textures) |
Generate texture names. | |
static void | unbind_texobj_from_fbo (GLcontext *ctx, struct gl_texture_object *texObj) |
Check if the given texture object is bound to the current draw or read framebuffer. | |
static void | unbind_texobj_from_texunits (GLcontext *ctx, struct gl_texture_object *texObj) |
Check if the given texture object is bound to any texture image units and unbind it if so (revert to default textures). | |
void GLAPIENTRY | _mesa_DeleteTextures (GLsizei n, const GLuint *textures) |
Delete named textures. | |
static GLint | target_enum_to_index (GLenum target) |
Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D into the corresponding Mesa texture target index. | |
void GLAPIENTRY | _mesa_BindTexture (GLenum target, GLuint texName) |
Bind a named texture to a texturing target. | |
void GLAPIENTRY | _mesa_PrioritizeTextures (GLsizei n, const GLuint *texName, const GLclampf *priorities) |
Set texture priorities. | |
GLboolean GLAPIENTRY | _mesa_AreTexturesResident (GLsizei n, const GLuint *texName, GLboolean *residences) |
See if textures are loaded in texture memory. | |
GLboolean GLAPIENTRY | _mesa_IsTexture (GLuint texture) |
See if a name corresponds to a texture. | |
void | _mesa_lock_context_textures (GLcontext *ctx) |
Simplest implementation of texture locking: grab the shared tex mutex. | |
void | _mesa_unlock_context_textures (GLcontext *ctx) |
#define incomplete | ( | t, | |||
why | ) |
Report why a texture object is incomplete.
t | texture object. | |
why | string describing why it's incomplete. |
GLboolean GLAPIENTRY _mesa_AreTexturesResident | ( | GLsizei | n, | |
const GLuint * | texName, | |||
GLboolean * | residences | |||
) |
See if textures are loaded in texture memory.
n | number of textures to query. | |
texName | array with the texture names. | |
residences | array which will hold the residence status. |
residences
is left unchanged,void GLAPIENTRY _mesa_BindTexture | ( | GLenum | target, | |
GLuint | texName | |||
) |
Bind a named texture to a texturing target.
target | texture target. | |
texName | texture name. |
void _mesa_clear_texture_object | ( | GLcontext * | ctx, | |
struct gl_texture_object * | texObj | |||
) |
Clear all texture images of the given texture object.
ctx | GL context. | |
t | texture object. |
void _mesa_copy_texture_object | ( | struct gl_texture_object * | dest, | |
const struct gl_texture_object * | src | |||
) |
Copy texture object state from one texture object to another.
Use for glPush/PopAttrib.
dest | destination texture object. | |
src | source texture object. |
void _mesa_delete_texture_object | ( | GLcontext * | ctx, | |
struct gl_texture_object * | texObj | |||
) |
Deallocate a texture object struct.
It should have already been removed from the texture object pool. Called via ctx->Driver.DeleteTexture() if not overriden by a driver.
shared | the shared GL state to which the object belongs. | |
texObj | the texture object to delete. |
void GLAPIENTRY _mesa_DeleteTextures | ( | GLsizei | n, | |
const GLuint * | textures | |||
) |
Delete named textures.
n | number of textures to be deleted. | |
textures | array of texture IDs to be deleted. |
void _mesa_dirty_texobj | ( | GLcontext * | ctx, | |
struct gl_texture_object * | texObj, | |||
GLboolean | invalidate_state | |||
) |
Mark a texture object dirty.
It forces the object to be incomplete and optionally forces the context to re-validate its state.
ctx | GL context. | |
texObj | texture object. | |
invalidate_state | also invalidate context state. |
void GLAPIENTRY _mesa_GenTextures | ( | GLsizei | n, | |
GLuint * | textures | |||
) |
Generate texture names.
n | number of texture names to be generated. | |
textures | an array in which will hold the generated texture names. |
textures
. Corresponding empty texture objects are also generated.
struct gl_texture_object* _mesa_get_fallback_texture | ( | GLcontext * | ctx | ) | [read] |
Return pointer to a default/fallback texture.
The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). That's the value a sampler should get when sampling from an incomplete texture.
void _mesa_initialize_texture_object | ( | struct gl_texture_object * | obj, | |
GLuint | name, | |||
GLenum | target | |||
) |
Initialize a new texture object to default values.
obj | the texture object | |
name | the texture name | |
target | the texture target |
GLboolean GLAPIENTRY _mesa_IsTexture | ( | GLuint | texture | ) |
See if a name corresponds to a texture.
texture | texture name. |
void _mesa_lock_context_textures | ( | GLcontext * | ctx | ) |
Simplest implementation of texture locking: grab the shared tex mutex.
Examine the shared context state timestamp and if there has been a change, set the appropriate bits in ctx->NewState.
This is used to deal with synchronizing things when a texture object is used/modified by different contexts (or threads) which are sharing the texture.
See also _mesa_lock/unlock_texture() in teximage.h
struct gl_texture_object* _mesa_lookup_texture | ( | GLcontext * | ctx, | |
GLuint | id | |||
) | [read] |
Return the gl_texture_object for a given ID.
struct gl_texture_object* _mesa_new_texture_object | ( | GLcontext * | ctx, | |
GLuint | name, | |||
GLenum | target | |||
) | [read] |
Allocate and initialize a new texture object.
But don't put it into the texture object hash table.
Called via ctx->Driver.NewTextureObject, unless overridden by a device driver.
shared | the shared GL state structure to contain the texture object | |
name | integer name for the texture object | |
target | either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake of GenTextures() |
void GLAPIENTRY _mesa_PrioritizeTextures | ( | GLsizei | n, | |
const GLuint * | texName, | |||
const GLclampf * | priorities | |||
) |
Set texture priorities.
n | number of textures. | |
texName | texture names. | |
priorities | corresponding texture priorities. |
void _mesa_reference_texobj | ( | struct gl_texture_object ** | ptr, | |
struct gl_texture_object * | tex | |||
) |
Reference (or unreference) a texture object.
If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). If 'tex' is non-null, increment its refcount.
void _mesa_test_texobj_completeness | ( | const GLcontext * | ctx, | |
struct gl_texture_object * | t | |||
) |
Examine a texture object to determine if it is complete.
The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE accordingly.
ctx | GL context. | |
t | texture object. |
void _mesa_unlock_context_textures | ( | GLcontext * | ctx | ) |
static void finish_texture_init | ( | GLcontext * | ctx, | |
GLenum | target, | |||
struct gl_texture_object * | obj | |||
) | [static] |
Some texture initialization can't be finished until we know which target it's getting bound to (GL_TEXTURE_1D/2D/etc).
static GLint target_enum_to_index | ( | GLenum | target | ) | [static] |
Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D into the corresponding Mesa texture target index.
Return -1 if target is invalid.
static void unbind_texobj_from_fbo | ( | GLcontext * | ctx, | |
struct gl_texture_object * | texObj | |||
) | [static] |
Check if the given texture object is bound to the current draw or read framebuffer.
If so, Unbind it.
static void unbind_texobj_from_texunits | ( | GLcontext * | ctx, | |
struct gl_texture_object * | texObj | |||
) | [static] |
Check if the given texture object is bound to any texture image units and unbind it if so (revert to default textures).
static GLboolean valid_texture_object | ( | const struct gl_texture_object * | tex | ) | [static] |
Check if the given texture object is valid by examining its Target field.
For debugging only.