2 * Mesa 3-D graphics library
4 * Copyright (C) 2011 VMware, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
28 * \brief Functions for the GL_ARB_sampler_objects extension.
33 #include "main/glheader.h"
34 #include "main/context.h"
35 #include "main/dispatch.h"
36 #include "main/enums.h"
37 #include "main/hash.h"
38 #include "main/macros.h"
39 #include "main/mtypes.h"
40 #include "main/samplerobj.h"
43 struct gl_sampler_object
*
44 _mesa_lookup_samplerobj(struct gl_context
*ctx
, GLuint name
)
49 return (struct gl_sampler_object
*)
50 _mesa_HashLookup(ctx
->Shared
->SamplerObjects
, name
);
55 begin_samplerobj_lookups(struct gl_context
*ctx
)
57 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
62 end_samplerobj_lookups(struct gl_context
*ctx
)
64 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
68 static inline struct gl_sampler_object
*
69 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
71 return (struct gl_sampler_object
*)
72 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
77 * Handle reference counting.
80 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
81 struct gl_sampler_object
**ptr
,
82 struct gl_sampler_object
*samp
)
84 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
87 /* Unreference the old sampler */
88 GLboolean deleteFlag
= GL_FALSE
;
89 struct gl_sampler_object
*oldSamp
= *ptr
;
91 mtx_lock(&oldSamp
->Mutex
);
92 assert(oldSamp
->RefCount
> 0);
94 deleteFlag
= (oldSamp
->RefCount
== 0);
95 mtx_unlock(&oldSamp
->Mutex
);
98 assert(ctx
->Driver
.DeleteSamplerObject
);
99 ctx
->Driver
.DeleteSamplerObject(ctx
, oldSamp
);
107 /* reference new sampler */
108 mtx_lock(&samp
->Mutex
);
109 if (samp
->RefCount
== 0) {
110 /* this sampler's being deleted (look just above) */
111 /* Not sure this can every really happen. Warn if it does. */
112 _mesa_problem(NULL
, "referencing deleted sampler object");
119 mtx_unlock(&samp
->Mutex
);
125 * Initialize the fields of the given sampler object.
128 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
130 mtx_init(&sampObj
->Mutex
, mtx_plain
);
131 sampObj
->Name
= name
;
132 sampObj
->RefCount
= 1;
133 sampObj
->WrapS
= GL_REPEAT
;
134 sampObj
->WrapT
= GL_REPEAT
;
135 sampObj
->WrapR
= GL_REPEAT
;
136 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
137 sampObj
->MagFilter
= GL_LINEAR
;
138 sampObj
->BorderColor
.f
[0] = 0.0;
139 sampObj
->BorderColor
.f
[1] = 0.0;
140 sampObj
->BorderColor
.f
[2] = 0.0;
141 sampObj
->BorderColor
.f
[3] = 0.0;
142 sampObj
->MinLod
= -1000.0F
;
143 sampObj
->MaxLod
= 1000.0F
;
144 sampObj
->LodBias
= 0.0F
;
145 sampObj
->MaxAnisotropy
= 1.0F
;
146 sampObj
->CompareMode
= GL_NONE
;
147 sampObj
->CompareFunc
= GL_LEQUAL
;
148 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
149 sampObj
->CubeMapSeamless
= GL_FALSE
;
153 * Fallback for ctx->Driver.NewSamplerObject();
155 struct gl_sampler_object
*
156 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
158 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
160 _mesa_init_sampler_object(sampObj
, name
);
167 * Fallback for ctx->Driver.DeleteSamplerObject();
170 _mesa_delete_sampler_object(struct gl_context
*ctx
,
171 struct gl_sampler_object
*sampObj
)
173 mtx_destroy(&sampObj
->Mutex
);
174 free(sampObj
->Label
);
179 create_samplers(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
);
196 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
198 /* Insert the ID and pointer to new sampler object into hash table */
199 for (i
= 0; i
< count
; i
++) {
200 struct gl_sampler_object
*sampObj
=
201 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
202 _mesa_HashInsert(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
203 samplers
[i
] = first
+ i
;
208 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
210 GET_CURRENT_CONTEXT(ctx
);
211 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
215 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
217 GET_CURRENT_CONTEXT(ctx
);
218 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
223 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
225 GET_CURRENT_CONTEXT(ctx
);
228 FLUSH_VERTICES(ctx
, 0);
231 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
235 mtx_lock(&ctx
->Shared
->Mutex
);
237 for (i
= 0; i
< count
; i
++) {
240 struct gl_sampler_object
*sampObj
=
241 _mesa_lookup_samplerobj(ctx
, samplers
[i
]);
244 /* If the sampler is currently bound, unbind it. */
245 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
246 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
247 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
248 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
252 /* The ID is immediately freed for re-use */
253 _mesa_HashRemove(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
254 /* But the object exists until its reference count goes to zero */
255 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
260 mtx_unlock(&ctx
->Shared
->Mutex
);
265 _mesa_IsSampler(GLuint sampler
)
267 struct gl_sampler_object
*sampObj
;
268 GET_CURRENT_CONTEXT(ctx
);
270 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
275 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
277 return sampObj
!= NULL
;
282 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
284 struct gl_sampler_object
*sampObj
;
285 GET_CURRENT_CONTEXT(ctx
);
287 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
288 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
293 /* Use the default sampler object, the one contained in the texture
299 /* user-defined sampler object */
300 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
302 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
307 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
308 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
311 /* bind new sampler */
312 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
318 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
320 GET_CURRENT_CONTEXT(ctx
);
323 /* The ARB_multi_bind spec says:
325 * "An INVALID_OPERATION error is generated if <first> + <count> is
326 * greater than the number of texture image units supported by
327 * the implementation."
329 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
330 _mesa_error(ctx
, GL_INVALID_OPERATION
,
331 "glBindSamplers(first=%u + count=%d > the value of "
332 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
333 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
337 FLUSH_VERTICES(ctx
, 0);
340 /* Note that the error semantics for multi-bind commands differ from
341 * those of other GL commands.
343 * The Issues section in the ARB_multi_bind spec says:
345 * "(11) Typically, OpenGL specifies that if an error is generated by
346 * a command, that command has no effect. This is somewhat
347 * unfortunate for multi-bind commands, because it would require
348 * a first pass to scan the entire list of bound objects for
349 * errors and then a second pass to actually perform the
350 * bindings. Should we have different error semantics?
352 * RESOLVED: Yes. In this specification, when the parameters for
353 * one of the <count> binding points are invalid, that binding
354 * point is not updated and an error will be generated. However,
355 * other binding points in the same command will be updated if
356 * their parameters are valid and no other error occurs."
359 begin_samplerobj_lookups(ctx
);
361 for (i
= 0; i
< count
; i
++) {
362 const GLuint unit
= first
+ i
;
363 struct gl_sampler_object
* const currentSampler
=
364 ctx
->Texture
.Unit
[unit
].Sampler
;
365 struct gl_sampler_object
*sampObj
;
367 if (samplers
[i
] != 0) {
368 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
369 sampObj
= currentSampler
;
371 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
373 /* The ARB_multi_bind spec says:
375 * "An INVALID_OPERATION error is generated if any value
376 * in <samplers> is not zero or the name of an existing
377 * sampler object (per binding)."
380 _mesa_error(ctx
, GL_INVALID_OPERATION
,
381 "glBindSamplers(samplers[%d]=%u is not zero or "
382 "the name of an existing sampler object)",
390 /* Bind the new sampler */
391 if (sampObj
!= currentSampler
) {
392 _mesa_reference_sampler_object(ctx
,
393 &ctx
->Texture
.Unit
[unit
].Sampler
,
395 ctx
->NewState
|= _NEW_TEXTURE
;
399 end_samplerobj_lookups(ctx
);
401 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
402 for (i
= 0; i
< count
; i
++) {
403 const GLuint unit
= first
+ i
;
405 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
406 _mesa_reference_sampler_object(ctx
,
407 &ctx
->Texture
.Unit
[unit
].Sampler
,
409 ctx
->NewState
|= _NEW_TEXTURE
;
417 * Check if a coordinate wrap mode is legal.
418 * \return GL_TRUE if legal, GL_FALSE otherwise
421 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
423 const struct gl_extensions
* const e
= &ctx
->Extensions
;
427 case GL_CLAMP_TO_EDGE
:
429 case GL_MIRRORED_REPEAT
:
431 case GL_CLAMP_TO_BORDER
:
432 return e
->ARB_texture_border_clamp
;
433 case GL_MIRROR_CLAMP_EXT
:
434 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
435 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
436 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
437 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
438 return e
->EXT_texture_mirror_clamp
;
446 * This is called just prior to changing any sampler object state.
449 flush(struct gl_context
*ctx
)
451 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
455 #define INVALID_PARAM 0x100
456 #define INVALID_PNAME 0x101
457 #define INVALID_VALUE 0x102
460 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
463 if (samp
->WrapS
== param
)
465 if (validate_texture_wrap_mode(ctx
, param
)) {
470 return INVALID_PARAM
;
475 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
478 if (samp
->WrapT
== param
)
480 if (validate_texture_wrap_mode(ctx
, param
)) {
485 return INVALID_PARAM
;
490 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
493 if (samp
->WrapR
== param
)
495 if (validate_texture_wrap_mode(ctx
, param
)) {
500 return INVALID_PARAM
;
505 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
508 if (samp
->MinFilter
== param
)
514 case GL_NEAREST_MIPMAP_NEAREST
:
515 case GL_LINEAR_MIPMAP_NEAREST
:
516 case GL_NEAREST_MIPMAP_LINEAR
:
517 case GL_LINEAR_MIPMAP_LINEAR
:
519 samp
->MinFilter
= param
;
522 return INVALID_PARAM
;
528 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
531 if (samp
->MagFilter
== param
)
538 samp
->MagFilter
= param
;
541 return INVALID_PARAM
;
547 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
550 if (samp
->LodBias
== param
)
554 samp
->LodBias
= param
;
560 set_sampler_border_colorf(struct gl_context
*ctx
,
561 struct gl_sampler_object
*samp
,
562 const GLfloat params
[4])
565 samp
->BorderColor
.f
[RCOMP
] = params
[0];
566 samp
->BorderColor
.f
[GCOMP
] = params
[1];
567 samp
->BorderColor
.f
[BCOMP
] = params
[2];
568 samp
->BorderColor
.f
[ACOMP
] = params
[3];
574 set_sampler_border_colori(struct gl_context
*ctx
,
575 struct gl_sampler_object
*samp
,
576 const GLint params
[4])
579 samp
->BorderColor
.i
[RCOMP
] = params
[0];
580 samp
->BorderColor
.i
[GCOMP
] = params
[1];
581 samp
->BorderColor
.i
[BCOMP
] = params
[2];
582 samp
->BorderColor
.i
[ACOMP
] = params
[3];
588 set_sampler_border_colorui(struct gl_context
*ctx
,
589 struct gl_sampler_object
*samp
,
590 const GLuint params
[4])
593 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
594 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
595 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
596 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
602 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
605 if (samp
->MinLod
== param
)
609 samp
->MinLod
= param
;
615 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
618 if (samp
->MaxLod
== param
)
622 samp
->MaxLod
= param
;
628 set_sampler_compare_mode(struct gl_context
*ctx
,
629 struct gl_sampler_object
*samp
, GLint param
)
631 if (!ctx
->Extensions
.ARB_shadow
)
632 return INVALID_PNAME
;
634 if (samp
->CompareMode
== param
)
637 if (param
== GL_NONE
||
638 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
640 samp
->CompareMode
= param
;
644 return INVALID_PARAM
;
649 set_sampler_compare_func(struct gl_context
*ctx
,
650 struct gl_sampler_object
*samp
, GLint param
)
652 if (!ctx
->Extensions
.ARB_shadow
)
653 return INVALID_PNAME
;
655 if (samp
->CompareFunc
== param
)
668 samp
->CompareFunc
= param
;
671 return INVALID_PARAM
;
677 set_sampler_max_anisotropy(struct gl_context
*ctx
,
678 struct gl_sampler_object
*samp
, GLfloat param
)
680 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
681 return INVALID_PNAME
;
683 if (samp
->MaxAnisotropy
== param
)
687 return INVALID_VALUE
;
690 /* clamp to max, that's what NVIDIA does */
691 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
697 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
698 struct gl_sampler_object
*samp
, GLboolean param
)
700 if (!_mesa_is_desktop_gl(ctx
)
701 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
702 return INVALID_PNAME
;
704 if (samp
->CubeMapSeamless
== param
)
707 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
708 return INVALID_VALUE
;
711 samp
->CubeMapSeamless
= param
;
716 set_sampler_srgb_decode(struct gl_context
*ctx
,
717 struct gl_sampler_object
*samp
, GLenum param
)
719 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
720 return INVALID_PNAME
;
722 if (samp
->sRGBDecode
== param
)
725 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
726 return INVALID_VALUE
;
729 samp
->sRGBDecode
= param
;
734 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
736 struct gl_sampler_object
*sampObj
;
738 GET_CURRENT_CONTEXT(ctx
);
740 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
742 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
744 * "An INVALID_OPERATION error is generated if sampler is not the name
745 * of a sampler object previously returned from a call to GenSamplers."
747 * In desktop GL, an GL_INVALID_VALUE is returned instead.
749 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
750 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
751 "glSamplerParameteri(sampler %u)", sampler
);
756 case GL_TEXTURE_WRAP_S
:
757 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
759 case GL_TEXTURE_WRAP_T
:
760 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
762 case GL_TEXTURE_WRAP_R
:
763 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
765 case GL_TEXTURE_MIN_FILTER
:
766 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
768 case GL_TEXTURE_MAG_FILTER
:
769 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
771 case GL_TEXTURE_MIN_LOD
:
772 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
774 case GL_TEXTURE_MAX_LOD
:
775 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
777 case GL_TEXTURE_LOD_BIAS
:
778 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
780 case GL_TEXTURE_COMPARE_MODE
:
781 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
783 case GL_TEXTURE_COMPARE_FUNC
:
784 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
786 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
787 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
789 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
790 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
792 case GL_TEXTURE_SRGB_DECODE_EXT
:
793 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
795 case GL_TEXTURE_BORDER_COLOR
:
806 /* state change - we do nothing special at this time */
809 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
810 _mesa_enum_to_string(pname
));
813 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
817 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
827 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
829 struct gl_sampler_object
*sampObj
;
831 GET_CURRENT_CONTEXT(ctx
);
833 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
835 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
837 * "An INVALID_OPERATION error is generated if sampler is not the name
838 * of a sampler object previously returned from a call to GenSamplers."
840 * In desktop GL, an GL_INVALID_VALUE is returned instead.
842 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
843 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
844 "glSamplerParameterf(sampler %u)", sampler
);
849 case GL_TEXTURE_WRAP_S
:
850 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
852 case GL_TEXTURE_WRAP_T
:
853 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
855 case GL_TEXTURE_WRAP_R
:
856 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
858 case GL_TEXTURE_MIN_FILTER
:
859 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
861 case GL_TEXTURE_MAG_FILTER
:
862 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
864 case GL_TEXTURE_MIN_LOD
:
865 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
867 case GL_TEXTURE_MAX_LOD
:
868 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
870 case GL_TEXTURE_LOD_BIAS
:
871 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
873 case GL_TEXTURE_COMPARE_MODE
:
874 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
876 case GL_TEXTURE_COMPARE_FUNC
:
877 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
879 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
880 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
882 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
883 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
885 case GL_TEXTURE_SRGB_DECODE_EXT
:
886 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
888 case GL_TEXTURE_BORDER_COLOR
:
899 /* state change - we do nothing special at this time */
902 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
903 _mesa_enum_to_string(pname
));
906 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
910 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
919 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
921 struct gl_sampler_object
*sampObj
;
923 GET_CURRENT_CONTEXT(ctx
);
925 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
927 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
929 * "An INVALID_OPERATION error is generated if sampler is not the name
930 * of a sampler object previously returned from a call to GenSamplers."
932 * In desktop GL, an GL_INVALID_VALUE is returned instead.
934 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
935 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
936 "glSamplerParameteriv(sampler %u)", sampler
);
941 case GL_TEXTURE_WRAP_S
:
942 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
944 case GL_TEXTURE_WRAP_T
:
945 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
947 case GL_TEXTURE_WRAP_R
:
948 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
950 case GL_TEXTURE_MIN_FILTER
:
951 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
953 case GL_TEXTURE_MAG_FILTER
:
954 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
956 case GL_TEXTURE_MIN_LOD
:
957 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
959 case GL_TEXTURE_MAX_LOD
:
960 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
962 case GL_TEXTURE_LOD_BIAS
:
963 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
965 case GL_TEXTURE_COMPARE_MODE
:
966 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
968 case GL_TEXTURE_COMPARE_FUNC
:
969 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
971 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
972 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
974 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
975 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
977 case GL_TEXTURE_SRGB_DECODE_EXT
:
978 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
980 case GL_TEXTURE_BORDER_COLOR
:
983 c
[0] = INT_TO_FLOAT(params
[0]);
984 c
[1] = INT_TO_FLOAT(params
[1]);
985 c
[2] = INT_TO_FLOAT(params
[2]);
986 c
[3] = INT_TO_FLOAT(params
[3]);
987 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
999 /* state change - we do nothing special at this time */
1002 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1003 _mesa_enum_to_string(pname
));
1006 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1010 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1019 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1021 struct gl_sampler_object
*sampObj
;
1023 GET_CURRENT_CONTEXT(ctx
);
1025 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1027 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1029 * "An INVALID_OPERATION error is generated if sampler is not the name
1030 * of a sampler object previously returned from a call to GenSamplers."
1032 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1034 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1035 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1036 "glSamplerParameterfv(sampler %u)", sampler
);
1041 case GL_TEXTURE_WRAP_S
:
1042 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1044 case GL_TEXTURE_WRAP_T
:
1045 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1047 case GL_TEXTURE_WRAP_R
:
1048 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1050 case GL_TEXTURE_MIN_FILTER
:
1051 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1053 case GL_TEXTURE_MAG_FILTER
:
1054 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1056 case GL_TEXTURE_MIN_LOD
:
1057 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1059 case GL_TEXTURE_MAX_LOD
:
1060 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1062 case GL_TEXTURE_LOD_BIAS
:
1063 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1065 case GL_TEXTURE_COMPARE_MODE
:
1066 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1068 case GL_TEXTURE_COMPARE_FUNC
:
1069 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1071 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1072 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1074 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1075 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1077 case GL_TEXTURE_SRGB_DECODE_EXT
:
1078 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1080 case GL_TEXTURE_BORDER_COLOR
:
1081 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1084 res
= INVALID_PNAME
;
1092 /* state change - we do nothing special at this time */
1095 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1096 _mesa_enum_to_string(pname
));
1099 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1103 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1112 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1114 struct gl_sampler_object
*sampObj
;
1116 GET_CURRENT_CONTEXT(ctx
);
1118 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1120 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1126 case GL_TEXTURE_WRAP_S
:
1127 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1129 case GL_TEXTURE_WRAP_T
:
1130 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1132 case GL_TEXTURE_WRAP_R
:
1133 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1135 case GL_TEXTURE_MIN_FILTER
:
1136 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1138 case GL_TEXTURE_MAG_FILTER
:
1139 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1141 case GL_TEXTURE_MIN_LOD
:
1142 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1144 case GL_TEXTURE_MAX_LOD
:
1145 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1147 case GL_TEXTURE_LOD_BIAS
:
1148 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1150 case GL_TEXTURE_COMPARE_MODE
:
1151 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1153 case GL_TEXTURE_COMPARE_FUNC
:
1154 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1156 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1157 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1159 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1160 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1162 case GL_TEXTURE_SRGB_DECODE_EXT
:
1163 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1165 case GL_TEXTURE_BORDER_COLOR
:
1166 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1169 res
= INVALID_PNAME
;
1177 /* state change - we do nothing special at this time */
1180 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1181 _mesa_enum_to_string(pname
));
1184 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1188 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1198 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1200 struct gl_sampler_object
*sampObj
;
1202 GET_CURRENT_CONTEXT(ctx
);
1204 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1206 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1212 case GL_TEXTURE_WRAP_S
:
1213 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1215 case GL_TEXTURE_WRAP_T
:
1216 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1218 case GL_TEXTURE_WRAP_R
:
1219 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1221 case GL_TEXTURE_MIN_FILTER
:
1222 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1224 case GL_TEXTURE_MAG_FILTER
:
1225 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1227 case GL_TEXTURE_MIN_LOD
:
1228 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1230 case GL_TEXTURE_MAX_LOD
:
1231 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1233 case GL_TEXTURE_LOD_BIAS
:
1234 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1236 case GL_TEXTURE_COMPARE_MODE
:
1237 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1239 case GL_TEXTURE_COMPARE_FUNC
:
1240 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1242 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1243 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1245 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1246 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1248 case GL_TEXTURE_SRGB_DECODE_EXT
:
1249 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1251 case GL_TEXTURE_BORDER_COLOR
:
1252 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1255 res
= INVALID_PNAME
;
1263 /* state change - we do nothing special at this time */
1266 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1267 _mesa_enum_to_string(pname
));
1270 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1274 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1284 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1286 struct gl_sampler_object
*sampObj
;
1287 GET_CURRENT_CONTEXT(ctx
);
1289 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1291 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1293 * "An INVALID_OPERATION error is generated if sampler is not the name
1294 * of a sampler object previously returned from a call to GenSamplers."
1296 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1298 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1299 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1300 "glGetSamplerParameteriv(sampler %u)", sampler
);
1305 case GL_TEXTURE_WRAP_S
:
1306 *params
= sampObj
->WrapS
;
1308 case GL_TEXTURE_WRAP_T
:
1309 *params
= sampObj
->WrapT
;
1311 case GL_TEXTURE_WRAP_R
:
1312 *params
= sampObj
->WrapR
;
1314 case GL_TEXTURE_MIN_FILTER
:
1315 *params
= sampObj
->MinFilter
;
1317 case GL_TEXTURE_MAG_FILTER
:
1318 *params
= sampObj
->MagFilter
;
1320 case GL_TEXTURE_MIN_LOD
:
1321 /* GL spec 'Data Conversions' section specifies that floating-point
1322 * value in integer Get function is rounded to nearest integer
1324 *params
= IROUND(sampObj
->MinLod
);
1326 case GL_TEXTURE_MAX_LOD
:
1327 /* GL spec 'Data Conversions' section specifies that floating-point
1328 * value in integer Get function is rounded to nearest integer
1330 *params
= IROUND(sampObj
->MaxLod
);
1332 case GL_TEXTURE_LOD_BIAS
:
1333 /* GL spec 'Data Conversions' section specifies that floating-point
1334 * value in integer Get function is rounded to nearest integer
1336 *params
= IROUND(sampObj
->LodBias
);
1338 case GL_TEXTURE_COMPARE_MODE
:
1339 if (!ctx
->Extensions
.ARB_shadow
)
1341 *params
= sampObj
->CompareMode
;
1343 case GL_TEXTURE_COMPARE_FUNC
:
1344 if (!ctx
->Extensions
.ARB_shadow
)
1346 *params
= sampObj
->CompareFunc
;
1348 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1349 /* GL spec 'Data Conversions' section specifies that floating-point
1350 * value in integer Get function is rounded to nearest integer
1352 *params
= IROUND(sampObj
->MaxAnisotropy
);
1354 case GL_TEXTURE_BORDER_COLOR
:
1355 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1356 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1357 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1358 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1360 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1361 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1363 *params
= sampObj
->CubeMapSeamless
;
1365 case GL_TEXTURE_SRGB_DECODE_EXT
:
1366 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1368 *params
= (GLenum
) sampObj
->sRGBDecode
;
1376 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1377 _mesa_enum_to_string(pname
));
1382 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1384 struct gl_sampler_object
*sampObj
;
1385 GET_CURRENT_CONTEXT(ctx
);
1387 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1389 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1391 * "An INVALID_OPERATION error is generated if sampler is not the name
1392 * of a sampler object previously returned from a call to GenSamplers."
1394 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1396 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1397 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1398 "glGetSamplerParameterfv(sampler %u)", sampler
);
1403 case GL_TEXTURE_WRAP_S
:
1404 *params
= (GLfloat
) sampObj
->WrapS
;
1406 case GL_TEXTURE_WRAP_T
:
1407 *params
= (GLfloat
) sampObj
->WrapT
;
1409 case GL_TEXTURE_WRAP_R
:
1410 *params
= (GLfloat
) sampObj
->WrapR
;
1412 case GL_TEXTURE_MIN_FILTER
:
1413 *params
= (GLfloat
) sampObj
->MinFilter
;
1415 case GL_TEXTURE_MAG_FILTER
:
1416 *params
= (GLfloat
) sampObj
->MagFilter
;
1418 case GL_TEXTURE_MIN_LOD
:
1419 *params
= sampObj
->MinLod
;
1421 case GL_TEXTURE_MAX_LOD
:
1422 *params
= sampObj
->MaxLod
;
1424 case GL_TEXTURE_LOD_BIAS
:
1425 *params
= sampObj
->LodBias
;
1427 case GL_TEXTURE_COMPARE_MODE
:
1428 if (!ctx
->Extensions
.ARB_shadow
)
1430 *params
= (GLfloat
) sampObj
->CompareMode
;
1432 case GL_TEXTURE_COMPARE_FUNC
:
1433 if (!ctx
->Extensions
.ARB_shadow
)
1435 *params
= (GLfloat
) sampObj
->CompareFunc
;
1437 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1438 *params
= sampObj
->MaxAnisotropy
;
1440 case GL_TEXTURE_BORDER_COLOR
:
1441 params
[0] = sampObj
->BorderColor
.f
[0];
1442 params
[1] = sampObj
->BorderColor
.f
[1];
1443 params
[2] = sampObj
->BorderColor
.f
[2];
1444 params
[3] = sampObj
->BorderColor
.f
[3];
1446 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1447 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1449 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1451 case GL_TEXTURE_SRGB_DECODE_EXT
:
1452 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1454 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1462 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1463 _mesa_enum_to_string(pname
));
1468 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1470 struct gl_sampler_object
*sampObj
;
1471 GET_CURRENT_CONTEXT(ctx
);
1473 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1475 _mesa_error(ctx
, GL_INVALID_VALUE
,
1476 "glGetSamplerParameterIiv(sampler %u)",
1482 case GL_TEXTURE_WRAP_S
:
1483 *params
= sampObj
->WrapS
;
1485 case GL_TEXTURE_WRAP_T
:
1486 *params
= sampObj
->WrapT
;
1488 case GL_TEXTURE_WRAP_R
:
1489 *params
= sampObj
->WrapR
;
1491 case GL_TEXTURE_MIN_FILTER
:
1492 *params
= sampObj
->MinFilter
;
1494 case GL_TEXTURE_MAG_FILTER
:
1495 *params
= sampObj
->MagFilter
;
1497 case GL_TEXTURE_MIN_LOD
:
1498 *params
= (GLint
) sampObj
->MinLod
;
1500 case GL_TEXTURE_MAX_LOD
:
1501 *params
= (GLint
) sampObj
->MaxLod
;
1503 case GL_TEXTURE_LOD_BIAS
:
1504 *params
= (GLint
) sampObj
->LodBias
;
1506 case GL_TEXTURE_COMPARE_MODE
:
1507 if (!ctx
->Extensions
.ARB_shadow
)
1509 *params
= sampObj
->CompareMode
;
1511 case GL_TEXTURE_COMPARE_FUNC
:
1512 if (!ctx
->Extensions
.ARB_shadow
)
1514 *params
= sampObj
->CompareFunc
;
1516 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1517 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1519 case GL_TEXTURE_BORDER_COLOR
:
1520 params
[0] = sampObj
->BorderColor
.i
[0];
1521 params
[1] = sampObj
->BorderColor
.i
[1];
1522 params
[2] = sampObj
->BorderColor
.i
[2];
1523 params
[3] = sampObj
->BorderColor
.i
[3];
1525 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1526 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1528 *params
= sampObj
->CubeMapSeamless
;
1530 case GL_TEXTURE_SRGB_DECODE_EXT
:
1531 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1533 *params
= (GLenum
) sampObj
->sRGBDecode
;
1541 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1542 _mesa_enum_to_string(pname
));
1547 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1549 struct gl_sampler_object
*sampObj
;
1550 GET_CURRENT_CONTEXT(ctx
);
1552 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1554 _mesa_error(ctx
, GL_INVALID_VALUE
,
1555 "glGetSamplerParameterIuiv(sampler %u)",
1561 case GL_TEXTURE_WRAP_S
:
1562 *params
= sampObj
->WrapS
;
1564 case GL_TEXTURE_WRAP_T
:
1565 *params
= sampObj
->WrapT
;
1567 case GL_TEXTURE_WRAP_R
:
1568 *params
= sampObj
->WrapR
;
1570 case GL_TEXTURE_MIN_FILTER
:
1571 *params
= sampObj
->MinFilter
;
1573 case GL_TEXTURE_MAG_FILTER
:
1574 *params
= sampObj
->MagFilter
;
1576 case GL_TEXTURE_MIN_LOD
:
1577 *params
= (GLuint
) sampObj
->MinLod
;
1579 case GL_TEXTURE_MAX_LOD
:
1580 *params
= (GLuint
) sampObj
->MaxLod
;
1582 case GL_TEXTURE_LOD_BIAS
:
1583 *params
= (GLuint
) sampObj
->LodBias
;
1585 case GL_TEXTURE_COMPARE_MODE
:
1586 if (!ctx
->Extensions
.ARB_shadow
)
1588 *params
= sampObj
->CompareMode
;
1590 case GL_TEXTURE_COMPARE_FUNC
:
1591 if (!ctx
->Extensions
.ARB_shadow
)
1593 *params
= sampObj
->CompareFunc
;
1595 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1596 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1598 case GL_TEXTURE_BORDER_COLOR
:
1599 params
[0] = sampObj
->BorderColor
.ui
[0];
1600 params
[1] = sampObj
->BorderColor
.ui
[1];
1601 params
[2] = sampObj
->BorderColor
.ui
[2];
1602 params
[3] = sampObj
->BorderColor
.ui
[3];
1604 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1605 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1607 *params
= sampObj
->CubeMapSeamless
;
1609 case GL_TEXTURE_SRGB_DECODE_EXT
:
1610 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1612 *params
= (GLenum
) sampObj
->sRGBDecode
;
1620 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1621 _mesa_enum_to_string(pname
));
1626 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1628 driver
->NewSamplerObject
= _mesa_new_sampler_object
;
1629 driver
->DeleteSamplerObject
= _mesa_delete_sampler_object
;