2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
29 * glTexParameter-related functions
33 #include "main/glheader.h"
34 #include "main/blend.h"
35 #include "main/context.h"
36 #include "main/enums.h"
37 #include "main/formats.h"
38 #include "main/glformats.h"
39 #include "main/macros.h"
40 #include "main/mtypes.h"
41 #include "main/state.h"
42 #include "main/texcompress.h"
43 #include "main/texobj.h"
44 #include "main/texparam.h"
45 #include "main/teximage.h"
46 #include "main/texstate.h"
47 #include "program/prog_instruction.h"
51 * Check if a coordinate wrap mode is supported for the texture target.
52 * \return GL_TRUE if legal, GL_FALSE otherwise
55 validate_texture_wrap_mode(struct gl_context
* ctx
, GLenum target
, GLenum wrap
)
57 const struct gl_extensions
* const e
= & ctx
->Extensions
;
58 const bool is_desktop_gl
= _mesa_is_desktop_gl(ctx
);
63 /* GL_CLAMP was removed in the core profile, and it has never existed in
66 supported
= (ctx
->API
== API_OPENGL_COMPAT
)
67 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
70 case GL_CLAMP_TO_EDGE
:
74 case GL_CLAMP_TO_BORDER
:
75 supported
= ctx
->API
!= API_OPENGLES
&& e
->ARB_texture_border_clamp
76 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
80 case GL_MIRRORED_REPEAT
:
81 supported
= (target
!= GL_TEXTURE_RECTANGLE_NV
)
82 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
85 case GL_MIRROR_CLAMP_EXT
:
86 supported
= is_desktop_gl
87 && (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)
88 && (target
!= GL_TEXTURE_RECTANGLE_NV
)
89 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
92 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
93 supported
= is_desktop_gl
94 && (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
)
95 && (target
!= GL_TEXTURE_RECTANGLE_NV
)
96 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
99 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
100 supported
= is_desktop_gl
&& e
->EXT_texture_mirror_clamp
101 && (target
!= GL_TEXTURE_RECTANGLE_NV
)
102 && (target
!= GL_TEXTURE_EXTERNAL_OES
);
111 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(param=0x%x)", wrap
);
118 * Get current texture object for given target.
119 * Return NULL if any error (and record the error).
120 * Note that this is different from _mesa_get_current_tex_object() in that
121 * proxy targets are not accepted.
122 * Only the glGetTexLevelParameter() functions accept proxy targets.
124 static struct gl_texture_object
*
125 get_texobj_by_target(struct gl_context
*ctx
, GLenum target
, GLboolean get
)
127 struct gl_texture_unit
*texUnit
;
130 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
131 _mesa_error(ctx
, GL_INVALID_OPERATION
,
132 "gl%sTexParameter(current unit)", get
? "Get" : "");
136 texUnit
= _mesa_get_current_tex_unit(ctx
);
138 targetIndex
= _mesa_tex_target_to_index(ctx
, target
);
139 if (targetIndex
< 0 || targetIndex
== TEXTURE_BUFFER_INDEX
) {
140 _mesa_error(ctx
, GL_INVALID_ENUM
,
141 "gl%sTexParameter(target)", get
? "Get" : "");
144 assert(targetIndex
< NUM_TEXTURE_TARGETS
);
146 return texUnit
->CurrentTex
[targetIndex
];
150 * Get current texture object for given name.
151 * Return NULL if any error (and record the error).
152 * Note that proxy targets are not accepted.
153 * Only the glGetTexLevelParameter() functions accept proxy targets.
155 static struct gl_texture_object
*
156 get_texobj_by_name(struct gl_context
*ctx
, GLuint texture
, const char *name
)
158 struct gl_texture_object
*texObj
;
160 texObj
= _mesa_lookup_texture(ctx
, texture
);
162 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture)", name
);
166 switch (texObj
->Target
) {
168 case GL_TEXTURE_1D_ARRAY
:
170 case GL_TEXTURE_2D_ARRAY
:
171 case GL_TEXTURE_2D_MULTISAMPLE
:
172 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
174 case GL_TEXTURE_CUBE_MAP
:
175 case GL_TEXTURE_CUBE_MAP_ARRAY
:
176 case GL_TEXTURE_RECTANGLE
:
179 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(target)", name
);
187 * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE.
188 * \return -1 if error.
191 comp_to_swizzle(GLenum comp
)
213 set_swizzle_component(GLuint
*swizzle
, GLuint comp
, GLuint swz
)
216 assert(swz
<= SWIZZLE_NIL
);
218 GLuint mask
= 0x7 << (3 * comp
);
219 GLuint s
= (*swizzle
& ~mask
) | (swz
<< (3 * comp
));
226 * This is called just prior to changing any texture object state which
227 * will not affect texture completeness.
230 flush(struct gl_context
*ctx
)
232 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
237 * This is called just prior to changing any texture object state which
238 * could affect texture completeness (texture base level, max level).
239 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE_OBJECT
240 * state flag and then mark the texture object as 'incomplete' so that any
241 * per-texture derived state gets recomputed.
244 incomplete(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
246 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
247 _mesa_dirty_texobj(ctx
, texObj
);
252 _mesa_target_allows_setting_sampler_parameters(GLenum target
)
255 case GL_TEXTURE_2D_MULTISAMPLE
:
256 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
266 * Set an integer-valued texture parameter
267 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
270 set_tex_parameteri(struct gl_context
*ctx
,
271 struct gl_texture_object
*texObj
,
272 GLenum pname
, const GLint
*params
, bool dsa
)
274 const char *suffix
= dsa
? "ture" : "";
276 if (texObj
->HandleAllocated
) {
277 /* The ARB_bindless_texture spec says:
279 * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
280 * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
281 * functions defined in terms of these, if the texture object to be
282 * modified is referenced by one or more texture or image handles."
284 _mesa_error(ctx
, GL_INVALID_OPERATION
,
285 "glTex%sParameter(immutable texture)", suffix
);
290 case GL_TEXTURE_MIN_FILTER
:
291 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
294 if (texObj
->Sampler
.MinFilter
== params
[0])
300 texObj
->Sampler
.MinFilter
= params
[0];
302 case GL_NEAREST_MIPMAP_NEAREST
:
303 case GL_LINEAR_MIPMAP_NEAREST
:
304 case GL_NEAREST_MIPMAP_LINEAR
:
305 case GL_LINEAR_MIPMAP_LINEAR
:
306 if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
307 texObj
->Target
!= GL_TEXTURE_EXTERNAL_OES
) {
309 texObj
->Sampler
.MinFilter
= params
[0];
318 case GL_TEXTURE_MAG_FILTER
:
319 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
322 if (texObj
->Sampler
.MagFilter
== params
[0])
327 flush(ctx
); /* does not effect completeness */
328 texObj
->Sampler
.MagFilter
= params
[0];
335 case GL_TEXTURE_WRAP_S
:
336 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
339 if (texObj
->Sampler
.WrapS
== params
[0])
341 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
343 texObj
->Sampler
.WrapS
= params
[0];
348 case GL_TEXTURE_WRAP_T
:
349 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
352 if (texObj
->Sampler
.WrapT
== params
[0])
354 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
356 texObj
->Sampler
.WrapT
= params
[0];
361 case GL_TEXTURE_WRAP_R
:
362 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
365 if (texObj
->Sampler
.WrapR
== params
[0])
367 if (validate_texture_wrap_mode(ctx
, texObj
->Target
, params
[0])) {
369 texObj
->Sampler
.WrapR
= params
[0];
374 case GL_TEXTURE_BASE_LEVEL
:
375 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
378 if (texObj
->BaseLevel
== params
[0])
381 if ((texObj
->Target
== GL_TEXTURE_2D_MULTISAMPLE
||
382 texObj
->Target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
) && params
[0] != 0)
383 goto invalid_operation
;
386 _mesa_error(ctx
, GL_INVALID_VALUE
,
387 "glTex%sParameter(param=%d)", suffix
, params
[0]);
390 if (texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
&& params
[0] != 0) {
391 _mesa_error(ctx
, GL_INVALID_OPERATION
,
392 "glTex%sParameter(target=%s, param=%d)", suffix
,
393 _mesa_enum_to_string(texObj
->Target
), params
[0]);
396 incomplete(ctx
, texObj
);
398 /** See note about ARB_texture_storage below */
399 if (texObj
->Immutable
)
400 texObj
->BaseLevel
= MIN2(texObj
->ImmutableLevels
- 1, params
[0]);
402 texObj
->BaseLevel
= params
[0];
406 case GL_TEXTURE_MAX_LEVEL
:
407 if (texObj
->MaxLevel
== params
[0])
411 (texObj
->Target
== GL_TEXTURE_RECTANGLE_ARB
&& params
[0] > 0)) {
412 _mesa_error(ctx
, GL_INVALID_VALUE
,
413 "glTex%sParameter(param=%d)", suffix
,
417 incomplete(ctx
, texObj
);
419 /** From ARB_texture_storage:
420 * However, if TEXTURE_IMMUTABLE_FORMAT is TRUE, then level_base is
421 * clamped to the range [0, <levels> - 1] and level_max is then clamped to
422 * the range [level_base, <levels> - 1], where <levels> is the parameter
423 * passed the call to TexStorage* for the texture object.
425 if (texObj
->Immutable
)
426 texObj
->MaxLevel
= CLAMP(params
[0], texObj
->BaseLevel
,
427 texObj
->ImmutableLevels
- 1);
429 texObj
->MaxLevel
= params
[0];
433 case GL_GENERATE_MIPMAP_SGIS
:
434 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
437 if (params
[0] && texObj
->Target
== GL_TEXTURE_EXTERNAL_OES
)
439 if (texObj
->GenerateMipmap
!= params
[0]) {
441 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
446 case GL_TEXTURE_COMPARE_MODE_ARB
:
447 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_shadow
)
448 || _mesa_is_gles3(ctx
)) {
450 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
453 if (texObj
->Sampler
.CompareMode
== params
[0])
455 if (params
[0] == GL_NONE
||
456 params
[0] == GL_COMPARE_R_TO_TEXTURE_ARB
) {
458 texObj
->Sampler
.CompareMode
= params
[0];
465 case GL_TEXTURE_COMPARE_FUNC_ARB
:
466 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_shadow
)
467 || _mesa_is_gles3(ctx
)) {
469 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
472 if (texObj
->Sampler
.CompareFunc
== params
[0])
484 texObj
->Sampler
.CompareFunc
= params
[0];
492 case GL_DEPTH_TEXTURE_MODE_ARB
:
493 /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has never
494 * existed in OpenGL ES.
496 if (ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Extensions
.ARB_depth_texture
) {
497 if (texObj
->DepthMode
== params
[0])
499 if (params
[0] == GL_LUMINANCE
||
500 params
[0] == GL_INTENSITY
||
501 params
[0] == GL_ALPHA
||
502 (ctx
->Extensions
.ARB_texture_rg
&& params
[0] == GL_RED
)) {
504 texObj
->DepthMode
= params
[0];
511 case GL_DEPTH_STENCIL_TEXTURE_MODE
:
512 if (_mesa_has_ARB_stencil_texturing(ctx
) || _mesa_is_gles31(ctx
)) {
513 bool stencil
= params
[0] == GL_STENCIL_INDEX
;
514 if (!stencil
&& params
[0] != GL_DEPTH_COMPONENT
)
517 if (texObj
->StencilSampling
== stencil
)
520 texObj
->StencilSampling
= stencil
;
525 case GL_TEXTURE_CROP_RECT_OES
:
526 if (ctx
->API
!= API_OPENGLES
|| !ctx
->Extensions
.OES_draw_texture
)
529 texObj
->CropRect
[0] = params
[0];
530 texObj
->CropRect
[1] = params
[1];
531 texObj
->CropRect
[2] = params
[2];
532 texObj
->CropRect
[3] = params
[3];
535 case GL_TEXTURE_SWIZZLE_R_EXT
:
536 case GL_TEXTURE_SWIZZLE_G_EXT
:
537 case GL_TEXTURE_SWIZZLE_B_EXT
:
538 case GL_TEXTURE_SWIZZLE_A_EXT
:
539 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_swizzle
)
540 || _mesa_is_gles3(ctx
)) {
541 const GLuint comp
= pname
- GL_TEXTURE_SWIZZLE_R_EXT
;
542 const GLint swz
= comp_to_swizzle(params
[0]);
544 _mesa_error(ctx
, GL_INVALID_ENUM
,
545 "glTex%sParameter(swizzle 0x%x)", suffix
, params
[0]);
551 texObj
->Swizzle
[comp
] = params
[0];
552 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
557 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
558 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_swizzle
)
559 || _mesa_is_gles3(ctx
)) {
562 for (comp
= 0; comp
< 4; comp
++) {
563 const GLint swz
= comp_to_swizzle(params
[comp
]);
565 texObj
->Swizzle
[comp
] = params
[comp
];
566 set_swizzle_component(&texObj
->_Swizzle
, comp
, swz
);
569 _mesa_error(ctx
, GL_INVALID_ENUM
,
570 "glTex%sParameter(swizzle 0x%x)",
571 suffix
, params
[comp
]);
579 case GL_TEXTURE_SRGB_DECODE_EXT
:
580 if (ctx
->Extensions
.EXT_texture_sRGB_decode
) {
581 GLenum decode
= params
[0];
583 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
586 if (decode
== GL_DECODE_EXT
|| decode
== GL_SKIP_DECODE_EXT
) {
587 if (texObj
->Sampler
.sRGBDecode
!= decode
) {
589 texObj
->Sampler
.sRGBDecode
= decode
;
596 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
597 if (_mesa_is_desktop_gl(ctx
)
598 && ctx
->Extensions
.AMD_seamless_cubemap_per_texture
) {
599 GLenum param
= params
[0];
601 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
604 if (param
!= GL_TRUE
&& param
!= GL_FALSE
) {
607 if (param
!= texObj
->Sampler
.CubeMapSeamless
) {
609 texObj
->Sampler
.CubeMapSeamless
= param
;
620 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameter(pname=%s)",
621 suffix
, _mesa_enum_to_string(pname
));
625 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameter(param=%s)",
626 suffix
, _mesa_enum_to_string(params
[0]));
630 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTex%sParameter(pname=%s)",
631 suffix
, _mesa_enum_to_string(pname
));
635 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameter(pname=%s)",
636 suffix
, _mesa_enum_to_string(pname
));
642 * Set a float-valued texture parameter
643 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
646 set_tex_parameterf(struct gl_context
*ctx
,
647 struct gl_texture_object
*texObj
,
648 GLenum pname
, const GLfloat
*params
, bool dsa
)
650 const char *suffix
= dsa
? "ture" : "";
652 if (texObj
->HandleAllocated
) {
653 /* The ARB_bindless_texture spec says:
655 * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
656 * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
657 * functions defined in terms of these, if the texture object to be
658 * modified is referenced by one or more texture or image handles."
660 _mesa_error(ctx
, GL_INVALID_OPERATION
,
661 "glTex%sParameter(immutable texture)", suffix
);
666 case GL_TEXTURE_MIN_LOD
:
667 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
670 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
673 if (texObj
->Sampler
.MinLod
== params
[0])
676 texObj
->Sampler
.MinLod
= params
[0];
679 case GL_TEXTURE_MAX_LOD
:
680 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
683 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
686 if (texObj
->Sampler
.MaxLod
== params
[0])
689 texObj
->Sampler
.MaxLod
= params
[0];
692 case GL_TEXTURE_PRIORITY
:
693 if (ctx
->API
!= API_OPENGL_COMPAT
)
697 texObj
->Priority
= CLAMP(params
[0], 0.0F
, 1.0F
);
700 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
701 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
702 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
705 if (texObj
->Sampler
.MaxAnisotropy
== params
[0])
707 if (params
[0] < 1.0F
) {
708 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTex%sParameter(param)",
713 /* clamp to max, that's what NVIDIA does */
714 texObj
->Sampler
.MaxAnisotropy
= MIN2(params
[0],
715 ctx
->Const
.MaxTextureMaxAnisotropy
);
719 static GLuint count
= 0;
725 case GL_TEXTURE_LOD_BIAS
:
726 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias. */
727 if (_mesa_is_gles(ctx
))
730 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
733 if (texObj
->Sampler
.LodBias
!= params
[0]) {
735 texObj
->Sampler
.LodBias
= params
[0];
740 case GL_TEXTURE_BORDER_COLOR
:
741 if (ctx
->API
== API_OPENGLES
||
742 !ctx
->Extensions
.ARB_texture_border_clamp
)
745 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
))
749 /* ARB_texture_float disables clamping */
750 if (ctx
->Extensions
.ARB_texture_float
) {
751 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = params
[0];
752 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = params
[1];
753 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = params
[2];
754 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = params
[3];
756 texObj
->Sampler
.BorderColor
.f
[RCOMP
] = CLAMP(params
[0], 0.0F
, 1.0F
);
757 texObj
->Sampler
.BorderColor
.f
[GCOMP
] = CLAMP(params
[1], 0.0F
, 1.0F
);
758 texObj
->Sampler
.BorderColor
.f
[BCOMP
] = CLAMP(params
[2], 0.0F
, 1.0F
);
759 texObj
->Sampler
.BorderColor
.f
[ACOMP
] = CLAMP(params
[3], 0.0F
, 1.0F
);
769 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameter(pname=%s)",
770 suffix
, _mesa_enum_to_string(pname
));
774 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameter(pname=%s)",
775 suffix
, _mesa_enum_to_string(pname
));
781 _mesa_texture_parameterf(struct gl_context
*ctx
,
782 struct gl_texture_object
*texObj
,
783 GLenum pname
, GLfloat param
, bool dsa
)
785 GLboolean need_update
;
788 case GL_TEXTURE_MIN_FILTER
:
789 case GL_TEXTURE_MAG_FILTER
:
790 case GL_TEXTURE_WRAP_S
:
791 case GL_TEXTURE_WRAP_T
:
792 case GL_TEXTURE_WRAP_R
:
793 case GL_TEXTURE_BASE_LEVEL
:
794 case GL_TEXTURE_MAX_LEVEL
:
795 case GL_GENERATE_MIPMAP_SGIS
:
796 case GL_TEXTURE_COMPARE_MODE_ARB
:
797 case GL_TEXTURE_COMPARE_FUNC_ARB
:
798 case GL_DEPTH_TEXTURE_MODE_ARB
:
799 case GL_DEPTH_STENCIL_TEXTURE_MODE
:
800 case GL_TEXTURE_SRGB_DECODE_EXT
:
801 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
802 case GL_TEXTURE_SWIZZLE_R_EXT
:
803 case GL_TEXTURE_SWIZZLE_G_EXT
:
804 case GL_TEXTURE_SWIZZLE_B_EXT
:
805 case GL_TEXTURE_SWIZZLE_A_EXT
:
809 ((param
> INT_MAX
) ? INT_MAX
: (GLint
) (param
+ 0.5)) :
810 ((param
< INT_MIN
) ? INT_MIN
: (GLint
) (param
- 0.5));
812 p
[1] = p
[2] = p
[3] = 0;
813 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
, dsa
);
816 case GL_TEXTURE_BORDER_COLOR
:
817 case GL_TEXTURE_SWIZZLE_RGBA
:
818 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTex%sParameterf(non-scalar pname)",
823 /* this will generate an error if pname is illegal */
826 p
[1] = p
[2] = p
[3] = 0.0F
;
827 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, p
, dsa
);
831 if (ctx
->Driver
.TexParameter
&& need_update
) {
832 ctx
->Driver
.TexParameter(ctx
, texObj
, pname
);
838 _mesa_texture_parameterfv(struct gl_context
*ctx
,
839 struct gl_texture_object
*texObj
,
840 GLenum pname
, const GLfloat
*params
, bool dsa
)
842 GLboolean need_update
;
844 case GL_TEXTURE_MIN_FILTER
:
845 case GL_TEXTURE_MAG_FILTER
:
846 case GL_TEXTURE_WRAP_S
:
847 case GL_TEXTURE_WRAP_T
:
848 case GL_TEXTURE_WRAP_R
:
849 case GL_TEXTURE_BASE_LEVEL
:
850 case GL_TEXTURE_MAX_LEVEL
:
851 case GL_GENERATE_MIPMAP_SGIS
:
852 case GL_TEXTURE_COMPARE_MODE_ARB
:
853 case GL_TEXTURE_COMPARE_FUNC_ARB
:
854 case GL_DEPTH_TEXTURE_MODE_ARB
:
855 case GL_DEPTH_STENCIL_TEXTURE_MODE
:
856 case GL_TEXTURE_SRGB_DECODE_EXT
:
857 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
859 /* convert float param to int */
861 p
[0] = (GLint
) params
[0];
862 p
[1] = p
[2] = p
[3] = 0;
863 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
, dsa
);
866 case GL_TEXTURE_CROP_RECT_OES
:
868 /* convert float params to int */
870 iparams
[0] = (GLint
) params
[0];
871 iparams
[1] = (GLint
) params
[1];
872 iparams
[2] = (GLint
) params
[2];
873 iparams
[3] = (GLint
) params
[3];
874 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparams
, dsa
);
877 case GL_TEXTURE_SWIZZLE_R_EXT
:
878 case GL_TEXTURE_SWIZZLE_G_EXT
:
879 case GL_TEXTURE_SWIZZLE_B_EXT
:
880 case GL_TEXTURE_SWIZZLE_A_EXT
:
881 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
883 GLint p
[4] = {0, 0, 0, 0};
884 p
[0] = (GLint
) params
[0];
885 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
) {
886 p
[1] = (GLint
) params
[1];
887 p
[2] = (GLint
) params
[2];
888 p
[3] = (GLint
) params
[3];
890 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, p
, dsa
);
894 /* this will generate an error if pname is illegal */
895 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, params
, dsa
);
898 if (ctx
->Driver
.TexParameter
&& need_update
) {
899 ctx
->Driver
.TexParameter(ctx
, texObj
, pname
);
905 _mesa_texture_parameteri(struct gl_context
*ctx
,
906 struct gl_texture_object
*texObj
,
907 GLenum pname
, GLint param
, bool dsa
)
909 GLboolean need_update
;
911 case GL_TEXTURE_MIN_LOD
:
912 case GL_TEXTURE_MAX_LOD
:
913 case GL_TEXTURE_PRIORITY
:
914 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
915 case GL_TEXTURE_LOD_BIAS
:
916 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
919 fparam
[0] = (GLfloat
) param
;
920 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
921 /* convert int param to float */
922 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparam
, dsa
);
925 case GL_TEXTURE_BORDER_COLOR
:
926 case GL_TEXTURE_SWIZZLE_RGBA
:
928 _mesa_error(ctx
, GL_INVALID_ENUM
,
929 "glTex%sParameteri(non-scalar pname)",
934 /* this will generate an error if pname is illegal */
938 iparam
[1] = iparam
[2] = iparam
[3] = 0;
939 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, iparam
, dsa
);
943 if (ctx
->Driver
.TexParameter
&& need_update
) {
944 ctx
->Driver
.TexParameter(ctx
, texObj
, pname
);
950 _mesa_texture_parameteriv(struct gl_context
*ctx
,
951 struct gl_texture_object
*texObj
,
952 GLenum pname
, const GLint
*params
, bool dsa
)
954 GLboolean need_update
;
957 case GL_TEXTURE_BORDER_COLOR
:
959 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
)) {
960 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTextureParameteriv(texture)");
963 /* convert int params to float */
965 fparams
[0] = INT_TO_FLOAT(params
[0]);
966 fparams
[1] = INT_TO_FLOAT(params
[1]);
967 fparams
[2] = INT_TO_FLOAT(params
[2]);
968 fparams
[3] = INT_TO_FLOAT(params
[3]);
969 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
, dsa
);
972 case GL_TEXTURE_MIN_LOD
:
973 case GL_TEXTURE_MAX_LOD
:
974 case GL_TEXTURE_PRIORITY
:
975 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
976 case GL_TEXTURE_LOD_BIAS
:
977 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB
:
979 /* convert int param to float */
981 fparams
[0] = (GLfloat
) params
[0];
982 fparams
[1] = fparams
[2] = fparams
[3] = 0.0F
;
983 need_update
= set_tex_parameterf(ctx
, texObj
, pname
, fparams
, dsa
);
987 /* this will generate an error if pname is illegal */
988 need_update
= set_tex_parameteri(ctx
, texObj
, pname
, params
, dsa
);
991 if (ctx
->Driver
.TexParameter
&& need_update
) {
992 ctx
->Driver
.TexParameter(ctx
, texObj
, pname
);
997 _mesa_texture_parameterIiv(struct gl_context
*ctx
,
998 struct gl_texture_object
*texObj
,
999 GLenum pname
, const GLint
*params
, bool dsa
)
1002 case GL_TEXTURE_BORDER_COLOR
:
1003 if (texObj
->HandleAllocated
) {
1004 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1005 "glTextureParameterIiv(immutable texture)");
1009 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
)) {
1010 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTextureParameterIiv(texture)");
1013 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1014 /* set the integer-valued border color */
1015 COPY_4V(texObj
->Sampler
.BorderColor
.i
, params
);
1018 _mesa_texture_parameteriv(ctx
, texObj
, pname
, params
, dsa
);
1021 /* XXX no driver hook for TexParameterIiv() yet */
1025 _mesa_texture_parameterIuiv(struct gl_context
*ctx
,
1026 struct gl_texture_object
*texObj
,
1027 GLenum pname
, const GLuint
*params
, bool dsa
)
1030 case GL_TEXTURE_BORDER_COLOR
:
1031 if (texObj
->HandleAllocated
) {
1032 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1033 "glTextureParameterIuiv(immutable texture)");
1037 if (!_mesa_target_allows_setting_sampler_parameters(texObj
->Target
)) {
1038 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTextureParameterIuiv(texture)");
1041 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
1042 /* set the unsigned integer-valued border color */
1043 COPY_4V(texObj
->Sampler
.BorderColor
.ui
, params
);
1046 _mesa_texture_parameteriv(ctx
, texObj
, pname
, (const GLint
*) params
,
1050 /* XXX no driver hook for TexParameterIuiv() yet */
1054 _mesa_TexParameterf(GLenum target
, GLenum pname
, GLfloat param
)
1056 struct gl_texture_object
*texObj
;
1057 GET_CURRENT_CONTEXT(ctx
);
1059 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1063 _mesa_texture_parameterf(ctx
, texObj
, pname
, param
, false);
1067 _mesa_TexParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
1069 struct gl_texture_object
*texObj
;
1070 GET_CURRENT_CONTEXT(ctx
);
1072 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1076 _mesa_texture_parameterfv(ctx
, texObj
, pname
, params
, false);
1080 _mesa_TexParameteri(GLenum target
, GLenum pname
, GLint param
)
1082 struct gl_texture_object
*texObj
;
1083 GET_CURRENT_CONTEXT(ctx
);
1085 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1089 _mesa_texture_parameteri(ctx
, texObj
, pname
, param
, false);
1093 _mesa_TexParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
1095 struct gl_texture_object
*texObj
;
1096 GET_CURRENT_CONTEXT(ctx
);
1098 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1102 _mesa_texture_parameteriv(ctx
, texObj
, pname
, params
, false);
1106 * Set tex parameter to integer value(s). Primarily intended to set
1107 * integer-valued texture border color (for integer-valued textures).
1111 _mesa_TexParameterIiv(GLenum target
, GLenum pname
, const GLint
*params
)
1113 struct gl_texture_object
*texObj
;
1114 GET_CURRENT_CONTEXT(ctx
);
1116 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1120 _mesa_texture_parameterIiv(ctx
, texObj
, pname
, params
, false);
1124 * Set tex parameter to unsigned integer value(s). Primarily intended to set
1125 * uint-valued texture border color (for integer-valued textures).
1129 _mesa_TexParameterIuiv(GLenum target
, GLenum pname
, const GLuint
*params
)
1131 struct gl_texture_object
*texObj
;
1132 GET_CURRENT_CONTEXT(ctx
);
1134 texObj
= get_texobj_by_target(ctx
, target
, GL_FALSE
);
1138 _mesa_texture_parameterIuiv(ctx
, texObj
, pname
, params
, false);
1143 _mesa_TextureParameterfv(GLuint texture
, GLenum pname
, const GLfloat
*params
)
1145 struct gl_texture_object
*texObj
;
1146 GET_CURRENT_CONTEXT(ctx
);
1148 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameterfv");
1152 _mesa_texture_parameterfv(ctx
, texObj
, pname
, params
, true);
1156 _mesa_TextureParameterf(GLuint texture
, GLenum pname
, GLfloat param
)
1158 struct gl_texture_object
*texObj
;
1159 GET_CURRENT_CONTEXT(ctx
);
1161 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameterf");
1165 _mesa_texture_parameterf(ctx
, texObj
, pname
, param
, true);
1169 _mesa_TextureParameteri(GLuint texture
, GLenum pname
, GLint param
)
1171 struct gl_texture_object
*texObj
;
1172 GET_CURRENT_CONTEXT(ctx
);
1174 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameteri");
1178 _mesa_texture_parameteri(ctx
, texObj
, pname
, param
, true);
1182 _mesa_TextureParameteriv(GLuint texture
, GLenum pname
,
1183 const GLint
*params
)
1185 struct gl_texture_object
*texObj
;
1186 GET_CURRENT_CONTEXT(ctx
);
1188 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameteriv");
1192 _mesa_texture_parameteriv(ctx
, texObj
, pname
, params
, true);
1197 _mesa_TextureParameterIiv(GLuint texture
, GLenum pname
, const GLint
*params
)
1199 struct gl_texture_object
*texObj
;
1200 GET_CURRENT_CONTEXT(ctx
);
1202 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameterIiv");
1206 _mesa_texture_parameterIiv(ctx
, texObj
, pname
, params
, true);
1210 _mesa_TextureParameterIuiv(GLuint texture
, GLenum pname
, const GLuint
*params
)
1212 struct gl_texture_object
*texObj
;
1213 GET_CURRENT_CONTEXT(ctx
);
1215 texObj
= get_texobj_by_name(ctx
, texture
, "glTextureParameterIuiv");
1219 _mesa_texture_parameterIuiv(ctx
, texObj
, pname
, params
, true);
1223 _mesa_legal_get_tex_level_parameter_target(struct gl_context
*ctx
, GLenum target
,
1226 /* Common targets for desktop GL and GLES 3.1. */
1231 case GL_TEXTURE_2D_ARRAY_EXT
:
1232 return ctx
->Extensions
.EXT_texture_array
;
1233 case GL_TEXTURE_CUBE_MAP_POSITIVE_X
:
1234 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X
:
1235 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y
:
1236 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
:
1237 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z
:
1238 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
:
1239 return ctx
->Extensions
.ARB_texture_cube_map
;
1240 case GL_TEXTURE_2D_MULTISAMPLE
:
1241 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
1242 return ctx
->Extensions
.ARB_texture_multisample
;
1243 case GL_TEXTURE_BUFFER
:
1244 /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
1245 * but not in earlier versions that expose ARB_texture_buffer_object.
1247 * From the ARB_texture_buffer_object spec:
1248 * "(7) Do buffer textures support texture parameters (TexParameter) or
1249 * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
1251 * RESOLVED: No. [...] Note that the spec edits above don't add
1252 * explicit error language for any of these cases. That is because
1253 * each of the functions enumerate the set of valid <target>
1254 * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
1255 * these cases means that target is not legal, and an INVALID_ENUM
1256 * error should be generated."
1258 * From the OpenGL 3.1 spec:
1259 * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
1261 return (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 31) ||
1262 _mesa_has_OES_texture_buffer(ctx
);
1263 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1264 return _mesa_has_texture_cube_map_array(ctx
);
1267 if (!_mesa_is_desktop_gl(ctx
))
1270 /* Rest of the desktop GL targets. */
1273 case GL_PROXY_TEXTURE_1D
:
1274 case GL_PROXY_TEXTURE_2D
:
1275 case GL_PROXY_TEXTURE_3D
:
1277 case GL_PROXY_TEXTURE_CUBE_MAP
:
1278 return ctx
->Extensions
.ARB_texture_cube_map
;
1279 case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY
:
1280 return ctx
->Extensions
.ARB_texture_cube_map_array
;
1281 case GL_TEXTURE_RECTANGLE_NV
:
1282 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1283 return ctx
->Extensions
.NV_texture_rectangle
;
1284 case GL_TEXTURE_1D_ARRAY_EXT
:
1285 case GL_PROXY_TEXTURE_1D_ARRAY_EXT
:
1286 case GL_PROXY_TEXTURE_2D_ARRAY_EXT
:
1287 return ctx
->Extensions
.EXT_texture_array
;
1288 case GL_PROXY_TEXTURE_2D_MULTISAMPLE
:
1289 case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY
:
1290 return ctx
->Extensions
.ARB_texture_multisample
;
1292 /* This is a valid target for dsa, but the OpenGL 4.5 core spec
1293 * (30.10.2014) Section 8.11 Texture Queries says:
1294 * "For GetTextureLevelParameter* only, texture may also be a cube
1295 * map texture object. In this case the query is always performed
1296 * for face zero (the TEXTURE_CUBE_MAP_POSITIVE_X face), since there
1297 * is no way to specify another face."
1299 case GL_TEXTURE_CUBE_MAP
:
1308 get_tex_level_parameter_image(struct gl_context
*ctx
,
1309 const struct gl_texture_object
*texObj
,
1310 GLenum target
, GLint level
,
1311 GLenum pname
, GLint
*params
,
1314 const struct gl_texture_image
*img
= NULL
;
1315 struct gl_texture_image dummy_image
;
1316 mesa_format texFormat
;
1317 const char *suffix
= dsa
? "ture" : "";
1319 img
= _mesa_select_tex_image(texObj
, target
, level
);
1320 if (!img
|| img
->TexFormat
== MESA_FORMAT_NONE
) {
1321 /* In case of undefined texture image return the default values.
1323 * From OpenGL 4.0 spec, page 398:
1324 * "The initial internal format of a texel array is RGBA
1325 * instead of 1. TEXTURE_COMPONENTS is deprecated; always
1326 * use TEXTURE_INTERNAL_FORMAT."
1328 memset(&dummy_image
, 0, sizeof(dummy_image
));
1329 dummy_image
.TexFormat
= MESA_FORMAT_NONE
;
1330 dummy_image
.InternalFormat
= GL_RGBA
;
1331 dummy_image
._BaseFormat
= GL_NONE
;
1332 dummy_image
.FixedSampleLocations
= GL_TRUE
;
1337 texFormat
= img
->TexFormat
;
1340 case GL_TEXTURE_WIDTH
:
1341 *params
= img
->Width
;
1343 case GL_TEXTURE_HEIGHT
:
1344 *params
= img
->Height
;
1346 case GL_TEXTURE_DEPTH
:
1347 *params
= img
->Depth
;
1349 case GL_TEXTURE_INTERNAL_FORMAT
:
1350 if (_mesa_is_format_compressed(texFormat
)) {
1351 /* need to return the actual compressed format */
1352 *params
= _mesa_compressed_format_to_glenum(ctx
, texFormat
);
1355 /* If the true internal format is not compressed but the user
1356 * requested a generic compressed format, we have to return the
1357 * generic base format that matches.
1359 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
1361 * "If no specific compressed format is available,
1362 * internalformat is instead replaced by the corresponding base
1365 * Otherwise just return the user's requested internal format
1368 _mesa_gl_compressed_format_base_format(img
->InternalFormat
);
1370 *params
= (f
!= 0) ? f
: img
->InternalFormat
;
1373 case GL_TEXTURE_BORDER
:
1374 if (ctx
->API
!= API_OPENGL_COMPAT
)
1376 *params
= img
->Border
;
1378 case GL_TEXTURE_RED_SIZE
:
1379 case GL_TEXTURE_GREEN_SIZE
:
1380 case GL_TEXTURE_BLUE_SIZE
:
1381 case GL_TEXTURE_ALPHA_SIZE
:
1382 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
1383 *params
= _mesa_get_format_bits(texFormat
, pname
);
1387 case GL_TEXTURE_INTENSITY_SIZE
:
1388 case GL_TEXTURE_LUMINANCE_SIZE
:
1389 if (ctx
->API
!= API_OPENGL_COMPAT
)
1391 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
)) {
1392 *params
= _mesa_get_format_bits(texFormat
, pname
);
1394 /* intensity or luminance is probably stored as RGB[A] */
1395 *params
= MIN2(_mesa_get_format_bits(texFormat
,
1396 GL_TEXTURE_RED_SIZE
),
1397 _mesa_get_format_bits(texFormat
,
1398 GL_TEXTURE_GREEN_SIZE
));
1405 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1406 if (!ctx
->Extensions
.ARB_depth_texture
)
1408 *params
= _mesa_get_format_bits(texFormat
, pname
);
1410 case GL_TEXTURE_STENCIL_SIZE
:
1411 *params
= _mesa_get_format_bits(texFormat
, pname
);
1413 case GL_TEXTURE_SHARED_SIZE
:
1414 if (ctx
->Version
< 30 &&
1415 !ctx
->Extensions
.EXT_texture_shared_exponent
)
1417 *params
= texFormat
== MESA_FORMAT_R9G9B9E5_FLOAT
? 5 : 0;
1420 /* GL_ARB_texture_compression */
1421 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1422 if (_mesa_is_format_compressed(texFormat
) &&
1423 !_mesa_is_proxy_texture(target
)) {
1424 *params
= _mesa_format_image_size(texFormat
, img
->Width
,
1425 img
->Height
, img
->Depth
);
1427 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1428 "glGetTex%sLevelParameter[if]v(pname=%s)", suffix
,
1429 _mesa_enum_to_string(pname
));
1432 case GL_TEXTURE_COMPRESSED
:
1433 *params
= (GLint
) _mesa_is_format_compressed(texFormat
);
1436 /* GL_ARB_texture_float */
1437 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1438 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1439 if (ctx
->API
!= API_OPENGL_COMPAT
)
1442 case GL_TEXTURE_RED_TYPE_ARB
:
1443 case GL_TEXTURE_GREEN_TYPE_ARB
:
1444 case GL_TEXTURE_BLUE_TYPE_ARB
:
1445 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1446 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1447 if (!ctx
->Extensions
.ARB_texture_float
)
1449 if (_mesa_base_format_has_channel(img
->_BaseFormat
, pname
))
1450 *params
= _mesa_get_format_datatype(texFormat
);
1455 /* GL_ARB_texture_multisample */
1456 case GL_TEXTURE_SAMPLES
:
1457 if (!ctx
->Extensions
.ARB_texture_multisample
)
1459 *params
= img
->NumSamples
;
1462 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS
:
1463 if (!ctx
->Extensions
.ARB_texture_multisample
)
1465 *params
= img
->FixedSampleLocations
;
1468 /* There is never a buffer data store here, but these pnames still have
1472 /* GL_ARB_texture_buffer_object */
1473 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING
:
1474 if (!ctx
->Extensions
.ARB_texture_buffer_object
)
1479 /* GL_ARB_texture_buffer_range */
1480 case GL_TEXTURE_BUFFER_OFFSET
:
1481 if (!ctx
->Extensions
.ARB_texture_buffer_range
)
1485 case GL_TEXTURE_BUFFER_SIZE
:
1486 if (!ctx
->Extensions
.ARB_texture_buffer_range
)
1495 /* no error if we get here */
1499 _mesa_error(ctx
, GL_INVALID_ENUM
,
1500 "glGetTex%sLevelParameter[if]v(pname=%s)", suffix
,
1501 _mesa_enum_to_string(pname
));
1506 * Handle a glGetTexLevelParamteriv() call for a texture buffer.
1509 get_tex_level_parameter_buffer(struct gl_context
*ctx
,
1510 const struct gl_texture_object
*texObj
,
1511 GLenum pname
, GLint
*params
, bool dsa
)
1513 const struct gl_buffer_object
*bo
= texObj
->BufferObject
;
1514 mesa_format texFormat
= texObj
->_BufferObjectFormat
;
1515 int bytes
= MAX2(1, _mesa_get_format_bytes(texFormat
));
1516 GLenum internalFormat
= texObj
->BufferObjectFormat
;
1517 GLenum baseFormat
= _mesa_get_format_base_format(texFormat
);
1518 const char *suffix
= dsa
? "ture" : "";
1520 assert(texObj
->Target
== GL_TEXTURE_BUFFER
);
1523 /* undefined texture buffer object */
1525 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS
:
1528 case GL_TEXTURE_INTERNAL_FORMAT
:
1529 *params
= internalFormat
;
1539 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING
:
1542 case GL_TEXTURE_WIDTH
:
1543 *params
= ((texObj
->BufferSize
== -1) ? bo
->Size
: texObj
->BufferSize
)
1546 case GL_TEXTURE_HEIGHT
:
1547 case GL_TEXTURE_DEPTH
:
1550 case GL_TEXTURE_BORDER
:
1551 case GL_TEXTURE_SHARED_SIZE
:
1552 case GL_TEXTURE_COMPRESSED
:
1555 case GL_TEXTURE_INTERNAL_FORMAT
:
1556 *params
= internalFormat
;
1558 case GL_TEXTURE_RED_SIZE
:
1559 case GL_TEXTURE_GREEN_SIZE
:
1560 case GL_TEXTURE_BLUE_SIZE
:
1561 case GL_TEXTURE_ALPHA_SIZE
:
1562 if (_mesa_base_format_has_channel(baseFormat
, pname
))
1563 *params
= _mesa_get_format_bits(texFormat
, pname
);
1567 case GL_TEXTURE_INTENSITY_SIZE
:
1568 case GL_TEXTURE_LUMINANCE_SIZE
:
1569 if (_mesa_base_format_has_channel(baseFormat
, pname
)) {
1570 *params
= _mesa_get_format_bits(texFormat
, pname
);
1572 /* intensity or luminance is probably stored as RGB[A] */
1573 *params
= MIN2(_mesa_get_format_bits(texFormat
,
1574 GL_TEXTURE_RED_SIZE
),
1575 _mesa_get_format_bits(texFormat
,
1576 GL_TEXTURE_GREEN_SIZE
));
1582 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1583 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1584 *params
= _mesa_get_format_bits(texFormat
, pname
);
1587 /* GL_ARB_texture_buffer_range */
1588 case GL_TEXTURE_BUFFER_OFFSET
:
1589 if (!ctx
->Extensions
.ARB_texture_buffer_range
)
1591 *params
= texObj
->BufferOffset
;
1593 case GL_TEXTURE_BUFFER_SIZE
:
1594 if (!ctx
->Extensions
.ARB_texture_buffer_range
)
1596 *params
= (texObj
->BufferSize
== -1) ? bo
->Size
: texObj
->BufferSize
;
1599 /* GL_ARB_texture_multisample */
1600 case GL_TEXTURE_SAMPLES
:
1601 if (!ctx
->Extensions
.ARB_texture_multisample
)
1606 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS
:
1607 if (!ctx
->Extensions
.ARB_texture_multisample
)
1612 /* GL_ARB_texture_compression */
1613 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1614 /* Always illegal for GL_TEXTURE_BUFFER */
1615 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1616 "glGetTex%sLevelParameter[if]v(pname=%s)", suffix
,
1617 _mesa_enum_to_string(pname
));
1620 /* GL_ARB_texture_float */
1621 case GL_TEXTURE_RED_TYPE_ARB
:
1622 case GL_TEXTURE_GREEN_TYPE_ARB
:
1623 case GL_TEXTURE_BLUE_TYPE_ARB
:
1624 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1625 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1626 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1627 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1628 if (!ctx
->Extensions
.ARB_texture_float
)
1630 if (_mesa_base_format_has_channel(baseFormat
, pname
))
1631 *params
= _mesa_get_format_datatype(texFormat
);
1640 /* no error if we get here */
1644 _mesa_error(ctx
, GL_INVALID_ENUM
,
1645 "glGetTex%sLevelParameter[if]v(pname=%s)", suffix
,
1646 _mesa_enum_to_string(pname
));
1650 valid_tex_level_parameteriv_target(struct gl_context
*ctx
, GLenum target
,
1653 const char *suffix
= dsa
? "ture" : "";
1654 if (!_mesa_legal_get_tex_level_parameter_target(ctx
, target
, dsa
)) {
1655 _mesa_error(ctx
, GL_INVALID_ENUM
,
1656 "glGetTex%sLevelParameter[if]v(target=%s)", suffix
,
1657 _mesa_enum_to_string(target
));
1664 * This isn't exposed to the rest of the driver because it is a part of the
1665 * OpenGL API that is rarely used.
1668 get_tex_level_parameteriv(struct gl_context
*ctx
,
1669 struct gl_texture_object
*texObj
,
1670 GLenum target
, GLint level
,
1671 GLenum pname
, GLint
*params
,
1675 const char *suffix
= dsa
? "ture" : "";
1677 /* Check for errors */
1678 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
1679 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1680 "glGetTex%sLevelParameter[if]v("
1681 "current unit >= max combined texture units)", suffix
);
1685 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
1686 assert(maxLevels
!= 0);
1688 if (level
< 0 || level
>= maxLevels
) {
1689 _mesa_error(ctx
, GL_INVALID_VALUE
,
1690 "glGetTex%sLevelParameter[if]v(level out of range)", suffix
);
1694 /* Get the level parameter */
1695 if (target
== GL_TEXTURE_BUFFER
) {
1696 get_tex_level_parameter_buffer(ctx
, texObj
, pname
, params
, dsa
);
1699 get_tex_level_parameter_image(ctx
, texObj
, target
,
1700 level
, pname
, params
, dsa
);
1705 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1706 GLenum pname
, GLfloat
*params
)
1708 struct gl_texture_object
*texObj
;
1710 GET_CURRENT_CONTEXT(ctx
);
1712 if (!valid_tex_level_parameteriv_target(ctx
, target
, false))
1715 texObj
= _mesa_get_current_tex_object(ctx
, target
);
1719 get_tex_level_parameteriv(ctx
, texObj
, target
, level
,
1720 pname
, &iparam
, false);
1722 *params
= (GLfloat
) iparam
;
1726 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1727 GLenum pname
, GLint
*params
)
1729 struct gl_texture_object
*texObj
;
1730 GET_CURRENT_CONTEXT(ctx
);
1732 if (!valid_tex_level_parameteriv_target(ctx
, target
, false))
1735 texObj
= _mesa_get_current_tex_object(ctx
, target
);
1739 get_tex_level_parameteriv(ctx
, texObj
, target
, level
,
1740 pname
, params
, false);
1744 _mesa_GetTextureLevelParameterfv(GLuint texture
, GLint level
,
1745 GLenum pname
, GLfloat
*params
)
1747 struct gl_texture_object
*texObj
;
1749 GET_CURRENT_CONTEXT(ctx
);
1751 texObj
= _mesa_lookup_texture_err(ctx
, texture
,
1752 "glGetTextureLevelParameterfv");
1756 if (!valid_tex_level_parameteriv_target(ctx
, texObj
->Target
, true))
1759 get_tex_level_parameteriv(ctx
, texObj
, texObj
->Target
, level
,
1760 pname
, &iparam
, true);
1762 *params
= (GLfloat
) iparam
;
1766 _mesa_GetTextureLevelParameteriv(GLuint texture
, GLint level
,
1767 GLenum pname
, GLint
*params
)
1769 struct gl_texture_object
*texObj
;
1770 GET_CURRENT_CONTEXT(ctx
);
1772 texObj
= _mesa_lookup_texture_err(ctx
, texture
,
1773 "glGetTextureLevelParameteriv");
1777 if (!valid_tex_level_parameteriv_target(ctx
, texObj
->Target
, true))
1780 get_tex_level_parameteriv(ctx
, texObj
, texObj
->Target
, level
,
1781 pname
, params
, true);
1785 * This isn't exposed to the rest of the driver because it is a part of the
1786 * OpenGL API that is rarely used.
1789 get_tex_parameterfv(struct gl_context
*ctx
,
1790 struct gl_texture_object
*obj
,
1791 GLenum pname
, GLfloat
*params
, bool dsa
)
1793 _mesa_lock_context_textures(ctx
);
1795 case GL_TEXTURE_MAG_FILTER
:
1796 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MagFilter
);
1798 case GL_TEXTURE_MIN_FILTER
:
1799 *params
= ENUM_TO_FLOAT(obj
->Sampler
.MinFilter
);
1801 case GL_TEXTURE_WRAP_S
:
1802 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapS
);
1804 case GL_TEXTURE_WRAP_T
:
1805 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapT
);
1807 case GL_TEXTURE_WRAP_R
:
1808 *params
= ENUM_TO_FLOAT(obj
->Sampler
.WrapR
);
1810 case GL_TEXTURE_BORDER_COLOR
:
1811 if (ctx
->API
== API_OPENGLES
||
1812 !ctx
->Extensions
.ARB_texture_border_clamp
)
1815 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1816 _mesa_update_state_locked(ctx
);
1817 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1818 params
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
1819 params
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
1820 params
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
1821 params
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
1824 params
[0] = obj
->Sampler
.BorderColor
.f
[0];
1825 params
[1] = obj
->Sampler
.BorderColor
.f
[1];
1826 params
[2] = obj
->Sampler
.BorderColor
.f
[2];
1827 params
[3] = obj
->Sampler
.BorderColor
.f
[3];
1830 case GL_TEXTURE_RESIDENT
:
1831 if (ctx
->API
!= API_OPENGL_COMPAT
)
1836 case GL_TEXTURE_PRIORITY
:
1837 if (ctx
->API
!= API_OPENGL_COMPAT
)
1840 *params
= obj
->Priority
;
1842 case GL_TEXTURE_MIN_LOD
:
1843 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1846 *params
= obj
->Sampler
.MinLod
;
1848 case GL_TEXTURE_MAX_LOD
:
1849 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1852 *params
= obj
->Sampler
.MaxLod
;
1854 case GL_TEXTURE_BASE_LEVEL
:
1855 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1858 *params
= (GLfloat
) obj
->BaseLevel
;
1860 case GL_TEXTURE_MAX_LEVEL
:
1861 *params
= (GLfloat
) obj
->MaxLevel
;
1863 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1864 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
1866 *params
= obj
->Sampler
.MaxAnisotropy
;
1868 case GL_GENERATE_MIPMAP_SGIS
:
1869 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1872 *params
= (GLfloat
) obj
->GenerateMipmap
;
1874 case GL_TEXTURE_COMPARE_MODE_ARB
:
1875 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_shadow
)
1876 && !_mesa_is_gles3(ctx
))
1878 *params
= (GLfloat
) obj
->Sampler
.CompareMode
;
1880 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1881 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_shadow
)
1882 && !_mesa_is_gles3(ctx
))
1884 *params
= (GLfloat
) obj
->Sampler
.CompareFunc
;
1886 case GL_DEPTH_TEXTURE_MODE_ARB
:
1887 /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has
1888 * never existed in OpenGL ES.
1890 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.ARB_depth_texture
)
1892 *params
= (GLfloat
) obj
->DepthMode
;
1894 case GL_DEPTH_STENCIL_TEXTURE_MODE
:
1895 if (!_mesa_has_ARB_stencil_texturing(ctx
) && !_mesa_is_gles31(ctx
))
1898 (obj
->StencilSampling
? GL_STENCIL_INDEX
: GL_DEPTH_COMPONENT
);
1900 case GL_TEXTURE_LOD_BIAS
:
1901 if (_mesa_is_gles(ctx
))
1904 *params
= obj
->Sampler
.LodBias
;
1906 case GL_TEXTURE_CROP_RECT_OES
:
1907 if (ctx
->API
!= API_OPENGLES
|| !ctx
->Extensions
.OES_draw_texture
)
1910 params
[0] = (GLfloat
) obj
->CropRect
[0];
1911 params
[1] = (GLfloat
) obj
->CropRect
[1];
1912 params
[2] = (GLfloat
) obj
->CropRect
[2];
1913 params
[3] = (GLfloat
) obj
->CropRect
[3];
1916 case GL_TEXTURE_SWIZZLE_R_EXT
:
1917 case GL_TEXTURE_SWIZZLE_G_EXT
:
1918 case GL_TEXTURE_SWIZZLE_B_EXT
:
1919 case GL_TEXTURE_SWIZZLE_A_EXT
:
1920 if ((!_mesa_is_desktop_gl(ctx
)
1921 || !ctx
->Extensions
.EXT_texture_swizzle
)
1922 && !_mesa_is_gles3(ctx
))
1924 *params
= (GLfloat
) obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
1927 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
1928 if ((!_mesa_is_desktop_gl(ctx
)
1929 || !ctx
->Extensions
.EXT_texture_swizzle
)
1930 && !_mesa_is_gles3(ctx
)) {
1935 for (comp
= 0; comp
< 4; comp
++) {
1936 params
[comp
] = (GLfloat
) obj
->Swizzle
[comp
];
1941 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1942 if (!_mesa_is_desktop_gl(ctx
)
1943 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1945 *params
= (GLfloat
) obj
->Sampler
.CubeMapSeamless
;
1948 case GL_TEXTURE_IMMUTABLE_FORMAT
:
1949 *params
= (GLfloat
) obj
->Immutable
;
1952 case GL_TEXTURE_IMMUTABLE_LEVELS
:
1953 if (_mesa_is_gles3(ctx
) ||
1954 (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_view
))
1955 *params
= (GLfloat
) obj
->ImmutableLevels
;
1960 case GL_TEXTURE_VIEW_MIN_LEVEL
:
1961 if (!ctx
->Extensions
.ARB_texture_view
)
1963 *params
= (GLfloat
) obj
->MinLevel
;
1966 case GL_TEXTURE_VIEW_NUM_LEVELS
:
1967 if (!ctx
->Extensions
.ARB_texture_view
)
1969 *params
= (GLfloat
) obj
->NumLevels
;
1972 case GL_TEXTURE_VIEW_MIN_LAYER
:
1973 if (!ctx
->Extensions
.ARB_texture_view
)
1975 *params
= (GLfloat
) obj
->MinLayer
;
1978 case GL_TEXTURE_VIEW_NUM_LAYERS
:
1979 if (!ctx
->Extensions
.ARB_texture_view
)
1981 *params
= (GLfloat
) obj
->NumLayers
;
1984 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
:
1985 if (!_mesa_is_gles(ctx
) || !ctx
->Extensions
.OES_EGL_image_external
)
1987 *params
= (GLfloat
) obj
->RequiredTextureImageUnits
;
1990 case GL_TEXTURE_SRGB_DECODE_EXT
:
1991 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1993 *params
= (GLfloat
) obj
->Sampler
.sRGBDecode
;
1996 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
1997 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1999 *params
= (GLfloat
) obj
->ImageFormatCompatibilityType
;
2002 case GL_TEXTURE_TARGET
:
2003 if (ctx
->API
!= API_OPENGL_CORE
)
2005 *params
= ENUM_TO_FLOAT(obj
->Target
);
2012 /* no error if we get here */
2013 _mesa_unlock_context_textures(ctx
);
2017 _mesa_unlock_context_textures(ctx
);
2018 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTex%sParameterfv(pname=0x%x)",
2019 dsa
? "ture" : "", pname
);
2024 get_tex_parameteriv(struct gl_context
*ctx
,
2025 struct gl_texture_object
*obj
,
2026 GLenum pname
, GLint
*params
, bool dsa
)
2028 _mesa_lock_texture(ctx
, obj
);
2030 case GL_TEXTURE_MAG_FILTER
:
2031 *params
= (GLint
) obj
->Sampler
.MagFilter
;
2033 case GL_TEXTURE_MIN_FILTER
:
2034 *params
= (GLint
) obj
->Sampler
.MinFilter
;
2036 case GL_TEXTURE_WRAP_S
:
2037 *params
= (GLint
) obj
->Sampler
.WrapS
;
2039 case GL_TEXTURE_WRAP_T
:
2040 *params
= (GLint
) obj
->Sampler
.WrapT
;
2042 case GL_TEXTURE_WRAP_R
:
2043 *params
= (GLint
) obj
->Sampler
.WrapR
;
2045 case GL_TEXTURE_BORDER_COLOR
:
2046 if (ctx
->API
== API_OPENGLES
||
2047 !ctx
->Extensions
.ARB_texture_border_clamp
)
2052 b
[0] = CLAMP(obj
->Sampler
.BorderColor
.f
[0], 0.0F
, 1.0F
);
2053 b
[1] = CLAMP(obj
->Sampler
.BorderColor
.f
[1], 0.0F
, 1.0F
);
2054 b
[2] = CLAMP(obj
->Sampler
.BorderColor
.f
[2], 0.0F
, 1.0F
);
2055 b
[3] = CLAMP(obj
->Sampler
.BorderColor
.f
[3], 0.0F
, 1.0F
);
2056 params
[0] = FLOAT_TO_INT(b
[0]);
2057 params
[1] = FLOAT_TO_INT(b
[1]);
2058 params
[2] = FLOAT_TO_INT(b
[2]);
2059 params
[3] = FLOAT_TO_INT(b
[3]);
2062 case GL_TEXTURE_RESIDENT
:
2063 if (ctx
->API
!= API_OPENGL_COMPAT
)
2068 case GL_TEXTURE_PRIORITY
:
2069 if (ctx
->API
!= API_OPENGL_COMPAT
)
2072 *params
= FLOAT_TO_INT(obj
->Priority
);
2074 case GL_TEXTURE_MIN_LOD
:
2075 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
2077 /* GL spec 'Data Conversions' section specifies that floating-point
2078 * value in integer Get function is rounded to nearest integer
2080 *params
= IROUND(obj
->Sampler
.MinLod
);
2082 case GL_TEXTURE_MAX_LOD
:
2083 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
2085 /* GL spec 'Data Conversions' section specifies that floating-point
2086 * value in integer Get function is rounded to nearest integer
2088 *params
= IROUND(obj
->Sampler
.MaxLod
);
2090 case GL_TEXTURE_BASE_LEVEL
:
2091 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
2094 *params
= obj
->BaseLevel
;
2096 case GL_TEXTURE_MAX_LEVEL
:
2097 *params
= obj
->MaxLevel
;
2099 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
2100 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
2102 /* GL spec 'Data Conversions' section specifies that floating-point
2103 * value in integer Get function is rounded to nearest integer
2105 *params
= IROUND(obj
->Sampler
.MaxAnisotropy
);
2107 case GL_GENERATE_MIPMAP_SGIS
:
2108 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
2111 *params
= (GLint
) obj
->GenerateMipmap
;
2113 case GL_TEXTURE_COMPARE_MODE_ARB
:
2114 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_shadow
)
2115 && !_mesa_is_gles3(ctx
))
2117 *params
= (GLint
) obj
->Sampler
.CompareMode
;
2119 case GL_TEXTURE_COMPARE_FUNC_ARB
:
2120 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_shadow
)
2121 && !_mesa_is_gles3(ctx
))
2123 *params
= (GLint
) obj
->Sampler
.CompareFunc
;
2125 case GL_DEPTH_TEXTURE_MODE_ARB
:
2126 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.ARB_depth_texture
)
2128 *params
= (GLint
) obj
->DepthMode
;
2130 case GL_DEPTH_STENCIL_TEXTURE_MODE
:
2131 if (!_mesa_has_ARB_stencil_texturing(ctx
) && !_mesa_is_gles31(ctx
))
2134 (obj
->StencilSampling
? GL_STENCIL_INDEX
: GL_DEPTH_COMPONENT
);
2136 case GL_TEXTURE_LOD_BIAS
:
2137 if (_mesa_is_gles(ctx
))
2140 /* GL spec 'Data Conversions' section specifies that floating-point
2141 * value in integer Get function is rounded to nearest integer
2143 *params
= IROUND(obj
->Sampler
.LodBias
);
2145 case GL_TEXTURE_CROP_RECT_OES
:
2146 if (ctx
->API
!= API_OPENGLES
|| !ctx
->Extensions
.OES_draw_texture
)
2149 params
[0] = obj
->CropRect
[0];
2150 params
[1] = obj
->CropRect
[1];
2151 params
[2] = obj
->CropRect
[2];
2152 params
[3] = obj
->CropRect
[3];
2154 case GL_TEXTURE_SWIZZLE_R_EXT
:
2155 case GL_TEXTURE_SWIZZLE_G_EXT
:
2156 case GL_TEXTURE_SWIZZLE_B_EXT
:
2157 case GL_TEXTURE_SWIZZLE_A_EXT
:
2158 if ((!_mesa_is_desktop_gl(ctx
)
2159 || !ctx
->Extensions
.EXT_texture_swizzle
)
2160 && !_mesa_is_gles3(ctx
))
2162 *params
= obj
->Swizzle
[pname
- GL_TEXTURE_SWIZZLE_R_EXT
];
2165 case GL_TEXTURE_SWIZZLE_RGBA_EXT
:
2166 if ((!_mesa_is_desktop_gl(ctx
)
2167 || !ctx
->Extensions
.EXT_texture_swizzle
)
2168 && !_mesa_is_gles3(ctx
))
2170 COPY_4V(params
, obj
->Swizzle
);
2173 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
2174 if (!_mesa_is_desktop_gl(ctx
)
2175 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
2177 *params
= (GLint
) obj
->Sampler
.CubeMapSeamless
;
2180 case GL_TEXTURE_IMMUTABLE_FORMAT
:
2181 *params
= (GLint
) obj
->Immutable
;
2184 case GL_TEXTURE_IMMUTABLE_LEVELS
:
2185 if (_mesa_is_gles3(ctx
) ||
2186 (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_view
))
2187 *params
= obj
->ImmutableLevels
;
2192 case GL_TEXTURE_VIEW_MIN_LEVEL
:
2193 if (!ctx
->Extensions
.ARB_texture_view
)
2195 *params
= (GLint
) obj
->MinLevel
;
2198 case GL_TEXTURE_VIEW_NUM_LEVELS
:
2199 if (!ctx
->Extensions
.ARB_texture_view
)
2201 *params
= (GLint
) obj
->NumLevels
;
2204 case GL_TEXTURE_VIEW_MIN_LAYER
:
2205 if (!ctx
->Extensions
.ARB_texture_view
)
2207 *params
= (GLint
) obj
->MinLayer
;
2210 case GL_TEXTURE_VIEW_NUM_LAYERS
:
2211 if (!ctx
->Extensions
.ARB_texture_view
)
2213 *params
= (GLint
) obj
->NumLayers
;
2216 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
:
2217 if (!_mesa_is_gles(ctx
) || !ctx
->Extensions
.OES_EGL_image_external
)
2219 *params
= obj
->RequiredTextureImageUnits
;
2222 case GL_TEXTURE_SRGB_DECODE_EXT
:
2223 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
2225 *params
= obj
->Sampler
.sRGBDecode
;
2228 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
2229 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2231 *params
= obj
->ImageFormatCompatibilityType
;
2234 case GL_TEXTURE_TARGET
:
2235 if (ctx
->API
!= API_OPENGL_CORE
)
2237 *params
= (GLint
) obj
->Target
;
2244 /* no error if we get here */
2245 _mesa_unlock_texture(ctx
, obj
);
2249 _mesa_unlock_texture(ctx
, obj
);
2250 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTex%sParameteriv(pname=0x%x)",
2251 dsa
? "ture" : "", pname
);
2255 get_tex_parameterIiv(struct gl_context
*ctx
,
2256 struct gl_texture_object
*obj
,
2257 GLenum pname
, GLint
*params
, bool dsa
)
2260 case GL_TEXTURE_BORDER_COLOR
:
2261 COPY_4V(params
, obj
->Sampler
.BorderColor
.i
);
2264 get_tex_parameteriv(ctx
, obj
, pname
, params
, dsa
);
2269 get_tex_parameterIuiv(struct gl_context
*ctx
,
2270 struct gl_texture_object
*obj
,
2271 GLenum pname
, GLuint
*params
, bool dsa
)
2274 case GL_TEXTURE_BORDER_COLOR
:
2275 COPY_4V(params
, obj
->Sampler
.BorderColor
.i
);
2280 get_tex_parameteriv(ctx
, obj
, pname
, ip
, dsa
);
2282 if (pname
== GL_TEXTURE_SWIZZLE_RGBA_EXT
||
2283 pname
== GL_TEXTURE_CROP_RECT_OES
) {
2293 _mesa_GetTexParameterfv(GLenum target
, GLenum pname
, GLfloat
*params
)
2295 struct gl_texture_object
*obj
;
2296 GET_CURRENT_CONTEXT(ctx
);
2298 obj
= get_texobj_by_target(ctx
, target
, GL_TRUE
);
2302 get_tex_parameterfv(ctx
, obj
, pname
, params
, false);
2306 _mesa_GetTexParameteriv(GLenum target
, GLenum pname
, GLint
*params
)
2308 struct gl_texture_object
*obj
;
2309 GET_CURRENT_CONTEXT(ctx
);
2311 obj
= get_texobj_by_target(ctx
, target
, GL_TRUE
);
2315 get_tex_parameteriv(ctx
, obj
, pname
, params
, false);
2318 /** New in GL 3.0 */
2320 _mesa_GetTexParameterIiv(GLenum target
, GLenum pname
, GLint
*params
)
2322 struct gl_texture_object
*texObj
;
2323 GET_CURRENT_CONTEXT(ctx
);
2325 texObj
= get_texobj_by_target(ctx
, target
, GL_TRUE
);
2329 get_tex_parameterIiv(ctx
, texObj
, pname
, params
, false);
2333 /** New in GL 3.0 */
2335 _mesa_GetTexParameterIuiv(GLenum target
, GLenum pname
, GLuint
*params
)
2337 struct gl_texture_object
*texObj
;
2338 GET_CURRENT_CONTEXT(ctx
);
2340 texObj
= get_texobj_by_target(ctx
, target
, GL_TRUE
);
2344 get_tex_parameterIuiv(ctx
, texObj
, pname
, params
, false);
2349 _mesa_GetTextureParameterfv(GLuint texture
, GLenum pname
, GLfloat
*params
)
2351 struct gl_texture_object
*obj
;
2352 GET_CURRENT_CONTEXT(ctx
);
2354 obj
= get_texobj_by_name(ctx
, texture
, "glGetTextureParameterfv");
2358 get_tex_parameterfv(ctx
, obj
, pname
, params
, true);
2362 _mesa_GetTextureParameteriv(GLuint texture
, GLenum pname
, GLint
*params
)
2364 struct gl_texture_object
*obj
;
2365 GET_CURRENT_CONTEXT(ctx
);
2367 obj
= get_texobj_by_name(ctx
, texture
, "glGetTextureParameteriv");
2371 get_tex_parameteriv(ctx
, obj
, pname
, params
, true);
2375 _mesa_GetTextureParameterIiv(GLuint texture
, GLenum pname
, GLint
*params
)
2377 struct gl_texture_object
*texObj
;
2378 GET_CURRENT_CONTEXT(ctx
);
2380 texObj
= get_texobj_by_name(ctx
, texture
, "glGetTextureParameterIiv");
2384 get_tex_parameterIiv(ctx
, texObj
, pname
, params
, true);
2389 _mesa_GetTextureParameterIuiv(GLuint texture
, GLenum pname
, GLuint
*params
)
2391 struct gl_texture_object
*texObj
;
2392 GET_CURRENT_CONTEXT(ctx
);
2394 texObj
= get_texobj_by_name(ctx
, texture
, "glGetTextureParameterIuiv");
2398 get_tex_parameterIuiv(ctx
, texObj
, pname
, params
, true);