#include "texfetch.h"
#include "teximage.h"
#include "texstate.h"
-#include "texstore.h"
#include "mtypes.h"
}
-
-
-#if 0
-static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
-{
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
- _mesa_problem(NULL, "PrintTexture not supported");
-#else
- GLuint i, j, c;
- const GLubyte *data = (const GLubyte *) img->Data;
-
- if (!data) {
- _mesa_printf("No texture data\n");
- return;
- }
-
- switch (img->Format) {
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_INTENSITY:
- case GL_COLOR_INDEX:
- c = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- c = 2;
- break;
- case GL_RGB:
- c = 3;
- break;
- case GL_RGBA:
- c = 4;
- break;
- default:
- _mesa_problem(NULL, "error in PrintTexture\n");
- return;
- }
-
- for (i = 0; i < img->Height; i++) {
- for (j = 0; j < img->Width; j++) {
- if (c==1)
- _mesa_printf("%02x ", data[0]);
- else if (c==2)
- _mesa_printf("%02x%02x ", data[0], data[1]);
- else if (c==3)
- _mesa_printf("%02x%02x%02x ", data[0], data[1], data[2]);
- else if (c==4)
- _mesa_printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
- data += (img->RowStride - img->Width) * c;
- }
- /* XXX use img->ImageStride here */
- _mesa_printf("\n");
- }
-#endif
-}
-#endif
-
-
/*
* Compute floor(log_base_2(n)).
* If n < 0 return -1.
ASSERT(texImage->Data == NULL);
if (texImage->ImageOffsets)
- _mesa_free(texImage->ImageOffsets);
- _mesa_free(texImage);
+ free(texImage->ImageOffsets);
+ free(texImage);
}
}
+/**
+ * Return pointer to texture object for given target on current texture unit.
+ */
+struct gl_texture_object *
+_mesa_get_current_tex_object(GLcontext *ctx, GLenum target)
+{
+ struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+ return _mesa_select_tex_object(ctx, texUnit, target);
+}
+
+
/**
* Get a texture image pointer from a texture object, given a texture
* target and mipmap level. The target and level parameters should
img->Depth = 0;
img->RowStride = 0;
if (img->ImageOffsets) {
- _mesa_free(img->ImageOffsets);
+ free(img->ImageOffsets);
img->ImageOffsets = NULL;
}
img->Width2 = 0;
* case code in the texstore routines.
*/
if (img->ImageOffsets)
- _mesa_free(img->ImageOffsets);
- img->ImageOffsets = (GLuint *) _mesa_malloc(depth * sizeof(GLuint));
+ free(img->ImageOffsets);
+ img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
for (i = 0; i < depth; i++) {
img->ImageOffsets[i] = i * width * height;
}
}
-/**
- * Return pointer to texture object for given target on current texture unit.
- */
-static struct gl_texture_object *
-get_current_tex_object(GLcontext *ctx, GLenum target)
-{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
- return _mesa_select_tex_object(ctx, texUnit, target);
-}
-
-
-
/**
* This is the fallback for Driver.TestProxyTexImage(). Test the texture
* level, width, height and depth against the ctx->Const limits for textures.
if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(internalFormat=0x%x)",
- dimensions, internalFormat);
+ "glTexImage%dD(internalFormat=%s)",
+ dimensions, _mesa_lookup_enum_by_nr(internalFormat));
}
return GL_TRUE;
}
if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
char message[100];
- _mesa_sprintf(message,
+ sprintf(message,
"glTexImage%d(format/type YCBCR mismatch", dimensions);
_mesa_error(ctx, GL_INVALID_ENUM, message);
return GL_TRUE; /* error */
if (border != 0) {
if (!isProxy) {
char message[100];
- _mesa_sprintf(message,
+ sprintf(message,
"glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
dimensions, border);
_mesa_error(ctx, GL_INVALID_VALUE, message);
struct gl_texture_object *texObj, GLint level)
{
ASSERT(target != GL_TEXTURE_CUBE_MAP);
- if (texObj->GenerateMipmap && level == texObj->BaseLevel) {
+ if (texObj->GenerateMipmap &&
+ level == texObj->BaseLevel &&
+ level < texObj->MaxLevel) {
ASSERT(ctx->Driver.GenerateMipmap);
ctx->Driver.GenerateMipmap(ctx, target, texObj);
}
if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
}
+#if FEATURE_OES_EGL_image
+void GLAPIENTRY
+_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
+{
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_TEXTURE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glEGLImageTargetTexture2D(target=%d)", target);
+ return;
+ }
+
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ _mesa_lock_texture(ctx, texObj);
+
+ texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D");
+ } else {
+ if (texImage->Data)
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+
+ ASSERT(texImage->Data == NULL);
+ ctx->Driver.EGLImageTargetTexture2D(ctx, target,
+ texObj, texImage, image);
+
+ /* state update */
+ texObj->_Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ _mesa_unlock_texture(ctx, texObj);
+
+}
+#endif
+
void GLAPIENTRY
_mesa_TexSubImage1D( GLenum target, GLint level,
{
GLsizei postConvWidth = width;
struct gl_texture_object *texObj;
- struct gl_texture_image *texImage = NULL;
+ struct gl_texture_image *texImage;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
assert(texObj);
_mesa_lock_texture(ctx, texObj);
return; /* error was detected */
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
return; /* error was detected */
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
postConvWidth, 1, border))
return;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
postConvWidth, postConvHeight, border))
return;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
if (copytexsubimage_error_check1(ctx, 1, target, level))
return;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
if (copytexsubimage_error_check1(ctx, 2, target, level))
return;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
if (copytexsubimage_error_check1(ctx, 3, target, level))
return;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
}
if (((width == 1 || width == 2) &&
- (GLuint) width != texImage->Width) ||
- (width > texImage->Width)) {
+ width != (GLsizei) texImage->Width) ||
+ (width > (GLsizei) texImage->Width)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCompressedTexSubImage%uD(width=%d)", dims, width);
return GL_TRUE;
if (dims >= 2) {
if (((height == 1 || height == 2) &&
- (GLuint) height != texImage->Height) ||
- (height > texImage->Height)) {
+ height != (GLsizei) texImage->Height) ||
+ (height > (GLsizei) texImage->Height)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCompressedTexSubImage%uD(height=%d)", dims, height);
return GL_TRUE;
if (dims >= 3) {
if (((depth == 1 || depth == 2) &&
- (GLuint) depth != texImage->Depth) ||
- (depth > texImage->Depth)) {
+ depth != (GLsizei) texImage->Depth) ||
+ (depth > (GLsizei) texImage->Depth)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCompressedTexSubImage%uD(depth=%d)", dims, depth);
return GL_TRUE;
return;
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
return;
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
return;
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
return;
}
- texObj = get_current_tex_object(ctx, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{