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
))
67 case GL_CLAMP_TO_EDGE
:
68 case GL_MIRRORED_REPEAT
:
70 case GL_CLAMP_TO_BORDER
:
71 if (e
->ARB_texture_border_clamp
)
74 case GL_MIRROR_CLAMP_EXT
:
75 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
76 if (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)
79 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
80 if (e
->EXT_texture_mirror_clamp
)
88 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
94 * Get current texture object for given target.
95 * Return NULL if any error (and record the error).
96 * Note that this is different from _mesa_select_tex_object() in that proxy
97 * targets are not accepted.
98 * Only the glGetTexLevelParameter() functions accept proxy targets.
100 static struct gl_texture_object
*
101 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
103 struct gl_texture_unit
*texUnit
;
105 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
106 _mesa_error(ctx
, GL_INVALID_OPERATION
,
107 "gl%sTexParameter(current unit)", get
? "Get" : "");
111 texUnit
= _mesa_get_current_tex_unit(ctx
);
115 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
117 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
119 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
120 case GL_TEXTURE_CUBE_MAP
:
121 if (ctx
->Extensions
.ARB_texture_cube_map
) {
122 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
125 case GL_TEXTURE_RECTANGLE_NV
:
126 if (ctx
->Extensions
.NV_texture_rectangle
) {
127 return texUnit
->CurrentTex
[TEXTURE_RECT_INDEX
];
130 case GL_TEXTURE_1D_ARRAY_EXT
:
131 if (ctx
->Extensions
.MESA_texture_array
||
132 ctx
->Extensions
.EXT_texture_array
) {
133 return texUnit
->CurrentTex
[TEXTURE_1D_ARRAY_INDEX
];
136 case GL_TEXTURE_2D_ARRAY_EXT
:
137 if (ctx
->Extensions
.MESA_texture_array
||
138 ctx
->Extensions
.EXT_texture_array
) {
139 return texUnit
->CurrentTex
[TEXTURE_2D_ARRAY_INDEX
];
146 _mesa_error(ctx
, GL_INVALID_ENUM
,
147 "gl%sTexParameter(target)", get
? "Get" : "");
153 * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE.
154 * \return -1 if error.
157 comp_to_swizzle(GLenum comp
)
179 set_swizzle_component(GLuint
*swizzle
, GLuint comp
, GLuint swz
)
182 ASSERT(swz
<= SWIZZLE_NIL
);
184 GLuint mask
= 0x7 << (3 * comp
);
185 GLuint s
= (*swizzle
& ~mask
) | (swz
<< (3 * comp
));
192 * This is called just prior to changing any texture object state which
193 * will not effect texture completeness.
196 flush(struct gl_context
*ctx
)
198 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
203 * This is called just prior to changing any texture object state which
204 * can effect texture completeness (texture base level, max level,
205 * minification filter).
206 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
207 * state flag and then mark the texture object as 'incomplete' so that any
208 * per-texture derived state gets recomputed.
211 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
213 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
214 texObj
->_Complete
= GL_FALSE
;
219 * Set an integer-valued texture parameter
220 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
223 set_tex_parameteri(struct gl_context
*ctx
,
224 struct gl_texture_object
*texObj
,
225 GLenum pname
, const GLint
*params
)
228 case GL_TEXTURE_MIN_FILTER
:
229 if (texObj
->Sampler
.MinFilter
== params
[0])
234 incomplete(ctx
, texObj
);
235 texObj
->Sampler
.MinFilter
= params
[0];
237 case GL_NEAREST_MIPMAP_NEAREST
:
238 case GL_LINEAR_MIPMAP_NEAREST
:
239 case GL_NEAREST_MIPMAP_LINEAR
:
240 case GL_LINEAR_MIPMAP_LINEAR
:
241 if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
) {
242 incomplete(ctx
, texObj
);
243 texObj
->Sampler
.MinFilter
= params
[0];
252 case GL_TEXTURE_MAG_FILTER
:
253 if (texObj
->Sampler
.MagFilter
== params
[0])
258 flush(ctx
); /* does not effect completeness */
259 texObj
->Sampler
.MagFilter
= params
[0];
266 case GL_TEXTURE_WRAP_S
:
267 if (texObj
->Sampler
.WrapS
== params
[0])
269 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
271 texObj
->Sampler
.WrapS
= params
[0];
276 case GL_TEXTURE_WRAP_T
:
277 if (texObj
->Sampler
.WrapT
== params
[0])
279 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
281 texObj
->Sampler
.WrapT
= params
[0];
286 case GL_TEXTURE_WRAP_R
:
287 if (texObj
->Sampler
.WrapR
== params
[0])
289 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
291 texObj
->Sampler
.WrapR
= params
[0];
296 case GL_TEXTURE_BASE_LEVEL
:
297 if (texObj
->BaseLevel
== params
[0])
300 (texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
&& params
[0] != 0)) {
301 _mesa_error(ctx
, GL_INVALID_VALUE
,
302 "glTexParameter(param=%d)", params
[0]);
305 incomplete(ctx
, texObj
);
306 texObj
->BaseLevel
= params
[0];
309 case GL_TEXTURE_MAX_LEVEL
:
310 if (texObj
->MaxLevel
== params
[0])
312 if (params
[0] < 0 || texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
) {
313 _mesa_error(ctx
, GL_INVALID_OPERATION
,
314 "glTexParameter(param=%d)", params
[0]);
317 incomplete(ctx
, texObj
);
318 texObj
->MaxLevel
= params
[0];
321 case GL_GENERATE_MIPMAP_SGIS
:
322 if (texObj
->GenerateMipmap
!= params
[0]) {
324 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
329 case GL_TEXTURE_COMPARE_MODE_ARB
:
330 if (ctx
->Extensions
.ARB_shadow
) {
331 if (texObj
->Sampler
.CompareMode
== params
[0])
333 if (params
[0] == GL_NONE
||
334 params
[0] == GL_COMPARE_R_TO_TEXTURE_ARB
) {
336 texObj
->Sampler
.CompareMode
= params
[0];
343 case GL_TEXTURE_COMPARE_FUNC_ARB
:
344 if (ctx
->Extensions
.ARB_shadow
) {
345 if (texObj
->Sampler
.CompareFunc
== params
[0])
351 texObj
->Sampler
.CompareFunc
= params
[0];
359 if (ctx
->Extensions
.EXT_shadow_funcs
) {
361 texObj
->Sampler
.CompareFunc
= params
[0];
371 case GL_DEPTH_TEXTURE_MODE_ARB
:
372 if (ctx
->Extensions
.ARB_depth_texture
) {
373 if (texObj
->Sampler
.DepthMode
== params
[0])
375 if (params
[0] == GL_LUMINANCE
||
376 params
[0] == GL_INTENSITY
||
377 params
[0] == GL_ALPHA
||
378 (ctx
->Extensions
.ARB_texture_rg
&& params
[0] == GL_RED
)) {
380 texObj
->Sampler
.DepthMode
= params
[0];
387 #if FEATURE_OES_draw_texture
388 case GL_TEXTURE_CROP_RECT_OES
:
389 texObj
->CropRect
[0] = params
[0];
390 texObj
->CropRect
[1] = params
[1];
391 texObj
->CropRect
[2] = params
[2];
392 texObj
->CropRect
[3] = params
[3];
396 case GL_TEXTURE_SWIZZLE_R_EXT
:
397 case GL_TEXTURE_SWIZZLE_G_EXT
:
398 case GL_TEXTURE_SWIZZLE_B_EXT
:
399 case GL_TEXTURE_SWIZZLE_A_EXT
:
400 if (ctx
->Extensions
.EXT_texture_swizzle
) {
401 const GLuint comp
= pname
- GL_TEXTURE_SWIZZLE_R_EXT
;
402 const GLint swz
= comp_to_swizzle(params
[0]);
404 _mesa_error(ctx
, GL_INVALID_OPERATION
,
405 "glTexParameter(swizzle 0x%x)", params
[0]);
411 texObj
->Swizzle
[comp
] = params
[0];
412 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
417 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
418 if (ctx
->Extensions
.EXT_texture_swizzle
) {
421 for (comp
= 0; comp
< 4; comp
++) {
422 const GLint swz
= comp_to_swizzle(params
[comp
]);
424 texObj
->Swizzle
[comp
] = params
[comp
];
425 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
428 _mesa_error(ctx
, GL_INVALID_OPERATION
,
429 "glTexParameter(swizzle 0x%x)", params
[comp
]);
437 case GL_TEXTURE_SRGB_DECODE_EXT
:
438 if (ctx
->Extensions
.EXT_texture_sRGB_decode
) {
439 GLenum decode
= params
[0];
440 if (decode
== GL_DECODE_EXT
|| decode
== GL_SKIP_DECODE_EXT
) {
441 if (texObj
->Sampler
.sRGBDecode
!= decode
) {
443 texObj
->Sampler
.sRGBDecode
= decode
;
450 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
451 if (ctx
->Extensions
.AMD_seamless_cubemap_per_texture
) {
452 GLenum param
= params
[0];
453 if (param
!= GL_TRUE
&& param
!= GL_FALSE
) {
456 if (param
!= texObj
->Sampler
.CubeMapSeamless
) {
458 texObj
->Sampler
.CubeMapSeamless
= param
;
469 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
470 _mesa_lookup_enum_by_nr(pname
));
474 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
475 _mesa_lookup_enum_by_nr(params
[0]));
481 * Set a float-valued texture parameter
482 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
485 set_tex_parameterf(struct gl_context
*ctx
,
486 struct gl_texture_object
*texObj
,
487 GLenum pname
, const GLfloat
*params
)
490 case GL_TEXTURE_MIN_LOD
:
491 if (texObj
->Sampler
.MinLod
== params
[0])
494 texObj
->Sampler
.MinLod
= params
[0];
497 case GL_TEXTURE_MAX_LOD
:
498 if (texObj
->Sampler
.MaxLod
== params
[0])
501 texObj
->Sampler
.MaxLod
= params
[0];
504 case GL_TEXTURE_PRIORITY
:
506 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
509 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
510 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
511 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
513 if (params
[0] < 1.0) {
514 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
518 /* clamp to max, that's what NVIDIA does */
519 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
520 ctx
->Const
.MaxTextureMaxAnisotropy
);
524 static GLuint count
= 0;
526 _mesa_error(ctx
, GL_INVALID_ENUM
,
527 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
531 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
532 if (ctx
->Extensions
.ARB_shadow_ambient
) {
533 if (texObj
->Sampler
.CompareFailValue
!= params
[0]) {
535 texObj
->Sampler
.CompareFailValue
= CLAMP(params
[0], 0.0F
, 1.0F
);
540 _mesa_error(ctx
, GL_INVALID_ENUM
,
541 "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)");
545 case GL_TEXTURE_LOD_BIAS
:
546 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
547 if (texObj
->Sampler
.LodBias
!= params
[0]) {
549 texObj
->Sampler
.LodBias
= params
[0];
554 case GL_TEXTURE_BORDER_COLOR
:
556 /* ARB_texture_float disables clamping */
557 if (ctx
->Extensions
.ARB_texture_float
) {
558 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
559 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
560 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
561 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
563 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
564 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
565 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
566 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
571 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
578 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
580 GLboolean need_update
;
581 struct gl_texture_object
*texObj
;
582 GET_CURRENT_CONTEXT(ctx
);
583 ASSERT_OUTSIDE_BEGIN_END(ctx
);
585 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
590 case GL_TEXTURE_MIN_FILTER
:
591 case GL_TEXTURE_MAG_FILTER
:
592 case GL_TEXTURE_WRAP_S
:
593 case GL_TEXTURE_WRAP_T
:
594 case GL_TEXTURE_WRAP_R
:
595 case GL_TEXTURE_BASE_LEVEL
:
596 case GL_TEXTURE_MAX_LEVEL
:
597 case GL_GENERATE_MIPMAP_SGIS
:
598 case GL_TEXTURE_COMPARE_MODE_ARB
:
599 case GL_TEXTURE_COMPARE_FUNC_ARB
:
600 case GL_DEPTH_TEXTURE_MODE_ARB
:
601 case GL_TEXTURE_SRGB_DECODE_EXT
:
602 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
604 /* convert float param to int */
606 p
[0] = (GLint
) param
;
607 p
[1] = p
[2] = p
[3] = 0;
608 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
611 case GL_TEXTURE_SWIZZLE_R_EXT
:
612 case GL_TEXTURE_SWIZZLE_G_EXT
:
613 case GL_TEXTURE_SWIZZLE_B_EXT
:
614 case GL_TEXTURE_SWIZZLE_A_EXT
:
617 p
[0] = (GLint
) param
;
618 p
[1] = p
[2] = p
[3] = 0;
619 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
624 /* this will generate an error if pname is illegal */
627 p
[1] = p
[2] = p
[3] = 0.0F
;
628 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
632 if (ctx
->Driver
.TexParameter
&& need_update
) {
633 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
639 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
641 GLboolean need_update
;
642 struct gl_texture_object
*texObj
;
643 GET_CURRENT_CONTEXT(ctx
);
644 ASSERT_OUTSIDE_BEGIN_END(ctx
);
646 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
651 case GL_TEXTURE_MIN_FILTER
:
652 case GL_TEXTURE_MAG_FILTER
:
653 case GL_TEXTURE_WRAP_S
:
654 case GL_TEXTURE_WRAP_T
:
655 case GL_TEXTURE_WRAP_R
:
656 case GL_TEXTURE_BASE_LEVEL
:
657 case GL_TEXTURE_MAX_LEVEL
:
658 case GL_GENERATE_MIPMAP_SGIS
:
659 case GL_TEXTURE_COMPARE_MODE_ARB
:
660 case GL_TEXTURE_COMPARE_FUNC_ARB
:
661 case GL_DEPTH_TEXTURE_MODE_ARB
:
662 case GL_TEXTURE_SRGB_DECODE_EXT
:
663 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
665 /* convert float param to int */
667 p
[0] = (GLint
) params
[0];
668 p
[1] = p
[2] = p
[3] = 0;
669 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
673 #if FEATURE_OES_draw_texture
674 case GL_TEXTURE_CROP_RECT_OES
:
676 /* convert float params to int */
678 iparams
[0] = (GLint
) params
[0];
679 iparams
[1] = (GLint
) params
[1];
680 iparams
[2] = (GLint
) params
[2];
681 iparams
[3] = (GLint
) params
[3];
682 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparams
);
687 case GL_TEXTURE_SWIZZLE_R_EXT
:
688 case GL_TEXTURE_SWIZZLE_G_EXT
:
689 case GL_TEXTURE_SWIZZLE_B_EXT
:
690 case GL_TEXTURE_SWIZZLE_A_EXT
:
691 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
693 GLint p
[4] = {0, 0, 0, 0};
694 p
[0] = (GLint
) params
[0];
695 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
696 p
[1] = (GLint
) params
[1];
697 p
[2] = (GLint
) params
[2];
698 p
[3] = (GLint
) params
[3];
700 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
704 /* this will generate an error if pname is illegal */
705 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
708 if (ctx
->Driver
.TexParameter
&& need_update
) {
709 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
715 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
717 GLboolean need_update
;
718 struct gl_texture_object
*texObj
;
719 GET_CURRENT_CONTEXT(ctx
);
720 ASSERT_OUTSIDE_BEGIN_END(ctx
);
722 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
727 case GL_TEXTURE_MIN_LOD
:
728 case GL_TEXTURE_MAX_LOD
:
729 case GL_TEXTURE_PRIORITY
:
730 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
731 case GL_TEXTURE_LOD_BIAS
:
732 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
735 fparam
[0] = (GLfloat
) param
;
736 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
737 /* convert int param to float */
738 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
742 /* this will generate an error if pname is illegal */
746 iparam
[1] = iparam
[2] = iparam
[3] = 0;
747 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
751 if (ctx
->Driver
.TexParameter
&& need_update
) {
752 GLfloat fparam
= (GLfloat
) param
;
753 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
759 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
761 GLboolean need_update
;
762 struct gl_texture_object
*texObj
;
763 GET_CURRENT_CONTEXT(ctx
);
764 ASSERT_OUTSIDE_BEGIN_END(ctx
);
766 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
771 case GL_TEXTURE_BORDER_COLOR
:
773 /* convert int params to float */
775 fparams
[0] = INT_TO_FLOAT(params
[0]);
776 fparams
[1] = INT_TO_FLOAT(params
[1]);
777 fparams
[2] = INT_TO_FLOAT(params
[2]);
778 fparams
[3] = INT_TO_FLOAT(params
[3]);
779 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
782 case GL_TEXTURE_MIN_LOD
:
783 case GL_TEXTURE_MAX_LOD
:
784 case GL_TEXTURE_PRIORITY
:
785 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
786 case GL_TEXTURE_LOD_BIAS
:
787 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
789 /* convert int param to float */
791 fparams
[0] = (GLfloat
) params
[0];
792 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
793 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
797 /* this will generate an error if pname is illegal */
798 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
801 if (ctx
->Driver
.TexParameter
&& need_update
) {
803 fparams
[0] = INT_TO_FLOAT(params
[0]);
804 if (pname
== GL_TEXTURE_BORDER_COLOR
||
805 pname
== GL_TEXTURE_CROP_RECT_OES
) {
806 fparams
[1] = INT_TO_FLOAT(params
[1]);
807 fparams
[2] = INT_TO_FLOAT(params
[2]);
808 fparams
[3] = INT_TO_FLOAT(params
[3]);
810 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
816 * Set tex parameter to integer value(s). Primarily intended to set
817 * integer-valued texture border color (for integer-valued textures).
821 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
823 struct gl_texture_object
*texObj
;
824 GET_CURRENT_CONTEXT(ctx
);
825 ASSERT_OUTSIDE_BEGIN_END(ctx
);
827 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
832 case GL_TEXTURE_BORDER_COLOR
:
833 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
834 /* set the integer-valued border color */
835 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
838 _mesa_TexParameteriv(target
, pname
, params
);
841 /* XXX no driver hook for TexParameterIiv() yet */
846 * Set tex parameter to unsigned integer value(s). Primarily intended to set
847 * uint-valued texture border color (for integer-valued textures).
851 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
853 struct gl_texture_object
*texObj
;
854 GET_CURRENT_CONTEXT(ctx
);
855 ASSERT_OUTSIDE_BEGIN_END(ctx
);
857 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
862 case GL_TEXTURE_BORDER_COLOR
:
863 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
864 /* set the unsigned integer-valued border color */
865 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
868 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
871 /* XXX no driver hook for TexParameterIuiv() yet */
878 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
879 GLenum pname
, GLfloat
*params
)
882 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
883 *params
= (GLfloat
) iparam
;
888 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
889 GLenum pname
, GLint
*params
)
891 const struct gl_texture_unit
*texUnit
;
892 struct gl_texture_object
*texObj
;
893 const struct gl_texture_image
*img
= NULL
;
896 GET_CURRENT_CONTEXT(ctx
);
897 ASSERT_OUTSIDE_BEGIN_END(ctx
);
899 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
900 _mesa_error(ctx
, GL_INVALID_OPERATION
,
901 "glGetTexLevelParameteriv(current unit)");
905 texUnit
= _mesa_get_current_tex_unit(ctx
);
907 /* this will catch bad target values */
908 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
909 if (maxLevels
== 0) {
910 _mesa_error(ctx
, GL_INVALID_ENUM
,
911 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
915 if (level
< 0 || level
>= maxLevels
) {
916 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
920 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
922 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
923 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
924 /* undefined texture image */
925 if (pname
== GL_TEXTURE_COMPONENTS
)
932 texFormat
= img
->TexFormat
;
935 case GL_TEXTURE_WIDTH
:
936 *params
= img
->Width
;
938 case GL_TEXTURE_HEIGHT
:
939 *params
= img
->Height
;
941 case GL_TEXTURE_DEPTH
:
942 *params
= img
->Depth
;
944 case GL_TEXTURE_INTERNAL_FORMAT
:
945 if (_mesa_is_format_compressed(texFormat
)) {
946 /* need to return the actual compressed format */
947 *params
= _mesa_compressed_format_to_glenum(ctx
, texFormat
);
950 /* If the true internal format is not compressed but the user
951 * requested a generic compressed format, we have to return the
952 * generic base format that matches.
954 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
956 * "If no specific compressed format is available,
957 * internalformat is instead replaced by the corresponding base
960 * Otherwise just return the user's requested internal format
963 _mesa_gl_compressed_format_base_format(img
->InternalFormat
);
965 *params
= (f
!= 0) ? f
: img
->InternalFormat
;
968 case GL_TEXTURE_BORDER
:
969 *params
= img
->Border
;
971 case GL_TEXTURE_RED_SIZE
:
972 if (img
->_BaseFormat
== GL_RED
) {
973 *params
= _mesa_get_format_bits(texFormat
, pname
);
977 case GL_TEXTURE_GREEN_SIZE
:
978 if (img
->_BaseFormat
== GL_RG
) {
979 *params
= _mesa_get_format_bits(texFormat
, pname
);
983 case GL_TEXTURE_BLUE_SIZE
:
984 if (img
->_BaseFormat
== GL_RGB
|| img
->_BaseFormat
== GL_RGBA
)
985 *params
= _mesa_get_format_bits(texFormat
, pname
);
989 case GL_TEXTURE_ALPHA_SIZE
:
990 if (img
->_BaseFormat
== GL_ALPHA
||
991 img
->_BaseFormat
== GL_LUMINANCE_ALPHA
||
992 img
->_BaseFormat
== GL_RGBA
)
993 *params
= _mesa_get_format_bits(texFormat
, pname
);
997 case GL_TEXTURE_INTENSITY_SIZE
:
998 if (img
->_BaseFormat
!= GL_INTENSITY
)
1001 *params
= _mesa_get_format_bits(texFormat
, pname
);
1003 /* intensity probably stored as rgb texture */
1004 *params
= MIN2(_mesa_get_format_bits(texFormat
, GL_TEXTURE_RED_SIZE
),
1005 _mesa_get_format_bits(texFormat
, GL_TEXTURE_GREEN_SIZE
));
1009 case GL_TEXTURE_LUMINANCE_SIZE
:
1010 if (img
->_BaseFormat
!= GL_LUMINANCE
&&
1011 img
->_BaseFormat
!= GL_LUMINANCE_ALPHA
)
1014 *params
= _mesa_get_format_bits(texFormat
, pname
);
1016 /* luminance probably stored as rgb texture */
1017 *params
= MIN2(_mesa_get_format_bits(texFormat
, GL_TEXTURE_RED_SIZE
),
1018 _mesa_get_format_bits(texFormat
, GL_TEXTURE_GREEN_SIZE
));
1022 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1023 if (!ctx
->Extensions
.ARB_depth_texture
)
1025 *params
= _mesa_get_format_bits(texFormat
, pname
);
1027 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1028 if (!ctx
->Extensions
.EXT_packed_depth_stencil
&&
1029 !ctx
->Extensions
.ARB_framebuffer_object
)
1031 *params
= _mesa_get_format_bits(texFormat
, pname
);
1033 case GL_TEXTURE_SHARED_SIZE
:
1034 if (ctx
->VersionMajor
< 3 &&
1035 !ctx
->Extensions
.EXT_texture_shared_exponent
)
1037 *params
= texFormat
== MESA_FORMAT_RGB9_E5_FLOAT
? 5 : 0;
1040 /* GL_ARB_texture_compression */
1041 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1042 if (_mesa_is_format_compressed(texFormat
) &&
1043 !_mesa_is_proxy_texture(target
)) {
1044 *params
= _mesa_format_image_size(texFormat
, img
->Width
,
1045 img
->Height
, img
->Depth
);
1048 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1049 "glGetTexLevelParameter[if]v(pname)");
1052 case GL_TEXTURE_COMPRESSED
:
1053 *params
= (GLint
) _mesa_is_format_compressed(texFormat
);
1056 /* GL_ARB_texture_float */
1057 case GL_TEXTURE_RED_TYPE_ARB
:
1058 if (!ctx
->Extensions
.ARB_texture_float
)
1060 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_RED_SIZE
) ?
1061 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1063 case GL_TEXTURE_GREEN_TYPE_ARB
:
1064 if (!ctx
->Extensions
.ARB_texture_float
)
1066 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_GREEN_SIZE
) ?
1067 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1069 case GL_TEXTURE_BLUE_TYPE_ARB
:
1070 if (!ctx
->Extensions
.ARB_texture_float
)
1072 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_BLUE_SIZE
) ?
1073 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1075 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1076 if (!ctx
->Extensions
.ARB_texture_float
)
1078 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_ALPHA_SIZE
) ?
1079 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1081 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1082 if (!ctx
->Extensions
.ARB_texture_float
)
1084 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_LUMINANCE_SIZE
) ?
1085 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1087 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1088 if (!ctx
->Extensions
.ARB_texture_float
)
1090 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_INTENSITY_SIZE
) ?
1091 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1093 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1094 if (!ctx
->Extensions
.ARB_texture_float
)
1096 *params
= _mesa_get_format_bits(texFormat
, GL_TEXTURE_DEPTH_SIZE
) ?
1097 _mesa_get_format_datatype(texFormat
) : GL_NONE
;
1104 /* no error if we get here */
1108 _mesa_error(ctx
, GL_INVALID_ENUM
,
1109 "glGetTexLevelParameter[if]v(pname=%s)",
1110 _mesa_lookup_enum_by_nr(pname
));
1116 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1118 struct gl_texture_object
*obj
;
1119 GET_CURRENT_CONTEXT(ctx
);
1120 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1122 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1126 _mesa_lock_texture(ctx
, obj
);
1128 case GL_TEXTURE_MAG_FILTER
:
1129 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
1131 case GL_TEXTURE_MIN_FILTER
:
1132 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
1134 case GL_TEXTURE_WRAP_S
:
1135 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
1137 case GL_TEXTURE_WRAP_T
:
1138 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
1140 case GL_TEXTURE_WRAP_R
:
1141 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
1143 case GL_TEXTURE_BORDER_COLOR
:
1144 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1145 _mesa_update_state_locked(ctx
);
1146 if (ctx
->Color
._ClampFragmentColor
) {
1147 params
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1148 params
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1149 params
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1150 params
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1153 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
1154 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
1155 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
1156 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
1159 case GL_TEXTURE_RESIDENT
:
1160 *params
= ctx
->Driver
.IsTextureResident
?
1161 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1.0F
;
1163 case GL_TEXTURE_PRIORITY
:
1164 *params
= obj
->Priority
;
1166 case GL_TEXTURE_MIN_LOD
:
1167 *params
= obj
->Sampler
.MinLod
;
1169 case GL_TEXTURE_MAX_LOD
:
1170 *params
= obj
->Sampler
.MaxLod
;
1172 case GL_TEXTURE_BASE_LEVEL
:
1173 *params
= (GLfloat
) obj
->BaseLevel
;
1175 case GL_TEXTURE_MAX_LEVEL
:
1176 *params
= (GLfloat
) obj
->MaxLevel
;
1178 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1179 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1181 *params
= obj
->Sampler
.MaxAnisotropy
;
1183 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1184 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1186 *params
= obj
->Sampler
.CompareFailValue
;
1188 case GL_GENERATE_MIPMAP_SGIS
:
1189 *params
= (GLfloat
) obj
->GenerateMipmap
;
1191 case GL_TEXTURE_COMPARE_MODE_ARB
:
1192 if (!ctx
->Extensions
.ARB_shadow
)
1194 *params
= (GLfloat
) obj
->Sampler
.CompareMode
;
1196 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1197 if (!ctx
->Extensions
.ARB_shadow
)
1199 *params
= (GLfloat
) obj
->Sampler
.CompareFunc
;
1201 case GL_DEPTH_TEXTURE_MODE_ARB
:
1202 if (!ctx
->Extensions
.ARB_depth_texture
)
1204 *params
= (GLfloat
) obj
->Sampler
.DepthMode
;
1206 case GL_TEXTURE_LOD_BIAS
:
1207 *params
= obj
->Sampler
.LodBias
;
1209 #if FEATURE_OES_draw_texture
1210 case GL_TEXTURE_CROP_RECT_OES
:
1211 params
[0] = obj
->CropRect
[0];
1212 params
[1] = obj
->CropRect
[1];
1213 params
[2] = obj
->CropRect
[2];
1214 params
[3] = obj
->CropRect
[3];
1218 case GL_TEXTURE_SWIZZLE_R_EXT
:
1219 case GL_TEXTURE_SWIZZLE_G_EXT
:
1220 case GL_TEXTURE_SWIZZLE_B_EXT
:
1221 case GL_TEXTURE_SWIZZLE_A_EXT
:
1222 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1224 *params
= (GLfloat
) obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1227 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1228 if (!ctx
->Extensions
.EXT_texture_swizzle
) {
1233 for (comp
= 0; comp
< 4; comp
++) {
1234 params
[comp
] = (GLfloat
) obj
->Swizzle
[comp
];
1239 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1240 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1242 *params
= (GLfloat
) obj
->Sampler
.CubeMapSeamless
;
1245 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1246 if (!ctx
->Extensions
.ARB_texture_storage
)
1248 *params
= (GLfloat
) obj
->Immutable
;
1255 /* no error if we get here */
1256 _mesa_unlock_texture(ctx
, obj
);
1260 _mesa_unlock_texture(ctx
, obj
);
1261 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
1266 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1268 struct gl_texture_object
*obj
;
1269 GET_CURRENT_CONTEXT(ctx
);
1270 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1272 obj
= get_texobj(ctx
, target
, GL_TRUE
);
1276 _mesa_lock_texture(ctx
, obj
);
1278 case GL_TEXTURE_MAG_FILTER
:
1279 *params
= (GLint
) obj
->Sampler
.MagFilter
;
1281 case GL_TEXTURE_MIN_FILTER
:
1282 *params
= (GLint
) obj
->Sampler
.MinFilter
;
1284 case GL_TEXTURE_WRAP_S
:
1285 *params
= (GLint
) obj
->Sampler
.WrapS
;
1287 case GL_TEXTURE_WRAP_T
:
1288 *params
= (GLint
) obj
->Sampler
.WrapT
;
1290 case GL_TEXTURE_WRAP_R
:
1291 *params
= (GLint
) obj
->Sampler
.WrapR
;
1293 case GL_TEXTURE_BORDER_COLOR
:
1296 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1297 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1298 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1299 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1300 params
[0] = FLOAT_TO_INT(b
[0]);
1301 params
[1] = FLOAT_TO_INT(b
[1]);
1302 params
[2] = FLOAT_TO_INT(b
[2]);
1303 params
[3] = FLOAT_TO_INT(b
[3]);
1306 case GL_TEXTURE_RESIDENT
:
1307 *params
= ctx
->Driver
.IsTextureResident
?
1308 ctx
->Driver
.IsTextureResident(ctx
, obj
) : 1;
1310 case GL_TEXTURE_PRIORITY
:
1311 *params
= FLOAT_TO_INT(obj
->Priority
);
1313 case GL_TEXTURE_MIN_LOD
:
1314 *params
= (GLint
) obj
->Sampler
.MinLod
;
1316 case GL_TEXTURE_MAX_LOD
:
1317 *params
= (GLint
) obj
->Sampler
.MaxLod
;
1319 case GL_TEXTURE_BASE_LEVEL
:
1320 *params
= obj
->BaseLevel
;
1322 case GL_TEXTURE_MAX_LEVEL
:
1323 *params
= obj
->MaxLevel
;
1325 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1326 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1328 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
1330 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
1331 if (!ctx
->Extensions
.ARB_shadow_ambient
)
1333 *params
= (GLint
) FLOAT_TO_INT(obj
->Sampler
.CompareFailValue
);
1335 case GL_GENERATE_MIPMAP_SGIS
:
1336 *params
= (GLint
) obj
->GenerateMipmap
;
1338 case GL_TEXTURE_COMPARE_MODE_ARB
:
1339 if (!ctx
->Extensions
.ARB_shadow
)
1341 *params
= (GLint
) obj
->Sampler
.CompareMode
;
1343 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1344 if (!ctx
->Extensions
.ARB_shadow
)
1346 *params
= (GLint
) obj
->Sampler
.CompareFunc
;
1348 case GL_DEPTH_TEXTURE_MODE_ARB
:
1349 if (!ctx
->Extensions
.ARB_depth_texture
)
1351 *params
= (GLint
) obj
->Sampler
.DepthMode
;
1353 case GL_TEXTURE_LOD_BIAS
:
1354 *params
= (GLint
) obj
->Sampler
.LodBias
;
1356 #if FEATURE_OES_draw_texture
1357 case GL_TEXTURE_CROP_RECT_OES
:
1358 params
[0] = obj
->CropRect
[0];
1359 params
[1] = obj
->CropRect
[1];
1360 params
[2] = obj
->CropRect
[2];
1361 params
[3] = obj
->CropRect
[3];
1364 case GL_TEXTURE_SWIZZLE_R_EXT
:
1365 case GL_TEXTURE_SWIZZLE_G_EXT
:
1366 case GL_TEXTURE_SWIZZLE_B_EXT
:
1367 case GL_TEXTURE_SWIZZLE_A_EXT
:
1368 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1370 *params
= obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1373 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1374 if (!ctx
->Extensions
.EXT_texture_swizzle
)
1376 COPY_4V(params
, obj
->Swizzle
);
1379 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1380 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1382 *params
= (GLint
) obj
->Sampler
.CubeMapSeamless
;
1385 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1386 if (!ctx
->Extensions
.ARB_texture_storage
)
1388 *params
= (GLint
) obj
->Immutable
;
1395 /* no error if we get here */
1396 _mesa_unlock_texture(ctx
, obj
);
1400 _mesa_unlock_texture(ctx
, obj
);
1401 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
1405 /** New in GL 3.0 */
1407 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
1409 struct gl_texture_object
*texObj
;
1410 GET_CURRENT_CONTEXT(ctx
);
1411 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1413 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1418 case GL_TEXTURE_BORDER_COLOR
:
1419 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1422 _mesa_GetTexParameteriv(target
, pname
, params
);
1427 /** New in GL 3.0 */
1429 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
1431 struct gl_texture_object
*texObj
;
1432 GET_CURRENT_CONTEXT(ctx
);
1433 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1435 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
1440 case GL_TEXTURE_BORDER_COLOR
:
1441 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
1446 _mesa_GetTexParameteriv(target
, pname
, ip
);
1448 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
1449 pname
== GL_TEXTURE_CROP_RECT_OES
) {