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
;
274 _mesa_bind_sampler(struct gl_context
*ctx
, GLuint unit
,
275 struct gl_sampler_object
*sampObj
)
277 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
278 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
281 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
286 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
288 struct gl_sampler_object
*sampObj
;
289 GET_CURRENT_CONTEXT(ctx
);
291 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
292 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
297 /* Use the default sampler object, the one contained in the texture
303 /* user-defined sampler object */
304 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
306 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
311 /* bind new sampler */
312 _mesa_bind_sampler(ctx
, unit
, sampObj
);
317 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
319 GET_CURRENT_CONTEXT(ctx
);
322 /* The ARB_multi_bind spec says:
324 * "An INVALID_OPERATION error is generated if <first> + <count> is
325 * greater than the number of texture image units supported by
326 * the implementation."
328 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
329 _mesa_error(ctx
, GL_INVALID_OPERATION
,
330 "glBindSamplers(first=%u + count=%d > the value of "
331 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
332 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
336 FLUSH_VERTICES(ctx
, 0);
339 /* Note that the error semantics for multi-bind commands differ from
340 * those of other GL commands.
342 * The Issues section in the ARB_multi_bind spec says:
344 * "(11) Typically, OpenGL specifies that if an error is generated by
345 * a command, that command has no effect. This is somewhat
346 * unfortunate for multi-bind commands, because it would require
347 * a first pass to scan the entire list of bound objects for
348 * errors and then a second pass to actually perform the
349 * bindings. Should we have different error semantics?
351 * RESOLVED: Yes. In this specification, when the parameters for
352 * one of the <count> binding points are invalid, that binding
353 * point is not updated and an error will be generated. However,
354 * other binding points in the same command will be updated if
355 * their parameters are valid and no other error occurs."
358 begin_samplerobj_lookups(ctx
);
360 for (i
= 0; i
< count
; i
++) {
361 const GLuint unit
= first
+ i
;
362 struct gl_sampler_object
* const currentSampler
=
363 ctx
->Texture
.Unit
[unit
].Sampler
;
364 struct gl_sampler_object
*sampObj
;
366 if (samplers
[i
] != 0) {
367 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
368 sampObj
= currentSampler
;
370 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
372 /* The ARB_multi_bind spec says:
374 * "An INVALID_OPERATION error is generated if any value
375 * in <samplers> is not zero or the name of an existing
376 * sampler object (per binding)."
379 _mesa_error(ctx
, GL_INVALID_OPERATION
,
380 "glBindSamplers(samplers[%d]=%u is not zero or "
381 "the name of an existing sampler object)",
389 /* Bind the new sampler */
390 if (sampObj
!= currentSampler
) {
391 _mesa_reference_sampler_object(ctx
,
392 &ctx
->Texture
.Unit
[unit
].Sampler
,
394 ctx
->NewState
|= _NEW_TEXTURE
;
398 end_samplerobj_lookups(ctx
);
400 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
401 for (i
= 0; i
< count
; i
++) {
402 const GLuint unit
= first
+ i
;
404 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
405 _mesa_reference_sampler_object(ctx
,
406 &ctx
->Texture
.Unit
[unit
].Sampler
,
408 ctx
->NewState
|= _NEW_TEXTURE
;
416 * Check if a coordinate wrap mode is legal.
417 * \return GL_TRUE if legal, GL_FALSE otherwise
420 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
422 const struct gl_extensions
* const e
= &ctx
->Extensions
;
426 case GL_CLAMP_TO_EDGE
:
428 case GL_MIRRORED_REPEAT
:
430 case GL_CLAMP_TO_BORDER
:
431 return e
->ARB_texture_border_clamp
;
432 case GL_MIRROR_CLAMP_EXT
:
433 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
434 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
435 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
436 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
437 return e
->EXT_texture_mirror_clamp
;
445 * This is called just prior to changing any sampler object state.
448 flush(struct gl_context
*ctx
)
450 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
454 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
455 GLenum s
, GLenum t
, GLenum r
)
457 assert(validate_texture_wrap_mode(ctx
, s
));
458 assert(validate_texture_wrap_mode(ctx
, t
));
459 assert(validate_texture_wrap_mode(ctx
, r
));
461 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
470 #define INVALID_PARAM 0x100
471 #define INVALID_PNAME 0x101
472 #define INVALID_VALUE 0x102
475 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
478 if (samp
->WrapS
== param
)
480 if (validate_texture_wrap_mode(ctx
, param
)) {
485 return INVALID_PARAM
;
490 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
493 if (samp
->WrapT
== param
)
495 if (validate_texture_wrap_mode(ctx
, param
)) {
500 return INVALID_PARAM
;
505 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
508 if (samp
->WrapR
== param
)
510 if (validate_texture_wrap_mode(ctx
, param
)) {
515 return INVALID_PARAM
;
519 _mesa_set_sampler_filters(struct gl_context
*ctx
,
520 struct gl_sampler_object
*samp
,
521 GLenum min_filter
, GLenum mag_filter
)
523 assert(min_filter
== GL_NEAREST
||
524 min_filter
== GL_LINEAR
||
525 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
526 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
527 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
528 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
529 assert(mag_filter
== GL_NEAREST
||
530 mag_filter
== GL_LINEAR
);
532 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
536 samp
->MinFilter
= min_filter
;
537 samp
->MagFilter
= mag_filter
;
541 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
544 if (samp
->MinFilter
== param
)
550 case GL_NEAREST_MIPMAP_NEAREST
:
551 case GL_LINEAR_MIPMAP_NEAREST
:
552 case GL_NEAREST_MIPMAP_LINEAR
:
553 case GL_LINEAR_MIPMAP_LINEAR
:
555 samp
->MinFilter
= param
;
558 return INVALID_PARAM
;
564 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
567 if (samp
->MagFilter
== param
)
574 samp
->MagFilter
= param
;
577 return INVALID_PARAM
;
583 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
586 if (samp
->LodBias
== param
)
590 samp
->LodBias
= param
;
596 set_sampler_border_colorf(struct gl_context
*ctx
,
597 struct gl_sampler_object
*samp
,
598 const GLfloat params
[4])
601 samp
->BorderColor
.f
[RCOMP
] = params
[0];
602 samp
->BorderColor
.f
[GCOMP
] = params
[1];
603 samp
->BorderColor
.f
[BCOMP
] = params
[2];
604 samp
->BorderColor
.f
[ACOMP
] = params
[3];
610 set_sampler_border_colori(struct gl_context
*ctx
,
611 struct gl_sampler_object
*samp
,
612 const GLint params
[4])
615 samp
->BorderColor
.i
[RCOMP
] = params
[0];
616 samp
->BorderColor
.i
[GCOMP
] = params
[1];
617 samp
->BorderColor
.i
[BCOMP
] = params
[2];
618 samp
->BorderColor
.i
[ACOMP
] = params
[3];
624 set_sampler_border_colorui(struct gl_context
*ctx
,
625 struct gl_sampler_object
*samp
,
626 const GLuint params
[4])
629 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
630 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
631 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
632 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
638 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
641 if (samp
->MinLod
== param
)
645 samp
->MinLod
= param
;
651 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
654 if (samp
->MaxLod
== param
)
658 samp
->MaxLod
= param
;
664 set_sampler_compare_mode(struct gl_context
*ctx
,
665 struct gl_sampler_object
*samp
, GLint param
)
667 /* If GL_ARB_shadow is not supported, don't report an error. The
668 * sampler object extension spec isn't clear on this extension interaction.
669 * Silences errors with Wine on older GPUs such as R200.
671 if (!ctx
->Extensions
.ARB_shadow
)
674 if (samp
->CompareMode
== param
)
677 if (param
== GL_NONE
||
678 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
680 samp
->CompareMode
= param
;
684 return INVALID_PARAM
;
689 set_sampler_compare_func(struct gl_context
*ctx
,
690 struct gl_sampler_object
*samp
, GLint param
)
692 /* If GL_ARB_shadow is not supported, don't report an error. The
693 * sampler object extension spec isn't clear on this extension interaction.
694 * Silences errors with Wine on older GPUs such as R200.
696 if (!ctx
->Extensions
.ARB_shadow
)
699 if (samp
->CompareFunc
== param
)
712 samp
->CompareFunc
= param
;
715 return INVALID_PARAM
;
721 set_sampler_max_anisotropy(struct gl_context
*ctx
,
722 struct gl_sampler_object
*samp
, GLfloat param
)
724 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
725 return INVALID_PNAME
;
727 if (samp
->MaxAnisotropy
== param
)
731 return INVALID_VALUE
;
734 /* clamp to max, that's what NVIDIA does */
735 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
741 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
742 struct gl_sampler_object
*samp
, GLboolean param
)
744 if (!_mesa_is_desktop_gl(ctx
)
745 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
746 return INVALID_PNAME
;
748 if (samp
->CubeMapSeamless
== param
)
751 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
752 return INVALID_VALUE
;
755 samp
->CubeMapSeamless
= param
;
760 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
761 struct gl_sampler_object
*samp
, GLenum param
)
763 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
766 samp
->sRGBDecode
= param
;
770 set_sampler_srgb_decode(struct gl_context
*ctx
,
771 struct gl_sampler_object
*samp
, GLenum param
)
773 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
774 return INVALID_PNAME
;
776 if (samp
->sRGBDecode
== param
)
779 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
780 return INVALID_VALUE
;
783 samp
->sRGBDecode
= param
;
788 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
790 struct gl_sampler_object
*sampObj
;
792 GET_CURRENT_CONTEXT(ctx
);
794 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
796 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
798 * "An INVALID_OPERATION error is generated if sampler is not the name
799 * of a sampler object previously returned from a call to GenSamplers."
801 * In desktop GL, an GL_INVALID_VALUE is returned instead.
803 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
804 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
805 "glSamplerParameteri(sampler %u)", sampler
);
810 case GL_TEXTURE_WRAP_S
:
811 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
813 case GL_TEXTURE_WRAP_T
:
814 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
816 case GL_TEXTURE_WRAP_R
:
817 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
819 case GL_TEXTURE_MIN_FILTER
:
820 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
822 case GL_TEXTURE_MAG_FILTER
:
823 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
825 case GL_TEXTURE_MIN_LOD
:
826 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
828 case GL_TEXTURE_MAX_LOD
:
829 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
831 case GL_TEXTURE_LOD_BIAS
:
832 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
834 case GL_TEXTURE_COMPARE_MODE
:
835 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
837 case GL_TEXTURE_COMPARE_FUNC
:
838 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
840 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
841 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
843 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
844 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
846 case GL_TEXTURE_SRGB_DECODE_EXT
:
847 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
849 case GL_TEXTURE_BORDER_COLOR
:
860 /* state change - we do nothing special at this time */
863 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
864 _mesa_enum_to_string(pname
));
867 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
871 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
881 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
883 struct gl_sampler_object
*sampObj
;
885 GET_CURRENT_CONTEXT(ctx
);
887 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
889 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
891 * "An INVALID_OPERATION error is generated if sampler is not the name
892 * of a sampler object previously returned from a call to GenSamplers."
894 * In desktop GL, an GL_INVALID_VALUE is returned instead.
896 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
897 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
898 "glSamplerParameterf(sampler %u)", sampler
);
903 case GL_TEXTURE_WRAP_S
:
904 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
906 case GL_TEXTURE_WRAP_T
:
907 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
909 case GL_TEXTURE_WRAP_R
:
910 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
912 case GL_TEXTURE_MIN_FILTER
:
913 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
915 case GL_TEXTURE_MAG_FILTER
:
916 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
918 case GL_TEXTURE_MIN_LOD
:
919 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
921 case GL_TEXTURE_MAX_LOD
:
922 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
924 case GL_TEXTURE_LOD_BIAS
:
925 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
927 case GL_TEXTURE_COMPARE_MODE
:
928 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
930 case GL_TEXTURE_COMPARE_FUNC
:
931 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
933 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
934 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
936 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
937 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
939 case GL_TEXTURE_SRGB_DECODE_EXT
:
940 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
942 case GL_TEXTURE_BORDER_COLOR
:
953 /* state change - we do nothing special at this time */
956 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
957 _mesa_enum_to_string(pname
));
960 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
964 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
973 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
975 struct gl_sampler_object
*sampObj
;
977 GET_CURRENT_CONTEXT(ctx
);
979 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
981 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
983 * "An INVALID_OPERATION error is generated if sampler is not the name
984 * of a sampler object previously returned from a call to GenSamplers."
986 * In desktop GL, an GL_INVALID_VALUE is returned instead.
988 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
989 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
990 "glSamplerParameteriv(sampler %u)", sampler
);
995 case GL_TEXTURE_WRAP_S
:
996 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
998 case GL_TEXTURE_WRAP_T
:
999 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1001 case GL_TEXTURE_WRAP_R
:
1002 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1004 case GL_TEXTURE_MIN_FILTER
:
1005 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1007 case GL_TEXTURE_MAG_FILTER
:
1008 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1010 case GL_TEXTURE_MIN_LOD
:
1011 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1013 case GL_TEXTURE_MAX_LOD
:
1014 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1016 case GL_TEXTURE_LOD_BIAS
:
1017 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1019 case GL_TEXTURE_COMPARE_MODE
:
1020 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1022 case GL_TEXTURE_COMPARE_FUNC
:
1023 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1025 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1026 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1028 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1029 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1031 case GL_TEXTURE_SRGB_DECODE_EXT
:
1032 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1034 case GL_TEXTURE_BORDER_COLOR
:
1037 c
[0] = INT_TO_FLOAT(params
[0]);
1038 c
[1] = INT_TO_FLOAT(params
[1]);
1039 c
[2] = INT_TO_FLOAT(params
[2]);
1040 c
[3] = INT_TO_FLOAT(params
[3]);
1041 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1045 res
= INVALID_PNAME
;
1053 /* state change - we do nothing special at this time */
1056 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1057 _mesa_enum_to_string(pname
));
1060 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1064 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1073 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1075 struct gl_sampler_object
*sampObj
;
1077 GET_CURRENT_CONTEXT(ctx
);
1079 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1081 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1083 * "An INVALID_OPERATION error is generated if sampler is not the name
1084 * of a sampler object previously returned from a call to GenSamplers."
1086 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1088 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1089 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1090 "glSamplerParameterfv(sampler %u)", sampler
);
1095 case GL_TEXTURE_WRAP_S
:
1096 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1098 case GL_TEXTURE_WRAP_T
:
1099 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1101 case GL_TEXTURE_WRAP_R
:
1102 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1104 case GL_TEXTURE_MIN_FILTER
:
1105 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1107 case GL_TEXTURE_MAG_FILTER
:
1108 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1110 case GL_TEXTURE_MIN_LOD
:
1111 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1113 case GL_TEXTURE_MAX_LOD
:
1114 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1116 case GL_TEXTURE_LOD_BIAS
:
1117 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1119 case GL_TEXTURE_COMPARE_MODE
:
1120 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1122 case GL_TEXTURE_COMPARE_FUNC
:
1123 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1125 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1126 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1128 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1129 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1131 case GL_TEXTURE_SRGB_DECODE_EXT
:
1132 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1134 case GL_TEXTURE_BORDER_COLOR
:
1135 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1138 res
= INVALID_PNAME
;
1146 /* state change - we do nothing special at this time */
1149 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1150 _mesa_enum_to_string(pname
));
1153 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1157 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1166 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1168 struct gl_sampler_object
*sampObj
;
1170 GET_CURRENT_CONTEXT(ctx
);
1172 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1174 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1180 case GL_TEXTURE_WRAP_S
:
1181 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1183 case GL_TEXTURE_WRAP_T
:
1184 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1186 case GL_TEXTURE_WRAP_R
:
1187 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1189 case GL_TEXTURE_MIN_FILTER
:
1190 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1192 case GL_TEXTURE_MAG_FILTER
:
1193 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1195 case GL_TEXTURE_MIN_LOD
:
1196 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1198 case GL_TEXTURE_MAX_LOD
:
1199 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1201 case GL_TEXTURE_LOD_BIAS
:
1202 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1204 case GL_TEXTURE_COMPARE_MODE
:
1205 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1207 case GL_TEXTURE_COMPARE_FUNC
:
1208 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1210 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1211 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1213 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1214 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1216 case GL_TEXTURE_SRGB_DECODE_EXT
:
1217 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1219 case GL_TEXTURE_BORDER_COLOR
:
1220 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1223 res
= INVALID_PNAME
;
1231 /* state change - we do nothing special at this time */
1234 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1235 _mesa_enum_to_string(pname
));
1238 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1242 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1252 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1254 struct gl_sampler_object
*sampObj
;
1256 GET_CURRENT_CONTEXT(ctx
);
1258 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1260 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1266 case GL_TEXTURE_WRAP_S
:
1267 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1269 case GL_TEXTURE_WRAP_T
:
1270 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1272 case GL_TEXTURE_WRAP_R
:
1273 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1275 case GL_TEXTURE_MIN_FILTER
:
1276 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1278 case GL_TEXTURE_MAG_FILTER
:
1279 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1281 case GL_TEXTURE_MIN_LOD
:
1282 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1284 case GL_TEXTURE_MAX_LOD
:
1285 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1287 case GL_TEXTURE_LOD_BIAS
:
1288 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1290 case GL_TEXTURE_COMPARE_MODE
:
1291 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1293 case GL_TEXTURE_COMPARE_FUNC
:
1294 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1296 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1297 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1299 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1300 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1302 case GL_TEXTURE_SRGB_DECODE_EXT
:
1303 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1305 case GL_TEXTURE_BORDER_COLOR
:
1306 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1309 res
= INVALID_PNAME
;
1317 /* state change - we do nothing special at this time */
1320 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1321 _mesa_enum_to_string(pname
));
1324 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1328 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1338 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1340 struct gl_sampler_object
*sampObj
;
1341 GET_CURRENT_CONTEXT(ctx
);
1343 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1345 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1347 * "An INVALID_OPERATION error is generated if sampler is not the name
1348 * of a sampler object previously returned from a call to GenSamplers."
1350 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1352 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1353 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1354 "glGetSamplerParameteriv(sampler %u)", sampler
);
1359 case GL_TEXTURE_WRAP_S
:
1360 *params
= sampObj
->WrapS
;
1362 case GL_TEXTURE_WRAP_T
:
1363 *params
= sampObj
->WrapT
;
1365 case GL_TEXTURE_WRAP_R
:
1366 *params
= sampObj
->WrapR
;
1368 case GL_TEXTURE_MIN_FILTER
:
1369 *params
= sampObj
->MinFilter
;
1371 case GL_TEXTURE_MAG_FILTER
:
1372 *params
= sampObj
->MagFilter
;
1374 case GL_TEXTURE_MIN_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
->MinLod
);
1380 case GL_TEXTURE_MAX_LOD
:
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
->MaxLod
);
1386 case GL_TEXTURE_LOD_BIAS
:
1387 /* GL spec 'Data Conversions' section specifies that floating-point
1388 * value in integer Get function is rounded to nearest integer
1390 *params
= IROUND(sampObj
->LodBias
);
1392 case GL_TEXTURE_COMPARE_MODE
:
1393 *params
= sampObj
->CompareMode
;
1395 case GL_TEXTURE_COMPARE_FUNC
:
1396 *params
= sampObj
->CompareFunc
;
1398 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1399 /* GL spec 'Data Conversions' section specifies that floating-point
1400 * value in integer Get function is rounded to nearest integer
1402 *params
= IROUND(sampObj
->MaxAnisotropy
);
1404 case GL_TEXTURE_BORDER_COLOR
:
1405 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1406 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1407 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1408 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1410 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1411 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1413 *params
= sampObj
->CubeMapSeamless
;
1415 case GL_TEXTURE_SRGB_DECODE_EXT
:
1416 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1418 *params
= (GLenum
) sampObj
->sRGBDecode
;
1426 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1427 _mesa_enum_to_string(pname
));
1432 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1434 struct gl_sampler_object
*sampObj
;
1435 GET_CURRENT_CONTEXT(ctx
);
1437 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1439 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1441 * "An INVALID_OPERATION error is generated if sampler is not the name
1442 * of a sampler object previously returned from a call to GenSamplers."
1444 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1446 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1447 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1448 "glGetSamplerParameterfv(sampler %u)", sampler
);
1453 case GL_TEXTURE_WRAP_S
:
1454 *params
= (GLfloat
) sampObj
->WrapS
;
1456 case GL_TEXTURE_WRAP_T
:
1457 *params
= (GLfloat
) sampObj
->WrapT
;
1459 case GL_TEXTURE_WRAP_R
:
1460 *params
= (GLfloat
) sampObj
->WrapR
;
1462 case GL_TEXTURE_MIN_FILTER
:
1463 *params
= (GLfloat
) sampObj
->MinFilter
;
1465 case GL_TEXTURE_MAG_FILTER
:
1466 *params
= (GLfloat
) sampObj
->MagFilter
;
1468 case GL_TEXTURE_MIN_LOD
:
1469 *params
= sampObj
->MinLod
;
1471 case GL_TEXTURE_MAX_LOD
:
1472 *params
= sampObj
->MaxLod
;
1474 case GL_TEXTURE_LOD_BIAS
:
1475 *params
= sampObj
->LodBias
;
1477 case GL_TEXTURE_COMPARE_MODE
:
1478 *params
= (GLfloat
) sampObj
->CompareMode
;
1480 case GL_TEXTURE_COMPARE_FUNC
:
1481 *params
= (GLfloat
) sampObj
->CompareFunc
;
1483 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1484 *params
= sampObj
->MaxAnisotropy
;
1486 case GL_TEXTURE_BORDER_COLOR
:
1487 params
[0] = sampObj
->BorderColor
.f
[0];
1488 params
[1] = sampObj
->BorderColor
.f
[1];
1489 params
[2] = sampObj
->BorderColor
.f
[2];
1490 params
[3] = sampObj
->BorderColor
.f
[3];
1492 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1493 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1495 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1497 case GL_TEXTURE_SRGB_DECODE_EXT
:
1498 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1500 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1508 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1509 _mesa_enum_to_string(pname
));
1514 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1516 struct gl_sampler_object
*sampObj
;
1517 GET_CURRENT_CONTEXT(ctx
);
1519 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1521 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1522 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1523 "glGetSamplerParameterIiv(sampler %u)",
1529 case GL_TEXTURE_WRAP_S
:
1530 *params
= sampObj
->WrapS
;
1532 case GL_TEXTURE_WRAP_T
:
1533 *params
= sampObj
->WrapT
;
1535 case GL_TEXTURE_WRAP_R
:
1536 *params
= sampObj
->WrapR
;
1538 case GL_TEXTURE_MIN_FILTER
:
1539 *params
= sampObj
->MinFilter
;
1541 case GL_TEXTURE_MAG_FILTER
:
1542 *params
= sampObj
->MagFilter
;
1544 case GL_TEXTURE_MIN_LOD
:
1545 *params
= (GLint
) sampObj
->MinLod
;
1547 case GL_TEXTURE_MAX_LOD
:
1548 *params
= (GLint
) sampObj
->MaxLod
;
1550 case GL_TEXTURE_LOD_BIAS
:
1551 *params
= (GLint
) sampObj
->LodBias
;
1553 case GL_TEXTURE_COMPARE_MODE
:
1554 *params
= sampObj
->CompareMode
;
1556 case GL_TEXTURE_COMPARE_FUNC
:
1557 *params
= sampObj
->CompareFunc
;
1559 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1560 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1562 case GL_TEXTURE_BORDER_COLOR
:
1563 params
[0] = sampObj
->BorderColor
.i
[0];
1564 params
[1] = sampObj
->BorderColor
.i
[1];
1565 params
[2] = sampObj
->BorderColor
.i
[2];
1566 params
[3] = sampObj
->BorderColor
.i
[3];
1568 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1569 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1571 *params
= sampObj
->CubeMapSeamless
;
1573 case GL_TEXTURE_SRGB_DECODE_EXT
:
1574 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1576 *params
= (GLenum
) sampObj
->sRGBDecode
;
1584 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1585 _mesa_enum_to_string(pname
));
1590 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1592 struct gl_sampler_object
*sampObj
;
1593 GET_CURRENT_CONTEXT(ctx
);
1595 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1597 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1598 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1599 "glGetSamplerParameterIuiv(sampler %u)",
1605 case GL_TEXTURE_WRAP_S
:
1606 *params
= sampObj
->WrapS
;
1608 case GL_TEXTURE_WRAP_T
:
1609 *params
= sampObj
->WrapT
;
1611 case GL_TEXTURE_WRAP_R
:
1612 *params
= sampObj
->WrapR
;
1614 case GL_TEXTURE_MIN_FILTER
:
1615 *params
= sampObj
->MinFilter
;
1617 case GL_TEXTURE_MAG_FILTER
:
1618 *params
= sampObj
->MagFilter
;
1620 case GL_TEXTURE_MIN_LOD
:
1621 *params
= (GLuint
) sampObj
->MinLod
;
1623 case GL_TEXTURE_MAX_LOD
:
1624 *params
= (GLuint
) sampObj
->MaxLod
;
1626 case GL_TEXTURE_LOD_BIAS
:
1627 *params
= (GLuint
) sampObj
->LodBias
;
1629 case GL_TEXTURE_COMPARE_MODE
:
1630 *params
= sampObj
->CompareMode
;
1632 case GL_TEXTURE_COMPARE_FUNC
:
1633 *params
= sampObj
->CompareFunc
;
1635 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1636 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1638 case GL_TEXTURE_BORDER_COLOR
:
1639 params
[0] = sampObj
->BorderColor
.ui
[0];
1640 params
[1] = sampObj
->BorderColor
.ui
[1];
1641 params
[2] = sampObj
->BorderColor
.ui
[2];
1642 params
[3] = sampObj
->BorderColor
.ui
[3];
1644 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1645 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1647 *params
= sampObj
->CubeMapSeamless
;
1649 case GL_TEXTURE_SRGB_DECODE_EXT
:
1650 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1652 *params
= (GLenum
) sampObj
->sRGBDecode
;
1660 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1661 _mesa_enum_to_string(pname
));
1666 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1668 driver
->NewSamplerObject
= _mesa_new_sampler_object
;