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
35 * Check if a coordinate wrap mode is supported for the texture target.
36 * \return GL_TRUE if legal, GL_FALSE otherwise
39 validate_texture_wrap_mode(struct gl_context
* ctx
, GLenum target
, GLenum wrap
)
44 case GL_MIRRORED_REPEAT
:
50 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
56 * Get current texture object for given target.
57 * Return NULL if any error (and record the error).
58 * Note that this is different from _mesa_select_tex_object() in that proxy
59 * targets are not accepted.
60 * Only the glGetTexLevelParameter() functions accept proxy targets.
62 static struct gl_texture_object
*
63 get_texobj(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
65 struct gl_texture_unit
*texUnit
;
67 texUnit
= &ctx
->Texture
.Unit
;
71 return texUnit
->CurrentTex
[TEXTURE_1D_INDEX
];
73 return texUnit
->CurrentTex
[TEXTURE_2D_INDEX
];
75 return texUnit
->CurrentTex
[TEXTURE_3D_INDEX
];
76 case GL_TEXTURE_CUBE_MAP
:
77 if (ctx
->Extensions
.ARB_texture_cube_map
) {
78 return texUnit
->CurrentTex
[TEXTURE_CUBE_INDEX
];
85 _mesa_error(ctx
, GL_INVALID_ENUM
,
86 "gl%sTexParameter(target)", get
? "Get" : "");
92 * This is called just prior to changing any texture object state which
93 * will not effect texture completeness.
96 flush(struct gl_context
*ctx
)
98 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
103 * This is called just prior to changing any texture object state which
104 * can effect texture completeness (texture base level, max level,
105 * minification filter).
106 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
107 * state flag and then mark the texture object as 'incomplete' so that any
108 * per-texture derived state gets recomputed.
111 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
113 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
114 texObj
->_Complete
= GL_FALSE
;
119 * Set an integer-valued texture parameter
120 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
123 set_tex_parameteri(struct gl_context
*ctx
,
124 struct gl_texture_object
*texObj
,
125 GLenum pname
, const GLint
*params
)
128 case GL_TEXTURE_MIN_FILTER
:
129 if (texObj
->Sampler
.MinFilter
== params
[0])
134 incomplete(ctx
, texObj
);
135 texObj
->Sampler
.MinFilter
= params
[0];
137 case GL_NEAREST_MIPMAP_NEAREST
:
138 case GL_LINEAR_MIPMAP_NEAREST
:
139 case GL_NEAREST_MIPMAP_LINEAR
:
140 case GL_LINEAR_MIPMAP_LINEAR
:
141 incomplete(ctx
, texObj
);
142 texObj
->Sampler
.MinFilter
= params
[0];
150 case GL_TEXTURE_MAG_FILTER
:
151 if (texObj
->Sampler
.MagFilter
== params
[0])
156 flush(ctx
); /* does not effect completeness */
157 texObj
->Sampler
.MagFilter
= params
[0];
164 case GL_TEXTURE_WRAP_S
:
165 if (texObj
->Sampler
.WrapS
== params
[0])
167 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
169 texObj
->Sampler
.WrapS
= params
[0];
174 case GL_TEXTURE_WRAP_T
:
175 if (texObj
->Sampler
.WrapT
== params
[0])
177 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
179 texObj
->Sampler
.WrapT
= params
[0];
184 case GL_TEXTURE_WRAP_R
:
185 if (texObj
->Sampler
.WrapR
== params
[0])
187 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
189 texObj
->Sampler
.WrapR
= params
[0];
199 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=%s)",
200 _mesa_lookup_enum_by_nr(pname
));
204 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param=%s)",
205 _mesa_lookup_enum_by_nr(params
[0]));
211 * Set a float-valued texture parameter
212 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
215 set_tex_parameterf(struct gl_context
*ctx
,
216 struct gl_texture_object
*texObj
,
217 GLenum pname
, const GLfloat
*params
)
221 case GL_TEXTURE_PRIORITY
:
223 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
226 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
227 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
228 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
230 if (params
[0] < 1.0) {
231 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
235 /* clamp to max, that's what NVIDIA does */
236 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
237 ctx
->Const
.MaxTextureMaxAnisotropy
);
241 static GLuint count
= 0;
243 _mesa_error(ctx
, GL_INVALID_ENUM
,
244 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
248 case GL_TEXTURE_BORDER_COLOR
:
250 /* ARB_texture_float disables clamping */
251 if (ctx
->Extensions
.ARB_texture_float
) {
252 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
253 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
254 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
255 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
257 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
258 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
259 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
260 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
265 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname=0x%x)", pname
);
272 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
274 GLboolean need_update
;
275 struct gl_texture_object
*texObj
;
276 GET_CURRENT_CONTEXT(ctx
);
277 ASSERT_OUTSIDE_BEGIN_END(ctx
);
279 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
284 case GL_TEXTURE_MIN_FILTER
:
285 case GL_TEXTURE_MAG_FILTER
:
286 case GL_TEXTURE_WRAP_S
:
287 case GL_TEXTURE_WRAP_T
:
288 case GL_TEXTURE_WRAP_R
:
289 case GL_TEXTURE_COMPARE_MODE_ARB
:
290 case GL_TEXTURE_COMPARE_FUNC_ARB
:
291 case GL_DEPTH_TEXTURE_MODE_ARB
:
292 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
294 /* convert float param to int */
296 p
[0] = (GLint
) param
;
297 p
[1] = p
[2] = p
[3] = 0;
298 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
301 case GL_TEXTURE_SWIZZLE_R_EXT
:
302 case GL_TEXTURE_SWIZZLE_G_EXT
:
303 case GL_TEXTURE_SWIZZLE_B_EXT
:
304 case GL_TEXTURE_SWIZZLE_A_EXT
:
307 p
[0] = (GLint
) param
;
308 p
[1] = p
[2] = p
[3] = 0;
309 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
314 /* this will generate an error if pname is illegal */
317 p
[1] = p
[2] = p
[3] = 0.0F
;
318 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
);
322 if (ctx
->Driver
.TexParameter
&& need_update
) {
323 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, ¶m
);
329 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
331 GLboolean need_update
;
332 struct gl_texture_object
*texObj
;
333 GET_CURRENT_CONTEXT(ctx
);
334 ASSERT_OUTSIDE_BEGIN_END(ctx
);
336 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
341 case GL_TEXTURE_MIN_FILTER
:
342 case GL_TEXTURE_MAG_FILTER
:
343 case GL_TEXTURE_WRAP_S
:
344 case GL_TEXTURE_WRAP_T
:
345 case GL_TEXTURE_WRAP_R
:
346 case GL_TEXTURE_COMPARE_MODE_ARB
:
347 case GL_TEXTURE_COMPARE_FUNC_ARB
:
348 case GL_DEPTH_TEXTURE_MODE_ARB
:
349 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
351 /* convert float param to int */
353 p
[0] = (GLint
) params
[0];
354 p
[1] = p
[2] = p
[3] = 0;
355 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
359 case GL_TEXTURE_SWIZZLE_R_EXT
:
360 case GL_TEXTURE_SWIZZLE_G_EXT
:
361 case GL_TEXTURE_SWIZZLE_B_EXT
:
362 case GL_TEXTURE_SWIZZLE_A_EXT
:
363 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
365 GLint p
[4] = {0, 0, 0, 0};
366 p
[0] = (GLint
) params
[0];
367 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
368 p
[1] = (GLint
) params
[1];
369 p
[2] = (GLint
) params
[2];
370 p
[3] = (GLint
) params
[3];
372 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
);
376 /* this will generate an error if pname is illegal */
377 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
);
380 if (ctx
->Driver
.TexParameter
&& need_update
) {
381 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, params
);
387 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
389 GLboolean need_update
;
390 struct gl_texture_object
*texObj
;
391 GET_CURRENT_CONTEXT(ctx
);
392 ASSERT_OUTSIDE_BEGIN_END(ctx
);
394 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
399 case GL_TEXTURE_MIN_LOD
:
400 case GL_TEXTURE_MAX_LOD
:
401 case GL_TEXTURE_PRIORITY
:
402 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
403 case GL_TEXTURE_LOD_BIAS
:
404 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
407 fparam
[0] = (GLfloat
) param
;
408 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
409 /* convert int param to float */
410 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
);
414 /* this will generate an error if pname is illegal */
418 iparam
[1] = iparam
[2] = iparam
[3] = 0;
419 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
);
423 if (ctx
->Driver
.TexParameter
&& need_update
) {
424 GLfloat fparam
= (GLfloat
) param
;
425 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, &fparam
);
431 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
433 GLboolean need_update
;
434 struct gl_texture_object
*texObj
;
435 GET_CURRENT_CONTEXT(ctx
);
436 ASSERT_OUTSIDE_BEGIN_END(ctx
);
438 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
443 case GL_TEXTURE_BORDER_COLOR
:
445 /* convert int params to float */
447 fparams
[0] = INT_TO_FLOAT(params
[0]);
448 fparams
[1] = INT_TO_FLOAT(params
[1]);
449 fparams
[2] = INT_TO_FLOAT(params
[2]);
450 fparams
[3] = INT_TO_FLOAT(params
[3]);
451 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
454 case GL_TEXTURE_MIN_LOD
:
455 case GL_TEXTURE_MAX_LOD
:
456 case GL_TEXTURE_PRIORITY
:
457 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
458 case GL_TEXTURE_LOD_BIAS
:
459 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
461 /* convert int param to float */
463 fparams
[0] = (GLfloat
) params
[0];
464 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
465 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
);
469 /* this will generate an error if pname is illegal */
470 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
);
473 if (ctx
->Driver
.TexParameter
&& need_update
) {
475 fparams
[0] = INT_TO_FLOAT(params
[0]);
476 if (pname
== GL_TEXTURE_BORDER_COLOR
||
477 pname
== GL_TEXTURE_CROP_RECT_OES
) {
478 fparams
[1] = INT_TO_FLOAT(params
[1]);
479 fparams
[2] = INT_TO_FLOAT(params
[2]);
480 fparams
[3] = INT_TO_FLOAT(params
[3]);
482 ctx
->Driver
.TexParameter(ctx
, target
, texObj
, pname
, fparams
);
488 * Set tex parameter to integer value(s). Primarily intended to set
489 * integer-valued texture border color (for integer-valued textures).
493 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
495 struct gl_texture_object
*texObj
;
496 GET_CURRENT_CONTEXT(ctx
);
497 ASSERT_OUTSIDE_BEGIN_END(ctx
);
499 texObj
= get_texobj(ctx
, target
, GL_FALSE
);
504 case GL_TEXTURE_BORDER_COLOR
:
505 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
506 /* set the integer-valued border color */
507 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
510 _mesa_TexParameteriv(target
, pname
, params
);
513 /* XXX no driver hook for TexParameterIiv() yet */
518 * Set tex parameter to unsigned integer value(s). Primarily intended to set
519 * uint-valued texture border color (for integer-valued textures).
523 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*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 unsigned integer-valued border color */
537 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
540 _mesa_TexParameteriv(target
, pname
, (const GLint
*) params
);
543 /* XXX no driver hook for TexParameterIuiv() yet */
548 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
549 GLenum pname
, GLfloat
*params
)
552 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
553 *params
= (GLfloat
) iparam
;
558 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
559 GLenum pname
, GLint
*params
)
561 struct gl_texture_object
*texObj
;
562 const struct gl_texture_image
*img
= NULL
;
565 GET_CURRENT_CONTEXT(ctx
);
566 ASSERT_OUTSIDE_BEGIN_END(ctx
);
568 /* this will catch bad target values */
569 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
570 if (maxLevels
== 0) {
571 _mesa_error(ctx
, GL_INVALID_ENUM
,
572 "glGetTexLevelParameter[if]v(target=0x%x)", target
);
576 if (level
< 0 || level
>= maxLevels
) {
577 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
581 texObj
= _mesa_select_tex_object(ctx
, target
);
583 img
= _mesa_select_tex_image(ctx
, texObj
, target
, level
);
584 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
585 /* undefined texture image */
586 if (pname
== GL_TEXTURE_COMPONENTS
)
593 texFormat
= img
->TexFormat
;
596 case GL_TEXTURE_WIDTH
:
597 *params
= img
->Width
;
599 case GL_TEXTURE_HEIGHT
:
600 *params
= img
->Height
;
602 case GL_TEXTURE_DEPTH
:
603 *params
= img
->Depth
;
605 case GL_TEXTURE_INTERNAL_FORMAT
:
606 *params
= img
->InternalFormat
;
608 case GL_TEXTURE_BORDER
:
609 *params
= img
->Border
;
611 case GL_TEXTURE_RED_SIZE
:
612 case GL_TEXTURE_GREEN_SIZE
:
613 case GL_TEXTURE_BLUE_SIZE
:
614 case GL_TEXTURE_ALPHA_SIZE
:
615 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
616 *params
= _mesa_get_format_bits(texFormat
, pname
);
620 case GL_TEXTURE_INTENSITY_SIZE
:
621 case GL_TEXTURE_LUMINANCE_SIZE
:
622 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
623 *params
= _mesa_get_format_bits(texFormat
, pname
);
625 /* intensity or luminance is probably stored as RGB[A] */
626 *params
= MIN2(_mesa_get_format_bits(texFormat
,
627 GL_TEXTURE_RED_SIZE
),
628 _mesa_get_format_bits(texFormat
,
629 GL_TEXTURE_GREEN_SIZE
));
637 /* GL_ARB_texture_float */
638 case GL_TEXTURE_RED_TYPE_ARB
:
639 case GL_TEXTURE_GREEN_TYPE_ARB
:
640 case GL_TEXTURE_BLUE_TYPE_ARB
:
641 case GL_TEXTURE_ALPHA_TYPE_ARB
:
642 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
643 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
644 case GL_TEXTURE_DEPTH_TYPE_ARB
:
645 if (!ctx
->Extensions
.ARB_texture_float
)
647 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
648 *params
= _mesa_get_format_datatype(texFormat
);
657 /* no error if we get here */
661 _mesa_error(ctx
, GL_INVALID_ENUM
,
662 "glGetTexLevelParameter[if]v(pname=%s)",
663 _mesa_lookup_enum_by_nr(pname
));
669 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
671 struct gl_texture_object
*obj
;
672 GET_CURRENT_CONTEXT(ctx
);
673 ASSERT_OUTSIDE_BEGIN_END(ctx
);
675 obj
= get_texobj(ctx
, target
, GL_TRUE
);
679 _mesa_lock_texture(ctx
, obj
);
681 case GL_TEXTURE_MAG_FILTER
:
682 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
684 case GL_TEXTURE_MIN_FILTER
:
685 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
687 case GL_TEXTURE_WRAP_S
:
688 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
690 case GL_TEXTURE_WRAP_T
:
691 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
693 case GL_TEXTURE_WRAP_R
:
694 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
696 case GL_TEXTURE_BORDER_COLOR
:
697 if (ctx
->NewState
& _NEW_BUFFERS
)
698 _mesa_update_state_locked(ctx
);
699 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
700 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
701 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
702 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
704 case GL_TEXTURE_RESIDENT
:
707 case GL_TEXTURE_PRIORITY
:
708 *params
= obj
->Priority
;
710 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
711 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
713 *params
= obj
->Sampler
.MaxAnisotropy
;
716 case GL_TEXTURE_IMMUTABLE_FORMAT
:
717 if (!ctx
->Extensions
.ARB_texture_storage
)
719 *params
= (GLfloat
) obj
->Immutable
;
726 /* no error if we get here */
727 _mesa_unlock_texture(ctx
, obj
);
731 _mesa_unlock_texture(ctx
, obj
);
732 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)", pname
);
737 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
739 struct gl_texture_object
*obj
;
740 GET_CURRENT_CONTEXT(ctx
);
741 ASSERT_OUTSIDE_BEGIN_END(ctx
);
743 obj
= get_texobj(ctx
, target
, GL_TRUE
);
747 _mesa_lock_texture(ctx
, obj
);
749 case GL_TEXTURE_MAG_FILTER
:
750 *params
= (GLint
) obj
->Sampler
.MagFilter
;
752 case GL_TEXTURE_MIN_FILTER
:
753 *params
= (GLint
) obj
->Sampler
.MinFilter
;
755 case GL_TEXTURE_WRAP_S
:
756 *params
= (GLint
) obj
->Sampler
.WrapS
;
758 case GL_TEXTURE_WRAP_T
:
759 *params
= (GLint
) obj
->Sampler
.WrapT
;
761 case GL_TEXTURE_WRAP_R
:
762 *params
= (GLint
) obj
->Sampler
.WrapR
;
764 case GL_TEXTURE_BORDER_COLOR
:
767 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
768 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
769 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
770 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
771 params
[0] = FLOAT_TO_INT(b
[0]);
772 params
[1] = FLOAT_TO_INT(b
[1]);
773 params
[2] = FLOAT_TO_INT(b
[2]);
774 params
[3] = FLOAT_TO_INT(b
[3]);
777 case GL_TEXTURE_RESIDENT
:
780 case GL_TEXTURE_PRIORITY
:
781 *params
= FLOAT_TO_INT(obj
->Priority
);
783 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
784 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
786 *params
= (GLint
) obj
->Sampler
.MaxAnisotropy
;
789 case GL_TEXTURE_IMMUTABLE_FORMAT
:
790 if (!ctx
->Extensions
.ARB_texture_storage
)
792 *params
= (GLint
) obj
->Immutable
;
799 /* no error if we get here */
800 _mesa_unlock_texture(ctx
, obj
);
804 _mesa_unlock_texture(ctx
, obj
);
805 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
811 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
813 struct gl_texture_object
*texObj
;
814 GET_CURRENT_CONTEXT(ctx
);
815 ASSERT_OUTSIDE_BEGIN_END(ctx
);
817 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
822 case GL_TEXTURE_BORDER_COLOR
:
823 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
826 _mesa_GetTexParameteriv(target
, pname
, params
);
833 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
835 struct gl_texture_object
*texObj
;
836 GET_CURRENT_CONTEXT(ctx
);
837 ASSERT_OUTSIDE_BEGIN_END(ctx
);
839 texObj
= get_texobj(ctx
, target
, GL_TRUE
);
844 case GL_TEXTURE_BORDER_COLOR
:
845 COPY_4V(params
, texObj
->Sampler
.BorderColor
.i
);
850 _mesa_GetTexParameteriv(target
, pname
, ip
);
852 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
853 pname
== GL_TEXTURE_CROP_RECT_OES
) {