2 * Mesa 3-D graphics library
4 * Copyright (C) 2011 VMware, Inc. All Rights Reserved.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
28 * \brief Functions for the GL_ARB_sampler_objects extension.
33 #include "main/glheader.h"
34 #include "main/context.h"
35 #include "main/dispatch.h"
36 #include "main/enums.h"
37 #include "main/hash.h"
38 #include "main/macros.h"
39 #include "main/mtypes.h"
40 #include "main/samplerobj.h"
43 struct gl_sampler_object
*
44 _mesa_lookup_samplerobj(struct gl_context
*ctx
, GLuint name
)
49 return (struct gl_sampler_object
*)
50 _mesa_HashLookup(ctx
->Shared
->SamplerObjects
, name
);
55 begin_samplerobj_lookups(struct gl_context
*ctx
)
57 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
62 end_samplerobj_lookups(struct gl_context
*ctx
)
64 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
68 static inline struct gl_sampler_object
*
69 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
71 return (struct gl_sampler_object
*)
72 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
76 delete_sampler_object(struct gl_context
*ctx
,
77 struct gl_sampler_object
*sampObj
)
79 mtx_destroy(&sampObj
->Mutex
);
85 * Handle reference counting.
88 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
89 struct gl_sampler_object
**ptr
,
90 struct gl_sampler_object
*samp
)
92 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
95 /* Unreference the old sampler */
96 GLboolean deleteFlag
= GL_FALSE
;
97 struct gl_sampler_object
*oldSamp
= *ptr
;
99 mtx_lock(&oldSamp
->Mutex
);
100 assert(oldSamp
->RefCount
> 0);
102 deleteFlag
= (oldSamp
->RefCount
== 0);
103 mtx_unlock(&oldSamp
->Mutex
);
106 delete_sampler_object(ctx
, oldSamp
);
113 /* reference new sampler */
114 mtx_lock(&samp
->Mutex
);
115 if (samp
->RefCount
== 0) {
116 /* this sampler's being deleted (look just above) */
117 /* Not sure this can every really happen. Warn if it does. */
118 _mesa_problem(NULL
, "referencing deleted sampler object");
125 mtx_unlock(&samp
->Mutex
);
131 * Initialize the fields of the given sampler object.
134 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
136 mtx_init(&sampObj
->Mutex
, mtx_plain
);
137 sampObj
->Name
= name
;
138 sampObj
->RefCount
= 1;
139 sampObj
->WrapS
= GL_REPEAT
;
140 sampObj
->WrapT
= GL_REPEAT
;
141 sampObj
->WrapR
= GL_REPEAT
;
142 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
143 sampObj
->MagFilter
= GL_LINEAR
;
144 sampObj
->BorderColor
.f
[0] = 0.0;
145 sampObj
->BorderColor
.f
[1] = 0.0;
146 sampObj
->BorderColor
.f
[2] = 0.0;
147 sampObj
->BorderColor
.f
[3] = 0.0;
148 sampObj
->MinLod
= -1000.0F
;
149 sampObj
->MaxLod
= 1000.0F
;
150 sampObj
->LodBias
= 0.0F
;
151 sampObj
->MaxAnisotropy
= 1.0F
;
152 sampObj
->CompareMode
= GL_NONE
;
153 sampObj
->CompareFunc
= GL_LEQUAL
;
154 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
155 sampObj
->CubeMapSeamless
= GL_FALSE
;
159 * Fallback for ctx->Driver.NewSamplerObject();
161 struct gl_sampler_object
*
162 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
164 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
166 _mesa_init_sampler_object(sampObj
, name
);
172 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
178 if (MESA_VERBOSE
& VERBOSE_API
)
179 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
182 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
189 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
191 /* Insert the ID and pointer to new sampler object into hash table */
192 for (i
= 0; i
< count
; i
++) {
193 struct gl_sampler_object
*sampObj
=
194 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
195 _mesa_HashInsert(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
196 samplers
[i
] = first
+ i
;
201 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
203 GET_CURRENT_CONTEXT(ctx
);
204 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
208 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
210 GET_CURRENT_CONTEXT(ctx
);
211 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
216 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
218 GET_CURRENT_CONTEXT(ctx
);
221 FLUSH_VERTICES(ctx
, 0);
224 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
228 mtx_lock(&ctx
->Shared
->Mutex
);
230 for (i
= 0; i
< count
; i
++) {
233 struct gl_sampler_object
*sampObj
=
234 _mesa_lookup_samplerobj(ctx
, samplers
[i
]);
237 /* If the sampler is currently bound, unbind it. */
238 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
239 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
240 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
241 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
245 /* The ID is immediately freed for re-use */
246 _mesa_HashRemove(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
247 /* But the object exists until its reference count goes to zero */
248 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
253 mtx_unlock(&ctx
->Shared
->Mutex
);
258 _mesa_IsSampler(GLuint sampler
)
260 struct gl_sampler_object
*sampObj
;
261 GET_CURRENT_CONTEXT(ctx
);
263 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
268 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
270 return sampObj
!= NULL
;
275 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
277 struct gl_sampler_object
*sampObj
;
278 GET_CURRENT_CONTEXT(ctx
);
280 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
281 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
286 /* Use the default sampler object, the one contained in the texture
292 /* user-defined sampler object */
293 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
295 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
300 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
301 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
304 /* bind new sampler */
305 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
311 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
313 GET_CURRENT_CONTEXT(ctx
);
316 /* The ARB_multi_bind spec says:
318 * "An INVALID_OPERATION error is generated if <first> + <count> is
319 * greater than the number of texture image units supported by
320 * the implementation."
322 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
323 _mesa_error(ctx
, GL_INVALID_OPERATION
,
324 "glBindSamplers(first=%u + count=%d > the value of "
325 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
326 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
330 FLUSH_VERTICES(ctx
, 0);
333 /* Note that the error semantics for multi-bind commands differ from
334 * those of other GL commands.
336 * The Issues section in the ARB_multi_bind spec says:
338 * "(11) Typically, OpenGL specifies that if an error is generated by
339 * a command, that command has no effect. This is somewhat
340 * unfortunate for multi-bind commands, because it would require
341 * a first pass to scan the entire list of bound objects for
342 * errors and then a second pass to actually perform the
343 * bindings. Should we have different error semantics?
345 * RESOLVED: Yes. In this specification, when the parameters for
346 * one of the <count> binding points are invalid, that binding
347 * point is not updated and an error will be generated. However,
348 * other binding points in the same command will be updated if
349 * their parameters are valid and no other error occurs."
352 begin_samplerobj_lookups(ctx
);
354 for (i
= 0; i
< count
; i
++) {
355 const GLuint unit
= first
+ i
;
356 struct gl_sampler_object
* const currentSampler
=
357 ctx
->Texture
.Unit
[unit
].Sampler
;
358 struct gl_sampler_object
*sampObj
;
360 if (samplers
[i
] != 0) {
361 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
362 sampObj
= currentSampler
;
364 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
366 /* The ARB_multi_bind spec says:
368 * "An INVALID_OPERATION error is generated if any value
369 * in <samplers> is not zero or the name of an existing
370 * sampler object (per binding)."
373 _mesa_error(ctx
, GL_INVALID_OPERATION
,
374 "glBindSamplers(samplers[%d]=%u is not zero or "
375 "the name of an existing sampler object)",
383 /* Bind the new sampler */
384 if (sampObj
!= currentSampler
) {
385 _mesa_reference_sampler_object(ctx
,
386 &ctx
->Texture
.Unit
[unit
].Sampler
,
388 ctx
->NewState
|= _NEW_TEXTURE
;
392 end_samplerobj_lookups(ctx
);
394 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
395 for (i
= 0; i
< count
; i
++) {
396 const GLuint unit
= first
+ i
;
398 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
399 _mesa_reference_sampler_object(ctx
,
400 &ctx
->Texture
.Unit
[unit
].Sampler
,
402 ctx
->NewState
|= _NEW_TEXTURE
;
410 * Check if a coordinate wrap mode is legal.
411 * \return GL_TRUE if legal, GL_FALSE otherwise
414 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
416 const struct gl_extensions
* const e
= &ctx
->Extensions
;
420 case GL_CLAMP_TO_EDGE
:
422 case GL_MIRRORED_REPEAT
:
424 case GL_CLAMP_TO_BORDER
:
425 return e
->ARB_texture_border_clamp
;
426 case GL_MIRROR_CLAMP_EXT
:
427 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
428 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
429 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
430 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
431 return e
->EXT_texture_mirror_clamp
;
439 * This is called just prior to changing any sampler object state.
442 flush(struct gl_context
*ctx
)
444 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
448 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
449 GLenum s
, GLenum t
, GLenum r
)
451 assert(validate_texture_wrap_mode(ctx
, s
));
452 assert(validate_texture_wrap_mode(ctx
, t
));
453 assert(validate_texture_wrap_mode(ctx
, r
));
455 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
464 #define INVALID_PARAM 0x100
465 #define INVALID_PNAME 0x101
466 #define INVALID_VALUE 0x102
469 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
472 if (samp
->WrapS
== param
)
474 if (validate_texture_wrap_mode(ctx
, param
)) {
479 return INVALID_PARAM
;
484 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
487 if (samp
->WrapT
== param
)
489 if (validate_texture_wrap_mode(ctx
, param
)) {
494 return INVALID_PARAM
;
499 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
502 if (samp
->WrapR
== param
)
504 if (validate_texture_wrap_mode(ctx
, param
)) {
509 return INVALID_PARAM
;
513 _mesa_set_sampler_filters(struct gl_context
*ctx
,
514 struct gl_sampler_object
*samp
,
515 GLenum min_filter
, GLenum mag_filter
)
517 assert(min_filter
== GL_NEAREST
||
518 min_filter
== GL_LINEAR
||
519 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
520 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
521 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
522 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
523 assert(mag_filter
== GL_NEAREST
||
524 mag_filter
== GL_LINEAR
);
526 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
530 samp
->MinFilter
= min_filter
;
531 samp
->MagFilter
= mag_filter
;
535 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
538 if (samp
->MinFilter
== param
)
544 case GL_NEAREST_MIPMAP_NEAREST
:
545 case GL_LINEAR_MIPMAP_NEAREST
:
546 case GL_NEAREST_MIPMAP_LINEAR
:
547 case GL_LINEAR_MIPMAP_LINEAR
:
549 samp
->MinFilter
= param
;
552 return INVALID_PARAM
;
558 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
561 if (samp
->MagFilter
== param
)
568 samp
->MagFilter
= param
;
571 return INVALID_PARAM
;
577 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
580 if (samp
->LodBias
== param
)
584 samp
->LodBias
= param
;
590 set_sampler_border_colorf(struct gl_context
*ctx
,
591 struct gl_sampler_object
*samp
,
592 const GLfloat params
[4])
595 samp
->BorderColor
.f
[RCOMP
] = params
[0];
596 samp
->BorderColor
.f
[GCOMP
] = params
[1];
597 samp
->BorderColor
.f
[BCOMP
] = params
[2];
598 samp
->BorderColor
.f
[ACOMP
] = params
[3];
604 set_sampler_border_colori(struct gl_context
*ctx
,
605 struct gl_sampler_object
*samp
,
606 const GLint params
[4])
609 samp
->BorderColor
.i
[RCOMP
] = params
[0];
610 samp
->BorderColor
.i
[GCOMP
] = params
[1];
611 samp
->BorderColor
.i
[BCOMP
] = params
[2];
612 samp
->BorderColor
.i
[ACOMP
] = params
[3];
618 set_sampler_border_colorui(struct gl_context
*ctx
,
619 struct gl_sampler_object
*samp
,
620 const GLuint params
[4])
623 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
624 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
625 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
626 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
632 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
635 if (samp
->MinLod
== param
)
639 samp
->MinLod
= param
;
645 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
648 if (samp
->MaxLod
== param
)
652 samp
->MaxLod
= param
;
658 set_sampler_compare_mode(struct gl_context
*ctx
,
659 struct gl_sampler_object
*samp
, GLint param
)
661 /* If GL_ARB_shadow is not supported, don't report an error. The
662 * sampler object extension spec isn't clear on this extension interaction.
663 * Silences errors with Wine on older GPUs such as R200.
665 if (!ctx
->Extensions
.ARB_shadow
)
668 if (samp
->CompareMode
== param
)
671 if (param
== GL_NONE
||
672 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
674 samp
->CompareMode
= param
;
678 return INVALID_PARAM
;
683 set_sampler_compare_func(struct gl_context
*ctx
,
684 struct gl_sampler_object
*samp
, GLint param
)
686 /* If GL_ARB_shadow is not supported, don't report an error. The
687 * sampler object extension spec isn't clear on this extension interaction.
688 * Silences errors with Wine on older GPUs such as R200.
690 if (!ctx
->Extensions
.ARB_shadow
)
693 if (samp
->CompareFunc
== param
)
706 samp
->CompareFunc
= param
;
709 return INVALID_PARAM
;
715 set_sampler_max_anisotropy(struct gl_context
*ctx
,
716 struct gl_sampler_object
*samp
, GLfloat param
)
718 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
719 return INVALID_PNAME
;
721 if (samp
->MaxAnisotropy
== param
)
725 return INVALID_VALUE
;
728 /* clamp to max, that's what NVIDIA does */
729 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
735 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
736 struct gl_sampler_object
*samp
, GLboolean param
)
738 if (!_mesa_is_desktop_gl(ctx
)
739 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
740 return INVALID_PNAME
;
742 if (samp
->CubeMapSeamless
== param
)
745 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
746 return INVALID_VALUE
;
749 samp
->CubeMapSeamless
= param
;
754 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
755 struct gl_sampler_object
*samp
, GLenum param
)
757 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
760 samp
->sRGBDecode
= param
;
764 set_sampler_srgb_decode(struct gl_context
*ctx
,
765 struct gl_sampler_object
*samp
, GLenum param
)
767 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
768 return INVALID_PNAME
;
770 if (samp
->sRGBDecode
== param
)
773 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
774 return INVALID_VALUE
;
777 samp
->sRGBDecode
= param
;
782 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
784 struct gl_sampler_object
*sampObj
;
786 GET_CURRENT_CONTEXT(ctx
);
788 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
790 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
792 * "An INVALID_OPERATION error is generated if sampler is not the name
793 * of a sampler object previously returned from a call to GenSamplers."
795 * In desktop GL, an GL_INVALID_VALUE is returned instead.
797 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
798 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
799 "glSamplerParameteri(sampler %u)", sampler
);
804 case GL_TEXTURE_WRAP_S
:
805 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
807 case GL_TEXTURE_WRAP_T
:
808 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
810 case GL_TEXTURE_WRAP_R
:
811 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
813 case GL_TEXTURE_MIN_FILTER
:
814 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
816 case GL_TEXTURE_MAG_FILTER
:
817 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
819 case GL_TEXTURE_MIN_LOD
:
820 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
822 case GL_TEXTURE_MAX_LOD
:
823 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
825 case GL_TEXTURE_LOD_BIAS
:
826 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
828 case GL_TEXTURE_COMPARE_MODE
:
829 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
831 case GL_TEXTURE_COMPARE_FUNC
:
832 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
834 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
835 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
837 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
838 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
840 case GL_TEXTURE_SRGB_DECODE_EXT
:
841 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
843 case GL_TEXTURE_BORDER_COLOR
:
854 /* state change - we do nothing special at this time */
857 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
858 _mesa_enum_to_string(pname
));
861 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
865 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
875 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
877 struct gl_sampler_object
*sampObj
;
879 GET_CURRENT_CONTEXT(ctx
);
881 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
883 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
885 * "An INVALID_OPERATION error is generated if sampler is not the name
886 * of a sampler object previously returned from a call to GenSamplers."
888 * In desktop GL, an GL_INVALID_VALUE is returned instead.
890 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
891 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
892 "glSamplerParameterf(sampler %u)", sampler
);
897 case GL_TEXTURE_WRAP_S
:
898 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
900 case GL_TEXTURE_WRAP_T
:
901 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
903 case GL_TEXTURE_WRAP_R
:
904 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
906 case GL_TEXTURE_MIN_FILTER
:
907 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
909 case GL_TEXTURE_MAG_FILTER
:
910 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
912 case GL_TEXTURE_MIN_LOD
:
913 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
915 case GL_TEXTURE_MAX_LOD
:
916 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
918 case GL_TEXTURE_LOD_BIAS
:
919 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
921 case GL_TEXTURE_COMPARE_MODE
:
922 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
924 case GL_TEXTURE_COMPARE_FUNC
:
925 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
927 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
928 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
930 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
931 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
933 case GL_TEXTURE_SRGB_DECODE_EXT
:
934 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
936 case GL_TEXTURE_BORDER_COLOR
:
947 /* state change - we do nothing special at this time */
950 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
951 _mesa_enum_to_string(pname
));
954 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
958 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
967 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
969 struct gl_sampler_object
*sampObj
;
971 GET_CURRENT_CONTEXT(ctx
);
973 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
975 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
977 * "An INVALID_OPERATION error is generated if sampler is not the name
978 * of a sampler object previously returned from a call to GenSamplers."
980 * In desktop GL, an GL_INVALID_VALUE is returned instead.
982 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
983 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
984 "glSamplerParameteriv(sampler %u)", sampler
);
989 case GL_TEXTURE_WRAP_S
:
990 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
992 case GL_TEXTURE_WRAP_T
:
993 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
995 case GL_TEXTURE_WRAP_R
:
996 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
998 case GL_TEXTURE_MIN_FILTER
:
999 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1001 case GL_TEXTURE_MAG_FILTER
:
1002 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1004 case GL_TEXTURE_MIN_LOD
:
1005 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1007 case GL_TEXTURE_MAX_LOD
:
1008 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1010 case GL_TEXTURE_LOD_BIAS
:
1011 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1013 case GL_TEXTURE_COMPARE_MODE
:
1014 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1016 case GL_TEXTURE_COMPARE_FUNC
:
1017 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1019 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1020 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1022 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1023 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1025 case GL_TEXTURE_SRGB_DECODE_EXT
:
1026 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1028 case GL_TEXTURE_BORDER_COLOR
:
1031 c
[0] = INT_TO_FLOAT(params
[0]);
1032 c
[1] = INT_TO_FLOAT(params
[1]);
1033 c
[2] = INT_TO_FLOAT(params
[2]);
1034 c
[3] = INT_TO_FLOAT(params
[3]);
1035 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1039 res
= INVALID_PNAME
;
1047 /* state change - we do nothing special at this time */
1050 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1051 _mesa_enum_to_string(pname
));
1054 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1058 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1067 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1069 struct gl_sampler_object
*sampObj
;
1071 GET_CURRENT_CONTEXT(ctx
);
1073 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1075 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1077 * "An INVALID_OPERATION error is generated if sampler is not the name
1078 * of a sampler object previously returned from a call to GenSamplers."
1080 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1082 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1083 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1084 "glSamplerParameterfv(sampler %u)", sampler
);
1089 case GL_TEXTURE_WRAP_S
:
1090 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1092 case GL_TEXTURE_WRAP_T
:
1093 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1095 case GL_TEXTURE_WRAP_R
:
1096 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1098 case GL_TEXTURE_MIN_FILTER
:
1099 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1101 case GL_TEXTURE_MAG_FILTER
:
1102 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1104 case GL_TEXTURE_MIN_LOD
:
1105 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1107 case GL_TEXTURE_MAX_LOD
:
1108 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1110 case GL_TEXTURE_LOD_BIAS
:
1111 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1113 case GL_TEXTURE_COMPARE_MODE
:
1114 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1116 case GL_TEXTURE_COMPARE_FUNC
:
1117 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1119 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1120 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1122 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1123 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1125 case GL_TEXTURE_SRGB_DECODE_EXT
:
1126 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1128 case GL_TEXTURE_BORDER_COLOR
:
1129 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1132 res
= INVALID_PNAME
;
1140 /* state change - we do nothing special at this time */
1143 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1144 _mesa_enum_to_string(pname
));
1147 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1151 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1160 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1162 struct gl_sampler_object
*sampObj
;
1164 GET_CURRENT_CONTEXT(ctx
);
1166 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1168 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1174 case GL_TEXTURE_WRAP_S
:
1175 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1177 case GL_TEXTURE_WRAP_T
:
1178 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1180 case GL_TEXTURE_WRAP_R
:
1181 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1183 case GL_TEXTURE_MIN_FILTER
:
1184 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1186 case GL_TEXTURE_MAG_FILTER
:
1187 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1189 case GL_TEXTURE_MIN_LOD
:
1190 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1192 case GL_TEXTURE_MAX_LOD
:
1193 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1195 case GL_TEXTURE_LOD_BIAS
:
1196 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1198 case GL_TEXTURE_COMPARE_MODE
:
1199 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1201 case GL_TEXTURE_COMPARE_FUNC
:
1202 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1204 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1205 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1207 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1208 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1210 case GL_TEXTURE_SRGB_DECODE_EXT
:
1211 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1213 case GL_TEXTURE_BORDER_COLOR
:
1214 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1217 res
= INVALID_PNAME
;
1225 /* state change - we do nothing special at this time */
1228 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1229 _mesa_enum_to_string(pname
));
1232 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1236 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1246 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1248 struct gl_sampler_object
*sampObj
;
1250 GET_CURRENT_CONTEXT(ctx
);
1252 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1254 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1260 case GL_TEXTURE_WRAP_S
:
1261 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1263 case GL_TEXTURE_WRAP_T
:
1264 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1266 case GL_TEXTURE_WRAP_R
:
1267 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1269 case GL_TEXTURE_MIN_FILTER
:
1270 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1272 case GL_TEXTURE_MAG_FILTER
:
1273 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1275 case GL_TEXTURE_MIN_LOD
:
1276 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1278 case GL_TEXTURE_MAX_LOD
:
1279 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1281 case GL_TEXTURE_LOD_BIAS
:
1282 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1284 case GL_TEXTURE_COMPARE_MODE
:
1285 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1287 case GL_TEXTURE_COMPARE_FUNC
:
1288 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1290 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1291 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1293 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1294 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1296 case GL_TEXTURE_SRGB_DECODE_EXT
:
1297 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1299 case GL_TEXTURE_BORDER_COLOR
:
1300 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1303 res
= INVALID_PNAME
;
1311 /* state change - we do nothing special at this time */
1314 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1315 _mesa_enum_to_string(pname
));
1318 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1322 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1332 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1334 struct gl_sampler_object
*sampObj
;
1335 GET_CURRENT_CONTEXT(ctx
);
1337 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1339 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1341 * "An INVALID_OPERATION error is generated if sampler is not the name
1342 * of a sampler object previously returned from a call to GenSamplers."
1344 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1346 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1347 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1348 "glGetSamplerParameteriv(sampler %u)", sampler
);
1353 case GL_TEXTURE_WRAP_S
:
1354 *params
= sampObj
->WrapS
;
1356 case GL_TEXTURE_WRAP_T
:
1357 *params
= sampObj
->WrapT
;
1359 case GL_TEXTURE_WRAP_R
:
1360 *params
= sampObj
->WrapR
;
1362 case GL_TEXTURE_MIN_FILTER
:
1363 *params
= sampObj
->MinFilter
;
1365 case GL_TEXTURE_MAG_FILTER
:
1366 *params
= sampObj
->MagFilter
;
1368 case GL_TEXTURE_MIN_LOD
:
1369 /* GL spec 'Data Conversions' section specifies that floating-point
1370 * value in integer Get function is rounded to nearest integer
1372 *params
= IROUND(sampObj
->MinLod
);
1374 case GL_TEXTURE_MAX_LOD
:
1375 /* GL spec 'Data Conversions' section specifies that floating-point
1376 * value in integer Get function is rounded to nearest integer
1378 *params
= IROUND(sampObj
->MaxLod
);
1380 case GL_TEXTURE_LOD_BIAS
:
1381 /* GL spec 'Data Conversions' section specifies that floating-point
1382 * value in integer Get function is rounded to nearest integer
1384 *params
= IROUND(sampObj
->LodBias
);
1386 case GL_TEXTURE_COMPARE_MODE
:
1387 *params
= sampObj
->CompareMode
;
1389 case GL_TEXTURE_COMPARE_FUNC
:
1390 *params
= sampObj
->CompareFunc
;
1392 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1393 /* GL spec 'Data Conversions' section specifies that floating-point
1394 * value in integer Get function is rounded to nearest integer
1396 *params
= IROUND(sampObj
->MaxAnisotropy
);
1398 case GL_TEXTURE_BORDER_COLOR
:
1399 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1400 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1401 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1402 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1404 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1405 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1407 *params
= sampObj
->CubeMapSeamless
;
1409 case GL_TEXTURE_SRGB_DECODE_EXT
:
1410 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1412 *params
= (GLenum
) sampObj
->sRGBDecode
;
1420 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1421 _mesa_enum_to_string(pname
));
1426 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1428 struct gl_sampler_object
*sampObj
;
1429 GET_CURRENT_CONTEXT(ctx
);
1431 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1433 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1435 * "An INVALID_OPERATION error is generated if sampler is not the name
1436 * of a sampler object previously returned from a call to GenSamplers."
1438 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1440 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1441 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1442 "glGetSamplerParameterfv(sampler %u)", sampler
);
1447 case GL_TEXTURE_WRAP_S
:
1448 *params
= (GLfloat
) sampObj
->WrapS
;
1450 case GL_TEXTURE_WRAP_T
:
1451 *params
= (GLfloat
) sampObj
->WrapT
;
1453 case GL_TEXTURE_WRAP_R
:
1454 *params
= (GLfloat
) sampObj
->WrapR
;
1456 case GL_TEXTURE_MIN_FILTER
:
1457 *params
= (GLfloat
) sampObj
->MinFilter
;
1459 case GL_TEXTURE_MAG_FILTER
:
1460 *params
= (GLfloat
) sampObj
->MagFilter
;
1462 case GL_TEXTURE_MIN_LOD
:
1463 *params
= sampObj
->MinLod
;
1465 case GL_TEXTURE_MAX_LOD
:
1466 *params
= sampObj
->MaxLod
;
1468 case GL_TEXTURE_LOD_BIAS
:
1469 *params
= sampObj
->LodBias
;
1471 case GL_TEXTURE_COMPARE_MODE
:
1472 *params
= (GLfloat
) sampObj
->CompareMode
;
1474 case GL_TEXTURE_COMPARE_FUNC
:
1475 *params
= (GLfloat
) sampObj
->CompareFunc
;
1477 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1478 *params
= sampObj
->MaxAnisotropy
;
1480 case GL_TEXTURE_BORDER_COLOR
:
1481 params
[0] = sampObj
->BorderColor
.f
[0];
1482 params
[1] = sampObj
->BorderColor
.f
[1];
1483 params
[2] = sampObj
->BorderColor
.f
[2];
1484 params
[3] = sampObj
->BorderColor
.f
[3];
1486 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1487 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1489 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1491 case GL_TEXTURE_SRGB_DECODE_EXT
:
1492 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1494 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1502 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1503 _mesa_enum_to_string(pname
));
1508 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1510 struct gl_sampler_object
*sampObj
;
1511 GET_CURRENT_CONTEXT(ctx
);
1513 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1515 _mesa_error(ctx
, GL_INVALID_VALUE
,
1516 "glGetSamplerParameterIiv(sampler %u)",
1522 case GL_TEXTURE_WRAP_S
:
1523 *params
= sampObj
->WrapS
;
1525 case GL_TEXTURE_WRAP_T
:
1526 *params
= sampObj
->WrapT
;
1528 case GL_TEXTURE_WRAP_R
:
1529 *params
= sampObj
->WrapR
;
1531 case GL_TEXTURE_MIN_FILTER
:
1532 *params
= sampObj
->MinFilter
;
1534 case GL_TEXTURE_MAG_FILTER
:
1535 *params
= sampObj
->MagFilter
;
1537 case GL_TEXTURE_MIN_LOD
:
1538 *params
= (GLint
) sampObj
->MinLod
;
1540 case GL_TEXTURE_MAX_LOD
:
1541 *params
= (GLint
) sampObj
->MaxLod
;
1543 case GL_TEXTURE_LOD_BIAS
:
1544 *params
= (GLint
) sampObj
->LodBias
;
1546 case GL_TEXTURE_COMPARE_MODE
:
1547 *params
= sampObj
->CompareMode
;
1549 case GL_TEXTURE_COMPARE_FUNC
:
1550 *params
= sampObj
->CompareFunc
;
1552 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1553 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1555 case GL_TEXTURE_BORDER_COLOR
:
1556 params
[0] = sampObj
->BorderColor
.i
[0];
1557 params
[1] = sampObj
->BorderColor
.i
[1];
1558 params
[2] = sampObj
->BorderColor
.i
[2];
1559 params
[3] = sampObj
->BorderColor
.i
[3];
1561 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1562 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1564 *params
= sampObj
->CubeMapSeamless
;
1566 case GL_TEXTURE_SRGB_DECODE_EXT
:
1567 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1569 *params
= (GLenum
) sampObj
->sRGBDecode
;
1577 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1578 _mesa_enum_to_string(pname
));
1583 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1585 struct gl_sampler_object
*sampObj
;
1586 GET_CURRENT_CONTEXT(ctx
);
1588 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1590 _mesa_error(ctx
, GL_INVALID_VALUE
,
1591 "glGetSamplerParameterIuiv(sampler %u)",
1597 case GL_TEXTURE_WRAP_S
:
1598 *params
= sampObj
->WrapS
;
1600 case GL_TEXTURE_WRAP_T
:
1601 *params
= sampObj
->WrapT
;
1603 case GL_TEXTURE_WRAP_R
:
1604 *params
= sampObj
->WrapR
;
1606 case GL_TEXTURE_MIN_FILTER
:
1607 *params
= sampObj
->MinFilter
;
1609 case GL_TEXTURE_MAG_FILTER
:
1610 *params
= sampObj
->MagFilter
;
1612 case GL_TEXTURE_MIN_LOD
:
1613 *params
= (GLuint
) sampObj
->MinLod
;
1615 case GL_TEXTURE_MAX_LOD
:
1616 *params
= (GLuint
) sampObj
->MaxLod
;
1618 case GL_TEXTURE_LOD_BIAS
:
1619 *params
= (GLuint
) sampObj
->LodBias
;
1621 case GL_TEXTURE_COMPARE_MODE
:
1622 *params
= sampObj
->CompareMode
;
1624 case GL_TEXTURE_COMPARE_FUNC
:
1625 *params
= sampObj
->CompareFunc
;
1627 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1628 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1630 case GL_TEXTURE_BORDER_COLOR
:
1631 params
[0] = sampObj
->BorderColor
.ui
[0];
1632 params
[1] = sampObj
->BorderColor
.ui
[1];
1633 params
[2] = sampObj
->BorderColor
.ui
[2];
1634 params
[3] = sampObj
->BorderColor
.ui
[3];
1636 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1637 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1639 *params
= sampObj
->CubeMapSeamless
;
1641 case GL_TEXTURE_SRGB_DECODE_EXT
:
1642 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1644 *params
= (GLenum
) sampObj
->sRGBDecode
;
1652 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1653 _mesa_enum_to_string(pname
));
1658 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1660 driver
->NewSamplerObject
= _mesa_new_sampler_object
;