6e53f641e952ab0f36c4e98ccb9803320e89b55e
[mesa.git] / 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_FALSE;
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.MaxTextureImageUnits) {
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 return GL_TRUE;
298 case GL_CLAMP_TO_BORDER:
299 return e->ARB_texture_border_clamp;
300 case GL_MIRRORED_REPEAT:
301 return e->ARB_texture_mirrored_repeat;
302 case GL_MIRROR_CLAMP_EXT:
303 return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp;
304 case GL_MIRROR_CLAMP_TO_EDGE_EXT:
305 return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp;
306 case GL_MIRROR_CLAMP_TO_BORDER_EXT:
307 return e->EXT_texture_mirror_clamp;
308 default:
309 return GL_FALSE;
310 }
311 }
312
313
314 /**
315 * This is called just prior to changing any sampler object state.
316 */
317 static INLINE void
318 flush(struct gl_context *ctx)
319 {
320 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
321 }
322
323
324 #define INVALID_PARAM 0x100
325 #define INVALID_PNAME 0x101
326 #define INVALID_VALUE 0x102
327
328 static GLuint
329 set_sampler_wrap_s(struct gl_context *ctx, struct gl_sampler_object *samp,
330 GLint param)
331 {
332 if (samp->WrapS == param)
333 return GL_FALSE;
334 if (validate_texture_wrap_mode(ctx, param)) {
335 flush(ctx);
336 samp->WrapS = param;
337 return GL_TRUE;
338 }
339 return INVALID_PARAM;
340 }
341
342
343 static GLuint
344 set_sampler_wrap_t(struct gl_context *ctx, struct gl_sampler_object *samp,
345 GLint param)
346 {
347 if (samp->WrapT == param)
348 return GL_FALSE;
349 if (validate_texture_wrap_mode(ctx, param)) {
350 flush(ctx);
351 samp->WrapT = param;
352 return GL_TRUE;
353 }
354 return INVALID_PARAM;
355 }
356
357
358 static GLuint
359 set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp,
360 GLint param)
361 {
362 if (samp->WrapR == param)
363 return GL_FALSE;
364 if (validate_texture_wrap_mode(ctx, param)) {
365 flush(ctx);
366 samp->WrapR = param;
367 return GL_TRUE;
368 }
369 return INVALID_PARAM;
370 }
371
372
373 static GLuint
374 set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
375 GLint param)
376 {
377 if (samp->MinFilter == param)
378 return GL_FALSE;
379
380 switch (param) {
381 case GL_NEAREST:
382 case GL_LINEAR:
383 case GL_NEAREST_MIPMAP_NEAREST:
384 case GL_LINEAR_MIPMAP_NEAREST:
385 case GL_NEAREST_MIPMAP_LINEAR:
386 case GL_LINEAR_MIPMAP_LINEAR:
387 flush(ctx);
388 samp->MinFilter = param;
389 return GL_TRUE;
390 default:
391 return INVALID_PARAM;
392 }
393 }
394
395
396 static GLuint
397 set_sampler_mag_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
398 GLint param)
399 {
400 if (samp->MagFilter == param)
401 return GL_FALSE;
402
403 switch (param) {
404 case GL_NEAREST:
405 case GL_LINEAR:
406 flush(ctx);
407 samp->MagFilter = param;
408 return GL_TRUE;
409 default:
410 return INVALID_PARAM;
411 }
412 }
413
414
415 static GLuint
416 set_sampler_lod_bias(struct gl_context *ctx, struct gl_sampler_object *samp,
417 GLfloat param)
418 {
419 if (samp->LodBias == param)
420 return GL_FALSE;
421
422 flush(ctx);
423 samp->LodBias = param;
424 return GL_TRUE;
425 }
426
427
428 static GLuint
429 set_sampler_border_colorf(struct gl_context *ctx,
430 struct gl_sampler_object *samp,
431 const GLfloat params[4])
432 {
433 flush(ctx);
434 samp->BorderColor.f[RCOMP] = params[0];
435 samp->BorderColor.f[GCOMP] = params[1];
436 samp->BorderColor.f[BCOMP] = params[2];
437 samp->BorderColor.f[ACOMP] = params[3];
438 return GL_TRUE;
439 }
440
441
442 static GLuint
443 set_sampler_border_colori(struct gl_context *ctx,
444 struct gl_sampler_object *samp,
445 const GLint params[4])
446 {
447 flush(ctx);
448 samp->BorderColor.i[RCOMP] = params[0];
449 samp->BorderColor.i[GCOMP] = params[1];
450 samp->BorderColor.i[BCOMP] = params[2];
451 samp->BorderColor.i[ACOMP] = params[3];
452 return GL_TRUE;
453 }
454
455
456 static GLuint
457 set_sampler_border_colorui(struct gl_context *ctx,
458 struct gl_sampler_object *samp,
459 const GLuint params[4])
460 {
461 flush(ctx);
462 samp->BorderColor.ui[RCOMP] = params[0];
463 samp->BorderColor.ui[GCOMP] = params[1];
464 samp->BorderColor.ui[BCOMP] = params[2];
465 samp->BorderColor.ui[ACOMP] = params[3];
466 return GL_TRUE;
467 }
468
469
470 static GLuint
471 set_sampler_min_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
472 GLfloat param)
473 {
474 if (samp->MinLod == param)
475 return GL_FALSE;
476
477 flush(ctx);
478 samp->MinLod = param;
479 return GL_TRUE;
480 }
481
482
483 static GLuint
484 set_sampler_max_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
485 GLfloat param)
486 {
487 if (samp->MaxLod == param)
488 return GL_FALSE;
489
490 flush(ctx);
491 samp->MaxLod = param;
492 return GL_TRUE;
493 }
494
495
496 static GLuint
497 set_sampler_compare_mode(struct gl_context *ctx,
498 struct gl_sampler_object *samp, GLint param)
499 {
500 if (!ctx->Extensions.ARB_shadow)
501 return INVALID_PNAME;
502
503 if (samp->CompareMode == param)
504 return GL_FALSE;
505
506 if (param == GL_NONE ||
507 param == GL_COMPARE_R_TO_TEXTURE_ARB) {
508 flush(ctx);
509 samp->CompareMode = param;
510 return GL_TRUE;
511 }
512
513 return INVALID_PARAM;
514 }
515
516
517 static GLuint
518 set_sampler_compare_func(struct gl_context *ctx,
519 struct gl_sampler_object *samp, GLint param)
520 {
521 if (!ctx->Extensions.ARB_shadow)
522 return INVALID_PNAME;
523
524 if (samp->CompareFunc == param)
525 return GL_FALSE;
526
527 switch (param) {
528 case GL_LEQUAL:
529 case GL_GEQUAL:
530 flush(ctx);
531 samp->CompareFunc = param;
532 return GL_TRUE;
533 case GL_EQUAL:
534 case GL_NOTEQUAL:
535 case GL_LESS:
536 case GL_GREATER:
537 case GL_ALWAYS:
538 case GL_NEVER:
539 if (ctx->Extensions.EXT_shadow_funcs) {
540 flush(ctx);
541 samp->CompareFunc = param;
542 return GL_TRUE;
543 }
544 /* fall-through */
545 default:
546 return INVALID_PARAM;
547 }
548 }
549
550
551 static GLuint
552 set_sampler_max_anisotropy(struct gl_context *ctx,
553 struct gl_sampler_object *samp, GLfloat param)
554 {
555 if (!ctx->Extensions.EXT_texture_filter_anisotropic)
556 return INVALID_PNAME;
557
558 if (samp->MaxAnisotropy == param)
559 return GL_FALSE;
560
561 if (param < 1.0)
562 return INVALID_VALUE;
563
564 flush(ctx);
565 /* clamp to max, that's what NVIDIA does */
566 samp->MaxAnisotropy = MIN2(param, ctx->Const.MaxTextureMaxAnisotropy);
567 return GL_TRUE;
568 }
569
570
571 static void GLAPIENTRY
572 _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
573 {
574 struct gl_sampler_object *sampObj;
575 GLuint res;
576 GET_CURRENT_CONTEXT(ctx);
577
578 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
579 if (!sampObj) {
580 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(sampler %u)",
581 sampler);
582 return;
583 }
584
585 switch (pname) {
586 case GL_TEXTURE_WRAP_S:
587 res = set_sampler_wrap_s(ctx, sampObj, param);
588 break;
589 case GL_TEXTURE_WRAP_T:
590 res = set_sampler_wrap_t(ctx, sampObj, param);
591 break;
592 case GL_TEXTURE_WRAP_R:
593 res = set_sampler_wrap_r(ctx, sampObj, param);
594 break;
595 case GL_TEXTURE_MIN_FILTER:
596 res = set_sampler_min_filter(ctx, sampObj, param);
597 break;
598 case GL_TEXTURE_MAG_FILTER:
599 res = set_sampler_mag_filter(ctx, sampObj, param);
600 break;
601 case GL_TEXTURE_MIN_LOD:
602 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) param);
603 break;
604 case GL_TEXTURE_MAX_LOD:
605 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) param);
606 break;
607 case GL_TEXTURE_LOD_BIAS:
608 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) param);
609 break;
610 case GL_TEXTURE_COMPARE_MODE:
611 res = set_sampler_compare_mode(ctx, sampObj, param);
612 break;
613 case GL_TEXTURE_COMPARE_FUNC:
614 res = set_sampler_compare_func(ctx, sampObj, param);
615 break;
616 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
617 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) param);
618 break;
619 case GL_TEXTURE_BORDER_COLOR:
620 /* fall-through */
621 default:
622 res = INVALID_PNAME;
623 }
624
625 switch (res) {
626 case GL_FALSE:
627 /* no change */
628 break;
629 case GL_TRUE:
630 /* state change - we do nothing special at this time */
631 break;
632 case INVALID_PNAME:
633 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(pname=%s)\n",
634 _mesa_lookup_enum_by_nr(pname));
635 break;
636 case INVALID_PARAM:
637 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(param=%d)\n",
638 param);
639 break;
640 case INVALID_VALUE:
641 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(param=%d)\n",
642 param);
643 break;
644 default:
645 ;
646 }
647 }
648
649
650 static void GLAPIENTRY
651 _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
652 {
653 struct gl_sampler_object *sampObj;
654 GLuint res;
655 GET_CURRENT_CONTEXT(ctx);
656
657 ASSERT_OUTSIDE_BEGIN_END(ctx);
658
659 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
660 if (!sampObj) {
661 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(sampler %u)",
662 sampler);
663 return;
664 }
665
666 switch (pname) {
667 case GL_TEXTURE_WRAP_S:
668 res = set_sampler_wrap_s(ctx, sampObj, (GLint) param);
669 break;
670 case GL_TEXTURE_WRAP_T:
671 res = set_sampler_wrap_t(ctx, sampObj, (GLint) param);
672 break;
673 case GL_TEXTURE_WRAP_R:
674 res = set_sampler_wrap_r(ctx, sampObj, (GLint) param);
675 break;
676 case GL_TEXTURE_MIN_FILTER:
677 res = set_sampler_min_filter(ctx, sampObj, (GLint) param);
678 break;
679 case GL_TEXTURE_MAG_FILTER:
680 res = set_sampler_mag_filter(ctx, sampObj, (GLint) param);
681 break;
682 case GL_TEXTURE_MIN_LOD:
683 res = set_sampler_min_lod(ctx, sampObj, param);
684 break;
685 case GL_TEXTURE_MAX_LOD:
686 res = set_sampler_max_lod(ctx, sampObj, param);
687 break;
688 case GL_TEXTURE_LOD_BIAS:
689 res = set_sampler_lod_bias(ctx, sampObj, param);
690 break;
691 case GL_TEXTURE_COMPARE_MODE:
692 res = set_sampler_compare_mode(ctx, sampObj, (GLint) param);
693 break;
694 case GL_TEXTURE_COMPARE_FUNC:
695 res = set_sampler_compare_func(ctx, sampObj, (GLint) param);
696 break;
697 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
698 res = set_sampler_max_anisotropy(ctx, sampObj, param);
699 break;
700 case GL_TEXTURE_BORDER_COLOR:
701 /* fall-through */
702 default:
703 res = INVALID_PNAME;
704 }
705
706 switch (res) {
707 case GL_FALSE:
708 /* no change */
709 break;
710 case GL_TRUE:
711 /* state change - we do nothing special at this time */
712 break;
713 case INVALID_PNAME:
714 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(pname=%s)\n",
715 _mesa_lookup_enum_by_nr(pname));
716 break;
717 case INVALID_PARAM:
718 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(param=%f)\n",
719 param);
720 break;
721 case INVALID_VALUE:
722 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(param=%f)\n",
723 param);
724 break;
725 default:
726 ;
727 }
728 }
729
730 static void GLAPIENTRY
731 _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
732 {
733 struct gl_sampler_object *sampObj;
734 GLuint res;
735 GET_CURRENT_CONTEXT(ctx);
736
737 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
738 if (!sampObj) {
739 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(sampler %u)",
740 sampler);
741 return;
742 }
743
744 switch (pname) {
745 case GL_TEXTURE_WRAP_S:
746 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
747 break;
748 case GL_TEXTURE_WRAP_T:
749 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
750 break;
751 case GL_TEXTURE_WRAP_R:
752 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
753 break;
754 case GL_TEXTURE_MIN_FILTER:
755 res = set_sampler_min_filter(ctx, sampObj, params[0]);
756 break;
757 case GL_TEXTURE_MAG_FILTER:
758 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
759 break;
760 case GL_TEXTURE_MIN_LOD:
761 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
762 break;
763 case GL_TEXTURE_MAX_LOD:
764 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
765 break;
766 case GL_TEXTURE_LOD_BIAS:
767 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
768 break;
769 case GL_TEXTURE_COMPARE_MODE:
770 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
771 break;
772 case GL_TEXTURE_COMPARE_FUNC:
773 res = set_sampler_compare_func(ctx, sampObj, params[0]);
774 break;
775 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
776 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
777 break;
778 case GL_TEXTURE_BORDER_COLOR:
779 {
780 GLfloat c[4];
781 c[0] = INT_TO_FLOAT(params[0]);
782 c[1] = INT_TO_FLOAT(params[1]);
783 c[2] = INT_TO_FLOAT(params[2]);
784 c[3] = INT_TO_FLOAT(params[3]);
785 res = set_sampler_border_colorf(ctx, sampObj, c);
786 }
787 break;
788 default:
789 res = INVALID_PNAME;
790 }
791
792 switch (res) {
793 case GL_FALSE:
794 /* no change */
795 break;
796 case GL_TRUE:
797 /* state change - we do nothing special at this time */
798 break;
799 case INVALID_PNAME:
800 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(pname=%s)\n",
801 _mesa_lookup_enum_by_nr(pname));
802 break;
803 case INVALID_PARAM:
804 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(param=%d)\n",
805 params[0]);
806 break;
807 case INVALID_VALUE:
808 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(param=%d)\n",
809 params[0]);
810 break;
811 default:
812 ;
813 }
814 }
815
816 static void GLAPIENTRY
817 _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
818 {
819 struct gl_sampler_object *sampObj;
820 GLuint res;
821 GET_CURRENT_CONTEXT(ctx);
822
823 ASSERT_OUTSIDE_BEGIN_END(ctx);
824
825 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
826 if (!sampObj) {
827 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(sampler %u)",
828 sampler);
829 return;
830 }
831
832 switch (pname) {
833 case GL_TEXTURE_WRAP_S:
834 res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]);
835 break;
836 case GL_TEXTURE_WRAP_T:
837 res = set_sampler_wrap_t(ctx, sampObj, (GLint) params[0]);
838 break;
839 case GL_TEXTURE_WRAP_R:
840 res = set_sampler_wrap_r(ctx, sampObj, (GLint) params[0]);
841 break;
842 case GL_TEXTURE_MIN_FILTER:
843 res = set_sampler_min_filter(ctx, sampObj, (GLint) params[0]);
844 break;
845 case GL_TEXTURE_MAG_FILTER:
846 res = set_sampler_mag_filter(ctx, sampObj, (GLint) params[0]);
847 break;
848 case GL_TEXTURE_MIN_LOD:
849 res = set_sampler_min_lod(ctx, sampObj, params[0]);
850 break;
851 case GL_TEXTURE_MAX_LOD:
852 res = set_sampler_max_lod(ctx, sampObj, params[0]);
853 break;
854 case GL_TEXTURE_LOD_BIAS:
855 res = set_sampler_lod_bias(ctx, sampObj, params[0]);
856 break;
857 case GL_TEXTURE_COMPARE_MODE:
858 res = set_sampler_compare_mode(ctx, sampObj, (GLint) params[0]);
859 break;
860 case GL_TEXTURE_COMPARE_FUNC:
861 res = set_sampler_compare_func(ctx, sampObj, (GLint) params[0]);
862 break;
863 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
864 res = set_sampler_max_anisotropy(ctx, sampObj, params[0]);
865 break;
866 case GL_TEXTURE_BORDER_COLOR:
867 res = set_sampler_border_colorf(ctx, sampObj, params);
868 break;
869 default:
870 res = INVALID_PNAME;
871 }
872
873 switch (res) {
874 case GL_FALSE:
875 /* no change */
876 break;
877 case GL_TRUE:
878 /* state change - we do nothing special at this time */
879 break;
880 case INVALID_PNAME:
881 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(pname=%s)\n",
882 _mesa_lookup_enum_by_nr(pname));
883 break;
884 case INVALID_PARAM:
885 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(param=%f)\n",
886 params[0]);
887 break;
888 case INVALID_VALUE:
889 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(param=%f)\n",
890 params[0]);
891 break;
892 default:
893 ;
894 }
895 }
896
897 static void GLAPIENTRY
898 _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
899 {
900 struct gl_sampler_object *sampObj;
901 GLuint res;
902 GET_CURRENT_CONTEXT(ctx);
903
904 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
905 if (!sampObj) {
906 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(sampler %u)",
907 sampler);
908 return;
909 }
910
911 switch (pname) {
912 case GL_TEXTURE_WRAP_S:
913 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
914 break;
915 case GL_TEXTURE_WRAP_T:
916 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
917 break;
918 case GL_TEXTURE_WRAP_R:
919 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
920 break;
921 case GL_TEXTURE_MIN_FILTER:
922 res = set_sampler_min_filter(ctx, sampObj, params[0]);
923 break;
924 case GL_TEXTURE_MAG_FILTER:
925 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
926 break;
927 case GL_TEXTURE_MIN_LOD:
928 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
929 break;
930 case GL_TEXTURE_MAX_LOD:
931 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
932 break;
933 case GL_TEXTURE_LOD_BIAS:
934 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
935 break;
936 case GL_TEXTURE_COMPARE_MODE:
937 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
938 break;
939 case GL_TEXTURE_COMPARE_FUNC:
940 res = set_sampler_compare_func(ctx, sampObj, params[0]);
941 break;
942 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
943 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
944 break;
945 case GL_TEXTURE_BORDER_COLOR:
946 res = set_sampler_border_colori(ctx, sampObj, params);
947 break;
948 default:
949 res = INVALID_PNAME;
950 }
951
952 switch (res) {
953 case GL_FALSE:
954 /* no change */
955 break;
956 case GL_TRUE:
957 /* state change - we do nothing special at this time */
958 break;
959 case INVALID_PNAME:
960 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(pname=%s)\n",
961 _mesa_lookup_enum_by_nr(pname));
962 break;
963 case INVALID_PARAM:
964 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(param=%d)\n",
965 params[0]);
966 break;
967 case INVALID_VALUE:
968 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(param=%d)\n",
969 params[0]);
970 break;
971 default:
972 ;
973 }
974 }
975
976
977 static void GLAPIENTRY
978 _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
979 {
980 struct gl_sampler_object *sampObj;
981 GLuint res;
982 GET_CURRENT_CONTEXT(ctx);
983
984 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
985 if (!sampObj) {
986 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(sampler %u)",
987 sampler);
988 return;
989 }
990
991 switch (pname) {
992 case GL_TEXTURE_WRAP_S:
993 res = set_sampler_wrap_s(ctx, sampObj, params[0]);
994 break;
995 case GL_TEXTURE_WRAP_T:
996 res = set_sampler_wrap_t(ctx, sampObj, params[0]);
997 break;
998 case GL_TEXTURE_WRAP_R:
999 res = set_sampler_wrap_r(ctx, sampObj, params[0]);
1000 break;
1001 case GL_TEXTURE_MIN_FILTER:
1002 res = set_sampler_min_filter(ctx, sampObj, params[0]);
1003 break;
1004 case GL_TEXTURE_MAG_FILTER:
1005 res = set_sampler_mag_filter(ctx, sampObj, params[0]);
1006 break;
1007 case GL_TEXTURE_MIN_LOD:
1008 res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]);
1009 break;
1010 case GL_TEXTURE_MAX_LOD:
1011 res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]);
1012 break;
1013 case GL_TEXTURE_LOD_BIAS:
1014 res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]);
1015 break;
1016 case GL_TEXTURE_COMPARE_MODE:
1017 res = set_sampler_compare_mode(ctx, sampObj, params[0]);
1018 break;
1019 case GL_TEXTURE_COMPARE_FUNC:
1020 res = set_sampler_compare_func(ctx, sampObj, params[0]);
1021 break;
1022 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1023 res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]);
1024 break;
1025 case GL_TEXTURE_BORDER_COLOR:
1026 res = set_sampler_border_colorui(ctx, sampObj, params);
1027 break;
1028 default:
1029 res = INVALID_PNAME;
1030 }
1031
1032 switch (res) {
1033 case GL_FALSE:
1034 /* no change */
1035 break;
1036 case GL_TRUE:
1037 /* state change - we do nothing special at this time */
1038 break;
1039 case INVALID_PNAME:
1040 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(pname=%s)\n",
1041 _mesa_lookup_enum_by_nr(pname));
1042 break;
1043 case INVALID_PARAM:
1044 _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(param=%u)\n",
1045 params[0]);
1046 break;
1047 case INVALID_VALUE:
1048 _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(param=%u)\n",
1049 params[0]);
1050 break;
1051 default:
1052 ;
1053 }
1054 }
1055
1056
1057 static void GLAPIENTRY
1058 _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
1059 {
1060 struct gl_sampler_object *sampObj;
1061 GET_CURRENT_CONTEXT(ctx);
1062
1063 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1064 if (!sampObj) {
1065 _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameteriv(sampler %u)",
1066 sampler);
1067 return;
1068 }
1069
1070 switch (pname) {
1071 case GL_TEXTURE_WRAP_S:
1072 *params = sampObj->WrapS;
1073 break;
1074 case GL_TEXTURE_WRAP_T:
1075 *params = sampObj->WrapT;
1076 break;
1077 case GL_TEXTURE_WRAP_R:
1078 *params = sampObj->WrapR;
1079 break;
1080 case GL_TEXTURE_MIN_FILTER:
1081 *params = sampObj->MinFilter;
1082 break;
1083 case GL_TEXTURE_MAG_FILTER:
1084 *params = sampObj->MagFilter;
1085 break;
1086 case GL_TEXTURE_MIN_LOD:
1087 *params = (GLint) sampObj->MinLod;
1088 break;
1089 case GL_TEXTURE_MAX_LOD:
1090 *params = (GLint) sampObj->MaxLod;
1091 break;
1092 case GL_TEXTURE_LOD_BIAS:
1093 *params = (GLint) sampObj->LodBias;
1094 break;
1095 case GL_TEXTURE_COMPARE_MODE:
1096 if (!ctx->Extensions.ARB_shadow)
1097 goto invalid_pname;
1098 *params = sampObj->CompareMode;
1099 break;
1100 case GL_TEXTURE_COMPARE_FUNC:
1101 if (!ctx->Extensions.ARB_shadow)
1102 goto invalid_pname;
1103 *params = sampObj->CompareFunc;
1104 break;
1105 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1106 *params = (GLint) sampObj->MaxAnisotropy;
1107 break;
1108 case GL_TEXTURE_BORDER_COLOR:
1109 params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]);
1110 params[1] = FLOAT_TO_INT(sampObj->BorderColor.f[1]);
1111 params[2] = FLOAT_TO_INT(sampObj->BorderColor.f[2]);
1112 params[3] = FLOAT_TO_INT(sampObj->BorderColor.f[3]);
1113 break;
1114 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1115 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1116 goto invalid_pname;
1117 *params = sampObj->CubeMapSeamless;
1118 break;
1119 default:
1120 goto invalid_pname;
1121 }
1122 return;
1123
1124 invalid_pname:
1125 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameteriv(pname=%s)",
1126 _mesa_lookup_enum_by_nr(pname));
1127 }
1128
1129
1130 static void GLAPIENTRY
1131 _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
1132 {
1133 struct gl_sampler_object *sampObj;
1134 GET_CURRENT_CONTEXT(ctx);
1135
1136 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1137 if (!sampObj) {
1138 _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameterfv(sampler %u)",
1139 sampler);
1140 return;
1141 }
1142
1143 switch (pname) {
1144 case GL_TEXTURE_WRAP_S:
1145 *params = (GLfloat) sampObj->WrapS;
1146 break;
1147 case GL_TEXTURE_WRAP_T:
1148 *params = (GLfloat) sampObj->WrapT;
1149 break;
1150 case GL_TEXTURE_WRAP_R:
1151 *params = (GLfloat) sampObj->WrapR;
1152 break;
1153 case GL_TEXTURE_MIN_FILTER:
1154 *params = (GLfloat) sampObj->MinFilter;
1155 break;
1156 case GL_TEXTURE_MAG_FILTER:
1157 *params = (GLfloat) sampObj->MagFilter;
1158 break;
1159 case GL_TEXTURE_MIN_LOD:
1160 *params = sampObj->MinLod;
1161 break;
1162 case GL_TEXTURE_MAX_LOD:
1163 *params = sampObj->MaxLod;
1164 break;
1165 case GL_TEXTURE_LOD_BIAS:
1166 *params = sampObj->LodBias;
1167 break;
1168 case GL_TEXTURE_COMPARE_MODE:
1169 if (!ctx->Extensions.ARB_shadow)
1170 goto invalid_pname;
1171 *params = (GLfloat) sampObj->CompareMode;
1172 break;
1173 case GL_TEXTURE_COMPARE_FUNC:
1174 if (!ctx->Extensions.ARB_shadow)
1175 goto invalid_pname;
1176 *params = (GLfloat) sampObj->CompareFunc;
1177 break;
1178 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1179 *params = sampObj->MaxAnisotropy;
1180 break;
1181 case GL_TEXTURE_BORDER_COLOR:
1182 params[0] = sampObj->BorderColor.f[0];
1183 params[1] = sampObj->BorderColor.f[1];
1184 params[2] = sampObj->BorderColor.f[2];
1185 params[3] = sampObj->BorderColor.f[3];
1186 break;
1187 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1188 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1189 goto invalid_pname;
1190 *params = (GLfloat) sampObj->CubeMapSeamless;
1191 break;
1192 default:
1193 goto invalid_pname;
1194 }
1195 return;
1196
1197 invalid_pname:
1198 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterfv(pname=%s)",
1199 _mesa_lookup_enum_by_nr(pname));
1200 }
1201
1202
1203 static void GLAPIENTRY
1204 _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
1205 {
1206 struct gl_sampler_object *sampObj;
1207 GET_CURRENT_CONTEXT(ctx);
1208
1209 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1210 if (!sampObj) {
1211 _mesa_error(ctx, GL_INVALID_VALUE,
1212 "glGetSamplerParameterIiv(sampler %u)",
1213 sampler);
1214 return;
1215 }
1216
1217 switch (pname) {
1218 case GL_TEXTURE_WRAP_S:
1219 *params = sampObj->WrapS;
1220 break;
1221 case GL_TEXTURE_WRAP_T:
1222 *params = sampObj->WrapT;
1223 break;
1224 case GL_TEXTURE_WRAP_R:
1225 *params = sampObj->WrapR;
1226 break;
1227 case GL_TEXTURE_MIN_FILTER:
1228 *params = sampObj->MinFilter;
1229 break;
1230 case GL_TEXTURE_MAG_FILTER:
1231 *params = sampObj->MagFilter;
1232 break;
1233 case GL_TEXTURE_MIN_LOD:
1234 *params = (GLint) sampObj->MinLod;
1235 break;
1236 case GL_TEXTURE_MAX_LOD:
1237 *params = (GLint) sampObj->MaxLod;
1238 break;
1239 case GL_TEXTURE_LOD_BIAS:
1240 *params = (GLint) sampObj->LodBias;
1241 break;
1242 case GL_TEXTURE_COMPARE_MODE:
1243 if (!ctx->Extensions.ARB_shadow)
1244 goto invalid_pname;
1245 *params = sampObj->CompareMode;
1246 break;
1247 case GL_TEXTURE_COMPARE_FUNC:
1248 if (!ctx->Extensions.ARB_shadow)
1249 goto invalid_pname;
1250 *params = sampObj->CompareFunc;
1251 break;
1252 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1253 *params = (GLint) sampObj->MaxAnisotropy;
1254 break;
1255 case GL_TEXTURE_BORDER_COLOR:
1256 params[0] = sampObj->BorderColor.i[0];
1257 params[1] = sampObj->BorderColor.i[1];
1258 params[2] = sampObj->BorderColor.i[2];
1259 params[3] = sampObj->BorderColor.i[3];
1260 break;
1261 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1262 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1263 goto invalid_pname;
1264 *params = sampObj->CubeMapSeamless;
1265 break;
1266 default:
1267 goto invalid_pname;
1268 }
1269 return;
1270
1271 invalid_pname:
1272 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIiv(pname=%s)",
1273 _mesa_lookup_enum_by_nr(pname));
1274 }
1275
1276
1277 static void GLAPIENTRY
1278 _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
1279 {
1280 struct gl_sampler_object *sampObj;
1281 GET_CURRENT_CONTEXT(ctx);
1282
1283 sampObj = _mesa_lookup_samplerobj(ctx, sampler);
1284 if (!sampObj) {
1285 _mesa_error(ctx, GL_INVALID_VALUE,
1286 "glGetSamplerParameterIuiv(sampler %u)",
1287 sampler);
1288 return;
1289 }
1290
1291 switch (pname) {
1292 case GL_TEXTURE_WRAP_S:
1293 *params = sampObj->WrapS;
1294 break;
1295 case GL_TEXTURE_WRAP_T:
1296 *params = sampObj->WrapT;
1297 break;
1298 case GL_TEXTURE_WRAP_R:
1299 *params = sampObj->WrapR;
1300 break;
1301 case GL_TEXTURE_MIN_FILTER:
1302 *params = sampObj->MinFilter;
1303 break;
1304 case GL_TEXTURE_MAG_FILTER:
1305 *params = sampObj->MagFilter;
1306 break;
1307 case GL_TEXTURE_MIN_LOD:
1308 *params = (GLuint) sampObj->MinLod;
1309 break;
1310 case GL_TEXTURE_MAX_LOD:
1311 *params = (GLuint) sampObj->MaxLod;
1312 break;
1313 case GL_TEXTURE_LOD_BIAS:
1314 *params = (GLuint) sampObj->LodBias;
1315 break;
1316 case GL_TEXTURE_COMPARE_MODE:
1317 if (!ctx->Extensions.ARB_shadow)
1318 goto invalid_pname;
1319 *params = sampObj->CompareMode;
1320 break;
1321 case GL_TEXTURE_COMPARE_FUNC:
1322 if (!ctx->Extensions.ARB_shadow)
1323 goto invalid_pname;
1324 *params = sampObj->CompareFunc;
1325 break;
1326 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1327 *params = (GLuint) sampObj->MaxAnisotropy;
1328 break;
1329 case GL_TEXTURE_BORDER_COLOR:
1330 params[0] = sampObj->BorderColor.ui[0];
1331 params[1] = sampObj->BorderColor.ui[1];
1332 params[2] = sampObj->BorderColor.ui[2];
1333 params[3] = sampObj->BorderColor.ui[3];
1334 break;
1335 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1336 if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
1337 goto invalid_pname;
1338 *params = sampObj->CubeMapSeamless;
1339 break;
1340 default:
1341 goto invalid_pname;
1342 }
1343 return;
1344
1345 invalid_pname:
1346 _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIuiv(pname=%s)",
1347 _mesa_lookup_enum_by_nr(pname));
1348 }
1349
1350
1351 void
1352 _mesa_init_sampler_object_functions(struct dd_function_table *driver)
1353 {
1354 driver->NewSamplerObject = _mesa_new_sampler_object;
1355 driver->DeleteSamplerObject = _mesa_delete_sampler_object;
1356 }
1357
1358
1359 void
1360 _mesa_init_sampler_object_dispatch(struct _glapi_table *disp)
1361 {
1362 SET_GenSamplers(disp, _mesa_GenSamplers);
1363 SET_DeleteSamplers(disp, _mesa_DeleteSamplers);
1364 SET_IsSampler(disp, _mesa_IsSampler);
1365 SET_BindSampler(disp, _mesa_BindSampler);
1366 SET_SamplerParameteri(disp, _mesa_SamplerParameteri);
1367 SET_SamplerParameterf(disp, _mesa_SamplerParameterf);
1368 SET_SamplerParameteriv(disp, _mesa_SamplerParameteriv);
1369 SET_SamplerParameterfv(disp, _mesa_SamplerParameterfv);
1370 SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv);
1371 SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv);
1372 SET_GetSamplerParameteriv(disp, _mesa_GetSamplerParameteriv);
1373 SET_GetSamplerParameterfv(disp, _mesa_GetSamplerParameterfv);
1374 SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv);
1375 SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv);
1376 }