2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 #include "glformats.h"
30 #include "formatquery.h"
35 _is_renderable(struct gl_context
*ctx
, GLenum internalformat
)
37 /* Section 4.4.4 on page 212 of the GLES 3.0.4 spec says:
39 * "An internal format is color-renderable if it is one of the
40 * formats from table 3.13 noted as color-renderable or if it
41 * is unsized format RGBA or RGB."
43 * Therefore, we must accept GL_RGB and GL_RGBA here.
45 if (internalformat
!= GL_RGB
&& internalformat
!= GL_RGBA
&&
46 _mesa_base_fbo_format(ctx
, internalformat
) == 0)
52 /* Handles the cases where either ARB_internalformat_query or
53 * ARB_internalformat_query2 have to return an error.
56 _legal_parameters(struct gl_context
*ctx
, GLenum target
, GLenum internalformat
,
57 GLenum pname
, GLsizei bufSize
, GLint
*params
)
60 bool query2
= _mesa_has_ARB_internalformat_query2(ctx
);
62 /* The ARB_internalformat_query2 spec says:
64 * "The INVALID_ENUM error is generated if the <target> parameter to
65 * GetInternalformati*v is not one of the targets listed in Table 6.xx.
69 case GL_TEXTURE_1D_ARRAY
:
71 case GL_TEXTURE_2D_ARRAY
:
73 case GL_TEXTURE_CUBE_MAP
:
74 case GL_TEXTURE_CUBE_MAP_ARRAY
:
75 case GL_TEXTURE_RECTANGLE
:
76 case GL_TEXTURE_BUFFER
:
78 /* The ARB_internalformat_query spec says:
80 * "If the <target> parameter to GetInternalformativ is not one of
81 * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY
82 * or RENDERBUFFER then an INVALID_ENUM error is generated.
84 _mesa_error(ctx
, GL_INVALID_ENUM
,
85 "glGetInternalformativ(target=%s)",
86 _mesa_enum_to_string(target
));
95 case GL_TEXTURE_2D_MULTISAMPLE
:
96 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
97 /* The non-existence of ARB_texture_multisample is treated in
98 * ARB_internalformat_query implementation like an error.
101 !(_mesa_has_ARB_texture_multisample(ctx
) || _mesa_is_gles31(ctx
))) {
102 _mesa_error(ctx
, GL_INVALID_ENUM
,
103 "glGetInternalformativ(target=%s)",
104 _mesa_enum_to_string(target
));
111 _mesa_error(ctx
, GL_INVALID_ENUM
,
112 "glGetInternalformativ(target=%s)",
113 _mesa_enum_to_string(target
));
118 /* The ARB_internalformat_query2 spec says:
120 * "The INVALID_ENUM error is generated if the <pname> parameter is
121 * not one of the listed possibilities.
125 case GL_NUM_SAMPLE_COUNTS
:
128 case GL_SRGB_DECODE_ARB
:
129 /* The ARB_internalformat_query2 spec says:
131 * "If ARB_texture_sRGB_decode or EXT_texture_sRGB_decode or
132 * equivalent functionality is not supported, queries for the
133 * SRGB_DECODE_ARB <pname> set the INVALID_ENUM error.
135 if (!_mesa_has_EXT_texture_sRGB_decode(ctx
)) {
136 _mesa_error(ctx
, GL_INVALID_ENUM
,
137 "glGetInternalformativ(pname=%s)",
138 _mesa_enum_to_string(pname
));
142 case GL_INTERNALFORMAT_SUPPORTED
:
143 case GL_INTERNALFORMAT_PREFERRED
:
144 case GL_INTERNALFORMAT_RED_SIZE
:
145 case GL_INTERNALFORMAT_GREEN_SIZE
:
146 case GL_INTERNALFORMAT_BLUE_SIZE
:
147 case GL_INTERNALFORMAT_ALPHA_SIZE
:
148 case GL_INTERNALFORMAT_DEPTH_SIZE
:
149 case GL_INTERNALFORMAT_STENCIL_SIZE
:
150 case GL_INTERNALFORMAT_SHARED_SIZE
:
151 case GL_INTERNALFORMAT_RED_TYPE
:
152 case GL_INTERNALFORMAT_GREEN_TYPE
:
153 case GL_INTERNALFORMAT_BLUE_TYPE
:
154 case GL_INTERNALFORMAT_ALPHA_TYPE
:
155 case GL_INTERNALFORMAT_DEPTH_TYPE
:
156 case GL_INTERNALFORMAT_STENCIL_TYPE
:
161 case GL_MAX_COMBINED_DIMENSIONS
:
162 case GL_COLOR_COMPONENTS
:
163 case GL_DEPTH_COMPONENTS
:
164 case GL_STENCIL_COMPONENTS
:
165 case GL_COLOR_RENDERABLE
:
166 case GL_DEPTH_RENDERABLE
:
167 case GL_STENCIL_RENDERABLE
:
168 case GL_FRAMEBUFFER_RENDERABLE
:
169 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
170 case GL_FRAMEBUFFER_BLEND
:
172 case GL_READ_PIXELS_FORMAT
:
173 case GL_READ_PIXELS_TYPE
:
174 case GL_TEXTURE_IMAGE_FORMAT
:
175 case GL_TEXTURE_IMAGE_TYPE
:
176 case GL_GET_TEXTURE_IMAGE_FORMAT
:
177 case GL_GET_TEXTURE_IMAGE_TYPE
:
179 case GL_MANUAL_GENERATE_MIPMAP
:
180 case GL_AUTO_GENERATE_MIPMAP
:
181 case GL_COLOR_ENCODING
:
185 case GL_VERTEX_TEXTURE
:
186 case GL_TESS_CONTROL_TEXTURE
:
187 case GL_TESS_EVALUATION_TEXTURE
:
188 case GL_GEOMETRY_TEXTURE
:
189 case GL_FRAGMENT_TEXTURE
:
190 case GL_COMPUTE_TEXTURE
:
191 case GL_TEXTURE_SHADOW
:
192 case GL_TEXTURE_GATHER
:
193 case GL_TEXTURE_GATHER_SHADOW
:
194 case GL_SHADER_IMAGE_LOAD
:
195 case GL_SHADER_IMAGE_STORE
:
196 case GL_SHADER_IMAGE_ATOMIC
:
197 case GL_IMAGE_TEXEL_SIZE
:
198 case GL_IMAGE_COMPATIBILITY_CLASS
:
199 case GL_IMAGE_PIXEL_FORMAT
:
200 case GL_IMAGE_PIXEL_TYPE
:
201 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
202 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
203 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
204 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
205 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
206 case GL_TEXTURE_COMPRESSED
:
207 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
208 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
209 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
:
210 case GL_CLEAR_BUFFER
:
211 case GL_TEXTURE_VIEW
:
212 case GL_VIEW_COMPATIBILITY_CLASS
:
213 /* The ARB_internalformat_query spec says:
215 * "If the <pname> parameter to GetInternalformativ is not SAMPLES
216 * or NUM_SAMPLE_COUNTS, then an INVALID_ENUM error is generated."
219 _mesa_error(ctx
, GL_INVALID_ENUM
,
220 "glGetInternalformativ(pname=%s)",
221 _mesa_enum_to_string(pname
));
228 _mesa_error(ctx
, GL_INVALID_ENUM
,
229 "glGetInternalformativ(pname=%s)",
230 _mesa_enum_to_string(pname
));
234 /* The ARB_internalformat_query spec says:
236 * "If the <bufSize> parameter to GetInternalformativ is negative, then
237 * an INVALID_VALUE error is generated."
239 * Nothing is said in ARB_internalformat_query2 but we assume the same.
242 _mesa_error(ctx
, GL_INVALID_VALUE
,
243 "glGetInternalformativ(target=%s)",
244 _mesa_enum_to_string(target
));
248 /* The ARB_internalformat_query spec says:
250 * "If the <internalformat> parameter to GetInternalformativ is not
251 * color-, depth- or stencil-renderable, then an INVALID_ENUM error is
254 if (!query2
&& !_is_renderable(ctx
, internalformat
)) {
255 _mesa_error(ctx
, GL_INVALID_ENUM
,
256 "glGetInternalformativ(internalformat=%s)",
257 _mesa_enum_to_string(internalformat
));
264 /* Sets the appropriate "unsupported" response as defined by the
265 * ARB_internalformat_query2 spec for each each <pname>.
268 _set_default_response(GLenum pname
, GLint buffer
[16])
270 /* The ARB_internalformat_query2 defines which is the reponse best
271 * representing "not supported" or "not applicable" for each <pname>.
274 * - size- or count-based queries will return zero,
275 * - support-, format- or type-based queries will return NONE,
276 * - boolean-based queries will return FALSE, and
277 * - list-based queries return no entries."
283 case GL_MAX_COMBINED_DIMENSIONS
:
284 case GL_NUM_SAMPLE_COUNTS
:
285 case GL_INTERNALFORMAT_RED_SIZE
:
286 case GL_INTERNALFORMAT_GREEN_SIZE
:
287 case GL_INTERNALFORMAT_BLUE_SIZE
:
288 case GL_INTERNALFORMAT_ALPHA_SIZE
:
289 case GL_INTERNALFORMAT_DEPTH_SIZE
:
290 case GL_INTERNALFORMAT_STENCIL_SIZE
:
291 case GL_INTERNALFORMAT_SHARED_SIZE
:
296 case GL_IMAGE_TEXEL_SIZE
:
297 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
298 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
299 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
:
303 case GL_INTERNALFORMAT_PREFERRED
:
304 case GL_INTERNALFORMAT_RED_TYPE
:
305 case GL_INTERNALFORMAT_GREEN_TYPE
:
306 case GL_INTERNALFORMAT_BLUE_TYPE
:
307 case GL_INTERNALFORMAT_ALPHA_TYPE
:
308 case GL_INTERNALFORMAT_DEPTH_TYPE
:
309 case GL_INTERNALFORMAT_STENCIL_TYPE
:
310 case GL_FRAMEBUFFER_RENDERABLE
:
311 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
312 case GL_FRAMEBUFFER_BLEND
:
314 case GL_READ_PIXELS_FORMAT
:
315 case GL_READ_PIXELS_TYPE
:
316 case GL_TEXTURE_IMAGE_FORMAT
:
317 case GL_TEXTURE_IMAGE_TYPE
:
318 case GL_GET_TEXTURE_IMAGE_FORMAT
:
319 case GL_GET_TEXTURE_IMAGE_TYPE
:
320 case GL_MANUAL_GENERATE_MIPMAP
:
321 case GL_AUTO_GENERATE_MIPMAP
:
322 case GL_COLOR_ENCODING
:
325 case GL_SRGB_DECODE_ARB
:
327 case GL_VERTEX_TEXTURE
:
328 case GL_TESS_CONTROL_TEXTURE
:
329 case GL_TESS_EVALUATION_TEXTURE
:
330 case GL_GEOMETRY_TEXTURE
:
331 case GL_FRAGMENT_TEXTURE
:
332 case GL_COMPUTE_TEXTURE
:
333 case GL_TEXTURE_SHADOW
:
334 case GL_TEXTURE_GATHER
:
335 case GL_TEXTURE_GATHER_SHADOW
:
336 case GL_SHADER_IMAGE_LOAD
:
337 case GL_SHADER_IMAGE_STORE
:
338 case GL_SHADER_IMAGE_ATOMIC
:
339 case GL_IMAGE_COMPATIBILITY_CLASS
:
340 case GL_IMAGE_PIXEL_FORMAT
:
341 case GL_IMAGE_PIXEL_TYPE
:
342 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
343 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
344 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
345 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
346 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
347 case GL_CLEAR_BUFFER
:
348 case GL_TEXTURE_VIEW
:
349 case GL_VIEW_COMPATIBILITY_CLASS
:
353 case GL_INTERNALFORMAT_SUPPORTED
:
354 case GL_COLOR_COMPONENTS
:
355 case GL_DEPTH_COMPONENTS
:
356 case GL_STENCIL_COMPONENTS
:
357 case GL_COLOR_RENDERABLE
:
358 case GL_DEPTH_RENDERABLE
:
359 case GL_STENCIL_RENDERABLE
:
361 case GL_TEXTURE_COMPRESSED
:
362 buffer
[0] = GL_FALSE
;
366 unreachable("invalid 'pname'");
371 _is_target_supported(struct gl_context
*ctx
, GLenum target
)
373 /* The ARB_internalformat_query2 spec says:
375 * "if a particular type of <target> is not supported by the
376 * implementation the "unsupported" answer should be given.
377 * This is not an error."
385 if (!_mesa_is_desktop_gl(ctx
))
389 case GL_TEXTURE_1D_ARRAY
:
390 if (!_mesa_has_EXT_texture_array(ctx
))
394 case GL_TEXTURE_2D_ARRAY
:
395 if (!(_mesa_has_EXT_texture_array(ctx
) || _mesa_is_gles3(ctx
)))
399 case GL_TEXTURE_CUBE_MAP
:
400 if (!_mesa_has_ARB_texture_cube_map(ctx
))
404 case GL_TEXTURE_CUBE_MAP_ARRAY
:
405 if (!_mesa_has_ARB_texture_cube_map_array(ctx
))
409 case GL_TEXTURE_RECTANGLE
:
410 if (!_mesa_has_NV_texture_rectangle(ctx
))
414 case GL_TEXTURE_BUFFER
:
415 if (!_mesa_has_ARB_texture_buffer_object(ctx
))
419 case GL_RENDERBUFFER
:
420 if (!(_mesa_has_ARB_framebuffer_object(ctx
) ||
421 _mesa_is_gles3(ctx
)))
425 case GL_TEXTURE_2D_MULTISAMPLE
:
426 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
427 if (!(_mesa_has_ARB_texture_multisample(ctx
) ||
428 _mesa_is_gles31(ctx
)))
433 unreachable("invalid target");
440 _is_resource_supported(struct gl_context
*ctx
, GLenum target
,
441 GLenum internalformat
, GLenum pname
)
443 /* From the ARB_internalformat_query2 spec:
445 * In the following descriptions, the term /resource/ is used to generically
446 * refer to an object of the appropriate type that has been created with
447 * <internalformat> and <target>. If the particular <target> and
448 * <internalformat> combination do not make sense, ... the "unsupported"
449 * answer should be given. This is not an error.
452 /* In the ARB_internalformat_query2 spec wording, some <pnames> do not care
453 * about the /resource/ being supported or not, we return 'true' for those.
456 case GL_INTERNALFORMAT_SUPPORTED
:
457 case GL_INTERNALFORMAT_PREFERRED
:
458 case GL_COLOR_COMPONENTS
:
459 case GL_DEPTH_COMPONENTS
:
460 case GL_STENCIL_COMPONENTS
:
461 case GL_COLOR_RENDERABLE
:
462 case GL_DEPTH_RENDERABLE
:
463 case GL_STENCIL_RENDERABLE
:
471 case GL_TEXTURE_1D_ARRAY
:
473 case GL_TEXTURE_2D_ARRAY
:
475 case GL_TEXTURE_CUBE_MAP
:
476 case GL_TEXTURE_CUBE_MAP_ARRAY
:
477 case GL_TEXTURE_RECTANGLE
:
478 /* Based on what Mesa does for glTexImage1D/2D/3D and
479 * glCompressedTexImage1D/2D/3D functions.
481 if (_mesa_base_tex_format(ctx
, internalformat
) < 0)
484 /* additional checks for depth textures */
485 if (!_mesa_legal_texture_base_format_for_target(ctx
, target
, internalformat
))
488 /* additional checks for compressed textures */
489 if (_mesa_is_compressed_format(ctx
, internalformat
) &&
490 (!_mesa_target_can_be_compressed(ctx
, target
, internalformat
, NULL
) ||
491 _mesa_format_no_online_compression(ctx
, internalformat
)))
495 case GL_TEXTURE_2D_MULTISAMPLE
:
496 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
497 /* Based on what Mesa does for glTexImage2D/3DMultisample,
498 * glTexStorage2D/3DMultisample and
499 * glTextureStorage2D/3DMultisample functions.
501 if (!_mesa_is_renderable_texture_format(ctx
, internalformat
))
505 case GL_TEXTURE_BUFFER
:
506 /* Based on what Mesa does for the glTexBuffer function. */
507 if (_mesa_validate_texbuffer_format(ctx
, internalformat
) ==
512 case GL_RENDERBUFFER
:
513 /* Based on what Mesa does for glRenderbufferStorage(Multisample) and
514 * glNamedRenderbufferStorage functions.
516 if (!_mesa_base_fbo_format(ctx
, internalformat
))
521 unreachable("bad target");
528 _is_internalformat_supported(struct gl_context
*ctx
, GLenum target
,
529 GLenum internalformat
)
531 /* From the ARB_internalformat_query2 specification:
533 * "- INTERNALFORMAT_SUPPORTED: If <internalformat> is an internal format
534 * that is supported by the implementation in at least some subset of
535 * possible operations, TRUE is written to <params>. If <internalformat>
536 * if not a valid token for any internal format usage, FALSE is returned.
538 * <internalformats> that must be supported (in GL 4.2 or later) include
540 * - "sized internal formats" from Table 3.12, 3.13, and 3.15,
541 * - any specific "compressed internal format" from Table 3.14,
542 * - any "image unit format" from Table 3.21.
543 * - any generic "compressed internal format" from Table 3.14, if the
544 * implementation accepts it for any texture specification commands, and
545 * - unsized or base internal format, if the implementation accepts
546 * it for texture or image specification.
550 /* At this point a internalformat is valid if it is valid as a texture or
551 * as a renderbuffer format. The checks are different because those methods
552 * return different values when passing non supported internalformats */
553 if (_mesa_base_tex_format(ctx
, internalformat
) < 0 &&
554 _mesa_base_fbo_format(ctx
, internalformat
) == 0)
557 /* Let the driver have the final word */
558 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
,
559 GL_INTERNALFORMAT_SUPPORTED
, buffer
);
561 return (buffer
[0] == GL_TRUE
);
564 /* default implementation of QueryInternalFormat driverfunc, for
565 * drivers not implementing ARB_internalformat_query2.
568 _mesa_query_internal_format_default(struct gl_context
*ctx
, GLenum target
,
569 GLenum internalFormat
, GLenum pname
,
574 (void) internalFormat
;
578 case GL_NUM_SAMPLE_COUNTS
:
582 case GL_INTERNALFORMAT_SUPPORTED
:
586 case GL_INTERNALFORMAT_PREFERRED
:
587 params
[0] = internalFormat
;
591 _set_default_response(pname
, params
);
597 _mesa_GetInternalformativ(GLenum target
, GLenum internalformat
, GLenum pname
,
598 GLsizei bufSize
, GLint
*params
)
601 GET_CURRENT_CONTEXT(ctx
);
603 ASSERT_OUTSIDE_BEGIN_END(ctx
);
605 /* ARB_internalformat_query is also mandatory for ARB_internalformat_query2 */
606 if (!(_mesa_has_ARB_internalformat_query(ctx
) ||
607 _mesa_is_gles3(ctx
))) {
608 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInternalformativ");
612 assert(ctx
->Driver
.QueryInternalFormat
!= NULL
);
614 if (!_legal_parameters(ctx
, target
, internalformat
, pname
, bufSize
, params
))
617 /* initialize the contents of the temporary buffer */
618 memcpy(buffer
, params
, MIN2(bufSize
, 16) * sizeof(GLint
));
620 /* Use the 'unsupported' response defined by the spec for every pname
621 * as the default answer.
623 _set_default_response(pname
, buffer
);
625 if (!_is_target_supported(ctx
, target
) ||
626 !_is_internalformat_supported(ctx
, target
, internalformat
) ||
627 !_is_resource_supported(ctx
, target
, internalformat
, pname
))
633 case GL_NUM_SAMPLE_COUNTS
:
634 /* The ARB_internalformat_query2 sets the response as 'unsupported' for
635 * SAMPLES and NUM_SAMPLE_COUNTS:
637 * "If <internalformat> is not color-renderable, depth-renderable, or
638 * stencil-renderable (as defined in section 4.4.4), or if <target>
639 * does not support multiple samples (ie other than
640 * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY,
643 if ((target
!= GL_RENDERBUFFER
&&
644 target
!= GL_TEXTURE_2D_MULTISAMPLE
&&
645 target
!= GL_TEXTURE_2D_MULTISAMPLE_ARRAY
) ||
646 !_is_renderable(ctx
, internalformat
))
649 /* The GL ES 3.0 specification, section 6.1.15 page 236 says:
651 * "Since multisampling is not supported for signed and unsigned
652 * integer internal formats, the value of NUM_SAMPLE_COUNTS will be
653 * zero for such formats.
655 if (pname
== GL_NUM_SAMPLE_COUNTS
&& ctx
->API
== API_OPENGLES2
&&
656 ctx
->Version
== 30 && _mesa_is_enum_format_integer(internalformat
)) {
660 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
664 case GL_INTERNALFORMAT_SUPPORTED
:
665 /* Having a supported <internalformat> is implemented as a prerequisite
666 * for all the <pnames>. Thus, if we reach this point, the internalformat is
672 case GL_INTERNALFORMAT_PREFERRED
:
673 /* The ARB_internalformat_query2 spec says:
675 * "- INTERNALFORMAT_PREFERRED: The implementation-preferred internal
676 * format for representing resources of the specified <internalformat> is
677 * returned in <params>.
679 * Therefore, we let the driver answer.
681 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
685 case GL_INTERNALFORMAT_RED_SIZE
:
686 case GL_INTERNALFORMAT_GREEN_SIZE
:
687 case GL_INTERNALFORMAT_BLUE_SIZE
:
688 case GL_INTERNALFORMAT_ALPHA_SIZE
:
689 case GL_INTERNALFORMAT_DEPTH_SIZE
:
690 case GL_INTERNALFORMAT_STENCIL_SIZE
:
691 case GL_INTERNALFORMAT_SHARED_SIZE
:
692 case GL_INTERNALFORMAT_RED_TYPE
:
693 case GL_INTERNALFORMAT_GREEN_TYPE
:
694 case GL_INTERNALFORMAT_BLUE_TYPE
:
695 case GL_INTERNALFORMAT_ALPHA_TYPE
:
696 case GL_INTERNALFORMAT_DEPTH_TYPE
:
697 case GL_INTERNALFORMAT_STENCIL_TYPE
: {
699 mesa_format texformat
;
701 if (target
!= GL_RENDERBUFFER
) {
702 if (!_mesa_legal_get_tex_level_parameter_target(ctx
, target
, true))
705 baseformat
= _mesa_base_tex_format(ctx
, internalformat
);
707 baseformat
= _mesa_base_fbo_format(ctx
, internalformat
);
710 /* Let the driver choose the texture format.
712 * Disclaimer: I am considering that drivers use for renderbuffers the
713 * same format-choice logic as for textures.
715 texformat
= ctx
->Driver
.ChooseTextureFormat(ctx
, target
, internalformat
,
716 GL_NONE
/*format */, GL_NONE
/* type */);
718 if (texformat
== MESA_FORMAT_NONE
|| baseformat
<= 0)
721 /* Implementation based on what Mesa does for glGetTexLevelParameteriv
722 * and glGetRenderbufferParameteriv functions.
724 if (pname
== GL_INTERNALFORMAT_SHARED_SIZE
) {
725 if (_mesa_has_EXT_texture_shared_exponent(ctx
) &&
726 target
!= GL_TEXTURE_BUFFER
&&
727 target
!= GL_RENDERBUFFER
&&
728 texformat
== MESA_FORMAT_R9G9B9E5_FLOAT
) {
734 if (!_mesa_base_format_has_channel(baseformat
, pname
))
738 case GL_INTERNALFORMAT_DEPTH_SIZE
:
739 if (!_mesa_has_ARB_depth_texture(ctx
) &&
740 target
!= GL_RENDERBUFFER
&&
741 target
!= GL_TEXTURE_BUFFER
)
744 case GL_INTERNALFORMAT_RED_SIZE
:
745 case GL_INTERNALFORMAT_GREEN_SIZE
:
746 case GL_INTERNALFORMAT_BLUE_SIZE
:
747 case GL_INTERNALFORMAT_ALPHA_SIZE
:
748 case GL_INTERNALFORMAT_STENCIL_SIZE
:
749 buffer
[0] = _mesa_get_format_bits(texformat
, pname
);
752 case GL_INTERNALFORMAT_DEPTH_TYPE
:
753 if (!_mesa_has_ARB_texture_float(ctx
))
756 case GL_INTERNALFORMAT_RED_TYPE
:
757 case GL_INTERNALFORMAT_GREEN_TYPE
:
758 case GL_INTERNALFORMAT_BLUE_TYPE
:
759 case GL_INTERNALFORMAT_ALPHA_TYPE
:
760 case GL_INTERNALFORMAT_STENCIL_TYPE
:
761 buffer
[0] = _mesa_get_format_datatype(texformat
);
787 case GL_MAX_COMBINED_DIMENSIONS
:
791 case GL_COLOR_COMPONENTS
:
795 case GL_DEPTH_COMPONENTS
:
799 case GL_STENCIL_COMPONENTS
:
803 case GL_COLOR_RENDERABLE
:
807 case GL_DEPTH_RENDERABLE
:
811 case GL_STENCIL_RENDERABLE
:
815 case GL_FRAMEBUFFER_RENDERABLE
:
819 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
823 case GL_FRAMEBUFFER_BLEND
:
831 case GL_READ_PIXELS_FORMAT
:
835 case GL_READ_PIXELS_TYPE
:
839 case GL_TEXTURE_IMAGE_FORMAT
:
843 case GL_TEXTURE_IMAGE_TYPE
:
847 case GL_GET_TEXTURE_IMAGE_FORMAT
:
851 case GL_GET_TEXTURE_IMAGE_TYPE
:
859 case GL_MANUAL_GENERATE_MIPMAP
:
863 case GL_AUTO_GENERATE_MIPMAP
:
867 case GL_COLOR_ENCODING
:
879 case GL_SRGB_DECODE_ARB
:
887 case GL_VERTEX_TEXTURE
:
891 case GL_TESS_CONTROL_TEXTURE
:
895 case GL_TESS_EVALUATION_TEXTURE
:
899 case GL_GEOMETRY_TEXTURE
:
903 case GL_FRAGMENT_TEXTURE
:
907 case GL_COMPUTE_TEXTURE
:
911 case GL_TEXTURE_SHADOW
:
915 case GL_TEXTURE_GATHER
:
919 case GL_TEXTURE_GATHER_SHADOW
:
923 case GL_SHADER_IMAGE_LOAD
:
927 case GL_SHADER_IMAGE_STORE
:
931 case GL_SHADER_IMAGE_ATOMIC
:
935 case GL_IMAGE_TEXEL_SIZE
:
939 case GL_IMAGE_COMPATIBILITY_CLASS
:
943 case GL_IMAGE_PIXEL_FORMAT
:
947 case GL_IMAGE_PIXEL_TYPE
:
951 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
955 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
959 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
963 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
967 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
971 case GL_TEXTURE_COMPRESSED
:
975 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
979 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
983 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
:
987 case GL_CLEAR_BUFFER
:
991 case GL_TEXTURE_VIEW
:
995 case GL_VIEW_COMPATIBILITY_CLASS
:
1000 unreachable("bad param");
1004 if (bufSize
!= 0 && params
== NULL
) {
1005 /* Emit a warning to aid application debugging, but go ahead and do the
1006 * memcpy (and probably crash) anyway.
1009 "glGetInternalformativ(bufSize = %d, but params = NULL)",
1013 /* Copy the data from the temporary buffer to the buffer supplied by the
1014 * application. Clamp the size of the copy to the size supplied by the
1017 memcpy(params
, buffer
, MIN2(bufSize
, 16) * sizeof(GLint
));
1023 _mesa_GetInternalformati64v(GLenum target
, GLenum internalformat
,
1024 GLenum pname
, GLsizei bufSize
, GLint64
*params
)
1026 GET_CURRENT_CONTEXT(ctx
);
1028 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1030 if (!_mesa_has_ARB_internalformat_query2(ctx
)) {
1031 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInternalformati64v");
1035 _mesa_debug(ctx
, "glGetInternalformati64v() not implemented");