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
)
165 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
167 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
169 /* Insert the ID and pointer to new sampler object into hash table */
170 for (i
= 0; i
< count
; i
++) {
171 struct gl_sampler_object
*sampObj
=
172 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
173 _mesa_HashInsertLocked(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
174 samplers
[i
] = first
+ i
;
177 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
181 create_samplers_err(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
185 if (MESA_VERBOSE
& VERBOSE_API
)
186 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
189 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
193 create_samplers(ctx
, count
, samplers
);
197 _mesa_GenSamplers_no_error(GLsizei count
, GLuint
*samplers
)
199 GET_CURRENT_CONTEXT(ctx
);
200 create_samplers(ctx
, count
, samplers
);
204 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
206 GET_CURRENT_CONTEXT(ctx
);
207 create_samplers_err(ctx
, count
, samplers
, "glGenSamplers");
211 _mesa_CreateSamplers_no_error(GLsizei count
, GLuint
*samplers
)
213 GET_CURRENT_CONTEXT(ctx
);
214 create_samplers(ctx
, count
, samplers
);
218 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
220 GET_CURRENT_CONTEXT(ctx
);
221 create_samplers_err(ctx
, count
, samplers
, "glCreateSamplers");
226 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
228 GET_CURRENT_CONTEXT(ctx
);
231 FLUSH_VERTICES(ctx
, 0);
234 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
238 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
240 for (i
= 0; i
< count
; i
++) {
243 struct gl_sampler_object
*sampObj
=
244 lookup_samplerobj_locked(ctx
, samplers
[i
]);
247 /* If the sampler is currently bound, unbind it. */
248 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
249 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
250 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
251 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
255 /* The ID is immediately freed for re-use */
256 _mesa_HashRemoveLocked(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
257 /* But the object exists until its reference count goes to zero */
258 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
263 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
268 _mesa_IsSampler(GLuint sampler
)
270 GET_CURRENT_CONTEXT(ctx
);
272 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
274 return _mesa_lookup_samplerobj(ctx
, sampler
) != NULL
;
278 _mesa_bind_sampler(struct gl_context
*ctx
, GLuint unit
,
279 struct gl_sampler_object
*sampObj
)
281 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
282 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
285 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
290 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
292 struct gl_sampler_object
*sampObj
;
293 GET_CURRENT_CONTEXT(ctx
);
295 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
296 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
301 /* Use the default sampler object, the one contained in the texture
307 /* user-defined sampler object */
308 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
310 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
315 /* bind new sampler */
316 _mesa_bind_sampler(ctx
, unit
, sampObj
);
321 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
323 GET_CURRENT_CONTEXT(ctx
);
326 /* The ARB_multi_bind spec says:
328 * "An INVALID_OPERATION error is generated if <first> + <count> is
329 * greater than the number of texture image units supported by
330 * the implementation."
332 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
333 _mesa_error(ctx
, GL_INVALID_OPERATION
,
334 "glBindSamplers(first=%u + count=%d > the value of "
335 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
336 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
340 FLUSH_VERTICES(ctx
, 0);
343 /* Note that the error semantics for multi-bind commands differ from
344 * those of other GL commands.
346 * The Issues section in the ARB_multi_bind spec says:
348 * "(11) Typically, OpenGL specifies that if an error is generated by
349 * a command, that command has no effect. This is somewhat
350 * unfortunate for multi-bind commands, because it would require
351 * a first pass to scan the entire list of bound objects for
352 * errors and then a second pass to actually perform the
353 * bindings. Should we have different error semantics?
355 * RESOLVED: Yes. In this specification, when the parameters for
356 * one of the <count> binding points are invalid, that binding
357 * point is not updated and an error will be generated. However,
358 * other binding points in the same command will be updated if
359 * their parameters are valid and no other error occurs."
362 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
364 for (i
= 0; i
< count
; i
++) {
365 const GLuint unit
= first
+ i
;
366 struct gl_sampler_object
* const currentSampler
=
367 ctx
->Texture
.Unit
[unit
].Sampler
;
368 struct gl_sampler_object
*sampObj
;
370 if (samplers
[i
] != 0) {
371 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
372 sampObj
= currentSampler
;
374 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
376 /* The ARB_multi_bind spec says:
378 * "An INVALID_OPERATION error is generated if any value
379 * in <samplers> is not zero or the name of an existing
380 * sampler object (per binding)."
383 _mesa_error(ctx
, GL_INVALID_OPERATION
,
384 "glBindSamplers(samplers[%d]=%u is not zero or "
385 "the name of an existing sampler object)",
393 /* Bind the new sampler */
394 if (sampObj
!= currentSampler
) {
395 _mesa_reference_sampler_object(ctx
,
396 &ctx
->Texture
.Unit
[unit
].Sampler
,
398 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
402 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
404 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
405 for (i
= 0; i
< count
; i
++) {
406 const GLuint unit
= first
+ i
;
408 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
409 _mesa_reference_sampler_object(ctx
,
410 &ctx
->Texture
.Unit
[unit
].Sampler
,
412 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
420 * Check if a coordinate wrap mode is legal.
421 * \return GL_TRUE if legal, GL_FALSE otherwise
424 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
426 const struct gl_extensions
* const e
= &ctx
->Extensions
;
430 case GL_CLAMP_TO_EDGE
:
432 case GL_MIRRORED_REPEAT
:
434 case GL_CLAMP_TO_BORDER
:
435 return e
->ARB_texture_border_clamp
;
436 case GL_MIRROR_CLAMP_EXT
:
437 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
438 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
439 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
440 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
441 return e
->EXT_texture_mirror_clamp
;
449 * This is called just prior to changing any sampler object state.
452 flush(struct gl_context
*ctx
)
454 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
458 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
459 GLenum s
, GLenum t
, GLenum r
)
461 assert(validate_texture_wrap_mode(ctx
, s
));
462 assert(validate_texture_wrap_mode(ctx
, t
));
463 assert(validate_texture_wrap_mode(ctx
, r
));
465 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
474 #define INVALID_PARAM 0x100
475 #define INVALID_PNAME 0x101
476 #define INVALID_VALUE 0x102
479 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
482 if (samp
->WrapS
== param
)
484 if (validate_texture_wrap_mode(ctx
, param
)) {
489 return INVALID_PARAM
;
494 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
497 if (samp
->WrapT
== param
)
499 if (validate_texture_wrap_mode(ctx
, param
)) {
504 return INVALID_PARAM
;
509 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
512 if (samp
->WrapR
== param
)
514 if (validate_texture_wrap_mode(ctx
, param
)) {
519 return INVALID_PARAM
;
523 _mesa_set_sampler_filters(struct gl_context
*ctx
,
524 struct gl_sampler_object
*samp
,
525 GLenum min_filter
, GLenum mag_filter
)
527 assert(min_filter
== GL_NEAREST
||
528 min_filter
== GL_LINEAR
||
529 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
530 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
531 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
532 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
533 assert(mag_filter
== GL_NEAREST
||
534 mag_filter
== GL_LINEAR
);
536 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
540 samp
->MinFilter
= min_filter
;
541 samp
->MagFilter
= mag_filter
;
545 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
548 if (samp
->MinFilter
== param
)
554 case GL_NEAREST_MIPMAP_NEAREST
:
555 case GL_LINEAR_MIPMAP_NEAREST
:
556 case GL_NEAREST_MIPMAP_LINEAR
:
557 case GL_LINEAR_MIPMAP_LINEAR
:
559 samp
->MinFilter
= param
;
562 return INVALID_PARAM
;
568 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
571 if (samp
->MagFilter
== param
)
578 samp
->MagFilter
= param
;
581 return INVALID_PARAM
;
587 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
590 if (samp
->LodBias
== param
)
594 samp
->LodBias
= param
;
600 set_sampler_border_colorf(struct gl_context
*ctx
,
601 struct gl_sampler_object
*samp
,
602 const GLfloat params
[4])
605 samp
->BorderColor
.f
[RCOMP
] = params
[0];
606 samp
->BorderColor
.f
[GCOMP
] = params
[1];
607 samp
->BorderColor
.f
[BCOMP
] = params
[2];
608 samp
->BorderColor
.f
[ACOMP
] = params
[3];
614 set_sampler_border_colori(struct gl_context
*ctx
,
615 struct gl_sampler_object
*samp
,
616 const GLint params
[4])
619 samp
->BorderColor
.i
[RCOMP
] = params
[0];
620 samp
->BorderColor
.i
[GCOMP
] = params
[1];
621 samp
->BorderColor
.i
[BCOMP
] = params
[2];
622 samp
->BorderColor
.i
[ACOMP
] = params
[3];
628 set_sampler_border_colorui(struct gl_context
*ctx
,
629 struct gl_sampler_object
*samp
,
630 const GLuint params
[4])
633 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
634 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
635 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
636 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
642 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
645 if (samp
->MinLod
== param
)
649 samp
->MinLod
= param
;
655 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
658 if (samp
->MaxLod
== param
)
662 samp
->MaxLod
= param
;
668 set_sampler_compare_mode(struct gl_context
*ctx
,
669 struct gl_sampler_object
*samp
, GLint param
)
671 /* If GL_ARB_shadow is not supported, don't report an error. The
672 * sampler object extension spec isn't clear on this extension interaction.
673 * Silences errors with Wine on older GPUs such as R200.
675 if (!ctx
->Extensions
.ARB_shadow
)
678 if (samp
->CompareMode
== param
)
681 if (param
== GL_NONE
||
682 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
684 samp
->CompareMode
= param
;
688 return INVALID_PARAM
;
693 set_sampler_compare_func(struct gl_context
*ctx
,
694 struct gl_sampler_object
*samp
, GLint param
)
696 /* If GL_ARB_shadow is not supported, don't report an error. The
697 * sampler object extension spec isn't clear on this extension interaction.
698 * Silences errors with Wine on older GPUs such as R200.
700 if (!ctx
->Extensions
.ARB_shadow
)
703 if (samp
->CompareFunc
== param
)
716 samp
->CompareFunc
= param
;
719 return INVALID_PARAM
;
725 set_sampler_max_anisotropy(struct gl_context
*ctx
,
726 struct gl_sampler_object
*samp
, GLfloat param
)
728 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
729 return INVALID_PNAME
;
731 if (samp
->MaxAnisotropy
== param
)
735 return INVALID_VALUE
;
738 /* clamp to max, that's what NVIDIA does */
739 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
745 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
746 struct gl_sampler_object
*samp
, GLboolean param
)
748 if (!_mesa_is_desktop_gl(ctx
)
749 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
750 return INVALID_PNAME
;
752 if (samp
->CubeMapSeamless
== param
)
755 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
756 return INVALID_VALUE
;
759 samp
->CubeMapSeamless
= param
;
764 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
765 struct gl_sampler_object
*samp
, GLenum param
)
767 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
770 samp
->sRGBDecode
= param
;
774 set_sampler_srgb_decode(struct gl_context
*ctx
,
775 struct gl_sampler_object
*samp
, GLenum param
)
777 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
778 return INVALID_PNAME
;
780 if (samp
->sRGBDecode
== param
)
783 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
784 return INVALID_VALUE
;
787 samp
->sRGBDecode
= param
;
791 static struct gl_sampler_object
*
792 sampler_parameter_error_check(struct gl_context
*ctx
, GLuint sampler
,
793 bool get
, const char *name
)
795 struct gl_sampler_object
*sampObj
;
797 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
799 /* OpenGL 4.5 spec, section "8.2 Sampler Objects", page 176 of the PDF
802 * "An INVALID_OPERATION error is generated if sampler is not the name
803 * of a sampler object previously returned from a call to
806 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(invalid sampler)", name
);
810 if (!get
&& sampObj
->HandleAllocated
) {
811 /* The ARB_bindless_texture spec says:
813 * "The error INVALID_OPERATION is generated by SamplerParameter* if
814 * <sampler> identifies a sampler object referenced by one or more
817 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(immutable sampler)", name
);
825 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
827 struct gl_sampler_object
*sampObj
;
829 GET_CURRENT_CONTEXT(ctx
);
831 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
832 "glSamplerParameteri");
837 case GL_TEXTURE_WRAP_S
:
838 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
840 case GL_TEXTURE_WRAP_T
:
841 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
843 case GL_TEXTURE_WRAP_R
:
844 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
846 case GL_TEXTURE_MIN_FILTER
:
847 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
849 case GL_TEXTURE_MAG_FILTER
:
850 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
852 case GL_TEXTURE_MIN_LOD
:
853 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
855 case GL_TEXTURE_MAX_LOD
:
856 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
858 case GL_TEXTURE_LOD_BIAS
:
859 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
861 case GL_TEXTURE_COMPARE_MODE
:
862 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
864 case GL_TEXTURE_COMPARE_FUNC
:
865 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
867 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
868 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
870 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
871 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
873 case GL_TEXTURE_SRGB_DECODE_EXT
:
874 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
876 case GL_TEXTURE_BORDER_COLOR
:
887 /* state change - we do nothing special at this time */
890 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
891 _mesa_enum_to_string(pname
));
894 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
898 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
908 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
910 struct gl_sampler_object
*sampObj
;
912 GET_CURRENT_CONTEXT(ctx
);
914 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
915 "glSamplerParameterf");
920 case GL_TEXTURE_WRAP_S
:
921 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
923 case GL_TEXTURE_WRAP_T
:
924 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
926 case GL_TEXTURE_WRAP_R
:
927 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
929 case GL_TEXTURE_MIN_FILTER
:
930 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
932 case GL_TEXTURE_MAG_FILTER
:
933 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
935 case GL_TEXTURE_MIN_LOD
:
936 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
938 case GL_TEXTURE_MAX_LOD
:
939 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
941 case GL_TEXTURE_LOD_BIAS
:
942 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
944 case GL_TEXTURE_COMPARE_MODE
:
945 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
947 case GL_TEXTURE_COMPARE_FUNC
:
948 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
950 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
951 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
953 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
954 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
956 case GL_TEXTURE_SRGB_DECODE_EXT
:
957 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
959 case GL_TEXTURE_BORDER_COLOR
:
970 /* state change - we do nothing special at this time */
973 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
974 _mesa_enum_to_string(pname
));
977 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
981 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
990 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
992 struct gl_sampler_object
*sampObj
;
994 GET_CURRENT_CONTEXT(ctx
);
996 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
997 "glSamplerParameteriv");
1002 case GL_TEXTURE_WRAP_S
:
1003 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1005 case GL_TEXTURE_WRAP_T
:
1006 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1008 case GL_TEXTURE_WRAP_R
:
1009 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1011 case GL_TEXTURE_MIN_FILTER
:
1012 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1014 case GL_TEXTURE_MAG_FILTER
:
1015 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1017 case GL_TEXTURE_MIN_LOD
:
1018 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1020 case GL_TEXTURE_MAX_LOD
:
1021 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1023 case GL_TEXTURE_LOD_BIAS
:
1024 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1026 case GL_TEXTURE_COMPARE_MODE
:
1027 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1029 case GL_TEXTURE_COMPARE_FUNC
:
1030 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1032 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1033 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1035 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1036 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1038 case GL_TEXTURE_SRGB_DECODE_EXT
:
1039 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1041 case GL_TEXTURE_BORDER_COLOR
:
1044 c
[0] = INT_TO_FLOAT(params
[0]);
1045 c
[1] = INT_TO_FLOAT(params
[1]);
1046 c
[2] = INT_TO_FLOAT(params
[2]);
1047 c
[3] = INT_TO_FLOAT(params
[3]);
1048 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1052 res
= INVALID_PNAME
;
1060 /* state change - we do nothing special at this time */
1063 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1064 _mesa_enum_to_string(pname
));
1067 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1071 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1080 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1082 struct gl_sampler_object
*sampObj
;
1084 GET_CURRENT_CONTEXT(ctx
);
1086 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1087 "glSamplerParameterfv");
1092 case GL_TEXTURE_WRAP_S
:
1093 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1095 case GL_TEXTURE_WRAP_T
:
1096 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1098 case GL_TEXTURE_WRAP_R
:
1099 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1101 case GL_TEXTURE_MIN_FILTER
:
1102 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1104 case GL_TEXTURE_MAG_FILTER
:
1105 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1107 case GL_TEXTURE_MIN_LOD
:
1108 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1110 case GL_TEXTURE_MAX_LOD
:
1111 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1113 case GL_TEXTURE_LOD_BIAS
:
1114 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1116 case GL_TEXTURE_COMPARE_MODE
:
1117 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1119 case GL_TEXTURE_COMPARE_FUNC
:
1120 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1122 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1123 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1125 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1126 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1128 case GL_TEXTURE_SRGB_DECODE_EXT
:
1129 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1131 case GL_TEXTURE_BORDER_COLOR
:
1132 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1135 res
= INVALID_PNAME
;
1143 /* state change - we do nothing special at this time */
1146 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1147 _mesa_enum_to_string(pname
));
1150 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1154 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1163 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1165 struct gl_sampler_object
*sampObj
;
1167 GET_CURRENT_CONTEXT(ctx
);
1169 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1170 "glSamplerParameterIiv");
1175 case GL_TEXTURE_WRAP_S
:
1176 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1178 case GL_TEXTURE_WRAP_T
:
1179 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1181 case GL_TEXTURE_WRAP_R
:
1182 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1184 case GL_TEXTURE_MIN_FILTER
:
1185 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1187 case GL_TEXTURE_MAG_FILTER
:
1188 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1190 case GL_TEXTURE_MIN_LOD
:
1191 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1193 case GL_TEXTURE_MAX_LOD
:
1194 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1196 case GL_TEXTURE_LOD_BIAS
:
1197 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1199 case GL_TEXTURE_COMPARE_MODE
:
1200 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1202 case GL_TEXTURE_COMPARE_FUNC
:
1203 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1205 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1206 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1208 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1209 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1211 case GL_TEXTURE_SRGB_DECODE_EXT
:
1212 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1214 case GL_TEXTURE_BORDER_COLOR
:
1215 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1218 res
= INVALID_PNAME
;
1226 /* state change - we do nothing special at this time */
1229 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1230 _mesa_enum_to_string(pname
));
1233 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1237 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1247 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1249 struct gl_sampler_object
*sampObj
;
1251 GET_CURRENT_CONTEXT(ctx
);
1253 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1254 "glSamplerParameterIuiv");
1259 case GL_TEXTURE_WRAP_S
:
1260 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1262 case GL_TEXTURE_WRAP_T
:
1263 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1265 case GL_TEXTURE_WRAP_R
:
1266 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1268 case GL_TEXTURE_MIN_FILTER
:
1269 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1271 case GL_TEXTURE_MAG_FILTER
:
1272 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1274 case GL_TEXTURE_MIN_LOD
:
1275 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1277 case GL_TEXTURE_MAX_LOD
:
1278 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1280 case GL_TEXTURE_LOD_BIAS
:
1281 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1283 case GL_TEXTURE_COMPARE_MODE
:
1284 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1286 case GL_TEXTURE_COMPARE_FUNC
:
1287 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1289 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1290 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1292 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1293 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1295 case GL_TEXTURE_SRGB_DECODE_EXT
:
1296 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1298 case GL_TEXTURE_BORDER_COLOR
:
1299 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1302 res
= INVALID_PNAME
;
1310 /* state change - we do nothing special at this time */
1313 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1314 _mesa_enum_to_string(pname
));
1317 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1321 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1331 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1333 struct gl_sampler_object
*sampObj
;
1334 GET_CURRENT_CONTEXT(ctx
);
1336 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1337 "glGetSamplerParameteriv");
1342 case GL_TEXTURE_WRAP_S
:
1343 *params
= sampObj
->WrapS
;
1345 case GL_TEXTURE_WRAP_T
:
1346 *params
= sampObj
->WrapT
;
1348 case GL_TEXTURE_WRAP_R
:
1349 *params
= sampObj
->WrapR
;
1351 case GL_TEXTURE_MIN_FILTER
:
1352 *params
= sampObj
->MinFilter
;
1354 case GL_TEXTURE_MAG_FILTER
:
1355 *params
= sampObj
->MagFilter
;
1357 case GL_TEXTURE_MIN_LOD
:
1358 /* GL spec 'Data Conversions' section specifies that floating-point
1359 * value in integer Get function is rounded to nearest integer
1361 *params
= IROUND(sampObj
->MinLod
);
1363 case GL_TEXTURE_MAX_LOD
:
1364 /* GL spec 'Data Conversions' section specifies that floating-point
1365 * value in integer Get function is rounded to nearest integer
1367 *params
= IROUND(sampObj
->MaxLod
);
1369 case GL_TEXTURE_LOD_BIAS
:
1370 /* GL spec 'Data Conversions' section specifies that floating-point
1371 * value in integer Get function is rounded to nearest integer
1373 *params
= IROUND(sampObj
->LodBias
);
1375 case GL_TEXTURE_COMPARE_MODE
:
1376 *params
= sampObj
->CompareMode
;
1378 case GL_TEXTURE_COMPARE_FUNC
:
1379 *params
= sampObj
->CompareFunc
;
1381 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1382 /* GL spec 'Data Conversions' section specifies that floating-point
1383 * value in integer Get function is rounded to nearest integer
1385 *params
= IROUND(sampObj
->MaxAnisotropy
);
1387 case GL_TEXTURE_BORDER_COLOR
:
1388 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1389 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1390 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1391 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1393 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1394 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1396 *params
= sampObj
->CubeMapSeamless
;
1398 case GL_TEXTURE_SRGB_DECODE_EXT
:
1399 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1401 *params
= (GLenum
) sampObj
->sRGBDecode
;
1409 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1410 _mesa_enum_to_string(pname
));
1415 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1417 struct gl_sampler_object
*sampObj
;
1418 GET_CURRENT_CONTEXT(ctx
);
1420 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1421 "glGetSamplerParameterfv");
1426 case GL_TEXTURE_WRAP_S
:
1427 *params
= (GLfloat
) sampObj
->WrapS
;
1429 case GL_TEXTURE_WRAP_T
:
1430 *params
= (GLfloat
) sampObj
->WrapT
;
1432 case GL_TEXTURE_WRAP_R
:
1433 *params
= (GLfloat
) sampObj
->WrapR
;
1435 case GL_TEXTURE_MIN_FILTER
:
1436 *params
= (GLfloat
) sampObj
->MinFilter
;
1438 case GL_TEXTURE_MAG_FILTER
:
1439 *params
= (GLfloat
) sampObj
->MagFilter
;
1441 case GL_TEXTURE_MIN_LOD
:
1442 *params
= sampObj
->MinLod
;
1444 case GL_TEXTURE_MAX_LOD
:
1445 *params
= sampObj
->MaxLod
;
1447 case GL_TEXTURE_LOD_BIAS
:
1448 *params
= sampObj
->LodBias
;
1450 case GL_TEXTURE_COMPARE_MODE
:
1451 *params
= (GLfloat
) sampObj
->CompareMode
;
1453 case GL_TEXTURE_COMPARE_FUNC
:
1454 *params
= (GLfloat
) sampObj
->CompareFunc
;
1456 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1457 *params
= sampObj
->MaxAnisotropy
;
1459 case GL_TEXTURE_BORDER_COLOR
:
1460 params
[0] = sampObj
->BorderColor
.f
[0];
1461 params
[1] = sampObj
->BorderColor
.f
[1];
1462 params
[2] = sampObj
->BorderColor
.f
[2];
1463 params
[3] = sampObj
->BorderColor
.f
[3];
1465 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1466 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1468 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1470 case GL_TEXTURE_SRGB_DECODE_EXT
:
1471 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1473 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1481 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1482 _mesa_enum_to_string(pname
));
1487 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1489 struct gl_sampler_object
*sampObj
;
1490 GET_CURRENT_CONTEXT(ctx
);
1492 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1493 "glGetSamplerParameterIiv");
1498 case GL_TEXTURE_WRAP_S
:
1499 *params
= sampObj
->WrapS
;
1501 case GL_TEXTURE_WRAP_T
:
1502 *params
= sampObj
->WrapT
;
1504 case GL_TEXTURE_WRAP_R
:
1505 *params
= sampObj
->WrapR
;
1507 case GL_TEXTURE_MIN_FILTER
:
1508 *params
= sampObj
->MinFilter
;
1510 case GL_TEXTURE_MAG_FILTER
:
1511 *params
= sampObj
->MagFilter
;
1513 case GL_TEXTURE_MIN_LOD
:
1514 *params
= (GLint
) sampObj
->MinLod
;
1516 case GL_TEXTURE_MAX_LOD
:
1517 *params
= (GLint
) sampObj
->MaxLod
;
1519 case GL_TEXTURE_LOD_BIAS
:
1520 *params
= (GLint
) sampObj
->LodBias
;
1522 case GL_TEXTURE_COMPARE_MODE
:
1523 *params
= sampObj
->CompareMode
;
1525 case GL_TEXTURE_COMPARE_FUNC
:
1526 *params
= sampObj
->CompareFunc
;
1528 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1529 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1531 case GL_TEXTURE_BORDER_COLOR
:
1532 params
[0] = sampObj
->BorderColor
.i
[0];
1533 params
[1] = sampObj
->BorderColor
.i
[1];
1534 params
[2] = sampObj
->BorderColor
.i
[2];
1535 params
[3] = sampObj
->BorderColor
.i
[3];
1537 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1538 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1540 *params
= sampObj
->CubeMapSeamless
;
1542 case GL_TEXTURE_SRGB_DECODE_EXT
:
1543 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1545 *params
= (GLenum
) sampObj
->sRGBDecode
;
1553 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1554 _mesa_enum_to_string(pname
));
1559 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1561 struct gl_sampler_object
*sampObj
;
1562 GET_CURRENT_CONTEXT(ctx
);
1564 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1565 "glGetSamplerParameterIuiv");
1570 case GL_TEXTURE_WRAP_S
:
1571 *params
= sampObj
->WrapS
;
1573 case GL_TEXTURE_WRAP_T
:
1574 *params
= sampObj
->WrapT
;
1576 case GL_TEXTURE_WRAP_R
:
1577 *params
= sampObj
->WrapR
;
1579 case GL_TEXTURE_MIN_FILTER
:
1580 *params
= sampObj
->MinFilter
;
1582 case GL_TEXTURE_MAG_FILTER
:
1583 *params
= sampObj
->MagFilter
;
1585 case GL_TEXTURE_MIN_LOD
:
1586 *params
= (GLuint
) sampObj
->MinLod
;
1588 case GL_TEXTURE_MAX_LOD
:
1589 *params
= (GLuint
) sampObj
->MaxLod
;
1591 case GL_TEXTURE_LOD_BIAS
:
1592 *params
= (GLuint
) sampObj
->LodBias
;
1594 case GL_TEXTURE_COMPARE_MODE
:
1595 *params
= sampObj
->CompareMode
;
1597 case GL_TEXTURE_COMPARE_FUNC
:
1598 *params
= sampObj
->CompareFunc
;
1600 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1601 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1603 case GL_TEXTURE_BORDER_COLOR
:
1604 params
[0] = sampObj
->BorderColor
.ui
[0];
1605 params
[1] = sampObj
->BorderColor
.ui
[1];
1606 params
[2] = sampObj
->BorderColor
.ui
[2];
1607 params
[3] = sampObj
->BorderColor
.ui
[3];
1609 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1610 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1612 *params
= sampObj
->CubeMapSeamless
;
1614 case GL_TEXTURE_SRGB_DECODE_EXT
:
1615 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1617 *params
= (GLenum
) sampObj
->sRGBDecode
;
1625 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1626 _mesa_enum_to_string(pname
));
1631 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1633 driver
->NewSamplerObject
= _mesa_new_sampler_object
;