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/glformats.h"
39 #include "main/macros.h"
40 #include "main/mfeatures.h"
41 #include "main/mtypes.h"
42 #include "main/state.h"
43 #include "main/texcompress.h"
44 #include "main/texobj.h"
45 #include "main/texparam.h"
46 #include "main/teximage.h"
47 #include "main/texstate.h"
48 #include "program/prog_instruction.h"
52 * Check if a coordinate wrap mode is supported for the texture target.
53 * \return GL_TRUE if legal, GL_FALSE otherwise
56 validate_texture_wrap_mode(struct gl_context
* ctx
, GLenum target
, GLenum wrap
)
58 const struct gl_extensions
* const e
= & ctx
->Extensions
;
63 supported
= (target
!= GL_TEXTURE_EXTERNAL_OES
);
66 case GL_CLAMP_TO_EDGE
:
70 case GL_CLAMP_TO_BORDER
:
71 supported
= e
->ARB_texture_border_clamp
72 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
76 case GL_MIRRORED_REPEAT
:
77 supported
= (target
!= GL_TEXTURE_RECTANGLE_NV
)
78 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
81 case GL_MIRROR_CLAMP_EXT
:
82 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
83 supported
= (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)
84 && (target
!= GL_TEXTURE_RECTANGLE_NV
)
85 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
88 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
89 supported
= e
->EXT_texture_mirror_clamp
90 && (target
!= GL_TEXTURE_RECTANGLE_NV
)
91 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
100 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
107 * Get current texture object for given target.
108 * Return NULL if any error (and record the error).
109 * Note that this is different from _mesa_select_tex_object() in that proxy
110 * targets are not accepted.
111 * Only the glGetTexLevelParameter() functions accept proxy targets.
113 static struct gl_texture_object
*
114 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
116 struct gl_texture_unit
*texUnit
;
118 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
119 _mesa_error(ctx
, GL_INVALID_OPERATION
,
120 "gl%sTexParameter(current unit)", get
? "Get" : "");
124 texUnit
= _mesa_get_current_tex_unit(ctx
);
128 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
130 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
132 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
133 case GL_TEXTURE_CUBE_MAP
:
134 if (ctx
->Extensions
.ARB_texture_cube_map
) {
135 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
138 case GL_TEXTURE_RECTANGLE_NV
:
139 if (ctx
->Extensions
.NV_texture_rectangle
) {
140 return texUnit
->CurrentTex
[TEXTURE_RECT_INDEX
];
143 case GL_TEXTURE_1D_ARRAY_EXT
:
144 if (ctx
->Extensions
.MESA_texture_array
||
145 ctx
->Extensions
.EXT_texture_array
) {
146 return texUnit
->CurrentTex
[TEXTURE_1D_ARRAY_INDEX
];
149 case GL_TEXTURE_2D_ARRAY_EXT
:
150 if (ctx
->Extensions
.MESA_texture_array
||
151 ctx
->Extensions
.EXT_texture_array
) {
152 return texUnit
->CurrentTex
[TEXTURE_2D_ARRAY_INDEX
];
155 case GL_TEXTURE_EXTERNAL_OES
:
156 if (ctx
->Extensions
.OES_EGL_image_external
) {
157 return texUnit
->CurrentTex
[TEXTURE_EXTERNAL_INDEX
];
164 _mesa_error(ctx
, GL_INVALID_ENUM
,
165 "gl%sTexParameter(target)", get
? "Get" : "");
171 * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE.
172 * \return -1 if error.
175 comp_to_swizzle(GLenum comp
)
197 set_swizzle_component(GLuint
*swizzle
, GLuint comp
, GLuint swz
)
200 ASSERT(swz
<= SWIZZLE_NIL
);
202 GLuint mask
= 0x7 << (3 * comp
);
203 GLuint s
= (*swizzle
& ~mask
) | (swz
<< (3 * comp
));
210 * This is called just prior to changing any texture object state which
211 * will not effect texture completeness.
214 flush(struct gl_context
*ctx
)
216 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
221 * This is called just prior to changing any texture object state which
222 * can effect texture completeness (texture base level, max level).
223 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
224 * state flag and then mark the texture object as 'incomplete' so that any
225 * per-texture derived state gets recomputed.
228 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
230 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
231 _mesa_dirty_texobj(ctx
, texObj
, GL_TRUE
);
236 * Set an integer-valued texture parameter
237 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
240 set_tex_parameteri(struct gl_context
*ctx
,
241 struct gl_texture_object
*texObj
,
242 GLenum pname
, const GLint
*params
)
245 case GL_TEXTURE_MIN_FILTER
:
246 if (texObj
->Sampler
.MinFilter
== params
[0])
252 texObj
->Sampler
.MinFilter
= params
[0];
254 case GL_NEAREST_MIPMAP_NEAREST
:
255 case GL_LINEAR_MIPMAP_NEAREST
:
256 case GL_NEAREST_MIPMAP_LINEAR
:
257 case GL_LINEAR_MIPMAP_LINEAR
:
258 if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
259 texObj
->Target
!= GL_TEXTURE_EXTERNAL_OES
) {
261 texObj
->Sampler
.MinFilter
= params
[0];
270 case GL_TEXTURE_MAG_FILTER
:
271 if (texObj
->Sampler
.MagFilter
== params
[0])
276 flush(ctx
); /* does not effect completeness */
277 texObj
->Sampler
.MagFilter
= params
[0];
284 case GL_TEXTURE_WRAP_S
:
285 if (texObj
->Sampler
.WrapS
== params
[0])
287 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
289 texObj
->Sampler
.WrapS
= params
[0];
294 case GL_TEXTURE_WRAP_T
:
295 if (texObj
->Sampler
.WrapT
== params
[0])
297 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
299 texObj
->Sampler
.WrapT
= params
[0];
304 case GL_TEXTURE_WRAP_R
:
305 if (texObj
->Sampler
.WrapR
== params
[0])
307 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
309 texObj
->Sampler
.WrapR
= params
[0];
314 case GL_TEXTURE_BASE_LEVEL
:
315 if (texObj
->BaseLevel
== params
[0])
318 (texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
&& params
[0] != 0)) {
319 _mesa_error(ctx
, GL_INVALID_VALUE
,
320 "glTexParameter(param=%d)", params
[0]);
323 incomplete(ctx
, texObj
);
324 texObj
->BaseLevel
= params
[0];
327 case GL_TEXTURE_MAX_LEVEL
:
328 if (texObj
->MaxLevel
== params
[0])
330 if (params
[0] < 0 || texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
) {
331 _mesa_error(ctx
, GL_INVALID_OPERATION
,
332 "glTexParameter(param=%d)", params
[0]);
335 incomplete(ctx
, texObj
);
336 texObj
->MaxLevel
= params
[0];
339 case GL_GENERATE_MIPMAP_SGIS
:
340 if (params
[0] && texObj
->Target
== GL_TEXTURE_EXTERNAL_OES
)
342 if (texObj
->GenerateMipmap
!= params
[0]) {
344 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
349 case GL_TEXTURE_COMPARE_MODE_ARB
:
350 if (ctx
->Extensions
.ARB_shadow
) {
351 if (texObj
->Sampler
.CompareMode
== params
[0])
353 if (params
[0] == GL_NONE
||
354 params
[0] == GL_COMPARE_R_TO_TEXTURE_ARB
) {
356 texObj
->Sampler
.CompareMode
= params
[0];
363 case GL_TEXTURE_COMPARE_FUNC_ARB
:
364 if (ctx
->Extensions
.ARB_shadow
) {
365 if (texObj
->Sampler
.CompareFunc
== params
[0])
371 texObj
->Sampler
.CompareFunc
= params
[0];
379 if (ctx
->Extensions
.EXT_shadow_funcs
) {
381 texObj
->Sampler
.CompareFunc
= params
[0];
391 case GL_DEPTH_TEXTURE_MODE_ARB
:
392 if (ctx
->Extensions
.ARB_depth_texture
) {
393 if (texObj
->DepthMode
== params
[0])
395 if (params
[0] == GL_LUMINANCE
||
396 params
[0] == GL_INTENSITY
||
397 params
[0] == GL_ALPHA
||
398 (ctx
->Extensions
.ARB_texture_rg
&& params
[0] == GL_RED
)) {
400 texObj
->DepthMode
= params
[0];
407 #if FEATURE_OES_draw_texture
408 case GL_TEXTURE_CROP_RECT_OES
:
409 texObj
->CropRect
[0] = params
[0];
410 texObj
->CropRect
[1] = params
[1];
411 texObj
->CropRect
[2] = params
[2];
412 texObj
->CropRect
[3] = params
[3];
416 case GL_TEXTURE_SWIZZLE_R_EXT
:
417 case GL_TEXTURE_SWIZZLE_G_EXT
:
418 case GL_TEXTURE_SWIZZLE_B_EXT
:
419 case GL_TEXTURE_SWIZZLE_A_EXT
:
420 if (ctx
->Extensions
.EXT_texture_swizzle
) {
421 const GLuint comp
= pname
- GL_TEXTURE_SWIZZLE_R_EXT
;
422 const GLint swz
= comp_to_swizzle(params
[0]);
424 _mesa_error(ctx
, GL_INVALID_OPERATION
,
425 "glTexParameter(swizzle 0x%x)", params
[0]);
431 texObj
->Swizzle
[comp
] = params
[0];
432 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
437 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
438 if (ctx
->Extensions
.EXT_texture_swizzle
) {
441 for (comp
= 0; comp
< 4; comp
++) {
442 const GLint swz
= comp_to_swizzle(params
[comp
]);
444 texObj
->Swizzle
[comp
] = params
[comp
];
445 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
448 _mesa_error(ctx
, GL_INVALID_OPERATION
,
449 "glTexParameter(swizzle 0x%x)", params
[comp
]);
457 case GL_TEXTURE_SRGB_DECODE_EXT
:
458 if (ctx
->Extensions
.EXT_texture_sRGB_decode
) {
459 GLenum decode
= params
[0];
460 if (decode
== GL_DECODE_EXT
|| decode
== GL_SKIP_DECODE_EXT
) {
461 if (texObj
->Sampler
.sRGBDecode
!= decode
) {
463 texObj
->Sampler
.sRGBDecode
= decode
;
470 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
471 if (ctx
->Extensions
.AMD_seamless_cubemap_per_texture
) {
472 GLenum param
= params
[0];
473 if (param
!= GL_TRUE
&& param
!= GL_FALSE
) {
476 if (param
!= texObj
->Sampler
.CubeMapSeamless
) {
478 texObj
->Sampler
.CubeMapSeamless
= param
;
489 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
490 _mesa_lookup_enum_by_nr(pname
));
494 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
495 _mesa_lookup_enum_by_nr(params
[0]));
501 * Set a float-valued texture parameter
502 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
505 set_tex_parameterf(struct gl_context
*ctx
,
506 struct gl_texture_object
*texObj
,
507 GLenum pname
, const GLfloat
*params
)
510 case GL_TEXTURE_MIN_LOD
:
511 if (texObj
->Sampler
.MinLod
== params
[0])
514 texObj
->Sampler
.MinLod
= params
[0];
517 case GL_TEXTURE_MAX_LOD
:
518 if (texObj
->Sampler
.MaxLod
== params
[0])
521 texObj
->Sampler
.MaxLod
= params
[0];
524 case GL_TEXTURE_PRIORITY
:
526 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
529 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
530 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
531 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
533 if (params
[0] < 1.0) {
534 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
538 /* clamp to max, that's what NVIDIA does */
539 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
540 ctx
->Const
.MaxTextureMaxAnisotropy
);
544 static GLuint count
= 0;
546 _mesa_error(ctx
, GL_INVALID_ENUM
,
547 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
551 case GL_TEXTURE_LOD_BIAS
:
552 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
553 if (texObj
->Sampler
.LodBias
!= params
[0]) {
555 texObj
->Sampler
.LodBias
= params
[0];
560 case GL_TEXTURE_BORDER_COLOR
:
562 /* ARB_texture_float disables clamping */
563 if (ctx
->Extensions
.ARB_texture_float
) {
564 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
565 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
566 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
567 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
569 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
570 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
571 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
572 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
577 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
584 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
586 GLboolean need_update
;
587 struct gl_texture_object
*texObj
;
588 GET_CURRENT_CONTEXT(ctx
);
589 ASSERT_OUTSIDE_BEGIN_END(ctx
);
591 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
596 case GL_TEXTURE_MIN_FILTER
:
597 case GL_TEXTURE_MAG_FILTER
:
598 case GL_TEXTURE_WRAP_S
:
599 case GL_TEXTURE_WRAP_T
:
600 case GL_TEXTURE_WRAP_R
:
601 case GL_TEXTURE_BASE_LEVEL
:
602 case GL_TEXTURE_MAX_LEVEL
:
603 case GL_GENERATE_MIPMAP_SGIS
:
604 case GL_TEXTURE_COMPARE_MODE_ARB
:
605 case GL_TEXTURE_COMPARE_FUNC_ARB
:
606 case GL_DEPTH_TEXTURE_MODE_ARB
:
607 case GL_TEXTURE_SRGB_DECODE_EXT
:
608 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
610 /* convert float param to int */
612 p
[0] = (GLint
) param
;
613 p
[1] = p
[2] = p
[3] = 0;
614 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
617 case GL_TEXTURE_SWIZZLE_R_EXT
:
618 case GL_TEXTURE_SWIZZLE_G_EXT
:
619 case GL_TEXTURE_SWIZZLE_B_EXT
:
620 case GL_TEXTURE_SWIZZLE_A_EXT
:
623 p
[0] = (GLint
) param
;
624 p
[1] = p
[2] = p
[3] = 0;
625 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
630 /* this will generate an error if pname is illegal */
633 p
[1] = p
[2] = p
[3] = 0.0F
;
634 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
638 if (ctx
->Driver
.TexParameter
&& need_update
) {
639 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
645 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
647 GLboolean need_update
;
648 struct gl_texture_object
*texObj
;
649 GET_CURRENT_CONTEXT(ctx
);
650 ASSERT_OUTSIDE_BEGIN_END(ctx
);
652 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
657 case GL_TEXTURE_MIN_FILTER
:
658 case GL_TEXTURE_MAG_FILTER
:
659 case GL_TEXTURE_WRAP_S
:
660 case GL_TEXTURE_WRAP_T
:
661 case GL_TEXTURE_WRAP_R
:
662 case GL_TEXTURE_BASE_LEVEL
:
663 case GL_TEXTURE_MAX_LEVEL
:
664 case GL_GENERATE_MIPMAP_SGIS
:
665 case GL_TEXTURE_COMPARE_MODE_ARB
:
666 case GL_TEXTURE_COMPARE_FUNC_ARB
:
667 case GL_DEPTH_TEXTURE_MODE_ARB
:
668 case GL_TEXTURE_SRGB_DECODE_EXT
:
669 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
671 /* convert float param to int */
673 p
[0] = (GLint
) params
[0];
674 p
[1] = p
[2] = p
[3] = 0;
675 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
679 #if FEATURE_OES_draw_texture
680 case GL_TEXTURE_CROP_RECT_OES
:
682 /* convert float params to int */
684 iparams
[0] = (GLint
) params
[0];
685 iparams
[1] = (GLint
) params
[1];
686 iparams
[2] = (GLint
) params
[2];
687 iparams
[3] = (GLint
) params
[3];
688 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparams
);
693 case GL_TEXTURE_SWIZZLE_R_EXT
:
694 case GL_TEXTURE_SWIZZLE_G_EXT
:
695 case GL_TEXTURE_SWIZZLE_B_EXT
:
696 case GL_TEXTURE_SWIZZLE_A_EXT
:
697 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
699 GLint p
[4] = {0, 0, 0, 0};
700 p
[0] = (GLint
) params
[0];
701 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
702 p
[1] = (GLint
) params
[1];
703 p
[2] = (GLint
) params
[2];
704 p
[3] = (GLint
) params
[3];
706 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
710 /* this will generate an error if pname is illegal */
711 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
714 if (ctx
->Driver
.TexParameter
&& need_update
) {
715 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
721 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
723 GLboolean need_update
;
724 struct gl_texture_object
*texObj
;
725 GET_CURRENT_CONTEXT(ctx
);
726 ASSERT_OUTSIDE_BEGIN_END(ctx
);
728 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
733 case GL_TEXTURE_MIN_LOD
:
734 case GL_TEXTURE_MAX_LOD
:
735 case GL_TEXTURE_PRIORITY
:
736 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
737 case GL_TEXTURE_LOD_BIAS
:
738 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
741 fparam
[0] = (GLfloat
) param
;
742 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
743 /* convert int param to float */
744 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
748 /* this will generate an error if pname is illegal */
752 iparam
[1] = iparam
[2] = iparam
[3] = 0;
753 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
757 if (ctx
->Driver
.TexParameter
&& need_update
) {
758 GLfloat fparam
= (GLfloat
) param
;
759 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
765 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
767 GLboolean need_update
;
768 struct gl_texture_object
*texObj
;
769 GET_CURRENT_CONTEXT(ctx
);
770 ASSERT_OUTSIDE_BEGIN_END(ctx
);
772 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
777 case GL_TEXTURE_BORDER_COLOR
:
779 /* convert int params to float */
781 fparams
[0] = INT_TO_FLOAT(params
[0]);
782 fparams
[1] = INT_TO_FLOAT(params
[1]);
783 fparams
[2] = INT_TO_FLOAT(params
[2]);
784 fparams
[3] = INT_TO_FLOAT(params
[3]);
785 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
788 case GL_TEXTURE_MIN_LOD
:
789 case GL_TEXTURE_MAX_LOD
:
790 case GL_TEXTURE_PRIORITY
:
791 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
792 case GL_TEXTURE_LOD_BIAS
:
793 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
795 /* convert int param to float */
797 fparams
[0] = (GLfloat
) params
[0];
798 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
799 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
803 /* this will generate an error if pname is illegal */
804 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
807 if (ctx
->Driver
.TexParameter
&& need_update
) {
809 fparams
[0] = INT_TO_FLOAT(params
[0]);
810 if (pname
== GL_TEXTURE_BORDER_COLOR
||
811 pname
== GL_TEXTURE_CROP_RECT_OES
) {
812 fparams
[1] = INT_TO_FLOAT(params
[1]);
813 fparams
[2] = INT_TO_FLOAT(params
[2]);
814 fparams
[3] = INT_TO_FLOAT(params
[3]);
816 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
822 * Set tex parameter to integer value(s). Primarily intended to set
823 * integer-valued texture border color (for integer-valued textures).
827 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
829 struct gl_texture_object
*texObj
;
830 GET_CURRENT_CONTEXT(ctx
);
831 ASSERT_OUTSIDE_BEGIN_END(ctx
);
833 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
838 case GL_TEXTURE_BORDER_COLOR
:
839 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
840 /* set the integer-valued border color */
841 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
844 _mesa_TexParameteriv(target
, pname
, params
);
847 /* XXX no driver hook for TexParameterIiv() yet */
852 * Set tex parameter to unsigned integer value(s). Primarily intended to set
853 * uint-valued texture border color (for integer-valued textures).
857 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
859 struct gl_texture_object
*texObj
;
860 GET_CURRENT_CONTEXT(ctx
);
861 ASSERT_OUTSIDE_BEGIN_END(ctx
);
863 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
868 case GL_TEXTURE_BORDER_COLOR
:
869 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
870 /* set the unsigned integer-valued border color */
871 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
874 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
877 /* XXX no driver hook for TexParameterIuiv() yet */
882 legal_get_tex_level_parameter_target(struct gl_context
*ctx
, GLenum target
)
886 case GL_PROXY_TEXTURE_1D
:
888 case GL_PROXY_TEXTURE_2D
:
890 case GL_PROXY_TEXTURE_3D
:
892 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
893 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
894 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
895 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
896 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
897 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
898 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
899 return ctx
->Extensions
.ARB_texture_cube_map
;
900 case GL_TEXTURE_RECTANGLE_NV
:
901 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
902 return ctx
->Extensions
.NV_texture_rectangle
;
903 case GL_TEXTURE_1D_ARRAY_EXT
:
904 case GL_PROXY_TEXTURE_1D_ARRAY_EXT
:
905 case GL_TEXTURE_2D_ARRAY_EXT
:
906 case GL_PROXY_TEXTURE_2D_ARRAY_EXT
:
907 return (ctx
->Extensions
.MESA_texture_array
||
908 ctx
->Extensions
.EXT_texture_array
);
909 case GL_TEXTURE_BUFFER
:
910 /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
911 * but not in earlier versions that expose ARB_texture_buffer_object.
913 * From the ARB_texture_buffer_object spec:
914 * "(7) Do buffer textures support texture parameters (TexParameter) or
915 * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
917 * RESOLVED: No. [...] Note that the spec edits above don't add
918 * explicit error language for any of these cases. That is because
919 * each of the functions enumerate the set of valid <target>
920 * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
921 * these cases means that target is not legal, and an INVALID_ENUM
922 * error should be generated."
924 * From the OpenGL 3.1 spec:
925 * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
927 return _mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 31;
935 get_tex_level_parameter_image(struct gl_context
*ctx
,
936 const struct gl_texture_object
*texObj
,
937 GLenum target
, GLint level
,
938 GLenum pname
, GLint
*params
)
940 const struct gl_texture_image
*img
= NULL
;
943 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
944 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
945 /* undefined texture image */
946 if (pname
== GL_TEXTURE_COMPONENTS
)
953 texFormat
= img
->TexFormat
;
956 case GL_TEXTURE_WIDTH
:
957 *params
= img
->Width
;
959 case GL_TEXTURE_HEIGHT
:
960 *params
= img
->Height
;
962 case GL_TEXTURE_DEPTH
:
963 *params
= img
->Depth
;
965 case GL_TEXTURE_INTERNAL_FORMAT
:
966 if (_mesa_is_format_compressed(texFormat
)) {
967 /* need to return the actual compressed format */
968 *params
= _mesa_compressed_format_to_glenum(ctx
, texFormat
);
971 /* If the true internal format is not compressed but the user
972 * requested a generic compressed format, we have to return the
973 * generic base format that matches.
975 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
977 * "If no specific compressed format is available,
978 * internalformat is instead replaced by the corresponding base
981 * Otherwise just return the user's requested internal format
984 _mesa_gl_compressed_format_base_format(img
->InternalFormat
);
986 *params
= (f
!= 0) ? f
: img
->InternalFormat
;
989 case GL_TEXTURE_BORDER
:
990 *params
= img
->Border
;
992 case GL_TEXTURE_RED_SIZE
:
993 case GL_TEXTURE_GREEN_SIZE
:
994 case GL_TEXTURE_BLUE_SIZE
:
995 case GL_TEXTURE_ALPHA_SIZE
:
996 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
997 *params
= _mesa_get_format_bits(texFormat
, pname
);
1001 case GL_TEXTURE_INTENSITY_SIZE
:
1002 case GL_TEXTURE_LUMINANCE_SIZE
:
1003 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
1004 *params
= _mesa_get_format_bits(texFormat
, pname
);
1006 /* intensity or luminance is probably stored as RGB[A] */
1007 *params
= MIN2(_mesa_get_format_bits(texFormat
,
1008 GL_TEXTURE_RED_SIZE
),
1009 _mesa_get_format_bits(texFormat
,
1010 GL_TEXTURE_GREEN_SIZE
));
1017 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1018 if (!ctx
->Extensions
.ARB_depth_texture
)
1020 *params
= _mesa_get_format_bits(texFormat
, pname
);
1022 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1023 if (!ctx
->Extensions
.EXT_packed_depth_stencil
&&
1024 !ctx
->Extensions
.ARB_framebuffer_object
)
1026 *params
= _mesa_get_format_bits(texFormat
, pname
);
1028 case GL_TEXTURE_SHARED_SIZE
:
1029 if (ctx
->Version
< 30 &&
1030 !ctx
->Extensions
.EXT_texture_shared_exponent
)
1032 *params
= texFormat
== MESA_FORMAT_RGB9_E5_FLOAT
? 5 : 0;
1035 /* GL_ARB_texture_compression */
1036 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1037 if (_mesa_is_format_compressed(texFormat
) &&
1038 !_mesa_is_proxy_texture(target
)) {
1039 *params
= _mesa_format_image_size(texFormat
, img
->Width
,
1040 img
->Height
, img
->Depth
);
1043 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1044 "glGetTexLevelParameter[if]v(pname)");
1047 case GL_TEXTURE_COMPRESSED
:
1048 *params
= (GLint
) _mesa_is_format_compressed(texFormat
);
1051 /* GL_ARB_texture_float */
1052 case GL_TEXTURE_RED_TYPE_ARB
:
1053 case GL_TEXTURE_GREEN_TYPE_ARB
:
1054 case GL_TEXTURE_BLUE_TYPE_ARB
:
1055 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1056 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1057 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1058 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1059 if (!ctx
->Extensions
.ARB_texture_float
)
1061 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
1062 *params
= _mesa_get_format_datatype(texFormat
);
1071 /* no error if we get here */
1075 _mesa_error(ctx
, GL_INVALID_ENUM
,
1076 "glGetTexLevelParameter[if]v(pname=%s)",
1077 _mesa_lookup_enum_by_nr(pname
));
1082 get_tex_level_parameter_buffer(struct gl_context
*ctx
,
1083 const struct gl_texture_object
*texObj
,
1084 GLenum pname
, GLint
*params
)
1086 const struct gl_buffer_object
*bo
= texObj
->BufferObject
;
1087 gl_format texFormat
= texObj
->_BufferObjectFormat
;
1088 GLenum internalFormat
= texObj
->BufferObjectFormat
;
1089 GLenum baseFormat
= _mesa_get_format_base_format(texFormat
);
1092 /* undefined texture buffer object */
1093 *params
= pname
== GL_TEXTURE_COMPONENTS
? 1 : 0;
1098 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING
:
1101 case GL_TEXTURE_WIDTH
:
1104 case GL_TEXTURE_HEIGHT
:
1105 case GL_TEXTURE_DEPTH
:
1106 case GL_TEXTURE_BORDER
:
1107 case GL_TEXTURE_SHARED_SIZE
:
1108 case GL_TEXTURE_COMPRESSED
:
1111 case GL_TEXTURE_INTERNAL_FORMAT
:
1112 *params
= internalFormat
;
1114 case GL_TEXTURE_RED_SIZE
:
1115 case GL_TEXTURE_GREEN_SIZE
:
1116 case GL_TEXTURE_BLUE_SIZE
:
1117 case GL_TEXTURE_ALPHA_SIZE
:
1118 if (_mesa_base_format_has_channel(baseFormat
, pname
))
1119 *params
= _mesa_get_format_bits(texFormat
, pname
);
1123 case GL_TEXTURE_INTENSITY_SIZE
:
1124 case GL_TEXTURE_LUMINANCE_SIZE
:
1125 if (_mesa_base_format_has_channel(baseFormat
, pname
)) {
1126 *params
= _mesa_get_format_bits(texFormat
, pname
);
1128 /* intensity or luminance is probably stored as RGB[A] */
1129 *params
= MIN2(_mesa_get_format_bits(texFormat
,
1130 GL_TEXTURE_RED_SIZE
),
1131 _mesa_get_format_bits(texFormat
,
1132 GL_TEXTURE_GREEN_SIZE
));
1138 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1139 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1140 *params
= _mesa_get_format_bits(texFormat
, pname
);
1143 /* GL_ARB_texture_compression */
1144 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1145 /* Always illegal for GL_TEXTURE_BUFFER */
1146 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1147 "glGetTexLevelParameter[if]v(pname)");
1150 /* GL_ARB_texture_float */
1151 case GL_TEXTURE_RED_TYPE_ARB
:
1152 case GL_TEXTURE_GREEN_TYPE_ARB
:
1153 case GL_TEXTURE_BLUE_TYPE_ARB
:
1154 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1155 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1156 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1157 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1158 if (!ctx
->Extensions
.ARB_texture_float
)
1160 if (_mesa_base_format_has_channel(baseFormat
, pname
))
1161 *params
= _mesa_get_format_datatype(texFormat
);
1170 /* no error if we get here */
1174 _mesa_error(ctx
, GL_INVALID_ENUM
,
1175 "glGetTexLevelParameter[if]v(pname=%s)",
1176 _mesa_lookup_enum_by_nr(pname
));
1181 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1182 GLenum pname
, GLfloat
*params
)
1185 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1186 *params
= (GLfloat
) iparam
;
1191 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1192 GLenum pname
, GLint
*params
)
1194 const struct gl_texture_unit
*texUnit
;
1195 struct gl_texture_object
*texObj
;
1197 GET_CURRENT_CONTEXT(ctx
);
1198 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1200 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
1201 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1202 "glGetTexLevelParameteriv(current unit)");
1206 texUnit
= _mesa_get_current_tex_unit(ctx
);
1208 if (!legal_get_tex_level_parameter_target(ctx
, target
)) {
1209 _mesa_error(ctx
, GL_INVALID_ENUM
,
1210 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
1214 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
1215 assert(maxLevels
!= 0);
1217 if (level
< 0 || level
>= maxLevels
) {
1218 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1222 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1224 if (target
== GL_TEXTURE_BUFFER
)
1225 get_tex_level_parameter_buffer(ctx
, texObj
, pname
, params
);
1227 get_tex_level_parameter_image(ctx
, texObj
, target
, level
, pname
, params
);
1232 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1234 struct gl_texture_object
*obj
;
1235 GET_CURRENT_CONTEXT(ctx
);
1236 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1238 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1242 _mesa_lock_texture(ctx
, obj
);
1244 case GL_TEXTURE_MAG_FILTER
:
1245 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
1247 case GL_TEXTURE_MIN_FILTER
:
1248 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
1250 case GL_TEXTURE_WRAP_S
:
1251 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
1253 case GL_TEXTURE_WRAP_T
:
1254 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
1256 case GL_TEXTURE_WRAP_R
:
1257 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
1259 case GL_TEXTURE_BORDER_COLOR
:
1260 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1261 _mesa_update_state_locked(ctx
);
1262 if (ctx
->Color
._ClampFragmentColor
) {
1263 params
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1264 params
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1265 params
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1266 params
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1269 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
1270 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
1271 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
1272 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
1275 case GL_TEXTURE_RESIDENT
:
1278 case GL_TEXTURE_PRIORITY
:
1279 *params
= obj
->Priority
;
1281 case GL_TEXTURE_MIN_LOD
:
1282 *params
= obj
->Sampler
.MinLod
;
1284 case GL_TEXTURE_MAX_LOD
:
1285 *params
= obj
->Sampler
.MaxLod
;
1287 case GL_TEXTURE_BASE_LEVEL
:
1288 *params
= (GLfloat
) obj
->BaseLevel
;
1290 case GL_TEXTURE_MAX_LEVEL
:
1291 *params
= (GLfloat
) obj
->MaxLevel
;
1293 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1294 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1296 *params
= obj
->Sampler
.MaxAnisotropy
;
1298 case GL_GENERATE_MIPMAP_SGIS
:
1299 *params
= (GLfloat
) obj
->GenerateMipmap
;
1301 case GL_TEXTURE_COMPARE_MODE_ARB
:
1302 if (!ctx
->Extensions
.ARB_shadow
)
1304 *params
= (GLfloat
) obj
->Sampler
.CompareMode
;
1306 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1307 if (!ctx
->Extensions
.ARB_shadow
)
1309 *params
= (GLfloat
) obj
->Sampler
.CompareFunc
;
1311 case GL_DEPTH_TEXTURE_MODE_ARB
:
1312 if (!ctx
->Extensions
.ARB_depth_texture
)
1314 *params
= (GLfloat
) obj
->DepthMode
;
1316 case GL_TEXTURE_LOD_BIAS
:
1317 *params
= obj
->Sampler
.LodBias
;
1319 #if FEATURE_OES_draw_texture
1320 case GL_TEXTURE_CROP_RECT_OES
:
1321 params
[0] = obj
->CropRect
[0];
1322 params
[1] = obj
->CropRect
[1];
1323 params
[2] = obj
->CropRect
[2];
1324 params
[3] = obj
->CropRect
[3];
1328 case GL_TEXTURE_SWIZZLE_R_EXT
:
1329 case GL_TEXTURE_SWIZZLE_G_EXT
:
1330 case GL_TEXTURE_SWIZZLE_B_EXT
:
1331 case GL_TEXTURE_SWIZZLE_A_EXT
:
1332 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1334 *params
= (GLfloat
) obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1337 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1338 if (!ctx
->Extensions
.EXT_texture_swizzle
) {
1343 for (comp
= 0; comp
< 4; comp
++) {
1344 params
[comp
] = (GLfloat
) obj
->Swizzle
[comp
];
1349 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1350 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1352 *params
= (GLfloat
) obj
->Sampler
.CubeMapSeamless
;
1355 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1356 if (!ctx
->Extensions
.ARB_texture_storage
)
1358 *params
= (GLfloat
) obj
->Immutable
;
1365 /* no error if we get here */
1366 _mesa_unlock_texture(ctx
, obj
);
1370 _mesa_unlock_texture(ctx
, obj
);
1371 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
1376 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1378 struct gl_texture_object
*obj
;
1379 GET_CURRENT_CONTEXT(ctx
);
1380 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1382 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1386 _mesa_lock_texture(ctx
, obj
);
1388 case GL_TEXTURE_MAG_FILTER
:
1389 *params
= (GLint
) obj
->Sampler
.MagFilter
;
1391 case GL_TEXTURE_MIN_FILTER
:
1392 *params
= (GLint
) obj
->Sampler
.MinFilter
;
1394 case GL_TEXTURE_WRAP_S
:
1395 *params
= (GLint
) obj
->Sampler
.WrapS
;
1397 case GL_TEXTURE_WRAP_T
:
1398 *params
= (GLint
) obj
->Sampler
.WrapT
;
1400 case GL_TEXTURE_WRAP_R
:
1401 *params
= (GLint
) obj
->Sampler
.WrapR
;
1403 case GL_TEXTURE_BORDER_COLOR
:
1406 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1407 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1408 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1409 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1410 params
[0] = FLOAT_TO_INT(b
[0]);
1411 params
[1] = FLOAT_TO_INT(b
[1]);
1412 params
[2] = FLOAT_TO_INT(b
[2]);
1413 params
[3] = FLOAT_TO_INT(b
[3]);
1416 case GL_TEXTURE_RESIDENT
:
1419 case GL_TEXTURE_PRIORITY
:
1420 *params
= FLOAT_TO_INT(obj
->Priority
);
1422 case GL_TEXTURE_MIN_LOD
:
1423 *params
= (GLint
) obj
->Sampler
.MinLod
;
1425 case GL_TEXTURE_MAX_LOD
:
1426 *params
= (GLint
) obj
->Sampler
.MaxLod
;
1428 case GL_TEXTURE_BASE_LEVEL
:
1429 *params
= obj
->BaseLevel
;
1431 case GL_TEXTURE_MAX_LEVEL
:
1432 *params
= obj
->MaxLevel
;
1434 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1435 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1437 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
1439 case GL_GENERATE_MIPMAP_SGIS
:
1440 *params
= (GLint
) obj
->GenerateMipmap
;
1442 case GL_TEXTURE_COMPARE_MODE_ARB
:
1443 if (!ctx
->Extensions
.ARB_shadow
)
1445 *params
= (GLint
) obj
->Sampler
.CompareMode
;
1447 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1448 if (!ctx
->Extensions
.ARB_shadow
)
1450 *params
= (GLint
) obj
->Sampler
.CompareFunc
;
1452 case GL_DEPTH_TEXTURE_MODE_ARB
:
1453 if (!ctx
->Extensions
.ARB_depth_texture
)
1455 *params
= (GLint
) obj
->DepthMode
;
1457 case GL_TEXTURE_LOD_BIAS
:
1458 *params
= (GLint
) obj
->Sampler
.LodBias
;
1460 #if FEATURE_OES_draw_texture
1461 case GL_TEXTURE_CROP_RECT_OES
:
1462 params
[0] = obj
->CropRect
[0];
1463 params
[1] = obj
->CropRect
[1];
1464 params
[2] = obj
->CropRect
[2];
1465 params
[3] = obj
->CropRect
[3];
1468 case GL_TEXTURE_SWIZZLE_R_EXT
:
1469 case GL_TEXTURE_SWIZZLE_G_EXT
:
1470 case GL_TEXTURE_SWIZZLE_B_EXT
:
1471 case GL_TEXTURE_SWIZZLE_A_EXT
:
1472 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1474 *params
= obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1477 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1478 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1480 COPY_4V(params
, obj
->Swizzle
);
1483 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1484 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1486 *params
= (GLint
) obj
->Sampler
.CubeMapSeamless
;
1489 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1490 if (!ctx
->Extensions
.ARB_texture_storage
)
1492 *params
= (GLint
) obj
->Immutable
;
1495 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
:
1496 if (!ctx
->Extensions
.OES_EGL_image_external
)
1498 *params
= obj
->RequiredTextureImageUnits
;
1505 /* no error if we get here */
1506 _mesa_unlock_texture(ctx
, obj
);
1510 _mesa_unlock_texture(ctx
, obj
);
1511 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
1515 /** New in GL 3.0 */
1517 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
1519 struct gl_texture_object
*texObj
;
1520 GET_CURRENT_CONTEXT(ctx
);
1521 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1523 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1528 case GL_TEXTURE_BORDER_COLOR
:
1529 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1532 _mesa_GetTexParameteriv(target
, pname
, params
);
1537 /** New in GL 3.0 */
1539 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
1541 struct gl_texture_object
*texObj
;
1542 GET_CURRENT_CONTEXT(ctx
);
1543 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1545 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1550 case GL_TEXTURE_BORDER_COLOR
:
1551 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1556 _mesa_GetTexParameteriv(target
, pname
, ip
);
1558 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
1559 pname
== GL_TEXTURE_CROP_RECT_OES
) {