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);
95 printf("SamplerObj %p %d DECR to %d\n",
96 (void *) oldSamp
, oldSamp
->Name
, oldSamp
->RefCount
);
98 deleteFlag
= (oldSamp
->RefCount
== 0);
99 /*mtx_unlock(&oldSamp->Mutex);*/
102 assert(ctx
->Driver
.DeleteSamplerObject
);
103 ctx
->Driver
.DeleteSamplerObject(ctx
, oldSamp
);
111 /* reference new sampler */
112 /*mtx_lock(&samp->Mutex);*/
113 if (samp
->RefCount
== 0) {
114 /* this sampler's being deleted (look just above) */
115 /* Not sure this can every really happen. Warn if it does. */
116 _mesa_problem(NULL
, "referencing deleted sampler object");
122 printf("SamplerObj %p %d INCR to %d\n",
123 (void *) samp
, samp
->Name
, samp
->RefCount
);
127 /*mtx_unlock(&samp->Mutex);*/
133 * Initialize the fields of the given sampler object.
136 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
138 sampObj
->Name
= name
;
139 sampObj
->RefCount
= 1;
140 sampObj
->WrapS
= GL_REPEAT
;
141 sampObj
->WrapT
= GL_REPEAT
;
142 sampObj
->WrapR
= GL_REPEAT
;
143 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
144 sampObj
->MagFilter
= GL_LINEAR
;
145 sampObj
->BorderColor
.f
[0] = 0.0;
146 sampObj
->BorderColor
.f
[1] = 0.0;
147 sampObj
->BorderColor
.f
[2] = 0.0;
148 sampObj
->BorderColor
.f
[3] = 0.0;
149 sampObj
->MinLod
= -1000.0F
;
150 sampObj
->MaxLod
= 1000.0F
;
151 sampObj
->LodBias
= 0.0F
;
152 sampObj
->MaxAnisotropy
= 1.0F
;
153 sampObj
->CompareMode
= GL_NONE
;
154 sampObj
->CompareFunc
= GL_LEQUAL
;
155 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
156 sampObj
->CubeMapSeamless
= GL_FALSE
;
160 * Fallback for ctx->Driver.NewSamplerObject();
162 struct gl_sampler_object
*
163 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
165 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
167 _mesa_init_sampler_object(sampObj
, name
);
174 * Fallback for ctx->Driver.DeleteSamplerObject();
177 _mesa_delete_sampler_object(struct gl_context
*ctx
,
178 struct gl_sampler_object
*sampObj
)
180 free(sampObj
->Label
);
185 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
191 if (MESA_VERBOSE
& VERBOSE_API
)
192 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
195 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
202 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
204 /* Insert the ID and pointer to new sampler object into hash table */
205 for (i
= 0; i
< count
; i
++) {
206 struct gl_sampler_object
*sampObj
=
207 ctx
->Driver
.NewSamplerObject(ctx
, first
+ i
);
208 _mesa_HashInsert(ctx
->Shared
->SamplerObjects
, first
+ i
, sampObj
);
209 samplers
[i
] = first
+ i
;
214 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
216 GET_CURRENT_CONTEXT(ctx
);
217 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
221 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
223 GET_CURRENT_CONTEXT(ctx
);
224 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
229 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
231 GET_CURRENT_CONTEXT(ctx
);
234 FLUSH_VERTICES(ctx
, 0);
237 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
241 mtx_lock(&ctx
->Shared
->Mutex
);
243 for (i
= 0; i
< count
; i
++) {
246 struct gl_sampler_object
*sampObj
=
247 _mesa_lookup_samplerobj(ctx
, samplers
[i
]);
250 /* If the sampler is currently bound, unbind it. */
251 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
252 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
253 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
254 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
258 /* The ID is immediately freed for re-use */
259 _mesa_HashRemove(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
260 /* But the object exists until its reference count goes to zero */
261 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
266 mtx_unlock(&ctx
->Shared
->Mutex
);
271 _mesa_IsSampler(GLuint sampler
)
273 struct gl_sampler_object
*sampObj
;
274 GET_CURRENT_CONTEXT(ctx
);
276 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
281 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
283 return sampObj
!= NULL
;
288 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
290 struct gl_sampler_object
*sampObj
;
291 GET_CURRENT_CONTEXT(ctx
);
293 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
294 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
299 /* Use the default sampler object, the one contained in the texture
305 /* user-defined sampler object */
306 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
308 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
313 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
314 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
317 /* bind new sampler */
318 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
324 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
326 GET_CURRENT_CONTEXT(ctx
);
329 /* The ARB_multi_bind spec says:
331 * "An INVALID_OPERATION error is generated if <first> + <count> is
332 * greater than the number of texture image units supported by
333 * the implementation."
335 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
336 _mesa_error(ctx
, GL_INVALID_OPERATION
,
337 "glBindSamplers(first=%u + count=%d > the value of "
338 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
339 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
343 FLUSH_VERTICES(ctx
, 0);
346 /* Note that the error semantics for multi-bind commands differ from
347 * those of other GL commands.
349 * The Issues section in the ARB_multi_bind spec says:
351 * "(11) Typically, OpenGL specifies that if an error is generated by
352 * a command, that command has no effect. This is somewhat
353 * unfortunate for multi-bind commands, because it would require
354 * a first pass to scan the entire list of bound objects for
355 * errors and then a second pass to actually perform the
356 * bindings. Should we have different error semantics?
358 * RESOLVED: Yes. In this specification, when the parameters for
359 * one of the <count> binding points are invalid, that binding
360 * point is not updated and an error will be generated. However,
361 * other binding points in the same command will be updated if
362 * their parameters are valid and no other error occurs."
365 begin_samplerobj_lookups(ctx
);
367 for (i
= 0; i
< count
; i
++) {
368 const GLuint unit
= first
+ i
;
369 struct gl_sampler_object
* const currentSampler
=
370 ctx
->Texture
.Unit
[unit
].Sampler
;
371 struct gl_sampler_object
*sampObj
;
373 if (samplers
[i
] != 0) {
374 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
375 sampObj
= currentSampler
;
377 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
379 /* The ARB_multi_bind spec says:
381 * "An INVALID_OPERATION error is generated if any value
382 * in <samplers> is not zero or the name of an existing
383 * sampler object (per binding)."
386 _mesa_error(ctx
, GL_INVALID_OPERATION
,
387 "glBindSamplers(samplers[%d]=%u is not zero or "
388 "the name of an existing sampler object)",
396 /* Bind the new sampler */
397 if (sampObj
!= currentSampler
) {
398 _mesa_reference_sampler_object(ctx
,
399 &ctx
->Texture
.Unit
[unit
].Sampler
,
401 ctx
->NewState
|= _NEW_TEXTURE
;
405 end_samplerobj_lookups(ctx
);
407 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
408 for (i
= 0; i
< count
; i
++) {
409 const GLuint unit
= first
+ i
;
411 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
412 _mesa_reference_sampler_object(ctx
,
413 &ctx
->Texture
.Unit
[unit
].Sampler
,
415 ctx
->NewState
|= _NEW_TEXTURE
;
423 * Check if a coordinate wrap mode is legal.
424 * \return GL_TRUE if legal, GL_FALSE otherwise
427 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
429 const struct gl_extensions
* const e
= &ctx
->Extensions
;
433 case GL_CLAMP_TO_EDGE
:
435 case GL_MIRRORED_REPEAT
:
437 case GL_CLAMP_TO_BORDER
:
438 return e
->ARB_texture_border_clamp
;
439 case GL_MIRROR_CLAMP_EXT
:
440 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
441 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
442 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
443 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
444 return e
->EXT_texture_mirror_clamp
;
452 * This is called just prior to changing any sampler object state.
455 flush(struct gl_context
*ctx
)
457 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
461 #define INVALID_PARAM 0x100
462 #define INVALID_PNAME 0x101
463 #define INVALID_VALUE 0x102
466 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
469 if (samp
->WrapS
== param
)
471 if (validate_texture_wrap_mode(ctx
, param
)) {
476 return INVALID_PARAM
;
481 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
484 if (samp
->WrapT
== param
)
486 if (validate_texture_wrap_mode(ctx
, param
)) {
491 return INVALID_PARAM
;
496 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
499 if (samp
->WrapR
== param
)
501 if (validate_texture_wrap_mode(ctx
, param
)) {
506 return INVALID_PARAM
;
511 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
514 if (samp
->MinFilter
== param
)
520 case GL_NEAREST_MIPMAP_NEAREST
:
521 case GL_LINEAR_MIPMAP_NEAREST
:
522 case GL_NEAREST_MIPMAP_LINEAR
:
523 case GL_LINEAR_MIPMAP_LINEAR
:
525 samp
->MinFilter
= param
;
528 return INVALID_PARAM
;
534 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
537 if (samp
->MagFilter
== param
)
544 samp
->MagFilter
= param
;
547 return INVALID_PARAM
;
553 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
556 if (samp
->LodBias
== param
)
560 samp
->LodBias
= param
;
566 set_sampler_border_colorf(struct gl_context
*ctx
,
567 struct gl_sampler_object
*samp
,
568 const GLfloat params
[4])
571 samp
->BorderColor
.f
[RCOMP
] = params
[0];
572 samp
->BorderColor
.f
[GCOMP
] = params
[1];
573 samp
->BorderColor
.f
[BCOMP
] = params
[2];
574 samp
->BorderColor
.f
[ACOMP
] = params
[3];
580 set_sampler_border_colori(struct gl_context
*ctx
,
581 struct gl_sampler_object
*samp
,
582 const GLint params
[4])
585 samp
->BorderColor
.i
[RCOMP
] = params
[0];
586 samp
->BorderColor
.i
[GCOMP
] = params
[1];
587 samp
->BorderColor
.i
[BCOMP
] = params
[2];
588 samp
->BorderColor
.i
[ACOMP
] = params
[3];
594 set_sampler_border_colorui(struct gl_context
*ctx
,
595 struct gl_sampler_object
*samp
,
596 const GLuint params
[4])
599 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
600 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
601 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
602 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
608 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
611 if (samp
->MinLod
== param
)
615 samp
->MinLod
= param
;
621 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
624 if (samp
->MaxLod
== param
)
628 samp
->MaxLod
= param
;
634 set_sampler_compare_mode(struct gl_context
*ctx
,
635 struct gl_sampler_object
*samp
, GLint param
)
637 if (!ctx
->Extensions
.ARB_shadow
)
638 return INVALID_PNAME
;
640 if (samp
->CompareMode
== param
)
643 if (param
== GL_NONE
||
644 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
646 samp
->CompareMode
= param
;
650 return INVALID_PARAM
;
655 set_sampler_compare_func(struct gl_context
*ctx
,
656 struct gl_sampler_object
*samp
, GLint param
)
658 if (!ctx
->Extensions
.ARB_shadow
)
659 return INVALID_PNAME
;
661 if (samp
->CompareFunc
== param
)
674 samp
->CompareFunc
= param
;
677 return INVALID_PARAM
;
683 set_sampler_max_anisotropy(struct gl_context
*ctx
,
684 struct gl_sampler_object
*samp
, GLfloat param
)
686 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
687 return INVALID_PNAME
;
689 if (samp
->MaxAnisotropy
== param
)
693 return INVALID_VALUE
;
696 /* clamp to max, that's what NVIDIA does */
697 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
703 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
704 struct gl_sampler_object
*samp
, GLboolean param
)
706 if (!_mesa_is_desktop_gl(ctx
)
707 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
708 return INVALID_PNAME
;
710 if (samp
->CubeMapSeamless
== param
)
713 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
714 return INVALID_VALUE
;
717 samp
->CubeMapSeamless
= param
;
722 set_sampler_srgb_decode(struct gl_context
*ctx
,
723 struct gl_sampler_object
*samp
, GLenum param
)
725 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
726 return INVALID_PNAME
;
728 if (samp
->sRGBDecode
== param
)
731 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
732 return INVALID_VALUE
;
735 samp
->sRGBDecode
= param
;
740 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
742 struct gl_sampler_object
*sampObj
;
744 GET_CURRENT_CONTEXT(ctx
);
746 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
748 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
750 * "An INVALID_OPERATION error is generated if sampler is not the name
751 * of a sampler object previously returned from a call to GenSamplers."
753 * In desktop GL, an GL_INVALID_VALUE is returned instead.
755 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
756 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
757 "glSamplerParameteri(sampler %u)", sampler
);
762 case GL_TEXTURE_WRAP_S
:
763 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
765 case GL_TEXTURE_WRAP_T
:
766 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
768 case GL_TEXTURE_WRAP_R
:
769 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
771 case GL_TEXTURE_MIN_FILTER
:
772 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
774 case GL_TEXTURE_MAG_FILTER
:
775 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
777 case GL_TEXTURE_MIN_LOD
:
778 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
780 case GL_TEXTURE_MAX_LOD
:
781 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
783 case GL_TEXTURE_LOD_BIAS
:
784 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
786 case GL_TEXTURE_COMPARE_MODE
:
787 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
789 case GL_TEXTURE_COMPARE_FUNC
:
790 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
792 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
793 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
795 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
796 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
798 case GL_TEXTURE_SRGB_DECODE_EXT
:
799 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
801 case GL_TEXTURE_BORDER_COLOR
:
812 /* state change - we do nothing special at this time */
815 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
816 _mesa_lookup_enum_by_nr(pname
));
819 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
823 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
833 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
835 struct gl_sampler_object
*sampObj
;
837 GET_CURRENT_CONTEXT(ctx
);
839 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
841 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
843 * "An INVALID_OPERATION error is generated if sampler is not the name
844 * of a sampler object previously returned from a call to GenSamplers."
846 * In desktop GL, an GL_INVALID_VALUE is returned instead.
848 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
849 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
850 "glSamplerParameterf(sampler %u)", sampler
);
855 case GL_TEXTURE_WRAP_S
:
856 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
858 case GL_TEXTURE_WRAP_T
:
859 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
861 case GL_TEXTURE_WRAP_R
:
862 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
864 case GL_TEXTURE_MIN_FILTER
:
865 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
867 case GL_TEXTURE_MAG_FILTER
:
868 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
870 case GL_TEXTURE_MIN_LOD
:
871 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
873 case GL_TEXTURE_MAX_LOD
:
874 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
876 case GL_TEXTURE_LOD_BIAS
:
877 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
879 case GL_TEXTURE_COMPARE_MODE
:
880 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
882 case GL_TEXTURE_COMPARE_FUNC
:
883 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
885 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
886 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
888 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
889 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
891 case GL_TEXTURE_SRGB_DECODE_EXT
:
892 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
894 case GL_TEXTURE_BORDER_COLOR
:
905 /* state change - we do nothing special at this time */
908 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
909 _mesa_lookup_enum_by_nr(pname
));
912 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
916 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
925 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
927 struct gl_sampler_object
*sampObj
;
929 GET_CURRENT_CONTEXT(ctx
);
931 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
933 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
935 * "An INVALID_OPERATION error is generated if sampler is not the name
936 * of a sampler object previously returned from a call to GenSamplers."
938 * In desktop GL, an GL_INVALID_VALUE is returned instead.
940 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
941 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
942 "glSamplerParameteriv(sampler %u)", sampler
);
947 case GL_TEXTURE_WRAP_S
:
948 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
950 case GL_TEXTURE_WRAP_T
:
951 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
953 case GL_TEXTURE_WRAP_R
:
954 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
956 case GL_TEXTURE_MIN_FILTER
:
957 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
959 case GL_TEXTURE_MAG_FILTER
:
960 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
962 case GL_TEXTURE_MIN_LOD
:
963 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
965 case GL_TEXTURE_MAX_LOD
:
966 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
968 case GL_TEXTURE_LOD_BIAS
:
969 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
971 case GL_TEXTURE_COMPARE_MODE
:
972 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
974 case GL_TEXTURE_COMPARE_FUNC
:
975 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
977 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
978 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
980 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
981 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
983 case GL_TEXTURE_SRGB_DECODE_EXT
:
984 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
986 case GL_TEXTURE_BORDER_COLOR
:
989 c
[0] = INT_TO_FLOAT(params
[0]);
990 c
[1] = INT_TO_FLOAT(params
[1]);
991 c
[2] = INT_TO_FLOAT(params
[2]);
992 c
[3] = INT_TO_FLOAT(params
[3]);
993 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1005 /* state change - we do nothing special at this time */
1008 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1009 _mesa_lookup_enum_by_nr(pname
));
1012 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1016 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1025 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1027 struct gl_sampler_object
*sampObj
;
1029 GET_CURRENT_CONTEXT(ctx
);
1031 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1033 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1035 * "An INVALID_OPERATION error is generated if sampler is not the name
1036 * of a sampler object previously returned from a call to GenSamplers."
1038 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1040 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1041 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1042 "glSamplerParameterfv(sampler %u)", sampler
);
1047 case GL_TEXTURE_WRAP_S
:
1048 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1050 case GL_TEXTURE_WRAP_T
:
1051 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1053 case GL_TEXTURE_WRAP_R
:
1054 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1056 case GL_TEXTURE_MIN_FILTER
:
1057 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1059 case GL_TEXTURE_MAG_FILTER
:
1060 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1062 case GL_TEXTURE_MIN_LOD
:
1063 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1065 case GL_TEXTURE_MAX_LOD
:
1066 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1068 case GL_TEXTURE_LOD_BIAS
:
1069 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1071 case GL_TEXTURE_COMPARE_MODE
:
1072 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1074 case GL_TEXTURE_COMPARE_FUNC
:
1075 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1077 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1078 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1080 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1081 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1083 case GL_TEXTURE_SRGB_DECODE_EXT
:
1084 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1086 case GL_TEXTURE_BORDER_COLOR
:
1087 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1090 res
= INVALID_PNAME
;
1098 /* state change - we do nothing special at this time */
1101 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1102 _mesa_lookup_enum_by_nr(pname
));
1105 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1109 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1118 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1120 struct gl_sampler_object
*sampObj
;
1122 GET_CURRENT_CONTEXT(ctx
);
1124 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1126 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1132 case GL_TEXTURE_WRAP_S
:
1133 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1135 case GL_TEXTURE_WRAP_T
:
1136 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1138 case GL_TEXTURE_WRAP_R
:
1139 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1141 case GL_TEXTURE_MIN_FILTER
:
1142 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1144 case GL_TEXTURE_MAG_FILTER
:
1145 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1147 case GL_TEXTURE_MIN_LOD
:
1148 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1150 case GL_TEXTURE_MAX_LOD
:
1151 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1153 case GL_TEXTURE_LOD_BIAS
:
1154 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1156 case GL_TEXTURE_COMPARE_MODE
:
1157 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1159 case GL_TEXTURE_COMPARE_FUNC
:
1160 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1162 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1163 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1165 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1166 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1168 case GL_TEXTURE_SRGB_DECODE_EXT
:
1169 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1171 case GL_TEXTURE_BORDER_COLOR
:
1172 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1175 res
= INVALID_PNAME
;
1183 /* state change - we do nothing special at this time */
1186 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1187 _mesa_lookup_enum_by_nr(pname
));
1190 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1194 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1204 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1206 struct gl_sampler_object
*sampObj
;
1208 GET_CURRENT_CONTEXT(ctx
);
1210 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1212 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1218 case GL_TEXTURE_WRAP_S
:
1219 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1221 case GL_TEXTURE_WRAP_T
:
1222 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1224 case GL_TEXTURE_WRAP_R
:
1225 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1227 case GL_TEXTURE_MIN_FILTER
:
1228 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1230 case GL_TEXTURE_MAG_FILTER
:
1231 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1233 case GL_TEXTURE_MIN_LOD
:
1234 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1236 case GL_TEXTURE_MAX_LOD
:
1237 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1239 case GL_TEXTURE_LOD_BIAS
:
1240 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1242 case GL_TEXTURE_COMPARE_MODE
:
1243 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1245 case GL_TEXTURE_COMPARE_FUNC
:
1246 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1248 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1249 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1251 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1252 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1254 case GL_TEXTURE_SRGB_DECODE_EXT
:
1255 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1257 case GL_TEXTURE_BORDER_COLOR
:
1258 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1261 res
= INVALID_PNAME
;
1269 /* state change - we do nothing special at this time */
1272 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1273 _mesa_lookup_enum_by_nr(pname
));
1276 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1280 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1290 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1292 struct gl_sampler_object
*sampObj
;
1293 GET_CURRENT_CONTEXT(ctx
);
1295 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1297 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1299 * "An INVALID_OPERATION error is generated if sampler is not the name
1300 * of a sampler object previously returned from a call to GenSamplers."
1302 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1304 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1305 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1306 "glGetSamplerParameteriv(sampler %u)", sampler
);
1311 case GL_TEXTURE_WRAP_S
:
1312 *params
= sampObj
->WrapS
;
1314 case GL_TEXTURE_WRAP_T
:
1315 *params
= sampObj
->WrapT
;
1317 case GL_TEXTURE_WRAP_R
:
1318 *params
= sampObj
->WrapR
;
1320 case GL_TEXTURE_MIN_FILTER
:
1321 *params
= sampObj
->MinFilter
;
1323 case GL_TEXTURE_MAG_FILTER
:
1324 *params
= sampObj
->MagFilter
;
1326 case GL_TEXTURE_MIN_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
->MinLod
);
1332 case GL_TEXTURE_MAX_LOD
:
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
->MaxLod
);
1338 case GL_TEXTURE_LOD_BIAS
:
1339 /* GL spec 'Data Conversions' section specifies that floating-point
1340 * value in integer Get function is rounded to nearest integer
1342 *params
= IROUND(sampObj
->LodBias
);
1344 case GL_TEXTURE_COMPARE_MODE
:
1345 if (!ctx
->Extensions
.ARB_shadow
)
1347 *params
= sampObj
->CompareMode
;
1349 case GL_TEXTURE_COMPARE_FUNC
:
1350 if (!ctx
->Extensions
.ARB_shadow
)
1352 *params
= sampObj
->CompareFunc
;
1354 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1355 /* GL spec 'Data Conversions' section specifies that floating-point
1356 * value in integer Get function is rounded to nearest integer
1358 *params
= IROUND(sampObj
->MaxAnisotropy
);
1360 case GL_TEXTURE_BORDER_COLOR
:
1361 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1362 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1363 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1364 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1366 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1367 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1369 *params
= sampObj
->CubeMapSeamless
;
1371 case GL_TEXTURE_SRGB_DECODE_EXT
:
1372 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1374 *params
= (GLenum
) sampObj
->sRGBDecode
;
1382 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1383 _mesa_lookup_enum_by_nr(pname
));
1388 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1390 struct gl_sampler_object
*sampObj
;
1391 GET_CURRENT_CONTEXT(ctx
);
1393 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1395 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1397 * "An INVALID_OPERATION error is generated if sampler is not the name
1398 * of a sampler object previously returned from a call to GenSamplers."
1400 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1402 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1403 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1404 "glGetSamplerParameterfv(sampler %u)", sampler
);
1409 case GL_TEXTURE_WRAP_S
:
1410 *params
= (GLfloat
) sampObj
->WrapS
;
1412 case GL_TEXTURE_WRAP_T
:
1413 *params
= (GLfloat
) sampObj
->WrapT
;
1415 case GL_TEXTURE_WRAP_R
:
1416 *params
= (GLfloat
) sampObj
->WrapR
;
1418 case GL_TEXTURE_MIN_FILTER
:
1419 *params
= (GLfloat
) sampObj
->MinFilter
;
1421 case GL_TEXTURE_MAG_FILTER
:
1422 *params
= (GLfloat
) sampObj
->MagFilter
;
1424 case GL_TEXTURE_MIN_LOD
:
1425 *params
= sampObj
->MinLod
;
1427 case GL_TEXTURE_MAX_LOD
:
1428 *params
= sampObj
->MaxLod
;
1430 case GL_TEXTURE_LOD_BIAS
:
1431 *params
= sampObj
->LodBias
;
1433 case GL_TEXTURE_COMPARE_MODE
:
1434 if (!ctx
->Extensions
.ARB_shadow
)
1436 *params
= (GLfloat
) sampObj
->CompareMode
;
1438 case GL_TEXTURE_COMPARE_FUNC
:
1439 if (!ctx
->Extensions
.ARB_shadow
)
1441 *params
= (GLfloat
) sampObj
->CompareFunc
;
1443 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1444 *params
= sampObj
->MaxAnisotropy
;
1446 case GL_TEXTURE_BORDER_COLOR
:
1447 params
[0] = sampObj
->BorderColor
.f
[0];
1448 params
[1] = sampObj
->BorderColor
.f
[1];
1449 params
[2] = sampObj
->BorderColor
.f
[2];
1450 params
[3] = sampObj
->BorderColor
.f
[3];
1452 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1453 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1455 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1457 case GL_TEXTURE_SRGB_DECODE_EXT
:
1458 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1460 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1468 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1469 _mesa_lookup_enum_by_nr(pname
));
1474 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1476 struct gl_sampler_object
*sampObj
;
1477 GET_CURRENT_CONTEXT(ctx
);
1479 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1481 _mesa_error(ctx
, GL_INVALID_VALUE
,
1482 "glGetSamplerParameterIiv(sampler %u)",
1488 case GL_TEXTURE_WRAP_S
:
1489 *params
= sampObj
->WrapS
;
1491 case GL_TEXTURE_WRAP_T
:
1492 *params
= sampObj
->WrapT
;
1494 case GL_TEXTURE_WRAP_R
:
1495 *params
= sampObj
->WrapR
;
1497 case GL_TEXTURE_MIN_FILTER
:
1498 *params
= sampObj
->MinFilter
;
1500 case GL_TEXTURE_MAG_FILTER
:
1501 *params
= sampObj
->MagFilter
;
1503 case GL_TEXTURE_MIN_LOD
:
1504 *params
= (GLint
) sampObj
->MinLod
;
1506 case GL_TEXTURE_MAX_LOD
:
1507 *params
= (GLint
) sampObj
->MaxLod
;
1509 case GL_TEXTURE_LOD_BIAS
:
1510 *params
= (GLint
) sampObj
->LodBias
;
1512 case GL_TEXTURE_COMPARE_MODE
:
1513 if (!ctx
->Extensions
.ARB_shadow
)
1515 *params
= sampObj
->CompareMode
;
1517 case GL_TEXTURE_COMPARE_FUNC
:
1518 if (!ctx
->Extensions
.ARB_shadow
)
1520 *params
= sampObj
->CompareFunc
;
1522 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1523 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1525 case GL_TEXTURE_BORDER_COLOR
:
1526 params
[0] = sampObj
->BorderColor
.i
[0];
1527 params
[1] = sampObj
->BorderColor
.i
[1];
1528 params
[2] = sampObj
->BorderColor
.i
[2];
1529 params
[3] = sampObj
->BorderColor
.i
[3];
1531 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1532 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1534 *params
= sampObj
->CubeMapSeamless
;
1536 case GL_TEXTURE_SRGB_DECODE_EXT
:
1537 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1539 *params
= (GLenum
) sampObj
->sRGBDecode
;
1547 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1548 _mesa_lookup_enum_by_nr(pname
));
1553 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1555 struct gl_sampler_object
*sampObj
;
1556 GET_CURRENT_CONTEXT(ctx
);
1558 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1560 _mesa_error(ctx
, GL_INVALID_VALUE
,
1561 "glGetSamplerParameterIuiv(sampler %u)",
1567 case GL_TEXTURE_WRAP_S
:
1568 *params
= sampObj
->WrapS
;
1570 case GL_TEXTURE_WRAP_T
:
1571 *params
= sampObj
->WrapT
;
1573 case GL_TEXTURE_WRAP_R
:
1574 *params
= sampObj
->WrapR
;
1576 case GL_TEXTURE_MIN_FILTER
:
1577 *params
= sampObj
->MinFilter
;
1579 case GL_TEXTURE_MAG_FILTER
:
1580 *params
= sampObj
->MagFilter
;
1582 case GL_TEXTURE_MIN_LOD
:
1583 *params
= (GLuint
) sampObj
->MinLod
;
1585 case GL_TEXTURE_MAX_LOD
:
1586 *params
= (GLuint
) sampObj
->MaxLod
;
1588 case GL_TEXTURE_LOD_BIAS
:
1589 *params
= (GLuint
) sampObj
->LodBias
;
1591 case GL_TEXTURE_COMPARE_MODE
:
1592 if (!ctx
->Extensions
.ARB_shadow
)
1594 *params
= sampObj
->CompareMode
;
1596 case GL_TEXTURE_COMPARE_FUNC
:
1597 if (!ctx
->Extensions
.ARB_shadow
)
1599 *params
= sampObj
->CompareFunc
;
1601 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1602 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1604 case GL_TEXTURE_BORDER_COLOR
:
1605 params
[0] = sampObj
->BorderColor
.ui
[0];
1606 params
[1] = sampObj
->BorderColor
.ui
[1];
1607 params
[2] = sampObj
->BorderColor
.ui
[2];
1608 params
[3] = sampObj
->BorderColor
.ui
[3];
1610 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1611 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1613 *params
= sampObj
->CubeMapSeamless
;
1615 case GL_TEXTURE_SRGB_DECODE_EXT
:
1616 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1618 *params
= (GLenum
) sampObj
->sRGBDecode
;
1626 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1627 _mesa_lookup_enum_by_nr(pname
));
1632 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1634 driver
->NewSamplerObject
= _mesa_new_sampler_object
;
1635 driver
->DeleteSamplerObject
= _mesa_delete_sampler_object
;