void intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); GLenum internalFormat = texImage->InternalFormat; /* Need to check texture is compatible with source format. */ if (!do_copy_texsubimage(intel_context(ctx), intel_texture_image(texImage), internalFormat, xoffset, yoffset, x, y, width, height)) { DBG("%s - fallback to swrast\n", __FUNCTION__); _swrast_copy_texsubimage2d(ctx, target, level, xoffset, yoffset, x, y, width, height); } }
void GLAPIENTRY _mesa_GenerateMipmapEXT(GLenum target) { struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); switch (target) { case GL_TEXTURE_1D: case GL_TEXTURE_2D: case GL_TEXTURE_3D: case GL_TEXTURE_CUBE_MAP: /* OK, legal value */ break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target)"); return; } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); /* XXX this might not handle cube maps correctly */ _mesa_lock_texture(ctx, texObj); _mesa_generate_mipmap(ctx, target, texUnit, texObj); _mesa_unlock_texture(ctx, texObj); }
void intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); if (border) goto fail; /* Setup or redefine the texture object, mipmap tree and texture * image. Don't populate yet. */ ctx->Driver.TexImage1D(ctx, target, level, internalFormat, width, border, GL_RGBA, CHAN_TYPE, NULL, &ctx->DefaultPacking, texObj, texImage); if (!do_copy_texsubimage(intel_context(ctx), intel_texture_image(texImage), internalFormat, 0, 0, x, y, width, 1)) goto fail; return; fail: _swrast_copy_teximage1d(ctx, target, level, internalFormat, x, y, width, border); }
static void GLAPIENTRY _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_color_table *table = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; default: /* Try texture targets */ { struct gl_texture_object *texobj = _mesa_select_tex_object(ctx, texUnit, target); if (texobj) { table = &texobj->Palette; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); return; } } } assert(table); switch (pname) { case GL_COLOR_TABLE_FORMAT: *params = table->InternalFormat; break; case GL_COLOR_TABLE_WIDTH: *params = table->Size; break; case GL_COLOR_TABLE_RED_SIZE: *params = table->RedSize; break; case GL_COLOR_TABLE_GREEN_SIZE: *params = table->GreenSize; break; case GL_COLOR_TABLE_BLUE_SIZE: *params = table->BlueSize; break; case GL_COLOR_TABLE_ALPHA_SIZE: *params = table->AlphaSize; break; case GL_COLOR_TABLE_LUMINANCE_SIZE: *params = table->LuminanceSize; break; case GL_COLOR_TABLE_INTENSITY_SIZE: *params = table->IntensitySize; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); return; } }
/** * Bind a pipe surface to a texture object. After the call, * the texture object is marked dirty and will be (re-)validated. * * If this is the first surface bound, the texture object is said to * switch from normal to surface based. It will be cleared first in * this case. * * \param ps pipe surface to be unbound * \param target texture target * \param level image level * \param format internal format of the texture */ int st_bind_texture_surface(struct pipe_surface *ps, int target, int level, enum pipe_format format) { GET_CURRENT_CONTEXT(ctx); const GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; switch (target) { case ST_TEXTURE_2D: target = GL_TEXTURE_2D; break; case ST_TEXTURE_RECT: target = GL_TEXTURE_RECTANGLE_ARB; break; default: return 0; } /* map pipe format to base format for now */ if (pf_get_component_bits(format, PIPE_FORMAT_COMP_A) > 0) internalFormat = GL_RGBA; else internalFormat = GL_RGB; texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); stObj = st_texture_object(texObj); /* switch to surface based */ if (!stObj->surface_based) { _mesa_clear_texture_object(ctx, texObj); stObj->surface_based = GL_TRUE; } texImage = _mesa_get_tex_image(ctx, texObj, target, level); stImage = st_texture_image(texImage); _mesa_init_teximage_fields(ctx, target, texImage, ps->width, ps->height, 1, 0, internalFormat); texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA, GL_UNSIGNED_BYTE); _mesa_set_fetch_functions(texImage, 2); pipe_texture_reference(&stImage->pt, ps->texture); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); return 1; }
void radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); int srcx, srcy, dstx, dsty; radeonContextPtr radeon = RADEON_CONTEXT(ctx); radeon_prepare_render(radeon); if (border) goto fail; /* Setup or redefine the texture object, mipmap tree and texture * image. Don't populate yet. */ ctx->Driver.TexImage2D(ctx, target, level, internalFormat, width, height, border, GL_RGBA, GL_UNSIGNED_BYTE, NULL, &ctx->DefaultPacking, texObj, texImage); srcx = x; srcy = y; dstx = 0; dsty = 0; if (!_mesa_clip_copytexsubimage(ctx, &dstx, &dsty, &srcx, &srcy, &width, &height)) { return; } if (!do_copy_texsubimage(ctx, target, level, radeon_tex_obj(texObj), (radeon_texture_image *)texImage, 0, 0, x, y, width, height)) { goto fail; } return; fail: radeon_print(RADEON_FALLBACKS, RADEON_NORMAL, "Falling back to sw for glCopyTexImage2D (internalFormat %s, border %d)\n", _mesa_lookup_enum_by_nr(internalFormat), border); _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, width, height, border); }
/** * Unbind a pipe surface from a texture object. After the call, * the texture object is marked dirty and will be (re-)validated. * * \param ps pipe surface to be unbound * \param target texture target * \param level image level */ int st_unbind_texture_surface(struct pipe_surface *ps, int target, int level) { GET_CURRENT_CONTEXT(ctx); const GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct st_texture_object *stObj; struct st_texture_image *stImage; switch (target) { case ST_TEXTURE_2D: target = GL_TEXTURE_2D; break; case ST_TEXTURE_RECT: target = GL_TEXTURE_RECTANGLE_ARB; break; default: return 0; } texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); texImage = _mesa_get_tex_image(ctx, texObj, target, level); stObj = st_texture_object(texObj); stImage = st_texture_image(texImage); /* Make sure the pipe surface is still bound. The texture object is still * considered surface based even if this is the last bound surface. */ if (stImage->pt == ps->texture) { pipe_texture_reference(&stImage->pt, NULL); _mesa_clear_texture_image(ctx, texImage); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } _mesa_unlock_texture(ctx, texObj); return 1; }
static void intelCopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); /* Need to check texture is compatible with source format. */ if (!intel_copy_texsubimage(intel_context(ctx), intel_texture_image(texImage), xoffset, yoffset, x, y, width, height)) { fallback_debug("%s - fallback to swrast\n", __FUNCTION__); _mesa_meta_CopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height); } }
static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format, __DRIdrawable *dPriv) { struct dri_context *dri_ctx; int x, y, w, h; __DRIscreen *sPriv = dPriv->driScreenPriv; struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct swrast_texture_image *swImage; uint32_t internalFormat; gl_format texFormat; dri_ctx = pDRICtx->driverPrivate; internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4); texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base); texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target); texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0); swImage = swrast_texture_image(texImage); _mesa_lock_texture(&dri_ctx->Base, texObj); sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate); if (texture_format == __DRI_TEXTURE_FORMAT_RGB) texFormat = MESA_FORMAT_XRGB8888; else texFormat = MESA_FORMAT_ARGB8888; _mesa_init_teximage_fields(&dri_ctx->Base, texImage, w, h, 1, 0, internalFormat, texFormat); sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Buffer, dPriv->loaderPrivate); _mesa_unlock_texture(&dri_ctx->Base, texObj); }
/** * Get texture image. Called by glGetTexImage. * * \param target texture target. * \param level image level. * \param format pixel data format for returned image. * \param type pixel data type for returned image. * \param bufSize size of the pixels data buffer. * \param pixels returned pixel data. */ void GLAPIENTRY _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (getteximage_error_check(ctx, target, level, format, type, pixels)) { return; } if (!pixels) { /* not an error, do nothing */ return; } texObj = _mesa_select_tex_object(ctx, target); texImage = _mesa_select_tex_image(ctx, texObj, target, level); if (_mesa_is_zero_size_texture(texImage)) return; if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," " dstFmt=0x%x, dstType=0x%x\n", texObj->Name, _mesa_get_format_name(texImage->TexFormat), texImage->Width, texImage->Height, format, type); } _mesa_lock_texture(ctx, texObj); { ctx->Driver.GetTexImage(ctx, format, type, pixels, texImage); } _mesa_unlock_texture(ctx, texObj); }
void GLAPIENTRY _mesa_GenerateMipmapEXT(GLenum target) { struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); switch (target) { case GL_TEXTURE_1D: case GL_TEXTURE_2D: case GL_TEXTURE_3D: case GL_TEXTURE_CUBE_MAP: /* OK, legal value */ break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target)"); return; } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); if (target == GL_TEXTURE_CUBE_MAP) { int face; for (face = 0; face < 6; face++) ctx->Driver.GenerateMipmap(ctx, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, texObj); } else { ctx->Driver.GenerateMipmap(ctx, target, texObj); } _mesa_unlock_texture(ctx, texObj); }
void intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); GLenum internalFormat = texImage->InternalFormat; /* XXX need to check <border> as in above function? */ /* Need to check texture is compatible with source format. */ if (!do_copy_texsubimage(intel_context(ctx), intel_texture_image(texImage), internalFormat, xoffset, 0, x, y, width, 1)) { _swrast_copy_texsubimage1d(ctx, target, level, xoffset, x, y, width); } }
void radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); radeonContextPtr radeon = RADEON_CONTEXT(ctx); radeon_prepare_render(radeon); if (!do_copy_texsubimage(ctx, target, level, radeon_tex_obj(texObj), (radeon_texture_image *)texImage, xoffset, yoffset, x, y, width, height)) { radeon_print(RADEON_FALLBACKS, RADEON_NORMAL, "Falling back to sw for glCopyTexSubImage2D\n"); _mesa_meta_CopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height); } }
static void GLAPIENTRY _mesa_GetnColorTableARB( GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_color_table *table = NULL; GLfloat rgba[MAX_COLOR_TABLE_SIZE][4]; GLbitfield transferOps = 0; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (ctx->NewState) { _mesa_update_state(ctx); } switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; default: /* try texture targets */ { struct gl_texture_object *texobj = _mesa_select_tex_object(ctx, texUnit, target); if (texobj && !_mesa_is_proxy_texture(target)) { table = &texobj->Palette; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); return; } } } ASSERT(table); if (table->Size <= 0) { return; } switch (table->_BaseFormat) { case GL_ALPHA: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = 0; rgba[i][GCOMP] = 0; rgba[i][BCOMP] = 0; rgba[i][ACOMP] = table->TableF[i]; } } break; case GL_LUMINANCE: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = table->TableF[i]; rgba[i][ACOMP] = 1.0F; } } break; case GL_LUMINANCE_ALPHA: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = table->TableF[i*2+0]; rgba[i][ACOMP] = table->TableF[i*2+1]; } } break; case GL_INTENSITY: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = table->TableF[i]; } } break; case GL_RGB: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = table->TableF[i*3+0]; rgba[i][GCOMP] = table->TableF[i*3+1]; rgba[i][BCOMP] = table->TableF[i*3+2]; rgba[i][ACOMP] = 1.0F; } } break; case GL_RGBA: memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat)); break; default: _mesa_problem(ctx, "bad table format in glGetColorTable"); return; } data = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, table->Size, 1, 1, format, type, bufSize, data, "glGetColorTable"); if (!data) return; /* TODO: is this correct? */ if(ctx->Color._ClampReadColor) transferOps |= IMAGE_CLAMP_BIT; _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, transferOps); _mesa_unmap_pbo_dest(ctx, &ctx->Pack); }
void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format, __DRIdrawable *dPriv) { struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct radeon_renderbuffer *rb; radeon_texture_image *rImage; radeonContextPtr radeon; r300ContextPtr rmesa; struct radeon_framebuffer *rfb; radeonTexObjPtr t; uint32_t pitch_val; uint32_t internalFormat, type, format; type = GL_BGRA; format = GL_UNSIGNED_BYTE; internalFormat = (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT ? 3 : 4); radeon = pDRICtx->driverPrivate; rmesa = pDRICtx->driverPrivate; rfb = dPriv->driverPrivate; texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target); texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0); rImage = get_radeon_texture_image(texImage); t = radeon_tex_obj(texObj); if (t == NULL) { return; } radeon_update_renderbuffers(pDRICtx, dPriv); /* back & depth buffer are useless free them right away */ rb = (void*)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } rb = (void*)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer; if (rb && rb->bo) { radeon_bo_unref(rb->bo); rb->bo = NULL; } rb = rfb->color_rb[0]; if (rb->bo == NULL) { /* Failed to BO for the buffer */ return; } _mesa_lock_texture(radeon->glCtx, texObj); if (t->bo) { radeon_bo_unref(t->bo); t->bo = NULL; } if (rImage->bo) { radeon_bo_unref(rImage->bo); rImage->bo = NULL; } radeon_miptree_unreference(&t->mt); radeon_miptree_unreference(&rImage->mt); _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp); texImage->RowStride = rb->pitch / rb->cpp; rImage->bo = rb->bo; radeon_bo_ref(rImage->bo); t->bo = rb->bo; radeon_bo_ref(t->bo); t->tile_bits = 0; t->image_override = GL_TRUE; t->override_offset = 0; t->pp_txpitch &= (1 << 13) -1; pitch_val = rb->pitch; switch (rb->cpp) { case 4: if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT) t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8); else t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8); t->pp_txfilter |= tx_table[2].filter; pitch_val /= 4; break; case 3: default: t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8); t->pp_txfilter |= tx_table[4].filter; pitch_val /= 4; break; case 2: t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5); t->pp_txfilter |= tx_table[5].filter; pitch_val /= 2; break; } pitch_val--; t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT))) | ((R300_TX_HEIGHTMASK_MASK & ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT)))); t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN; t->pp_txpitch |= pitch_val; if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) { if (rb->base.Width > 2048) t->pp_txpitch |= R500_TXWIDTH_BIT11; else t->pp_txpitch &= ~R500_TXWIDTH_BIT11; if (rb->base.Height > 2048) t->pp_txpitch |= R500_TXHEIGHT_BIT11; else t->pp_txpitch &= ~R500_TXHEIGHT_BIT11; } t->validated = GL_TRUE; _mesa_unlock_texture(radeon->glCtx, texObj); return; }
void GLAPIENTRY _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) { struct gl_texture_unit *texUnit; struct gl_texture_object *obj; GLboolean error = GL_FALSE; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexParameterfv(current unit)"); return; } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; obj = _mesa_select_tex_object(ctx, texUnit, target); if (!obj) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)"); return; } _mesa_lock_texture(ctx, obj); switch (pname) { case GL_TEXTURE_MAG_FILTER: *params = ENUM_TO_FLOAT(obj->MagFilter); break; case GL_TEXTURE_MIN_FILTER: *params = ENUM_TO_FLOAT(obj->MinFilter); break; case GL_TEXTURE_WRAP_S: *params = ENUM_TO_FLOAT(obj->WrapS); break; case GL_TEXTURE_WRAP_T: *params = ENUM_TO_FLOAT(obj->WrapT); break; case GL_TEXTURE_WRAP_R: *params = ENUM_TO_FLOAT(obj->WrapR); break; case GL_TEXTURE_BORDER_COLOR: params[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F); params[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F); params[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F); params[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F); break; case GL_TEXTURE_RESIDENT: { GLboolean resident; if (ctx->Driver.IsTextureResident) resident = ctx->Driver.IsTextureResident(ctx, obj); else resident = GL_TRUE; *params = ENUM_TO_FLOAT(resident); } break; case GL_TEXTURE_PRIORITY: *params = obj->Priority; break; case GL_TEXTURE_MIN_LOD: *params = obj->MinLod; break; case GL_TEXTURE_MAX_LOD: *params = obj->MaxLod; break; case GL_TEXTURE_BASE_LEVEL: *params = (GLfloat) obj->BaseLevel; break; case GL_TEXTURE_MAX_LEVEL: *params = (GLfloat) obj->MaxLevel; break; case GL_TEXTURE_MAX_ANISOTROPY_EXT: if (ctx->Extensions.EXT_texture_filter_anisotropic) { *params = obj->MaxAnisotropy; } else error = 1; break; case GL_TEXTURE_COMPARE_SGIX: if (ctx->Extensions.SGIX_shadow) { *params = (GLfloat) obj->CompareFlag; } else error = 1; break; case GL_TEXTURE_COMPARE_OPERATOR_SGIX: if (ctx->Extensions.SGIX_shadow) { *params = (GLfloat) obj->CompareOperator; } else error = 1; break; case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ if (ctx->Extensions.SGIX_shadow_ambient) { *params = obj->ShadowAmbient; } else error = 1; break; case GL_GENERATE_MIPMAP_SGIS: if (ctx->Extensions.SGIS_generate_mipmap) { *params = (GLfloat) obj->GenerateMipmap; } else error = 1; break; case GL_TEXTURE_COMPARE_MODE_ARB: if (ctx->Extensions.ARB_shadow) { *params = (GLfloat) obj->CompareMode; } else error = 1; break; case GL_TEXTURE_COMPARE_FUNC_ARB: if (ctx->Extensions.ARB_shadow) { *params = (GLfloat) obj->CompareFunc; } else error = 1; break; case GL_DEPTH_TEXTURE_MODE_ARB: if (ctx->Extensions.ARB_depth_texture) { *params = (GLfloat) obj->DepthMode; } else error = 1; break; case GL_TEXTURE_LOD_BIAS: if (ctx->Extensions.EXT_texture_lod_bias) { *params = obj->LodBias; } else error = 1; break; #ifdef FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: params[0] = obj->CropRect[0]; params[1] = obj->CropRect[1]; params[2] = obj->CropRect[2]; params[3] = obj->CropRect[3]; break; #endif default: error = 1; break; } if (error) _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); _mesa_unlock_texture(ctx, obj); }
void GLAPIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { const struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; const struct gl_texture_image *img = NULL; GLuint dimensions; GLboolean isProxy; GLint maxLevels; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexLevelParameteriv(current unit)"); return; } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; /* this will catch bad target values */ dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */ if (dimensions == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)"); return; } maxLevels = _mesa_max_texture_levels(ctx, target); if (maxLevels == 0) { /* should not happen since <target> was just checked above */ _mesa_problem(ctx, "maxLevels=0 in _mesa_GetTexLevelParameter"); return; } if (level < 0 || level >= maxLevels) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); return; } texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); img = _mesa_select_tex_image(ctx, texObj, target, level); if (!img || !img->TexFormat) { /* undefined texture image */ if (pname == GL_TEXTURE_COMPONENTS) *params = 1; else *params = 0; goto out; } isProxy = _mesa_is_proxy_texture(target); switch (pname) { case GL_TEXTURE_WIDTH: *params = img->Width; break; case GL_TEXTURE_HEIGHT: *params = img->Height; break; case GL_TEXTURE_DEPTH: *params = img->Depth; break; case GL_TEXTURE_INTERNAL_FORMAT: *params = img->InternalFormat; break; case GL_TEXTURE_BORDER: *params = img->Border; break; case GL_TEXTURE_RED_SIZE: if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) *params = img->TexFormat->RedBits; else *params = 0; break; case GL_TEXTURE_GREEN_SIZE: if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) *params = img->TexFormat->GreenBits; else *params = 0; break; case GL_TEXTURE_BLUE_SIZE: if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) *params = img->TexFormat->BlueBits; else *params = 0; break; case GL_TEXTURE_ALPHA_SIZE: if (img->_BaseFormat == GL_ALPHA || img->_BaseFormat == GL_LUMINANCE_ALPHA || img->_BaseFormat == GL_RGBA) *params = img->TexFormat->AlphaBits; else *params = 0; break; case GL_TEXTURE_INTENSITY_SIZE: if (img->_BaseFormat != GL_INTENSITY) *params = 0; else if (img->TexFormat->IntensityBits > 0) *params = img->TexFormat->IntensityBits; else /* intensity probably stored as rgb texture */ *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits); break; case GL_TEXTURE_LUMINANCE_SIZE: if (img->_BaseFormat != GL_LUMINANCE && img->_BaseFormat != GL_LUMINANCE_ALPHA) *params = 0; else if (img->TexFormat->LuminanceBits > 0) *params = img->TexFormat->LuminanceBits; else /* luminance probably stored as rgb texture */ *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits); break; case GL_TEXTURE_INDEX_SIZE_EXT: if (img->_BaseFormat == GL_COLOR_INDEX) *params = img->TexFormat->IndexBits; else *params = 0; break; case GL_TEXTURE_DEPTH_SIZE_ARB: if (ctx->Extensions.ARB_depth_texture) *params = img->TexFormat->DepthBits; else _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); break; case GL_TEXTURE_STENCIL_SIZE_EXT: if (ctx->Extensions.EXT_packed_depth_stencil) { *params = img->TexFormat->StencilBits; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: if (ctx->Extensions.ARB_texture_compression) { if (img->IsCompressed && !isProxy) { /* Don't use ctx->Driver.CompressedTextureSize() since that * may returned a padded hardware size. */ *params = _mesa_compressed_texture_size(ctx, img->Width, img->Height, img->Depth, img->TexFormat->MesaFormat); } else { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexLevelParameter[if]v(pname)"); } } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_COMPRESSED: if (ctx->Extensions.ARB_texture_compression) { *params = (GLint) img->IsCompressed; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; /* GL_ARB_texture_float */ case GL_TEXTURE_RED_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_GREEN_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_BLUE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_ALPHA_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_LUMINANCE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_INTENSITY_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_DEPTH_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } out: _mesa_unlock_texture(ctx, texObj); }
static void GLAPIENTRY _mesa_GetColorTable( GLenum target, GLenum format, GLenum type, GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_color_table *table = NULL; GLfloat rgba[MAX_COLOR_TABLE_SIZE][4]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (ctx->NewState) { _mesa_update_state(ctx); } switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); return; } table = &(texUnit->ColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: /* try texture targets */ { struct gl_texture_object *texobj = _mesa_select_tex_object(ctx, texUnit, target); if (texobj && !_mesa_is_proxy_texture(target)) { table = &texobj->Palette; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); return; } } } ASSERT(table); if (table->Size <= 0) { return; } switch (table->_BaseFormat) { case GL_ALPHA: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = 0; rgba[i][GCOMP] = 0; rgba[i][BCOMP] = 0; rgba[i][ACOMP] = table->TableF[i]; } } break; case GL_LUMINANCE: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = table->TableF[i]; rgba[i][ACOMP] = 1.0F; } } break; case GL_LUMINANCE_ALPHA: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = table->TableF[i*2+0]; rgba[i][ACOMP] = table->TableF[i*2+1]; } } break; case GL_INTENSITY: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = table->TableF[i]; } } break; case GL_RGB: { GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = table->TableF[i*3+0]; rgba[i][GCOMP] = table->TableF[i*3+1]; rgba[i][BCOMP] = table->TableF[i*3+2]; rgba[i][ACOMP] = 1.0F; } } break; case GL_RGBA: _mesa_memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat)); break; default: _mesa_problem(ctx, "bad table format in glGetColorTable"); return; } data = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, table->Size, 1, 1, format, type, data, "glGetColorTable"); if (!data) return; _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, 0x0); _mesa_unmap_pbo_dest(ctx, &ctx->Pack); }
void GLAPIENTRY _mesa_ColorTable( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data ) { static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; GLboolean proxy = GL_FALSE; GLint baseFormat; const GLfloat *scale = one, *bias = zero; GLint comps; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_PROXY_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; proxy = GL_TRUE; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } table = &(texUnit->ColorTable); scale = ctx->Pixel.TextureColorTableScale; bias = ctx->Pixel.TextureColorTableBias; break; case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } table = &(texUnit->ProxyColorTable); proxy = GL_TRUE; break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; proxy = GL_TRUE; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; proxy = GL_TRUE; break; default: /* try texture targets */ { struct gl_texture_object *texobj = _mesa_select_tex_object(ctx, texUnit, target); if (texobj) { table = &texobj->Palette; proxy = _mesa_is_proxy_texture(target); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } } } assert(table); if (!_mesa_is_legal_format_and_type(ctx, format, type) || format == GL_INTENSITY) { _mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)"); return; } baseFormat = base_colortab_format(internalFormat); if (baseFormat < 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)"); return; } if (width < 0 || (width != 0 && !_mesa_is_pow_two(width))) { /* error */ if (proxy) { table->Size = 0; table->InternalFormat = (GLenum) 0; table->_BaseFormat = (GLenum) 0; } else { _mesa_error(ctx, GL_INVALID_VALUE, "glColorTable(width=%d)", width); } return; } if (width > (GLsizei) ctx->Const.MaxColorTableSize) { if (proxy) { table->Size = 0; table->InternalFormat = (GLenum) 0; table->_BaseFormat = (GLenum) 0; } else { _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)"); } return; } table->Size = width; table->InternalFormat = internalFormat; table->_BaseFormat = (GLenum) baseFormat; comps = _mesa_components_in_format(table->_BaseFormat); assert(comps > 0); /* error should have been caught sooner */ if (!proxy) { _mesa_free_colortable_data(table); if (width > 0) { table->TableF = (GLfloat *) _mesa_malloc(comps * width * sizeof(GLfloat)); table->TableUB = (GLubyte *) _mesa_malloc(comps * width * sizeof(GLubyte)); if (!table->TableF || !table->TableUB) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); return; } store_colortable_entries(ctx, table, 0, width, /* start, count */ format, type, data, scale[0], bias[0], scale[1], bias[1], scale[2], bias[2], scale[3], bias[3]); } } /* proxy */ /* do this after the table's Type and Format are set */ set_component_sizes(table); if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { /* texture object palette, texObj==NULL means the shared palette */ if (ctx->Driver.UpdateTexturePalette) { (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } ctx->NewState |= _NEW_PIXEL; }
static boolean st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type tex_type, int level, enum pipe_format pipe_format, struct pipe_resource *tex, boolean mipmap) { struct st_context *st = (struct st_context *) stctxi; struct gl_context *ctx = st->ctx; struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; GLuint width, height, depth; GLenum target; switch (tex_type) { case ST_TEXTURE_1D: target = GL_TEXTURE_1D; break; case ST_TEXTURE_2D: target = GL_TEXTURE_2D; break; case ST_TEXTURE_3D: target = GL_TEXTURE_3D; break; case ST_TEXTURE_RECT: target = GL_TEXTURE_RECTANGLE_ARB; break; default: return FALSE; } texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); stObj = st_texture_object(texObj); /* switch to surface based */ if (!stObj->surface_based) { _mesa_clear_texture_object(ctx, texObj); stObj->surface_based = GL_TRUE; } texImage = _mesa_get_tex_image(ctx, texObj, target, level); stImage = st_texture_image(texImage); if (tex) { gl_format texFormat = st_pipe_format_to_mesa_format(pipe_format); if (util_format_has_alpha(tex->format)) internalFormat = GL_RGBA; else internalFormat = GL_RGB; _mesa_init_teximage_fields(ctx, texImage, tex->width0, tex->height0, 1, 0, internalFormat, texFormat); width = tex->width0; height = tex->height0; depth = tex->depth0; /* grow the image size until we hit level = 0 */ while (level > 0) { if (width != 1) width <<= 1; if (height != 1) height <<= 1; if (depth != 1) depth <<= 1; level--; } } else { _mesa_clear_texture_image(ctx, texImage); width = height = depth = 0; } pipe_resource_reference(&stImage->pt, tex); stObj->width0 = width; stObj->height0 = height; stObj->depth0 = depth; stObj->surface_format = pipe_format; _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); return TRUE; }
static boolean st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target, int level, enum pipe_format internal_format, struct pipe_resource *tex, boolean mipmap) { struct st_context *st = (struct st_context *) stctxi; struct gl_context *ctx = st->ctx; struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; GLuint width, height, depth; switch (target) { case ST_TEXTURE_1D: target = GL_TEXTURE_1D; break; case ST_TEXTURE_2D: target = GL_TEXTURE_2D; break; case ST_TEXTURE_3D: target = GL_TEXTURE_3D; break; case ST_TEXTURE_RECT: target = GL_TEXTURE_RECTANGLE_ARB; break; default: return FALSE; break; } texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); stObj = st_texture_object(texObj); /* switch to surface based */ if (!stObj->surface_based) { _mesa_clear_texture_object(ctx, texObj); stObj->surface_based = GL_TRUE; } texImage = _mesa_get_tex_image(ctx, texObj, target, level); stImage = st_texture_image(texImage); if (tex) { gl_format texFormat; /* * XXX When internal_format and tex->format differ, st_finalize_texture * needs to allocate a new texture with internal_format and copy the * texture here into the new one. It will result in surface_copy being * called on surfaces whose formats differ. * * To avoid that, internal_format is (wrongly) ignored here. A sane fix * is to use a sampler view. */ if (!st_sampler_compat_formats(tex->format, internal_format)) internal_format = tex->format; if (util_format_get_component_bits(internal_format, UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) internalFormat = GL_RGBA; else internalFormat = GL_RGB; texFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_BGRA, GL_UNSIGNED_BYTE); _mesa_init_teximage_fields(ctx, texImage, tex->width0, tex->height0, 1, 0, internalFormat, texFormat); width = tex->width0; height = tex->height0; depth = tex->depth0; /* grow the image size until we hit level = 0 */ while (level > 0) { if (width != 1) width <<= 1; if (height != 1) height <<= 1; if (depth != 1) depth <<= 1; level--; } } else { _mesa_clear_texture_image(ctx, texImage); width = height = depth = 0; } pipe_resource_reference(&stImage->pt, tex); stObj->width0 = width; stObj->height0 = height; stObj->depth0 = depth; _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); return TRUE; }
void GLAPIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { const struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; const struct gl_texture_image *img = NULL; GLint maxLevels; gl_format texFormat; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexLevelParameteriv(current unit)"); return; } texUnit = _mesa_get_current_tex_unit(ctx); /* this will catch bad target values */ maxLevels = _mesa_max_texture_levels(ctx, target); if (maxLevels == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target=0x%x)", target); return; } if (level < 0 || level >= maxLevels) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); return; } texObj = _mesa_select_tex_object(ctx, texUnit, target); img = _mesa_select_tex_image(ctx, texObj, target, level); if (!img || !img->TexFormat) { /* undefined texture image */ if (pname == GL_TEXTURE_COMPONENTS) *params = 1; else *params = 0; return; } texFormat = img->TexFormat; switch (pname) { case GL_TEXTURE_WIDTH: *params = img->Width; break; case GL_TEXTURE_HEIGHT: *params = img->Height; break; case GL_TEXTURE_DEPTH: *params = img->Depth; break; case GL_TEXTURE_INTERNAL_FORMAT: if (_mesa_is_format_compressed(texFormat)) { /* need to return the actual compressed format */ *params = _mesa_compressed_format_to_glenum(ctx, texFormat); } else { /* If the true internal format is not compressed but the user * requested a generic compressed format, we have to return the * generic base format that matches. * * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec: * * "If no specific compressed format is available, * internalformat is instead replaced by the corresponding base * internal format." * * Otherwise just return the user's requested internal format */ const GLenum f = _mesa_gl_compressed_format_base_format(img->InternalFormat); *params = (f != 0) ? f : img->InternalFormat; } break; case GL_TEXTURE_BORDER: *params = img->Border; break; case GL_TEXTURE_RED_SIZE: if (img->_BaseFormat == GL_RED) { *params = _mesa_get_format_bits(texFormat, pname); break; } /* FALLTHROUGH */ case GL_TEXTURE_GREEN_SIZE: if (img->_BaseFormat == GL_RG) { *params = _mesa_get_format_bits(texFormat, pname); break; } /* FALLTHROUGH */ case GL_TEXTURE_BLUE_SIZE: if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_ALPHA_SIZE: if (img->_BaseFormat == GL_ALPHA || img->_BaseFormat == GL_LUMINANCE_ALPHA || img->_BaseFormat == GL_RGBA) *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_INTENSITY_SIZE: if (img->_BaseFormat != GL_INTENSITY) *params = 0; else { *params = _mesa_get_format_bits(texFormat, pname); if (*params == 0) { /* intensity probably stored as rgb texture */ *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); } } break; case GL_TEXTURE_LUMINANCE_SIZE: if (img->_BaseFormat != GL_LUMINANCE && img->_BaseFormat != GL_LUMINANCE_ALPHA) *params = 0; else { *params = _mesa_get_format_bits(texFormat, pname); if (*params == 0) { /* luminance probably stored as rgb texture */ *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); } } break; case GL_TEXTURE_INDEX_SIZE_EXT: if (img->_BaseFormat == GL_COLOR_INDEX) *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_DEPTH_SIZE_ARB: if (ctx->Extensions.ARB_depth_texture) *params = _mesa_get_format_bits(texFormat, pname); else goto invalid_pname; break; case GL_TEXTURE_STENCIL_SIZE_EXT: if (ctx->Extensions.EXT_packed_depth_stencil || ctx->Extensions.ARB_framebuffer_object) { *params = _mesa_get_format_bits(texFormat, pname); } else { goto invalid_pname; } break; case GL_TEXTURE_SHARED_SIZE: if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_shared_exponent) { *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0; } else { goto invalid_pname; } break; /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: if (_mesa_is_format_compressed(texFormat) && !_mesa_is_proxy_texture(target)) { *params = _mesa_format_image_size(texFormat, img->Width, img->Height, img->Depth); } else { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexLevelParameter[if]v(pname)"); } break; case GL_TEXTURE_COMPRESSED: *params = (GLint) _mesa_is_format_compressed(texFormat); break; /* GL_ARB_texture_float */ case GL_TEXTURE_RED_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_GREEN_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_BLUE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_ALPHA_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_LUMINANCE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_INTENSITY_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; case GL_TEXTURE_DEPTH_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? _mesa_get_format_datatype(texFormat) : GL_NONE; } else { goto invalid_pname; } break; default: goto invalid_pname; } /* no error if we get here */ return; invalid_pname: _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname=%s)", _mesa_lookup_enum_by_nr(pname)); }
void GLAPIENTRY _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ) { static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; const GLfloat *scale = one, *bias = zero; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); return; } table = &(texUnit->ColorTable); scale = ctx->Pixel.TextureColorTableScale; bias = ctx->Pixel.TextureColorTableBias; break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; default: /* try texture targets */ texObj = _mesa_select_tex_object(ctx, texUnit, target); if (texObj && !_mesa_is_proxy_texture(target)) { table = &texObj->Palette; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); return; } } assert(table); if (!_mesa_is_legal_format_and_type(ctx, format, type) || format == GL_INTENSITY) { _mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)"); return; } if (count < 1) { _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); return; } /* error should have been caught sooner */ assert(_mesa_components_in_format(table->_BaseFormat) > 0); if (start + count > (GLint) table->Size) { _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); return; } if (!table->TableF || !table->TableUB) { /* a GL_OUT_OF_MEMORY error would have been recorded previously */ return; } store_colortable_entries(ctx, table, start, count, format, type, data, scale[0], bias[0], scale[1], bias[1], scale[2], bias[2], scale[3], bias[3]); if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { /* per-texture object palette */ if (ctx->Driver.UpdateTexturePalette) { (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } ctx->NewState |= _NEW_PIXEL; }
void GLAPIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { struct gl_texture_object *texObj; const struct gl_texture_image *img = NULL; GLint maxLevels; gl_format texFormat; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); /* this will catch bad target values */ maxLevels = _mesa_max_texture_levels(ctx, target); if (maxLevels == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target=0x%x)", target); return; } if (level < 0 || level >= maxLevels) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); return; } texObj = _mesa_select_tex_object(ctx, target); img = _mesa_select_tex_image(ctx, texObj, target, level); if (!img || img->TexFormat == MESA_FORMAT_NONE) { /* undefined texture image */ if (pname == GL_TEXTURE_COMPONENTS) *params = 1; else *params = 0; return; } texFormat = img->TexFormat; switch (pname) { case GL_TEXTURE_WIDTH: *params = img->Width; break; case GL_TEXTURE_HEIGHT: *params = img->Height; break; case GL_TEXTURE_DEPTH: *params = img->Depth; break; case GL_TEXTURE_INTERNAL_FORMAT: *params = img->InternalFormat; break; case GL_TEXTURE_BORDER: *params = img->Border; break; case GL_TEXTURE_RED_SIZE: case GL_TEXTURE_GREEN_SIZE: case GL_TEXTURE_BLUE_SIZE: case GL_TEXTURE_ALPHA_SIZE: if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_INTENSITY_SIZE: case GL_TEXTURE_LUMINANCE_SIZE: if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) { *params = _mesa_get_format_bits(texFormat, pname); if (*params == 0) { /* intensity or luminance is probably stored as RGB[A] */ *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); } } else { *params = 0; } break; /* GL_ARB_texture_float */ case GL_TEXTURE_RED_TYPE_ARB: case GL_TEXTURE_GREEN_TYPE_ARB: case GL_TEXTURE_BLUE_TYPE_ARB: case GL_TEXTURE_ALPHA_TYPE_ARB: case GL_TEXTURE_LUMINANCE_TYPE_ARB: case GL_TEXTURE_INTENSITY_TYPE_ARB: case GL_TEXTURE_DEPTH_TYPE_ARB: if (!ctx->Extensions.ARB_texture_float) goto invalid_pname; if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) *params = _mesa_get_format_datatype(texFormat); else *params = GL_NONE; break; default: goto invalid_pname; } /* no error if we get here */ return; invalid_pname: _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname=%s)", _mesa_lookup_enum_by_nr(pname)); }
static void GLAPIENTRY _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); struct gl_color_table *table = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); switch (target) { case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; params[0] = (GLint) scale[0]; params[1] = (GLint) scale[1]; params[2] = (GLint) scale[2]; params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; params[0] = (GLint) bias[0]; params[1] = (GLint) bias[1]; params[2] = (GLint) bias[2]; params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); return; } table = &(texUnit->ColorTable); if (pname == GL_COLOR_TABLE_SCALE_SGI) { params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0]; params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1]; params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2]; params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0]; params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1]; params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2]; params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3]; return; } break; case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); return; } table = &(texUnit->ProxyColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; params[0] = (GLint) scale[0]; params[1] = (GLint) scale[1]; params[2] = (GLint) scale[2]; params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; params[0] = (GLint) bias[0]; params[1] = (GLint) bias[1]; params[2] = (GLint) bias[2]; params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; params[0] = (GLint) scale[0]; params[0] = (GLint) scale[1]; params[0] = (GLint) scale[2]; params[0] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; params[0] = (GLint) bias[0]; params[1] = (GLint) bias[1]; params[2] = (GLint) bias[2]; params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: /* Try texture targets */ { struct gl_texture_object *texobj = _mesa_select_tex_object(ctx, texUnit, target); if (texobj) { table = &texobj->Palette; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); return; } } } assert(table); switch (pname) { case GL_COLOR_TABLE_FORMAT: *params = table->InternalFormat; break; case GL_COLOR_TABLE_WIDTH: *params = table->Size; break; case GL_COLOR_TABLE_RED_SIZE: *params = table->RedSize; break; case GL_COLOR_TABLE_GREEN_SIZE: *params = table->GreenSize; break; case GL_COLOR_TABLE_BLUE_SIZE: *params = table->BlueSize; break; case GL_COLOR_TABLE_ALPHA_SIZE: *params = table->AlphaSize; break; case GL_COLOR_TABLE_LUMINANCE_SIZE: *params = table->LuminanceSize; break; case GL_COLOR_TABLE_INTENSITY_SIZE: *params = table->IntensitySize; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); return; } }
/** * Do error checking for a glGetTexImage() call. * \return GL_TRUE if any error, GL_FALSE if no errors. */ static GLboolean getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; const GLint maxLevels = _mesa_max_texture_levels(ctx, target); GLenum baseFormat, err; if (maxLevels == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); return GL_TRUE; } if (level < 0 || level >= maxLevels) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); return GL_TRUE; } if (_mesa_sizeof_packed_type(type) <= 0) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); return GL_TRUE; } if (_mesa_components_in_format(format) <= 0 || format == GL_STENCIL_INDEX || format == GL_COLOR_INDEX) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); return GL_TRUE; } if (_mesa_is_depth_format(format)) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); return GL_TRUE; } if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); return GL_TRUE; } err = _mesa_error_check_format_and_type(ctx, format, type); if (err != GL_NO_ERROR) { _mesa_error(ctx, err, "glGetTexImage(format/type)"); return GL_TRUE; } texObj = _mesa_select_tex_object(ctx, target); if (!texObj || _mesa_is_proxy_texture(target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); return GL_TRUE; } texImage = _mesa_select_tex_image(ctx, texObj, target, level); if (!texImage) { /* non-existant texture image */ return GL_TRUE; } baseFormat = _mesa_get_format_base_format(texImage->TexFormat); /* Make sure the requested image format is compatible with the * texture's format. */ if (_mesa_is_color_format(format) && !_mesa_is_color_format(baseFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); return GL_TRUE; } else if (_mesa_is_depth_format(format) && !_mesa_is_depth_format(baseFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); return GL_TRUE; } else if (_mesa_is_ycbcr_format(format) && !_mesa_is_ycbcr_format(baseFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); return GL_TRUE; } return GL_FALSE; }