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
);
53 static struct gl_sampler_object
*
54 _mesa_lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
59 return (struct gl_sampler_object
*)
60 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
64 begin_samplerobj_lookups(struct gl_context
*ctx
)
66 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
71 end_samplerobj_lookups(struct gl_context
*ctx
)
73 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
77 static inline struct gl_sampler_object
*
78 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
80 return (struct gl_sampler_object
*)
81 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
85 delete_sampler_object(struct gl_context
*ctx
,
86 struct gl_sampler_object
*sampObj
)
88 mtx_destroy(&sampObj
->Mutex
);
94 * Handle reference counting.
97 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
98 struct gl_sampler_object
**ptr
,
99 struct gl_sampler_object
*samp
)
101 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
104 /* Unreference the old sampler */
105 GLboolean deleteFlag
= GL_FALSE
;
106 struct gl_sampler_object
*oldSamp
= *ptr
;
108 mtx_lock(&oldSamp
->Mutex
);
109 assert(oldSamp
->RefCount
> 0);
111 deleteFlag
= (oldSamp
->RefCount
== 0);
112 mtx_unlock(&oldSamp
->Mutex
);
115 delete_sampler_object(ctx
, oldSamp
);
122 /* reference new sampler */
123 mtx_lock(&samp
->Mutex
);
124 if (samp
->RefCount
== 0) {
125 /* this sampler's being deleted (look just above) */
126 /* Not sure this can every really happen. Warn if it does. */
127 _mesa_problem(NULL
, "referencing deleted sampler object");
134 mtx_unlock(&samp
->Mutex
);
140 * Initialize the fields of the given sampler object.
143 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
145 mtx_init(&sampObj
->Mutex
, mtx_plain
);
146 sampObj
->Name
= name
;
147 sampObj
->RefCount
= 1;
148 sampObj
->WrapS
= GL_REPEAT
;
149 sampObj
->WrapT
= GL_REPEAT
;
150 sampObj
->WrapR
= GL_REPEAT
;
151 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
152 sampObj
->MagFilter
= GL_LINEAR
;
153 sampObj
->BorderColor
.f
[0] = 0.0;
154 sampObj
->BorderColor
.f
[1] = 0.0;
155 sampObj
->BorderColor
.f
[2] = 0.0;
156 sampObj
->BorderColor
.f
[3] = 0.0;
157 sampObj
->MinLod
= -1000.0F
;
158 sampObj
->MaxLod
= 1000.0F
;
159 sampObj
->LodBias
= 0.0F
;
160 sampObj
->MaxAnisotropy
= 1.0F
;
161 sampObj
->CompareMode
= GL_NONE
;
162 sampObj
->CompareFunc
= GL_LEQUAL
;
163 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
164 sampObj
->CubeMapSeamless
= GL_FALSE
;
168 * Fallback for ctx->Driver.NewSamplerObject();
170 struct gl_sampler_object
*
171 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
173 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
175 _mesa_init_sampler_object(sampObj
, name
);
181 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
187 if (MESA_VERBOSE
& VERBOSE_API
)
188 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
191 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
198 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
200 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
202 /* Insert the ID and pointer to new sampler object into hash table */
203 for (i
= 0; i
< count
; i
++) {
204 struct gl_sampler_object
*sampObj
=
205 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
206 _mesa_HashInsertLocked(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
207 samplers
[i
] = first
+ i
;
210 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
214 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
216 GET_CURRENT_CONTEXT(ctx
);
217 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
221 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
223 GET_CURRENT_CONTEXT(ctx
);
224 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
229 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
231 GET_CURRENT_CONTEXT(ctx
);
234 FLUSH_VERTICES(ctx
, 0);
237 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
241 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
243 for (i
= 0; i
< count
; i
++) {
246 struct gl_sampler_object
*sampObj
=
247 _mesa_lookup_samplerobj_locked(ctx
, samplers
[i
]);
250 /* If the sampler is currently bound, unbind it. */
251 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
252 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
253 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
254 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
258 /* The ID is immediately freed for re-use */
259 _mesa_HashRemoveLocked(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
260 /* But the object exists until its reference count goes to zero */
261 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
266 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
271 _mesa_IsSampler(GLuint sampler
)
273 struct gl_sampler_object
*sampObj
;
274 GET_CURRENT_CONTEXT(ctx
);
276 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
281 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
283 return sampObj
!= NULL
;
287 _mesa_bind_sampler(struct gl_context
*ctx
, GLuint unit
,
288 struct gl_sampler_object
*sampObj
)
290 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
291 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
294 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
299 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
301 struct gl_sampler_object
*sampObj
;
302 GET_CURRENT_CONTEXT(ctx
);
304 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
305 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
310 /* Use the default sampler object, the one contained in the texture
316 /* user-defined sampler object */
317 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
319 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
324 /* bind new sampler */
325 _mesa_bind_sampler(ctx
, unit
, sampObj
);
330 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
332 GET_CURRENT_CONTEXT(ctx
);
335 /* The ARB_multi_bind spec says:
337 * "An INVALID_OPERATION error is generated if <first> + <count> is
338 * greater than the number of texture image units supported by
339 * the implementation."
341 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
342 _mesa_error(ctx
, GL_INVALID_OPERATION
,
343 "glBindSamplers(first=%u + count=%d > the value of "
344 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
345 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
349 FLUSH_VERTICES(ctx
, 0);
352 /* Note that the error semantics for multi-bind commands differ from
353 * those of other GL commands.
355 * The Issues section in the ARB_multi_bind spec says:
357 * "(11) Typically, OpenGL specifies that if an error is generated by
358 * a command, that command has no effect. This is somewhat
359 * unfortunate for multi-bind commands, because it would require
360 * a first pass to scan the entire list of bound objects for
361 * errors and then a second pass to actually perform the
362 * bindings. Should we have different error semantics?
364 * RESOLVED: Yes. In this specification, when the parameters for
365 * one of the <count> binding points are invalid, that binding
366 * point is not updated and an error will be generated. However,
367 * other binding points in the same command will be updated if
368 * their parameters are valid and no other error occurs."
371 begin_samplerobj_lookups(ctx
);
373 for (i
= 0; i
< count
; i
++) {
374 const GLuint unit
= first
+ i
;
375 struct gl_sampler_object
* const currentSampler
=
376 ctx
->Texture
.Unit
[unit
].Sampler
;
377 struct gl_sampler_object
*sampObj
;
379 if (samplers
[i
] != 0) {
380 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
381 sampObj
= currentSampler
;
383 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
385 /* The ARB_multi_bind spec says:
387 * "An INVALID_OPERATION error is generated if any value
388 * in <samplers> is not zero or the name of an existing
389 * sampler object (per binding)."
392 _mesa_error(ctx
, GL_INVALID_OPERATION
,
393 "glBindSamplers(samplers[%d]=%u is not zero or "
394 "the name of an existing sampler object)",
402 /* Bind the new sampler */
403 if (sampObj
!= currentSampler
) {
404 _mesa_reference_sampler_object(ctx
,
405 &ctx
->Texture
.Unit
[unit
].Sampler
,
407 ctx
->NewState
|= _NEW_TEXTURE
;
411 end_samplerobj_lookups(ctx
);
413 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
414 for (i
= 0; i
< count
; i
++) {
415 const GLuint unit
= first
+ i
;
417 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
418 _mesa_reference_sampler_object(ctx
,
419 &ctx
->Texture
.Unit
[unit
].Sampler
,
421 ctx
->NewState
|= _NEW_TEXTURE
;
429 * Check if a coordinate wrap mode is legal.
430 * \return GL_TRUE if legal, GL_FALSE otherwise
433 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
435 const struct gl_extensions
* const e
= &ctx
->Extensions
;
439 case GL_CLAMP_TO_EDGE
:
441 case GL_MIRRORED_REPEAT
:
443 case GL_CLAMP_TO_BORDER
:
444 return e
->ARB_texture_border_clamp
;
445 case GL_MIRROR_CLAMP_EXT
:
446 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
447 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
448 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
449 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
450 return e
->EXT_texture_mirror_clamp
;
458 * This is called just prior to changing any sampler object state.
461 flush(struct gl_context
*ctx
)
463 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
467 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
468 GLenum s
, GLenum t
, GLenum r
)
470 assert(validate_texture_wrap_mode(ctx
, s
));
471 assert(validate_texture_wrap_mode(ctx
, t
));
472 assert(validate_texture_wrap_mode(ctx
, r
));
474 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
483 #define INVALID_PARAM 0x100
484 #define INVALID_PNAME 0x101
485 #define INVALID_VALUE 0x102
488 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
491 if (samp
->WrapS
== param
)
493 if (validate_texture_wrap_mode(ctx
, param
)) {
498 return INVALID_PARAM
;
503 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
506 if (samp
->WrapT
== param
)
508 if (validate_texture_wrap_mode(ctx
, param
)) {
513 return INVALID_PARAM
;
518 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
521 if (samp
->WrapR
== param
)
523 if (validate_texture_wrap_mode(ctx
, param
)) {
528 return INVALID_PARAM
;
532 _mesa_set_sampler_filters(struct gl_context
*ctx
,
533 struct gl_sampler_object
*samp
,
534 GLenum min_filter
, GLenum mag_filter
)
536 assert(min_filter
== GL_NEAREST
||
537 min_filter
== GL_LINEAR
||
538 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
539 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
540 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
541 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
542 assert(mag_filter
== GL_NEAREST
||
543 mag_filter
== GL_LINEAR
);
545 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
549 samp
->MinFilter
= min_filter
;
550 samp
->MagFilter
= mag_filter
;
554 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
557 if (samp
->MinFilter
== param
)
563 case GL_NEAREST_MIPMAP_NEAREST
:
564 case GL_LINEAR_MIPMAP_NEAREST
:
565 case GL_NEAREST_MIPMAP_LINEAR
:
566 case GL_LINEAR_MIPMAP_LINEAR
:
568 samp
->MinFilter
= param
;
571 return INVALID_PARAM
;
577 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
580 if (samp
->MagFilter
== param
)
587 samp
->MagFilter
= param
;
590 return INVALID_PARAM
;
596 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
599 if (samp
->LodBias
== param
)
603 samp
->LodBias
= param
;
609 set_sampler_border_colorf(struct gl_context
*ctx
,
610 struct gl_sampler_object
*samp
,
611 const GLfloat params
[4])
614 samp
->BorderColor
.f
[RCOMP
] = params
[0];
615 samp
->BorderColor
.f
[GCOMP
] = params
[1];
616 samp
->BorderColor
.f
[BCOMP
] = params
[2];
617 samp
->BorderColor
.f
[ACOMP
] = params
[3];
623 set_sampler_border_colori(struct gl_context
*ctx
,
624 struct gl_sampler_object
*samp
,
625 const GLint params
[4])
628 samp
->BorderColor
.i
[RCOMP
] = params
[0];
629 samp
->BorderColor
.i
[GCOMP
] = params
[1];
630 samp
->BorderColor
.i
[BCOMP
] = params
[2];
631 samp
->BorderColor
.i
[ACOMP
] = params
[3];
637 set_sampler_border_colorui(struct gl_context
*ctx
,
638 struct gl_sampler_object
*samp
,
639 const GLuint params
[4])
642 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
643 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
644 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
645 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
651 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
654 if (samp
->MinLod
== param
)
658 samp
->MinLod
= param
;
664 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
667 if (samp
->MaxLod
== param
)
671 samp
->MaxLod
= param
;
677 set_sampler_compare_mode(struct gl_context
*ctx
,
678 struct gl_sampler_object
*samp
, GLint param
)
680 /* If GL_ARB_shadow is not supported, don't report an error. The
681 * sampler object extension spec isn't clear on this extension interaction.
682 * Silences errors with Wine on older GPUs such as R200.
684 if (!ctx
->Extensions
.ARB_shadow
)
687 if (samp
->CompareMode
== param
)
690 if (param
== GL_NONE
||
691 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
693 samp
->CompareMode
= param
;
697 return INVALID_PARAM
;
702 set_sampler_compare_func(struct gl_context
*ctx
,
703 struct gl_sampler_object
*samp
, GLint param
)
705 /* If GL_ARB_shadow is not supported, don't report an error. The
706 * sampler object extension spec isn't clear on this extension interaction.
707 * Silences errors with Wine on older GPUs such as R200.
709 if (!ctx
->Extensions
.ARB_shadow
)
712 if (samp
->CompareFunc
== param
)
725 samp
->CompareFunc
= param
;
728 return INVALID_PARAM
;
734 set_sampler_max_anisotropy(struct gl_context
*ctx
,
735 struct gl_sampler_object
*samp
, GLfloat param
)
737 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
738 return INVALID_PNAME
;
740 if (samp
->MaxAnisotropy
== param
)
744 return INVALID_VALUE
;
747 /* clamp to max, that's what NVIDIA does */
748 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
754 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
755 struct gl_sampler_object
*samp
, GLboolean param
)
757 if (!_mesa_is_desktop_gl(ctx
)
758 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
759 return INVALID_PNAME
;
761 if (samp
->CubeMapSeamless
== param
)
764 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
765 return INVALID_VALUE
;
768 samp
->CubeMapSeamless
= param
;
773 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
774 struct gl_sampler_object
*samp
, GLenum param
)
776 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
779 samp
->sRGBDecode
= param
;
783 set_sampler_srgb_decode(struct gl_context
*ctx
,
784 struct gl_sampler_object
*samp
, GLenum param
)
786 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
787 return INVALID_PNAME
;
789 if (samp
->sRGBDecode
== param
)
792 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
793 return INVALID_VALUE
;
796 samp
->sRGBDecode
= param
;
801 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
803 struct gl_sampler_object
*sampObj
;
805 GET_CURRENT_CONTEXT(ctx
);
807 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
809 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
811 * "An INVALID_OPERATION error is generated if sampler is not the name
812 * of a sampler object previously returned from a call to GenSamplers."
815 _mesa_error(ctx
, GL_INVALID_OPERATION
,
816 "glSamplerParameteri(sampler %u)", sampler
);
821 case GL_TEXTURE_WRAP_S
:
822 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
824 case GL_TEXTURE_WRAP_T
:
825 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
827 case GL_TEXTURE_WRAP_R
:
828 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
830 case GL_TEXTURE_MIN_FILTER
:
831 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
833 case GL_TEXTURE_MAG_FILTER
:
834 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
836 case GL_TEXTURE_MIN_LOD
:
837 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
839 case GL_TEXTURE_MAX_LOD
:
840 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
842 case GL_TEXTURE_LOD_BIAS
:
843 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
845 case GL_TEXTURE_COMPARE_MODE
:
846 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
848 case GL_TEXTURE_COMPARE_FUNC
:
849 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
851 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
852 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
854 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
855 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
857 case GL_TEXTURE_SRGB_DECODE_EXT
:
858 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
860 case GL_TEXTURE_BORDER_COLOR
:
871 /* state change - we do nothing special at this time */
874 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
875 _mesa_enum_to_string(pname
));
878 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
882 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
892 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
894 struct gl_sampler_object
*sampObj
;
896 GET_CURRENT_CONTEXT(ctx
);
898 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
900 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
902 * "An INVALID_OPERATION error is generated if sampler is not the name
903 * of a sampler object previously returned from a call to GenSamplers."
906 _mesa_error(ctx
, GL_INVALID_OPERATION
,
907 "glSamplerParameterf(sampler %u)", sampler
);
912 case GL_TEXTURE_WRAP_S
:
913 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
915 case GL_TEXTURE_WRAP_T
:
916 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
918 case GL_TEXTURE_WRAP_R
:
919 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
921 case GL_TEXTURE_MIN_FILTER
:
922 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
924 case GL_TEXTURE_MAG_FILTER
:
925 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
927 case GL_TEXTURE_MIN_LOD
:
928 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
930 case GL_TEXTURE_MAX_LOD
:
931 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
933 case GL_TEXTURE_LOD_BIAS
:
934 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
936 case GL_TEXTURE_COMPARE_MODE
:
937 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
939 case GL_TEXTURE_COMPARE_FUNC
:
940 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
942 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
943 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
945 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
946 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
948 case GL_TEXTURE_SRGB_DECODE_EXT
:
949 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
951 case GL_TEXTURE_BORDER_COLOR
:
962 /* state change - we do nothing special at this time */
965 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
966 _mesa_enum_to_string(pname
));
969 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
973 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
982 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
984 struct gl_sampler_object
*sampObj
;
986 GET_CURRENT_CONTEXT(ctx
);
988 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
990 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
992 * "An INVALID_OPERATION error is generated if sampler is not the name
993 * of a sampler object previously returned from a call to GenSamplers."
995 _mesa_error(ctx
, GL_INVALID_OPERATION
,
996 "glSamplerParameteriv(sampler %u)", sampler
);
1001 case GL_TEXTURE_WRAP_S
:
1002 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1004 case GL_TEXTURE_WRAP_T
:
1005 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1007 case GL_TEXTURE_WRAP_R
:
1008 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1010 case GL_TEXTURE_MIN_FILTER
:
1011 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1013 case GL_TEXTURE_MAG_FILTER
:
1014 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1016 case GL_TEXTURE_MIN_LOD
:
1017 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1019 case GL_TEXTURE_MAX_LOD
:
1020 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1022 case GL_TEXTURE_LOD_BIAS
:
1023 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1025 case GL_TEXTURE_COMPARE_MODE
:
1026 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1028 case GL_TEXTURE_COMPARE_FUNC
:
1029 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1031 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1032 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1034 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1035 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1037 case GL_TEXTURE_SRGB_DECODE_EXT
:
1038 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1040 case GL_TEXTURE_BORDER_COLOR
:
1043 c
[0] = INT_TO_FLOAT(params
[0]);
1044 c
[1] = INT_TO_FLOAT(params
[1]);
1045 c
[2] = INT_TO_FLOAT(params
[2]);
1046 c
[3] = INT_TO_FLOAT(params
[3]);
1047 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1051 res
= INVALID_PNAME
;
1059 /* state change - we do nothing special at this time */
1062 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1063 _mesa_enum_to_string(pname
));
1066 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1070 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1079 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1081 struct gl_sampler_object
*sampObj
;
1083 GET_CURRENT_CONTEXT(ctx
);
1085 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1087 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1089 * "An INVALID_OPERATION error is generated if sampler is not the name
1090 * of a sampler object previously returned from a call to GenSamplers."
1093 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1094 "glSamplerParameterfv(sampler %u)", sampler
);
1099 case GL_TEXTURE_WRAP_S
:
1100 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1102 case GL_TEXTURE_WRAP_T
:
1103 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1105 case GL_TEXTURE_WRAP_R
:
1106 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1108 case GL_TEXTURE_MIN_FILTER
:
1109 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1111 case GL_TEXTURE_MAG_FILTER
:
1112 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1114 case GL_TEXTURE_MIN_LOD
:
1115 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1117 case GL_TEXTURE_MAX_LOD
:
1118 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1120 case GL_TEXTURE_LOD_BIAS
:
1121 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1123 case GL_TEXTURE_COMPARE_MODE
:
1124 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1126 case GL_TEXTURE_COMPARE_FUNC
:
1127 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1129 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1130 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1132 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1133 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1135 case GL_TEXTURE_SRGB_DECODE_EXT
:
1136 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1138 case GL_TEXTURE_BORDER_COLOR
:
1139 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1142 res
= INVALID_PNAME
;
1150 /* state change - we do nothing special at this time */
1153 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1154 _mesa_enum_to_string(pname
));
1157 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1161 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1170 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1172 struct gl_sampler_object
*sampObj
;
1174 GET_CURRENT_CONTEXT(ctx
);
1176 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1178 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1179 "glSamplerParameterIiv(sampler %u)", sampler
);
1184 case GL_TEXTURE_WRAP_S
:
1185 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1187 case GL_TEXTURE_WRAP_T
:
1188 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1190 case GL_TEXTURE_WRAP_R
:
1191 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1193 case GL_TEXTURE_MIN_FILTER
:
1194 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1196 case GL_TEXTURE_MAG_FILTER
:
1197 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1199 case GL_TEXTURE_MIN_LOD
:
1200 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1202 case GL_TEXTURE_MAX_LOD
:
1203 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1205 case GL_TEXTURE_LOD_BIAS
:
1206 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1208 case GL_TEXTURE_COMPARE_MODE
:
1209 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1211 case GL_TEXTURE_COMPARE_FUNC
:
1212 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1214 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1215 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1217 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1218 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1220 case GL_TEXTURE_SRGB_DECODE_EXT
:
1221 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1223 case GL_TEXTURE_BORDER_COLOR
:
1224 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1227 res
= INVALID_PNAME
;
1235 /* state change - we do nothing special at this time */
1238 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1239 _mesa_enum_to_string(pname
));
1242 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1246 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1256 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1258 struct gl_sampler_object
*sampObj
;
1260 GET_CURRENT_CONTEXT(ctx
);
1262 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1264 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1265 "glSamplerParameterIuiv(sampler %u)", sampler
);
1270 case GL_TEXTURE_WRAP_S
:
1271 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1273 case GL_TEXTURE_WRAP_T
:
1274 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1276 case GL_TEXTURE_WRAP_R
:
1277 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1279 case GL_TEXTURE_MIN_FILTER
:
1280 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1282 case GL_TEXTURE_MAG_FILTER
:
1283 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1285 case GL_TEXTURE_MIN_LOD
:
1286 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1288 case GL_TEXTURE_MAX_LOD
:
1289 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1291 case GL_TEXTURE_LOD_BIAS
:
1292 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1294 case GL_TEXTURE_COMPARE_MODE
:
1295 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1297 case GL_TEXTURE_COMPARE_FUNC
:
1298 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1300 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1301 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1303 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1304 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1306 case GL_TEXTURE_SRGB_DECODE_EXT
:
1307 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1309 case GL_TEXTURE_BORDER_COLOR
:
1310 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1313 res
= INVALID_PNAME
;
1321 /* state change - we do nothing special at this time */
1324 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1325 _mesa_enum_to_string(pname
));
1328 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1332 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1342 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1344 struct gl_sampler_object
*sampObj
;
1345 GET_CURRENT_CONTEXT(ctx
);
1347 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1349 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1351 * "An INVALID_OPERATION error is generated if sampler is not the name
1352 * of a sampler object previously returned from a call to GenSamplers."
1355 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1356 "glGetSamplerParameteriv(sampler %u)", sampler
);
1361 case GL_TEXTURE_WRAP_S
:
1362 *params
= sampObj
->WrapS
;
1364 case GL_TEXTURE_WRAP_T
:
1365 *params
= sampObj
->WrapT
;
1367 case GL_TEXTURE_WRAP_R
:
1368 *params
= sampObj
->WrapR
;
1370 case GL_TEXTURE_MIN_FILTER
:
1371 *params
= sampObj
->MinFilter
;
1373 case GL_TEXTURE_MAG_FILTER
:
1374 *params
= sampObj
->MagFilter
;
1376 case GL_TEXTURE_MIN_LOD
:
1377 /* GL spec 'Data Conversions' section specifies that floating-point
1378 * value in integer Get function is rounded to nearest integer
1380 *params
= IROUND(sampObj
->MinLod
);
1382 case GL_TEXTURE_MAX_LOD
:
1383 /* GL spec 'Data Conversions' section specifies that floating-point
1384 * value in integer Get function is rounded to nearest integer
1386 *params
= IROUND(sampObj
->MaxLod
);
1388 case GL_TEXTURE_LOD_BIAS
:
1389 /* GL spec 'Data Conversions' section specifies that floating-point
1390 * value in integer Get function is rounded to nearest integer
1392 *params
= IROUND(sampObj
->LodBias
);
1394 case GL_TEXTURE_COMPARE_MODE
:
1395 *params
= sampObj
->CompareMode
;
1397 case GL_TEXTURE_COMPARE_FUNC
:
1398 *params
= sampObj
->CompareFunc
;
1400 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1401 /* GL spec 'Data Conversions' section specifies that floating-point
1402 * value in integer Get function is rounded to nearest integer
1404 *params
= IROUND(sampObj
->MaxAnisotropy
);
1406 case GL_TEXTURE_BORDER_COLOR
:
1407 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1408 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1409 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1410 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1412 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1413 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1415 *params
= sampObj
->CubeMapSeamless
;
1417 case GL_TEXTURE_SRGB_DECODE_EXT
:
1418 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1420 *params
= (GLenum
) sampObj
->sRGBDecode
;
1428 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1429 _mesa_enum_to_string(pname
));
1434 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1436 struct gl_sampler_object
*sampObj
;
1437 GET_CURRENT_CONTEXT(ctx
);
1439 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1441 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1443 * "An INVALID_OPERATION error is generated if sampler is not the name
1444 * of a sampler object previously returned from a call to GenSamplers."
1447 _mesa_error(ctx
, GL_INVALID_OPERATION
,
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
, GL_INVALID_OPERATION
,
1522 "glGetSamplerParameterIiv(sampler %u)",
1528 case GL_TEXTURE_WRAP_S
:
1529 *params
= sampObj
->WrapS
;
1531 case GL_TEXTURE_WRAP_T
:
1532 *params
= sampObj
->WrapT
;
1534 case GL_TEXTURE_WRAP_R
:
1535 *params
= sampObj
->WrapR
;
1537 case GL_TEXTURE_MIN_FILTER
:
1538 *params
= sampObj
->MinFilter
;
1540 case GL_TEXTURE_MAG_FILTER
:
1541 *params
= sampObj
->MagFilter
;
1543 case GL_TEXTURE_MIN_LOD
:
1544 *params
= (GLint
) sampObj
->MinLod
;
1546 case GL_TEXTURE_MAX_LOD
:
1547 *params
= (GLint
) sampObj
->MaxLod
;
1549 case GL_TEXTURE_LOD_BIAS
:
1550 *params
= (GLint
) sampObj
->LodBias
;
1552 case GL_TEXTURE_COMPARE_MODE
:
1553 *params
= sampObj
->CompareMode
;
1555 case GL_TEXTURE_COMPARE_FUNC
:
1556 *params
= sampObj
->CompareFunc
;
1558 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1559 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1561 case GL_TEXTURE_BORDER_COLOR
:
1562 params
[0] = sampObj
->BorderColor
.i
[0];
1563 params
[1] = sampObj
->BorderColor
.i
[1];
1564 params
[2] = sampObj
->BorderColor
.i
[2];
1565 params
[3] = sampObj
->BorderColor
.i
[3];
1567 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1568 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1570 *params
= sampObj
->CubeMapSeamless
;
1572 case GL_TEXTURE_SRGB_DECODE_EXT
:
1573 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1575 *params
= (GLenum
) sampObj
->sRGBDecode
;
1583 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1584 _mesa_enum_to_string(pname
));
1589 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1591 struct gl_sampler_object
*sampObj
;
1592 GET_CURRENT_CONTEXT(ctx
);
1594 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1596 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1597 "glGetSamplerParameterIuiv(sampler %u)",
1603 case GL_TEXTURE_WRAP_S
:
1604 *params
= sampObj
->WrapS
;
1606 case GL_TEXTURE_WRAP_T
:
1607 *params
= sampObj
->WrapT
;
1609 case GL_TEXTURE_WRAP_R
:
1610 *params
= sampObj
->WrapR
;
1612 case GL_TEXTURE_MIN_FILTER
:
1613 *params
= sampObj
->MinFilter
;
1615 case GL_TEXTURE_MAG_FILTER
:
1616 *params
= sampObj
->MagFilter
;
1618 case GL_TEXTURE_MIN_LOD
:
1619 *params
= (GLuint
) sampObj
->MinLod
;
1621 case GL_TEXTURE_MAX_LOD
:
1622 *params
= (GLuint
) sampObj
->MaxLod
;
1624 case GL_TEXTURE_LOD_BIAS
:
1625 *params
= (GLuint
) sampObj
->LodBias
;
1627 case GL_TEXTURE_COMPARE_MODE
:
1628 *params
= sampObj
->CompareMode
;
1630 case GL_TEXTURE_COMPARE_FUNC
:
1631 *params
= sampObj
->CompareFunc
;
1633 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1634 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1636 case GL_TEXTURE_BORDER_COLOR
:
1637 params
[0] = sampObj
->BorderColor
.ui
[0];
1638 params
[1] = sampObj
->BorderColor
.ui
[1];
1639 params
[2] = sampObj
->BorderColor
.ui
[2];
1640 params
[3] = sampObj
->BorderColor
.ui
[3];
1642 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1643 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1645 *params
= sampObj
->CubeMapSeamless
;
1647 case GL_TEXTURE_SRGB_DECODE_EXT
:
1648 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1650 *params
= (GLenum
) sampObj
->sRGBDecode
;
1658 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1659 _mesa_enum_to_string(pname
));
1664 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1666 driver
->NewSamplerObject
= _mesa_new_sampler_object
;