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 sampObj
->Name
= name
;
131 sampObj
->RefCount
= 1;
132 sampObj
->WrapS
= GL_REPEAT
;
133 sampObj
->WrapT
= GL_REPEAT
;
134 sampObj
->WrapR
= GL_REPEAT
;
135 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
136 sampObj
->MagFilter
= GL_LINEAR
;
137 sampObj
->BorderColor
.f
[0] = 0.0;
138 sampObj
->BorderColor
.f
[1] = 0.0;
139 sampObj
->BorderColor
.f
[2] = 0.0;
140 sampObj
->BorderColor
.f
[3] = 0.0;
141 sampObj
->MinLod
= -1000.0F
;
142 sampObj
->MaxLod
= 1000.0F
;
143 sampObj
->LodBias
= 0.0F
;
144 sampObj
->MaxAnisotropy
= 1.0F
;
145 sampObj
->CompareMode
= GL_NONE
;
146 sampObj
->CompareFunc
= GL_LEQUAL
;
147 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
148 sampObj
->CubeMapSeamless
= GL_FALSE
;
152 * Fallback for ctx->Driver.NewSamplerObject();
154 struct gl_sampler_object
*
155 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
157 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
159 _mesa_init_sampler_object(sampObj
, name
);
166 * Fallback for ctx->Driver.DeleteSamplerObject();
169 _mesa_delete_sampler_object(struct gl_context
*ctx
,
170 struct gl_sampler_object
*sampObj
)
172 free(sampObj
->Label
);
177 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
183 if (MESA_VERBOSE
& VERBOSE_API
)
184 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
187 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
194 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
196 /* Insert the ID and pointer to new sampler object into hash table */
197 for (i
= 0; i
< count
; i
++) {
198 struct gl_sampler_object
*sampObj
=
199 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
200 _mesa_HashInsert(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
201 samplers
[i
] = first
+ i
;
206 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
208 GET_CURRENT_CONTEXT(ctx
);
209 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
213 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
215 GET_CURRENT_CONTEXT(ctx
);
216 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
221 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
223 GET_CURRENT_CONTEXT(ctx
);
226 FLUSH_VERTICES(ctx
, 0);
229 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
233 mtx_lock(&ctx
->Shared
->Mutex
);
235 for (i
= 0; i
< count
; i
++) {
238 struct gl_sampler_object
*sampObj
=
239 _mesa_lookup_samplerobj(ctx
, samplers
[i
]);
242 /* If the sampler is currently bound, unbind it. */
243 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
244 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
245 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
246 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
250 /* The ID is immediately freed for re-use */
251 _mesa_HashRemove(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
252 /* But the object exists until its reference count goes to zero */
253 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
258 mtx_unlock(&ctx
->Shared
->Mutex
);
263 _mesa_IsSampler(GLuint sampler
)
265 struct gl_sampler_object
*sampObj
;
266 GET_CURRENT_CONTEXT(ctx
);
268 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
273 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
275 return sampObj
!= NULL
;
280 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
282 struct gl_sampler_object
*sampObj
;
283 GET_CURRENT_CONTEXT(ctx
);
285 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
286 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
291 /* Use the default sampler object, the one contained in the texture
297 /* user-defined sampler object */
298 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
300 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
305 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
306 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
309 /* bind new sampler */
310 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
316 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
318 GET_CURRENT_CONTEXT(ctx
);
321 /* The ARB_multi_bind spec says:
323 * "An INVALID_OPERATION error is generated if <first> + <count> is
324 * greater than the number of texture image units supported by
325 * the implementation."
327 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
328 _mesa_error(ctx
, GL_INVALID_OPERATION
,
329 "glBindSamplers(first=%u + count=%d > the value of "
330 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
331 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
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 begin_samplerobj_lookups(ctx
);
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)."
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
;
397 end_samplerobj_lookups(ctx
);
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
;
415 * Check if a coordinate wrap mode is legal.
416 * \return GL_TRUE if legal, GL_FALSE otherwise
419 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
421 const struct gl_extensions
* const e
= &ctx
->Extensions
;
425 case GL_CLAMP_TO_EDGE
:
427 case GL_MIRRORED_REPEAT
:
429 case GL_CLAMP_TO_BORDER
:
430 return e
->ARB_texture_border_clamp
;
431 case GL_MIRROR_CLAMP_EXT
:
432 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
433 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
434 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
435 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
436 return e
->EXT_texture_mirror_clamp
;
444 * This is called just prior to changing any sampler object state.
447 flush(struct gl_context
*ctx
)
449 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
453 #define INVALID_PARAM 0x100
454 #define INVALID_PNAME 0x101
455 #define INVALID_VALUE 0x102
458 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
461 if (samp
->WrapS
== param
)
463 if (validate_texture_wrap_mode(ctx
, param
)) {
468 return INVALID_PARAM
;
473 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
476 if (samp
->WrapT
== param
)
478 if (validate_texture_wrap_mode(ctx
, param
)) {
483 return INVALID_PARAM
;
488 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
491 if (samp
->WrapR
== param
)
493 if (validate_texture_wrap_mode(ctx
, param
)) {
498 return INVALID_PARAM
;
503 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
506 if (samp
->MinFilter
== param
)
512 case GL_NEAREST_MIPMAP_NEAREST
:
513 case GL_LINEAR_MIPMAP_NEAREST
:
514 case GL_NEAREST_MIPMAP_LINEAR
:
515 case GL_LINEAR_MIPMAP_LINEAR
:
517 samp
->MinFilter
= param
;
520 return INVALID_PARAM
;
526 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
529 if (samp
->MagFilter
== param
)
536 samp
->MagFilter
= param
;
539 return INVALID_PARAM
;
545 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
548 if (samp
->LodBias
== param
)
552 samp
->LodBias
= param
;
558 set_sampler_border_colorf(struct gl_context
*ctx
,
559 struct gl_sampler_object
*samp
,
560 const GLfloat params
[4])
563 samp
->BorderColor
.f
[RCOMP
] = params
[0];
564 samp
->BorderColor
.f
[GCOMP
] = params
[1];
565 samp
->BorderColor
.f
[BCOMP
] = params
[2];
566 samp
->BorderColor
.f
[ACOMP
] = params
[3];
572 set_sampler_border_colori(struct gl_context
*ctx
,
573 struct gl_sampler_object
*samp
,
574 const GLint params
[4])
577 samp
->BorderColor
.i
[RCOMP
] = params
[0];
578 samp
->BorderColor
.i
[GCOMP
] = params
[1];
579 samp
->BorderColor
.i
[BCOMP
] = params
[2];
580 samp
->BorderColor
.i
[ACOMP
] = params
[3];
586 set_sampler_border_colorui(struct gl_context
*ctx
,
587 struct gl_sampler_object
*samp
,
588 const GLuint params
[4])
591 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
592 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
593 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
594 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
600 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
603 if (samp
->MinLod
== param
)
607 samp
->MinLod
= param
;
613 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
616 if (samp
->MaxLod
== param
)
620 samp
->MaxLod
= param
;
626 set_sampler_compare_mode(struct gl_context
*ctx
,
627 struct gl_sampler_object
*samp
, GLint param
)
629 if (!ctx
->Extensions
.ARB_shadow
)
630 return INVALID_PNAME
;
632 if (samp
->CompareMode
== param
)
635 if (param
== GL_NONE
||
636 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
638 samp
->CompareMode
= param
;
642 return INVALID_PARAM
;
647 set_sampler_compare_func(struct gl_context
*ctx
,
648 struct gl_sampler_object
*samp
, GLint param
)
650 if (!ctx
->Extensions
.ARB_shadow
)
651 return INVALID_PNAME
;
653 if (samp
->CompareFunc
== param
)
666 samp
->CompareFunc
= param
;
669 return INVALID_PARAM
;
675 set_sampler_max_anisotropy(struct gl_context
*ctx
,
676 struct gl_sampler_object
*samp
, GLfloat param
)
678 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
679 return INVALID_PNAME
;
681 if (samp
->MaxAnisotropy
== param
)
685 return INVALID_VALUE
;
688 /* clamp to max, that's what NVIDIA does */
689 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
695 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
696 struct gl_sampler_object
*samp
, GLboolean param
)
698 if (!_mesa_is_desktop_gl(ctx
)
699 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
700 return INVALID_PNAME
;
702 if (samp
->CubeMapSeamless
== param
)
705 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
706 return INVALID_VALUE
;
709 samp
->CubeMapSeamless
= param
;
714 set_sampler_srgb_decode(struct gl_context
*ctx
,
715 struct gl_sampler_object
*samp
, GLenum param
)
717 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
718 return INVALID_PNAME
;
720 if (samp
->sRGBDecode
== param
)
723 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
724 return INVALID_VALUE
;
727 samp
->sRGBDecode
= param
;
732 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
734 struct gl_sampler_object
*sampObj
;
736 GET_CURRENT_CONTEXT(ctx
);
738 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
740 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
742 * "An INVALID_OPERATION error is generated if sampler is not the name
743 * of a sampler object previously returned from a call to GenSamplers."
745 * In desktop GL, an GL_INVALID_VALUE is returned instead.
747 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
748 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
749 "glSamplerParameteri(sampler %u)", sampler
);
754 case GL_TEXTURE_WRAP_S
:
755 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
757 case GL_TEXTURE_WRAP_T
:
758 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
760 case GL_TEXTURE_WRAP_R
:
761 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
763 case GL_TEXTURE_MIN_FILTER
:
764 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
766 case GL_TEXTURE_MAG_FILTER
:
767 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
769 case GL_TEXTURE_MIN_LOD
:
770 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
772 case GL_TEXTURE_MAX_LOD
:
773 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
775 case GL_TEXTURE_LOD_BIAS
:
776 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
778 case GL_TEXTURE_COMPARE_MODE
:
779 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
781 case GL_TEXTURE_COMPARE_FUNC
:
782 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
784 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
785 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
787 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
788 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
790 case GL_TEXTURE_SRGB_DECODE_EXT
:
791 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
793 case GL_TEXTURE_BORDER_COLOR
:
804 /* state change - we do nothing special at this time */
807 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
808 _mesa_enum_to_string(pname
));
811 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
815 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
825 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
827 struct gl_sampler_object
*sampObj
;
829 GET_CURRENT_CONTEXT(ctx
);
831 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
833 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
835 * "An INVALID_OPERATION error is generated if sampler is not the name
836 * of a sampler object previously returned from a call to GenSamplers."
838 * In desktop GL, an GL_INVALID_VALUE is returned instead.
840 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
841 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
842 "glSamplerParameterf(sampler %u)", sampler
);
847 case GL_TEXTURE_WRAP_S
:
848 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
850 case GL_TEXTURE_WRAP_T
:
851 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
853 case GL_TEXTURE_WRAP_R
:
854 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
856 case GL_TEXTURE_MIN_FILTER
:
857 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
859 case GL_TEXTURE_MAG_FILTER
:
860 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
862 case GL_TEXTURE_MIN_LOD
:
863 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
865 case GL_TEXTURE_MAX_LOD
:
866 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
868 case GL_TEXTURE_LOD_BIAS
:
869 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
871 case GL_TEXTURE_COMPARE_MODE
:
872 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
874 case GL_TEXTURE_COMPARE_FUNC
:
875 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
877 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
878 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
880 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
881 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
883 case GL_TEXTURE_SRGB_DECODE_EXT
:
884 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
886 case GL_TEXTURE_BORDER_COLOR
:
897 /* state change - we do nothing special at this time */
900 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
901 _mesa_enum_to_string(pname
));
904 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
908 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
917 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
919 struct gl_sampler_object
*sampObj
;
921 GET_CURRENT_CONTEXT(ctx
);
923 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
925 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
927 * "An INVALID_OPERATION error is generated if sampler is not the name
928 * of a sampler object previously returned from a call to GenSamplers."
930 * In desktop GL, an GL_INVALID_VALUE is returned instead.
932 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
933 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
934 "glSamplerParameteriv(sampler %u)", sampler
);
939 case GL_TEXTURE_WRAP_S
:
940 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
942 case GL_TEXTURE_WRAP_T
:
943 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
945 case GL_TEXTURE_WRAP_R
:
946 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
948 case GL_TEXTURE_MIN_FILTER
:
949 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
951 case GL_TEXTURE_MAG_FILTER
:
952 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
954 case GL_TEXTURE_MIN_LOD
:
955 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
957 case GL_TEXTURE_MAX_LOD
:
958 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
960 case GL_TEXTURE_LOD_BIAS
:
961 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
963 case GL_TEXTURE_COMPARE_MODE
:
964 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
966 case GL_TEXTURE_COMPARE_FUNC
:
967 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
969 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
970 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
972 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
973 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
975 case GL_TEXTURE_SRGB_DECODE_EXT
:
976 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
978 case GL_TEXTURE_BORDER_COLOR
:
981 c
[0] = INT_TO_FLOAT(params
[0]);
982 c
[1] = INT_TO_FLOAT(params
[1]);
983 c
[2] = INT_TO_FLOAT(params
[2]);
984 c
[3] = INT_TO_FLOAT(params
[3]);
985 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
997 /* state change - we do nothing special at this time */
1000 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1001 _mesa_enum_to_string(pname
));
1004 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1008 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1017 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1019 struct gl_sampler_object
*sampObj
;
1021 GET_CURRENT_CONTEXT(ctx
);
1023 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1025 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1027 * "An INVALID_OPERATION error is generated if sampler is not the name
1028 * of a sampler object previously returned from a call to GenSamplers."
1030 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1032 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1033 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1034 "glSamplerParameterfv(sampler %u)", sampler
);
1039 case GL_TEXTURE_WRAP_S
:
1040 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1042 case GL_TEXTURE_WRAP_T
:
1043 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1045 case GL_TEXTURE_WRAP_R
:
1046 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1048 case GL_TEXTURE_MIN_FILTER
:
1049 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1051 case GL_TEXTURE_MAG_FILTER
:
1052 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1054 case GL_TEXTURE_MIN_LOD
:
1055 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1057 case GL_TEXTURE_MAX_LOD
:
1058 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1060 case GL_TEXTURE_LOD_BIAS
:
1061 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1063 case GL_TEXTURE_COMPARE_MODE
:
1064 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1066 case GL_TEXTURE_COMPARE_FUNC
:
1067 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1069 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1070 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1072 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1073 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1075 case GL_TEXTURE_SRGB_DECODE_EXT
:
1076 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1078 case GL_TEXTURE_BORDER_COLOR
:
1079 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1082 res
= INVALID_PNAME
;
1090 /* state change - we do nothing special at this time */
1093 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1094 _mesa_enum_to_string(pname
));
1097 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1101 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1110 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1112 struct gl_sampler_object
*sampObj
;
1114 GET_CURRENT_CONTEXT(ctx
);
1116 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1118 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1124 case GL_TEXTURE_WRAP_S
:
1125 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1127 case GL_TEXTURE_WRAP_T
:
1128 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1130 case GL_TEXTURE_WRAP_R
:
1131 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1133 case GL_TEXTURE_MIN_FILTER
:
1134 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1136 case GL_TEXTURE_MAG_FILTER
:
1137 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1139 case GL_TEXTURE_MIN_LOD
:
1140 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1142 case GL_TEXTURE_MAX_LOD
:
1143 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1145 case GL_TEXTURE_LOD_BIAS
:
1146 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1148 case GL_TEXTURE_COMPARE_MODE
:
1149 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1151 case GL_TEXTURE_COMPARE_FUNC
:
1152 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1154 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1155 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1157 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1158 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1160 case GL_TEXTURE_SRGB_DECODE_EXT
:
1161 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1163 case GL_TEXTURE_BORDER_COLOR
:
1164 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1167 res
= INVALID_PNAME
;
1175 /* state change - we do nothing special at this time */
1178 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1179 _mesa_enum_to_string(pname
));
1182 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1186 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1196 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1198 struct gl_sampler_object
*sampObj
;
1200 GET_CURRENT_CONTEXT(ctx
);
1202 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1204 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1210 case GL_TEXTURE_WRAP_S
:
1211 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1213 case GL_TEXTURE_WRAP_T
:
1214 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1216 case GL_TEXTURE_WRAP_R
:
1217 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1219 case GL_TEXTURE_MIN_FILTER
:
1220 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1222 case GL_TEXTURE_MAG_FILTER
:
1223 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1225 case GL_TEXTURE_MIN_LOD
:
1226 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1228 case GL_TEXTURE_MAX_LOD
:
1229 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1231 case GL_TEXTURE_LOD_BIAS
:
1232 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1234 case GL_TEXTURE_COMPARE_MODE
:
1235 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1237 case GL_TEXTURE_COMPARE_FUNC
:
1238 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1240 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1241 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1243 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1244 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1246 case GL_TEXTURE_SRGB_DECODE_EXT
:
1247 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1249 case GL_TEXTURE_BORDER_COLOR
:
1250 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1253 res
= INVALID_PNAME
;
1261 /* state change - we do nothing special at this time */
1264 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1265 _mesa_enum_to_string(pname
));
1268 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1272 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1282 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1284 struct gl_sampler_object
*sampObj
;
1285 GET_CURRENT_CONTEXT(ctx
);
1287 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1289 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1291 * "An INVALID_OPERATION error is generated if sampler is not the name
1292 * of a sampler object previously returned from a call to GenSamplers."
1294 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1296 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1297 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1298 "glGetSamplerParameteriv(sampler %u)", sampler
);
1303 case GL_TEXTURE_WRAP_S
:
1304 *params
= sampObj
->WrapS
;
1306 case GL_TEXTURE_WRAP_T
:
1307 *params
= sampObj
->WrapT
;
1309 case GL_TEXTURE_WRAP_R
:
1310 *params
= sampObj
->WrapR
;
1312 case GL_TEXTURE_MIN_FILTER
:
1313 *params
= sampObj
->MinFilter
;
1315 case GL_TEXTURE_MAG_FILTER
:
1316 *params
= sampObj
->MagFilter
;
1318 case GL_TEXTURE_MIN_LOD
:
1319 /* GL spec 'Data Conversions' section specifies that floating-point
1320 * value in integer Get function is rounded to nearest integer
1322 *params
= IROUND(sampObj
->MinLod
);
1324 case GL_TEXTURE_MAX_LOD
:
1325 /* GL spec 'Data Conversions' section specifies that floating-point
1326 * value in integer Get function is rounded to nearest integer
1328 *params
= IROUND(sampObj
->MaxLod
);
1330 case GL_TEXTURE_LOD_BIAS
:
1331 /* GL spec 'Data Conversions' section specifies that floating-point
1332 * value in integer Get function is rounded to nearest integer
1334 *params
= IROUND(sampObj
->LodBias
);
1336 case GL_TEXTURE_COMPARE_MODE
:
1337 if (!ctx
->Extensions
.ARB_shadow
)
1339 *params
= sampObj
->CompareMode
;
1341 case GL_TEXTURE_COMPARE_FUNC
:
1342 if (!ctx
->Extensions
.ARB_shadow
)
1344 *params
= sampObj
->CompareFunc
;
1346 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1347 /* GL spec 'Data Conversions' section specifies that floating-point
1348 * value in integer Get function is rounded to nearest integer
1350 *params
= IROUND(sampObj
->MaxAnisotropy
);
1352 case GL_TEXTURE_BORDER_COLOR
:
1353 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1354 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1355 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1356 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1358 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1359 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1361 *params
= sampObj
->CubeMapSeamless
;
1363 case GL_TEXTURE_SRGB_DECODE_EXT
:
1364 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1366 *params
= (GLenum
) sampObj
->sRGBDecode
;
1374 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1375 _mesa_enum_to_string(pname
));
1380 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1382 struct gl_sampler_object
*sampObj
;
1383 GET_CURRENT_CONTEXT(ctx
);
1385 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1387 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1389 * "An INVALID_OPERATION error is generated if sampler is not the name
1390 * of a sampler object previously returned from a call to GenSamplers."
1392 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1394 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1395 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1396 "glGetSamplerParameterfv(sampler %u)", sampler
);
1401 case GL_TEXTURE_WRAP_S
:
1402 *params
= (GLfloat
) sampObj
->WrapS
;
1404 case GL_TEXTURE_WRAP_T
:
1405 *params
= (GLfloat
) sampObj
->WrapT
;
1407 case GL_TEXTURE_WRAP_R
:
1408 *params
= (GLfloat
) sampObj
->WrapR
;
1410 case GL_TEXTURE_MIN_FILTER
:
1411 *params
= (GLfloat
) sampObj
->MinFilter
;
1413 case GL_TEXTURE_MAG_FILTER
:
1414 *params
= (GLfloat
) sampObj
->MagFilter
;
1416 case GL_TEXTURE_MIN_LOD
:
1417 *params
= sampObj
->MinLod
;
1419 case GL_TEXTURE_MAX_LOD
:
1420 *params
= sampObj
->MaxLod
;
1422 case GL_TEXTURE_LOD_BIAS
:
1423 *params
= sampObj
->LodBias
;
1425 case GL_TEXTURE_COMPARE_MODE
:
1426 if (!ctx
->Extensions
.ARB_shadow
)
1428 *params
= (GLfloat
) sampObj
->CompareMode
;
1430 case GL_TEXTURE_COMPARE_FUNC
:
1431 if (!ctx
->Extensions
.ARB_shadow
)
1433 *params
= (GLfloat
) sampObj
->CompareFunc
;
1435 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1436 *params
= sampObj
->MaxAnisotropy
;
1438 case GL_TEXTURE_BORDER_COLOR
:
1439 params
[0] = sampObj
->BorderColor
.f
[0];
1440 params
[1] = sampObj
->BorderColor
.f
[1];
1441 params
[2] = sampObj
->BorderColor
.f
[2];
1442 params
[3] = sampObj
->BorderColor
.f
[3];
1444 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1445 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1447 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1449 case GL_TEXTURE_SRGB_DECODE_EXT
:
1450 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1452 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1460 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1461 _mesa_enum_to_string(pname
));
1466 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1468 struct gl_sampler_object
*sampObj
;
1469 GET_CURRENT_CONTEXT(ctx
);
1471 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1473 _mesa_error(ctx
, GL_INVALID_VALUE
,
1474 "glGetSamplerParameterIiv(sampler %u)",
1480 case GL_TEXTURE_WRAP_S
:
1481 *params
= sampObj
->WrapS
;
1483 case GL_TEXTURE_WRAP_T
:
1484 *params
= sampObj
->WrapT
;
1486 case GL_TEXTURE_WRAP_R
:
1487 *params
= sampObj
->WrapR
;
1489 case GL_TEXTURE_MIN_FILTER
:
1490 *params
= sampObj
->MinFilter
;
1492 case GL_TEXTURE_MAG_FILTER
:
1493 *params
= sampObj
->MagFilter
;
1495 case GL_TEXTURE_MIN_LOD
:
1496 *params
= (GLint
) sampObj
->MinLod
;
1498 case GL_TEXTURE_MAX_LOD
:
1499 *params
= (GLint
) sampObj
->MaxLod
;
1501 case GL_TEXTURE_LOD_BIAS
:
1502 *params
= (GLint
) sampObj
->LodBias
;
1504 case GL_TEXTURE_COMPARE_MODE
:
1505 if (!ctx
->Extensions
.ARB_shadow
)
1507 *params
= sampObj
->CompareMode
;
1509 case GL_TEXTURE_COMPARE_FUNC
:
1510 if (!ctx
->Extensions
.ARB_shadow
)
1512 *params
= sampObj
->CompareFunc
;
1514 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1515 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1517 case GL_TEXTURE_BORDER_COLOR
:
1518 params
[0] = sampObj
->BorderColor
.i
[0];
1519 params
[1] = sampObj
->BorderColor
.i
[1];
1520 params
[2] = sampObj
->BorderColor
.i
[2];
1521 params
[3] = sampObj
->BorderColor
.i
[3];
1523 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1524 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1526 *params
= sampObj
->CubeMapSeamless
;
1528 case GL_TEXTURE_SRGB_DECODE_EXT
:
1529 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1531 *params
= (GLenum
) sampObj
->sRGBDecode
;
1539 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1540 _mesa_enum_to_string(pname
));
1545 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1547 struct gl_sampler_object
*sampObj
;
1548 GET_CURRENT_CONTEXT(ctx
);
1550 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1552 _mesa_error(ctx
, GL_INVALID_VALUE
,
1553 "glGetSamplerParameterIuiv(sampler %u)",
1559 case GL_TEXTURE_WRAP_S
:
1560 *params
= sampObj
->WrapS
;
1562 case GL_TEXTURE_WRAP_T
:
1563 *params
= sampObj
->WrapT
;
1565 case GL_TEXTURE_WRAP_R
:
1566 *params
= sampObj
->WrapR
;
1568 case GL_TEXTURE_MIN_FILTER
:
1569 *params
= sampObj
->MinFilter
;
1571 case GL_TEXTURE_MAG_FILTER
:
1572 *params
= sampObj
->MagFilter
;
1574 case GL_TEXTURE_MIN_LOD
:
1575 *params
= (GLuint
) sampObj
->MinLod
;
1577 case GL_TEXTURE_MAX_LOD
:
1578 *params
= (GLuint
) sampObj
->MaxLod
;
1580 case GL_TEXTURE_LOD_BIAS
:
1581 *params
= (GLuint
) sampObj
->LodBias
;
1583 case GL_TEXTURE_COMPARE_MODE
:
1584 if (!ctx
->Extensions
.ARB_shadow
)
1586 *params
= sampObj
->CompareMode
;
1588 case GL_TEXTURE_COMPARE_FUNC
:
1589 if (!ctx
->Extensions
.ARB_shadow
)
1591 *params
= sampObj
->CompareFunc
;
1593 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1594 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1596 case GL_TEXTURE_BORDER_COLOR
:
1597 params
[0] = sampObj
->BorderColor
.ui
[0];
1598 params
[1] = sampObj
->BorderColor
.ui
[1];
1599 params
[2] = sampObj
->BorderColor
.ui
[2];
1600 params
[3] = sampObj
->BorderColor
.ui
[3];
1602 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1603 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1605 *params
= sampObj
->CubeMapSeamless
;
1607 case GL_TEXTURE_SRGB_DECODE_EXT
:
1608 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1610 *params
= (GLenum
) sampObj
->sRGBDecode
;
1618 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1619 _mesa_enum_to_string(pname
));
1624 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1626 driver
->NewSamplerObject
= _mesa_new_sampler_object
;
1627 driver
->DeleteSamplerObject
= _mesa_delete_sampler_object
;