static void r128TexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { driTextureObject * t = (driTextureObject *) texObj->DriverData; if ( t ) { driSwapOutTextureObject( (driTextureObject *) t ); } else { t = (driTextureObject *) r128AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } /* Note, this will call r128ChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); t->dirty_images[0] |= (1 << level); }
static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData; /* fprintf(stderr, "%s\n", __FUNCTION__); */ if ( t ) { radeonSwapOutTexObj( rmesa, t ); } else { t = radeonAllocTexObj( texObj ); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } texObj->DriverData = t; } /* Note, this will call radeonChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); t->dirty_images |= (1 << level); }
static void i810TexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { driTextureObject *t = (driTextureObject *) texObj->DriverData; if (t) { I810_FIREVERTICES( I810_CONTEXT(ctx) ); driSwapOutTextureObject( t ); } else { t = (driTextureObject *) i810AllocTexObj( ctx, texObj ); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, packing, texObj, texImage ); }
static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { driTextureObject * t = (driTextureObject *) texObj->DriverData; if ( t != NULL ) { driSwapOutTextureObject( t ); } else { t = (driTextureObject *) mgaAllocTexObj( texObj ); if ( t == NULL ) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" ); return; } } _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, packing, texObj, texImage ); level -= t->firstLevel; if (level >= 0) t->dirty_images[0] |= (1UL << level); }
static void mach64TexImage2D( struct gl_context *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); driTextureObject * t = (driTextureObject *) texObj->DriverData; if ( t ) { driSwapOutTextureObject( t ); } else { t = (driTextureObject *) mach64AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } /* Note, this will call mach64ChooseTextureFormat */ _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage ); mmesa->new_state |= MACH64_NEW_TEXTURE; }
static void viaTexImage2D(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData; if (VIA_DEBUG) fprintf(stderr, "viaTexImage2D - in\n"); if (t) { if (level == 0) { viaSwapOutTexObj(VIA_CONTEXT(ctx), t); t->actualLevel = 0; } else t->actualLevel++; } else { t = viaAllocTextureObject(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "viaTexImage2D"); return; } texObj->DriverData = t; } _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, packing, texObj, texImage); if (VIA_DEBUG) fprintf(stderr, "viaTexImage2D - out\n"); }
static void sisTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { sisContextPtr smesa = SIS_CONTEXT(ctx); sisTexObjPtr t; if ( texObj->DriverData == NULL ) sisAllocTexObj( texObj ); t = texObj->DriverData; /* Note, this will call sisChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); /* Allocate offscreen space for the texture */ sisFreeTexImage(smesa, t, level); sisAllocTexImage(smesa, t, level, texImage); /* Upload the texture */ WaitEngIdle(smesa); memcpy(t->image[level].Data, texImage->Data, t->image[level].size); if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) { smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format; } smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; }
static void r128TexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { r128ContextPtr rmesa = R128_CONTEXT(ctx); r128TexObjPtr t = (r128TexObjPtr) texObj->DriverData; if ( t ) { r128SwapOutTexObj( R128_CONTEXT(ctx), t ); } else { t = r128AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } texObj->DriverData = t; } /* Note, this will call r128ChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); t->dirty_images |= (1 << level); rmesa->new_state |= R128_NEW_TEXTURE; }
static void st_TexImage2D(struct gl_context * ctx, struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *unpack) { prep_teximage(ctx, texImage, internalFormat, width, height, 1, border, format, type); _mesa_store_teximage2d(ctx, texImage, internalFormat, width, height, border, format, type, pixels, unpack); }
/* Handles 2D, CUBE, RECT: */ static void intelTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { struct intel_texture_object *intelObj = intel_texture_object(texObj); GLuint face = target_to_face(target); _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, packing, texObj, texImage ); intelObj->dirty_images[face] |= (1 << level); intelObj->dirty |= 1 << face; }
static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { driTextureObject * t = (driTextureObject *) texObj->DriverData; GLuint face; /* which cube face or ordinary 2D image */ switch (target) { case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; ASSERT(face < 6); break; default: face = 0; } if ( t != NULL ) { driSwapOutTextureObject( t ); } else { t = (driTextureObject *) radeonAllocTexObj( texObj ); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } /* Note, this will call ChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); t->dirty_images[face] |= (1 << level); }
/** * \brief Load a texture image. * * \param ctx GL context. * \param texObj texture object * \param target target texture. * \param level level of detail number. * \param internalFormat internal format. * \param width texture image width. * \param height texture image height. * \param border border width. * \param format pixel format. * \param type pixel data type. * \param pixels image data. * \param packing passed to _mesa_store_teximage2d() unchanged. * \param texImage passed to _mesa_store_teximage2d() unchanged. * * If there is a device specific texture object associated with the given * texture object then swaps that texture out. Calls _mesa_store_teximage2d() * with all other parameters unchanged. */ static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData; if ( t ) radeonSwapOutTexObj( rmesa, t ); /* Note, this will call radeonChooseTextureFormat */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); }
static void r300TexImage2D(GLcontext * ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid * pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { driTextureObject *t = (driTextureObject *) texObj->DriverData; GLuint face; /* which cube face or ordinary 2D image */ switch (target) { case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; ASSERT(face < 6); break; default: face = 0; } if (t != NULL) { driSwapOutTextureObject(t); } else { t = (driTextureObject *) r300AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } texImage->IsClientData = GL_FALSE; if (r300ValidateClientStorage(ctx, target, internalFormat, width, height, format, type, pixels, packing, texObj, texImage)) { if (RADEON_DEBUG & DEBUG_TEXTURE) fprintf(stderr, "%s: Using client storage\n", __FUNCTION__); } else { if (RADEON_DEBUG & DEBUG_TEXTURE) fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__); /* Normal path: copy (to cached memory) and eventually upload * via another copy to GART memory and then a blit... Could * eliminate one copy by going straight to (permanent) GART. * * Note, this will call r300ChooseTextureFormat. */ _mesa_store_teximage2d(ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage); t->dirty_images[face] |= (1 << level); } }