Merge my current work done on the kd++ branch:
[reactos.git] / reactos / dll / opengl / mesa / src / mesa / main / samplerobj.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2011 VMware, Inc. All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24
25 /**
26 * \file samplerobj.c
27 * \brief Functions for the GL_ARB_sampler_objects extension.
28 * \author Brian Paul
29 */
30
31
32 #include "main/glheader.h"
33 #include "main/context.h"
34 #include "main/dispatch.h"
35 #include "main/enums.h"
36 #include "main/hash.h"
37 #include "main/macros.h"
38 #include "main/mfeatures.h"
39 #include "main/mtypes.h"
40 #include "main/samplerobj.h"
41
42
43 static struct gl_sampler_object *
44 _mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name)
45 {
46 if (name == 0)
47 return NULL;
48 else
49 return (struct gl_sampler_object *)
50 _mesa_HashLookup(ctx->Shared->SamplerObjects, name);
51 }
52
53
54 /**
55 * Handle reference counting.
56 */
57 void
58 _mesa_reference_sampler_object(struct gl_context *ctx,
59 struct gl_sampler_object **ptr,
60 struct gl_sampler_object *samp)
61 {
62 if (*ptr == samp)
63 return;
64
65 if (*ptr) {
66 /* Unreference the old sampler */
67 GLboolean deleteFlag = GL_FALSE;
68 struct gl_sampler_object *oldSamp = *ptr;
69
70 /*_glthread_LOCK_MUTEX(oldSamp->Mutex);*/
71 ASSERT(oldSamp->RefCount > 0);
72 oldSamp->RefCount--;
73 #if 0
74 printf("SamplerObj %p %d DECR to %d\n",
75 (void *) oldSamp, oldSamp->Name, oldSamp->RefCount);
76 #endif
77 deleteFlag = (oldSamp->RefCount == 0);
78 /*_glthread_UNLOCK_MUTEX(oldSamp->Mutex);*/
79
80 if (deleteFlag) {
81 ASSERT(ctx->Driver.DeleteSamplerObject);
82 ctx->Driver.DeleteSamplerObject(ctx, oldSamp);
83 }
84
85 *ptr = NULL;
86 }
87 ASSERT(!*ptr);
88
89 if (samp) {
90 /* reference new sampler */
91 /*_glthread_LOCK_MUTEX(samp->Mutex);*/
92 if (samp->RefCount == 0) {
93 /* this sampler's being deleted (look just above) */
94 /* Not sure this can every really happen. Warn if it does. */
95 _mesa_problem(NULL, "referencing deleted sampler object");
96 *ptr = NULL;
97 }
98 else {
99 samp->RefCount++;
100 #if 0
101 printf("SamplerObj %p %d INCR to %d\n",
102 (void *) samp, samp->Name, samp->RefCount);
103 #endif
104 *ptr = samp;
105 }
106 /*_glthread_UNLOCK_MUTEX(samp->Mutex);*/
107 }
108 }
109
110
111 /**
112 * Initialize the fields of the given sampler object.
113 */
114 void
115 _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
116 {
117 sampObj->Name = name;
118 sampObj->RefCount = 1;
119 sampObj->WrapS = GL_REPEAT;
120 sampObj->WrapT = GL_REPEAT;
121 sampObj->WrapR = GL_REPEAT;
122 sampObj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
123 sampObj->MagFilter = GL_LINEAR;
124 sampObj->BorderColor.f[0] = 0.0;
125 sampObj->BorderColor.f[1] = 0.0;
126 sampObj->BorderColor.f[2] = 0.0;
127 sampObj->BorderColor.f[3] = 0.0;
128 sampObj->MinLod = -1000.0F;
129 sampObj->MaxLod = 1000.0F;
130 sampObj->LodBias = 0.0F;
131 sampObj->MaxAnisotropy = 1.0F;
132 sampObj->CompareMode = GL_NONE;
133 sampObj->CompareFunc = GL_LEQUAL;
134 sampObj->CompareFailValue = 0.0;
135 sampObj->sRGBDecode = GL_DECODE_EXT;
136 sampObj->CubeMapSeamless = GL_FALSE;
137 sampObj->DepthMode = 0;
138 }
139
140
141 /**
142 * Fallback for ctx->Driver.NewSamplerObject();
143 */
144 struct gl_sampler_object *
145 _mesa_new_sampler_object(struct gl_context *ctx, GLuint name)
146 {
147 struct gl_sampler_object *sampObj = CALLOC_STRUCT(gl_sampler_object);
148 if (sampObj) {
149 _mesa_init_sampler_object(sampObj, name);
150 }
151 return sampObj;
152 }
153
154
155 /**
156 * Fallback for ctx->Driver.DeleteSamplerObject();
157 */
158 void
159 _mesa_delete_sampler_object(struct gl_context *ctx,
160 struct gl_sampler_object *sampObj)
161 {
162 FREE(sampObj);
163 }
164
165
166 static void GLAPIENTRY
167 _mesa_GenSamplers(GLsizei count, GLuint *samplers)
168 {
169 GET_CURRENT_CONTEXT(ctx);
170 GLuint first;
171 GLint i;
172
173 ASSERT_OUTSIDE_BEGIN_END(ctx);
174
175 if (MESA_VERBOSE & VERBOSE_API)
176 _mesa_debug(ctx, "glGenSamplers(%d)\n", count);
177
178 if (count < 0) {
179 _mesa_error(ctx, GL_INVALID_VALUE, "glGenSamplers");
180 return;
181 }
182
183 if (!samplers)
184 return;
185
186 first = _mesa_HashFindFreeKeyBlock(ctx->Shared->SamplerObjects, count);
187
188 /* Insert the ID and pointer to new sampler object into hash table */
189 for (i = 0; i < count; i++) {
190 struct gl_sampler_object *sampObj =
191 ctx->Driver.NewSamplerObject(ctx, first + i);
192 _mesa_HashInsert(ctx->Shared->SamplerObjects, first + i, sampObj);
193 samplers[i] = first + i;
194 }
195 }
196
197
198 static void GLAPIENTRY
199 _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers)
200 {
201 GET_CURRENT_CONTEXT(ctx);
202 GLsizei i;
203
204 ASSERT_OUTSIDE_BEGIN_END(ctx);
205 FLUSH_VERTICES(ctx, 0);
206
207 if (count < 0) {
208 _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteSamplers(count)");
209 return;
210 }
211
212 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
213
214 for (i = 0; i < count; i++) {
215 if (samplers[i]) {
216 struct gl_sampler_object *sampObj =
217 _mesa_lookup_samplerobj(ctx, samplers[i]);
218 if (sampObj) {
219 /* The ID is immediately freed for re-use */
220 _mesa_HashRemove(ctx->Shared->SamplerObjects, samplers[i]);
221 /* But the object exists until its reference count goes to zero */
222 _mesa_reference_sampler_object(ctx, &sampObj, NULL);
223 }
224 }
225 }
226
227 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
228 }
229
230
231 static GLboolean GLAPIENTRY
232 _mesa_IsSampler(GLuint sampler)
233 {
234 struct gl_sampler_object *sampObj;
235 GET_CURRENT_CONTEXT(ctx);
236
237 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
238
239 if (sampler == 0)
240 return GL_FALSE;
241
242 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
243
244 return sampObj != NULL;
245 }
246
247
248 static void GLAPIENTRY
249 _mesa_BindSampler(GLuint unit, GLuint sampler)
250 {
251 struct gl_sampler_object *sampObj;
252 GET_CURRENT_CONTEXT(ctx);
253
254 if (unit >= ctx->Const.MaxCombinedTextureImageUnits) {
255 _mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit);
256 return;
257 }
258
259 if (sampler == 0) {
260 /* Use the default sampler object, the one contained in the texture
261 * object.
262 */
263 sampObj = NULL;
264 }
265 else {
266 /* user-defined sampler object */
267 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
268 if (!sampObj) {
269 _mesa_error(ctx, GL_INVALID_OPERATION, "glBindSampler(sampler)");
270 return;
271 }
272 }
273
274 if (ctx->Texture.Unit[unit].Sampler != sampObj) {
275 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
276 }
277
278 /* bind new sampler */
279 _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
280 sampObj);
281 }
282
283
284 /**
285 * Check if a coordinate wrap mode is legal.
286 * \return GL_TRUE if legal, GL_FALSE otherwise
287 */
288 static GLboolean
289 validate_texture_wrap_mode(struct gl_context *ctx, GLenum wrap)
290 {
291 const struct gl_extensions * const e = &ctx->Extensions;
292
293 switch (wrap) {
294 case GL_CLAMP:
295 case GL_CLAMP_TO_EDGE:
296 case GL_REPEAT:
297 case GL_MIRRORED_REPEAT:
298 return GL_TRUE;
299 case GL_CLAMP_TO_BORDER:
300 return e->ARB_texture_border_clamp;
301 case GL_MIRROR_CLAMP_EXT:
302 return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp;
303 case GL_MIRROR_CLAMP_TO_EDGE_EXT:
304 return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp;
305 case GL_MIRROR_CLAMP_TO_BORDER_EXT:
306 return e->EXT_texture_mirror_clamp;
307 default:
308 return GL_FALSE;
309 }
310 }
311
312
313 /**
314 * This is called just prior to changing any sampler object state.
315 */
316 static inline void
317 flush(struct gl_context *ctx)
318 {
319 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
320 }
321
322
323 #define INVALID_PARAM 0x100
324 #define INVALID_PNAME 0x101
325 #define INVALID_VALUE 0x102
326
327 static GLuint
328 set_sampler_wrap_s(struct gl_context *ctx, struct gl_sampler_object *samp,
329 GLint param)
330 {
331 if (samp->WrapS == param)
332 return GL_FALSE;
333 if (validate_texture_wrap_mode(ctx, param)) {
334 flush(ctx);
335 samp->WrapS = param;
336 return GL_TRUE;
337 }
338 return INVALID_PARAM;
339 }
340
341
342 static GLuint
343 set_sampler_wrap_t(struct gl_context *ctx, struct gl_sampler_object *samp,
344 GLint param)
345 {
346 if (samp->WrapT == param)
347 return GL_FALSE;
348 if (validate_texture_wrap_mode(ctx, param)) {
349 flush(ctx);
350 samp->WrapT = param;
351 return GL_TRUE;
352 }
353 return INVALID_PARAM;
354 }
355
356
357 static GLuint
358 set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp,
359 GLint param)
360 {
361 if (samp->WrapR == param)
362 return GL_FALSE;
363 if (validate_texture_wrap_mode(ctx, param)) {
364 flush(ctx);
365 samp->WrapR = param;
366 return GL_TRUE;
367 }
368 return INVALID_PARAM;
369 }
370
371
372 static GLuint
373 set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
374 GLint param)
375 {
376 if (samp->MinFilter == param)
377 return GL_FALSE;
378
379 switch (param) {
380 case GL_NEAREST:
381 case GL_LINEAR:
382 case GL_NEAREST_MIPMAP_NEAREST:
383 case GL_LINEAR_MIPMAP_NEAREST:
384 case GL_NEAREST_MIPMAP_LINEAR:
385 case GL_LINEAR_MIPMAP_LINEAR:
386 flush(ctx);
387 samp->MinFilter = param;
388 return GL_TRUE;
389 default:
390 return INVALID_PARAM;
391 }
392 }
393
394
395 static GLuint
396 set_sampler_mag_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
397 GLint param)
398 {
399 if (samp->MagFilter == param)
400 return GL_FALSE;
401
402 switch (param) {
403 case GL_NEAREST:
404 case GL_LINEAR:
405 flush(ctx);
406 samp->MagFilter = param;
407 return GL_TRUE;
408 default:
409 return INVALID_PARAM;
410 }
411 }
412
413
414 static GLuint
415 set_sampler_lod_bias(struct gl_context *ctx, struct gl_sampler_object *samp,
416 GLfloat param)
417 {
418 if (samp->LodBias == param)
419 return GL_FALSE;
420
421 flush(ctx);
422 samp->LodBias = param;
423 return GL_TRUE;
424 }
425
426
427 static GLuint
428 set_sampler_border_colorf(struct gl_context *ctx,
429 struct gl_sampler_object *samp,
430 const GLfloat params[4])
431 {
432 flush(ctx);
433 samp->BorderColor.f[RCOMP] = params[0];
434 samp->BorderColor.f[GCOMP] = params[1];
435 samp->BorderColor.f[BCOMP] = params[2];
436 samp->BorderColor.f[ACOMP] = params[3];
437 return GL_TRUE;
438 }
439
440
441 static GLuint
442 set_sampler_border_colori(struct gl_context *ctx,
443 struct gl_sampler_object *samp,
444 const GLint params[4])
445 {
446 flush(ctx);
447 samp->BorderColor.i[RCOMP] = params[0];
448 samp->BorderColor.i[GCOMP] = params[1];
449 samp->BorderColor.i[BCOMP] = params[2];
450 samp->BorderColor.i[ACOMP] = params[3];
451 return GL_TRUE;
452 }
453
454
455 static GLuint
456 set_sampler_border_colorui(struct gl_context *ctx,
457 struct gl_sampler_object *samp,
458 const GLuint params[4])
459 {
460 flush(ctx);
461 samp->BorderColor.ui[RCOMP] = params[0];
462 samp->BorderColor.ui[GCOMP] = params[1];
463 samp->BorderColor.ui[BCOMP] = params[2];
464 samp->BorderColor.ui[ACOMP] = params[3];
465 return GL_TRUE;
466 }
467
468
469 static GLuint
470 set_sampler_min_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
471 GLfloat param)
472 {
473 if (samp->MinLod == param)
474 return GL_FALSE;
475
476 flush(ctx);
477 samp->MinLod = param;
478 return GL_TRUE;
479 }
480
481
482 static GLuint
483 set_sampler_max_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
484 GLfloat param)
485 {
486 if (samp->MaxLod == param)
487 return GL_FALSE;
488
489 flush(ctx);
490 samp->MaxLod = param;
491 return GL_TRUE;
492 }
493
494
495 static GLuint
496 set_sampler_compare_mode(struct gl_context *ctx,
497 struct gl_sampler_object *samp, GLint param)
498 {
499 if (!ctx->Extensions.ARB_shadow)
500 return INVALID_PNAME;
501
502 if (samp->CompareMode == param)
503 return GL_FALSE;
504
505 if (param == GL_NONE ||
506 param == GL_COMPARE_R_TO_TEXTURE_ARB) {
507 flush(ctx);
508 samp->CompareMode = param;
509 return GL_TRUE;
510 }
511
512 return INVALID_PARAM;
513 }
514
515
516 static GLuint
517 set_sampler_compare_func(struct gl_context *ctx,
518 struct gl_sampler_object *samp, GLint param)
519 {
520 if (!ctx->Extensions.ARB_shadow)
521 return INVALID_PNAME;
522
523 if (samp->CompareFunc == param)
524 return GL_FALSE;
525
526 switch (param) {
527 case GL_LEQUAL:
528 case GL_GEQUAL:
529 flush(ctx);
530 samp->CompareFunc = param;
531 return GL_TRUE;
532 case GL_EQUAL:
533 case GL_NOTEQUAL:
534 case GL_LESS:
535 case GL_GREATER:
536 case GL_ALWAYS:
537 case GL_NEVER:
538 if (ctx->Extensions.EXT_shadow_funcs) {
539 flush(ctx);
540 samp->CompareFunc = param;
541 return GL_TRUE;
542 }
543 /* fall-through */
544 default:
545 return INVALID_PARAM;
546 }
547 }
548
549
550 static GLuint
551 set_sampler_max_anisotropy(struct gl_context *ctx,
552 struct gl_sampler_object *samp, GLfloat param)
553 {
554 if (!ctx->Extensions.EXT_texture_filter_anisotropic)
555 return INVALID_PNAME;
556
557 if (samp->MaxAnisotropy == param)
558 return GL_FALSE;
559
560 if (param < 1.0)
561 return INVALID_VALUE;
562
563 flush(ctx);
564 /* clamp to max, that's what NVIDIA does */
565 samp->MaxAnisotropy = MIN2(param, ctx->Const.MaxTextureMaxAnisotropy);
566 return GL_TRUE;
567 }
568
569
570 static GLuint
571 set_sampler_cube_map_seamless(struct gl_context *ctx,
572 struct gl_sampler_object *samp, GLboolean param)
573 {
574 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
575 return INVALID_PNAME;
576
577 if (samp->CubeMapSeamless == param)
578 return GL_FALSE;
579
580 if (param != GL_TRUE && param != GL_FALSE)
581 return INVALID_VALUE;
582
583 flush(ctx);
584 samp->CubeMapSeamless = param;
585 return GL_TRUE;
586 }
587
588
589 static void GLAPIENTRY
590 _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
591 {
592 struct gl_sampler_object *sampObj;
593 GLuint res;
594 GET_CURRENT_CONTEXT(ctx);
595
596 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
597 if (!sampObj) {
598 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(sampler %u)",
599 sampler);
600 return;
601 }
602
603 switch (pname) {
604 case GL_TEXTURE_WRAP_S:
605 res = set_sampler_wrap_s(ctx, sampObj, param);
606 break;
607 case GL_TEXTURE_WRAP_T:
608 res = set_sampler_wrap_t(ctx, sampObj, param);
609 break;
610 case GL_TEXTURE_WRAP_R:
611 res = set_sampler_wrap_r(ctx, sampObj, param);
612 break;
613 case GL_TEXTURE_MIN_FILTER:
614 res = set_sampler_min_filter(ctx, sampObj, param);
615 break;
616 case GL_TEXTURE_MAG_FILTER:
617 res = set_sampler_mag_filter(ctx, sampObj, param);
618 break;
619 case GL_TEXTURE_MIN_LOD:
620 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) param);
621 break;
622 case GL_TEXTURE_MAX_LOD:
623 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) param);
624 break;
625 case GL_TEXTURE_LOD_BIAS:
626 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) param);
627 break;
628 case GL_TEXTURE_COMPARE_MODE:
629 res = set_sampler_compare_mode(ctx, sampObj, param);
630 break;
631 case GL_TEXTURE_COMPARE_FUNC:
632 res = set_sampler_compare_func(ctx, sampObj, param);
633 break;
634 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
635 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) param);
636 break;
637 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
638 res = set_sampler_cube_map_seamless(ctx, sampObj, param);
639 break;
640 case GL_TEXTURE_BORDER_COLOR:
641 /* fall-through */
642 default:
643 res = INVALID_PNAME;
644 }
645
646 switch (res) {
647 case GL_FALSE:
648 /* no change */
649 break;
650 case GL_TRUE:
651 /* state change - we do nothing special at this time */
652 break;
653 case INVALID_PNAME:
654 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(pname=%s)\n",
655 _mesa_lookup_enum_by_nr(pname));
656 break;
657 case INVALID_PARAM:
658 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(param=%d)\n",
659 param);
660 break;
661 case INVALID_VALUE:
662 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(param=%d)\n",
663 param);
664 break;
665 default:
666 ;
667 }
668 }
669
670
671 static void GLAPIENTRY
672 _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
673 {
674 struct gl_sampler_object *sampObj;
675 GLuint res;
676 GET_CURRENT_CONTEXT(ctx);
677
678 ASSERT_OUTSIDE_BEGIN_END(ctx);
679
680 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
681 if (!sampObj) {
682 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(sampler %u)",
683 sampler);
684 return;
685 }
686
687 switch (pname) {
688 case GL_TEXTURE_WRAP_S:
689 res = set_sampler_wrap_s(ctx, sampObj, (GLint) param);
690 break;
691 case GL_TEXTURE_WRAP_T:
692 res = set_sampler_wrap_t(ctx, sampObj, (GLint) param);
693 break;
694 case GL_TEXTURE_WRAP_R:
695 res = set_sampler_wrap_r(ctx, sampObj, (GLint) param);
696 break;
697 case GL_TEXTURE_MIN_FILTER:
698 res = set_sampler_min_filter(ctx, sampObj, (GLint) param);
699 break;
700 case GL_TEXTURE_MAG_FILTER:
701 res = set_sampler_mag_filter(ctx, sampObj, (GLint) param);
702 break;
703 case GL_TEXTURE_MIN_LOD:
704 res = set_sampler_min_lod(ctx, sampObj, param);
705 break;
706 case GL_TEXTURE_MAX_LOD:
707 res = set_sampler_max_lod(ctx, sampObj, param);
708 break;
709 case GL_TEXTURE_LOD_BIAS:
710 res = set_sampler_lod_bias(ctx, sampObj, param);
711 break;
712 case GL_TEXTURE_COMPARE_MODE:
713 res = set_sampler_compare_mode(ctx, sampObj, (GLint) param);
714 break;
715 case GL_TEXTURE_COMPARE_FUNC:
716 res = set_sampler_compare_func(ctx, sampObj, (GLint) param);
717 break;
718 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
719 res = set_sampler_max_anisotropy(ctx, sampObj, param);
720 break;
721 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
722 res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param);
723 break;
724 case GL_TEXTURE_BORDER_COLOR:
725 /* fall-through */
726 default:
727 res = INVALID_PNAME;
728 }
729
730 switch (res) {
731 case GL_FALSE:
732 /* no change */
733 break;
734 case GL_TRUE:
735 /* state change - we do nothing special at this time */
736 break;
737 case INVALID_PNAME:
738 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(pname=%s)\n",
739 _mesa_lookup_enum_by_nr(pname));
740 break;
741 case INVALID_PARAM:
742 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(param=%f)\n",
743 param);
744 break;
745 case INVALID_VALUE:
746 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(param=%f)\n",
747 param);
748 break;
749 default:
750 ;
751 }
752 }
753
754 static void GLAPIENTRY
755 _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
756 {
757 struct gl_sampler_object *sampObj;
758 GLuint res;
759 GET_CURRENT_CONTEXT(ctx);
760
761 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
762 if (!sampObj) {
763 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(sampler %u)",
764 sampler);
765 return;
766 }
767
768 switch (pname) {
769 case GL_TEXTURE_WRAP_S:
770 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
771 break;
772 case GL_TEXTURE_WRAP_T:
773 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
774 break;
775 case GL_TEXTURE_WRAP_R:
776 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
777 break;
778 case GL_TEXTURE_MIN_FILTER:
779 res = set_sampler_min_filter(ctx, sampObj, params[0]);
780 break;
781 case GL_TEXTURE_MAG_FILTER:
782 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
783 break;
784 case GL_TEXTURE_MIN_LOD:
785 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
786 break;
787 case GL_TEXTURE_MAX_LOD:
788 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
789 break;
790 case GL_TEXTURE_LOD_BIAS:
791 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
792 break;
793 case GL_TEXTURE_COMPARE_MODE:
794 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
795 break;
796 case GL_TEXTURE_COMPARE_FUNC:
797 res = set_sampler_compare_func(ctx, sampObj, params[0]);
798 break;
799 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
800 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
801 break;
802 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
803 res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
804 break;
805 case GL_TEXTURE_BORDER_COLOR:
806 {
807 GLfloat c[4];
808 c[0] = INT_TO_FLOAT(params[0]);
809 c[1] = INT_TO_FLOAT(params[1]);
810 c[2] = INT_TO_FLOAT(params[2]);
811 c[3] = INT_TO_FLOAT(params[3]);
812 res = set_sampler_border_colorf(ctx, sampObj, c);
813 }
814 break;
815 default:
816 res = INVALID_PNAME;
817 }
818
819 switch (res) {
820 case GL_FALSE:
821 /* no change */
822 break;
823 case GL_TRUE:
824 /* state change - we do nothing special at this time */
825 break;
826 case INVALID_PNAME:
827 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(pname=%s)\n",
828 _mesa_lookup_enum_by_nr(pname));
829 break;
830 case INVALID_PARAM:
831 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(param=%d)\n",
832 params[0]);
833 break;
834 case INVALID_VALUE:
835 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(param=%d)\n",
836 params[0]);
837 break;
838 default:
839 ;
840 }
841 }
842
843 static void GLAPIENTRY
844 _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
845 {
846 struct gl_sampler_object *sampObj;
847 GLuint res;
848 GET_CURRENT_CONTEXT(ctx);
849
850 ASSERT_OUTSIDE_BEGIN_END(ctx);
851
852 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
853 if (!sampObj) {
854 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(sampler %u)",
855 sampler);
856 return;
857 }
858
859 switch (pname) {
860 case GL_TEXTURE_WRAP_S:
861 res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]);
862 break;
863 case GL_TEXTURE_WRAP_T:
864 res = set_sampler_wrap_t(ctx, sampObj, (GLint) params[0]);
865 break;
866 case GL_TEXTURE_WRAP_R:
867 res = set_sampler_wrap_r(ctx, sampObj, (GLint) params[0]);
868 break;
869 case GL_TEXTURE_MIN_FILTER:
870 res = set_sampler_min_filter(ctx, sampObj, (GLint) params[0]);
871 break;
872 case GL_TEXTURE_MAG_FILTER:
873 res = set_sampler_mag_filter(ctx, sampObj, (GLint) params[0]);
874 break;
875 case GL_TEXTURE_MIN_LOD:
876 res = set_sampler_min_lod(ctx, sampObj, params[0]);
877 break;
878 case GL_TEXTURE_MAX_LOD:
879 res = set_sampler_max_lod(ctx, sampObj, params[0]);
880 break;
881 case GL_TEXTURE_LOD_BIAS:
882 res = set_sampler_lod_bias(ctx, sampObj, params[0]);
883 break;
884 case GL_TEXTURE_COMPARE_MODE:
885 res = set_sampler_compare_mode(ctx, sampObj, (GLint) params[0]);
886 break;
887 case GL_TEXTURE_COMPARE_FUNC:
888 res = set_sampler_compare_func(ctx, sampObj, (GLint) params[0]);
889 break;
890 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
891 res = set_sampler_max_anisotropy(ctx, sampObj, params[0]);
892 break;
893 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
894 res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]);
895 break;
896 case GL_TEXTURE_BORDER_COLOR:
897 res = set_sampler_border_colorf(ctx, sampObj, params);
898 break;
899 default:
900 res = INVALID_PNAME;
901 }
902
903 switch (res) {
904 case GL_FALSE:
905 /* no change */
906 break;
907 case GL_TRUE:
908 /* state change - we do nothing special at this time */
909 break;
910 case INVALID_PNAME:
911 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(pname=%s)\n",
912 _mesa_lookup_enum_by_nr(pname));
913 break;
914 case INVALID_PARAM:
915 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(param=%f)\n",
916 params[0]);
917 break;
918 case INVALID_VALUE:
919 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(param=%f)\n",
920 params[0]);
921 break;
922 default:
923 ;
924 }
925 }
926
927 static void GLAPIENTRY
928 _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
929 {
930 struct gl_sampler_object *sampObj;
931 GLuint res;
932 GET_CURRENT_CONTEXT(ctx);
933
934 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
935 if (!sampObj) {
936 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(sampler %u)",
937 sampler);
938 return;
939 }
940
941 switch (pname) {
942 case GL_TEXTURE_WRAP_S:
943 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
944 break;
945 case GL_TEXTURE_WRAP_T:
946 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
947 break;
948 case GL_TEXTURE_WRAP_R:
949 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
950 break;
951 case GL_TEXTURE_MIN_FILTER:
952 res = set_sampler_min_filter(ctx, sampObj, params[0]);
953 break;
954 case GL_TEXTURE_MAG_FILTER:
955 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
956 break;
957 case GL_TEXTURE_MIN_LOD:
958 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
959 break;
960 case GL_TEXTURE_MAX_LOD:
961 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
962 break;
963 case GL_TEXTURE_LOD_BIAS:
964 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
965 break;
966 case GL_TEXTURE_COMPARE_MODE:
967 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
968 break;
969 case GL_TEXTURE_COMPARE_FUNC:
970 res = set_sampler_compare_func(ctx, sampObj, params[0]);
971 break;
972 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
973 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
974 break;
975 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
976 res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
977 break;
978 case GL_TEXTURE_BORDER_COLOR:
979 res = set_sampler_border_colori(ctx, sampObj, params);
980 break;
981 default:
982 res = INVALID_PNAME;
983 }
984
985 switch (res) {
986 case GL_FALSE:
987 /* no change */
988 break;
989 case GL_TRUE:
990 /* state change - we do nothing special at this time */
991 break;
992 case INVALID_PNAME:
993 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(pname=%s)\n",
994 _mesa_lookup_enum_by_nr(pname));
995 break;
996 case INVALID_PARAM:
997 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(param=%d)\n",
998 params[0]);
999 break;
1000 case INVALID_VALUE:
1001 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(param=%d)\n",
1002 params[0]);
1003 break;
1004 default:
1005 ;
1006 }
1007 }
1008
1009
1010 static void GLAPIENTRY
1011 _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
1012 {
1013 struct gl_sampler_object *sampObj;
1014 GLuint res;
1015 GET_CURRENT_CONTEXT(ctx);
1016
1017 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1018 if (!sampObj) {
1019 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(sampler %u)",
1020 sampler);
1021 return;
1022 }
1023
1024 switch (pname) {
1025 case GL_TEXTURE_WRAP_S:
1026 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
1027 break;
1028 case GL_TEXTURE_WRAP_T:
1029 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
1030 break;
1031 case GL_TEXTURE_WRAP_R:
1032 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
1033 break;
1034 case GL_TEXTURE_MIN_FILTER:
1035 res = set_sampler_min_filter(ctx, sampObj, params[0]);
1036 break;
1037 case GL_TEXTURE_MAG_FILTER:
1038 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
1039 break;
1040 case GL_TEXTURE_MIN_LOD:
1041 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
1042 break;
1043 case GL_TEXTURE_MAX_LOD:
1044 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
1045 break;
1046 case GL_TEXTURE_LOD_BIAS:
1047 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
1048 break;
1049 case GL_TEXTURE_COMPARE_MODE:
1050 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
1051 break;
1052 case GL_TEXTURE_COMPARE_FUNC:
1053 res = set_sampler_compare_func(ctx, sampObj, params[0]);
1054 break;
1055 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1056 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
1057 break;
1058 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1059 res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
1060 break;
1061 case GL_TEXTURE_BORDER_COLOR:
1062 res = set_sampler_border_colorui(ctx, sampObj, params);
1063 break;
1064 default:
1065 res = INVALID_PNAME;
1066 }
1067
1068 switch (res) {
1069 case GL_FALSE:
1070 /* no change */
1071 break;
1072 case GL_TRUE:
1073 /* state change - we do nothing special at this time */
1074 break;
1075 case INVALID_PNAME:
1076 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(pname=%s)\n",
1077 _mesa_lookup_enum_by_nr(pname));
1078 break;
1079 case INVALID_PARAM:
1080 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(param=%u)\n",
1081 params[0]);
1082 break;
1083 case INVALID_VALUE:
1084 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(param=%u)\n",
1085 params[0]);
1086 break;
1087 default:
1088 ;
1089 }
1090 }
1091
1092
1093 static void GLAPIENTRY
1094 _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
1095 {
1096 struct gl_sampler_object *sampObj;
1097 GET_CURRENT_CONTEXT(ctx);
1098
1099 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1100 if (!sampObj) {
1101 _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameteriv(sampler %u)",
1102 sampler);
1103 return;
1104 }
1105
1106 switch (pname) {
1107 case GL_TEXTURE_WRAP_S:
1108 *params = sampObj->WrapS;
1109 break;
1110 case GL_TEXTURE_WRAP_T:
1111 *params = sampObj->WrapT;
1112 break;
1113 case GL_TEXTURE_WRAP_R:
1114 *params = sampObj->WrapR;
1115 break;
1116 case GL_TEXTURE_MIN_FILTER:
1117 *params = sampObj->MinFilter;
1118 break;
1119 case GL_TEXTURE_MAG_FILTER:
1120 *params = sampObj->MagFilter;
1121 break;
1122 case GL_TEXTURE_MIN_LOD:
1123 *params = (GLint) sampObj->MinLod;
1124 break;
1125 case GL_TEXTURE_MAX_LOD:
1126 *params = (GLint) sampObj->MaxLod;
1127 break;
1128 case GL_TEXTURE_LOD_BIAS:
1129 *params = (GLint) sampObj->LodBias;
1130 break;
1131 case GL_TEXTURE_COMPARE_MODE:
1132 if (!ctx->Extensions.ARB_shadow)
1133 goto invalid_pname;
1134 *params = sampObj->CompareMode;
1135 break;
1136 case GL_TEXTURE_COMPARE_FUNC:
1137 if (!ctx->Extensions.ARB_shadow)
1138 goto invalid_pname;
1139 *params = sampObj->CompareFunc;
1140 break;
1141 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1142 *params = (GLint) sampObj->MaxAnisotropy;
1143 break;
1144 case GL_TEXTURE_BORDER_COLOR:
1145 params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]);
1146 params[1] = FLOAT_TO_INT(sampObj->BorderColor.f[1]);
1147 params[2] = FLOAT_TO_INT(sampObj->BorderColor.f[2]);
1148 params[3] = FLOAT_TO_INT(sampObj->BorderColor.f[3]);
1149 break;
1150 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1151 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1152 goto invalid_pname;
1153 *params = sampObj->CubeMapSeamless;
1154 break;
1155 default:
1156 goto invalid_pname;
1157 }
1158 return;
1159
1160 invalid_pname:
1161 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameteriv(pname=%s)",
1162 _mesa_lookup_enum_by_nr(pname));
1163 }
1164
1165
1166 static void GLAPIENTRY
1167 _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
1168 {
1169 struct gl_sampler_object *sampObj;
1170 GET_CURRENT_CONTEXT(ctx);
1171
1172 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1173 if (!sampObj) {
1174 _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameterfv(sampler %u)",
1175 sampler);
1176 return;
1177 }
1178
1179 switch (pname) {
1180 case GL_TEXTURE_WRAP_S:
1181 *params = (GLfloat) sampObj->WrapS;
1182 break;
1183 case GL_TEXTURE_WRAP_T:
1184 *params = (GLfloat) sampObj->WrapT;
1185 break;
1186 case GL_TEXTURE_WRAP_R:
1187 *params = (GLfloat) sampObj->WrapR;
1188 break;
1189 case GL_TEXTURE_MIN_FILTER:
1190 *params = (GLfloat) sampObj->MinFilter;
1191 break;
1192 case GL_TEXTURE_MAG_FILTER:
1193 *params = (GLfloat) sampObj->MagFilter;
1194 break;
1195 case GL_TEXTURE_MIN_LOD:
1196 *params = sampObj->MinLod;
1197 break;
1198 case GL_TEXTURE_MAX_LOD:
1199 *params = sampObj->MaxLod;
1200 break;
1201 case GL_TEXTURE_LOD_BIAS:
1202 *params = sampObj->LodBias;
1203 break;
1204 case GL_TEXTURE_COMPARE_MODE:
1205 if (!ctx->Extensions.ARB_shadow)
1206 goto invalid_pname;
1207 *params = (GLfloat) sampObj->CompareMode;
1208 break;
1209 case GL_TEXTURE_COMPARE_FUNC:
1210 if (!ctx->Extensions.ARB_shadow)
1211 goto invalid_pname;
1212 *params = (GLfloat) sampObj->CompareFunc;
1213 break;
1214 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1215 *params = sampObj->MaxAnisotropy;
1216 break;
1217 case GL_TEXTURE_BORDER_COLOR:
1218 params[0] = sampObj->BorderColor.f[0];
1219 params[1] = sampObj->BorderColor.f[1];
1220 params[2] = sampObj->BorderColor.f[2];
1221 params[3] = sampObj->BorderColor.f[3];
1222 break;
1223 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1224 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1225 goto invalid_pname;
1226 *params = (GLfloat) sampObj->CubeMapSeamless;
1227 break;
1228 default:
1229 goto invalid_pname;
1230 }
1231 return;
1232
1233 invalid_pname:
1234 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterfv(pname=%s)",
1235 _mesa_lookup_enum_by_nr(pname));
1236 }
1237
1238
1239 static void GLAPIENTRY
1240 _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
1241 {
1242 struct gl_sampler_object *sampObj;
1243 GET_CURRENT_CONTEXT(ctx);
1244
1245 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1246 if (!sampObj) {
1247 _mesa_error(ctx, GL_INVALID_VALUE,
1248 "glGetSamplerParameterIiv(sampler %u)",
1249 sampler);
1250 return;
1251 }
1252
1253 switch (pname) {
1254 case GL_TEXTURE_WRAP_S:
1255 *params = sampObj->WrapS;
1256 break;
1257 case GL_TEXTURE_WRAP_T:
1258 *params = sampObj->WrapT;
1259 break;
1260 case GL_TEXTURE_WRAP_R:
1261 *params = sampObj->WrapR;
1262 break;
1263 case GL_TEXTURE_MIN_FILTER:
1264 *params = sampObj->MinFilter;
1265 break;
1266 case GL_TEXTURE_MAG_FILTER:
1267 *params = sampObj->MagFilter;
1268 break;
1269 case GL_TEXTURE_MIN_LOD:
1270 *params = (GLint) sampObj->MinLod;
1271 break;
1272 case GL_TEXTURE_MAX_LOD:
1273 *params = (GLint) sampObj->MaxLod;
1274 break;
1275 case GL_TEXTURE_LOD_BIAS:
1276 *params = (GLint) sampObj->LodBias;
1277 break;
1278 case GL_TEXTURE_COMPARE_MODE:
1279 if (!ctx->Extensions.ARB_shadow)
1280 goto invalid_pname;
1281 *params = sampObj->CompareMode;
1282 break;
1283 case GL_TEXTURE_COMPARE_FUNC:
1284 if (!ctx->Extensions.ARB_shadow)
1285 goto invalid_pname;
1286 *params = sampObj->CompareFunc;
1287 break;
1288 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1289 *params = (GLint) sampObj->MaxAnisotropy;
1290 break;
1291 case GL_TEXTURE_BORDER_COLOR:
1292 params[0] = sampObj->BorderColor.i[0];
1293 params[1] = sampObj->BorderColor.i[1];
1294 params[2] = sampObj->BorderColor.i[2];
1295 params[3] = sampObj->BorderColor.i[3];
1296 break;
1297 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1298 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1299 goto invalid_pname;
1300 *params = sampObj->CubeMapSeamless;
1301 break;
1302 default:
1303 goto invalid_pname;
1304 }
1305 return;
1306
1307 invalid_pname:
1308 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIiv(pname=%s)",
1309 _mesa_lookup_enum_by_nr(pname));
1310 }
1311
1312
1313 static void GLAPIENTRY
1314 _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
1315 {
1316 struct gl_sampler_object *sampObj;
1317 GET_CURRENT_CONTEXT(ctx);
1318
1319 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1320 if (!sampObj) {
1321 _mesa_error(ctx, GL_INVALID_VALUE,
1322 "glGetSamplerParameterIuiv(sampler %u)",
1323 sampler);
1324 return;
1325 }
1326
1327 switch (pname) {
1328 case GL_TEXTURE_WRAP_S:
1329 *params = sampObj->WrapS;
1330 break;
1331 case GL_TEXTURE_WRAP_T:
1332 *params = sampObj->WrapT;
1333 break;
1334 case GL_TEXTURE_WRAP_R:
1335 *params = sampObj->WrapR;
1336 break;
1337 case GL_TEXTURE_MIN_FILTER:
1338 *params = sampObj->MinFilter;
1339 break;
1340 case GL_TEXTURE_MAG_FILTER:
1341 *params = sampObj->MagFilter;
1342 break;
1343 case GL_TEXTURE_MIN_LOD:
1344 *params = (GLuint) sampObj->MinLod;
1345 break;
1346 case GL_TEXTURE_MAX_LOD:
1347 *params = (GLuint) sampObj->MaxLod;
1348 break;
1349 case GL_TEXTURE_LOD_BIAS:
1350 *params = (GLuint) sampObj->LodBias;
1351 break;
1352 case GL_TEXTURE_COMPARE_MODE:
1353 if (!ctx->Extensions.ARB_shadow)
1354 goto invalid_pname;
1355 *params = sampObj->CompareMode;
1356 break;
1357 case GL_TEXTURE_COMPARE_FUNC:
1358 if (!ctx->Extensions.ARB_shadow)
1359 goto invalid_pname;
1360 *params = sampObj->CompareFunc;
1361 break;
1362 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1363 *params = (GLuint) sampObj->MaxAnisotropy;
1364 break;
1365 case GL_TEXTURE_BORDER_COLOR:
1366 params[0] = sampObj->BorderColor.ui[0];
1367 params[1] = sampObj->BorderColor.ui[1];
1368 params[2] = sampObj->BorderColor.ui[2];
1369 params[3] = sampObj->BorderColor.ui[3];
1370 break;
1371 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1372 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1373 goto invalid_pname;
1374 *params = sampObj->CubeMapSeamless;
1375 break;
1376 default:
1377 goto invalid_pname;
1378 }
1379 return;
1380
1381 invalid_pname:
1382 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIuiv(pname=%s)",
1383 _mesa_lookup_enum_by_nr(pname));
1384 }
1385
1386
1387 void
1388 _mesa_init_sampler_object_functions(struct dd_function_table *driver)
1389 {
1390 driver->NewSamplerObject = _mesa_new_sampler_object;
1391 driver->DeleteSamplerObject = _mesa_delete_sampler_object;
1392 }
1393
1394
1395 void
1396 _mesa_init_sampler_object_dispatch(struct _glapi_table *disp)
1397 {
1398 SET_GenSamplers(disp, _mesa_GenSamplers);
1399 SET_DeleteSamplers(disp, _mesa_DeleteSamplers);
1400 SET_IsSampler(disp, _mesa_IsSampler);
1401 SET_BindSampler(disp, _mesa_BindSampler);
1402 SET_SamplerParameteri(disp, _mesa_SamplerParameteri);
1403 SET_SamplerParameterf(disp, _mesa_SamplerParameterf);
1404 SET_SamplerParameteriv(disp, _mesa_SamplerParameteriv);
1405 SET_SamplerParameterfv(disp, _mesa_SamplerParameterfv);
1406 SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv);
1407 SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv);
1408 SET_GetSamplerParameteriv(disp, _mesa_GetSamplerParameteriv);
1409 SET_GetSamplerParameterfv(disp, _mesa_GetSamplerParameterfv);
1410 SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv);
1411 SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv);
1412 }