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
)
55 const struct gl_extensions
* const e
= & ctx
->Extensions
;
60 case GL_CLAMP_TO_EDGE
:
61 case GL_MIRRORED_REPEAT
:
63 case GL_CLAMP_TO_BORDER
:
64 if (e
->ARB_texture_border_clamp
)
67 case GL_MIRROR_CLAMP_EXT
:
68 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
69 if (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)
72 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
73 if (e
->EXT_texture_mirror_clamp
)
80 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
86 * Get current texture object for given target.
87 * Return NULL if any error (and record the error).
88 * Note that this is different from _mesa_select_tex_object() in that proxy
89 * targets are not accepted.
90 * Only the glGetTexLevelParameter() functions accept proxy targets.
92 static struct gl_texture_object
*
93 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
95 struct gl_texture_unit
*texUnit
;
97 texUnit
= &ctx
->Texture
.Unit
;
101 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
103 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
105 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
106 case GL_TEXTURE_CUBE_MAP
:
107 if (ctx
->Extensions
.ARB_texture_cube_map
) {
108 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
115 _mesa_error(ctx
, GL_INVALID_ENUM
,
116 "gl%sTexParameter(target)", get
? "Get" : "");
122 * This is called just prior to changing any texture object state which
123 * will not effect texture completeness.
126 flush(struct gl_context
*ctx
)
128 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
133 * This is called just prior to changing any texture object state which
134 * can effect texture completeness (texture base level, max level,
135 * minification filter).
136 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
137 * state flag and then mark the texture object as 'incomplete' so that any
138 * per-texture derived state gets recomputed.
141 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
143 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
144 texObj
->_Complete
= GL_FALSE
;
149 * Set an integer-valued texture parameter
150 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
153 set_tex_parameteri(struct gl_context
*ctx
,
154 struct gl_texture_object
*texObj
,
155 GLenum pname
, const GLint
*params
)
158 case GL_TEXTURE_MIN_FILTER
:
159 if (texObj
->Sampler
.MinFilter
== params
[0])
164 incomplete(ctx
, texObj
);
165 texObj
->Sampler
.MinFilter
= params
[0];
167 case GL_NEAREST_MIPMAP_NEAREST
:
168 case GL_LINEAR_MIPMAP_NEAREST
:
169 case GL_NEAREST_MIPMAP_LINEAR
:
170 case GL_LINEAR_MIPMAP_LINEAR
:
171 incomplete(ctx
, texObj
);
172 texObj
->Sampler
.MinFilter
= params
[0];
180 case GL_TEXTURE_MAG_FILTER
:
181 if (texObj
->Sampler
.MagFilter
== params
[0])
186 flush(ctx
); /* does not effect completeness */
187 texObj
->Sampler
.MagFilter
= params
[0];
194 case GL_TEXTURE_WRAP_S
:
195 if (texObj
->Sampler
.WrapS
== params
[0])
197 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
199 texObj
->Sampler
.WrapS
= params
[0];
204 case GL_TEXTURE_WRAP_T
:
205 if (texObj
->Sampler
.WrapT
== params
[0])
207 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
209 texObj
->Sampler
.WrapT
= params
[0];
214 case GL_TEXTURE_WRAP_R
:
215 if (texObj
->Sampler
.WrapR
== params
[0])
217 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
219 texObj
->Sampler
.WrapR
= params
[0];
229 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
230 _mesa_lookup_enum_by_nr(pname
));
234 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
235 _mesa_lookup_enum_by_nr(params
[0]));
241 * Set a float-valued texture parameter
242 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
245 set_tex_parameterf(struct gl_context
*ctx
,
246 struct gl_texture_object
*texObj
,
247 GLenum pname
, const GLfloat
*params
)
251 case GL_TEXTURE_PRIORITY
:
253 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
256 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
257 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
258 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
260 if (params
[0] < 1.0) {
261 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
265 /* clamp to max, that's what NVIDIA does */
266 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
267 ctx
->Const
.MaxTextureMaxAnisotropy
);
271 static GLuint count
= 0;
273 _mesa_error(ctx
, GL_INVALID_ENUM
,
274 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
278 case GL_TEXTURE_BORDER_COLOR
:
280 /* ARB_texture_float disables clamping */
281 if (ctx
->Extensions
.ARB_texture_float
) {
282 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
283 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
284 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
285 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
287 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
288 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
289 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
290 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
295 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
302 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
304 GLboolean need_update
;
305 struct gl_texture_object
*texObj
;
306 GET_CURRENT_CONTEXT(ctx
);
307 ASSERT_OUTSIDE_BEGIN_END(ctx
);
309 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
314 case GL_TEXTURE_MIN_FILTER
:
315 case GL_TEXTURE_MAG_FILTER
:
316 case GL_TEXTURE_WRAP_S
:
317 case GL_TEXTURE_WRAP_T
:
318 case GL_TEXTURE_WRAP_R
:
319 case GL_TEXTURE_COMPARE_MODE_ARB
:
320 case GL_TEXTURE_COMPARE_FUNC_ARB
:
321 case GL_DEPTH_TEXTURE_MODE_ARB
:
322 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
324 /* convert float param to int */
326 p
[0] = (GLint
) param
;
327 p
[1] = p
[2] = p
[3] = 0;
328 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
331 case GL_TEXTURE_SWIZZLE_R_EXT
:
332 case GL_TEXTURE_SWIZZLE_G_EXT
:
333 case GL_TEXTURE_SWIZZLE_B_EXT
:
334 case GL_TEXTURE_SWIZZLE_A_EXT
:
337 p
[0] = (GLint
) param
;
338 p
[1] = p
[2] = p
[3] = 0;
339 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
344 /* this will generate an error if pname is illegal */
347 p
[1] = p
[2] = p
[3] = 0.0F
;
348 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
352 if (ctx
->Driver
.TexParameter
&& need_update
) {
353 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
359 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
361 GLboolean need_update
;
362 struct gl_texture_object
*texObj
;
363 GET_CURRENT_CONTEXT(ctx
);
364 ASSERT_OUTSIDE_BEGIN_END(ctx
);
366 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
371 case GL_TEXTURE_MIN_FILTER
:
372 case GL_TEXTURE_MAG_FILTER
:
373 case GL_TEXTURE_WRAP_S
:
374 case GL_TEXTURE_WRAP_T
:
375 case GL_TEXTURE_WRAP_R
:
376 case GL_TEXTURE_COMPARE_MODE_ARB
:
377 case GL_TEXTURE_COMPARE_FUNC_ARB
:
378 case GL_DEPTH_TEXTURE_MODE_ARB
:
379 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
381 /* convert float param to int */
383 p
[0] = (GLint
) params
[0];
384 p
[1] = p
[2] = p
[3] = 0;
385 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
389 case GL_TEXTURE_SWIZZLE_R_EXT
:
390 case GL_TEXTURE_SWIZZLE_G_EXT
:
391 case GL_TEXTURE_SWIZZLE_B_EXT
:
392 case GL_TEXTURE_SWIZZLE_A_EXT
:
393 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
395 GLint p
[4] = {0, 0, 0, 0};
396 p
[0] = (GLint
) params
[0];
397 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
398 p
[1] = (GLint
) params
[1];
399 p
[2] = (GLint
) params
[2];
400 p
[3] = (GLint
) params
[3];
402 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
406 /* this will generate an error if pname is illegal */
407 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
410 if (ctx
->Driver
.TexParameter
&& need_update
) {
411 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
417 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
419 GLboolean need_update
;
420 struct gl_texture_object
*texObj
;
421 GET_CURRENT_CONTEXT(ctx
);
422 ASSERT_OUTSIDE_BEGIN_END(ctx
);
424 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
429 case GL_TEXTURE_MIN_LOD
:
430 case GL_TEXTURE_MAX_LOD
:
431 case GL_TEXTURE_PRIORITY
:
432 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
433 case GL_TEXTURE_LOD_BIAS
:
434 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
437 fparam
[0] = (GLfloat
) param
;
438 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
439 /* convert int param to float */
440 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
444 /* this will generate an error if pname is illegal */
448 iparam
[1] = iparam
[2] = iparam
[3] = 0;
449 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
453 if (ctx
->Driver
.TexParameter
&& need_update
) {
454 GLfloat fparam
= (GLfloat
) param
;
455 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
461 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
463 GLboolean need_update
;
464 struct gl_texture_object
*texObj
;
465 GET_CURRENT_CONTEXT(ctx
);
466 ASSERT_OUTSIDE_BEGIN_END(ctx
);
468 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
473 case GL_TEXTURE_BORDER_COLOR
:
475 /* convert int params to float */
477 fparams
[0] = INT_TO_FLOAT(params
[0]);
478 fparams
[1] = INT_TO_FLOAT(params
[1]);
479 fparams
[2] = INT_TO_FLOAT(params
[2]);
480 fparams
[3] = INT_TO_FLOAT(params
[3]);
481 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
484 case GL_TEXTURE_MIN_LOD
:
485 case GL_TEXTURE_MAX_LOD
:
486 case GL_TEXTURE_PRIORITY
:
487 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
488 case GL_TEXTURE_LOD_BIAS
:
489 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
491 /* convert int param to float */
493 fparams
[0] = (GLfloat
) params
[0];
494 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
495 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
499 /* this will generate an error if pname is illegal */
500 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
503 if (ctx
->Driver
.TexParameter
&& need_update
) {
505 fparams
[0] = INT_TO_FLOAT(params
[0]);
506 if (pname
== GL_TEXTURE_BORDER_COLOR
||
507 pname
== GL_TEXTURE_CROP_RECT_OES
) {
508 fparams
[1] = INT_TO_FLOAT(params
[1]);
509 fparams
[2] = INT_TO_FLOAT(params
[2]);
510 fparams
[3] = INT_TO_FLOAT(params
[3]);
512 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
518 * Set tex parameter to integer value(s). Primarily intended to set
519 * integer-valued texture border color (for integer-valued textures).
523 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
525 struct gl_texture_object
*texObj
;
526 GET_CURRENT_CONTEXT(ctx
);
527 ASSERT_OUTSIDE_BEGIN_END(ctx
);
529 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
534 case GL_TEXTURE_BORDER_COLOR
:
535 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
536 /* set the integer-valued border color */
537 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
540 _mesa_TexParameteriv(target
, pname
, params
);
543 /* XXX no driver hook for TexParameterIiv() yet */
548 * Set tex parameter to unsigned integer value(s). Primarily intended to set
549 * uint-valued texture border color (for integer-valued textures).
553 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
555 struct gl_texture_object
*texObj
;
556 GET_CURRENT_CONTEXT(ctx
);
557 ASSERT_OUTSIDE_BEGIN_END(ctx
);
559 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
564 case GL_TEXTURE_BORDER_COLOR
:
565 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
566 /* set the unsigned integer-valued border color */
567 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
570 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
573 /* XXX no driver hook for TexParameterIuiv() yet */
578 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
579 GLenum pname
, GLfloat
*params
)
582 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
583 *params
= (GLfloat
) iparam
;
588 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
589 GLenum pname
, GLint
*params
)
591 struct gl_texture_object
*texObj
;
592 const struct gl_texture_image
*img
= NULL
;
595 GET_CURRENT_CONTEXT(ctx
);
596 ASSERT_OUTSIDE_BEGIN_END(ctx
);
598 /* this will catch bad target values */
599 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
600 if (maxLevels
== 0) {
601 _mesa_error(ctx
, GL_INVALID_ENUM
,
602 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
606 if (level
< 0 || level
>= maxLevels
) {
607 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
611 texObj
= _mesa_select_tex_object(ctx
, target
);
613 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
614 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
615 /* undefined texture image */
616 if (pname
== GL_TEXTURE_COMPONENTS
)
623 texFormat
= img
->TexFormat
;
626 case GL_TEXTURE_WIDTH
:
627 *params
= img
->Width
;
629 case GL_TEXTURE_HEIGHT
:
630 *params
= img
->Height
;
632 case GL_TEXTURE_DEPTH
:
633 *params
= img
->Depth
;
635 case GL_TEXTURE_INTERNAL_FORMAT
:
636 *params
= img
->InternalFormat
;
638 case GL_TEXTURE_BORDER
:
639 *params
= img
->Border
;
641 case GL_TEXTURE_RED_SIZE
:
642 case GL_TEXTURE_GREEN_SIZE
:
643 case GL_TEXTURE_BLUE_SIZE
:
644 case GL_TEXTURE_ALPHA_SIZE
:
645 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
646 *params
= _mesa_get_format_bits(texFormat
, pname
);
650 case GL_TEXTURE_INTENSITY_SIZE
:
651 case GL_TEXTURE_LUMINANCE_SIZE
:
652 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
653 *params
= _mesa_get_format_bits(texFormat
, pname
);
655 /* intensity or luminance is probably stored as RGB[A] */
656 *params
= MIN2(_mesa_get_format_bits(texFormat
,
657 GL_TEXTURE_RED_SIZE
),
658 _mesa_get_format_bits(texFormat
,
659 GL_TEXTURE_GREEN_SIZE
));
667 /* GL_ARB_texture_float */
668 case GL_TEXTURE_RED_TYPE_ARB
:
669 case GL_TEXTURE_GREEN_TYPE_ARB
:
670 case GL_TEXTURE_BLUE_TYPE_ARB
:
671 case GL_TEXTURE_ALPHA_TYPE_ARB
:
672 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
673 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
674 case GL_TEXTURE_DEPTH_TYPE_ARB
:
675 if (!ctx
->Extensions
.ARB_texture_float
)
677 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
678 *params
= _mesa_get_format_datatype(texFormat
);
687 /* no error if we get here */
691 _mesa_error(ctx
, GL_INVALID_ENUM
,
692 "glGetTexLevelParameter[if]v(pname=%s)",
693 _mesa_lookup_enum_by_nr(pname
));
699 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
701 struct gl_texture_object
*obj
;
702 GET_CURRENT_CONTEXT(ctx
);
703 ASSERT_OUTSIDE_BEGIN_END(ctx
);
705 obj
= get_texobj(ctx
, target
, GL_TRUE
);
709 _mesa_lock_texture(ctx
, obj
);
711 case GL_TEXTURE_MAG_FILTER
:
712 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
714 case GL_TEXTURE_MIN_FILTER
:
715 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
717 case GL_TEXTURE_WRAP_S
:
718 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
720 case GL_TEXTURE_WRAP_T
:
721 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
723 case GL_TEXTURE_WRAP_R
:
724 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
726 case GL_TEXTURE_BORDER_COLOR
:
727 if (ctx
->NewState
& _NEW_BUFFERS
)
728 _mesa_update_state_locked(ctx
);
729 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
730 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
731 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
732 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
734 case GL_TEXTURE_RESIDENT
:
737 case GL_TEXTURE_PRIORITY
:
738 *params
= obj
->Priority
;
740 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
741 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
743 *params
= obj
->Sampler
.MaxAnisotropy
;
746 case GL_TEXTURE_IMMUTABLE_FORMAT
:
747 if (!ctx
->Extensions
.ARB_texture_storage
)
749 *params
= (GLfloat
) obj
->Immutable
;
756 /* no error if we get here */
757 _mesa_unlock_texture(ctx
, obj
);
761 _mesa_unlock_texture(ctx
, obj
);
762 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
767 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
769 struct gl_texture_object
*obj
;
770 GET_CURRENT_CONTEXT(ctx
);
771 ASSERT_OUTSIDE_BEGIN_END(ctx
);
773 obj
= get_texobj(ctx
, target
, GL_TRUE
);
777 _mesa_lock_texture(ctx
, obj
);
779 case GL_TEXTURE_MAG_FILTER
:
780 *params
= (GLint
) obj
->Sampler
.MagFilter
;
782 case GL_TEXTURE_MIN_FILTER
:
783 *params
= (GLint
) obj
->Sampler
.MinFilter
;
785 case GL_TEXTURE_WRAP_S
:
786 *params
= (GLint
) obj
->Sampler
.WrapS
;
788 case GL_TEXTURE_WRAP_T
:
789 *params
= (GLint
) obj
->Sampler
.WrapT
;
791 case GL_TEXTURE_WRAP_R
:
792 *params
= (GLint
) obj
->Sampler
.WrapR
;
794 case GL_TEXTURE_BORDER_COLOR
:
797 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
798 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
799 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
800 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
801 params
[0] = FLOAT_TO_INT(b
[0]);
802 params
[1] = FLOAT_TO_INT(b
[1]);
803 params
[2] = FLOAT_TO_INT(b
[2]);
804 params
[3] = FLOAT_TO_INT(b
[3]);
807 case GL_TEXTURE_RESIDENT
:
810 case GL_TEXTURE_PRIORITY
:
811 *params
= FLOAT_TO_INT(obj
->Priority
);
813 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
814 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
816 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
819 case GL_TEXTURE_IMMUTABLE_FORMAT
:
820 if (!ctx
->Extensions
.ARB_texture_storage
)
822 *params
= (GLint
) obj
->Immutable
;
829 /* no error if we get here */
830 _mesa_unlock_texture(ctx
, obj
);
834 _mesa_unlock_texture(ctx
, obj
);
835 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
841 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
843 struct gl_texture_object
*texObj
;
844 GET_CURRENT_CONTEXT(ctx
);
845 ASSERT_OUTSIDE_BEGIN_END(ctx
);
847 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
852 case GL_TEXTURE_BORDER_COLOR
:
853 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
856 _mesa_GetTexParameteriv(target
, pname
, params
);
863 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, 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_TRUE
);
874 case GL_TEXTURE_BORDER_COLOR
:
875 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
880 _mesa_GetTexParameteriv(target
, pname
, ip
);
882 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
883 pname
== GL_TEXTURE_CROP_RECT_OES
) {