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 _mesa_base_format_has_channel(GLenum base_format
, GLenum pname
)
891 case GL_TEXTURE_RED_SIZE
:
892 case GL_TEXTURE_RED_TYPE
:
893 case GL_RENDERBUFFER_RED_SIZE_EXT
:
894 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
895 if (base_format
== GL_RED
||
896 base_format
== GL_RG
||
897 base_format
== GL_RGB
||
898 base_format
== GL_RGBA
) {
902 case GL_TEXTURE_GREEN_SIZE
:
903 case GL_TEXTURE_GREEN_TYPE
:
904 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
905 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
906 if (base_format
== GL_RG
||
907 base_format
== GL_RGB
||
908 base_format
== GL_RGBA
) {
912 case GL_TEXTURE_BLUE_SIZE
:
913 case GL_TEXTURE_BLUE_TYPE
:
914 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
915 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
916 if (base_format
== GL_RGB
||
917 base_format
== GL_RGBA
) {
921 case GL_TEXTURE_ALPHA_SIZE
:
922 case GL_TEXTURE_ALPHA_TYPE
:
923 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
924 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
925 if (base_format
== GL_RGBA
||
926 base_format
== GL_ALPHA
||
927 base_format
== GL_LUMINANCE_ALPHA
) {
931 case GL_TEXTURE_LUMINANCE_SIZE
:
932 case GL_TEXTURE_LUMINANCE_TYPE
:
933 if (base_format
== GL_LUMINANCE
||
934 base_format
== GL_LUMINANCE_ALPHA
) {
938 case GL_TEXTURE_INTENSITY_SIZE
:
939 case GL_TEXTURE_INTENSITY_TYPE
:
940 if (base_format
== GL_INTENSITY
) {
944 case GL_TEXTURE_DEPTH_SIZE
:
945 case GL_TEXTURE_DEPTH_TYPE
:
946 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
947 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
948 if (base_format
== GL_DEPTH_STENCIL
||
949 base_format
== GL_DEPTH_COMPONENT
) {
953 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
954 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
955 if (base_format
== GL_DEPTH_STENCIL
||
956 base_format
== GL_STENCIL_INDEX
) {
961 _mesa_warning(NULL
, "%s: Unexpected channel token 0x%x\n",
962 __FUNCTION__
, pname
);
971 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
972 GLenum pname
, GLfloat
*params
)
975 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
976 *params
= (GLfloat
) iparam
;
981 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
982 GLenum pname
, GLint
*params
)
984 const struct gl_texture_unit
*texUnit
;
985 struct gl_texture_object
*texObj
;
986 const struct gl_texture_image
*img
= NULL
;
989 GET_CURRENT_CONTEXT(ctx
);
990 ASSERT_OUTSIDE_BEGIN_END(ctx
);
992 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
993 _mesa_error(ctx
, GL_INVALID_OPERATION
,
994 "glGetTexLevelParameteriv(current unit)");
998 texUnit
= _mesa_get_current_tex_unit(ctx
);
1000 /* this will catch bad target values */
1001 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
1002 if (maxLevels
== 0) {
1003 _mesa_error(ctx
, GL_INVALID_ENUM
,
1004 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
1008 if (level
< 0 || level
>= maxLevels
) {
1009 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1013 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1015 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1016 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
1017 /* undefined texture image */
1018 if (pname
== GL_TEXTURE_COMPONENTS
)
1025 texFormat
= img
->TexFormat
;
1028 case GL_TEXTURE_WIDTH
:
1029 *params
= img
->Width
;
1031 case GL_TEXTURE_HEIGHT
:
1032 *params
= img
->Height
;
1034 case GL_TEXTURE_DEPTH
:
1035 *params
= img
->Depth
;
1037 case GL_TEXTURE_INTERNAL_FORMAT
:
1038 if (_mesa_is_format_compressed(texFormat
)) {
1039 /* need to return the actual compressed format */
1040 *params
= _mesa_compressed_format_to_glenum(ctx
, texFormat
);
1043 /* If the true internal format is not compressed but the user
1044 * requested a generic compressed format, we have to return the
1045 * generic base format that matches.
1047 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
1049 * "If no specific compressed format is available,
1050 * internalformat is instead replaced by the corresponding base
1053 * Otherwise just return the user's requested internal format
1056 _mesa_gl_compressed_format_base_format(img
->InternalFormat
);
1058 *params
= (f
!= 0) ? f
: img
->InternalFormat
;
1061 case GL_TEXTURE_BORDER
:
1062 *params
= img
->Border
;
1064 case GL_TEXTURE_RED_SIZE
:
1065 case GL_TEXTURE_GREEN_SIZE
:
1066 case GL_TEXTURE_BLUE_SIZE
:
1067 case GL_TEXTURE_ALPHA_SIZE
:
1068 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
1069 *params
= _mesa_get_format_bits(texFormat
, pname
);
1073 case GL_TEXTURE_INTENSITY_SIZE
:
1074 case GL_TEXTURE_LUMINANCE_SIZE
:
1075 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
1076 *params
= _mesa_get_format_bits(texFormat
, pname
);
1078 /* intensity or luminance is probably stored as RGB[A] */
1079 *params
= MIN2(_mesa_get_format_bits(texFormat
,
1080 GL_TEXTURE_RED_SIZE
),
1081 _mesa_get_format_bits(texFormat
,
1082 GL_TEXTURE_GREEN_SIZE
));
1089 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1090 if (!ctx
->Extensions
.ARB_depth_texture
)
1092 *params
= _mesa_get_format_bits(texFormat
, pname
);
1094 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1095 if (!ctx
->Extensions
.EXT_packed_depth_stencil
&&
1096 !ctx
->Extensions
.ARB_framebuffer_object
)
1098 *params
= _mesa_get_format_bits(texFormat
, pname
);
1100 case GL_TEXTURE_SHARED_SIZE
:
1101 if (ctx
->VersionMajor
< 3 &&
1102 !ctx
->Extensions
.EXT_texture_shared_exponent
)
1104 *params
= texFormat
== MESA_FORMAT_RGB9_E5_FLOAT
? 5 : 0;
1107 /* GL_ARB_texture_compression */
1108 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1109 if (_mesa_is_format_compressed(texFormat
) &&
1110 !_mesa_is_proxy_texture(target
)) {
1111 *params
= _mesa_format_image_size(texFormat
, img
->Width
,
1112 img
->Height
, img
->Depth
);
1115 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1116 "glGetTexLevelParameter[if]v(pname)");
1119 case GL_TEXTURE_COMPRESSED
:
1120 *params
= (GLint
) _mesa_is_format_compressed(texFormat
);
1123 /* GL_ARB_texture_float */
1124 case GL_TEXTURE_RED_TYPE_ARB
:
1125 case GL_TEXTURE_GREEN_TYPE_ARB
:
1126 case GL_TEXTURE_BLUE_TYPE_ARB
:
1127 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1128 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1129 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1130 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1131 if (!ctx
->Extensions
.ARB_texture_float
)
1133 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
1134 *params
= _mesa_get_format_datatype(texFormat
);
1143 /* no error if we get here */
1147 _mesa_error(ctx
, GL_INVALID_ENUM
,
1148 "glGetTexLevelParameter[if]v(pname=%s)",
1149 _mesa_lookup_enum_by_nr(pname
));
1155 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1157 struct gl_texture_object
*obj
;
1158 GET_CURRENT_CONTEXT(ctx
);
1159 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1161 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1165 _mesa_lock_texture(ctx
, obj
);
1167 case GL_TEXTURE_MAG_FILTER
:
1168 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
1170 case GL_TEXTURE_MIN_FILTER
:
1171 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
1173 case GL_TEXTURE_WRAP_S
:
1174 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
1176 case GL_TEXTURE_WRAP_T
:
1177 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
1179 case GL_TEXTURE_WRAP_R
:
1180 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
1182 case GL_TEXTURE_BORDER_COLOR
:
1183 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1184 _mesa_update_state_locked(ctx
);
1185 if (ctx
->Color
._ClampFragmentColor
) {
1186 params
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1187 params
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1188 params
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1189 params
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1192 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
1193 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
1194 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
1195 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
1198 case GL_TEXTURE_RESIDENT
:
1199 *params
= ctx
->Driver
.IsTextureResident
?
1200 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1.0F
;
1202 case GL_TEXTURE_PRIORITY
:
1203 *params
= obj
->Priority
;
1205 case GL_TEXTURE_MIN_LOD
:
1206 *params
= obj
->Sampler
.MinLod
;
1208 case GL_TEXTURE_MAX_LOD
:
1209 *params
= obj
->Sampler
.MaxLod
;
1211 case GL_TEXTURE_BASE_LEVEL
:
1212 *params
= (GLfloat
) obj
->BaseLevel
;
1214 case GL_TEXTURE_MAX_LEVEL
:
1215 *params
= (GLfloat
) obj
->MaxLevel
;
1217 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1218 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1220 *params
= obj
->Sampler
.MaxAnisotropy
;
1222 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1223 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1225 *params
= obj
->Sampler
.CompareFailValue
;
1227 case GL_GENERATE_MIPMAP_SGIS
:
1228 *params
= (GLfloat
) obj
->GenerateMipmap
;
1230 case GL_TEXTURE_COMPARE_MODE_ARB
:
1231 if (!ctx
->Extensions
.ARB_shadow
)
1233 *params
= (GLfloat
) obj
->Sampler
.CompareMode
;
1235 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1236 if (!ctx
->Extensions
.ARB_shadow
)
1238 *params
= (GLfloat
) obj
->Sampler
.CompareFunc
;
1240 case GL_DEPTH_TEXTURE_MODE_ARB
:
1241 if (!ctx
->Extensions
.ARB_depth_texture
)
1243 *params
= (GLfloat
) obj
->Sampler
.DepthMode
;
1245 case GL_TEXTURE_LOD_BIAS
:
1246 *params
= obj
->Sampler
.LodBias
;
1248 #if FEATURE_OES_draw_texture
1249 case GL_TEXTURE_CROP_RECT_OES
:
1250 params
[0] = obj
->CropRect
[0];
1251 params
[1] = obj
->CropRect
[1];
1252 params
[2] = obj
->CropRect
[2];
1253 params
[3] = obj
->CropRect
[3];
1257 case GL_TEXTURE_SWIZZLE_R_EXT
:
1258 case GL_TEXTURE_SWIZZLE_G_EXT
:
1259 case GL_TEXTURE_SWIZZLE_B_EXT
:
1260 case GL_TEXTURE_SWIZZLE_A_EXT
:
1261 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1263 *params
= (GLfloat
) obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1266 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1267 if (!ctx
->Extensions
.EXT_texture_swizzle
) {
1272 for (comp
= 0; comp
< 4; comp
++) {
1273 params
[comp
] = (GLfloat
) obj
->Swizzle
[comp
];
1278 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1279 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1281 *params
= (GLfloat
) obj
->Sampler
.CubeMapSeamless
;
1284 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1285 if (!ctx
->Extensions
.ARB_texture_storage
)
1287 *params
= (GLfloat
) obj
->Immutable
;
1294 /* no error if we get here */
1295 _mesa_unlock_texture(ctx
, obj
);
1299 _mesa_unlock_texture(ctx
, obj
);
1300 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
1305 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1307 struct gl_texture_object
*obj
;
1308 GET_CURRENT_CONTEXT(ctx
);
1309 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1311 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1315 _mesa_lock_texture(ctx
, obj
);
1317 case GL_TEXTURE_MAG_FILTER
:
1318 *params
= (GLint
) obj
->Sampler
.MagFilter
;
1320 case GL_TEXTURE_MIN_FILTER
:
1321 *params
= (GLint
) obj
->Sampler
.MinFilter
;
1323 case GL_TEXTURE_WRAP_S
:
1324 *params
= (GLint
) obj
->Sampler
.WrapS
;
1326 case GL_TEXTURE_WRAP_T
:
1327 *params
= (GLint
) obj
->Sampler
.WrapT
;
1329 case GL_TEXTURE_WRAP_R
:
1330 *params
= (GLint
) obj
->Sampler
.WrapR
;
1332 case GL_TEXTURE_BORDER_COLOR
:
1335 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1336 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1337 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1338 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1339 params
[0] = FLOAT_TO_INT(b
[0]);
1340 params
[1] = FLOAT_TO_INT(b
[1]);
1341 params
[2] = FLOAT_TO_INT(b
[2]);
1342 params
[3] = FLOAT_TO_INT(b
[3]);
1345 case GL_TEXTURE_RESIDENT
:
1346 *params
= ctx
->Driver
.IsTextureResident
?
1347 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1;
1349 case GL_TEXTURE_PRIORITY
:
1350 *params
= FLOAT_TO_INT(obj
->Priority
);
1352 case GL_TEXTURE_MIN_LOD
:
1353 *params
= (GLint
) obj
->Sampler
.MinLod
;
1355 case GL_TEXTURE_MAX_LOD
:
1356 *params
= (GLint
) obj
->Sampler
.MaxLod
;
1358 case GL_TEXTURE_BASE_LEVEL
:
1359 *params
= obj
->BaseLevel
;
1361 case GL_TEXTURE_MAX_LEVEL
:
1362 *params
= obj
->MaxLevel
;
1364 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1365 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1367 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
1369 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1370 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1372 *params
= (GLint
) FLOAT_TO_INT(obj
->Sampler
.CompareFailValue
);
1374 case GL_GENERATE_MIPMAP_SGIS
:
1375 *params
= (GLint
) obj
->GenerateMipmap
;
1377 case GL_TEXTURE_COMPARE_MODE_ARB
:
1378 if (!ctx
->Extensions
.ARB_shadow
)
1380 *params
= (GLint
) obj
->Sampler
.CompareMode
;
1382 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1383 if (!ctx
->Extensions
.ARB_shadow
)
1385 *params
= (GLint
) obj
->Sampler
.CompareFunc
;
1387 case GL_DEPTH_TEXTURE_MODE_ARB
:
1388 if (!ctx
->Extensions
.ARB_depth_texture
)
1390 *params
= (GLint
) obj
->Sampler
.DepthMode
;
1392 case GL_TEXTURE_LOD_BIAS
:
1393 *params
= (GLint
) obj
->Sampler
.LodBias
;
1395 #if FEATURE_OES_draw_texture
1396 case GL_TEXTURE_CROP_RECT_OES
:
1397 params
[0] = obj
->CropRect
[0];
1398 params
[1] = obj
->CropRect
[1];
1399 params
[2] = obj
->CropRect
[2];
1400 params
[3] = obj
->CropRect
[3];
1403 case GL_TEXTURE_SWIZZLE_R_EXT
:
1404 case GL_TEXTURE_SWIZZLE_G_EXT
:
1405 case GL_TEXTURE_SWIZZLE_B_EXT
:
1406 case GL_TEXTURE_SWIZZLE_A_EXT
:
1407 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1409 *params
= obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1412 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1413 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1415 COPY_4V(params
, obj
->Swizzle
);
1418 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1419 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1421 *params
= (GLint
) obj
->Sampler
.CubeMapSeamless
;
1424 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1425 if (!ctx
->Extensions
.ARB_texture_storage
)
1427 *params
= (GLint
) obj
->Immutable
;
1430 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
:
1431 if (!ctx
->Extensions
.OES_EGL_image_external
)
1433 *params
= obj
->RequiredTextureImageUnits
;
1440 /* no error if we get here */
1441 _mesa_unlock_texture(ctx
, obj
);
1445 _mesa_unlock_texture(ctx
, obj
);
1446 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
1450 /** New in GL 3.0 */
1452 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
1454 struct gl_texture_object
*texObj
;
1455 GET_CURRENT_CONTEXT(ctx
);
1456 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1458 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1463 case GL_TEXTURE_BORDER_COLOR
:
1464 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1467 _mesa_GetTexParameteriv(target
, pname
, params
);
1472 /** New in GL 3.0 */
1474 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
1476 struct gl_texture_object
*texObj
;
1477 GET_CURRENT_CONTEXT(ctx
);
1478 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1480 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1485 case GL_TEXTURE_BORDER_COLOR
:
1486 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1491 _mesa_GetTexParameteriv(target
, pname
, ip
);
1493 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
1494 pname
== GL_TEXTURE_CROP_RECT_OES
) {