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/image.h"
39 #include "main/macros.h"
40 #include "main/mfeatures.h"
41 #include "main/mtypes.h"
42 #include "main/state.h"
43 #include "main/texparam.h"
44 #include "main/teximage.h"
45 #include "main/texstate.h"
49 * Check if a coordinate wrap mode is supported for the texture target.
50 * \return GL_TRUE if legal, GL_FALSE otherwise
53 validate_texture_wrap_mode(struct gl_context
* ctx
, GLenum target
, GLenum wrap
)
58 case GL_MIRRORED_REPEAT
:
64 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
70 * Get current texture object for given target.
71 * Return NULL if any error (and record the error).
72 * Note that this is different from _mesa_select_tex_object() in that proxy
73 * targets are not accepted.
74 * Only the glGetTexLevelParameter() functions accept proxy targets.
76 static struct gl_texture_object
*
77 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
79 struct gl_texture_unit
*texUnit
;
81 texUnit
= &ctx
->Texture
.Unit
;
85 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
87 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
89 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
90 case GL_TEXTURE_CUBE_MAP
:
91 if (ctx
->Extensions
.ARB_texture_cube_map
) {
92 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
99 _mesa_error(ctx
, GL_INVALID_ENUM
,
100 "gl%sTexParameter(target)", get
? "Get" : "");
106 * This is called just prior to changing any texture object state which
107 * will not effect texture completeness.
110 flush(struct gl_context
*ctx
)
112 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
117 * This is called just prior to changing any texture object state which
118 * can effect texture completeness (texture base level, max level,
119 * minification filter).
120 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
121 * state flag and then mark the texture object as 'incomplete' so that any
122 * per-texture derived state gets recomputed.
125 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
127 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
128 texObj
->_Complete
= GL_FALSE
;
133 * Set an integer-valued texture parameter
134 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
137 set_tex_parameteri(struct gl_context
*ctx
,
138 struct gl_texture_object
*texObj
,
139 GLenum pname
, const GLint
*params
)
142 case GL_TEXTURE_MIN_FILTER
:
143 if (texObj
->Sampler
.MinFilter
== params
[0])
148 incomplete(ctx
, texObj
);
149 texObj
->Sampler
.MinFilter
= params
[0];
151 case GL_NEAREST_MIPMAP_NEAREST
:
152 case GL_LINEAR_MIPMAP_NEAREST
:
153 case GL_NEAREST_MIPMAP_LINEAR
:
154 case GL_LINEAR_MIPMAP_LINEAR
:
155 incomplete(ctx
, texObj
);
156 texObj
->Sampler
.MinFilter
= params
[0];
164 case GL_TEXTURE_MAG_FILTER
:
165 if (texObj
->Sampler
.MagFilter
== params
[0])
170 flush(ctx
); /* does not effect completeness */
171 texObj
->Sampler
.MagFilter
= params
[0];
178 case GL_TEXTURE_WRAP_S
:
179 if (texObj
->Sampler
.WrapS
== params
[0])
181 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
183 texObj
->Sampler
.WrapS
= params
[0];
188 case GL_TEXTURE_WRAP_T
:
189 if (texObj
->Sampler
.WrapT
== params
[0])
191 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
193 texObj
->Sampler
.WrapT
= params
[0];
198 case GL_TEXTURE_WRAP_R
:
199 if (texObj
->Sampler
.WrapR
== params
[0])
201 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
203 texObj
->Sampler
.WrapR
= params
[0];
213 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
214 _mesa_lookup_enum_by_nr(pname
));
218 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
219 _mesa_lookup_enum_by_nr(params
[0]));
225 * Set a float-valued texture parameter
226 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
229 set_tex_parameterf(struct gl_context
*ctx
,
230 struct gl_texture_object
*texObj
,
231 GLenum pname
, const GLfloat
*params
)
235 case GL_TEXTURE_PRIORITY
:
237 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
240 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
241 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
242 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
244 if (params
[0] < 1.0) {
245 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
249 /* clamp to max, that's what NVIDIA does */
250 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
251 ctx
->Const
.MaxTextureMaxAnisotropy
);
255 static GLuint count
= 0;
257 _mesa_error(ctx
, GL_INVALID_ENUM
,
258 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
262 case GL_TEXTURE_BORDER_COLOR
:
264 /* ARB_texture_float disables clamping */
265 if (ctx
->Extensions
.ARB_texture_float
) {
266 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
267 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
268 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
269 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
271 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
272 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
273 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
274 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
279 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
286 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
288 GLboolean need_update
;
289 struct gl_texture_object
*texObj
;
290 GET_CURRENT_CONTEXT(ctx
);
291 ASSERT_OUTSIDE_BEGIN_END(ctx
);
293 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
298 case GL_TEXTURE_MIN_FILTER
:
299 case GL_TEXTURE_MAG_FILTER
:
300 case GL_TEXTURE_WRAP_S
:
301 case GL_TEXTURE_WRAP_T
:
302 case GL_TEXTURE_WRAP_R
:
303 case GL_TEXTURE_COMPARE_MODE_ARB
:
304 case GL_TEXTURE_COMPARE_FUNC_ARB
:
305 case GL_DEPTH_TEXTURE_MODE_ARB
:
306 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
308 /* convert float param to int */
310 p
[0] = (GLint
) param
;
311 p
[1] = p
[2] = p
[3] = 0;
312 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
315 case GL_TEXTURE_SWIZZLE_R_EXT
:
316 case GL_TEXTURE_SWIZZLE_G_EXT
:
317 case GL_TEXTURE_SWIZZLE_B_EXT
:
318 case GL_TEXTURE_SWIZZLE_A_EXT
:
321 p
[0] = (GLint
) param
;
322 p
[1] = p
[2] = p
[3] = 0;
323 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
328 /* this will generate an error if pname is illegal */
331 p
[1] = p
[2] = p
[3] = 0.0F
;
332 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
336 if (ctx
->Driver
.TexParameter
&& need_update
) {
337 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
343 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
345 GLboolean need_update
;
346 struct gl_texture_object
*texObj
;
347 GET_CURRENT_CONTEXT(ctx
);
348 ASSERT_OUTSIDE_BEGIN_END(ctx
);
350 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
355 case GL_TEXTURE_MIN_FILTER
:
356 case GL_TEXTURE_MAG_FILTER
:
357 case GL_TEXTURE_WRAP_S
:
358 case GL_TEXTURE_WRAP_T
:
359 case GL_TEXTURE_WRAP_R
:
360 case GL_TEXTURE_COMPARE_MODE_ARB
:
361 case GL_TEXTURE_COMPARE_FUNC_ARB
:
362 case GL_DEPTH_TEXTURE_MODE_ARB
:
363 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
365 /* convert float param to int */
367 p
[0] = (GLint
) params
[0];
368 p
[1] = p
[2] = p
[3] = 0;
369 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
373 case GL_TEXTURE_SWIZZLE_R_EXT
:
374 case GL_TEXTURE_SWIZZLE_G_EXT
:
375 case GL_TEXTURE_SWIZZLE_B_EXT
:
376 case GL_TEXTURE_SWIZZLE_A_EXT
:
377 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
379 GLint p
[4] = {0, 0, 0, 0};
380 p
[0] = (GLint
) params
[0];
381 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
382 p
[1] = (GLint
) params
[1];
383 p
[2] = (GLint
) params
[2];
384 p
[3] = (GLint
) params
[3];
386 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
390 /* this will generate an error if pname is illegal */
391 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
394 if (ctx
->Driver
.TexParameter
&& need_update
) {
395 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
401 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
403 GLboolean need_update
;
404 struct gl_texture_object
*texObj
;
405 GET_CURRENT_CONTEXT(ctx
);
406 ASSERT_OUTSIDE_BEGIN_END(ctx
);
408 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
413 case GL_TEXTURE_MIN_LOD
:
414 case GL_TEXTURE_MAX_LOD
:
415 case GL_TEXTURE_PRIORITY
:
416 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
417 case GL_TEXTURE_LOD_BIAS
:
418 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
421 fparam
[0] = (GLfloat
) param
;
422 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
423 /* convert int param to float */
424 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
428 /* this will generate an error if pname is illegal */
432 iparam
[1] = iparam
[2] = iparam
[3] = 0;
433 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
437 if (ctx
->Driver
.TexParameter
&& need_update
) {
438 GLfloat fparam
= (GLfloat
) param
;
439 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
445 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
447 GLboolean need_update
;
448 struct gl_texture_object
*texObj
;
449 GET_CURRENT_CONTEXT(ctx
);
450 ASSERT_OUTSIDE_BEGIN_END(ctx
);
452 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
457 case GL_TEXTURE_BORDER_COLOR
:
459 /* convert int params to float */
461 fparams
[0] = INT_TO_FLOAT(params
[0]);
462 fparams
[1] = INT_TO_FLOAT(params
[1]);
463 fparams
[2] = INT_TO_FLOAT(params
[2]);
464 fparams
[3] = INT_TO_FLOAT(params
[3]);
465 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
468 case GL_TEXTURE_MIN_LOD
:
469 case GL_TEXTURE_MAX_LOD
:
470 case GL_TEXTURE_PRIORITY
:
471 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
472 case GL_TEXTURE_LOD_BIAS
:
473 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
475 /* convert int param to float */
477 fparams
[0] = (GLfloat
) params
[0];
478 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
479 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
483 /* this will generate an error if pname is illegal */
484 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
487 if (ctx
->Driver
.TexParameter
&& need_update
) {
489 fparams
[0] = INT_TO_FLOAT(params
[0]);
490 if (pname
== GL_TEXTURE_BORDER_COLOR
||
491 pname
== GL_TEXTURE_CROP_RECT_OES
) {
492 fparams
[1] = INT_TO_FLOAT(params
[1]);
493 fparams
[2] = INT_TO_FLOAT(params
[2]);
494 fparams
[3] = INT_TO_FLOAT(params
[3]);
496 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
502 * Set tex parameter to integer value(s). Primarily intended to set
503 * integer-valued texture border color (for integer-valued textures).
507 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
509 struct gl_texture_object
*texObj
;
510 GET_CURRENT_CONTEXT(ctx
);
511 ASSERT_OUTSIDE_BEGIN_END(ctx
);
513 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
518 case GL_TEXTURE_BORDER_COLOR
:
519 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
520 /* set the integer-valued border color */
521 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
524 _mesa_TexParameteriv(target
, pname
, params
);
527 /* XXX no driver hook for TexParameterIiv() yet */
532 * Set tex parameter to unsigned integer value(s). Primarily intended to set
533 * uint-valued texture border color (for integer-valued textures).
537 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
539 struct gl_texture_object
*texObj
;
540 GET_CURRENT_CONTEXT(ctx
);
541 ASSERT_OUTSIDE_BEGIN_END(ctx
);
543 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
548 case GL_TEXTURE_BORDER_COLOR
:
549 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
550 /* set the unsigned integer-valued border color */
551 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
554 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
557 /* XXX no driver hook for TexParameterIuiv() yet */
562 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
563 GLenum pname
, GLfloat
*params
)
566 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
567 *params
= (GLfloat
) iparam
;
572 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
573 GLenum pname
, GLint
*params
)
575 struct gl_texture_object
*texObj
;
576 const struct gl_texture_image
*img
= NULL
;
579 GET_CURRENT_CONTEXT(ctx
);
580 ASSERT_OUTSIDE_BEGIN_END(ctx
);
582 /* this will catch bad target values */
583 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
584 if (maxLevels
== 0) {
585 _mesa_error(ctx
, GL_INVALID_ENUM
,
586 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
590 if (level
< 0 || level
>= maxLevels
) {
591 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
595 texObj
= _mesa_select_tex_object(ctx
, target
);
597 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
598 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
599 /* undefined texture image */
600 if (pname
== GL_TEXTURE_COMPONENTS
)
607 texFormat
= img
->TexFormat
;
610 case GL_TEXTURE_WIDTH
:
611 *params
= img
->Width
;
613 case GL_TEXTURE_HEIGHT
:
614 *params
= img
->Height
;
616 case GL_TEXTURE_DEPTH
:
617 *params
= img
->Depth
;
619 case GL_TEXTURE_INTERNAL_FORMAT
:
620 *params
= img
->InternalFormat
;
622 case GL_TEXTURE_BORDER
:
623 *params
= img
->Border
;
625 case GL_TEXTURE_RED_SIZE
:
626 case GL_TEXTURE_GREEN_SIZE
:
627 case GL_TEXTURE_BLUE_SIZE
:
628 case GL_TEXTURE_ALPHA_SIZE
:
629 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
630 *params
= _mesa_get_format_bits(texFormat
, pname
);
634 case GL_TEXTURE_INTENSITY_SIZE
:
635 case GL_TEXTURE_LUMINANCE_SIZE
:
636 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
637 *params
= _mesa_get_format_bits(texFormat
, pname
);
639 /* intensity or luminance is probably stored as RGB[A] */
640 *params
= MIN2(_mesa_get_format_bits(texFormat
,
641 GL_TEXTURE_RED_SIZE
),
642 _mesa_get_format_bits(texFormat
,
643 GL_TEXTURE_GREEN_SIZE
));
651 /* GL_ARB_texture_float */
652 case GL_TEXTURE_RED_TYPE_ARB
:
653 case GL_TEXTURE_GREEN_TYPE_ARB
:
654 case GL_TEXTURE_BLUE_TYPE_ARB
:
655 case GL_TEXTURE_ALPHA_TYPE_ARB
:
656 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
657 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
658 case GL_TEXTURE_DEPTH_TYPE_ARB
:
659 if (!ctx
->Extensions
.ARB_texture_float
)
661 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
662 *params
= _mesa_get_format_datatype(texFormat
);
671 /* no error if we get here */
675 _mesa_error(ctx
, GL_INVALID_ENUM
,
676 "glGetTexLevelParameter[if]v(pname=%s)",
677 _mesa_lookup_enum_by_nr(pname
));
683 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
685 struct gl_texture_object
*obj
;
686 GET_CURRENT_CONTEXT(ctx
);
687 ASSERT_OUTSIDE_BEGIN_END(ctx
);
689 obj
= get_texobj(ctx
, target
, GL_TRUE
);
693 _mesa_lock_texture(ctx
, obj
);
695 case GL_TEXTURE_MAG_FILTER
:
696 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
698 case GL_TEXTURE_MIN_FILTER
:
699 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
701 case GL_TEXTURE_WRAP_S
:
702 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
704 case GL_TEXTURE_WRAP_T
:
705 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
707 case GL_TEXTURE_WRAP_R
:
708 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
710 case GL_TEXTURE_BORDER_COLOR
:
711 if (ctx
->NewState
& _NEW_BUFFERS
)
712 _mesa_update_state_locked(ctx
);
713 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
714 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
715 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
716 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
718 case GL_TEXTURE_RESIDENT
:
721 case GL_TEXTURE_PRIORITY
:
722 *params
= obj
->Priority
;
724 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
725 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
727 *params
= obj
->Sampler
.MaxAnisotropy
;
730 case GL_TEXTURE_IMMUTABLE_FORMAT
:
731 if (!ctx
->Extensions
.ARB_texture_storage
)
733 *params
= (GLfloat
) obj
->Immutable
;
740 /* no error if we get here */
741 _mesa_unlock_texture(ctx
, obj
);
745 _mesa_unlock_texture(ctx
, obj
);
746 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
751 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
753 struct gl_texture_object
*obj
;
754 GET_CURRENT_CONTEXT(ctx
);
755 ASSERT_OUTSIDE_BEGIN_END(ctx
);
757 obj
= get_texobj(ctx
, target
, GL_TRUE
);
761 _mesa_lock_texture(ctx
, obj
);
763 case GL_TEXTURE_MAG_FILTER
:
764 *params
= (GLint
) obj
->Sampler
.MagFilter
;
766 case GL_TEXTURE_MIN_FILTER
:
767 *params
= (GLint
) obj
->Sampler
.MinFilter
;
769 case GL_TEXTURE_WRAP_S
:
770 *params
= (GLint
) obj
->Sampler
.WrapS
;
772 case GL_TEXTURE_WRAP_T
:
773 *params
= (GLint
) obj
->Sampler
.WrapT
;
775 case GL_TEXTURE_WRAP_R
:
776 *params
= (GLint
) obj
->Sampler
.WrapR
;
778 case GL_TEXTURE_BORDER_COLOR
:
781 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
782 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
783 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
784 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
785 params
[0] = FLOAT_TO_INT(b
[0]);
786 params
[1] = FLOAT_TO_INT(b
[1]);
787 params
[2] = FLOAT_TO_INT(b
[2]);
788 params
[3] = FLOAT_TO_INT(b
[3]);
791 case GL_TEXTURE_RESIDENT
:
794 case GL_TEXTURE_PRIORITY
:
795 *params
= FLOAT_TO_INT(obj
->Priority
);
797 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
798 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
800 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
803 case GL_TEXTURE_IMMUTABLE_FORMAT
:
804 if (!ctx
->Extensions
.ARB_texture_storage
)
806 *params
= (GLint
) obj
->Immutable
;
813 /* no error if we get here */
814 _mesa_unlock_texture(ctx
, obj
);
818 _mesa_unlock_texture(ctx
, obj
);
819 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
825 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
827 struct gl_texture_object
*texObj
;
828 GET_CURRENT_CONTEXT(ctx
);
829 ASSERT_OUTSIDE_BEGIN_END(ctx
);
831 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
836 case GL_TEXTURE_BORDER_COLOR
:
837 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
840 _mesa_GetTexParameteriv(target
, pname
, params
);
847 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
849 struct gl_texture_object
*texObj
;
850 GET_CURRENT_CONTEXT(ctx
);
851 ASSERT_OUTSIDE_BEGIN_END(ctx
);
853 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
858 case GL_TEXTURE_BORDER_COLOR
:
859 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
864 _mesa_GetTexParameteriv(target
, pname
, ip
);
866 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
867 pname
== GL_TEXTURE_CROP_RECT_OES
) {