mesa: Use common _mesa_tex_target_to_index in tex param code
[mesa.git] / src / mesa / main / texparam.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
24 */
25
26 /**
27 * \file texparam.c
28 *
29 * glTexParameter-related functions
30 */
31
32 #include <stdbool.h>
33 #include "main/glheader.h"
34 #include "main/blend.h"
35 #include "main/colormac.h"
36 #include "main/context.h"
37 #include "main/enums.h"
38 #include "main/formats.h"
39 #include "main/glformats.h"
40 #include "main/macros.h"
41 #include "main/mtypes.h"
42 #include "main/state.h"
43 #include "main/texcompress.h"
44 #include "main/texobj.h"
45 #include "main/texparam.h"
46 #include "main/teximage.h"
47 #include "main/texstate.h"
48 #include "program/prog_instruction.h"
49
50
51 /**
52 * Check if a coordinate wrap mode is supported for the texture target.
53 * \return GL_TRUE if legal, GL_FALSE otherwise
54 */
55 static GLboolean
56 validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap)
57 {
58 const struct gl_extensions * const e = & ctx->Extensions;
59 const bool is_desktop_gl = _mesa_is_desktop_gl(ctx);
60 bool supported;
61
62 switch (wrap) {
63 case GL_CLAMP:
64 /* GL_CLAMP was removed in the core profile, and it has never existed in
65 * OpenGL ES.
66 */
67 supported = (ctx->API == API_OPENGL_COMPAT)
68 && (target != GL_TEXTURE_EXTERNAL_OES);
69 break;
70
71 case GL_CLAMP_TO_EDGE:
72 supported = true;
73 break;
74
75 case GL_CLAMP_TO_BORDER:
76 supported = is_desktop_gl && e->ARB_texture_border_clamp
77 && (target != GL_TEXTURE_EXTERNAL_OES);
78 break;
79
80 case GL_REPEAT:
81 case GL_MIRRORED_REPEAT:
82 supported = (target != GL_TEXTURE_RECTANGLE_NV)
83 && (target != GL_TEXTURE_EXTERNAL_OES);
84 break;
85
86 case GL_MIRROR_CLAMP_EXT:
87 supported = is_desktop_gl
88 && (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)
89 && (target != GL_TEXTURE_RECTANGLE_NV)
90 && (target != GL_TEXTURE_EXTERNAL_OES);
91 break;
92
93 case GL_MIRROR_CLAMP_TO_EDGE_EXT:
94 supported = is_desktop_gl
95 && (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp || e->ARB_texture_mirror_clamp_to_edge)
96 && (target != GL_TEXTURE_RECTANGLE_NV)
97 && (target != GL_TEXTURE_EXTERNAL_OES);
98 break;
99
100 case GL_MIRROR_CLAMP_TO_BORDER_EXT:
101 supported = is_desktop_gl && e->EXT_texture_mirror_clamp
102 && (target != GL_TEXTURE_RECTANGLE_NV)
103 && (target != GL_TEXTURE_EXTERNAL_OES);
104 break;
105
106 default:
107 supported = false;
108 break;
109 }
110
111 if (!supported)
112 _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap );
113
114 return supported;
115 }
116
117
118 /**
119 * Get current texture object for given target.
120 * Return NULL if any error (and record the error).
121 * Note that this is different from _mesa_get_current_tex_object() in that
122 * proxy targets are not accepted.
123 * Only the glGetTexLevelParameter() functions accept proxy targets.
124 */
125 static struct gl_texture_object *
126 get_texobj(struct gl_context *ctx, GLenum target, GLboolean get)
127 {
128 struct gl_texture_unit *texUnit;
129 int targetIndex;
130
131 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
132 _mesa_error(ctx, GL_INVALID_OPERATION,
133 "gl%sTexParameter(current unit)", get ? "Get" : "");
134 return NULL;
135 }
136
137 texUnit = _mesa_get_current_tex_unit(ctx);
138
139 targetIndex = _mesa_tex_target_to_index(ctx, target);
140 if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) {
141 _mesa_error(ctx, GL_INVALID_ENUM,
142 "gl%sTexParameter(target)", get ? "Get" : "");
143 return NULL;
144 }
145 assert(targetIndex < NUM_TEXTURE_TARGETS);
146
147 return texUnit->CurrentTex[targetIndex];
148 }
149
150
151 /**
152 * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE.
153 * \return -1 if error.
154 */
155 static GLint
156 comp_to_swizzle(GLenum comp)
157 {
158 switch (comp) {
159 case GL_RED:
160 return SWIZZLE_X;
161 case GL_GREEN:
162 return SWIZZLE_Y;
163 case GL_BLUE:
164 return SWIZZLE_Z;
165 case GL_ALPHA:
166 return SWIZZLE_W;
167 case GL_ZERO:
168 return SWIZZLE_ZERO;
169 case GL_ONE:
170 return SWIZZLE_ONE;
171 default:
172 return -1;
173 }
174 }
175
176
177 static void
178 set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
179 {
180 ASSERT(comp < 4);
181 ASSERT(swz <= SWIZZLE_NIL);
182 {
183 GLuint mask = 0x7 << (3 * comp);
184 GLuint s = (*swizzle & ~mask) | (swz << (3 * comp));
185 *swizzle = s;
186 }
187 }
188
189
190 /**
191 * This is called just prior to changing any texture object state which
192 * will not effect texture completeness.
193 */
194 static inline void
195 flush(struct gl_context *ctx)
196 {
197 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
198 }
199
200
201 /**
202 * This is called just prior to changing any texture object state which
203 * can effect texture completeness (texture base level, max level).
204 * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
205 * state flag and then mark the texture object as 'incomplete' so that any
206 * per-texture derived state gets recomputed.
207 */
208 static inline void
209 incomplete(struct gl_context *ctx, struct gl_texture_object *texObj)
210 {
211 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
212 _mesa_dirty_texobj(ctx, texObj);
213 }
214
215
216 static GLboolean
217 target_allows_setting_sampler_parameters(GLenum target)
218 {
219 switch (target) {
220 case GL_TEXTURE_2D_MULTISAMPLE:
221 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
222 return GL_FALSE;
223
224 default:
225 return GL_TRUE;
226 }
227 }
228
229
230 /**
231 * Set an integer-valued texture parameter
232 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
233 */
234 static GLboolean
235 set_tex_parameteri(struct gl_context *ctx,
236 struct gl_texture_object *texObj,
237 GLenum pname, const GLint *params)
238 {
239 switch (pname) {
240 case GL_TEXTURE_MIN_FILTER:
241 if (!target_allows_setting_sampler_parameters(texObj->Target))
242 goto invalid_operation;
243
244 if (texObj->Sampler.MinFilter == params[0])
245 return GL_FALSE;
246 switch (params[0]) {
247 case GL_NEAREST:
248 case GL_LINEAR:
249 flush(ctx);
250 texObj->Sampler.MinFilter = params[0];
251 return GL_TRUE;
252 case GL_NEAREST_MIPMAP_NEAREST:
253 case GL_LINEAR_MIPMAP_NEAREST:
254 case GL_NEAREST_MIPMAP_LINEAR:
255 case GL_LINEAR_MIPMAP_LINEAR:
256 if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
257 texObj->Target != GL_TEXTURE_EXTERNAL_OES) {
258 flush(ctx);
259 texObj->Sampler.MinFilter = params[0];
260 return GL_TRUE;
261 }
262 /* fall-through */
263 default:
264 goto invalid_param;
265 }
266 return GL_FALSE;
267
268 case GL_TEXTURE_MAG_FILTER:
269 if (!target_allows_setting_sampler_parameters(texObj->Target))
270 goto invalid_operation;
271
272 if (texObj->Sampler.MagFilter == params[0])
273 return GL_FALSE;
274 switch (params[0]) {
275 case GL_NEAREST:
276 case GL_LINEAR:
277 flush(ctx); /* does not effect completeness */
278 texObj->Sampler.MagFilter = params[0];
279 return GL_TRUE;
280 default:
281 goto invalid_param;
282 }
283 return GL_FALSE;
284
285 case GL_TEXTURE_WRAP_S:
286 if (!target_allows_setting_sampler_parameters(texObj->Target))
287 goto invalid_operation;
288
289 if (texObj->Sampler.WrapS == params[0])
290 return GL_FALSE;
291 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
292 flush(ctx);
293 texObj->Sampler.WrapS = params[0];
294 return GL_TRUE;
295 }
296 return GL_FALSE;
297
298 case GL_TEXTURE_WRAP_T:
299 if (!target_allows_setting_sampler_parameters(texObj->Target))
300 goto invalid_operation;
301
302 if (texObj->Sampler.WrapT == params[0])
303 return GL_FALSE;
304 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
305 flush(ctx);
306 texObj->Sampler.WrapT = params[0];
307 return GL_TRUE;
308 }
309 return GL_FALSE;
310
311 case GL_TEXTURE_WRAP_R:
312 if (!target_allows_setting_sampler_parameters(texObj->Target))
313 goto invalid_operation;
314
315 if (texObj->Sampler.WrapR == params[0])
316 return GL_FALSE;
317 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
318 flush(ctx);
319 texObj->Sampler.WrapR = params[0];
320 return GL_TRUE;
321 }
322 return GL_FALSE;
323
324 case GL_TEXTURE_BASE_LEVEL:
325 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
326 goto invalid_pname;
327
328 if (texObj->BaseLevel == params[0])
329 return GL_FALSE;
330
331 if ((texObj->Target == GL_TEXTURE_2D_MULTISAMPLE ||
332 texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) && params[0] != 0)
333 goto invalid_operation;
334
335 if (params[0] < 0 ||
336 (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) {
337 _mesa_error(ctx, GL_INVALID_VALUE,
338 "glTexParameter(param=%d)", params[0]);
339 return GL_FALSE;
340 }
341 incomplete(ctx, texObj);
342
343 /** See note about ARB_texture_storage below */
344 if (texObj->Immutable)
345 texObj->BaseLevel = MIN2(texObj->ImmutableLevels - 1, params[0]);
346 else
347 texObj->BaseLevel = params[0];
348
349 return GL_TRUE;
350
351 case GL_TEXTURE_MAX_LEVEL:
352 if (texObj->MaxLevel == params[0])
353 return GL_FALSE;
354
355 if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) {
356 _mesa_error(ctx, GL_INVALID_VALUE,
357 "glTexParameter(param=%d)", params[0]);
358 return GL_FALSE;
359 }
360 incomplete(ctx, texObj);
361
362 /** From ARB_texture_storage:
363 * However, if TEXTURE_IMMUTABLE_FORMAT is TRUE, then level_base is
364 * clamped to the range [0, <levels> - 1] and level_max is then clamped to
365 * the range [level_base, <levels> - 1], where <levels> is the parameter
366 * passed the call to TexStorage* for the texture object.
367 */
368 if (texObj->Immutable)
369 texObj->MaxLevel = CLAMP(params[0], texObj->BaseLevel,
370 texObj->ImmutableLevels - 1);
371 else
372 texObj->MaxLevel = params[0];
373
374 return GL_TRUE;
375
376 case GL_GENERATE_MIPMAP_SGIS:
377 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
378 goto invalid_pname;
379
380 if (params[0] && texObj->Target == GL_TEXTURE_EXTERNAL_OES)
381 goto invalid_param;
382 if (texObj->GenerateMipmap != params[0]) {
383 /* no flush() */
384 texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
385 return GL_TRUE;
386 }
387 return GL_FALSE;
388
389 case GL_TEXTURE_COMPARE_MODE_ARB:
390 if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow)
391 || _mesa_is_gles3(ctx)) {
392
393 if (!target_allows_setting_sampler_parameters(texObj->Target))
394 goto invalid_operation;
395
396 if (texObj->Sampler.CompareMode == params[0])
397 return GL_FALSE;
398 if (params[0] == GL_NONE ||
399 params[0] == GL_COMPARE_R_TO_TEXTURE_ARB) {
400 flush(ctx);
401 texObj->Sampler.CompareMode = params[0];
402 return GL_TRUE;
403 }
404 goto invalid_param;
405 }
406 goto invalid_pname;
407
408 case GL_TEXTURE_COMPARE_FUNC_ARB:
409 if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow)
410 || _mesa_is_gles3(ctx)) {
411
412 if (!target_allows_setting_sampler_parameters(texObj->Target))
413 goto invalid_operation;
414
415 if (texObj->Sampler.CompareFunc == params[0])
416 return GL_FALSE;
417 switch (params[0]) {
418 case GL_LEQUAL:
419 case GL_GEQUAL:
420 case GL_EQUAL:
421 case GL_NOTEQUAL:
422 case GL_LESS:
423 case GL_GREATER:
424 case GL_ALWAYS:
425 case GL_NEVER:
426 flush(ctx);
427 texObj->Sampler.CompareFunc = params[0];
428 return GL_TRUE;
429 default:
430 goto invalid_param;
431 }
432 }
433 goto invalid_pname;
434
435 case GL_DEPTH_TEXTURE_MODE_ARB:
436 /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has never
437 * existed in OpenGL ES.
438 */
439 if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_depth_texture) {
440 if (texObj->DepthMode == params[0])
441 return GL_FALSE;
442 if (params[0] == GL_LUMINANCE ||
443 params[0] == GL_INTENSITY ||
444 params[0] == GL_ALPHA ||
445 (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED)) {
446 flush(ctx);
447 texObj->DepthMode = params[0];
448 return GL_TRUE;
449 }
450 goto invalid_param;
451 }
452 goto invalid_pname;
453
454 case GL_TEXTURE_CROP_RECT_OES:
455 if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
456 goto invalid_pname;
457
458 texObj->CropRect[0] = params[0];
459 texObj->CropRect[1] = params[1];
460 texObj->CropRect[2] = params[2];
461 texObj->CropRect[3] = params[3];
462 return GL_TRUE;
463
464 case GL_TEXTURE_SWIZZLE_R_EXT:
465 case GL_TEXTURE_SWIZZLE_G_EXT:
466 case GL_TEXTURE_SWIZZLE_B_EXT:
467 case GL_TEXTURE_SWIZZLE_A_EXT:
468 if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_swizzle)
469 || _mesa_is_gles3(ctx)) {
470 const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT;
471 const GLint swz = comp_to_swizzle(params[0]);
472 if (swz < 0) {
473 _mesa_error(ctx, GL_INVALID_OPERATION,
474 "glTexParameter(swizzle 0x%x)", params[0]);
475 return GL_FALSE;
476 }
477 ASSERT(comp < 4);
478
479 flush(ctx);
480 texObj->Swizzle[comp] = params[0];
481 set_swizzle_component(&texObj->_Swizzle, comp, swz);
482 return GL_TRUE;
483 }
484 goto invalid_pname;
485
486 case GL_TEXTURE_SWIZZLE_RGBA_EXT:
487 if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_swizzle)
488 || _mesa_is_gles3(ctx)) {
489 GLuint comp;
490 flush(ctx);
491 for (comp = 0; comp < 4; comp++) {
492 const GLint swz = comp_to_swizzle(params[comp]);
493 if (swz >= 0) {
494 texObj->Swizzle[comp] = params[comp];
495 set_swizzle_component(&texObj->_Swizzle, comp, swz);
496 }
497 else {
498 _mesa_error(ctx, GL_INVALID_OPERATION,
499 "glTexParameter(swizzle 0x%x)", params[comp]);
500 return GL_FALSE;
501 }
502 }
503 return GL_TRUE;
504 }
505 goto invalid_pname;
506
507 case GL_TEXTURE_SRGB_DECODE_EXT:
508 if (_mesa_is_desktop_gl(ctx)
509 && ctx->Extensions.EXT_texture_sRGB_decode) {
510 GLenum decode = params[0];
511
512 if (!target_allows_setting_sampler_parameters(texObj->Target))
513 goto invalid_operation;
514
515 if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) {
516 if (texObj->Sampler.sRGBDecode != decode) {
517 flush(ctx);
518 texObj->Sampler.sRGBDecode = decode;
519 }
520 return GL_TRUE;
521 }
522 }
523 goto invalid_pname;
524
525 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
526 if (_mesa_is_desktop_gl(ctx)
527 && ctx->Extensions.AMD_seamless_cubemap_per_texture) {
528 GLenum param = params[0];
529
530 if (!target_allows_setting_sampler_parameters(texObj->Target))
531 goto invalid_operation;
532
533 if (param != GL_TRUE && param != GL_FALSE) {
534 goto invalid_param;
535 }
536 if (param != texObj->Sampler.CubeMapSeamless) {
537 flush(ctx);
538 texObj->Sampler.CubeMapSeamless = param;
539 }
540 return GL_TRUE;
541 }
542 goto invalid_pname;
543
544 default:
545 goto invalid_pname;
546 }
547
548 invalid_pname:
549 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)",
550 _mesa_lookup_enum_by_nr(pname));
551 return GL_FALSE;
552
553 invalid_param:
554 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param=%s)",
555 _mesa_lookup_enum_by_nr(params[0]));
556 return GL_FALSE;
557
558 invalid_operation:
559 _mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(pname=%s)",
560 _mesa_lookup_enum_by_nr(pname));
561 return GL_FALSE;
562 }
563
564
565 /**
566 * Set a float-valued texture parameter
567 * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
568 */
569 static GLboolean
570 set_tex_parameterf(struct gl_context *ctx,
571 struct gl_texture_object *texObj,
572 GLenum pname, const GLfloat *params)
573 {
574 switch (pname) {
575 case GL_TEXTURE_MIN_LOD:
576 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
577 goto invalid_pname;
578
579 if (!target_allows_setting_sampler_parameters(texObj->Target))
580 goto invalid_operation;
581
582 if (texObj->Sampler.MinLod == params[0])
583 return GL_FALSE;
584 flush(ctx);
585 texObj->Sampler.MinLod = params[0];
586 return GL_TRUE;
587
588 case GL_TEXTURE_MAX_LOD:
589 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
590 goto invalid_pname;
591
592 if (!target_allows_setting_sampler_parameters(texObj->Target))
593 goto invalid_operation;
594
595 if (texObj->Sampler.MaxLod == params[0])
596 return GL_FALSE;
597 flush(ctx);
598 texObj->Sampler.MaxLod = params[0];
599 return GL_TRUE;
600
601 case GL_TEXTURE_PRIORITY:
602 if (ctx->API != API_OPENGL_COMPAT)
603 goto invalid_pname;
604
605 flush(ctx);
606 texObj->Priority = CLAMP(params[0], 0.0F, 1.0F);
607 return GL_TRUE;
608
609 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
610 if (ctx->Extensions.EXT_texture_filter_anisotropic) {
611 if (!target_allows_setting_sampler_parameters(texObj->Target))
612 goto invalid_operation;
613
614 if (texObj->Sampler.MaxAnisotropy == params[0])
615 return GL_FALSE;
616 if (params[0] < 1.0) {
617 _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
618 return GL_FALSE;
619 }
620 flush(ctx);
621 /* clamp to max, that's what NVIDIA does */
622 texObj->Sampler.MaxAnisotropy = MIN2(params[0],
623 ctx->Const.MaxTextureMaxAnisotropy);
624 return GL_TRUE;
625 }
626 else {
627 static GLuint count = 0;
628 if (count++ < 10)
629 goto invalid_pname;
630 }
631 return GL_FALSE;
632
633 case GL_TEXTURE_LOD_BIAS:
634 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias. */
635 if (_mesa_is_gles(ctx))
636 goto invalid_pname;
637
638 if (!target_allows_setting_sampler_parameters(texObj->Target))
639 goto invalid_operation;
640
641 if (texObj->Sampler.LodBias != params[0]) {
642 flush(ctx);
643 texObj->Sampler.LodBias = params[0];
644 return GL_TRUE;
645 }
646 break;
647
648 case GL_TEXTURE_BORDER_COLOR:
649 if (!_mesa_is_desktop_gl(ctx))
650 goto invalid_pname;
651
652 if (!target_allows_setting_sampler_parameters(texObj->Target))
653 goto invalid_operation;
654
655 flush(ctx);
656 /* ARB_texture_float disables clamping */
657 if (ctx->Extensions.ARB_texture_float) {
658 texObj->Sampler.BorderColor.f[RCOMP] = params[0];
659 texObj->Sampler.BorderColor.f[GCOMP] = params[1];
660 texObj->Sampler.BorderColor.f[BCOMP] = params[2];
661 texObj->Sampler.BorderColor.f[ACOMP] = params[3];
662 } else {
663 texObj->Sampler.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F);
664 texObj->Sampler.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F);
665 texObj->Sampler.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F);
666 texObj->Sampler.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F);
667 }
668 return GL_TRUE;
669
670 default:
671 goto invalid_pname;
672 }
673 return GL_FALSE;
674
675 invalid_pname:
676 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)",
677 _mesa_lookup_enum_by_nr(pname));
678 return GL_FALSE;
679
680 invalid_operation:
681 _mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(pname=%s)",
682 _mesa_lookup_enum_by_nr(pname));
683 return GL_FALSE;
684 }
685
686
687 void GLAPIENTRY
688 _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
689 {
690 GLboolean need_update;
691 struct gl_texture_object *texObj;
692 GET_CURRENT_CONTEXT(ctx);
693
694 texObj = get_texobj(ctx, target, GL_FALSE);
695 if (!texObj)
696 return;
697
698 switch (pname) {
699 case GL_TEXTURE_MIN_FILTER:
700 case GL_TEXTURE_MAG_FILTER:
701 case GL_TEXTURE_WRAP_S:
702 case GL_TEXTURE_WRAP_T:
703 case GL_TEXTURE_WRAP_R:
704 case GL_TEXTURE_BASE_LEVEL:
705 case GL_TEXTURE_MAX_LEVEL:
706 case GL_GENERATE_MIPMAP_SGIS:
707 case GL_TEXTURE_COMPARE_MODE_ARB:
708 case GL_TEXTURE_COMPARE_FUNC_ARB:
709 case GL_DEPTH_TEXTURE_MODE_ARB:
710 case GL_TEXTURE_SRGB_DECODE_EXT:
711 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
712 case GL_TEXTURE_SWIZZLE_R_EXT:
713 case GL_TEXTURE_SWIZZLE_G_EXT:
714 case GL_TEXTURE_SWIZZLE_B_EXT:
715 case GL_TEXTURE_SWIZZLE_A_EXT:
716 {
717 GLint p[4];
718 p[0] = (param > 0) ?
719 ((param > INT_MAX) ? INT_MAX : (GLint) (param + 0.5)) :
720 ((param < INT_MIN) ? INT_MIN : (GLint) (param - 0.5));
721
722 p[1] = p[2] = p[3] = 0;
723 need_update = set_tex_parameteri(ctx, texObj, pname, p);
724 }
725 break;
726 default:
727 {
728 /* this will generate an error if pname is illegal */
729 GLfloat p[4];
730 p[0] = param;
731 p[1] = p[2] = p[3] = 0.0F;
732 need_update = set_tex_parameterf(ctx, texObj, pname, p);
733 }
734 }
735
736 if (ctx->Driver.TexParameter && need_update) {
737 ctx->Driver.TexParameter(ctx, texObj, pname, &param);
738 }
739 }
740
741
742 void GLAPIENTRY
743 _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
744 {
745 GLboolean need_update;
746 struct gl_texture_object *texObj;
747 GET_CURRENT_CONTEXT(ctx);
748
749 texObj = get_texobj(ctx, target, GL_FALSE);
750 if (!texObj)
751 return;
752
753 switch (pname) {
754 case GL_TEXTURE_MIN_FILTER:
755 case GL_TEXTURE_MAG_FILTER:
756 case GL_TEXTURE_WRAP_S:
757 case GL_TEXTURE_WRAP_T:
758 case GL_TEXTURE_WRAP_R:
759 case GL_TEXTURE_BASE_LEVEL:
760 case GL_TEXTURE_MAX_LEVEL:
761 case GL_GENERATE_MIPMAP_SGIS:
762 case GL_TEXTURE_COMPARE_MODE_ARB:
763 case GL_TEXTURE_COMPARE_FUNC_ARB:
764 case GL_DEPTH_TEXTURE_MODE_ARB:
765 case GL_TEXTURE_SRGB_DECODE_EXT:
766 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
767 {
768 /* convert float param to int */
769 GLint p[4];
770 p[0] = (GLint) params[0];
771 p[1] = p[2] = p[3] = 0;
772 need_update = set_tex_parameteri(ctx, texObj, pname, p);
773 }
774 break;
775 case GL_TEXTURE_CROP_RECT_OES:
776 {
777 /* convert float params to int */
778 GLint iparams[4];
779 iparams[0] = (GLint) params[0];
780 iparams[1] = (GLint) params[1];
781 iparams[2] = (GLint) params[2];
782 iparams[3] = (GLint) params[3];
783 need_update = set_tex_parameteri(ctx, texObj, pname, iparams);
784 }
785 break;
786 case GL_TEXTURE_SWIZZLE_R_EXT:
787 case GL_TEXTURE_SWIZZLE_G_EXT:
788 case GL_TEXTURE_SWIZZLE_B_EXT:
789 case GL_TEXTURE_SWIZZLE_A_EXT:
790 case GL_TEXTURE_SWIZZLE_RGBA_EXT:
791 {
792 GLint p[4] = {0, 0, 0, 0};
793 p[0] = (GLint) params[0];
794 if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT) {
795 p[1] = (GLint) params[1];
796 p[2] = (GLint) params[2];
797 p[3] = (GLint) params[3];
798 }
799 need_update = set_tex_parameteri(ctx, texObj, pname, p);
800 }
801 break;
802 default:
803 /* this will generate an error if pname is illegal */
804 need_update = set_tex_parameterf(ctx, texObj, pname, params);
805 }
806
807 if (ctx->Driver.TexParameter && need_update) {
808 ctx->Driver.TexParameter(ctx, texObj, pname, params);
809 }
810 }
811
812
813 void GLAPIENTRY
814 _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
815 {
816 GLboolean need_update;
817 struct gl_texture_object *texObj;
818 GET_CURRENT_CONTEXT(ctx);
819
820 texObj = get_texobj(ctx, target, GL_FALSE);
821 if (!texObj)
822 return;
823
824 switch (pname) {
825 case GL_TEXTURE_MIN_LOD:
826 case GL_TEXTURE_MAX_LOD:
827 case GL_TEXTURE_PRIORITY:
828 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
829 case GL_TEXTURE_LOD_BIAS:
830 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
831 {
832 GLfloat fparam[4];
833 fparam[0] = (GLfloat) param;
834 fparam[1] = fparam[2] = fparam[3] = 0.0F;
835 /* convert int param to float */
836 need_update = set_tex_parameterf(ctx, texObj, pname, fparam);
837 }
838 break;
839 default:
840 /* this will generate an error if pname is illegal */
841 {
842 GLint iparam[4];
843 iparam[0] = param;
844 iparam[1] = iparam[2] = iparam[3] = 0;
845 need_update = set_tex_parameteri(ctx, texObj, pname, iparam);
846 }
847 }
848
849 if (ctx->Driver.TexParameter && need_update) {
850 GLfloat fparam = (GLfloat) param;
851 ctx->Driver.TexParameter(ctx, texObj, pname, &fparam);
852 }
853 }
854
855
856 void GLAPIENTRY
857 _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
858 {
859 GLboolean need_update;
860 struct gl_texture_object *texObj;
861 GET_CURRENT_CONTEXT(ctx);
862
863 texObj = get_texobj(ctx, target, GL_FALSE);
864 if (!texObj)
865 return;
866
867 switch (pname) {
868 case GL_TEXTURE_BORDER_COLOR:
869 {
870 /* convert int params to float */
871 GLfloat fparams[4];
872 fparams[0] = INT_TO_FLOAT(params[0]);
873 fparams[1] = INT_TO_FLOAT(params[1]);
874 fparams[2] = INT_TO_FLOAT(params[2]);
875 fparams[3] = INT_TO_FLOAT(params[3]);
876 need_update = set_tex_parameterf(ctx, texObj, pname, fparams);
877 }
878 break;
879 case GL_TEXTURE_MIN_LOD:
880 case GL_TEXTURE_MAX_LOD:
881 case GL_TEXTURE_PRIORITY:
882 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
883 case GL_TEXTURE_LOD_BIAS:
884 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
885 {
886 /* convert int param to float */
887 GLfloat fparams[4];
888 fparams[0] = (GLfloat) params[0];
889 fparams[1] = fparams[2] = fparams[3] = 0.0F;
890 need_update = set_tex_parameterf(ctx, texObj, pname, fparams);
891 }
892 break;
893 default:
894 /* this will generate an error if pname is illegal */
895 need_update = set_tex_parameteri(ctx, texObj, pname, params);
896 }
897
898 if (ctx->Driver.TexParameter && need_update) {
899 GLfloat fparams[4];
900 fparams[0] = INT_TO_FLOAT(params[0]);
901 if (pname == GL_TEXTURE_BORDER_COLOR ||
902 pname == GL_TEXTURE_CROP_RECT_OES) {
903 fparams[1] = INT_TO_FLOAT(params[1]);
904 fparams[2] = INT_TO_FLOAT(params[2]);
905 fparams[3] = INT_TO_FLOAT(params[3]);
906 }
907 ctx->Driver.TexParameter(ctx, texObj, pname, fparams);
908 }
909 }
910
911
912 /**
913 * Set tex parameter to integer value(s). Primarily intended to set
914 * integer-valued texture border color (for integer-valued textures).
915 * New in GL 3.0.
916 */
917 void GLAPIENTRY
918 _mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
919 {
920 struct gl_texture_object *texObj;
921 GET_CURRENT_CONTEXT(ctx);
922
923 texObj = get_texobj(ctx, target, GL_FALSE);
924 if (!texObj)
925 return;
926
927 switch (pname) {
928 case GL_TEXTURE_BORDER_COLOR:
929 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
930 /* set the integer-valued border color */
931 COPY_4V(texObj->Sampler.BorderColor.i, params);
932 break;
933 default:
934 _mesa_TexParameteriv(target, pname, params);
935 break;
936 }
937 /* XXX no driver hook for TexParameterIiv() yet */
938 }
939
940
941 /**
942 * Set tex parameter to unsigned integer value(s). Primarily intended to set
943 * uint-valued texture border color (for integer-valued textures).
944 * New in GL 3.0
945 */
946 void GLAPIENTRY
947 _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
948 {
949 struct gl_texture_object *texObj;
950 GET_CURRENT_CONTEXT(ctx);
951
952 texObj = get_texobj(ctx, target, GL_FALSE);
953 if (!texObj)
954 return;
955
956 switch (pname) {
957 case GL_TEXTURE_BORDER_COLOR:
958 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
959 /* set the unsigned integer-valued border color */
960 COPY_4V(texObj->Sampler.BorderColor.ui, params);
961 break;
962 default:
963 _mesa_TexParameteriv(target, pname, (const GLint *) params);
964 break;
965 }
966 /* XXX no driver hook for TexParameterIuiv() yet */
967 }
968
969
970 static GLboolean
971 legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target)
972 {
973 switch (target) {
974 case GL_TEXTURE_1D:
975 case GL_PROXY_TEXTURE_1D:
976 case GL_TEXTURE_2D:
977 case GL_PROXY_TEXTURE_2D:
978 case GL_TEXTURE_3D:
979 case GL_PROXY_TEXTURE_3D:
980 return GL_TRUE;
981 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
982 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
983 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
984 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
985 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
986 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
987 case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
988 return ctx->Extensions.ARB_texture_cube_map;
989 case GL_TEXTURE_RECTANGLE_NV:
990 case GL_PROXY_TEXTURE_RECTANGLE_NV:
991 return ctx->Extensions.NV_texture_rectangle;
992 case GL_TEXTURE_1D_ARRAY_EXT:
993 case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
994 case GL_TEXTURE_2D_ARRAY_EXT:
995 case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
996 return ctx->Extensions.EXT_texture_array;
997 case GL_TEXTURE_BUFFER:
998 /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
999 * but not in earlier versions that expose ARB_texture_buffer_object.
1000 *
1001 * From the ARB_texture_buffer_object spec:
1002 * "(7) Do buffer textures support texture parameters (TexParameter) or
1003 * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
1004 *
1005 * RESOLVED: No. [...] Note that the spec edits above don't add
1006 * explicit error language for any of these cases. That is because
1007 * each of the functions enumerate the set of valid <target>
1008 * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
1009 * these cases means that target is not legal, and an INVALID_ENUM
1010 * error should be generated."
1011 *
1012 * From the OpenGL 3.1 spec:
1013 * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
1014 */
1015 return ctx->API == API_OPENGL_CORE && ctx->Version >= 31;
1016 case GL_TEXTURE_2D_MULTISAMPLE:
1017 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1018 case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
1019 case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
1020 return ctx->Extensions.ARB_texture_multisample;
1021 default:
1022 return GL_FALSE;
1023 }
1024 }
1025
1026
1027 static void
1028 get_tex_level_parameter_image(struct gl_context *ctx,
1029 const struct gl_texture_object *texObj,
1030 GLenum target, GLint level,
1031 GLenum pname, GLint *params)
1032 {
1033 const struct gl_texture_image *img = NULL;
1034 mesa_format texFormat;
1035
1036 img = _mesa_select_tex_image(ctx, texObj, target, level);
1037 if (!img || img->TexFormat == MESA_FORMAT_NONE) {
1038 /* undefined texture image */
1039 if (pname == GL_TEXTURE_COMPONENTS)
1040 *params = 1;
1041 else
1042 *params = 0;
1043 return;
1044 }
1045
1046 texFormat = img->TexFormat;
1047
1048 switch (pname) {
1049 case GL_TEXTURE_WIDTH:
1050 *params = img->Width;
1051 break;
1052 case GL_TEXTURE_HEIGHT:
1053 *params = img->Height;
1054 break;
1055 case GL_TEXTURE_DEPTH:
1056 *params = img->Depth;
1057 break;
1058 case GL_TEXTURE_INTERNAL_FORMAT:
1059 if (_mesa_is_format_compressed(texFormat)) {
1060 /* need to return the actual compressed format */
1061 *params = _mesa_compressed_format_to_glenum(ctx, texFormat);
1062 }
1063 else {
1064 /* If the true internal format is not compressed but the user
1065 * requested a generic compressed format, we have to return the
1066 * generic base format that matches.
1067 *
1068 * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
1069 *
1070 * "If no specific compressed format is available,
1071 * internalformat is instead replaced by the corresponding base
1072 * internal format."
1073 *
1074 * Otherwise just return the user's requested internal format
1075 */
1076 const GLenum f =
1077 _mesa_gl_compressed_format_base_format(img->InternalFormat);
1078
1079 *params = (f != 0) ? f : img->InternalFormat;
1080 }
1081 break;
1082 case GL_TEXTURE_BORDER:
1083 *params = img->Border;
1084 break;
1085 case GL_TEXTURE_RED_SIZE:
1086 case GL_TEXTURE_GREEN_SIZE:
1087 case GL_TEXTURE_BLUE_SIZE:
1088 case GL_TEXTURE_ALPHA_SIZE:
1089 if (_mesa_base_format_has_channel(img->_BaseFormat, pname))
1090 *params = _mesa_get_format_bits(texFormat, pname);
1091 else
1092 *params = 0;
1093 break;
1094 case GL_TEXTURE_INTENSITY_SIZE:
1095 case GL_TEXTURE_LUMINANCE_SIZE:
1096 if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) {
1097 *params = _mesa_get_format_bits(texFormat, pname);
1098 if (*params == 0) {
1099 /* intensity or luminance is probably stored as RGB[A] */
1100 *params = MIN2(_mesa_get_format_bits(texFormat,
1101 GL_TEXTURE_RED_SIZE),
1102 _mesa_get_format_bits(texFormat,
1103 GL_TEXTURE_GREEN_SIZE));
1104 }
1105 }
1106 else {
1107 *params = 0;
1108 }
1109 break;
1110 case GL_TEXTURE_DEPTH_SIZE_ARB:
1111 if (!ctx->Extensions.ARB_depth_texture)
1112 goto invalid_pname;
1113 *params = _mesa_get_format_bits(texFormat, pname);
1114 break;
1115 case GL_TEXTURE_STENCIL_SIZE:
1116 *params = _mesa_get_format_bits(texFormat, pname);
1117 break;
1118 case GL_TEXTURE_SHARED_SIZE:
1119 if (ctx->Version < 30 &&
1120 !ctx->Extensions.EXT_texture_shared_exponent)
1121 goto invalid_pname;
1122 *params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 : 0;
1123 break;
1124
1125 /* GL_ARB_texture_compression */
1126 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
1127 if (_mesa_is_format_compressed(texFormat) &&
1128 !_mesa_is_proxy_texture(target)) {
1129 *params = _mesa_format_image_size(texFormat, img->Width,
1130 img->Height, img->Depth);
1131 }
1132 else {
1133 _mesa_error(ctx, GL_INVALID_OPERATION,
1134 "glGetTexLevelParameter[if]v(pname)");
1135 }
1136 break;
1137 case GL_TEXTURE_COMPRESSED:
1138 *params = (GLint) _mesa_is_format_compressed(texFormat);
1139 break;
1140
1141 /* GL_ARB_texture_float */
1142 case GL_TEXTURE_RED_TYPE_ARB:
1143 case GL_TEXTURE_GREEN_TYPE_ARB:
1144 case GL_TEXTURE_BLUE_TYPE_ARB:
1145 case GL_TEXTURE_ALPHA_TYPE_ARB:
1146 case GL_TEXTURE_LUMINANCE_TYPE_ARB:
1147 case GL_TEXTURE_INTENSITY_TYPE_ARB:
1148 case GL_TEXTURE_DEPTH_TYPE_ARB:
1149 if (!ctx->Extensions.ARB_texture_float)
1150 goto invalid_pname;
1151 if (_mesa_base_format_has_channel(img->_BaseFormat, pname))
1152 *params = _mesa_get_format_datatype(texFormat);
1153 else
1154 *params = GL_NONE;
1155 break;
1156
1157 /* GL_ARB_texture_multisample */
1158 case GL_TEXTURE_SAMPLES:
1159 if (!ctx->Extensions.ARB_texture_multisample)
1160 goto invalid_pname;
1161 *params = img->NumSamples;
1162 break;
1163
1164 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
1165 if (!ctx->Extensions.ARB_texture_multisample)
1166 goto invalid_pname;
1167 *params = img->FixedSampleLocations;
1168 break;
1169
1170 default:
1171 goto invalid_pname;
1172 }
1173
1174 /* no error if we get here */
1175 return;
1176
1177 invalid_pname:
1178 _mesa_error(ctx, GL_INVALID_ENUM,
1179 "glGetTexLevelParameter[if]v(pname=%s)",
1180 _mesa_lookup_enum_by_nr(pname));
1181 }
1182
1183
1184 static void
1185 get_tex_level_parameter_buffer(struct gl_context *ctx,
1186 const struct gl_texture_object *texObj,
1187 GLenum pname, GLint *params)
1188 {
1189 const struct gl_buffer_object *bo = texObj->BufferObject;
1190 mesa_format texFormat = texObj->_BufferObjectFormat;
1191 GLenum internalFormat = texObj->BufferObjectFormat;
1192 GLenum baseFormat = _mesa_get_format_base_format(texFormat);
1193
1194 if (!bo) {
1195 /* undefined texture buffer object */
1196 *params = pname == GL_TEXTURE_COMPONENTS ? 1 : 0;
1197 return;
1198 }
1199
1200 switch (pname) {
1201 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING:
1202 *params = bo->Name;
1203 break;
1204 case GL_TEXTURE_WIDTH:
1205 *params = bo->Size;
1206 break;
1207 case GL_TEXTURE_HEIGHT:
1208 case GL_TEXTURE_DEPTH:
1209 case GL_TEXTURE_BORDER:
1210 case GL_TEXTURE_SHARED_SIZE:
1211 case GL_TEXTURE_COMPRESSED:
1212 *params = 0;
1213 break;
1214 case GL_TEXTURE_INTERNAL_FORMAT:
1215 *params = internalFormat;
1216 break;
1217 case GL_TEXTURE_RED_SIZE:
1218 case GL_TEXTURE_GREEN_SIZE:
1219 case GL_TEXTURE_BLUE_SIZE:
1220 case GL_TEXTURE_ALPHA_SIZE:
1221 if (_mesa_base_format_has_channel(baseFormat, pname))
1222 *params = _mesa_get_format_bits(texFormat, pname);
1223 else
1224 *params = 0;
1225 break;
1226 case GL_TEXTURE_INTENSITY_SIZE:
1227 case GL_TEXTURE_LUMINANCE_SIZE:
1228 if (_mesa_base_format_has_channel(baseFormat, pname)) {
1229 *params = _mesa_get_format_bits(texFormat, pname);
1230 if (*params == 0) {
1231 /* intensity or luminance is probably stored as RGB[A] */
1232 *params = MIN2(_mesa_get_format_bits(texFormat,
1233 GL_TEXTURE_RED_SIZE),
1234 _mesa_get_format_bits(texFormat,
1235 GL_TEXTURE_GREEN_SIZE));
1236 }
1237 } else {
1238 *params = 0;
1239 }
1240 break;
1241 case GL_TEXTURE_DEPTH_SIZE_ARB:
1242 case GL_TEXTURE_STENCIL_SIZE_EXT:
1243 *params = _mesa_get_format_bits(texFormat, pname);
1244 break;
1245
1246 /* GL_ARB_texture_buffer_range */
1247 case GL_TEXTURE_BUFFER_OFFSET:
1248 if (!ctx->Extensions.ARB_texture_buffer_range)
1249 goto invalid_pname;
1250 *params = texObj->BufferOffset;
1251 break;
1252 case GL_TEXTURE_BUFFER_SIZE:
1253 if (!ctx->Extensions.ARB_texture_buffer_range)
1254 goto invalid_pname;
1255 *params = (texObj->BufferSize == -1) ? bo->Size : texObj->BufferSize;
1256 break;
1257
1258 /* GL_ARB_texture_compression */
1259 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
1260 /* Always illegal for GL_TEXTURE_BUFFER */
1261 _mesa_error(ctx, GL_INVALID_OPERATION,
1262 "glGetTexLevelParameter[if]v(pname)");
1263 break;
1264
1265 /* GL_ARB_texture_float */
1266 case GL_TEXTURE_RED_TYPE_ARB:
1267 case GL_TEXTURE_GREEN_TYPE_ARB:
1268 case GL_TEXTURE_BLUE_TYPE_ARB:
1269 case GL_TEXTURE_ALPHA_TYPE_ARB:
1270 case GL_TEXTURE_LUMINANCE_TYPE_ARB:
1271 case GL_TEXTURE_INTENSITY_TYPE_ARB:
1272 case GL_TEXTURE_DEPTH_TYPE_ARB:
1273 if (!ctx->Extensions.ARB_texture_float)
1274 goto invalid_pname;
1275 if (_mesa_base_format_has_channel(baseFormat, pname))
1276 *params = _mesa_get_format_datatype(texFormat);
1277 else
1278 *params = GL_NONE;
1279 break;
1280
1281 default:
1282 goto invalid_pname;
1283 }
1284
1285 /* no error if we get here */
1286 return;
1287
1288 invalid_pname:
1289 _mesa_error(ctx, GL_INVALID_ENUM,
1290 "glGetTexLevelParameter[if]v(pname=%s)",
1291 _mesa_lookup_enum_by_nr(pname));
1292 }
1293
1294
1295 void GLAPIENTRY
1296 _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
1297 GLenum pname, GLfloat *params )
1298 {
1299 GLint iparam;
1300 _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
1301 *params = (GLfloat) iparam;
1302 }
1303
1304
1305 void GLAPIENTRY
1306 _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
1307 GLenum pname, GLint *params )
1308 {
1309 struct gl_texture_object *texObj;
1310 GLint maxLevels;
1311 GET_CURRENT_CONTEXT(ctx);
1312
1313 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
1314 _mesa_error(ctx, GL_INVALID_OPERATION,
1315 "glGetTexLevelParameteriv(current unit)");
1316 return;
1317 }
1318
1319 if (!legal_get_tex_level_parameter_target(ctx, target)) {
1320 _mesa_error(ctx, GL_INVALID_ENUM,
1321 "glGetTexLevelParameter[if]v(target=0x%x)", target);
1322 return;
1323 }
1324
1325 maxLevels = _mesa_max_texture_levels(ctx, target);
1326 assert(maxLevels != 0);
1327
1328 if (level < 0 || level >= maxLevels) {
1329 _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
1330 return;
1331 }
1332
1333 texObj = _mesa_get_current_tex_object(ctx, target);
1334
1335 if (target == GL_TEXTURE_BUFFER)
1336 get_tex_level_parameter_buffer(ctx, texObj, pname, params);
1337 else
1338 get_tex_level_parameter_image(ctx, texObj, target, level, pname, params);
1339 }
1340
1341
1342 void GLAPIENTRY
1343 _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
1344 {
1345 struct gl_texture_object *obj;
1346 GET_CURRENT_CONTEXT(ctx);
1347
1348 obj = get_texobj(ctx, target, GL_TRUE);
1349 if (!obj)
1350 return;
1351
1352 _mesa_lock_texture(ctx, obj);
1353 switch (pname) {
1354 case GL_TEXTURE_MAG_FILTER:
1355 *params = ENUM_TO_FLOAT(obj->Sampler.MagFilter);
1356 break;
1357 case GL_TEXTURE_MIN_FILTER:
1358 *params = ENUM_TO_FLOAT(obj->Sampler.MinFilter);
1359 break;
1360 case GL_TEXTURE_WRAP_S:
1361 *params = ENUM_TO_FLOAT(obj->Sampler.WrapS);
1362 break;
1363 case GL_TEXTURE_WRAP_T:
1364 *params = ENUM_TO_FLOAT(obj->Sampler.WrapT);
1365 break;
1366 case GL_TEXTURE_WRAP_R:
1367 *params = ENUM_TO_FLOAT(obj->Sampler.WrapR);
1368 break;
1369 case GL_TEXTURE_BORDER_COLOR:
1370 if (!_mesa_is_desktop_gl(ctx))
1371 goto invalid_pname;
1372
1373 if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
1374 _mesa_update_state_locked(ctx);
1375 if (_mesa_get_clamp_fragment_color(ctx)) {
1376 params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
1377 params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
1378 params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
1379 params[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F);
1380 }
1381 else {
1382 params[0] = obj->Sampler.BorderColor.f[0];
1383 params[1] = obj->Sampler.BorderColor.f[1];
1384 params[2] = obj->Sampler.BorderColor.f[2];
1385 params[3] = obj->Sampler.BorderColor.f[3];
1386 }
1387 break;
1388 case GL_TEXTURE_RESIDENT:
1389 if (ctx->API != API_OPENGL_COMPAT)
1390 goto invalid_pname;
1391
1392 *params = 1.0F;
1393 break;
1394 case GL_TEXTURE_PRIORITY:
1395 if (ctx->API != API_OPENGL_COMPAT)
1396 goto invalid_pname;
1397
1398 *params = obj->Priority;
1399 break;
1400 case GL_TEXTURE_MIN_LOD:
1401 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1402 goto invalid_pname;
1403
1404 *params = obj->Sampler.MinLod;
1405 break;
1406 case GL_TEXTURE_MAX_LOD:
1407 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1408 goto invalid_pname;
1409
1410 *params = obj->Sampler.MaxLod;
1411 break;
1412 case GL_TEXTURE_BASE_LEVEL:
1413 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1414 goto invalid_pname;
1415
1416 *params = (GLfloat) obj->BaseLevel;
1417 break;
1418 case GL_TEXTURE_MAX_LEVEL:
1419 *params = (GLfloat) obj->MaxLevel;
1420 break;
1421 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1422 if (!ctx->Extensions.EXT_texture_filter_anisotropic)
1423 goto invalid_pname;
1424 *params = obj->Sampler.MaxAnisotropy;
1425 break;
1426 case GL_GENERATE_MIPMAP_SGIS:
1427 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1428 goto invalid_pname;
1429
1430 *params = (GLfloat) obj->GenerateMipmap;
1431 break;
1432 case GL_TEXTURE_COMPARE_MODE_ARB:
1433 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
1434 && !_mesa_is_gles3(ctx))
1435 goto invalid_pname;
1436 *params = (GLfloat) obj->Sampler.CompareMode;
1437 break;
1438 case GL_TEXTURE_COMPARE_FUNC_ARB:
1439 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
1440 && !_mesa_is_gles3(ctx))
1441 goto invalid_pname;
1442 *params = (GLfloat) obj->Sampler.CompareFunc;
1443 break;
1444 case GL_DEPTH_TEXTURE_MODE_ARB:
1445 /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has
1446 * never existed in OpenGL ES.
1447 */
1448 if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ARB_depth_texture)
1449 goto invalid_pname;
1450 *params = (GLfloat) obj->DepthMode;
1451 break;
1452 case GL_TEXTURE_LOD_BIAS:
1453 if (_mesa_is_gles(ctx))
1454 goto invalid_pname;
1455
1456 *params = obj->Sampler.LodBias;
1457 break;
1458 case GL_TEXTURE_CROP_RECT_OES:
1459 if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
1460 goto invalid_pname;
1461
1462 params[0] = (GLfloat) obj->CropRect[0];
1463 params[1] = (GLfloat) obj->CropRect[1];
1464 params[2] = (GLfloat) obj->CropRect[2];
1465 params[3] = (GLfloat) obj->CropRect[3];
1466 break;
1467
1468 case GL_TEXTURE_SWIZZLE_R_EXT:
1469 case GL_TEXTURE_SWIZZLE_G_EXT:
1470 case GL_TEXTURE_SWIZZLE_B_EXT:
1471 case GL_TEXTURE_SWIZZLE_A_EXT:
1472 if ((!_mesa_is_desktop_gl(ctx)
1473 || !ctx->Extensions.EXT_texture_swizzle)
1474 && !_mesa_is_gles3(ctx))
1475 goto invalid_pname;
1476 *params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
1477 break;
1478
1479 case GL_TEXTURE_SWIZZLE_RGBA_EXT:
1480 if ((!_mesa_is_desktop_gl(ctx)
1481 || !ctx->Extensions.EXT_texture_swizzle)
1482 && !_mesa_is_gles3(ctx)) {
1483 goto invalid_pname;
1484 }
1485 else {
1486 GLuint comp;
1487 for (comp = 0; comp < 4; comp++) {
1488 params[comp] = (GLfloat) obj->Swizzle[comp];
1489 }
1490 }
1491 break;
1492
1493 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1494 if (!_mesa_is_desktop_gl(ctx)
1495 || !ctx->Extensions.AMD_seamless_cubemap_per_texture)
1496 goto invalid_pname;
1497 *params = (GLfloat) obj->Sampler.CubeMapSeamless;
1498 break;
1499
1500 case GL_TEXTURE_IMMUTABLE_FORMAT:
1501 *params = (GLfloat) obj->Immutable;
1502 break;
1503
1504 case GL_TEXTURE_IMMUTABLE_LEVELS:
1505 if (_mesa_is_gles3(ctx) ||
1506 (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_view))
1507 *params = (GLfloat) obj->ImmutableLevels;
1508 else
1509 goto invalid_pname;
1510 break;
1511
1512 case GL_TEXTURE_VIEW_MIN_LEVEL:
1513 if (!ctx->Extensions.ARB_texture_view)
1514 goto invalid_pname;
1515 *params = (GLfloat) obj->MinLevel;
1516 break;
1517
1518 case GL_TEXTURE_VIEW_NUM_LEVELS:
1519 if (!ctx->Extensions.ARB_texture_view)
1520 goto invalid_pname;
1521 *params = (GLfloat) obj->NumLevels;
1522 break;
1523
1524 case GL_TEXTURE_VIEW_MIN_LAYER:
1525 if (!ctx->Extensions.ARB_texture_view)
1526 goto invalid_pname;
1527 *params = (GLfloat) obj->MinLayer;
1528 break;
1529
1530 case GL_TEXTURE_VIEW_NUM_LAYERS:
1531 if (!ctx->Extensions.ARB_texture_view)
1532 goto invalid_pname;
1533 *params = (GLfloat) obj->NumLayers;
1534 break;
1535
1536 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
1537 if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external)
1538 goto invalid_pname;
1539 *params = (GLfloat) obj->RequiredTextureImageUnits;
1540 break;
1541
1542 case GL_TEXTURE_SRGB_DECODE_EXT:
1543 if (!ctx->Extensions.EXT_texture_sRGB_decode)
1544 goto invalid_pname;
1545 *params = (GLfloat) obj->Sampler.sRGBDecode;
1546 break;
1547
1548 default:
1549 goto invalid_pname;
1550 }
1551
1552 /* no error if we get here */
1553 _mesa_unlock_texture(ctx, obj);
1554 return;
1555
1556 invalid_pname:
1557 _mesa_unlock_texture(ctx, obj);
1558 _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname);
1559 }
1560
1561
1562 void GLAPIENTRY
1563 _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
1564 {
1565 struct gl_texture_object *obj;
1566 GET_CURRENT_CONTEXT(ctx);
1567
1568 obj = get_texobj(ctx, target, GL_TRUE);
1569 if (!obj)
1570 return;
1571
1572 _mesa_lock_texture(ctx, obj);
1573 switch (pname) {
1574 case GL_TEXTURE_MAG_FILTER:
1575 *params = (GLint) obj->Sampler.MagFilter;
1576 break;
1577 case GL_TEXTURE_MIN_FILTER:
1578 *params = (GLint) obj->Sampler.MinFilter;
1579 break;
1580 case GL_TEXTURE_WRAP_S:
1581 *params = (GLint) obj->Sampler.WrapS;
1582 break;
1583 case GL_TEXTURE_WRAP_T:
1584 *params = (GLint) obj->Sampler.WrapT;
1585 break;
1586 case GL_TEXTURE_WRAP_R:
1587 *params = (GLint) obj->Sampler.WrapR;
1588 break;
1589 case GL_TEXTURE_BORDER_COLOR:
1590 if (!_mesa_is_desktop_gl(ctx))
1591 goto invalid_pname;
1592
1593 {
1594 GLfloat b[4];
1595 b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
1596 b[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
1597 b[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
1598 b[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F);
1599 params[0] = FLOAT_TO_INT(b[0]);
1600 params[1] = FLOAT_TO_INT(b[1]);
1601 params[2] = FLOAT_TO_INT(b[2]);
1602 params[3] = FLOAT_TO_INT(b[3]);
1603 }
1604 break;
1605 case GL_TEXTURE_RESIDENT:
1606 if (ctx->API != API_OPENGL_COMPAT)
1607 goto invalid_pname;
1608
1609 *params = 1;
1610 break;
1611 case GL_TEXTURE_PRIORITY:
1612 if (ctx->API != API_OPENGL_COMPAT)
1613 goto invalid_pname;
1614
1615 *params = FLOAT_TO_INT(obj->Priority);
1616 break;
1617 case GL_TEXTURE_MIN_LOD:
1618 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1619 goto invalid_pname;
1620
1621 *params = (GLint) obj->Sampler.MinLod;
1622 break;
1623 case GL_TEXTURE_MAX_LOD:
1624 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1625 goto invalid_pname;
1626
1627 *params = (GLint) obj->Sampler.MaxLod;
1628 break;
1629 case GL_TEXTURE_BASE_LEVEL:
1630 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1631 goto invalid_pname;
1632
1633 *params = obj->BaseLevel;
1634 break;
1635 case GL_TEXTURE_MAX_LEVEL:
1636 *params = obj->MaxLevel;
1637 break;
1638 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1639 if (!ctx->Extensions.EXT_texture_filter_anisotropic)
1640 goto invalid_pname;
1641 *params = (GLint) obj->Sampler.MaxAnisotropy;
1642 break;
1643 case GL_GENERATE_MIPMAP_SGIS:
1644 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
1645 goto invalid_pname;
1646
1647 *params = (GLint) obj->GenerateMipmap;
1648 break;
1649 case GL_TEXTURE_COMPARE_MODE_ARB:
1650 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
1651 && !_mesa_is_gles3(ctx))
1652 goto invalid_pname;
1653 *params = (GLint) obj->Sampler.CompareMode;
1654 break;
1655 case GL_TEXTURE_COMPARE_FUNC_ARB:
1656 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow)
1657 && !_mesa_is_gles3(ctx))
1658 goto invalid_pname;
1659 *params = (GLint) obj->Sampler.CompareFunc;
1660 break;
1661 case GL_DEPTH_TEXTURE_MODE_ARB:
1662 if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ARB_depth_texture)
1663 goto invalid_pname;
1664 *params = (GLint) obj->DepthMode;
1665 break;
1666 case GL_TEXTURE_LOD_BIAS:
1667 if (_mesa_is_gles(ctx))
1668 goto invalid_pname;
1669
1670 /* GL spec 'Data Conversions' section specifies that floating-point
1671 * value in integer Get function is rounded to nearest integer
1672 */
1673 *params = IROUND(obj->Sampler.LodBias);
1674 break;
1675 case GL_TEXTURE_CROP_RECT_OES:
1676 if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
1677 goto invalid_pname;
1678
1679 params[0] = obj->CropRect[0];
1680 params[1] = obj->CropRect[1];
1681 params[2] = obj->CropRect[2];
1682 params[3] = obj->CropRect[3];
1683 break;
1684 case GL_TEXTURE_SWIZZLE_R_EXT:
1685 case GL_TEXTURE_SWIZZLE_G_EXT:
1686 case GL_TEXTURE_SWIZZLE_B_EXT:
1687 case GL_TEXTURE_SWIZZLE_A_EXT:
1688 if ((!_mesa_is_desktop_gl(ctx)
1689 || !ctx->Extensions.EXT_texture_swizzle)
1690 && !_mesa_is_gles3(ctx))
1691 goto invalid_pname;
1692 *params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
1693 break;
1694
1695 case GL_TEXTURE_SWIZZLE_RGBA_EXT:
1696 if ((!_mesa_is_desktop_gl(ctx)
1697 || !ctx->Extensions.EXT_texture_swizzle)
1698 && !_mesa_is_gles3(ctx))
1699 goto invalid_pname;
1700 COPY_4V(params, obj->Swizzle);
1701 break;
1702
1703 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1704 if (!_mesa_is_desktop_gl(ctx)
1705 || !ctx->Extensions.AMD_seamless_cubemap_per_texture)
1706 goto invalid_pname;
1707 *params = (GLint) obj->Sampler.CubeMapSeamless;
1708 break;
1709
1710 case GL_TEXTURE_IMMUTABLE_FORMAT:
1711 *params = (GLint) obj->Immutable;
1712 break;
1713
1714 case GL_TEXTURE_IMMUTABLE_LEVELS:
1715 if (_mesa_is_gles3(ctx) ||
1716 (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_view))
1717 *params = obj->ImmutableLevels;
1718 else
1719 goto invalid_pname;
1720 break;
1721
1722 case GL_TEXTURE_VIEW_MIN_LEVEL:
1723 if (!ctx->Extensions.ARB_texture_view)
1724 goto invalid_pname;
1725 *params = (GLint) obj->MinLevel;
1726 break;
1727
1728 case GL_TEXTURE_VIEW_NUM_LEVELS:
1729 if (!ctx->Extensions.ARB_texture_view)
1730 goto invalid_pname;
1731 *params = (GLint) obj->NumLevels;
1732 break;
1733
1734 case GL_TEXTURE_VIEW_MIN_LAYER:
1735 if (!ctx->Extensions.ARB_texture_view)
1736 goto invalid_pname;
1737 *params = (GLint) obj->MinLayer;
1738 break;
1739
1740 case GL_TEXTURE_VIEW_NUM_LAYERS:
1741 if (!ctx->Extensions.ARB_texture_view)
1742 goto invalid_pname;
1743 *params = (GLint) obj->NumLayers;
1744 break;
1745
1746 case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
1747 if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external)
1748 goto invalid_pname;
1749 *params = obj->RequiredTextureImageUnits;
1750 break;
1751
1752 case GL_TEXTURE_SRGB_DECODE_EXT:
1753 if (!ctx->Extensions.EXT_texture_sRGB_decode)
1754 goto invalid_pname;
1755 *params = obj->Sampler.sRGBDecode;
1756 break;
1757
1758 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE:
1759 if (!ctx->Extensions.ARB_shader_image_load_store)
1760 goto invalid_pname;
1761 *params = obj->ImageFormatCompatibilityType;
1762 break;
1763
1764 default:
1765 goto invalid_pname;
1766 }
1767
1768 /* no error if we get here */
1769 _mesa_unlock_texture(ctx, obj);
1770 return;
1771
1772 invalid_pname:
1773 _mesa_unlock_texture(ctx, obj);
1774 _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname);
1775 }
1776
1777
1778 /** New in GL 3.0 */
1779 void GLAPIENTRY
1780 _mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
1781 {
1782 struct gl_texture_object *texObj;
1783 GET_CURRENT_CONTEXT(ctx);
1784
1785 texObj = get_texobj(ctx, target, GL_TRUE);
1786 if (!texObj)
1787 return;
1788
1789 switch (pname) {
1790 case GL_TEXTURE_BORDER_COLOR:
1791 COPY_4V(params, texObj->Sampler.BorderColor.i);
1792 break;
1793 default:
1794 _mesa_GetTexParameteriv(target, pname, params);
1795 }
1796 }
1797
1798
1799 /** New in GL 3.0 */
1800 void GLAPIENTRY
1801 _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
1802 {
1803 struct gl_texture_object *texObj;
1804 GET_CURRENT_CONTEXT(ctx);
1805
1806 texObj = get_texobj(ctx, target, GL_TRUE);
1807 if (!texObj)
1808 return;
1809
1810 switch (pname) {
1811 case GL_TEXTURE_BORDER_COLOR:
1812 COPY_4V(params, texObj->Sampler.BorderColor.i);
1813 break;
1814 default:
1815 {
1816 GLint ip[4];
1817 _mesa_GetTexParameteriv(target, pname, ip);
1818 params[0] = ip[0];
1819 if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
1820 pname == GL_TEXTURE_CROP_RECT_OES) {
1821 params[1] = ip[1];
1822 params[2] = ip[2];
1823 params[3] = ip[3];
1824 }
1825 }
1826 }
1827 }