2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * glTexParameter-related functions
33 #include "main/glheader.h"
34 #include "main/colormac.h"
35 #include "main/context.h"
36 #include "main/enums.h"
37 #include "main/formats.h"
38 #include "main/macros.h"
39 #include "main/mfeatures.h"
40 #include "main/mtypes.h"
41 #include "main/state.h"
42 #include "main/texcompress.h"
43 #include "main/texparam.h"
44 #include "main/teximage.h"
45 #include "main/texstate.h"
46 #include "program/prog_instruction.h"
50 * Check if a coordinate wrap mode is supported for the texture target.
51 * \return GL_TRUE if legal, GL_FALSE otherwise
54 validate_texture_wrap_mode(struct gl_context
* ctx
, GLenum target
, GLenum wrap
)
56 const struct gl_extensions
* const e
= & ctx
->Extensions
;
58 if (target
== GL_TEXTURE_RECTANGLE_NV
) {
59 if (wrap
== GL_CLAMP
|| wrap
== GL_CLAMP_TO_EDGE
||
60 (wrap
== GL_CLAMP_TO_BORDER
&& e
->ARB_texture_border_clamp
))
63 else if (target
== GL_TEXTURE_EXTERNAL_OES
) {
64 if (wrap
== GL_CLAMP_TO_EDGE
)
71 case GL_CLAMP_TO_EDGE
:
72 case GL_MIRRORED_REPEAT
:
74 case GL_CLAMP_TO_BORDER
:
75 if (e
->ARB_texture_border_clamp
)
78 case GL_MIRROR_CLAMP_EXT
:
79 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
80 if (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)
83 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
84 if (e
->EXT_texture_mirror_clamp
)
92 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
98 * Get current texture object for given target.
99 * Return NULL if any error (and record the error).
100 * Note that this is different from _mesa_select_tex_object() in that proxy
101 * targets are not accepted.
102 * Only the glGetTexLevelParameter() functions accept proxy targets.
104 static struct gl_texture_object
*
105 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
107 struct gl_texture_unit
*texUnit
;
109 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
110 _mesa_error(ctx
, GL_INVALID_OPERATION
,
111 "gl%sTexParameter(current unit)", get
? "Get" : "");
115 texUnit
= _mesa_get_current_tex_unit(ctx
);
119 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
121 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
123 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
124 case GL_TEXTURE_CUBE_MAP
:
125 if (ctx
->Extensions
.ARB_texture_cube_map
) {
126 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
129 case GL_TEXTURE_RECTANGLE_NV
:
130 if (ctx
->Extensions
.NV_texture_rectangle
) {
131 return texUnit
->CurrentTex
[TEXTURE_RECT_INDEX
];
134 case GL_TEXTURE_1D_ARRAY_EXT
:
135 if (ctx
->Extensions
.MESA_texture_array
||
136 ctx
->Extensions
.EXT_texture_array
) {
137 return texUnit
->CurrentTex
[TEXTURE_1D_ARRAY_INDEX
];
140 case GL_TEXTURE_2D_ARRAY_EXT
:
141 if (ctx
->Extensions
.MESA_texture_array
||
142 ctx
->Extensions
.EXT_texture_array
) {
143 return texUnit
->CurrentTex
[TEXTURE_2D_ARRAY_INDEX
];
146 case GL_TEXTURE_EXTERNAL_OES
:
147 if (ctx
->Extensions
.OES_EGL_image_external
) {
148 return texUnit
->CurrentTex
[TEXTURE_EXTERNAL_INDEX
];
155 _mesa_error(ctx
, GL_INVALID_ENUM
,
156 "gl%sTexParameter(target)", get
? "Get" : "");
162 * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE.
163 * \return -1 if error.
166 comp_to_swizzle(GLenum comp
)
188 set_swizzle_component(GLuint
*swizzle
, GLuint comp
, GLuint swz
)
191 ASSERT(swz
<= SWIZZLE_NIL
);
193 GLuint mask
= 0x7 << (3 * comp
);
194 GLuint s
= (*swizzle
& ~mask
) | (swz
<< (3 * comp
));
201 * This is called just prior to changing any texture object state which
202 * will not effect texture completeness.
205 flush(struct gl_context
*ctx
)
207 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
212 * This is called just prior to changing any texture object state which
213 * can effect texture completeness (texture base level, max level,
214 * minification filter).
215 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
216 * state flag and then mark the texture object as 'incomplete' so that any
217 * per-texture derived state gets recomputed.
220 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
222 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
223 texObj
->_Complete
= GL_FALSE
;
228 * Set an integer-valued texture parameter
229 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
232 set_tex_parameteri(struct gl_context
*ctx
,
233 struct gl_texture_object
*texObj
,
234 GLenum pname
, const GLint
*params
)
237 case GL_TEXTURE_MIN_FILTER
:
238 if (texObj
->Sampler
.MinFilter
== params
[0])
243 incomplete(ctx
, texObj
);
244 texObj
->Sampler
.MinFilter
= params
[0];
246 case GL_NEAREST_MIPMAP_NEAREST
:
247 case GL_LINEAR_MIPMAP_NEAREST
:
248 case GL_NEAREST_MIPMAP_LINEAR
:
249 case GL_LINEAR_MIPMAP_LINEAR
:
250 if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
251 texObj
->Target
!= GL_TEXTURE_EXTERNAL_OES
) {
252 incomplete(ctx
, texObj
);
253 texObj
->Sampler
.MinFilter
= params
[0];
262 case GL_TEXTURE_MAG_FILTER
:
263 if (texObj
->Sampler
.MagFilter
== params
[0])
268 flush(ctx
); /* does not effect completeness */
269 texObj
->Sampler
.MagFilter
= params
[0];
276 case GL_TEXTURE_WRAP_S
:
277 if (texObj
->Sampler
.WrapS
== params
[0])
279 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
281 texObj
->Sampler
.WrapS
= params
[0];
286 case GL_TEXTURE_WRAP_T
:
287 if (texObj
->Sampler
.WrapT
== params
[0])
289 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
291 texObj
->Sampler
.WrapT
= params
[0];
296 case GL_TEXTURE_WRAP_R
:
297 if (texObj
->Sampler
.WrapR
== params
[0])
299 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
301 texObj
->Sampler
.WrapR
= params
[0];
306 case GL_TEXTURE_BASE_LEVEL
:
307 if (texObj
->BaseLevel
== params
[0])
310 (texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
&& params
[0] != 0)) {
311 _mesa_error(ctx
, GL_INVALID_VALUE
,
312 "glTexParameter(param=%d)", params
[0]);
315 incomplete(ctx
, texObj
);
316 texObj
->BaseLevel
= params
[0];
319 case GL_TEXTURE_MAX_LEVEL
:
320 if (texObj
->MaxLevel
== params
[0])
322 if (params
[0] < 0 || texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
) {
323 _mesa_error(ctx
, GL_INVALID_OPERATION
,
324 "glTexParameter(param=%d)", params
[0]);
327 incomplete(ctx
, texObj
);
328 texObj
->MaxLevel
= params
[0];
331 case GL_GENERATE_MIPMAP_SGIS
:
332 if (params
[0] && texObj
->Target
== GL_TEXTURE_EXTERNAL_OES
)
334 if (texObj
->GenerateMipmap
!= params
[0]) {
336 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
341 case GL_TEXTURE_COMPARE_MODE_ARB
:
342 if (ctx
->Extensions
.ARB_shadow
) {
343 if (texObj
->Sampler
.CompareMode
== params
[0])
345 if (params
[0] == GL_NONE
||
346 params
[0] == GL_COMPARE_R_TO_TEXTURE_ARB
) {
348 texObj
->Sampler
.CompareMode
= params
[0];
355 case GL_TEXTURE_COMPARE_FUNC_ARB
:
356 if (ctx
->Extensions
.ARB_shadow
) {
357 if (texObj
->Sampler
.CompareFunc
== params
[0])
363 texObj
->Sampler
.CompareFunc
= params
[0];
371 if (ctx
->Extensions
.EXT_shadow_funcs
) {
373 texObj
->Sampler
.CompareFunc
= params
[0];
383 case GL_DEPTH_TEXTURE_MODE_ARB
:
384 if (ctx
->Extensions
.ARB_depth_texture
) {
385 if (texObj
->Sampler
.DepthMode
== params
[0])
387 if (params
[0] == GL_LUMINANCE
||
388 params
[0] == GL_INTENSITY
||
389 params
[0] == GL_ALPHA
||
390 (ctx
->Extensions
.ARB_texture_rg
&& params
[0] == GL_RED
)) {
392 texObj
->Sampler
.DepthMode
= params
[0];
399 #if FEATURE_OES_draw_texture
400 case GL_TEXTURE_CROP_RECT_OES
:
401 texObj
->CropRect
[0] = params
[0];
402 texObj
->CropRect
[1] = params
[1];
403 texObj
->CropRect
[2] = params
[2];
404 texObj
->CropRect
[3] = params
[3];
408 case GL_TEXTURE_SWIZZLE_R_EXT
:
409 case GL_TEXTURE_SWIZZLE_G_EXT
:
410 case GL_TEXTURE_SWIZZLE_B_EXT
:
411 case GL_TEXTURE_SWIZZLE_A_EXT
:
412 if (ctx
->Extensions
.EXT_texture_swizzle
) {
413 const GLuint comp
= pname
- GL_TEXTURE_SWIZZLE_R_EXT
;
414 const GLint swz
= comp_to_swizzle(params
[0]);
416 _mesa_error(ctx
, GL_INVALID_OPERATION
,
417 "glTexParameter(swizzle 0x%x)", params
[0]);
423 texObj
->Swizzle
[comp
] = params
[0];
424 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
429 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
430 if (ctx
->Extensions
.EXT_texture_swizzle
) {
433 for (comp
= 0; comp
< 4; comp
++) {
434 const GLint swz
= comp_to_swizzle(params
[comp
]);
436 texObj
->Swizzle
[comp
] = params
[comp
];
437 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
440 _mesa_error(ctx
, GL_INVALID_OPERATION
,
441 "glTexParameter(swizzle 0x%x)", params
[comp
]);
449 case GL_TEXTURE_SRGB_DECODE_EXT
:
450 if (ctx
->Extensions
.EXT_texture_sRGB_decode
) {
451 GLenum decode
= params
[0];
452 if (decode
== GL_DECODE_EXT
|| decode
== GL_SKIP_DECODE_EXT
) {
453 if (texObj
->Sampler
.sRGBDecode
!= decode
) {
455 texObj
->Sampler
.sRGBDecode
= decode
;
462 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
463 if (ctx
->Extensions
.AMD_seamless_cubemap_per_texture
) {
464 GLenum param
= params
[0];
465 if (param
!= GL_TRUE
&& param
!= GL_FALSE
) {
468 if (param
!= texObj
->Sampler
.CubeMapSeamless
) {
470 texObj
->Sampler
.CubeMapSeamless
= param
;
481 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
482 _mesa_lookup_enum_by_nr(pname
));
486 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
487 _mesa_lookup_enum_by_nr(params
[0]));
493 * Set a float-valued texture parameter
494 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
497 set_tex_parameterf(struct gl_context
*ctx
,
498 struct gl_texture_object
*texObj
,
499 GLenum pname
, const GLfloat
*params
)
502 case GL_TEXTURE_MIN_LOD
:
503 if (texObj
->Sampler
.MinLod
== params
[0])
506 texObj
->Sampler
.MinLod
= params
[0];
509 case GL_TEXTURE_MAX_LOD
:
510 if (texObj
->Sampler
.MaxLod
== params
[0])
513 texObj
->Sampler
.MaxLod
= params
[0];
516 case GL_TEXTURE_PRIORITY
:
518 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
521 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
522 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
523 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
525 if (params
[0] < 1.0) {
526 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
530 /* clamp to max, that's what NVIDIA does */
531 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
532 ctx
->Const
.MaxTextureMaxAnisotropy
);
536 static GLuint count
= 0;
538 _mesa_error(ctx
, GL_INVALID_ENUM
,
539 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
543 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
544 if (ctx
->Extensions
.ARB_shadow_ambient
) {
545 if (texObj
->Sampler
.CompareFailValue
!= params
[0]) {
547 texObj
->Sampler
.CompareFailValue
= CLAMP(params
[0], 0.0F
, 1.0F
);
552 _mesa_error(ctx
, GL_INVALID_ENUM
,
553 "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)");
557 case GL_TEXTURE_LOD_BIAS
:
558 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
559 if (texObj
->Sampler
.LodBias
!= params
[0]) {
561 texObj
->Sampler
.LodBias
= params
[0];
566 case GL_TEXTURE_BORDER_COLOR
:
568 /* ARB_texture_float disables clamping */
569 if (ctx
->Extensions
.ARB_texture_float
) {
570 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
571 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
572 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
573 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
575 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
576 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
577 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
578 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
583 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
590 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
592 GLboolean need_update
;
593 struct gl_texture_object
*texObj
;
594 GET_CURRENT_CONTEXT(ctx
);
595 ASSERT_OUTSIDE_BEGIN_END(ctx
);
597 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
602 case GL_TEXTURE_MIN_FILTER
:
603 case GL_TEXTURE_MAG_FILTER
:
604 case GL_TEXTURE_WRAP_S
:
605 case GL_TEXTURE_WRAP_T
:
606 case GL_TEXTURE_WRAP_R
:
607 case GL_TEXTURE_BASE_LEVEL
:
608 case GL_TEXTURE_MAX_LEVEL
:
609 case GL_GENERATE_MIPMAP_SGIS
:
610 case GL_TEXTURE_COMPARE_MODE_ARB
:
611 case GL_TEXTURE_COMPARE_FUNC_ARB
:
612 case GL_DEPTH_TEXTURE_MODE_ARB
:
613 case GL_TEXTURE_SRGB_DECODE_EXT
:
614 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
616 /* convert float param to int */
618 p
[0] = (GLint
) param
;
619 p
[1] = p
[2] = p
[3] = 0;
620 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
623 case GL_TEXTURE_SWIZZLE_R_EXT
:
624 case GL_TEXTURE_SWIZZLE_G_EXT
:
625 case GL_TEXTURE_SWIZZLE_B_EXT
:
626 case GL_TEXTURE_SWIZZLE_A_EXT
:
629 p
[0] = (GLint
) param
;
630 p
[1] = p
[2] = p
[3] = 0;
631 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
636 /* this will generate an error if pname is illegal */
639 p
[1] = p
[2] = p
[3] = 0.0F
;
640 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
644 if (ctx
->Driver
.TexParameter
&& need_update
) {
645 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
651 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
653 GLboolean need_update
;
654 struct gl_texture_object
*texObj
;
655 GET_CURRENT_CONTEXT(ctx
);
656 ASSERT_OUTSIDE_BEGIN_END(ctx
);
658 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
663 case GL_TEXTURE_MIN_FILTER
:
664 case GL_TEXTURE_MAG_FILTER
:
665 case GL_TEXTURE_WRAP_S
:
666 case GL_TEXTURE_WRAP_T
:
667 case GL_TEXTURE_WRAP_R
:
668 case GL_TEXTURE_BASE_LEVEL
:
669 case GL_TEXTURE_MAX_LEVEL
:
670 case GL_GENERATE_MIPMAP_SGIS
:
671 case GL_TEXTURE_COMPARE_MODE_ARB
:
672 case GL_TEXTURE_COMPARE_FUNC_ARB
:
673 case GL_DEPTH_TEXTURE_MODE_ARB
:
674 case GL_TEXTURE_SRGB_DECODE_EXT
:
675 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
677 /* convert float param to int */
679 p
[0] = (GLint
) params
[0];
680 p
[1] = p
[2] = p
[3] = 0;
681 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
685 #if FEATURE_OES_draw_texture
686 case GL_TEXTURE_CROP_RECT_OES
:
688 /* convert float params to int */
690 iparams
[0] = (GLint
) params
[0];
691 iparams
[1] = (GLint
) params
[1];
692 iparams
[2] = (GLint
) params
[2];
693 iparams
[3] = (GLint
) params
[3];
694 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparams
);
699 case GL_TEXTURE_SWIZZLE_R_EXT
:
700 case GL_TEXTURE_SWIZZLE_G_EXT
:
701 case GL_TEXTURE_SWIZZLE_B_EXT
:
702 case GL_TEXTURE_SWIZZLE_A_EXT
:
703 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
705 GLint p
[4] = {0, 0, 0, 0};
706 p
[0] = (GLint
) params
[0];
707 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
708 p
[1] = (GLint
) params
[1];
709 p
[2] = (GLint
) params
[2];
710 p
[3] = (GLint
) params
[3];
712 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
716 /* this will generate an error if pname is illegal */
717 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
720 if (ctx
->Driver
.TexParameter
&& need_update
) {
721 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
727 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
729 GLboolean need_update
;
730 struct gl_texture_object
*texObj
;
731 GET_CURRENT_CONTEXT(ctx
);
732 ASSERT_OUTSIDE_BEGIN_END(ctx
);
734 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
739 case GL_TEXTURE_MIN_LOD
:
740 case GL_TEXTURE_MAX_LOD
:
741 case GL_TEXTURE_PRIORITY
:
742 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
743 case GL_TEXTURE_LOD_BIAS
:
744 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
747 fparam
[0] = (GLfloat
) param
;
748 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
749 /* convert int param to float */
750 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
754 /* this will generate an error if pname is illegal */
758 iparam
[1] = iparam
[2] = iparam
[3] = 0;
759 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
763 if (ctx
->Driver
.TexParameter
&& need_update
) {
764 GLfloat fparam
= (GLfloat
) param
;
765 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
771 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
773 GLboolean need_update
;
774 struct gl_texture_object
*texObj
;
775 GET_CURRENT_CONTEXT(ctx
);
776 ASSERT_OUTSIDE_BEGIN_END(ctx
);
778 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
783 case GL_TEXTURE_BORDER_COLOR
:
785 /* convert int params to float */
787 fparams
[0] = INT_TO_FLOAT(params
[0]);
788 fparams
[1] = INT_TO_FLOAT(params
[1]);
789 fparams
[2] = INT_TO_FLOAT(params
[2]);
790 fparams
[3] = INT_TO_FLOAT(params
[3]);
791 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
794 case GL_TEXTURE_MIN_LOD
:
795 case GL_TEXTURE_MAX_LOD
:
796 case GL_TEXTURE_PRIORITY
:
797 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
798 case GL_TEXTURE_LOD_BIAS
:
799 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
801 /* convert int param to float */
803 fparams
[0] = (GLfloat
) params
[0];
804 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
805 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
809 /* this will generate an error if pname is illegal */
810 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
813 if (ctx
->Driver
.TexParameter
&& need_update
) {
815 fparams
[0] = INT_TO_FLOAT(params
[0]);
816 if (pname
== GL_TEXTURE_BORDER_COLOR
||
817 pname
== GL_TEXTURE_CROP_RECT_OES
) {
818 fparams
[1] = INT_TO_FLOAT(params
[1]);
819 fparams
[2] = INT_TO_FLOAT(params
[2]);
820 fparams
[3] = INT_TO_FLOAT(params
[3]);
822 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
828 * Set tex parameter to integer value(s). Primarily intended to set
829 * integer-valued texture border color (for integer-valued textures).
833 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
835 struct gl_texture_object
*texObj
;
836 GET_CURRENT_CONTEXT(ctx
);
837 ASSERT_OUTSIDE_BEGIN_END(ctx
);
839 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
844 case GL_TEXTURE_BORDER_COLOR
:
845 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
846 /* set the integer-valued border color */
847 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
850 _mesa_TexParameteriv(target
, pname
, params
);
853 /* XXX no driver hook for TexParameterIiv() yet */
858 * Set tex parameter to unsigned integer value(s). Primarily intended to set
859 * uint-valued texture border color (for integer-valued textures).
863 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
865 struct gl_texture_object
*texObj
;
866 GET_CURRENT_CONTEXT(ctx
);
867 ASSERT_OUTSIDE_BEGIN_END(ctx
);
869 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
874 case GL_TEXTURE_BORDER_COLOR
:
875 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
876 /* set the unsigned integer-valued border color */
877 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
880 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
883 /* XXX no driver hook for TexParameterIuiv() yet */
888 base_format_has_channel(GLenum base_format
, GLenum pname
)
891 case GL_TEXTURE_RED_SIZE
:
892 case GL_TEXTURE_RED_TYPE
:
893 if (base_format
== GL_RED
||
894 base_format
== GL_RG
||
895 base_format
== GL_RGB
||
896 base_format
== GL_RGBA
) {
900 case GL_TEXTURE_GREEN_SIZE
:
901 case GL_TEXTURE_GREEN_TYPE
:
902 if (base_format
== GL_RG
||
903 base_format
== GL_RGB
||
904 base_format
== GL_RGBA
) {
908 case GL_TEXTURE_BLUE_SIZE
:
909 case GL_TEXTURE_BLUE_TYPE
:
910 if (base_format
== GL_RGB
||
911 base_format
== GL_RGBA
) {
915 case GL_TEXTURE_ALPHA_SIZE
:
916 case GL_TEXTURE_ALPHA_TYPE
:
917 if (base_format
== GL_RGBA
||
918 base_format
== GL_ALPHA
||
919 base_format
== GL_LUMINANCE_ALPHA
) {
923 case GL_TEXTURE_LUMINANCE_SIZE
:
924 case GL_TEXTURE_LUMINANCE_TYPE
:
925 if (base_format
== GL_LUMINANCE
||
926 base_format
== GL_LUMINANCE_ALPHA
) {
930 case GL_TEXTURE_INTENSITY_SIZE
:
931 case GL_TEXTURE_INTENSITY_TYPE
:
932 if (base_format
== GL_INTENSITY
) {
936 case GL_TEXTURE_DEPTH_SIZE
:
937 case GL_TEXTURE_DEPTH_TYPE
:
938 if (base_format
== GL_DEPTH_STENCIL
||
939 base_format
== GL_DEPTH_COMPONENT
) {
944 _mesa_warning(NULL
, "%s: Unexpected channel token 0x%x\n",
945 __FUNCTION__
, pname
);
954 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
955 GLenum pname
, GLfloat
*params
)
958 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
959 *params
= (GLfloat
) iparam
;
964 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
965 GLenum pname
, GLint
*params
)
967 const struct gl_texture_unit
*texUnit
;
968 struct gl_texture_object
*texObj
;
969 const struct gl_texture_image
*img
= NULL
;
972 GET_CURRENT_CONTEXT(ctx
);
973 ASSERT_OUTSIDE_BEGIN_END(ctx
);
975 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
976 _mesa_error(ctx
, GL_INVALID_OPERATION
,
977 "glGetTexLevelParameteriv(current unit)");
981 texUnit
= _mesa_get_current_tex_unit(ctx
);
983 /* this will catch bad target values */
984 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
985 if (maxLevels
== 0) {
986 _mesa_error(ctx
, GL_INVALID_ENUM
,
987 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
991 if (level
< 0 || level
>= maxLevels
) {
992 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
996 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
998 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
999 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
1000 /* undefined texture image */
1001 if (pname
== GL_TEXTURE_COMPONENTS
)
1008 texFormat
= img
->TexFormat
;
1011 case GL_TEXTURE_WIDTH
:
1012 *params
= img
->Width
;
1014 case GL_TEXTURE_HEIGHT
:
1015 *params
= img
->Height
;
1017 case GL_TEXTURE_DEPTH
:
1018 *params
= img
->Depth
;
1020 case GL_TEXTURE_INTERNAL_FORMAT
:
1021 if (_mesa_is_format_compressed(texFormat
)) {
1022 /* need to return the actual compressed format */
1023 *params
= _mesa_compressed_format_to_glenum(ctx
, texFormat
);
1026 /* If the true internal format is not compressed but the user
1027 * requested a generic compressed format, we have to return the
1028 * generic base format that matches.
1030 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
1032 * "If no specific compressed format is available,
1033 * internalformat is instead replaced by the corresponding base
1036 * Otherwise just return the user's requested internal format
1039 _mesa_gl_compressed_format_base_format(img
->InternalFormat
);
1041 *params
= (f
!= 0) ? f
: img
->InternalFormat
;
1044 case GL_TEXTURE_BORDER
:
1045 *params
= img
->Border
;
1047 case GL_TEXTURE_RED_SIZE
:
1048 case GL_TEXTURE_GREEN_SIZE
:
1049 case GL_TEXTURE_BLUE_SIZE
:
1050 case GL_TEXTURE_ALPHA_SIZE
:
1051 if (base_format_has_channel(img
->_BaseFormat
, pname
))
1052 *params
= _mesa_get_format_bits(texFormat
, pname
);
1056 case GL_TEXTURE_INTENSITY_SIZE
:
1057 if (img
->_BaseFormat
!= GL_INTENSITY
)
1060 *params
= _mesa_get_format_bits(texFormat
, pname
);
1062 /* intensity probably stored as rgb texture */
1063 *params
= MIN2(_mesa_get_format_bits(texFormat
, GL_TEXTURE_RED_SIZE
),
1064 _mesa_get_format_bits(texFormat
, GL_TEXTURE_GREEN_SIZE
));
1068 case GL_TEXTURE_LUMINANCE_SIZE
:
1069 if (img
->_BaseFormat
!= GL_LUMINANCE
&&
1070 img
->_BaseFormat
!= GL_LUMINANCE_ALPHA
)
1073 *params
= _mesa_get_format_bits(texFormat
, pname
);
1075 /* luminance probably stored as rgb texture */
1076 *params
= MIN2(_mesa_get_format_bits(texFormat
, GL_TEXTURE_RED_SIZE
),
1077 _mesa_get_format_bits(texFormat
, GL_TEXTURE_GREEN_SIZE
));
1081 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1082 if (!ctx
->Extensions
.ARB_depth_texture
)
1084 *params
= _mesa_get_format_bits(texFormat
, pname
);
1086 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1087 if (!ctx
->Extensions
.EXT_packed_depth_stencil
&&
1088 !ctx
->Extensions
.ARB_framebuffer_object
)
1090 *params
= _mesa_get_format_bits(texFormat
, pname
);
1092 case GL_TEXTURE_SHARED_SIZE
:
1093 if (ctx
->VersionMajor
< 3 &&
1094 !ctx
->Extensions
.EXT_texture_shared_exponent
)
1096 *params
= texFormat
== MESA_FORMAT_RGB9_E5_FLOAT
? 5 : 0;
1099 /* GL_ARB_texture_compression */
1100 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1101 if (_mesa_is_format_compressed(texFormat
) &&
1102 !_mesa_is_proxy_texture(target
)) {
1103 *params
= _mesa_format_image_size(texFormat
, img
->Width
,
1104 img
->Height
, img
->Depth
);
1107 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1108 "glGetTexLevelParameter[if]v(pname)");
1111 case GL_TEXTURE_COMPRESSED
:
1112 *params
= (GLint
) _mesa_is_format_compressed(texFormat
);
1115 /* GL_ARB_texture_float */
1116 case GL_TEXTURE_RED_TYPE_ARB
:
1117 case GL_TEXTURE_GREEN_TYPE_ARB
:
1118 case GL_TEXTURE_BLUE_TYPE_ARB
:
1119 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1120 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1121 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1122 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1123 if (!ctx
->Extensions
.ARB_texture_float
)
1125 if (base_format_has_channel(img
->_BaseFormat
, pname
))
1126 *params
= _mesa_get_format_datatype(texFormat
);
1135 /* no error if we get here */
1139 _mesa_error(ctx
, GL_INVALID_ENUM
,
1140 "glGetTexLevelParameter[if]v(pname=%s)",
1141 _mesa_lookup_enum_by_nr(pname
));
1147 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1149 struct gl_texture_object
*obj
;
1150 GET_CURRENT_CONTEXT(ctx
);
1151 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1153 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1157 _mesa_lock_texture(ctx
, obj
);
1159 case GL_TEXTURE_MAG_FILTER
:
1160 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
1162 case GL_TEXTURE_MIN_FILTER
:
1163 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
1165 case GL_TEXTURE_WRAP_S
:
1166 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
1168 case GL_TEXTURE_WRAP_T
:
1169 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
1171 case GL_TEXTURE_WRAP_R
:
1172 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
1174 case GL_TEXTURE_BORDER_COLOR
:
1175 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1176 _mesa_update_state_locked(ctx
);
1177 if (ctx
->Color
._ClampFragmentColor
) {
1178 params
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1179 params
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1180 params
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1181 params
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1184 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
1185 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
1186 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
1187 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
1190 case GL_TEXTURE_RESIDENT
:
1191 *params
= ctx
->Driver
.IsTextureResident
?
1192 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1.0F
;
1194 case GL_TEXTURE_PRIORITY
:
1195 *params
= obj
->Priority
;
1197 case GL_TEXTURE_MIN_LOD
:
1198 *params
= obj
->Sampler
.MinLod
;
1200 case GL_TEXTURE_MAX_LOD
:
1201 *params
= obj
->Sampler
.MaxLod
;
1203 case GL_TEXTURE_BASE_LEVEL
:
1204 *params
= (GLfloat
) obj
->BaseLevel
;
1206 case GL_TEXTURE_MAX_LEVEL
:
1207 *params
= (GLfloat
) obj
->MaxLevel
;
1209 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1210 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1212 *params
= obj
->Sampler
.MaxAnisotropy
;
1214 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1215 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1217 *params
= obj
->Sampler
.CompareFailValue
;
1219 case GL_GENERATE_MIPMAP_SGIS
:
1220 *params
= (GLfloat
) obj
->GenerateMipmap
;
1222 case GL_TEXTURE_COMPARE_MODE_ARB
:
1223 if (!ctx
->Extensions
.ARB_shadow
)
1225 *params
= (GLfloat
) obj
->Sampler
.CompareMode
;
1227 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1228 if (!ctx
->Extensions
.ARB_shadow
)
1230 *params
= (GLfloat
) obj
->Sampler
.CompareFunc
;
1232 case GL_DEPTH_TEXTURE_MODE_ARB
:
1233 if (!ctx
->Extensions
.ARB_depth_texture
)
1235 *params
= (GLfloat
) obj
->Sampler
.DepthMode
;
1237 case GL_TEXTURE_LOD_BIAS
:
1238 *params
= obj
->Sampler
.LodBias
;
1240 #if FEATURE_OES_draw_texture
1241 case GL_TEXTURE_CROP_RECT_OES
:
1242 params
[0] = obj
->CropRect
[0];
1243 params
[1] = obj
->CropRect
[1];
1244 params
[2] = obj
->CropRect
[2];
1245 params
[3] = obj
->CropRect
[3];
1249 case GL_TEXTURE_SWIZZLE_R_EXT
:
1250 case GL_TEXTURE_SWIZZLE_G_EXT
:
1251 case GL_TEXTURE_SWIZZLE_B_EXT
:
1252 case GL_TEXTURE_SWIZZLE_A_EXT
:
1253 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1255 *params
= (GLfloat
) obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1258 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1259 if (!ctx
->Extensions
.EXT_texture_swizzle
) {
1264 for (comp
= 0; comp
< 4; comp
++) {
1265 params
[comp
] = (GLfloat
) obj
->Swizzle
[comp
];
1270 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1271 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1273 *params
= (GLfloat
) obj
->Sampler
.CubeMapSeamless
;
1276 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1277 if (!ctx
->Extensions
.ARB_texture_storage
)
1279 *params
= (GLfloat
) obj
->Immutable
;
1286 /* no error if we get here */
1287 _mesa_unlock_texture(ctx
, obj
);
1291 _mesa_unlock_texture(ctx
, obj
);
1292 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
1297 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1299 struct gl_texture_object
*obj
;
1300 GET_CURRENT_CONTEXT(ctx
);
1301 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1303 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1307 _mesa_lock_texture(ctx
, obj
);
1309 case GL_TEXTURE_MAG_FILTER
:
1310 *params
= (GLint
) obj
->Sampler
.MagFilter
;
1312 case GL_TEXTURE_MIN_FILTER
:
1313 *params
= (GLint
) obj
->Sampler
.MinFilter
;
1315 case GL_TEXTURE_WRAP_S
:
1316 *params
= (GLint
) obj
->Sampler
.WrapS
;
1318 case GL_TEXTURE_WRAP_T
:
1319 *params
= (GLint
) obj
->Sampler
.WrapT
;
1321 case GL_TEXTURE_WRAP_R
:
1322 *params
= (GLint
) obj
->Sampler
.WrapR
;
1324 case GL_TEXTURE_BORDER_COLOR
:
1327 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1328 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1329 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1330 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1331 params
[0] = FLOAT_TO_INT(b
[0]);
1332 params
[1] = FLOAT_TO_INT(b
[1]);
1333 params
[2] = FLOAT_TO_INT(b
[2]);
1334 params
[3] = FLOAT_TO_INT(b
[3]);
1337 case GL_TEXTURE_RESIDENT
:
1338 *params
= ctx
->Driver
.IsTextureResident
?
1339 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1;
1341 case GL_TEXTURE_PRIORITY
:
1342 *params
= FLOAT_TO_INT(obj
->Priority
);
1344 case GL_TEXTURE_MIN_LOD
:
1345 *params
= (GLint
) obj
->Sampler
.MinLod
;
1347 case GL_TEXTURE_MAX_LOD
:
1348 *params
= (GLint
) obj
->Sampler
.MaxLod
;
1350 case GL_TEXTURE_BASE_LEVEL
:
1351 *params
= obj
->BaseLevel
;
1353 case GL_TEXTURE_MAX_LEVEL
:
1354 *params
= obj
->MaxLevel
;
1356 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1357 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1359 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
1361 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1362 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1364 *params
= (GLint
) FLOAT_TO_INT(obj
->Sampler
.CompareFailValue
);
1366 case GL_GENERATE_MIPMAP_SGIS
:
1367 *params
= (GLint
) obj
->GenerateMipmap
;
1369 case GL_TEXTURE_COMPARE_MODE_ARB
:
1370 if (!ctx
->Extensions
.ARB_shadow
)
1372 *params
= (GLint
) obj
->Sampler
.CompareMode
;
1374 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1375 if (!ctx
->Extensions
.ARB_shadow
)
1377 *params
= (GLint
) obj
->Sampler
.CompareFunc
;
1379 case GL_DEPTH_TEXTURE_MODE_ARB
:
1380 if (!ctx
->Extensions
.ARB_depth_texture
)
1382 *params
= (GLint
) obj
->Sampler
.DepthMode
;
1384 case GL_TEXTURE_LOD_BIAS
:
1385 *params
= (GLint
) obj
->Sampler
.LodBias
;
1387 #if FEATURE_OES_draw_texture
1388 case GL_TEXTURE_CROP_RECT_OES
:
1389 params
[0] = obj
->CropRect
[0];
1390 params
[1] = obj
->CropRect
[1];
1391 params
[2] = obj
->CropRect
[2];
1392 params
[3] = obj
->CropRect
[3];
1395 case GL_TEXTURE_SWIZZLE_R_EXT
:
1396 case GL_TEXTURE_SWIZZLE_G_EXT
:
1397 case GL_TEXTURE_SWIZZLE_B_EXT
:
1398 case GL_TEXTURE_SWIZZLE_A_EXT
:
1399 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1401 *params
= obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1404 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1405 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1407 COPY_4V(params
, obj
->Swizzle
);
1410 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1411 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1413 *params
= (GLint
) obj
->Sampler
.CubeMapSeamless
;
1416 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1417 if (!ctx
->Extensions
.ARB_texture_storage
)
1419 *params
= (GLint
) obj
->Immutable
;
1422 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
:
1423 if (!ctx
->Extensions
.OES_EGL_image_external
)
1425 *params
= obj
->RequiredTextureImageUnits
;
1432 /* no error if we get here */
1433 _mesa_unlock_texture(ctx
, obj
);
1437 _mesa_unlock_texture(ctx
, obj
);
1438 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
1442 /** New in GL 3.0 */
1444 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
1446 struct gl_texture_object
*texObj
;
1447 GET_CURRENT_CONTEXT(ctx
);
1448 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1450 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1455 case GL_TEXTURE_BORDER_COLOR
:
1456 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1459 _mesa_GetTexParameteriv(target
, pname
, params
);
1464 /** New in GL 3.0 */
1466 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
1468 struct gl_texture_object
*texObj
;
1469 GET_CURRENT_CONTEXT(ctx
);
1470 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1472 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1477 case GL_TEXTURE_BORDER_COLOR
:
1478 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1483 _mesa_GetTexParameteriv(target
, pname
, ip
);
1485 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
1486 pname
== GL_TEXTURE_CROP_RECT_OES
) {