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
);
225 if (!ctx
->Extensions
.ARB_direct_state_access
) {
226 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glCreateSamplers("
227 "GL_ARB_direct_state_access is not supported)");
231 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
236 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
238 GET_CURRENT_CONTEXT(ctx
);
241 FLUSH_VERTICES(ctx
, 0);
244 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
248 mtx_lock(&ctx
->Shared
->Mutex
);
250 for (i
= 0; i
< count
; i
++) {
253 struct gl_sampler_object
*sampObj
=
254 _mesa_lookup_samplerobj(ctx
, samplers
[i
]);
257 /* If the sampler is currently bound, unbind it. */
258 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
259 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
260 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
261 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
265 /* The ID is immediately freed for re-use */
266 _mesa_HashRemove(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
267 /* But the object exists until its reference count goes to zero */
268 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
273 mtx_unlock(&ctx
->Shared
->Mutex
);
278 _mesa_IsSampler(GLuint sampler
)
280 struct gl_sampler_object
*sampObj
;
281 GET_CURRENT_CONTEXT(ctx
);
283 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
288 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
290 return sampObj
!= NULL
;
295 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
297 struct gl_sampler_object
*sampObj
;
298 GET_CURRENT_CONTEXT(ctx
);
300 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
301 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
306 /* Use the default sampler object, the one contained in the texture
312 /* user-defined sampler object */
313 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
315 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
320 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
321 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
324 /* bind new sampler */
325 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
331 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
333 GET_CURRENT_CONTEXT(ctx
);
336 /* The ARB_multi_bind spec says:
338 * "An INVALID_OPERATION error is generated if <first> + <count> is
339 * greater than the number of texture image units supported by
340 * the implementation."
342 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
343 _mesa_error(ctx
, GL_INVALID_OPERATION
,
344 "glBindSamplers(first=%u + count=%d > the value of "
345 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
346 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
350 FLUSH_VERTICES(ctx
, 0);
353 /* Note that the error semantics for multi-bind commands differ from
354 * those of other GL commands.
356 * The Issues section in the ARB_multi_bind spec says:
358 * "(11) Typically, OpenGL specifies that if an error is generated by
359 * a command, that command has no effect. This is somewhat
360 * unfortunate for multi-bind commands, because it would require
361 * a first pass to scan the entire list of bound objects for
362 * errors and then a second pass to actually perform the
363 * bindings. Should we have different error semantics?
365 * RESOLVED: Yes. In this specification, when the parameters for
366 * one of the <count> binding points are invalid, that binding
367 * point is not updated and an error will be generated. However,
368 * other binding points in the same command will be updated if
369 * their parameters are valid and no other error occurs."
372 begin_samplerobj_lookups(ctx
);
374 for (i
= 0; i
< count
; i
++) {
375 const GLuint unit
= first
+ i
;
376 struct gl_sampler_object
* const currentSampler
=
377 ctx
->Texture
.Unit
[unit
].Sampler
;
378 struct gl_sampler_object
*sampObj
;
380 if (samplers
[i
] != 0) {
381 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
382 sampObj
= currentSampler
;
384 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
386 /* The ARB_multi_bind spec says:
388 * "An INVALID_OPERATION error is generated if any value
389 * in <samplers> is not zero or the name of an existing
390 * sampler object (per binding)."
393 _mesa_error(ctx
, GL_INVALID_OPERATION
,
394 "glBindSamplers(samplers[%d]=%u is not zero or "
395 "the name of an existing sampler object)",
403 /* Bind the new sampler */
404 if (sampObj
!= currentSampler
) {
405 _mesa_reference_sampler_object(ctx
,
406 &ctx
->Texture
.Unit
[unit
].Sampler
,
408 ctx
->NewState
|= _NEW_TEXTURE
;
412 end_samplerobj_lookups(ctx
);
414 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
415 for (i
= 0; i
< count
; i
++) {
416 const GLuint unit
= first
+ i
;
418 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
419 _mesa_reference_sampler_object(ctx
,
420 &ctx
->Texture
.Unit
[unit
].Sampler
,
422 ctx
->NewState
|= _NEW_TEXTURE
;
430 * Check if a coordinate wrap mode is legal.
431 * \return GL_TRUE if legal, GL_FALSE otherwise
434 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
436 const struct gl_extensions
* const e
= &ctx
->Extensions
;
440 case GL_CLAMP_TO_EDGE
:
442 case GL_MIRRORED_REPEAT
:
444 case GL_CLAMP_TO_BORDER
:
445 return e
->ARB_texture_border_clamp
;
446 case GL_MIRROR_CLAMP_EXT
:
447 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
448 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
449 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
450 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
451 return e
->EXT_texture_mirror_clamp
;
459 * This is called just prior to changing any sampler object state.
462 flush(struct gl_context
*ctx
)
464 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
468 #define INVALID_PARAM 0x100
469 #define INVALID_PNAME 0x101
470 #define INVALID_VALUE 0x102
473 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
476 if (samp
->WrapS
== param
)
478 if (validate_texture_wrap_mode(ctx
, param
)) {
483 return INVALID_PARAM
;
488 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
491 if (samp
->WrapT
== param
)
493 if (validate_texture_wrap_mode(ctx
, param
)) {
498 return INVALID_PARAM
;
503 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
506 if (samp
->WrapR
== param
)
508 if (validate_texture_wrap_mode(ctx
, param
)) {
513 return INVALID_PARAM
;
518 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
521 if (samp
->MinFilter
== param
)
527 case GL_NEAREST_MIPMAP_NEAREST
:
528 case GL_LINEAR_MIPMAP_NEAREST
:
529 case GL_NEAREST_MIPMAP_LINEAR
:
530 case GL_LINEAR_MIPMAP_LINEAR
:
532 samp
->MinFilter
= param
;
535 return INVALID_PARAM
;
541 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
544 if (samp
->MagFilter
== param
)
551 samp
->MagFilter
= param
;
554 return INVALID_PARAM
;
560 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
563 if (samp
->LodBias
== param
)
567 samp
->LodBias
= param
;
573 set_sampler_border_colorf(struct gl_context
*ctx
,
574 struct gl_sampler_object
*samp
,
575 const GLfloat params
[4])
578 samp
->BorderColor
.f
[RCOMP
] = params
[0];
579 samp
->BorderColor
.f
[GCOMP
] = params
[1];
580 samp
->BorderColor
.f
[BCOMP
] = params
[2];
581 samp
->BorderColor
.f
[ACOMP
] = params
[3];
587 set_sampler_border_colori(struct gl_context
*ctx
,
588 struct gl_sampler_object
*samp
,
589 const GLint params
[4])
592 samp
->BorderColor
.i
[RCOMP
] = params
[0];
593 samp
->BorderColor
.i
[GCOMP
] = params
[1];
594 samp
->BorderColor
.i
[BCOMP
] = params
[2];
595 samp
->BorderColor
.i
[ACOMP
] = params
[3];
601 set_sampler_border_colorui(struct gl_context
*ctx
,
602 struct gl_sampler_object
*samp
,
603 const GLuint params
[4])
606 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
607 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
608 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
609 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
615 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
618 if (samp
->MinLod
== param
)
622 samp
->MinLod
= param
;
628 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
631 if (samp
->MaxLod
== param
)
635 samp
->MaxLod
= param
;
641 set_sampler_compare_mode(struct gl_context
*ctx
,
642 struct gl_sampler_object
*samp
, GLint param
)
644 if (!ctx
->Extensions
.ARB_shadow
)
645 return INVALID_PNAME
;
647 if (samp
->CompareMode
== param
)
650 if (param
== GL_NONE
||
651 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
653 samp
->CompareMode
= param
;
657 return INVALID_PARAM
;
662 set_sampler_compare_func(struct gl_context
*ctx
,
663 struct gl_sampler_object
*samp
, GLint param
)
665 if (!ctx
->Extensions
.ARB_shadow
)
666 return INVALID_PNAME
;
668 if (samp
->CompareFunc
== param
)
681 samp
->CompareFunc
= param
;
684 return INVALID_PARAM
;
690 set_sampler_max_anisotropy(struct gl_context
*ctx
,
691 struct gl_sampler_object
*samp
, GLfloat param
)
693 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
694 return INVALID_PNAME
;
696 if (samp
->MaxAnisotropy
== param
)
700 return INVALID_VALUE
;
703 /* clamp to max, that's what NVIDIA does */
704 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
710 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
711 struct gl_sampler_object
*samp
, GLboolean param
)
713 if (!_mesa_is_desktop_gl(ctx
)
714 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
715 return INVALID_PNAME
;
717 if (samp
->CubeMapSeamless
== param
)
720 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
721 return INVALID_VALUE
;
724 samp
->CubeMapSeamless
= param
;
729 set_sampler_srgb_decode(struct gl_context
*ctx
,
730 struct gl_sampler_object
*samp
, GLenum param
)
732 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
733 return INVALID_PNAME
;
735 if (samp
->sRGBDecode
== param
)
738 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
739 return INVALID_VALUE
;
742 samp
->sRGBDecode
= param
;
747 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
749 struct gl_sampler_object
*sampObj
;
751 GET_CURRENT_CONTEXT(ctx
);
753 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
755 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
757 * "An INVALID_OPERATION error is generated if sampler is not the name
758 * of a sampler object previously returned from a call to GenSamplers."
760 * In desktop GL, an GL_INVALID_VALUE is returned instead.
762 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
763 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
764 "glSamplerParameteri(sampler %u)", sampler
);
769 case GL_TEXTURE_WRAP_S
:
770 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
772 case GL_TEXTURE_WRAP_T
:
773 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
775 case GL_TEXTURE_WRAP_R
:
776 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
778 case GL_TEXTURE_MIN_FILTER
:
779 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
781 case GL_TEXTURE_MAG_FILTER
:
782 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
784 case GL_TEXTURE_MIN_LOD
:
785 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
787 case GL_TEXTURE_MAX_LOD
:
788 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
790 case GL_TEXTURE_LOD_BIAS
:
791 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
793 case GL_TEXTURE_COMPARE_MODE
:
794 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
796 case GL_TEXTURE_COMPARE_FUNC
:
797 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
799 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
800 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
802 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
803 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
805 case GL_TEXTURE_SRGB_DECODE_EXT
:
806 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
808 case GL_TEXTURE_BORDER_COLOR
:
819 /* state change - we do nothing special at this time */
822 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
823 _mesa_lookup_enum_by_nr(pname
));
826 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
830 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
840 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
842 struct gl_sampler_object
*sampObj
;
844 GET_CURRENT_CONTEXT(ctx
);
846 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
848 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
850 * "An INVALID_OPERATION error is generated if sampler is not the name
851 * of a sampler object previously returned from a call to GenSamplers."
853 * In desktop GL, an GL_INVALID_VALUE is returned instead.
855 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
856 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
857 "glSamplerParameterf(sampler %u)", sampler
);
862 case GL_TEXTURE_WRAP_S
:
863 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
865 case GL_TEXTURE_WRAP_T
:
866 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
868 case GL_TEXTURE_WRAP_R
:
869 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
871 case GL_TEXTURE_MIN_FILTER
:
872 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
874 case GL_TEXTURE_MAG_FILTER
:
875 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
877 case GL_TEXTURE_MIN_LOD
:
878 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
880 case GL_TEXTURE_MAX_LOD
:
881 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
883 case GL_TEXTURE_LOD_BIAS
:
884 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
886 case GL_TEXTURE_COMPARE_MODE
:
887 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
889 case GL_TEXTURE_COMPARE_FUNC
:
890 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
892 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
893 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
895 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
896 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
898 case GL_TEXTURE_SRGB_DECODE_EXT
:
899 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
901 case GL_TEXTURE_BORDER_COLOR
:
912 /* state change - we do nothing special at this time */
915 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
916 _mesa_lookup_enum_by_nr(pname
));
919 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
923 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
932 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
934 struct gl_sampler_object
*sampObj
;
936 GET_CURRENT_CONTEXT(ctx
);
938 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
940 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
942 * "An INVALID_OPERATION error is generated if sampler is not the name
943 * of a sampler object previously returned from a call to GenSamplers."
945 * In desktop GL, an GL_INVALID_VALUE is returned instead.
947 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
948 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
949 "glSamplerParameteriv(sampler %u)", sampler
);
954 case GL_TEXTURE_WRAP_S
:
955 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
957 case GL_TEXTURE_WRAP_T
:
958 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
960 case GL_TEXTURE_WRAP_R
:
961 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
963 case GL_TEXTURE_MIN_FILTER
:
964 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
966 case GL_TEXTURE_MAG_FILTER
:
967 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
969 case GL_TEXTURE_MIN_LOD
:
970 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
972 case GL_TEXTURE_MAX_LOD
:
973 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
975 case GL_TEXTURE_LOD_BIAS
:
976 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
978 case GL_TEXTURE_COMPARE_MODE
:
979 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
981 case GL_TEXTURE_COMPARE_FUNC
:
982 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
984 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
985 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
987 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
988 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
990 case GL_TEXTURE_SRGB_DECODE_EXT
:
991 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
993 case GL_TEXTURE_BORDER_COLOR
:
996 c
[0] = INT_TO_FLOAT(params
[0]);
997 c
[1] = INT_TO_FLOAT(params
[1]);
998 c
[2] = INT_TO_FLOAT(params
[2]);
999 c
[3] = INT_TO_FLOAT(params
[3]);
1000 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1004 res
= INVALID_PNAME
;
1012 /* state change - we do nothing special at this time */
1015 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1016 _mesa_lookup_enum_by_nr(pname
));
1019 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1023 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1032 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1034 struct gl_sampler_object
*sampObj
;
1036 GET_CURRENT_CONTEXT(ctx
);
1038 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1040 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1042 * "An INVALID_OPERATION error is generated if sampler is not the name
1043 * of a sampler object previously returned from a call to GenSamplers."
1045 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1047 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1048 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1049 "glSamplerParameterfv(sampler %u)", sampler
);
1054 case GL_TEXTURE_WRAP_S
:
1055 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1057 case GL_TEXTURE_WRAP_T
:
1058 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1060 case GL_TEXTURE_WRAP_R
:
1061 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1063 case GL_TEXTURE_MIN_FILTER
:
1064 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1066 case GL_TEXTURE_MAG_FILTER
:
1067 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1069 case GL_TEXTURE_MIN_LOD
:
1070 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1072 case GL_TEXTURE_MAX_LOD
:
1073 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1075 case GL_TEXTURE_LOD_BIAS
:
1076 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1078 case GL_TEXTURE_COMPARE_MODE
:
1079 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1081 case GL_TEXTURE_COMPARE_FUNC
:
1082 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1084 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1085 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1087 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1088 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1090 case GL_TEXTURE_SRGB_DECODE_EXT
:
1091 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1093 case GL_TEXTURE_BORDER_COLOR
:
1094 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1097 res
= INVALID_PNAME
;
1105 /* state change - we do nothing special at this time */
1108 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1109 _mesa_lookup_enum_by_nr(pname
));
1112 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1116 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1125 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1127 struct gl_sampler_object
*sampObj
;
1129 GET_CURRENT_CONTEXT(ctx
);
1131 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1133 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(sampler %u)",
1139 case GL_TEXTURE_WRAP_S
:
1140 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1142 case GL_TEXTURE_WRAP_T
:
1143 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1145 case GL_TEXTURE_WRAP_R
:
1146 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1148 case GL_TEXTURE_MIN_FILTER
:
1149 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1151 case GL_TEXTURE_MAG_FILTER
:
1152 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1154 case GL_TEXTURE_MIN_LOD
:
1155 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1157 case GL_TEXTURE_MAX_LOD
:
1158 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1160 case GL_TEXTURE_LOD_BIAS
:
1161 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1163 case GL_TEXTURE_COMPARE_MODE
:
1164 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1166 case GL_TEXTURE_COMPARE_FUNC
:
1167 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1169 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1170 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1172 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1173 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1175 case GL_TEXTURE_SRGB_DECODE_EXT
:
1176 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1178 case GL_TEXTURE_BORDER_COLOR
:
1179 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1182 res
= INVALID_PNAME
;
1190 /* state change - we do nothing special at this time */
1193 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1194 _mesa_lookup_enum_by_nr(pname
));
1197 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1201 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1211 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1213 struct gl_sampler_object
*sampObj
;
1215 GET_CURRENT_CONTEXT(ctx
);
1217 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1219 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(sampler %u)",
1225 case GL_TEXTURE_WRAP_S
:
1226 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1228 case GL_TEXTURE_WRAP_T
:
1229 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1231 case GL_TEXTURE_WRAP_R
:
1232 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1234 case GL_TEXTURE_MIN_FILTER
:
1235 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1237 case GL_TEXTURE_MAG_FILTER
:
1238 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1240 case GL_TEXTURE_MIN_LOD
:
1241 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1243 case GL_TEXTURE_MAX_LOD
:
1244 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1246 case GL_TEXTURE_LOD_BIAS
:
1247 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1249 case GL_TEXTURE_COMPARE_MODE
:
1250 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1252 case GL_TEXTURE_COMPARE_FUNC
:
1253 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1255 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1256 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1258 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1259 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1261 case GL_TEXTURE_SRGB_DECODE_EXT
:
1262 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1264 case GL_TEXTURE_BORDER_COLOR
:
1265 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1268 res
= INVALID_PNAME
;
1276 /* state change - we do nothing special at this time */
1279 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1280 _mesa_lookup_enum_by_nr(pname
));
1283 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1287 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1297 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1299 struct gl_sampler_object
*sampObj
;
1300 GET_CURRENT_CONTEXT(ctx
);
1302 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1304 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1306 * "An INVALID_OPERATION error is generated if sampler is not the name
1307 * of a sampler object previously returned from a call to GenSamplers."
1309 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1311 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1312 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1313 "glGetSamplerParameteriv(sampler %u)", sampler
);
1318 case GL_TEXTURE_WRAP_S
:
1319 *params
= sampObj
->WrapS
;
1321 case GL_TEXTURE_WRAP_T
:
1322 *params
= sampObj
->WrapT
;
1324 case GL_TEXTURE_WRAP_R
:
1325 *params
= sampObj
->WrapR
;
1327 case GL_TEXTURE_MIN_FILTER
:
1328 *params
= sampObj
->MinFilter
;
1330 case GL_TEXTURE_MAG_FILTER
:
1331 *params
= sampObj
->MagFilter
;
1333 case GL_TEXTURE_MIN_LOD
:
1334 /* GL spec 'Data Conversions' section specifies that floating-point
1335 * value in integer Get function is rounded to nearest integer
1337 *params
= IROUND(sampObj
->MinLod
);
1339 case GL_TEXTURE_MAX_LOD
:
1340 /* GL spec 'Data Conversions' section specifies that floating-point
1341 * value in integer Get function is rounded to nearest integer
1343 *params
= IROUND(sampObj
->MaxLod
);
1345 case GL_TEXTURE_LOD_BIAS
:
1346 /* GL spec 'Data Conversions' section specifies that floating-point
1347 * value in integer Get function is rounded to nearest integer
1349 *params
= IROUND(sampObj
->LodBias
);
1351 case GL_TEXTURE_COMPARE_MODE
:
1352 if (!ctx
->Extensions
.ARB_shadow
)
1354 *params
= sampObj
->CompareMode
;
1356 case GL_TEXTURE_COMPARE_FUNC
:
1357 if (!ctx
->Extensions
.ARB_shadow
)
1359 *params
= sampObj
->CompareFunc
;
1361 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1362 /* GL spec 'Data Conversions' section specifies that floating-point
1363 * value in integer Get function is rounded to nearest integer
1365 *params
= IROUND(sampObj
->MaxAnisotropy
);
1367 case GL_TEXTURE_BORDER_COLOR
:
1368 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1369 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1370 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1371 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1373 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1374 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1376 *params
= sampObj
->CubeMapSeamless
;
1378 case GL_TEXTURE_SRGB_DECODE_EXT
:
1379 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1381 *params
= (GLenum
) sampObj
->sRGBDecode
;
1389 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1390 _mesa_lookup_enum_by_nr(pname
));
1395 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1397 struct gl_sampler_object
*sampObj
;
1398 GET_CURRENT_CONTEXT(ctx
);
1400 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1402 /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states:
1404 * "An INVALID_OPERATION error is generated if sampler is not the name
1405 * of a sampler object previously returned from a call to GenSamplers."
1407 * In desktop GL, an GL_INVALID_VALUE is returned instead.
1409 _mesa_error(ctx
, (_mesa_is_gles(ctx
) ?
1410 GL_INVALID_OPERATION
: GL_INVALID_VALUE
),
1411 "glGetSamplerParameterfv(sampler %u)", sampler
);
1416 case GL_TEXTURE_WRAP_S
:
1417 *params
= (GLfloat
) sampObj
->WrapS
;
1419 case GL_TEXTURE_WRAP_T
:
1420 *params
= (GLfloat
) sampObj
->WrapT
;
1422 case GL_TEXTURE_WRAP_R
:
1423 *params
= (GLfloat
) sampObj
->WrapR
;
1425 case GL_TEXTURE_MIN_FILTER
:
1426 *params
= (GLfloat
) sampObj
->MinFilter
;
1428 case GL_TEXTURE_MAG_FILTER
:
1429 *params
= (GLfloat
) sampObj
->MagFilter
;
1431 case GL_TEXTURE_MIN_LOD
:
1432 *params
= sampObj
->MinLod
;
1434 case GL_TEXTURE_MAX_LOD
:
1435 *params
= sampObj
->MaxLod
;
1437 case GL_TEXTURE_LOD_BIAS
:
1438 *params
= sampObj
->LodBias
;
1440 case GL_TEXTURE_COMPARE_MODE
:
1441 if (!ctx
->Extensions
.ARB_shadow
)
1443 *params
= (GLfloat
) sampObj
->CompareMode
;
1445 case GL_TEXTURE_COMPARE_FUNC
:
1446 if (!ctx
->Extensions
.ARB_shadow
)
1448 *params
= (GLfloat
) sampObj
->CompareFunc
;
1450 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1451 *params
= sampObj
->MaxAnisotropy
;
1453 case GL_TEXTURE_BORDER_COLOR
:
1454 params
[0] = sampObj
->BorderColor
.f
[0];
1455 params
[1] = sampObj
->BorderColor
.f
[1];
1456 params
[2] = sampObj
->BorderColor
.f
[2];
1457 params
[3] = sampObj
->BorderColor
.f
[3];
1459 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1460 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1462 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1464 case GL_TEXTURE_SRGB_DECODE_EXT
:
1465 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1467 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1475 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1476 _mesa_lookup_enum_by_nr(pname
));
1481 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1483 struct gl_sampler_object
*sampObj
;
1484 GET_CURRENT_CONTEXT(ctx
);
1486 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1488 _mesa_error(ctx
, GL_INVALID_VALUE
,
1489 "glGetSamplerParameterIiv(sampler %u)",
1495 case GL_TEXTURE_WRAP_S
:
1496 *params
= sampObj
->WrapS
;
1498 case GL_TEXTURE_WRAP_T
:
1499 *params
= sampObj
->WrapT
;
1501 case GL_TEXTURE_WRAP_R
:
1502 *params
= sampObj
->WrapR
;
1504 case GL_TEXTURE_MIN_FILTER
:
1505 *params
= sampObj
->MinFilter
;
1507 case GL_TEXTURE_MAG_FILTER
:
1508 *params
= sampObj
->MagFilter
;
1510 case GL_TEXTURE_MIN_LOD
:
1511 *params
= (GLint
) sampObj
->MinLod
;
1513 case GL_TEXTURE_MAX_LOD
:
1514 *params
= (GLint
) sampObj
->MaxLod
;
1516 case GL_TEXTURE_LOD_BIAS
:
1517 *params
= (GLint
) sampObj
->LodBias
;
1519 case GL_TEXTURE_COMPARE_MODE
:
1520 if (!ctx
->Extensions
.ARB_shadow
)
1522 *params
= sampObj
->CompareMode
;
1524 case GL_TEXTURE_COMPARE_FUNC
:
1525 if (!ctx
->Extensions
.ARB_shadow
)
1527 *params
= sampObj
->CompareFunc
;
1529 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1530 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1532 case GL_TEXTURE_BORDER_COLOR
:
1533 params
[0] = sampObj
->BorderColor
.i
[0];
1534 params
[1] = sampObj
->BorderColor
.i
[1];
1535 params
[2] = sampObj
->BorderColor
.i
[2];
1536 params
[3] = sampObj
->BorderColor
.i
[3];
1538 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1539 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1541 *params
= sampObj
->CubeMapSeamless
;
1543 case GL_TEXTURE_SRGB_DECODE_EXT
:
1544 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1546 *params
= (GLenum
) sampObj
->sRGBDecode
;
1554 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1555 _mesa_lookup_enum_by_nr(pname
));
1560 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1562 struct gl_sampler_object
*sampObj
;
1563 GET_CURRENT_CONTEXT(ctx
);
1565 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
1567 _mesa_error(ctx
, GL_INVALID_VALUE
,
1568 "glGetSamplerParameterIuiv(sampler %u)",
1574 case GL_TEXTURE_WRAP_S
:
1575 *params
= sampObj
->WrapS
;
1577 case GL_TEXTURE_WRAP_T
:
1578 *params
= sampObj
->WrapT
;
1580 case GL_TEXTURE_WRAP_R
:
1581 *params
= sampObj
->WrapR
;
1583 case GL_TEXTURE_MIN_FILTER
:
1584 *params
= sampObj
->MinFilter
;
1586 case GL_TEXTURE_MAG_FILTER
:
1587 *params
= sampObj
->MagFilter
;
1589 case GL_TEXTURE_MIN_LOD
:
1590 *params
= (GLuint
) sampObj
->MinLod
;
1592 case GL_TEXTURE_MAX_LOD
:
1593 *params
= (GLuint
) sampObj
->MaxLod
;
1595 case GL_TEXTURE_LOD_BIAS
:
1596 *params
= (GLuint
) sampObj
->LodBias
;
1598 case GL_TEXTURE_COMPARE_MODE
:
1599 if (!ctx
->Extensions
.ARB_shadow
)
1601 *params
= sampObj
->CompareMode
;
1603 case GL_TEXTURE_COMPARE_FUNC
:
1604 if (!ctx
->Extensions
.ARB_shadow
)
1606 *params
= sampObj
->CompareFunc
;
1608 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1609 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1611 case GL_TEXTURE_BORDER_COLOR
:
1612 params
[0] = sampObj
->BorderColor
.ui
[0];
1613 params
[1] = sampObj
->BorderColor
.ui
[1];
1614 params
[2] = sampObj
->BorderColor
.ui
[2];
1615 params
[3] = sampObj
->BorderColor
.ui
[3];
1617 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1618 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1620 *params
= sampObj
->CubeMapSeamless
;
1622 case GL_TEXTURE_SRGB_DECODE_EXT
:
1623 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1625 *params
= (GLenum
) sampObj
->sRGBDecode
;
1633 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1634 _mesa_lookup_enum_by_nr(pname
));
1639 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1641 driver
->NewSamplerObject
= _mesa_new_sampler_object
;
1642 driver
->DeleteSamplerObject
= _mesa_delete_sampler_object
;