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/enums.h"
36 #include "main/hash.h"
37 #include "main/macros.h"
38 #include "main/mtypes.h"
39 #include "main/samplerobj.h"
40 #include "main/texturebindless.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
);
53 static inline struct gl_sampler_object
*
54 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
56 return (struct gl_sampler_object
*)
57 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
61 delete_sampler_object(struct gl_context
*ctx
,
62 struct gl_sampler_object
*sampObj
)
64 _mesa_delete_sampler_handles(ctx
, sampObj
);
65 simple_mtx_destroy(&sampObj
->Mutex
);
71 * Handle reference counting.
74 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
75 struct gl_sampler_object
**ptr
,
76 struct gl_sampler_object
*samp
)
78 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
81 /* Unreference the old sampler */
82 GLboolean deleteFlag
= GL_FALSE
;
83 struct gl_sampler_object
*oldSamp
= *ptr
;
85 simple_mtx_lock(&oldSamp
->Mutex
);
86 assert(oldSamp
->RefCount
> 0);
88 deleteFlag
= (oldSamp
->RefCount
== 0);
89 simple_mtx_unlock(&oldSamp
->Mutex
);
92 delete_sampler_object(ctx
, oldSamp
);
99 /* reference new sampler */
100 simple_mtx_lock(&samp
->Mutex
);
101 assert(samp
->RefCount
> 0);
105 simple_mtx_unlock(&samp
->Mutex
);
111 * Initialize the fields of the given sampler object.
114 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
116 simple_mtx_init(&sampObj
->Mutex
, mtx_plain
);
117 sampObj
->Name
= name
;
118 sampObj
->RefCount
= 1;
119 sampObj
->WrapS
= GL_REPEAT
;
120 sampObj
->WrapT
= GL_REPEAT
;
121 sampObj
->WrapR
= GL_REPEAT
;
122 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
123 sampObj
->MagFilter
= GL_LINEAR
;
124 sampObj
->BorderColor
.f
[0] = 0.0;
125 sampObj
->BorderColor
.f
[1] = 0.0;
126 sampObj
->BorderColor
.f
[2] = 0.0;
127 sampObj
->BorderColor
.f
[3] = 0.0;
128 sampObj
->MinLod
= -1000.0F
;
129 sampObj
->MaxLod
= 1000.0F
;
130 sampObj
->LodBias
= 0.0F
;
131 sampObj
->MaxAnisotropy
= 1.0F
;
132 sampObj
->CompareMode
= GL_NONE
;
133 sampObj
->CompareFunc
= GL_LEQUAL
;
134 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
135 sampObj
->CubeMapSeamless
= GL_FALSE
;
136 sampObj
->HandleAllocated
= GL_FALSE
;
138 /* GL_ARB_bindless_texture */
139 _mesa_init_sampler_handles(sampObj
);
143 * Fallback for ctx->Driver.NewSamplerObject();
145 struct gl_sampler_object
*
146 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
148 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
150 _mesa_init_sampler_object(sampObj
, name
);
156 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
165 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
167 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
169 /* Insert the ID and pointer to new sampler object into hash table */
170 for (i
= 0; i
< count
; i
++) {
171 struct gl_sampler_object
*sampObj
;
172 GLuint name
= first
+ i
;
174 sampObj
= ctx
->Driver
.NewSamplerObject(ctx
, name
);
176 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
177 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
181 _mesa_HashInsertLocked(ctx
->Shared
->SamplerObjects
, name
, sampObj
);
185 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
189 create_samplers_err(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
193 if (MESA_VERBOSE
& VERBOSE_API
)
194 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
197 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
201 create_samplers(ctx
, count
, samplers
, caller
);
205 _mesa_GenSamplers_no_error(GLsizei count
, GLuint
*samplers
)
207 GET_CURRENT_CONTEXT(ctx
);
208 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
212 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
214 GET_CURRENT_CONTEXT(ctx
);
215 create_samplers_err(ctx
, count
, samplers
, "glGenSamplers");
219 _mesa_CreateSamplers_no_error(GLsizei count
, GLuint
*samplers
)
221 GET_CURRENT_CONTEXT(ctx
);
222 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
226 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
228 GET_CURRENT_CONTEXT(ctx
);
229 create_samplers_err(ctx
, count
, samplers
, "glCreateSamplers");
234 delete_samplers(struct gl_context
*ctx
, GLsizei count
, const GLuint
*samplers
)
236 FLUSH_VERTICES(ctx
, 0);
238 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
240 for (GLsizei i
= 0; i
< count
; i
++) {
243 struct gl_sampler_object
*sampObj
=
244 lookup_samplerobj_locked(ctx
, samplers
[i
]);
247 /* If the sampler is currently bound, unbind it. */
248 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
249 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
250 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
251 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
255 /* The ID is immediately freed for re-use */
256 _mesa_HashRemoveLocked(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
257 /* But the object exists until its reference count goes to zero */
258 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
263 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
268 _mesa_DeleteSamplers_no_error(GLsizei count
, const GLuint
*samplers
)
270 GET_CURRENT_CONTEXT(ctx
);
271 delete_samplers(ctx
, count
, samplers
);
276 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
278 GET_CURRENT_CONTEXT(ctx
);
281 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
285 delete_samplers(ctx
, count
, samplers
);
290 _mesa_IsSampler(GLuint sampler
)
292 GET_CURRENT_CONTEXT(ctx
);
294 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
296 return _mesa_lookup_samplerobj(ctx
, sampler
) != NULL
;
300 _mesa_bind_sampler(struct gl_context
*ctx
, GLuint unit
,
301 struct gl_sampler_object
*sampObj
)
303 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
304 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
307 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
311 static ALWAYS_INLINE
void
312 bind_sampler(struct gl_context
*ctx
, GLuint unit
, GLuint sampler
, bool no_error
)
314 struct gl_sampler_object
*sampObj
;
317 /* Use the default sampler object, the one contained in the texture
322 /* user-defined sampler object */
323 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
324 if (!no_error
&& !sampObj
) {
325 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
330 /* bind new sampler */
331 _mesa_bind_sampler(ctx
, unit
, sampObj
);
335 _mesa_BindSampler_no_error(GLuint unit
, GLuint sampler
)
337 GET_CURRENT_CONTEXT(ctx
);
338 bind_sampler(ctx
, unit
, sampler
, true);
342 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
344 GET_CURRENT_CONTEXT(ctx
);
346 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
347 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
351 bind_sampler(ctx
, unit
, sampler
, false);
355 static ALWAYS_INLINE
void
356 bind_samplers(struct gl_context
*ctx
, GLuint first
, GLsizei count
,
357 const GLuint
*samplers
, bool no_error
)
361 FLUSH_VERTICES(ctx
, 0);
364 /* Note that the error semantics for multi-bind commands differ from
365 * those of other GL commands.
367 * The Issues section in the ARB_multi_bind spec says:
369 * "(11) Typically, OpenGL specifies that if an error is generated by
370 * a command, that command has no effect. This is somewhat
371 * unfortunate for multi-bind commands, because it would require
372 * a first pass to scan the entire list of bound objects for
373 * errors and then a second pass to actually perform the
374 * bindings. Should we have different error semantics?
376 * RESOLVED: Yes. In this specification, when the parameters for
377 * one of the <count> binding points are invalid, that binding
378 * point is not updated and an error will be generated. However,
379 * other binding points in the same command will be updated if
380 * their parameters are valid and no other error occurs."
383 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
385 for (i
= 0; i
< count
; i
++) {
386 const GLuint unit
= first
+ i
;
387 struct gl_sampler_object
* const currentSampler
=
388 ctx
->Texture
.Unit
[unit
].Sampler
;
389 struct gl_sampler_object
*sampObj
;
391 if (samplers
[i
] != 0) {
392 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
393 sampObj
= currentSampler
;
395 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
397 /* The ARB_multi_bind spec says:
399 * "An INVALID_OPERATION error is generated if any value
400 * in <samplers> is not zero or the name of an existing
401 * sampler object (per binding)."
403 if (!no_error
&& !sampObj
) {
404 _mesa_error(ctx
, GL_INVALID_OPERATION
,
405 "glBindSamplers(samplers[%d]=%u is not zero or "
406 "the name of an existing sampler object)",
414 /* Bind the new sampler */
415 if (sampObj
!= currentSampler
) {
416 _mesa_reference_sampler_object(ctx
,
417 &ctx
->Texture
.Unit
[unit
].Sampler
,
419 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
423 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
425 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
426 for (i
= 0; i
< count
; i
++) {
427 const GLuint unit
= first
+ i
;
429 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
430 _mesa_reference_sampler_object(ctx
,
431 &ctx
->Texture
.Unit
[unit
].Sampler
,
433 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
441 _mesa_BindSamplers_no_error(GLuint first
, GLsizei count
, const GLuint
*samplers
)
443 GET_CURRENT_CONTEXT(ctx
);
444 bind_samplers(ctx
, first
, count
, samplers
, true);
449 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
451 GET_CURRENT_CONTEXT(ctx
);
453 /* The ARB_multi_bind spec says:
455 * "An INVALID_OPERATION error is generated if <first> + <count> is
456 * greater than the number of texture image units supported by
457 * the implementation."
459 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
460 _mesa_error(ctx
, GL_INVALID_OPERATION
,
461 "glBindSamplers(first=%u + count=%d > the value of "
462 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
463 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
467 bind_samplers(ctx
, first
, count
, samplers
, false);
472 * Check if a coordinate wrap mode is legal.
473 * \return GL_TRUE if legal, GL_FALSE otherwise
476 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
478 const struct gl_extensions
* const e
= &ctx
->Extensions
;
482 case GL_CLAMP_TO_EDGE
:
484 case GL_MIRRORED_REPEAT
:
486 case GL_CLAMP_TO_BORDER
:
487 return e
->ARB_texture_border_clamp
;
488 case GL_MIRROR_CLAMP_EXT
:
489 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
490 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
491 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
492 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
493 return e
->EXT_texture_mirror_clamp
;
501 * This is called just prior to changing any sampler object state.
504 flush(struct gl_context
*ctx
)
506 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
510 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
511 GLenum s
, GLenum t
, GLenum r
)
513 assert(validate_texture_wrap_mode(ctx
, s
));
514 assert(validate_texture_wrap_mode(ctx
, t
));
515 assert(validate_texture_wrap_mode(ctx
, r
));
517 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
526 #define INVALID_PARAM 0x100
527 #define INVALID_PNAME 0x101
528 #define INVALID_VALUE 0x102
531 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
534 if (samp
->WrapS
== param
)
536 if (validate_texture_wrap_mode(ctx
, param
)) {
541 return INVALID_PARAM
;
546 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
549 if (samp
->WrapT
== param
)
551 if (validate_texture_wrap_mode(ctx
, param
)) {
556 return INVALID_PARAM
;
561 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
564 if (samp
->WrapR
== param
)
566 if (validate_texture_wrap_mode(ctx
, param
)) {
571 return INVALID_PARAM
;
575 _mesa_set_sampler_filters(struct gl_context
*ctx
,
576 struct gl_sampler_object
*samp
,
577 GLenum min_filter
, GLenum mag_filter
)
579 assert(min_filter
== GL_NEAREST
||
580 min_filter
== GL_LINEAR
||
581 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
582 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
583 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
584 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
585 assert(mag_filter
== GL_NEAREST
||
586 mag_filter
== GL_LINEAR
);
588 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
592 samp
->MinFilter
= min_filter
;
593 samp
->MagFilter
= mag_filter
;
597 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
600 if (samp
->MinFilter
== param
)
606 case GL_NEAREST_MIPMAP_NEAREST
:
607 case GL_LINEAR_MIPMAP_NEAREST
:
608 case GL_NEAREST_MIPMAP_LINEAR
:
609 case GL_LINEAR_MIPMAP_LINEAR
:
611 samp
->MinFilter
= param
;
614 return INVALID_PARAM
;
620 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
623 if (samp
->MagFilter
== param
)
630 samp
->MagFilter
= param
;
633 return INVALID_PARAM
;
639 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
642 if (samp
->LodBias
== param
)
646 samp
->LodBias
= param
;
652 set_sampler_border_colorf(struct gl_context
*ctx
,
653 struct gl_sampler_object
*samp
,
654 const GLfloat params
[4])
657 samp
->BorderColor
.f
[RCOMP
] = params
[0];
658 samp
->BorderColor
.f
[GCOMP
] = params
[1];
659 samp
->BorderColor
.f
[BCOMP
] = params
[2];
660 samp
->BorderColor
.f
[ACOMP
] = params
[3];
666 set_sampler_border_colori(struct gl_context
*ctx
,
667 struct gl_sampler_object
*samp
,
668 const GLint params
[4])
671 samp
->BorderColor
.i
[RCOMP
] = params
[0];
672 samp
->BorderColor
.i
[GCOMP
] = params
[1];
673 samp
->BorderColor
.i
[BCOMP
] = params
[2];
674 samp
->BorderColor
.i
[ACOMP
] = params
[3];
680 set_sampler_border_colorui(struct gl_context
*ctx
,
681 struct gl_sampler_object
*samp
,
682 const GLuint params
[4])
685 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
686 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
687 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
688 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
694 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
697 if (samp
->MinLod
== param
)
701 samp
->MinLod
= param
;
707 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
710 if (samp
->MaxLod
== param
)
714 samp
->MaxLod
= param
;
720 set_sampler_compare_mode(struct gl_context
*ctx
,
721 struct gl_sampler_object
*samp
, GLint param
)
723 /* If GL_ARB_shadow is not supported, don't report an error. The
724 * sampler object extension spec isn't clear on this extension interaction.
725 * Silences errors with Wine on older GPUs such as R200.
727 if (!ctx
->Extensions
.ARB_shadow
)
730 if (samp
->CompareMode
== param
)
733 if (param
== GL_NONE
||
734 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
736 samp
->CompareMode
= param
;
740 return INVALID_PARAM
;
745 set_sampler_compare_func(struct gl_context
*ctx
,
746 struct gl_sampler_object
*samp
, GLint param
)
748 /* If GL_ARB_shadow is not supported, don't report an error. The
749 * sampler object extension spec isn't clear on this extension interaction.
750 * Silences errors with Wine on older GPUs such as R200.
752 if (!ctx
->Extensions
.ARB_shadow
)
755 if (samp
->CompareFunc
== param
)
768 samp
->CompareFunc
= param
;
771 return INVALID_PARAM
;
777 set_sampler_max_anisotropy(struct gl_context
*ctx
,
778 struct gl_sampler_object
*samp
, GLfloat param
)
780 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
781 return INVALID_PNAME
;
783 if (samp
->MaxAnisotropy
== param
)
787 return INVALID_VALUE
;
790 /* clamp to max, that's what NVIDIA does */
791 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
797 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
798 struct gl_sampler_object
*samp
, GLboolean param
)
800 if (!_mesa_is_desktop_gl(ctx
)
801 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
802 return INVALID_PNAME
;
804 if (samp
->CubeMapSeamless
== param
)
807 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
808 return INVALID_VALUE
;
811 samp
->CubeMapSeamless
= param
;
816 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
817 struct gl_sampler_object
*samp
, GLenum param
)
819 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
822 samp
->sRGBDecode
= param
;
826 set_sampler_srgb_decode(struct gl_context
*ctx
,
827 struct gl_sampler_object
*samp
, GLenum param
)
829 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
830 return INVALID_PNAME
;
832 if (samp
->sRGBDecode
== param
)
835 /* The EXT_texture_sRGB_decode spec says:
837 * "INVALID_ENUM is generated if the <pname> parameter of
838 * TexParameter[i,f,Ii,Iui][v][EXT],
839 * MultiTexParameter[i,f,Ii,Iui][v]EXT,
840 * TextureParameter[i,f,Ii,Iui][v]EXT, SamplerParameter[i,f,Ii,Iui][v]
841 * is TEXTURE_SRGB_DECODE_EXT when the <param> parameter is not one of
842 * DECODE_EXT or SKIP_DECODE_EXT.
844 * Returning INVALID_PARAM makes that happen.
846 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
847 return INVALID_PARAM
;
850 samp
->sRGBDecode
= param
;
854 static struct gl_sampler_object
*
855 sampler_parameter_error_check(struct gl_context
*ctx
, GLuint sampler
,
856 bool get
, const char *name
)
858 struct gl_sampler_object
*sampObj
;
860 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
862 /* OpenGL 4.5 spec, section "8.2 Sampler Objects", page 176 of the PDF
865 * "An INVALID_OPERATION error is generated if sampler is not the name
866 * of a sampler object previously returned from a call to
869 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(invalid sampler)", name
);
873 if (!get
&& sampObj
->HandleAllocated
) {
874 /* The ARB_bindless_texture spec says:
876 * "The error INVALID_OPERATION is generated by SamplerParameter* if
877 * <sampler> identifies a sampler object referenced by one or more
880 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(immutable sampler)", name
);
888 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
890 struct gl_sampler_object
*sampObj
;
892 GET_CURRENT_CONTEXT(ctx
);
894 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
895 "glSamplerParameteri");
900 case GL_TEXTURE_WRAP_S
:
901 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
903 case GL_TEXTURE_WRAP_T
:
904 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
906 case GL_TEXTURE_WRAP_R
:
907 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
909 case GL_TEXTURE_MIN_FILTER
:
910 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
912 case GL_TEXTURE_MAG_FILTER
:
913 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
915 case GL_TEXTURE_MIN_LOD
:
916 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
918 case GL_TEXTURE_MAX_LOD
:
919 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
921 case GL_TEXTURE_LOD_BIAS
:
922 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
924 case GL_TEXTURE_COMPARE_MODE
:
925 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
927 case GL_TEXTURE_COMPARE_FUNC
:
928 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
930 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
931 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
933 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
934 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
936 case GL_TEXTURE_SRGB_DECODE_EXT
:
937 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
939 case GL_TEXTURE_BORDER_COLOR
:
950 /* state change - we do nothing special at this time */
953 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
954 _mesa_enum_to_string(pname
));
957 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
961 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
971 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
973 struct gl_sampler_object
*sampObj
;
975 GET_CURRENT_CONTEXT(ctx
);
977 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
978 "glSamplerParameterf");
983 case GL_TEXTURE_WRAP_S
:
984 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
986 case GL_TEXTURE_WRAP_T
:
987 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
989 case GL_TEXTURE_WRAP_R
:
990 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
992 case GL_TEXTURE_MIN_FILTER
:
993 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
995 case GL_TEXTURE_MAG_FILTER
:
996 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
998 case GL_TEXTURE_MIN_LOD
:
999 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
1001 case GL_TEXTURE_MAX_LOD
:
1002 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
1004 case GL_TEXTURE_LOD_BIAS
:
1005 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
1007 case GL_TEXTURE_COMPARE_MODE
:
1008 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
1010 case GL_TEXTURE_COMPARE_FUNC
:
1011 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
1013 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1014 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
1016 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1017 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
1019 case GL_TEXTURE_SRGB_DECODE_EXT
:
1020 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
1022 case GL_TEXTURE_BORDER_COLOR
:
1025 res
= INVALID_PNAME
;
1033 /* state change - we do nothing special at this time */
1036 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
1037 _mesa_enum_to_string(pname
));
1040 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
1044 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
1053 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1055 struct gl_sampler_object
*sampObj
;
1057 GET_CURRENT_CONTEXT(ctx
);
1059 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1060 "glSamplerParameteriv");
1065 case GL_TEXTURE_WRAP_S
:
1066 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1068 case GL_TEXTURE_WRAP_T
:
1069 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1071 case GL_TEXTURE_WRAP_R
:
1072 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1074 case GL_TEXTURE_MIN_FILTER
:
1075 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1077 case GL_TEXTURE_MAG_FILTER
:
1078 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1080 case GL_TEXTURE_MIN_LOD
:
1081 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1083 case GL_TEXTURE_MAX_LOD
:
1084 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1086 case GL_TEXTURE_LOD_BIAS
:
1087 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1089 case GL_TEXTURE_COMPARE_MODE
:
1090 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1092 case GL_TEXTURE_COMPARE_FUNC
:
1093 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1095 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1096 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1098 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1099 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1101 case GL_TEXTURE_SRGB_DECODE_EXT
:
1102 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1104 case GL_TEXTURE_BORDER_COLOR
:
1107 c
[0] = INT_TO_FLOAT(params
[0]);
1108 c
[1] = INT_TO_FLOAT(params
[1]);
1109 c
[2] = INT_TO_FLOAT(params
[2]);
1110 c
[3] = INT_TO_FLOAT(params
[3]);
1111 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1115 res
= INVALID_PNAME
;
1123 /* state change - we do nothing special at this time */
1126 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1127 _mesa_enum_to_string(pname
));
1130 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1134 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1143 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1145 struct gl_sampler_object
*sampObj
;
1147 GET_CURRENT_CONTEXT(ctx
);
1149 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1150 "glSamplerParameterfv");
1155 case GL_TEXTURE_WRAP_S
:
1156 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1158 case GL_TEXTURE_WRAP_T
:
1159 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1161 case GL_TEXTURE_WRAP_R
:
1162 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1164 case GL_TEXTURE_MIN_FILTER
:
1165 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1167 case GL_TEXTURE_MAG_FILTER
:
1168 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1170 case GL_TEXTURE_MIN_LOD
:
1171 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1173 case GL_TEXTURE_MAX_LOD
:
1174 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1176 case GL_TEXTURE_LOD_BIAS
:
1177 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1179 case GL_TEXTURE_COMPARE_MODE
:
1180 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1182 case GL_TEXTURE_COMPARE_FUNC
:
1183 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1185 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1186 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1188 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1189 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1191 case GL_TEXTURE_SRGB_DECODE_EXT
:
1192 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1194 case GL_TEXTURE_BORDER_COLOR
:
1195 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1198 res
= INVALID_PNAME
;
1206 /* state change - we do nothing special at this time */
1209 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1210 _mesa_enum_to_string(pname
));
1213 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1217 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1226 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1228 struct gl_sampler_object
*sampObj
;
1230 GET_CURRENT_CONTEXT(ctx
);
1232 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1233 "glSamplerParameterIiv");
1238 case GL_TEXTURE_WRAP_S
:
1239 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1241 case GL_TEXTURE_WRAP_T
:
1242 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1244 case GL_TEXTURE_WRAP_R
:
1245 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1247 case GL_TEXTURE_MIN_FILTER
:
1248 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1250 case GL_TEXTURE_MAG_FILTER
:
1251 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1253 case GL_TEXTURE_MIN_LOD
:
1254 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1256 case GL_TEXTURE_MAX_LOD
:
1257 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1259 case GL_TEXTURE_LOD_BIAS
:
1260 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1262 case GL_TEXTURE_COMPARE_MODE
:
1263 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1265 case GL_TEXTURE_COMPARE_FUNC
:
1266 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1268 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1269 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1271 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1272 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1274 case GL_TEXTURE_SRGB_DECODE_EXT
:
1275 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1277 case GL_TEXTURE_BORDER_COLOR
:
1278 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1281 res
= INVALID_PNAME
;
1289 /* state change - we do nothing special at this time */
1292 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1293 _mesa_enum_to_string(pname
));
1296 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1300 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1310 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1312 struct gl_sampler_object
*sampObj
;
1314 GET_CURRENT_CONTEXT(ctx
);
1316 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1317 "glSamplerParameterIuiv");
1322 case GL_TEXTURE_WRAP_S
:
1323 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1325 case GL_TEXTURE_WRAP_T
:
1326 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1328 case GL_TEXTURE_WRAP_R
:
1329 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1331 case GL_TEXTURE_MIN_FILTER
:
1332 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1334 case GL_TEXTURE_MAG_FILTER
:
1335 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1337 case GL_TEXTURE_MIN_LOD
:
1338 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1340 case GL_TEXTURE_MAX_LOD
:
1341 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1343 case GL_TEXTURE_LOD_BIAS
:
1344 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1346 case GL_TEXTURE_COMPARE_MODE
:
1347 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1349 case GL_TEXTURE_COMPARE_FUNC
:
1350 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1352 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1353 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1355 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1356 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1358 case GL_TEXTURE_SRGB_DECODE_EXT
:
1359 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1361 case GL_TEXTURE_BORDER_COLOR
:
1362 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1365 res
= INVALID_PNAME
;
1373 /* state change - we do nothing special at this time */
1376 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1377 _mesa_enum_to_string(pname
));
1380 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1384 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1394 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1396 struct gl_sampler_object
*sampObj
;
1397 GET_CURRENT_CONTEXT(ctx
);
1399 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1400 "glGetSamplerParameteriv");
1405 case GL_TEXTURE_WRAP_S
:
1406 *params
= sampObj
->WrapS
;
1408 case GL_TEXTURE_WRAP_T
:
1409 *params
= sampObj
->WrapT
;
1411 case GL_TEXTURE_WRAP_R
:
1412 *params
= sampObj
->WrapR
;
1414 case GL_TEXTURE_MIN_FILTER
:
1415 *params
= sampObj
->MinFilter
;
1417 case GL_TEXTURE_MAG_FILTER
:
1418 *params
= sampObj
->MagFilter
;
1420 case GL_TEXTURE_MIN_LOD
:
1421 /* GL spec 'Data Conversions' section specifies that floating-point
1422 * value in integer Get function is rounded to nearest integer
1424 *params
= IROUND(sampObj
->MinLod
);
1426 case GL_TEXTURE_MAX_LOD
:
1427 /* GL spec 'Data Conversions' section specifies that floating-point
1428 * value in integer Get function is rounded to nearest integer
1430 *params
= IROUND(sampObj
->MaxLod
);
1432 case GL_TEXTURE_LOD_BIAS
:
1433 /* GL spec 'Data Conversions' section specifies that floating-point
1434 * value in integer Get function is rounded to nearest integer
1436 *params
= IROUND(sampObj
->LodBias
);
1438 case GL_TEXTURE_COMPARE_MODE
:
1439 *params
= sampObj
->CompareMode
;
1441 case GL_TEXTURE_COMPARE_FUNC
:
1442 *params
= sampObj
->CompareFunc
;
1444 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1445 /* GL spec 'Data Conversions' section specifies that floating-point
1446 * value in integer Get function is rounded to nearest integer
1448 *params
= IROUND(sampObj
->MaxAnisotropy
);
1450 case GL_TEXTURE_BORDER_COLOR
:
1451 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1452 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1453 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1454 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1456 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1457 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1459 *params
= sampObj
->CubeMapSeamless
;
1461 case GL_TEXTURE_SRGB_DECODE_EXT
:
1462 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1464 *params
= (GLenum
) sampObj
->sRGBDecode
;
1472 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1473 _mesa_enum_to_string(pname
));
1478 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1480 struct gl_sampler_object
*sampObj
;
1481 GET_CURRENT_CONTEXT(ctx
);
1483 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1484 "glGetSamplerParameterfv");
1489 case GL_TEXTURE_WRAP_S
:
1490 *params
= (GLfloat
) sampObj
->WrapS
;
1492 case GL_TEXTURE_WRAP_T
:
1493 *params
= (GLfloat
) sampObj
->WrapT
;
1495 case GL_TEXTURE_WRAP_R
:
1496 *params
= (GLfloat
) sampObj
->WrapR
;
1498 case GL_TEXTURE_MIN_FILTER
:
1499 *params
= (GLfloat
) sampObj
->MinFilter
;
1501 case GL_TEXTURE_MAG_FILTER
:
1502 *params
= (GLfloat
) sampObj
->MagFilter
;
1504 case GL_TEXTURE_MIN_LOD
:
1505 *params
= sampObj
->MinLod
;
1507 case GL_TEXTURE_MAX_LOD
:
1508 *params
= sampObj
->MaxLod
;
1510 case GL_TEXTURE_LOD_BIAS
:
1511 *params
= sampObj
->LodBias
;
1513 case GL_TEXTURE_COMPARE_MODE
:
1514 *params
= (GLfloat
) sampObj
->CompareMode
;
1516 case GL_TEXTURE_COMPARE_FUNC
:
1517 *params
= (GLfloat
) sampObj
->CompareFunc
;
1519 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1520 *params
= sampObj
->MaxAnisotropy
;
1522 case GL_TEXTURE_BORDER_COLOR
:
1523 params
[0] = sampObj
->BorderColor
.f
[0];
1524 params
[1] = sampObj
->BorderColor
.f
[1];
1525 params
[2] = sampObj
->BorderColor
.f
[2];
1526 params
[3] = sampObj
->BorderColor
.f
[3];
1528 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1529 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1531 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1533 case GL_TEXTURE_SRGB_DECODE_EXT
:
1534 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1536 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1544 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1545 _mesa_enum_to_string(pname
));
1550 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1552 struct gl_sampler_object
*sampObj
;
1553 GET_CURRENT_CONTEXT(ctx
);
1555 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1556 "glGetSamplerParameterIiv");
1561 case GL_TEXTURE_WRAP_S
:
1562 *params
= sampObj
->WrapS
;
1564 case GL_TEXTURE_WRAP_T
:
1565 *params
= sampObj
->WrapT
;
1567 case GL_TEXTURE_WRAP_R
:
1568 *params
= sampObj
->WrapR
;
1570 case GL_TEXTURE_MIN_FILTER
:
1571 *params
= sampObj
->MinFilter
;
1573 case GL_TEXTURE_MAG_FILTER
:
1574 *params
= sampObj
->MagFilter
;
1576 case GL_TEXTURE_MIN_LOD
:
1577 *params
= (GLint
) sampObj
->MinLod
;
1579 case GL_TEXTURE_MAX_LOD
:
1580 *params
= (GLint
) sampObj
->MaxLod
;
1582 case GL_TEXTURE_LOD_BIAS
:
1583 *params
= (GLint
) sampObj
->LodBias
;
1585 case GL_TEXTURE_COMPARE_MODE
:
1586 *params
= sampObj
->CompareMode
;
1588 case GL_TEXTURE_COMPARE_FUNC
:
1589 *params
= sampObj
->CompareFunc
;
1591 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1592 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1594 case GL_TEXTURE_BORDER_COLOR
:
1595 params
[0] = sampObj
->BorderColor
.i
[0];
1596 params
[1] = sampObj
->BorderColor
.i
[1];
1597 params
[2] = sampObj
->BorderColor
.i
[2];
1598 params
[3] = sampObj
->BorderColor
.i
[3];
1600 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1601 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1603 *params
= sampObj
->CubeMapSeamless
;
1605 case GL_TEXTURE_SRGB_DECODE_EXT
:
1606 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1608 *params
= (GLenum
) sampObj
->sRGBDecode
;
1616 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1617 _mesa_enum_to_string(pname
));
1622 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1624 struct gl_sampler_object
*sampObj
;
1625 GET_CURRENT_CONTEXT(ctx
);
1627 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1628 "glGetSamplerParameterIuiv");
1633 case GL_TEXTURE_WRAP_S
:
1634 *params
= sampObj
->WrapS
;
1636 case GL_TEXTURE_WRAP_T
:
1637 *params
= sampObj
->WrapT
;
1639 case GL_TEXTURE_WRAP_R
:
1640 *params
= sampObj
->WrapR
;
1642 case GL_TEXTURE_MIN_FILTER
:
1643 *params
= sampObj
->MinFilter
;
1645 case GL_TEXTURE_MAG_FILTER
:
1646 *params
= sampObj
->MagFilter
;
1648 case GL_TEXTURE_MIN_LOD
:
1649 *params
= (GLuint
) sampObj
->MinLod
;
1651 case GL_TEXTURE_MAX_LOD
:
1652 *params
= (GLuint
) sampObj
->MaxLod
;
1654 case GL_TEXTURE_LOD_BIAS
:
1655 *params
= (GLuint
) sampObj
->LodBias
;
1657 case GL_TEXTURE_COMPARE_MODE
:
1658 *params
= sampObj
->CompareMode
;
1660 case GL_TEXTURE_COMPARE_FUNC
:
1661 *params
= sampObj
->CompareFunc
;
1663 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1664 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1666 case GL_TEXTURE_BORDER_COLOR
:
1667 params
[0] = sampObj
->BorderColor
.ui
[0];
1668 params
[1] = sampObj
->BorderColor
.ui
[1];
1669 params
[2] = sampObj
->BorderColor
.ui
[2];
1670 params
[3] = sampObj
->BorderColor
.ui
[3];
1672 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1673 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1675 *params
= sampObj
->CubeMapSeamless
;
1677 case GL_TEXTURE_SRGB_DECODE_EXT
:
1678 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1680 *params
= (GLenum
) sampObj
->sRGBDecode
;
1688 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1689 _mesa_enum_to_string(pname
));
1694 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1696 driver
->NewSamplerObject
= _mesa_new_sampler_object
;