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"
41 #include "main/texturebindless.h"
44 struct gl_sampler_object
*
45 _mesa_lookup_samplerobj(struct gl_context
*ctx
, GLuint name
)
50 return (struct gl_sampler_object
*)
51 _mesa_HashLookup(ctx
->Shared
->SamplerObjects
, name
);
54 static inline struct gl_sampler_object
*
55 lookup_samplerobj_locked(struct gl_context
*ctx
, GLuint name
)
57 return (struct gl_sampler_object
*)
58 _mesa_HashLookupLocked(ctx
->Shared
->SamplerObjects
, name
);
62 delete_sampler_object(struct gl_context
*ctx
,
63 struct gl_sampler_object
*sampObj
)
65 _mesa_delete_sampler_handles(ctx
, sampObj
);
66 simple_mtx_destroy(&sampObj
->Mutex
);
72 * Handle reference counting.
75 _mesa_reference_sampler_object_(struct gl_context
*ctx
,
76 struct gl_sampler_object
**ptr
,
77 struct gl_sampler_object
*samp
)
79 assert(*ptr
!= samp
); /* The inline wrapper should prevent no-op calls */
82 /* Unreference the old sampler */
83 GLboolean deleteFlag
= GL_FALSE
;
84 struct gl_sampler_object
*oldSamp
= *ptr
;
86 simple_mtx_lock(&oldSamp
->Mutex
);
87 assert(oldSamp
->RefCount
> 0);
89 deleteFlag
= (oldSamp
->RefCount
== 0);
90 simple_mtx_unlock(&oldSamp
->Mutex
);
93 delete_sampler_object(ctx
, oldSamp
);
100 /* reference new sampler */
101 simple_mtx_lock(&samp
->Mutex
);
102 assert(samp
->RefCount
> 0);
106 simple_mtx_unlock(&samp
->Mutex
);
112 * Initialize the fields of the given sampler object.
115 _mesa_init_sampler_object(struct gl_sampler_object
*sampObj
, GLuint name
)
117 simple_mtx_init(&sampObj
->Mutex
, mtx_plain
);
118 sampObj
->Name
= name
;
119 sampObj
->RefCount
= 1;
120 sampObj
->WrapS
= GL_REPEAT
;
121 sampObj
->WrapT
= GL_REPEAT
;
122 sampObj
->WrapR
= GL_REPEAT
;
123 sampObj
->MinFilter
= GL_NEAREST_MIPMAP_LINEAR
;
124 sampObj
->MagFilter
= GL_LINEAR
;
125 sampObj
->BorderColor
.f
[0] = 0.0;
126 sampObj
->BorderColor
.f
[1] = 0.0;
127 sampObj
->BorderColor
.f
[2] = 0.0;
128 sampObj
->BorderColor
.f
[3] = 0.0;
129 sampObj
->MinLod
= -1000.0F
;
130 sampObj
->MaxLod
= 1000.0F
;
131 sampObj
->LodBias
= 0.0F
;
132 sampObj
->MaxAnisotropy
= 1.0F
;
133 sampObj
->CompareMode
= GL_NONE
;
134 sampObj
->CompareFunc
= GL_LEQUAL
;
135 sampObj
->sRGBDecode
= GL_DECODE_EXT
;
136 sampObj
->CubeMapSeamless
= GL_FALSE
;
137 sampObj
->HandleAllocated
= GL_FALSE
;
139 /* GL_ARB_bindless_texture */
140 _mesa_init_sampler_handles(sampObj
);
144 * Fallback for ctx->Driver.NewSamplerObject();
146 struct gl_sampler_object
*
147 _mesa_new_sampler_object(struct gl_context
*ctx
, GLuint name
)
149 struct gl_sampler_object
*sampObj
= CALLOC_STRUCT(gl_sampler_object
);
151 _mesa_init_sampler_object(sampObj
, name
);
157 create_samplers(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
166 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
168 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SamplerObjects
, count
);
170 /* Insert the ID and pointer to new sampler object into hash table */
171 for (i
= 0; i
< count
; i
++) {
172 struct gl_sampler_object
*sampObj
;
173 GLuint name
= first
+ i
;
175 sampObj
= ctx
->Driver
.NewSamplerObject(ctx
, name
);
177 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
178 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
182 _mesa_HashInsertLocked(ctx
->Shared
->SamplerObjects
, name
, sampObj
);
186 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
190 create_samplers_err(struct gl_context
*ctx
, GLsizei count
, GLuint
*samplers
,
194 if (MESA_VERBOSE
& VERBOSE_API
)
195 _mesa_debug(ctx
, "%s(%d)\n", caller
, count
);
198 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n<0)", caller
);
202 create_samplers(ctx
, count
, samplers
, caller
);
206 _mesa_GenSamplers_no_error(GLsizei count
, GLuint
*samplers
)
208 GET_CURRENT_CONTEXT(ctx
);
209 create_samplers(ctx
, count
, samplers
, "glGenSamplers");
213 _mesa_GenSamplers(GLsizei count
, GLuint
*samplers
)
215 GET_CURRENT_CONTEXT(ctx
);
216 create_samplers_err(ctx
, count
, samplers
, "glGenSamplers");
220 _mesa_CreateSamplers_no_error(GLsizei count
, GLuint
*samplers
)
222 GET_CURRENT_CONTEXT(ctx
);
223 create_samplers(ctx
, count
, samplers
, "glCreateSamplers");
227 _mesa_CreateSamplers(GLsizei count
, GLuint
*samplers
)
229 GET_CURRENT_CONTEXT(ctx
);
230 create_samplers_err(ctx
, count
, samplers
, "glCreateSamplers");
235 delete_samplers(struct gl_context
*ctx
, GLsizei count
, const GLuint
*samplers
)
237 FLUSH_VERTICES(ctx
, 0);
239 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
241 for (GLsizei i
= 0; i
< count
; i
++) {
244 struct gl_sampler_object
*sampObj
=
245 lookup_samplerobj_locked(ctx
, samplers
[i
]);
248 /* If the sampler is currently bound, unbind it. */
249 for (j
= 0; j
< ctx
->Const
.MaxCombinedTextureImageUnits
; j
++) {
250 if (ctx
->Texture
.Unit
[j
].Sampler
== sampObj
) {
251 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
252 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[j
].Sampler
, NULL
);
256 /* The ID is immediately freed for re-use */
257 _mesa_HashRemoveLocked(ctx
->Shared
->SamplerObjects
, samplers
[i
]);
258 /* But the object exists until its reference count goes to zero */
259 _mesa_reference_sampler_object(ctx
, &sampObj
, NULL
);
264 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
269 _mesa_DeleteSamplers_no_error(GLsizei count
, const GLuint
*samplers
)
271 GET_CURRENT_CONTEXT(ctx
);
272 delete_samplers(ctx
, count
, samplers
);
277 _mesa_DeleteSamplers(GLsizei count
, const GLuint
*samplers
)
279 GET_CURRENT_CONTEXT(ctx
);
282 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteSamplers(count)");
286 delete_samplers(ctx
, count
, samplers
);
291 _mesa_IsSampler(GLuint sampler
)
293 GET_CURRENT_CONTEXT(ctx
);
295 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
297 return _mesa_lookup_samplerobj(ctx
, sampler
) != NULL
;
301 _mesa_bind_sampler(struct gl_context
*ctx
, GLuint unit
,
302 struct gl_sampler_object
*sampObj
)
304 if (ctx
->Texture
.Unit
[unit
].Sampler
!= sampObj
) {
305 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
308 _mesa_reference_sampler_object(ctx
, &ctx
->Texture
.Unit
[unit
].Sampler
,
312 static ALWAYS_INLINE
void
313 bind_sampler(struct gl_context
*ctx
, GLuint unit
, GLuint sampler
, bool no_error
)
315 struct gl_sampler_object
*sampObj
;
318 /* Use the default sampler object, the one contained in the texture
323 /* user-defined sampler object */
324 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
325 if (!no_error
&& !sampObj
) {
326 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindSampler(sampler)");
331 /* bind new sampler */
332 _mesa_bind_sampler(ctx
, unit
, sampObj
);
336 _mesa_BindSampler_no_error(GLuint unit
, GLuint sampler
)
338 GET_CURRENT_CONTEXT(ctx
);
339 bind_sampler(ctx
, unit
, sampler
, true);
343 _mesa_BindSampler(GLuint unit
, GLuint sampler
)
345 GET_CURRENT_CONTEXT(ctx
);
347 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
348 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindSampler(unit %u)", unit
);
352 bind_sampler(ctx
, unit
, sampler
, false);
356 static ALWAYS_INLINE
void
357 bind_samplers(struct gl_context
*ctx
, GLuint first
, GLsizei count
,
358 const GLuint
*samplers
, bool no_error
)
362 FLUSH_VERTICES(ctx
, 0);
365 /* Note that the error semantics for multi-bind commands differ from
366 * those of other GL commands.
368 * The Issues section in the ARB_multi_bind spec says:
370 * "(11) Typically, OpenGL specifies that if an error is generated by
371 * a command, that command has no effect. This is somewhat
372 * unfortunate for multi-bind commands, because it would require
373 * a first pass to scan the entire list of bound objects for
374 * errors and then a second pass to actually perform the
375 * bindings. Should we have different error semantics?
377 * RESOLVED: Yes. In this specification, when the parameters for
378 * one of the <count> binding points are invalid, that binding
379 * point is not updated and an error will be generated. However,
380 * other binding points in the same command will be updated if
381 * their parameters are valid and no other error occurs."
384 _mesa_HashLockMutex(ctx
->Shared
->SamplerObjects
);
386 for (i
= 0; i
< count
; i
++) {
387 const GLuint unit
= first
+ i
;
388 struct gl_sampler_object
* const currentSampler
=
389 ctx
->Texture
.Unit
[unit
].Sampler
;
390 struct gl_sampler_object
*sampObj
;
392 if (samplers
[i
] != 0) {
393 if (currentSampler
&& currentSampler
->Name
== samplers
[i
])
394 sampObj
= currentSampler
;
396 sampObj
= lookup_samplerobj_locked(ctx
, samplers
[i
]);
398 /* The ARB_multi_bind spec says:
400 * "An INVALID_OPERATION error is generated if any value
401 * in <samplers> is not zero or the name of an existing
402 * sampler object (per binding)."
404 if (!no_error
&& !sampObj
) {
405 _mesa_error(ctx
, GL_INVALID_OPERATION
,
406 "glBindSamplers(samplers[%d]=%u is not zero or "
407 "the name of an existing sampler object)",
415 /* Bind the new sampler */
416 if (sampObj
!= currentSampler
) {
417 _mesa_reference_sampler_object(ctx
,
418 &ctx
->Texture
.Unit
[unit
].Sampler
,
420 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
424 _mesa_HashUnlockMutex(ctx
->Shared
->SamplerObjects
);
426 /* Unbind all samplers in the range <first> through <first>+<count>-1 */
427 for (i
= 0; i
< count
; i
++) {
428 const GLuint unit
= first
+ i
;
430 if (ctx
->Texture
.Unit
[unit
].Sampler
) {
431 _mesa_reference_sampler_object(ctx
,
432 &ctx
->Texture
.Unit
[unit
].Sampler
,
434 ctx
->NewState
|= _NEW_TEXTURE_OBJECT
;
442 _mesa_BindSamplers_no_error(GLuint first
, GLsizei count
, const GLuint
*samplers
)
444 GET_CURRENT_CONTEXT(ctx
);
445 bind_samplers(ctx
, first
, count
, samplers
, true);
450 _mesa_BindSamplers(GLuint first
, GLsizei count
, const GLuint
*samplers
)
452 GET_CURRENT_CONTEXT(ctx
);
454 /* The ARB_multi_bind spec says:
456 * "An INVALID_OPERATION error is generated if <first> + <count> is
457 * greater than the number of texture image units supported by
458 * the implementation."
460 if (first
+ count
> ctx
->Const
.MaxCombinedTextureImageUnits
) {
461 _mesa_error(ctx
, GL_INVALID_OPERATION
,
462 "glBindSamplers(first=%u + count=%d > the value of "
463 "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS=%u)",
464 first
, count
, ctx
->Const
.MaxCombinedTextureImageUnits
);
468 bind_samplers(ctx
, first
, count
, samplers
, false);
473 * Check if a coordinate wrap mode is legal.
474 * \return GL_TRUE if legal, GL_FALSE otherwise
477 validate_texture_wrap_mode(struct gl_context
*ctx
, GLenum wrap
)
479 const struct gl_extensions
* const e
= &ctx
->Extensions
;
483 case GL_CLAMP_TO_EDGE
:
485 case GL_MIRRORED_REPEAT
:
487 case GL_CLAMP_TO_BORDER
:
488 return e
->ARB_texture_border_clamp
;
489 case GL_MIRROR_CLAMP_EXT
:
490 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
;
491 case GL_MIRROR_CLAMP_TO_EDGE_EXT
:
492 return e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
|| e
->ARB_texture_mirror_clamp_to_edge
;
493 case GL_MIRROR_CLAMP_TO_BORDER_EXT
:
494 return e
->EXT_texture_mirror_clamp
;
502 * This is called just prior to changing any sampler object state.
505 flush(struct gl_context
*ctx
)
507 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
511 _mesa_set_sampler_wrap(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
512 GLenum s
, GLenum t
, GLenum r
)
514 assert(validate_texture_wrap_mode(ctx
, s
));
515 assert(validate_texture_wrap_mode(ctx
, t
));
516 assert(validate_texture_wrap_mode(ctx
, r
));
518 if (samp
->WrapS
== s
&& samp
->WrapT
== t
&& samp
->WrapR
== r
)
527 #define INVALID_PARAM 0x100
528 #define INVALID_PNAME 0x101
529 #define INVALID_VALUE 0x102
532 set_sampler_wrap_s(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
535 if (samp
->WrapS
== param
)
537 if (validate_texture_wrap_mode(ctx
, param
)) {
542 return INVALID_PARAM
;
547 set_sampler_wrap_t(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
550 if (samp
->WrapT
== param
)
552 if (validate_texture_wrap_mode(ctx
, param
)) {
557 return INVALID_PARAM
;
562 set_sampler_wrap_r(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
565 if (samp
->WrapR
== param
)
567 if (validate_texture_wrap_mode(ctx
, param
)) {
572 return INVALID_PARAM
;
576 _mesa_set_sampler_filters(struct gl_context
*ctx
,
577 struct gl_sampler_object
*samp
,
578 GLenum min_filter
, GLenum mag_filter
)
580 assert(min_filter
== GL_NEAREST
||
581 min_filter
== GL_LINEAR
||
582 min_filter
== GL_NEAREST_MIPMAP_NEAREST
||
583 min_filter
== GL_LINEAR_MIPMAP_NEAREST
||
584 min_filter
== GL_NEAREST_MIPMAP_LINEAR
||
585 min_filter
== GL_LINEAR_MIPMAP_LINEAR
);
586 assert(mag_filter
== GL_NEAREST
||
587 mag_filter
== GL_LINEAR
);
589 if (samp
->MinFilter
== min_filter
&& samp
->MagFilter
== mag_filter
)
593 samp
->MinFilter
= min_filter
;
594 samp
->MagFilter
= mag_filter
;
598 set_sampler_min_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
601 if (samp
->MinFilter
== param
)
607 case GL_NEAREST_MIPMAP_NEAREST
:
608 case GL_LINEAR_MIPMAP_NEAREST
:
609 case GL_NEAREST_MIPMAP_LINEAR
:
610 case GL_LINEAR_MIPMAP_LINEAR
:
612 samp
->MinFilter
= param
;
615 return INVALID_PARAM
;
621 set_sampler_mag_filter(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
624 if (samp
->MagFilter
== param
)
631 samp
->MagFilter
= param
;
634 return INVALID_PARAM
;
640 set_sampler_lod_bias(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
643 if (samp
->LodBias
== param
)
647 samp
->LodBias
= param
;
653 set_sampler_border_colorf(struct gl_context
*ctx
,
654 struct gl_sampler_object
*samp
,
655 const GLfloat params
[4])
658 samp
->BorderColor
.f
[RCOMP
] = params
[0];
659 samp
->BorderColor
.f
[GCOMP
] = params
[1];
660 samp
->BorderColor
.f
[BCOMP
] = params
[2];
661 samp
->BorderColor
.f
[ACOMP
] = params
[3];
667 set_sampler_border_colori(struct gl_context
*ctx
,
668 struct gl_sampler_object
*samp
,
669 const GLint params
[4])
672 samp
->BorderColor
.i
[RCOMP
] = params
[0];
673 samp
->BorderColor
.i
[GCOMP
] = params
[1];
674 samp
->BorderColor
.i
[BCOMP
] = params
[2];
675 samp
->BorderColor
.i
[ACOMP
] = params
[3];
681 set_sampler_border_colorui(struct gl_context
*ctx
,
682 struct gl_sampler_object
*samp
,
683 const GLuint params
[4])
686 samp
->BorderColor
.ui
[RCOMP
] = params
[0];
687 samp
->BorderColor
.ui
[GCOMP
] = params
[1];
688 samp
->BorderColor
.ui
[BCOMP
] = params
[2];
689 samp
->BorderColor
.ui
[ACOMP
] = params
[3];
695 set_sampler_min_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
698 if (samp
->MinLod
== param
)
702 samp
->MinLod
= param
;
708 set_sampler_max_lod(struct gl_context
*ctx
, struct gl_sampler_object
*samp
,
711 if (samp
->MaxLod
== param
)
715 samp
->MaxLod
= param
;
721 set_sampler_compare_mode(struct gl_context
*ctx
,
722 struct gl_sampler_object
*samp
, GLint param
)
724 /* If GL_ARB_shadow is not supported, don't report an error. The
725 * sampler object extension spec isn't clear on this extension interaction.
726 * Silences errors with Wine on older GPUs such as R200.
728 if (!ctx
->Extensions
.ARB_shadow
)
731 if (samp
->CompareMode
== param
)
734 if (param
== GL_NONE
||
735 param
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
737 samp
->CompareMode
= param
;
741 return INVALID_PARAM
;
746 set_sampler_compare_func(struct gl_context
*ctx
,
747 struct gl_sampler_object
*samp
, GLint param
)
749 /* If GL_ARB_shadow is not supported, don't report an error. The
750 * sampler object extension spec isn't clear on this extension interaction.
751 * Silences errors with Wine on older GPUs such as R200.
753 if (!ctx
->Extensions
.ARB_shadow
)
756 if (samp
->CompareFunc
== param
)
769 samp
->CompareFunc
= param
;
772 return INVALID_PARAM
;
778 set_sampler_max_anisotropy(struct gl_context
*ctx
,
779 struct gl_sampler_object
*samp
, GLfloat param
)
781 if (!ctx
->Extensions
.EXT_texture_filter_anisotropic
)
782 return INVALID_PNAME
;
784 if (samp
->MaxAnisotropy
== param
)
788 return INVALID_VALUE
;
791 /* clamp to max, that's what NVIDIA does */
792 samp
->MaxAnisotropy
= MIN2(param
, ctx
->Const
.MaxTextureMaxAnisotropy
);
798 set_sampler_cube_map_seamless(struct gl_context
*ctx
,
799 struct gl_sampler_object
*samp
, GLboolean param
)
801 if (!_mesa_is_desktop_gl(ctx
)
802 || !ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
803 return INVALID_PNAME
;
805 if (samp
->CubeMapSeamless
== param
)
808 if (param
!= GL_TRUE
&& param
!= GL_FALSE
)
809 return INVALID_VALUE
;
812 samp
->CubeMapSeamless
= param
;
817 _mesa_set_sampler_srgb_decode(struct gl_context
*ctx
,
818 struct gl_sampler_object
*samp
, GLenum param
)
820 assert(param
== GL_DECODE_EXT
|| param
== GL_SKIP_DECODE_EXT
);
823 samp
->sRGBDecode
= param
;
827 set_sampler_srgb_decode(struct gl_context
*ctx
,
828 struct gl_sampler_object
*samp
, GLenum param
)
830 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
831 return INVALID_PNAME
;
833 if (samp
->sRGBDecode
== param
)
836 /* The EXT_texture_sRGB_decode spec says:
838 * "INVALID_ENUM is generated if the <pname> parameter of
839 * TexParameter[i,f,Ii,Iui][v][EXT],
840 * MultiTexParameter[i,f,Ii,Iui][v]EXT,
841 * TextureParameter[i,f,Ii,Iui][v]EXT, SamplerParameter[i,f,Ii,Iui][v]
842 * is TEXTURE_SRGB_DECODE_EXT when the <param> parameter is not one of
843 * DECODE_EXT or SKIP_DECODE_EXT.
845 * Returning INVALID_PARAM makes that happen.
847 if (param
!= GL_DECODE_EXT
&& param
!= GL_SKIP_DECODE_EXT
)
848 return INVALID_PARAM
;
851 samp
->sRGBDecode
= param
;
855 static struct gl_sampler_object
*
856 sampler_parameter_error_check(struct gl_context
*ctx
, GLuint sampler
,
857 bool get
, const char *name
)
859 struct gl_sampler_object
*sampObj
;
861 sampObj
= _mesa_lookup_samplerobj(ctx
, sampler
);
863 /* OpenGL 4.5 spec, section "8.2 Sampler Objects", page 176 of the PDF
866 * "An INVALID_OPERATION error is generated if sampler is not the name
867 * of a sampler object previously returned from a call to
870 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(invalid sampler)", name
);
874 if (!get
&& sampObj
->HandleAllocated
) {
875 /* The ARB_bindless_texture spec says:
877 * "The error INVALID_OPERATION is generated by SamplerParameter* if
878 * <sampler> identifies a sampler object referenced by one or more
881 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(immutable sampler)", name
);
889 _mesa_SamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
)
891 struct gl_sampler_object
*sampObj
;
893 GET_CURRENT_CONTEXT(ctx
);
895 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
896 "glSamplerParameteri");
901 case GL_TEXTURE_WRAP_S
:
902 res
= set_sampler_wrap_s(ctx
, sampObj
, param
);
904 case GL_TEXTURE_WRAP_T
:
905 res
= set_sampler_wrap_t(ctx
, sampObj
, param
);
907 case GL_TEXTURE_WRAP_R
:
908 res
= set_sampler_wrap_r(ctx
, sampObj
, param
);
910 case GL_TEXTURE_MIN_FILTER
:
911 res
= set_sampler_min_filter(ctx
, sampObj
, param
);
913 case GL_TEXTURE_MAG_FILTER
:
914 res
= set_sampler_mag_filter(ctx
, sampObj
, param
);
916 case GL_TEXTURE_MIN_LOD
:
917 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) param
);
919 case GL_TEXTURE_MAX_LOD
:
920 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) param
);
922 case GL_TEXTURE_LOD_BIAS
:
923 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) param
);
925 case GL_TEXTURE_COMPARE_MODE
:
926 res
= set_sampler_compare_mode(ctx
, sampObj
, param
);
928 case GL_TEXTURE_COMPARE_FUNC
:
929 res
= set_sampler_compare_func(ctx
, sampObj
, param
);
931 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
932 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) param
);
934 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
935 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, param
);
937 case GL_TEXTURE_SRGB_DECODE_EXT
:
938 res
= set_sampler_srgb_decode(ctx
, sampObj
, param
);
940 case GL_TEXTURE_BORDER_COLOR
:
951 /* state change - we do nothing special at this time */
954 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(pname=%s)\n",
955 _mesa_enum_to_string(pname
));
958 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteri(param=%d)\n",
962 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteri(param=%d)\n",
972 _mesa_SamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
)
974 struct gl_sampler_object
*sampObj
;
976 GET_CURRENT_CONTEXT(ctx
);
978 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
979 "glSamplerParameterf");
984 case GL_TEXTURE_WRAP_S
:
985 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) param
);
987 case GL_TEXTURE_WRAP_T
:
988 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) param
);
990 case GL_TEXTURE_WRAP_R
:
991 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) param
);
993 case GL_TEXTURE_MIN_FILTER
:
994 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) param
);
996 case GL_TEXTURE_MAG_FILTER
:
997 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) param
);
999 case GL_TEXTURE_MIN_LOD
:
1000 res
= set_sampler_min_lod(ctx
, sampObj
, param
);
1002 case GL_TEXTURE_MAX_LOD
:
1003 res
= set_sampler_max_lod(ctx
, sampObj
, param
);
1005 case GL_TEXTURE_LOD_BIAS
:
1006 res
= set_sampler_lod_bias(ctx
, sampObj
, param
);
1008 case GL_TEXTURE_COMPARE_MODE
:
1009 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) param
);
1011 case GL_TEXTURE_COMPARE_FUNC
:
1012 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) param
);
1014 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1015 res
= set_sampler_max_anisotropy(ctx
, sampObj
, param
);
1017 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1018 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) param
);
1020 case GL_TEXTURE_SRGB_DECODE_EXT
:
1021 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) param
);
1023 case GL_TEXTURE_BORDER_COLOR
:
1026 res
= INVALID_PNAME
;
1034 /* state change - we do nothing special at this time */
1037 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(pname=%s)\n",
1038 _mesa_enum_to_string(pname
));
1041 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterf(param=%f)\n",
1045 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterf(param=%f)\n",
1054 _mesa_SamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1056 struct gl_sampler_object
*sampObj
;
1058 GET_CURRENT_CONTEXT(ctx
);
1060 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1061 "glSamplerParameteriv");
1066 case GL_TEXTURE_WRAP_S
:
1067 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1069 case GL_TEXTURE_WRAP_T
:
1070 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1072 case GL_TEXTURE_WRAP_R
:
1073 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1075 case GL_TEXTURE_MIN_FILTER
:
1076 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1078 case GL_TEXTURE_MAG_FILTER
:
1079 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1081 case GL_TEXTURE_MIN_LOD
:
1082 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1084 case GL_TEXTURE_MAX_LOD
:
1085 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1087 case GL_TEXTURE_LOD_BIAS
:
1088 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1090 case GL_TEXTURE_COMPARE_MODE
:
1091 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1093 case GL_TEXTURE_COMPARE_FUNC
:
1094 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1096 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1097 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1099 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1100 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1102 case GL_TEXTURE_SRGB_DECODE_EXT
:
1103 res
= set_sampler_srgb_decode(ctx
, sampObj
, params
[0]);
1105 case GL_TEXTURE_BORDER_COLOR
:
1108 c
[0] = INT_TO_FLOAT(params
[0]);
1109 c
[1] = INT_TO_FLOAT(params
[1]);
1110 c
[2] = INT_TO_FLOAT(params
[2]);
1111 c
[3] = INT_TO_FLOAT(params
[3]);
1112 res
= set_sampler_border_colorf(ctx
, sampObj
, c
);
1116 res
= INVALID_PNAME
;
1124 /* state change - we do nothing special at this time */
1127 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(pname=%s)\n",
1128 _mesa_enum_to_string(pname
));
1131 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameteriv(param=%d)\n",
1135 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameteriv(param=%d)\n",
1144 _mesa_SamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
*params
)
1146 struct gl_sampler_object
*sampObj
;
1148 GET_CURRENT_CONTEXT(ctx
);
1150 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1151 "glSamplerParameterfv");
1156 case GL_TEXTURE_WRAP_S
:
1157 res
= set_sampler_wrap_s(ctx
, sampObj
, (GLint
) params
[0]);
1159 case GL_TEXTURE_WRAP_T
:
1160 res
= set_sampler_wrap_t(ctx
, sampObj
, (GLint
) params
[0]);
1162 case GL_TEXTURE_WRAP_R
:
1163 res
= set_sampler_wrap_r(ctx
, sampObj
, (GLint
) params
[0]);
1165 case GL_TEXTURE_MIN_FILTER
:
1166 res
= set_sampler_min_filter(ctx
, sampObj
, (GLint
) params
[0]);
1168 case GL_TEXTURE_MAG_FILTER
:
1169 res
= set_sampler_mag_filter(ctx
, sampObj
, (GLint
) params
[0]);
1171 case GL_TEXTURE_MIN_LOD
:
1172 res
= set_sampler_min_lod(ctx
, sampObj
, params
[0]);
1174 case GL_TEXTURE_MAX_LOD
:
1175 res
= set_sampler_max_lod(ctx
, sampObj
, params
[0]);
1177 case GL_TEXTURE_LOD_BIAS
:
1178 res
= set_sampler_lod_bias(ctx
, sampObj
, params
[0]);
1180 case GL_TEXTURE_COMPARE_MODE
:
1181 res
= set_sampler_compare_mode(ctx
, sampObj
, (GLint
) params
[0]);
1183 case GL_TEXTURE_COMPARE_FUNC
:
1184 res
= set_sampler_compare_func(ctx
, sampObj
, (GLint
) params
[0]);
1186 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1187 res
= set_sampler_max_anisotropy(ctx
, sampObj
, params
[0]);
1189 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1190 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, (GLboolean
) params
[0]);
1192 case GL_TEXTURE_SRGB_DECODE_EXT
:
1193 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1195 case GL_TEXTURE_BORDER_COLOR
:
1196 res
= set_sampler_border_colorf(ctx
, sampObj
, params
);
1199 res
= INVALID_PNAME
;
1207 /* state change - we do nothing special at this time */
1210 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(pname=%s)\n",
1211 _mesa_enum_to_string(pname
));
1214 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterfv(param=%f)\n",
1218 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterfv(param=%f)\n",
1227 _mesa_SamplerParameterIiv(GLuint sampler
, GLenum pname
, const GLint
*params
)
1229 struct gl_sampler_object
*sampObj
;
1231 GET_CURRENT_CONTEXT(ctx
);
1233 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1234 "glSamplerParameterIiv");
1239 case GL_TEXTURE_WRAP_S
:
1240 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1242 case GL_TEXTURE_WRAP_T
:
1243 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1245 case GL_TEXTURE_WRAP_R
:
1246 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1248 case GL_TEXTURE_MIN_FILTER
:
1249 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1251 case GL_TEXTURE_MAG_FILTER
:
1252 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1254 case GL_TEXTURE_MIN_LOD
:
1255 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1257 case GL_TEXTURE_MAX_LOD
:
1258 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1260 case GL_TEXTURE_LOD_BIAS
:
1261 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1263 case GL_TEXTURE_COMPARE_MODE
:
1264 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1266 case GL_TEXTURE_COMPARE_FUNC
:
1267 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1269 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1270 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1272 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1273 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1275 case GL_TEXTURE_SRGB_DECODE_EXT
:
1276 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1278 case GL_TEXTURE_BORDER_COLOR
:
1279 res
= set_sampler_border_colori(ctx
, sampObj
, params
);
1282 res
= INVALID_PNAME
;
1290 /* state change - we do nothing special at this time */
1293 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(pname=%s)\n",
1294 _mesa_enum_to_string(pname
));
1297 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIiv(param=%d)\n",
1301 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIiv(param=%d)\n",
1311 _mesa_SamplerParameterIuiv(GLuint sampler
, GLenum pname
, const GLuint
*params
)
1313 struct gl_sampler_object
*sampObj
;
1315 GET_CURRENT_CONTEXT(ctx
);
1317 sampObj
= sampler_parameter_error_check(ctx
, sampler
, false,
1318 "glSamplerParameterIuiv");
1323 case GL_TEXTURE_WRAP_S
:
1324 res
= set_sampler_wrap_s(ctx
, sampObj
, params
[0]);
1326 case GL_TEXTURE_WRAP_T
:
1327 res
= set_sampler_wrap_t(ctx
, sampObj
, params
[0]);
1329 case GL_TEXTURE_WRAP_R
:
1330 res
= set_sampler_wrap_r(ctx
, sampObj
, params
[0]);
1332 case GL_TEXTURE_MIN_FILTER
:
1333 res
= set_sampler_min_filter(ctx
, sampObj
, params
[0]);
1335 case GL_TEXTURE_MAG_FILTER
:
1336 res
= set_sampler_mag_filter(ctx
, sampObj
, params
[0]);
1338 case GL_TEXTURE_MIN_LOD
:
1339 res
= set_sampler_min_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1341 case GL_TEXTURE_MAX_LOD
:
1342 res
= set_sampler_max_lod(ctx
, sampObj
, (GLfloat
) params
[0]);
1344 case GL_TEXTURE_LOD_BIAS
:
1345 res
= set_sampler_lod_bias(ctx
, sampObj
, (GLfloat
) params
[0]);
1347 case GL_TEXTURE_COMPARE_MODE
:
1348 res
= set_sampler_compare_mode(ctx
, sampObj
, params
[0]);
1350 case GL_TEXTURE_COMPARE_FUNC
:
1351 res
= set_sampler_compare_func(ctx
, sampObj
, params
[0]);
1353 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1354 res
= set_sampler_max_anisotropy(ctx
, sampObj
, (GLfloat
) params
[0]);
1356 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1357 res
= set_sampler_cube_map_seamless(ctx
, sampObj
, params
[0]);
1359 case GL_TEXTURE_SRGB_DECODE_EXT
:
1360 res
= set_sampler_srgb_decode(ctx
, sampObj
, (GLenum
) params
[0]);
1362 case GL_TEXTURE_BORDER_COLOR
:
1363 res
= set_sampler_border_colorui(ctx
, sampObj
, params
);
1366 res
= INVALID_PNAME
;
1374 /* state change - we do nothing special at this time */
1377 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(pname=%s)\n",
1378 _mesa_enum_to_string(pname
));
1381 _mesa_error(ctx
, GL_INVALID_ENUM
, "glSamplerParameterIuiv(param=%u)\n",
1385 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSamplerParameterIuiv(param=%u)\n",
1395 _mesa_GetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
*params
)
1397 struct gl_sampler_object
*sampObj
;
1398 GET_CURRENT_CONTEXT(ctx
);
1400 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1401 "glGetSamplerParameteriv");
1406 case GL_TEXTURE_WRAP_S
:
1407 *params
= sampObj
->WrapS
;
1409 case GL_TEXTURE_WRAP_T
:
1410 *params
= sampObj
->WrapT
;
1412 case GL_TEXTURE_WRAP_R
:
1413 *params
= sampObj
->WrapR
;
1415 case GL_TEXTURE_MIN_FILTER
:
1416 *params
= sampObj
->MinFilter
;
1418 case GL_TEXTURE_MAG_FILTER
:
1419 *params
= sampObj
->MagFilter
;
1421 case GL_TEXTURE_MIN_LOD
:
1422 /* GL spec 'Data Conversions' section specifies that floating-point
1423 * value in integer Get function is rounded to nearest integer
1425 *params
= IROUND(sampObj
->MinLod
);
1427 case GL_TEXTURE_MAX_LOD
:
1428 /* GL spec 'Data Conversions' section specifies that floating-point
1429 * value in integer Get function is rounded to nearest integer
1431 *params
= IROUND(sampObj
->MaxLod
);
1433 case GL_TEXTURE_LOD_BIAS
:
1434 /* GL spec 'Data Conversions' section specifies that floating-point
1435 * value in integer Get function is rounded to nearest integer
1437 *params
= IROUND(sampObj
->LodBias
);
1439 case GL_TEXTURE_COMPARE_MODE
:
1440 *params
= sampObj
->CompareMode
;
1442 case GL_TEXTURE_COMPARE_FUNC
:
1443 *params
= sampObj
->CompareFunc
;
1445 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1446 /* GL spec 'Data Conversions' section specifies that floating-point
1447 * value in integer Get function is rounded to nearest integer
1449 *params
= IROUND(sampObj
->MaxAnisotropy
);
1451 case GL_TEXTURE_BORDER_COLOR
:
1452 params
[0] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[0]);
1453 params
[1] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[1]);
1454 params
[2] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[2]);
1455 params
[3] = FLOAT_TO_INT(sampObj
->BorderColor
.f
[3]);
1457 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1458 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1460 *params
= sampObj
->CubeMapSeamless
;
1462 case GL_TEXTURE_SRGB_DECODE_EXT
:
1463 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1465 *params
= (GLenum
) sampObj
->sRGBDecode
;
1473 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameteriv(pname=%s)",
1474 _mesa_enum_to_string(pname
));
1479 _mesa_GetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
*params
)
1481 struct gl_sampler_object
*sampObj
;
1482 GET_CURRENT_CONTEXT(ctx
);
1484 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1485 "glGetSamplerParameterfv");
1490 case GL_TEXTURE_WRAP_S
:
1491 *params
= (GLfloat
) sampObj
->WrapS
;
1493 case GL_TEXTURE_WRAP_T
:
1494 *params
= (GLfloat
) sampObj
->WrapT
;
1496 case GL_TEXTURE_WRAP_R
:
1497 *params
= (GLfloat
) sampObj
->WrapR
;
1499 case GL_TEXTURE_MIN_FILTER
:
1500 *params
= (GLfloat
) sampObj
->MinFilter
;
1502 case GL_TEXTURE_MAG_FILTER
:
1503 *params
= (GLfloat
) sampObj
->MagFilter
;
1505 case GL_TEXTURE_MIN_LOD
:
1506 *params
= sampObj
->MinLod
;
1508 case GL_TEXTURE_MAX_LOD
:
1509 *params
= sampObj
->MaxLod
;
1511 case GL_TEXTURE_LOD_BIAS
:
1512 *params
= sampObj
->LodBias
;
1514 case GL_TEXTURE_COMPARE_MODE
:
1515 *params
= (GLfloat
) sampObj
->CompareMode
;
1517 case GL_TEXTURE_COMPARE_FUNC
:
1518 *params
= (GLfloat
) sampObj
->CompareFunc
;
1520 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1521 *params
= sampObj
->MaxAnisotropy
;
1523 case GL_TEXTURE_BORDER_COLOR
:
1524 params
[0] = sampObj
->BorderColor
.f
[0];
1525 params
[1] = sampObj
->BorderColor
.f
[1];
1526 params
[2] = sampObj
->BorderColor
.f
[2];
1527 params
[3] = sampObj
->BorderColor
.f
[3];
1529 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1530 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1532 *params
= (GLfloat
) sampObj
->CubeMapSeamless
;
1534 case GL_TEXTURE_SRGB_DECODE_EXT
:
1535 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1537 *params
= (GLfloat
) sampObj
->sRGBDecode
;
1545 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterfv(pname=%s)",
1546 _mesa_enum_to_string(pname
));
1551 _mesa_GetSamplerParameterIiv(GLuint sampler
, GLenum pname
, GLint
*params
)
1553 struct gl_sampler_object
*sampObj
;
1554 GET_CURRENT_CONTEXT(ctx
);
1556 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1557 "glGetSamplerParameterIiv");
1562 case GL_TEXTURE_WRAP_S
:
1563 *params
= sampObj
->WrapS
;
1565 case GL_TEXTURE_WRAP_T
:
1566 *params
= sampObj
->WrapT
;
1568 case GL_TEXTURE_WRAP_R
:
1569 *params
= sampObj
->WrapR
;
1571 case GL_TEXTURE_MIN_FILTER
:
1572 *params
= sampObj
->MinFilter
;
1574 case GL_TEXTURE_MAG_FILTER
:
1575 *params
= sampObj
->MagFilter
;
1577 case GL_TEXTURE_MIN_LOD
:
1578 *params
= (GLint
) sampObj
->MinLod
;
1580 case GL_TEXTURE_MAX_LOD
:
1581 *params
= (GLint
) sampObj
->MaxLod
;
1583 case GL_TEXTURE_LOD_BIAS
:
1584 *params
= (GLint
) sampObj
->LodBias
;
1586 case GL_TEXTURE_COMPARE_MODE
:
1587 *params
= sampObj
->CompareMode
;
1589 case GL_TEXTURE_COMPARE_FUNC
:
1590 *params
= sampObj
->CompareFunc
;
1592 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1593 *params
= (GLint
) sampObj
->MaxAnisotropy
;
1595 case GL_TEXTURE_BORDER_COLOR
:
1596 params
[0] = sampObj
->BorderColor
.i
[0];
1597 params
[1] = sampObj
->BorderColor
.i
[1];
1598 params
[2] = sampObj
->BorderColor
.i
[2];
1599 params
[3] = sampObj
->BorderColor
.i
[3];
1601 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1602 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1604 *params
= sampObj
->CubeMapSeamless
;
1606 case GL_TEXTURE_SRGB_DECODE_EXT
:
1607 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1609 *params
= (GLenum
) sampObj
->sRGBDecode
;
1617 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIiv(pname=%s)",
1618 _mesa_enum_to_string(pname
));
1623 _mesa_GetSamplerParameterIuiv(GLuint sampler
, GLenum pname
, GLuint
*params
)
1625 struct gl_sampler_object
*sampObj
;
1626 GET_CURRENT_CONTEXT(ctx
);
1628 sampObj
= sampler_parameter_error_check(ctx
, sampler
, true,
1629 "glGetSamplerParameterIuiv");
1634 case GL_TEXTURE_WRAP_S
:
1635 *params
= sampObj
->WrapS
;
1637 case GL_TEXTURE_WRAP_T
:
1638 *params
= sampObj
->WrapT
;
1640 case GL_TEXTURE_WRAP_R
:
1641 *params
= sampObj
->WrapR
;
1643 case GL_TEXTURE_MIN_FILTER
:
1644 *params
= sampObj
->MinFilter
;
1646 case GL_TEXTURE_MAG_FILTER
:
1647 *params
= sampObj
->MagFilter
;
1649 case GL_TEXTURE_MIN_LOD
:
1650 *params
= (GLuint
) sampObj
->MinLod
;
1652 case GL_TEXTURE_MAX_LOD
:
1653 *params
= (GLuint
) sampObj
->MaxLod
;
1655 case GL_TEXTURE_LOD_BIAS
:
1656 *params
= (GLuint
) sampObj
->LodBias
;
1658 case GL_TEXTURE_COMPARE_MODE
:
1659 *params
= sampObj
->CompareMode
;
1661 case GL_TEXTURE_COMPARE_FUNC
:
1662 *params
= sampObj
->CompareFunc
;
1664 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1665 *params
= (GLuint
) sampObj
->MaxAnisotropy
;
1667 case GL_TEXTURE_BORDER_COLOR
:
1668 params
[0] = sampObj
->BorderColor
.ui
[0];
1669 params
[1] = sampObj
->BorderColor
.ui
[1];
1670 params
[2] = sampObj
->BorderColor
.ui
[2];
1671 params
[3] = sampObj
->BorderColor
.ui
[3];
1673 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1674 if (!ctx
->Extensions
.AMD_seamless_cubemap_per_texture
)
1676 *params
= sampObj
->CubeMapSeamless
;
1678 case GL_TEXTURE_SRGB_DECODE_EXT
:
1679 if (!ctx
->Extensions
.EXT_texture_sRGB_decode
)
1681 *params
= (GLenum
) sampObj
->sRGBDecode
;
1689 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetSamplerParameterIuiv(pname=%s)",
1690 _mesa_enum_to_string(pname
));
1695 _mesa_init_sampler_object_functions(struct dd_function_table
*driver
)
1697 driver
->NewSamplerObject
= _mesa_new_sampler_object
;