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"
41 #include "main/texturebindless.h"
44 struct gl_sampler_object
*
45 _mesa_lookup_samplerobj(struct gl_context
*ctx
, GLuint name
)
50 return (struct gl_sampler_object
*)
51 _mesa_HashLookup(ctx
->Shared
->SamplerObjects
, name
);
54 static inline struct gl_sampler_object
*
55 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
57 return (struct gl_sampler_object
*)
58 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
62 delete_sampler_object(struct gl_context
*ctx
,
63 struct gl_sampler_object
*sampObj
)
65 _mesa_delete_sampler_handles(ctx
, sampObj
);
66 mtx_destroy(&sampObj
->Mutex
);
72 * Handle reference counting.
75 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
76 struct gl_sampler_object
**ptr
,
77 struct gl_sampler_object
*samp
)
79 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
82 /* Unreference the old sampler */
83 GLboolean deleteFlag
= GL_FALSE
;
84 struct gl_sampler_object
*oldSamp
= *ptr
;
86 mtx_lock(&oldSamp
->Mutex
);
87 assert(oldSamp
->RefCount
> 0);
89 deleteFlag
= (oldSamp
->RefCount
== 0);
90 mtx_unlock(&oldSamp
->Mutex
);
93 delete_sampler_object(ctx
, oldSamp
);
100 /* reference new sampler */
101 mtx_lock(&samp
->Mutex
);
102 assert(samp
->RefCount
> 0);
106 mtx_unlock(&samp
->Mutex
);
112 * Initialize the fields of the given sampler object.
115 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
117 mtx_init(&sampObj
->Mutex
, mtx_plain
);
118 sampObj
->Name
= name
;
119 sampObj
->RefCount
= 1;
120 sampObj
->WrapS
= GL_REPEAT
;
121 sampObj
->WrapT
= GL_REPEAT
;
122 sampObj
->WrapR
= GL_REPEAT
;
123 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
124 sampObj
->MagFilter
= GL_LINEAR
;
125 sampObj
->BorderColor
.f
[0] = 0.0;
126 sampObj
->BorderColor
.f
[1] = 0.0;
127 sampObj
->BorderColor
.f
[2] = 0.0;
128 sampObj
->BorderColor
.f
[3] = 0.0;
129 sampObj
->MinLod
= -1000.0F
;
130 sampObj
->MaxLod
= 1000.0F
;
131 sampObj
->LodBias
= 0.0F
;
132 sampObj
->MaxAnisotropy
= 1.0F
;
133 sampObj
->CompareMode
= GL_NONE
;
134 sampObj
->CompareFunc
= GL_LEQUAL
;
135 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
136 sampObj
->CubeMapSeamless
= GL_FALSE
;
137 sampObj
->HandleAllocated
= GL_FALSE
;
139 /* GL_ARB_bindless_texture */
140 _mesa_init_sampler_handles(sampObj
);
144 * Fallback for ctx->Driver.NewSamplerObject();
146 struct gl_sampler_object
*
147 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
149 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
151 _mesa_init_sampler_object(sampObj
, name
);
157 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
166 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
168 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
170 /* Insert the ID and pointer to new sampler object into hash table */
171 for (i
= 0; i
< count
; i
++) {
172 struct gl_sampler_object
*sampObj
;
173 GLuint name
= first
+ i
;
175 sampObj
= ctx
->Driver
.NewSamplerObject(ctx
, name
);
177 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
178 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
182 _mesa_HashInsertLocked(ctx
->Shared
->SamplerObjects
, name
, sampObj
);
186 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
190 create_samplers_err(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
194 if (MESA_VERBOSE
& VERBOSE_API
)
195 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
198 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
202 create_samplers(ctx
, count
, samplers
, caller
);
206 _mesa_GenSamplers_no_error(GLsizei count
, GLuint
*samplers
)
208 GET_CURRENT_CONTEXT(ctx
);
209 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
213 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
215 GET_CURRENT_CONTEXT(ctx
);
216 create_samplers_err(ctx
, count
, samplers
, "glGenSamplers");
220 _mesa_CreateSamplers_no_error(GLsizei count
, GLuint
*samplers
)
222 GET_CURRENT_CONTEXT(ctx
);
223 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
227 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
229 GET_CURRENT_CONTEXT(ctx
);
230 create_samplers_err(ctx
, count
, samplers
, "glCreateSamplers");
235 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
237 GET_CURRENT_CONTEXT(ctx
);
240 FLUSH_VERTICES(ctx
, 0);
243 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
247 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
249 for (i
= 0; i
< count
; i
++) {
252 struct gl_sampler_object
*sampObj
=
253 lookup_samplerobj_locked(ctx
, samplers
[i
]);
256 /* If the sampler is currently bound, unbind it. */
257 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
258 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
259 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
260 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
264 /* The ID is immediately freed for re-use */
265 _mesa_HashRemoveLocked(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
266 /* But the object exists until its reference count goes to zero */
267 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
272 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
277 _mesa_IsSampler(GLuint sampler
)
279 GET_CURRENT_CONTEXT(ctx
);
281 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
283 return _mesa_lookup_samplerobj(ctx
, sampler
) != 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_OBJECT
);
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
);
329 static ALWAYS_INLINE
void
330 bind_samplers(struct gl_context
*ctx
, GLuint first
, GLsizei count
,
331 const GLuint
*samplers
, bool no_error
)
335 FLUSH_VERTICES(ctx
, 0);
338 /* Note that the error semantics for multi-bind commands differ from
339 * those of other GL commands.
341 * The Issues section in the ARB_multi_bind spec says:
343 * "(11) Typically, OpenGL specifies that if an error is generated by
344 * a command, that command has no effect. This is somewhat
345 * unfortunate for multi-bind commands, because it would require
346 * a first pass to scan the entire list of bound objects for
347 * errors and then a second pass to actually perform the
348 * bindings. Should we have different error semantics?
350 * RESOLVED: Yes. In this specification, when the parameters for
351 * one of the <count> binding points are invalid, that binding
352 * point is not updated and an error will be generated. However,
353 * other binding points in the same command will be updated if
354 * their parameters are valid and no other error occurs."
357 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
359 for (i
= 0; i
< count
; i
++) {
360 const GLuint unit
= first
+ i
;
361 struct gl_sampler_object
* const currentSampler
=
362 ctx
->Texture
.Unit
[unit
].Sampler
;
363 struct gl_sampler_object
*sampObj
;
365 if (samplers
[i
] != 0) {
366 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
367 sampObj
= currentSampler
;
369 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
371 /* The ARB_multi_bind spec says:
373 * "An INVALID_OPERATION error is generated if any value
374 * in <samplers> is not zero or the name of an existing
375 * sampler object (per binding)."
377 if (!no_error
&& !sampObj
) {
378 _mesa_error(ctx
, GL_INVALID_OPERATION
,
379 "glBindSamplers(samplers[%d]=%u is not zero or "
380 "the name of an existing sampler object)",
388 /* Bind the new sampler */
389 if (sampObj
!= currentSampler
) {
390 _mesa_reference_sampler_object(ctx
,
391 &ctx
->Texture
.Unit
[unit
].Sampler
,
393 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
397 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
399 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
400 for (i
= 0; i
< count
; i
++) {
401 const GLuint unit
= first
+ i
;
403 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
404 _mesa_reference_sampler_object(ctx
,
405 &ctx
->Texture
.Unit
[unit
].Sampler
,
407 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
415 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
417 GET_CURRENT_CONTEXT(ctx
);
419 /* The ARB_multi_bind spec says:
421 * "An INVALID_OPERATION error is generated if <first> + <count> is
422 * greater than the number of texture image units supported by
423 * the implementation."
425 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
426 _mesa_error(ctx
, GL_INVALID_OPERATION
,
427 "glBindSamplers(first=%u + count=%d > the value of "
428 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
429 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
433 bind_samplers(ctx
, first
, count
, samplers
, false);
438 * Check if a coordinate wrap mode is legal.
439 * \return GL_TRUE if legal, GL_FALSE otherwise
442 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
444 const struct gl_extensions
* const e
= &ctx
->Extensions
;
448 case GL_CLAMP_TO_EDGE
:
450 case GL_MIRRORED_REPEAT
:
452 case GL_CLAMP_TO_BORDER
:
453 return e
->ARB_texture_border_clamp
;
454 case GL_MIRROR_CLAMP_EXT
:
455 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
456 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
457 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
458 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
459 return e
->EXT_texture_mirror_clamp
;
467 * This is called just prior to changing any sampler object state.
470 flush(struct gl_context
*ctx
)
472 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
476 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
477 GLenum s
, GLenum t
, GLenum r
)
479 assert(validate_texture_wrap_mode(ctx
, s
));
480 assert(validate_texture_wrap_mode(ctx
, t
));
481 assert(validate_texture_wrap_mode(ctx
, r
));
483 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
492 #define INVALID_PARAM 0x100
493 #define INVALID_PNAME 0x101
494 #define INVALID_VALUE 0x102
497 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
500 if (samp
->WrapS
== param
)
502 if (validate_texture_wrap_mode(ctx
, param
)) {
507 return INVALID_PARAM
;
512 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
515 if (samp
->WrapT
== param
)
517 if (validate_texture_wrap_mode(ctx
, param
)) {
522 return INVALID_PARAM
;
527 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
530 if (samp
->WrapR
== param
)
532 if (validate_texture_wrap_mode(ctx
, param
)) {
537 return INVALID_PARAM
;
541 _mesa_set_sampler_filters(struct gl_context
*ctx
,
542 struct gl_sampler_object
*samp
,
543 GLenum min_filter
, GLenum mag_filter
)
545 assert(min_filter
== GL_NEAREST
||
546 min_filter
== GL_LINEAR
||
547 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
548 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
549 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
550 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
551 assert(mag_filter
== GL_NEAREST
||
552 mag_filter
== GL_LINEAR
);
554 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
558 samp
->MinFilter
= min_filter
;
559 samp
->MagFilter
= mag_filter
;
563 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
566 if (samp
->MinFilter
== param
)
572 case GL_NEAREST_MIPMAP_NEAREST
:
573 case GL_LINEAR_MIPMAP_NEAREST
:
574 case GL_NEAREST_MIPMAP_LINEAR
:
575 case GL_LINEAR_MIPMAP_LINEAR
:
577 samp
->MinFilter
= param
;
580 return INVALID_PARAM
;
586 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
589 if (samp
->MagFilter
== param
)
596 samp
->MagFilter
= param
;
599 return INVALID_PARAM
;
605 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
608 if (samp
->LodBias
== param
)
612 samp
->LodBias
= param
;
618 set_sampler_border_colorf(struct gl_context
*ctx
,
619 struct gl_sampler_object
*samp
,
620 const GLfloat params
[4])
623 samp
->BorderColor
.f
[RCOMP
] = params
[0];
624 samp
->BorderColor
.f
[GCOMP
] = params
[1];
625 samp
->BorderColor
.f
[BCOMP
] = params
[2];
626 samp
->BorderColor
.f
[ACOMP
] = params
[3];
632 set_sampler_border_colori(struct gl_context
*ctx
,
633 struct gl_sampler_object
*samp
,
634 const GLint params
[4])
637 samp
->BorderColor
.i
[RCOMP
] = params
[0];
638 samp
->BorderColor
.i
[GCOMP
] = params
[1];
639 samp
->BorderColor
.i
[BCOMP
] = params
[2];
640 samp
->BorderColor
.i
[ACOMP
] = params
[3];
646 set_sampler_border_colorui(struct gl_context
*ctx
,
647 struct gl_sampler_object
*samp
,
648 const GLuint params
[4])
651 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
652 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
653 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
654 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
660 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
663 if (samp
->MinLod
== param
)
667 samp
->MinLod
= param
;
673 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
676 if (samp
->MaxLod
== param
)
680 samp
->MaxLod
= param
;
686 set_sampler_compare_mode(struct gl_context
*ctx
,
687 struct gl_sampler_object
*samp
, GLint param
)
689 /* If GL_ARB_shadow is not supported, don't report an error. The
690 * sampler object extension spec isn't clear on this extension interaction.
691 * Silences errors with Wine on older GPUs such as R200.
693 if (!ctx
->Extensions
.ARB_shadow
)
696 if (samp
->CompareMode
== param
)
699 if (param
== GL_NONE
||
700 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
702 samp
->CompareMode
= param
;
706 return INVALID_PARAM
;
711 set_sampler_compare_func(struct gl_context
*ctx
,
712 struct gl_sampler_object
*samp
, GLint param
)
714 /* If GL_ARB_shadow is not supported, don't report an error. The
715 * sampler object extension spec isn't clear on this extension interaction.
716 * Silences errors with Wine on older GPUs such as R200.
718 if (!ctx
->Extensions
.ARB_shadow
)
721 if (samp
->CompareFunc
== param
)
734 samp
->CompareFunc
= param
;
737 return INVALID_PARAM
;
743 set_sampler_max_anisotropy(struct gl_context
*ctx
,
744 struct gl_sampler_object
*samp
, GLfloat param
)
746 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
747 return INVALID_PNAME
;
749 if (samp
->MaxAnisotropy
== param
)
753 return INVALID_VALUE
;
756 /* clamp to max, that's what NVIDIA does */
757 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
763 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
764 struct gl_sampler_object
*samp
, GLboolean param
)
766 if (!_mesa_is_desktop_gl(ctx
)
767 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
768 return INVALID_PNAME
;
770 if (samp
->CubeMapSeamless
== param
)
773 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
774 return INVALID_VALUE
;
777 samp
->CubeMapSeamless
= param
;
782 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
783 struct gl_sampler_object
*samp
, GLenum param
)
785 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
788 samp
->sRGBDecode
= param
;
792 set_sampler_srgb_decode(struct gl_context
*ctx
,
793 struct gl_sampler_object
*samp
, GLenum param
)
795 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
796 return INVALID_PNAME
;
798 if (samp
->sRGBDecode
== param
)
801 /* The EXT_texture_sRGB_decode spec says:
803 * "INVALID_ENUM is generated if the <pname> parameter of
804 * TexParameter[i,f,Ii,Iui][v][EXT],
805 * MultiTexParameter[i,f,Ii,Iui][v]EXT,
806 * TextureParameter[i,f,Ii,Iui][v]EXT, SamplerParameter[i,f,Ii,Iui][v]
807 * is TEXTURE_SRGB_DECODE_EXT when the <param> parameter is not one of
808 * DECODE_EXT or SKIP_DECODE_EXT.
810 * Returning INVALID_PARAM makes that happen.
812 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
813 return INVALID_PARAM
;
816 samp
->sRGBDecode
= param
;
820 static struct gl_sampler_object
*
821 sampler_parameter_error_check(struct gl_context
*ctx
, GLuint sampler
,
822 bool get
, const char *name
)
824 struct gl_sampler_object
*sampObj
;
826 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
828 /* OpenGL 4.5 spec, section "8.2 Sampler Objects", page 176 of the PDF
831 * "An INVALID_OPERATION error is generated if sampler is not the name
832 * of a sampler object previously returned from a call to
835 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(invalid sampler)", name
);
839 if (!get
&& sampObj
->HandleAllocated
) {
840 /* The ARB_bindless_texture spec says:
842 * "The error INVALID_OPERATION is generated by SamplerParameter* if
843 * <sampler> identifies a sampler object referenced by one or more
846 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(immutable sampler)", name
);
854 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
856 struct gl_sampler_object
*sampObj
;
858 GET_CURRENT_CONTEXT(ctx
);
860 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
861 "glSamplerParameteri");
866 case GL_TEXTURE_WRAP_S
:
867 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
869 case GL_TEXTURE_WRAP_T
:
870 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
872 case GL_TEXTURE_WRAP_R
:
873 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
875 case GL_TEXTURE_MIN_FILTER
:
876 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
878 case GL_TEXTURE_MAG_FILTER
:
879 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
881 case GL_TEXTURE_MIN_LOD
:
882 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
884 case GL_TEXTURE_MAX_LOD
:
885 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
887 case GL_TEXTURE_LOD_BIAS
:
888 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
890 case GL_TEXTURE_COMPARE_MODE
:
891 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
893 case GL_TEXTURE_COMPARE_FUNC
:
894 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
896 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
897 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
899 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
900 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
902 case GL_TEXTURE_SRGB_DECODE_EXT
:
903 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
905 case GL_TEXTURE_BORDER_COLOR
:
916 /* state change - we do nothing special at this time */
919 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
920 _mesa_enum_to_string(pname
));
923 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
927 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
937 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
939 struct gl_sampler_object
*sampObj
;
941 GET_CURRENT_CONTEXT(ctx
);
943 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
944 "glSamplerParameterf");
949 case GL_TEXTURE_WRAP_S
:
950 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
952 case GL_TEXTURE_WRAP_T
:
953 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
955 case GL_TEXTURE_WRAP_R
:
956 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
958 case GL_TEXTURE_MIN_FILTER
:
959 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
961 case GL_TEXTURE_MAG_FILTER
:
962 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
964 case GL_TEXTURE_MIN_LOD
:
965 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
967 case GL_TEXTURE_MAX_LOD
:
968 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
970 case GL_TEXTURE_LOD_BIAS
:
971 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
973 case GL_TEXTURE_COMPARE_MODE
:
974 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
976 case GL_TEXTURE_COMPARE_FUNC
:
977 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
979 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
980 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
982 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
983 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
985 case GL_TEXTURE_SRGB_DECODE_EXT
:
986 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
988 case GL_TEXTURE_BORDER_COLOR
:
999 /* state change - we do nothing special at this time */
1002 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
1003 _mesa_enum_to_string(pname
));
1006 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
1010 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
1019 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1021 struct gl_sampler_object
*sampObj
;
1023 GET_CURRENT_CONTEXT(ctx
);
1025 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1026 "glSamplerParameteriv");
1031 case GL_TEXTURE_WRAP_S
:
1032 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1034 case GL_TEXTURE_WRAP_T
:
1035 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1037 case GL_TEXTURE_WRAP_R
:
1038 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1040 case GL_TEXTURE_MIN_FILTER
:
1041 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1043 case GL_TEXTURE_MAG_FILTER
:
1044 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1046 case GL_TEXTURE_MIN_LOD
:
1047 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1049 case GL_TEXTURE_MAX_LOD
:
1050 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1052 case GL_TEXTURE_LOD_BIAS
:
1053 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1055 case GL_TEXTURE_COMPARE_MODE
:
1056 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1058 case GL_TEXTURE_COMPARE_FUNC
:
1059 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1061 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1062 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1064 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1065 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1067 case GL_TEXTURE_SRGB_DECODE_EXT
:
1068 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1070 case GL_TEXTURE_BORDER_COLOR
:
1073 c
[0] = INT_TO_FLOAT(params
[0]);
1074 c
[1] = INT_TO_FLOAT(params
[1]);
1075 c
[2] = INT_TO_FLOAT(params
[2]);
1076 c
[3] = INT_TO_FLOAT(params
[3]);
1077 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1081 res
= INVALID_PNAME
;
1089 /* state change - we do nothing special at this time */
1092 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1093 _mesa_enum_to_string(pname
));
1096 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1100 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1109 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1111 struct gl_sampler_object
*sampObj
;
1113 GET_CURRENT_CONTEXT(ctx
);
1115 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1116 "glSamplerParameterfv");
1121 case GL_TEXTURE_WRAP_S
:
1122 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1124 case GL_TEXTURE_WRAP_T
:
1125 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1127 case GL_TEXTURE_WRAP_R
:
1128 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1130 case GL_TEXTURE_MIN_FILTER
:
1131 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1133 case GL_TEXTURE_MAG_FILTER
:
1134 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1136 case GL_TEXTURE_MIN_LOD
:
1137 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1139 case GL_TEXTURE_MAX_LOD
:
1140 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1142 case GL_TEXTURE_LOD_BIAS
:
1143 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1145 case GL_TEXTURE_COMPARE_MODE
:
1146 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1148 case GL_TEXTURE_COMPARE_FUNC
:
1149 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1151 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1152 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1154 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1155 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1157 case GL_TEXTURE_SRGB_DECODE_EXT
:
1158 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1160 case GL_TEXTURE_BORDER_COLOR
:
1161 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1164 res
= INVALID_PNAME
;
1172 /* state change - we do nothing special at this time */
1175 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1176 _mesa_enum_to_string(pname
));
1179 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1183 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1192 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1194 struct gl_sampler_object
*sampObj
;
1196 GET_CURRENT_CONTEXT(ctx
);
1198 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1199 "glSamplerParameterIiv");
1204 case GL_TEXTURE_WRAP_S
:
1205 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1207 case GL_TEXTURE_WRAP_T
:
1208 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1210 case GL_TEXTURE_WRAP_R
:
1211 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1213 case GL_TEXTURE_MIN_FILTER
:
1214 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1216 case GL_TEXTURE_MAG_FILTER
:
1217 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1219 case GL_TEXTURE_MIN_LOD
:
1220 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1222 case GL_TEXTURE_MAX_LOD
:
1223 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1225 case GL_TEXTURE_LOD_BIAS
:
1226 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1228 case GL_TEXTURE_COMPARE_MODE
:
1229 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1231 case GL_TEXTURE_COMPARE_FUNC
:
1232 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1234 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1235 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1237 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1238 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1240 case GL_TEXTURE_SRGB_DECODE_EXT
:
1241 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1243 case GL_TEXTURE_BORDER_COLOR
:
1244 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1247 res
= INVALID_PNAME
;
1255 /* state change - we do nothing special at this time */
1258 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1259 _mesa_enum_to_string(pname
));
1262 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1266 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1276 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1278 struct gl_sampler_object
*sampObj
;
1280 GET_CURRENT_CONTEXT(ctx
);
1282 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1283 "glSamplerParameterIuiv");
1288 case GL_TEXTURE_WRAP_S
:
1289 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1291 case GL_TEXTURE_WRAP_T
:
1292 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1294 case GL_TEXTURE_WRAP_R
:
1295 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1297 case GL_TEXTURE_MIN_FILTER
:
1298 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1300 case GL_TEXTURE_MAG_FILTER
:
1301 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1303 case GL_TEXTURE_MIN_LOD
:
1304 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1306 case GL_TEXTURE_MAX_LOD
:
1307 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1309 case GL_TEXTURE_LOD_BIAS
:
1310 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1312 case GL_TEXTURE_COMPARE_MODE
:
1313 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1315 case GL_TEXTURE_COMPARE_FUNC
:
1316 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1318 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1319 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1321 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1322 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1324 case GL_TEXTURE_SRGB_DECODE_EXT
:
1325 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1327 case GL_TEXTURE_BORDER_COLOR
:
1328 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1331 res
= INVALID_PNAME
;
1339 /* state change - we do nothing special at this time */
1342 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1343 _mesa_enum_to_string(pname
));
1346 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1350 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1360 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1362 struct gl_sampler_object
*sampObj
;
1363 GET_CURRENT_CONTEXT(ctx
);
1365 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1366 "glGetSamplerParameteriv");
1371 case GL_TEXTURE_WRAP_S
:
1372 *params
= sampObj
->WrapS
;
1374 case GL_TEXTURE_WRAP_T
:
1375 *params
= sampObj
->WrapT
;
1377 case GL_TEXTURE_WRAP_R
:
1378 *params
= sampObj
->WrapR
;
1380 case GL_TEXTURE_MIN_FILTER
:
1381 *params
= sampObj
->MinFilter
;
1383 case GL_TEXTURE_MAG_FILTER
:
1384 *params
= sampObj
->MagFilter
;
1386 case GL_TEXTURE_MIN_LOD
:
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
->MinLod
);
1392 case GL_TEXTURE_MAX_LOD
:
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
->MaxLod
);
1398 case GL_TEXTURE_LOD_BIAS
:
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
->LodBias
);
1404 case GL_TEXTURE_COMPARE_MODE
:
1405 *params
= sampObj
->CompareMode
;
1407 case GL_TEXTURE_COMPARE_FUNC
:
1408 *params
= sampObj
->CompareFunc
;
1410 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1411 /* GL spec 'Data Conversions' section specifies that floating-point
1412 * value in integer Get function is rounded to nearest integer
1414 *params
= IROUND(sampObj
->MaxAnisotropy
);
1416 case GL_TEXTURE_BORDER_COLOR
:
1417 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1418 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1419 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1420 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1422 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1423 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1425 *params
= sampObj
->CubeMapSeamless
;
1427 case GL_TEXTURE_SRGB_DECODE_EXT
:
1428 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1430 *params
= (GLenum
) sampObj
->sRGBDecode
;
1438 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1439 _mesa_enum_to_string(pname
));
1444 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1446 struct gl_sampler_object
*sampObj
;
1447 GET_CURRENT_CONTEXT(ctx
);
1449 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1450 "glGetSamplerParameterfv");
1455 case GL_TEXTURE_WRAP_S
:
1456 *params
= (GLfloat
) sampObj
->WrapS
;
1458 case GL_TEXTURE_WRAP_T
:
1459 *params
= (GLfloat
) sampObj
->WrapT
;
1461 case GL_TEXTURE_WRAP_R
:
1462 *params
= (GLfloat
) sampObj
->WrapR
;
1464 case GL_TEXTURE_MIN_FILTER
:
1465 *params
= (GLfloat
) sampObj
->MinFilter
;
1467 case GL_TEXTURE_MAG_FILTER
:
1468 *params
= (GLfloat
) sampObj
->MagFilter
;
1470 case GL_TEXTURE_MIN_LOD
:
1471 *params
= sampObj
->MinLod
;
1473 case GL_TEXTURE_MAX_LOD
:
1474 *params
= sampObj
->MaxLod
;
1476 case GL_TEXTURE_LOD_BIAS
:
1477 *params
= sampObj
->LodBias
;
1479 case GL_TEXTURE_COMPARE_MODE
:
1480 *params
= (GLfloat
) sampObj
->CompareMode
;
1482 case GL_TEXTURE_COMPARE_FUNC
:
1483 *params
= (GLfloat
) sampObj
->CompareFunc
;
1485 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1486 *params
= sampObj
->MaxAnisotropy
;
1488 case GL_TEXTURE_BORDER_COLOR
:
1489 params
[0] = sampObj
->BorderColor
.f
[0];
1490 params
[1] = sampObj
->BorderColor
.f
[1];
1491 params
[2] = sampObj
->BorderColor
.f
[2];
1492 params
[3] = sampObj
->BorderColor
.f
[3];
1494 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1495 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1497 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1499 case GL_TEXTURE_SRGB_DECODE_EXT
:
1500 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1502 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1510 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1511 _mesa_enum_to_string(pname
));
1516 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1518 struct gl_sampler_object
*sampObj
;
1519 GET_CURRENT_CONTEXT(ctx
);
1521 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1522 "glGetSamplerParameterIiv");
1527 case GL_TEXTURE_WRAP_S
:
1528 *params
= sampObj
->WrapS
;
1530 case GL_TEXTURE_WRAP_T
:
1531 *params
= sampObj
->WrapT
;
1533 case GL_TEXTURE_WRAP_R
:
1534 *params
= sampObj
->WrapR
;
1536 case GL_TEXTURE_MIN_FILTER
:
1537 *params
= sampObj
->MinFilter
;
1539 case GL_TEXTURE_MAG_FILTER
:
1540 *params
= sampObj
->MagFilter
;
1542 case GL_TEXTURE_MIN_LOD
:
1543 *params
= (GLint
) sampObj
->MinLod
;
1545 case GL_TEXTURE_MAX_LOD
:
1546 *params
= (GLint
) sampObj
->MaxLod
;
1548 case GL_TEXTURE_LOD_BIAS
:
1549 *params
= (GLint
) sampObj
->LodBias
;
1551 case GL_TEXTURE_COMPARE_MODE
:
1552 *params
= sampObj
->CompareMode
;
1554 case GL_TEXTURE_COMPARE_FUNC
:
1555 *params
= sampObj
->CompareFunc
;
1557 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1558 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1560 case GL_TEXTURE_BORDER_COLOR
:
1561 params
[0] = sampObj
->BorderColor
.i
[0];
1562 params
[1] = sampObj
->BorderColor
.i
[1];
1563 params
[2] = sampObj
->BorderColor
.i
[2];
1564 params
[3] = sampObj
->BorderColor
.i
[3];
1566 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1567 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1569 *params
= sampObj
->CubeMapSeamless
;
1571 case GL_TEXTURE_SRGB_DECODE_EXT
:
1572 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1574 *params
= (GLenum
) sampObj
->sRGBDecode
;
1582 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1583 _mesa_enum_to_string(pname
));
1588 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1590 struct gl_sampler_object
*sampObj
;
1591 GET_CURRENT_CONTEXT(ctx
);
1593 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1594 "glGetSamplerParameterIuiv");
1599 case GL_TEXTURE_WRAP_S
:
1600 *params
= sampObj
->WrapS
;
1602 case GL_TEXTURE_WRAP_T
:
1603 *params
= sampObj
->WrapT
;
1605 case GL_TEXTURE_WRAP_R
:
1606 *params
= sampObj
->WrapR
;
1608 case GL_TEXTURE_MIN_FILTER
:
1609 *params
= sampObj
->MinFilter
;
1611 case GL_TEXTURE_MAG_FILTER
:
1612 *params
= sampObj
->MagFilter
;
1614 case GL_TEXTURE_MIN_LOD
:
1615 *params
= (GLuint
) sampObj
->MinLod
;
1617 case GL_TEXTURE_MAX_LOD
:
1618 *params
= (GLuint
) sampObj
->MaxLod
;
1620 case GL_TEXTURE_LOD_BIAS
:
1621 *params
= (GLuint
) sampObj
->LodBias
;
1623 case GL_TEXTURE_COMPARE_MODE
:
1624 *params
= sampObj
->CompareMode
;
1626 case GL_TEXTURE_COMPARE_FUNC
:
1627 *params
= sampObj
->CompareFunc
;
1629 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1630 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1632 case GL_TEXTURE_BORDER_COLOR
:
1633 params
[0] = sampObj
->BorderColor
.ui
[0];
1634 params
[1] = sampObj
->BorderColor
.ui
[1];
1635 params
[2] = sampObj
->BorderColor
.ui
[2];
1636 params
[3] = sampObj
->BorderColor
.ui
[3];
1638 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1639 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1641 *params
= sampObj
->CubeMapSeamless
;
1643 case GL_TEXTURE_SRGB_DECODE_EXT
:
1644 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1646 *params
= (GLenum
) sampObj
->sRGBDecode
;
1654 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1655 _mesa_enum_to_string(pname
));
1660 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1662 driver
->NewSamplerObject
= _mesa_new_sampler_object
;