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 #include "genmipmap.h"
36 #include "shaderimage.h"
37 #include "texcompress.h"
38 #include "textureview.h"
41 _is_renderable(struct gl_context
*ctx
, GLenum internalformat
)
43 /* Section 4.4.4 on page 212 of the GLES 3.0.4 spec says:
45 * "An internal format is color-renderable if it is one of the
46 * formats from table 3.13 noted as color-renderable or if it
47 * is unsized format RGBA or RGB."
49 * Therefore, we must accept GL_RGB and GL_RGBA here.
51 if (internalformat
!= GL_RGB
&& internalformat
!= GL_RGBA
&&
52 _mesa_base_fbo_format(ctx
, internalformat
) == 0)
58 /* Handles the cases where either ARB_internalformat_query or
59 * ARB_internalformat_query2 have to return an error.
62 _legal_parameters(struct gl_context
*ctx
, GLenum target
, GLenum internalformat
,
63 GLenum pname
, GLsizei bufSize
, GLint
*params
)
66 bool query2
= _mesa_has_ARB_internalformat_query2(ctx
);
68 /* The ARB_internalformat_query2 spec says:
70 * "The INVALID_ENUM error is generated if the <target> parameter to
71 * GetInternalformati*v is not one of the targets listed in Table 6.xx.
75 case GL_TEXTURE_1D_ARRAY
:
77 case GL_TEXTURE_2D_ARRAY
:
79 case GL_TEXTURE_CUBE_MAP
:
80 case GL_TEXTURE_CUBE_MAP_ARRAY
:
81 case GL_TEXTURE_RECTANGLE
:
82 case GL_TEXTURE_BUFFER
:
84 /* The ARB_internalformat_query spec says:
86 * "If the <target> parameter to GetInternalformativ is not one of
87 * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY
88 * or RENDERBUFFER then an INVALID_ENUM error is generated.
90 _mesa_error(ctx
, GL_INVALID_ENUM
,
91 "glGetInternalformativ(target=%s)",
92 _mesa_enum_to_string(target
));
101 case GL_TEXTURE_2D_MULTISAMPLE
:
102 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
103 /* The non-existence of ARB_texture_multisample is treated in
104 * ARB_internalformat_query implementation like an error.
107 !(_mesa_has_ARB_texture_multisample(ctx
) || _mesa_is_gles31(ctx
))) {
108 _mesa_error(ctx
, GL_INVALID_ENUM
,
109 "glGetInternalformativ(target=%s)",
110 _mesa_enum_to_string(target
));
117 _mesa_error(ctx
, GL_INVALID_ENUM
,
118 "glGetInternalformativ(target=%s)",
119 _mesa_enum_to_string(target
));
124 /* The ARB_internalformat_query2 spec says:
126 * "The INVALID_ENUM error is generated if the <pname> parameter is
127 * not one of the listed possibilities.
131 case GL_NUM_SAMPLE_COUNTS
:
134 case GL_SRGB_DECODE_ARB
:
135 /* The ARB_internalformat_query2 spec says:
137 * "If ARB_texture_sRGB_decode or EXT_texture_sRGB_decode or
138 * equivalent functionality is not supported, queries for the
139 * SRGB_DECODE_ARB <pname> set the INVALID_ENUM error.
141 if (!_mesa_has_EXT_texture_sRGB_decode(ctx
)) {
142 _mesa_error(ctx
, GL_INVALID_ENUM
,
143 "glGetInternalformativ(pname=%s)",
144 _mesa_enum_to_string(pname
));
148 case GL_INTERNALFORMAT_SUPPORTED
:
149 case GL_INTERNALFORMAT_PREFERRED
:
150 case GL_INTERNALFORMAT_RED_SIZE
:
151 case GL_INTERNALFORMAT_GREEN_SIZE
:
152 case GL_INTERNALFORMAT_BLUE_SIZE
:
153 case GL_INTERNALFORMAT_ALPHA_SIZE
:
154 case GL_INTERNALFORMAT_DEPTH_SIZE
:
155 case GL_INTERNALFORMAT_STENCIL_SIZE
:
156 case GL_INTERNALFORMAT_SHARED_SIZE
:
157 case GL_INTERNALFORMAT_RED_TYPE
:
158 case GL_INTERNALFORMAT_GREEN_TYPE
:
159 case GL_INTERNALFORMAT_BLUE_TYPE
:
160 case GL_INTERNALFORMAT_ALPHA_TYPE
:
161 case GL_INTERNALFORMAT_DEPTH_TYPE
:
162 case GL_INTERNALFORMAT_STENCIL_TYPE
:
167 case GL_MAX_COMBINED_DIMENSIONS
:
168 case GL_COLOR_COMPONENTS
:
169 case GL_DEPTH_COMPONENTS
:
170 case GL_STENCIL_COMPONENTS
:
171 case GL_COLOR_RENDERABLE
:
172 case GL_DEPTH_RENDERABLE
:
173 case GL_STENCIL_RENDERABLE
:
174 case GL_FRAMEBUFFER_RENDERABLE
:
175 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
176 case GL_FRAMEBUFFER_BLEND
:
178 case GL_READ_PIXELS_FORMAT
:
179 case GL_READ_PIXELS_TYPE
:
180 case GL_TEXTURE_IMAGE_FORMAT
:
181 case GL_TEXTURE_IMAGE_TYPE
:
182 case GL_GET_TEXTURE_IMAGE_FORMAT
:
183 case GL_GET_TEXTURE_IMAGE_TYPE
:
185 case GL_MANUAL_GENERATE_MIPMAP
:
186 case GL_AUTO_GENERATE_MIPMAP
:
187 case GL_COLOR_ENCODING
:
191 case GL_VERTEX_TEXTURE
:
192 case GL_TESS_CONTROL_TEXTURE
:
193 case GL_TESS_EVALUATION_TEXTURE
:
194 case GL_GEOMETRY_TEXTURE
:
195 case GL_FRAGMENT_TEXTURE
:
196 case GL_COMPUTE_TEXTURE
:
197 case GL_TEXTURE_SHADOW
:
198 case GL_TEXTURE_GATHER
:
199 case GL_TEXTURE_GATHER_SHADOW
:
200 case GL_SHADER_IMAGE_LOAD
:
201 case GL_SHADER_IMAGE_STORE
:
202 case GL_SHADER_IMAGE_ATOMIC
:
203 case GL_IMAGE_TEXEL_SIZE
:
204 case GL_IMAGE_COMPATIBILITY_CLASS
:
205 case GL_IMAGE_PIXEL_FORMAT
:
206 case GL_IMAGE_PIXEL_TYPE
:
207 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
208 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
209 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
210 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
211 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
212 case GL_TEXTURE_COMPRESSED
:
213 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
214 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
215 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
:
216 case GL_CLEAR_BUFFER
:
217 case GL_TEXTURE_VIEW
:
218 case GL_VIEW_COMPATIBILITY_CLASS
:
219 /* The ARB_internalformat_query spec says:
221 * "If the <pname> parameter to GetInternalformativ is not SAMPLES
222 * or NUM_SAMPLE_COUNTS, then an INVALID_ENUM error is generated."
225 _mesa_error(ctx
, GL_INVALID_ENUM
,
226 "glGetInternalformativ(pname=%s)",
227 _mesa_enum_to_string(pname
));
234 _mesa_error(ctx
, GL_INVALID_ENUM
,
235 "glGetInternalformativ(pname=%s)",
236 _mesa_enum_to_string(pname
));
240 /* The ARB_internalformat_query spec says:
242 * "If the <bufSize> parameter to GetInternalformativ is negative, then
243 * an INVALID_VALUE error is generated."
245 * Nothing is said in ARB_internalformat_query2 but we assume the same.
248 _mesa_error(ctx
, GL_INVALID_VALUE
,
249 "glGetInternalformativ(target=%s)",
250 _mesa_enum_to_string(target
));
254 /* The ARB_internalformat_query spec says:
256 * "If the <internalformat> parameter to GetInternalformativ is not
257 * color-, depth- or stencil-renderable, then an INVALID_ENUM error is
260 if (!query2
&& !_is_renderable(ctx
, internalformat
)) {
261 _mesa_error(ctx
, GL_INVALID_ENUM
,
262 "glGetInternalformativ(internalformat=%s)",
263 _mesa_enum_to_string(internalformat
));
270 /* Sets the appropriate "unsupported" response as defined by the
271 * ARB_internalformat_query2 spec for each each <pname>.
274 _set_default_response(GLenum pname
, GLint buffer
[16])
276 /* The ARB_internalformat_query2 defines which is the reponse best
277 * representing "not supported" or "not applicable" for each <pname>.
280 * - size- or count-based queries will return zero,
281 * - support-, format- or type-based queries will return NONE,
282 * - boolean-based queries will return FALSE, and
283 * - list-based queries return no entries."
289 case GL_MAX_COMBINED_DIMENSIONS
:
290 /* This value can be a 64-bit value. As the default is the 32-bit query,
291 * we pack 2 32-bit integers. So we need to clean both */
296 case GL_NUM_SAMPLE_COUNTS
:
297 case GL_INTERNALFORMAT_RED_SIZE
:
298 case GL_INTERNALFORMAT_GREEN_SIZE
:
299 case GL_INTERNALFORMAT_BLUE_SIZE
:
300 case GL_INTERNALFORMAT_ALPHA_SIZE
:
301 case GL_INTERNALFORMAT_DEPTH_SIZE
:
302 case GL_INTERNALFORMAT_STENCIL_SIZE
:
303 case GL_INTERNALFORMAT_SHARED_SIZE
:
308 case GL_IMAGE_TEXEL_SIZE
:
309 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
310 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
311 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
:
315 case GL_INTERNALFORMAT_PREFERRED
:
316 case GL_INTERNALFORMAT_RED_TYPE
:
317 case GL_INTERNALFORMAT_GREEN_TYPE
:
318 case GL_INTERNALFORMAT_BLUE_TYPE
:
319 case GL_INTERNALFORMAT_ALPHA_TYPE
:
320 case GL_INTERNALFORMAT_DEPTH_TYPE
:
321 case GL_INTERNALFORMAT_STENCIL_TYPE
:
322 case GL_FRAMEBUFFER_RENDERABLE
:
323 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
324 case GL_FRAMEBUFFER_BLEND
:
326 case GL_READ_PIXELS_FORMAT
:
327 case GL_READ_PIXELS_TYPE
:
328 case GL_TEXTURE_IMAGE_FORMAT
:
329 case GL_TEXTURE_IMAGE_TYPE
:
330 case GL_GET_TEXTURE_IMAGE_FORMAT
:
331 case GL_GET_TEXTURE_IMAGE_TYPE
:
332 case GL_MANUAL_GENERATE_MIPMAP
:
333 case GL_AUTO_GENERATE_MIPMAP
:
334 case GL_COLOR_ENCODING
:
337 case GL_SRGB_DECODE_ARB
:
339 case GL_VERTEX_TEXTURE
:
340 case GL_TESS_CONTROL_TEXTURE
:
341 case GL_TESS_EVALUATION_TEXTURE
:
342 case GL_GEOMETRY_TEXTURE
:
343 case GL_FRAGMENT_TEXTURE
:
344 case GL_COMPUTE_TEXTURE
:
345 case GL_TEXTURE_SHADOW
:
346 case GL_TEXTURE_GATHER
:
347 case GL_TEXTURE_GATHER_SHADOW
:
348 case GL_SHADER_IMAGE_LOAD
:
349 case GL_SHADER_IMAGE_STORE
:
350 case GL_SHADER_IMAGE_ATOMIC
:
351 case GL_IMAGE_COMPATIBILITY_CLASS
:
352 case GL_IMAGE_PIXEL_FORMAT
:
353 case GL_IMAGE_PIXEL_TYPE
:
354 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
:
355 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
356 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
357 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
358 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
359 case GL_CLEAR_BUFFER
:
360 case GL_TEXTURE_VIEW
:
361 case GL_VIEW_COMPATIBILITY_CLASS
:
365 case GL_INTERNALFORMAT_SUPPORTED
:
366 case GL_COLOR_COMPONENTS
:
367 case GL_DEPTH_COMPONENTS
:
368 case GL_STENCIL_COMPONENTS
:
369 case GL_COLOR_RENDERABLE
:
370 case GL_DEPTH_RENDERABLE
:
371 case GL_STENCIL_RENDERABLE
:
373 case GL_TEXTURE_COMPRESSED
:
374 buffer
[0] = GL_FALSE
;
378 unreachable("invalid 'pname'");
383 _is_target_supported(struct gl_context
*ctx
, GLenum target
)
385 /* The ARB_internalformat_query2 spec says:
387 * "if a particular type of <target> is not supported by the
388 * implementation the "unsupported" answer should be given.
389 * This is not an error."
397 if (!_mesa_is_desktop_gl(ctx
))
401 case GL_TEXTURE_1D_ARRAY
:
402 if (!_mesa_has_EXT_texture_array(ctx
))
406 case GL_TEXTURE_2D_ARRAY
:
407 if (!(_mesa_has_EXT_texture_array(ctx
) || _mesa_is_gles3(ctx
)))
411 case GL_TEXTURE_CUBE_MAP
:
412 if (!_mesa_has_ARB_texture_cube_map(ctx
))
416 case GL_TEXTURE_CUBE_MAP_ARRAY
:
417 if (!_mesa_has_ARB_texture_cube_map_array(ctx
))
421 case GL_TEXTURE_RECTANGLE
:
422 if (!_mesa_has_NV_texture_rectangle(ctx
))
426 case GL_TEXTURE_BUFFER
:
427 if (!_mesa_has_ARB_texture_buffer_object(ctx
))
431 case GL_RENDERBUFFER
:
432 if (!(_mesa_has_ARB_framebuffer_object(ctx
) ||
433 _mesa_is_gles3(ctx
)))
437 case GL_TEXTURE_2D_MULTISAMPLE
:
438 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
439 if (!(_mesa_has_ARB_texture_multisample(ctx
) ||
440 _mesa_is_gles31(ctx
)))
445 unreachable("invalid target");
452 _is_resource_supported(struct gl_context
*ctx
, GLenum target
,
453 GLenum internalformat
, GLenum pname
)
455 /* From the ARB_internalformat_query2 spec:
457 * In the following descriptions, the term /resource/ is used to generically
458 * refer to an object of the appropriate type that has been created with
459 * <internalformat> and <target>. If the particular <target> and
460 * <internalformat> combination do not make sense, ... the "unsupported"
461 * answer should be given. This is not an error.
464 /* In the ARB_internalformat_query2 spec wording, some <pnames> do not care
465 * about the /resource/ being supported or not, we return 'true' for those.
468 case GL_INTERNALFORMAT_SUPPORTED
:
469 case GL_INTERNALFORMAT_PREFERRED
:
470 case GL_COLOR_COMPONENTS
:
471 case GL_DEPTH_COMPONENTS
:
472 case GL_STENCIL_COMPONENTS
:
473 case GL_COLOR_RENDERABLE
:
474 case GL_DEPTH_RENDERABLE
:
475 case GL_STENCIL_RENDERABLE
:
483 case GL_TEXTURE_1D_ARRAY
:
485 case GL_TEXTURE_2D_ARRAY
:
487 case GL_TEXTURE_CUBE_MAP
:
488 case GL_TEXTURE_CUBE_MAP_ARRAY
:
489 case GL_TEXTURE_RECTANGLE
:
490 /* Based on what Mesa does for glTexImage1D/2D/3D and
491 * glCompressedTexImage1D/2D/3D functions.
493 if (_mesa_base_tex_format(ctx
, internalformat
) < 0)
496 /* additional checks for depth textures */
497 if (!_mesa_legal_texture_base_format_for_target(ctx
, target
, internalformat
))
500 /* additional checks for compressed textures */
501 if (_mesa_is_compressed_format(ctx
, internalformat
) &&
502 (!_mesa_target_can_be_compressed(ctx
, target
, internalformat
, NULL
) ||
503 _mesa_format_no_online_compression(ctx
, internalformat
)))
507 case GL_TEXTURE_2D_MULTISAMPLE
:
508 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
509 /* Based on what Mesa does for glTexImage2D/3DMultisample,
510 * glTexStorage2D/3DMultisample and
511 * glTextureStorage2D/3DMultisample functions.
513 if (!_mesa_is_renderable_texture_format(ctx
, internalformat
))
517 case GL_TEXTURE_BUFFER
:
518 /* Based on what Mesa does for the glTexBuffer function. */
519 if (_mesa_validate_texbuffer_format(ctx
, internalformat
) ==
524 case GL_RENDERBUFFER
:
525 /* Based on what Mesa does for glRenderbufferStorage(Multisample) and
526 * glNamedRenderbufferStorage functions.
528 if (!_mesa_base_fbo_format(ctx
, internalformat
))
533 unreachable("bad target");
540 _is_internalformat_supported(struct gl_context
*ctx
, GLenum target
,
541 GLenum internalformat
)
543 /* From the ARB_internalformat_query2 specification:
545 * "- INTERNALFORMAT_SUPPORTED: If <internalformat> is an internal format
546 * that is supported by the implementation in at least some subset of
547 * possible operations, TRUE is written to <params>. If <internalformat>
548 * if not a valid token for any internal format usage, FALSE is returned.
550 * <internalformats> that must be supported (in GL 4.2 or later) include
552 * - "sized internal formats" from Table 3.12, 3.13, and 3.15,
553 * - any specific "compressed internal format" from Table 3.14,
554 * - any "image unit format" from Table 3.21.
555 * - any generic "compressed internal format" from Table 3.14, if the
556 * implementation accepts it for any texture specification commands, and
557 * - unsized or base internal format, if the implementation accepts
558 * it for texture or image specification.
562 /* At this point a internalformat is valid if it is valid as a texture or
563 * as a renderbuffer format. The checks are different because those methods
564 * return different values when passing non supported internalformats */
565 if (_mesa_base_tex_format(ctx
, internalformat
) < 0 &&
566 _mesa_base_fbo_format(ctx
, internalformat
) == 0)
569 /* Let the driver have the final word */
570 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
,
571 GL_INTERNALFORMAT_SUPPORTED
, buffer
);
573 return (buffer
[0] == GL_TRUE
);
577 _legal_target_for_framebuffer_texture_layer(struct gl_context
*ctx
,
582 case GL_TEXTURE_1D_ARRAY
:
583 case GL_TEXTURE_2D_ARRAY
:
584 case GL_TEXTURE_CUBE_MAP_ARRAY
:
585 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
586 case GL_TEXTURE_CUBE_MAP
:
594 _mesa_generic_type_for_internal_format(GLenum internalFormat
)
596 if (_mesa_is_enum_format_unsigned_int(internalFormat
))
597 return GL_UNSIGNED_BYTE
;
598 else if (_mesa_is_enum_format_signed_int(internalFormat
))
604 /* default implementation of QueryInternalFormat driverfunc, for
605 * drivers not implementing ARB_internalformat_query2.
608 _mesa_query_internal_format_default(struct gl_context
*ctx
, GLenum target
,
609 GLenum internalFormat
, GLenum pname
,
616 case GL_NUM_SAMPLE_COUNTS
:
620 case GL_INTERNALFORMAT_SUPPORTED
:
624 case GL_INTERNALFORMAT_PREFERRED
:
625 params
[0] = internalFormat
;
628 case GL_READ_PIXELS_FORMAT
: {
629 GLenum base_format
= _mesa_base_tex_format(ctx
, internalFormat
);
630 switch (base_format
) {
631 case GL_STENCIL_INDEX
:
632 case GL_DEPTH_COMPONENT
:
633 case GL_DEPTH_STENCIL
:
639 params
[0] = base_format
;
648 case GL_READ_PIXELS_TYPE
: {
649 GLenum base_format
= _mesa_base_tex_format(ctx
, internalFormat
);
651 params
[0] = _mesa_generic_type_for_internal_format(internalFormat
);
657 case GL_TEXTURE_IMAGE_FORMAT
:
658 case GL_GET_TEXTURE_IMAGE_FORMAT
: {
659 GLenum format
= GL_NONE
;
660 GLenum base_format
= _mesa_base_tex_format(ctx
, internalFormat
);
661 if (base_format
> 0) {
662 if (_mesa_is_enum_format_integer(internalFormat
))
663 format
= _mesa_base_format_to_integer_format(base_format
);
665 format
= base_format
;
672 case GL_MANUAL_GENERATE_MIPMAP
:
673 case GL_AUTO_GENERATE_MIPMAP
:
676 case GL_SRGB_DECODE_ARB
:
677 case GL_VERTEX_TEXTURE
:
678 case GL_TESS_CONTROL_TEXTURE
:
679 case GL_TESS_EVALUATION_TEXTURE
:
680 case GL_GEOMETRY_TEXTURE
:
681 case GL_FRAGMENT_TEXTURE
:
682 case GL_COMPUTE_TEXTURE
:
683 case GL_SHADER_IMAGE_LOAD
:
684 case GL_SHADER_IMAGE_STORE
:
685 case GL_SHADER_IMAGE_ATOMIC
:
686 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
687 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
688 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
689 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
690 case GL_CLEAR_BUFFER
:
691 case GL_TEXTURE_VIEW
:
692 case GL_TEXTURE_SHADOW
:
693 case GL_TEXTURE_GATHER
:
694 case GL_TEXTURE_GATHER_SHADOW
:
695 case GL_FRAMEBUFFER_RENDERABLE
:
696 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
697 case GL_FRAMEBUFFER_BLEND
:
699 params
[0] = GL_FULL_SUPPORT
;
703 _set_default_response(pname
, params
);
709 * For MAX_WIDTH/MAX_HEIGHT/MAX_DEPTH it returns the equivalent GetInteger
710 * pname for a Getinternalformat pname/target combination. target/pname
711 * combinations that would return 0 due dimension number or unsupported status
712 * should be already filtered out
714 * Note that this means that the returned value would be independent of the
715 * internalformat. This possibility is already mentioned at the Issue 7 of the
716 * arb_internalformat_query2 spec.
719 equivalentSizePname(GLenum target
,
725 case GL_TEXTURE_2D_MULTISAMPLE
:
726 return GL_MAX_TEXTURE_SIZE
;
728 return GL_MAX_3D_TEXTURE_SIZE
;
729 case GL_TEXTURE_CUBE_MAP
:
730 return GL_MAX_CUBE_MAP_TEXTURE_SIZE
;
731 case GL_TEXTURE_RECTANGLE
:
732 return GL_MAX_RECTANGLE_TEXTURE_SIZE
;
733 case GL_RENDERBUFFER
:
734 return GL_MAX_RENDERBUFFER_SIZE
;
735 case GL_TEXTURE_1D_ARRAY
:
736 if (pname
== GL_MAX_HEIGHT
)
737 return GL_MAX_ARRAY_TEXTURE_LAYERS
;
739 return GL_MAX_TEXTURE_SIZE
;
740 case GL_TEXTURE_2D_ARRAY
:
741 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
742 if (pname
== GL_MAX_DEPTH
)
743 return GL_MAX_ARRAY_TEXTURE_LAYERS
;
745 return GL_MAX_TEXTURE_SIZE
;
746 case GL_TEXTURE_CUBE_MAP_ARRAY
:
747 if (pname
== GL_MAX_DEPTH
)
748 return GL_MAX_ARRAY_TEXTURE_LAYERS
;
750 return GL_MAX_CUBE_MAP_TEXTURE_SIZE
;
751 case GL_TEXTURE_BUFFER
:
752 return GL_MAX_TEXTURE_BUFFER_SIZE
;
759 * Returns the dimensions associated to a target. GL_TEXTURE_BUFFER and
760 * GL_RENDERBUFFER have associated a dimension, but they are not textures
761 * per-se, so we can't just call _mesa_get_texture_dimension directly.
764 get_target_dimensions(GLenum target
)
767 case GL_TEXTURE_BUFFER
:
769 case GL_RENDERBUFFER
:
772 return _mesa_get_texture_dimensions(target
);
777 * Returns the minimum amount of dimensions associated to a pname. So for
778 * example, if querying GL_MAX_HEIGHT, it is assumed that your target would
779 * have as minimum 2 dimensions.
781 * Useful to handle sentences like this from query2 spec:
785 * If the resource does not have at least two dimensions
789 get_min_dimensions(GLenum pname
)
804 * Similar to teximage.c:check_multisample_target, but independent of the
808 is_multisample_target(GLenum target
)
811 case GL_TEXTURE_2D_MULTISAMPLE
:
812 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
821 _mesa_GetInternalformativ(GLenum target
, GLenum internalformat
, GLenum pname
,
822 GLsizei bufSize
, GLint
*params
)
825 GET_CURRENT_CONTEXT(ctx
);
827 ASSERT_OUTSIDE_BEGIN_END(ctx
);
829 /* ARB_internalformat_query is also mandatory for ARB_internalformat_query2 */
830 if (!(_mesa_has_ARB_internalformat_query(ctx
) ||
831 _mesa_is_gles3(ctx
))) {
832 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInternalformativ");
836 assert(ctx
->Driver
.QueryInternalFormat
!= NULL
);
838 if (!_legal_parameters(ctx
, target
, internalformat
, pname
, bufSize
, params
))
841 /* initialize the contents of the temporary buffer */
842 memcpy(buffer
, params
, MIN2(bufSize
, 16) * sizeof(GLint
));
844 /* Use the 'unsupported' response defined by the spec for every pname
845 * as the default answer.
847 _set_default_response(pname
, buffer
);
849 if (!_is_target_supported(ctx
, target
) ||
850 !_is_internalformat_supported(ctx
, target
, internalformat
) ||
851 !_is_resource_supported(ctx
, target
, internalformat
, pname
))
857 case GL_NUM_SAMPLE_COUNTS
:
858 /* The ARB_internalformat_query2 sets the response as 'unsupported' for
859 * SAMPLES and NUM_SAMPLE_COUNTS:
861 * "If <internalformat> is not color-renderable, depth-renderable, or
862 * stencil-renderable (as defined in section 4.4.4), or if <target>
863 * does not support multiple samples (ie other than
864 * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY,
867 if ((target
!= GL_RENDERBUFFER
&&
868 target
!= GL_TEXTURE_2D_MULTISAMPLE
&&
869 target
!= GL_TEXTURE_2D_MULTISAMPLE_ARRAY
) ||
870 !_is_renderable(ctx
, internalformat
))
873 /* The GL ES 3.0 specification, section 6.1.15 page 236 says:
875 * "Since multisampling is not supported for signed and unsigned
876 * integer internal formats, the value of NUM_SAMPLE_COUNTS will be
877 * zero for such formats.
879 if (pname
== GL_NUM_SAMPLE_COUNTS
&& ctx
->API
== API_OPENGLES2
&&
880 ctx
->Version
== 30 && _mesa_is_enum_format_integer(internalformat
)) {
884 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
888 case GL_INTERNALFORMAT_SUPPORTED
:
889 /* Having a supported <internalformat> is implemented as a prerequisite
890 * for all the <pnames>. Thus, if we reach this point, the internalformat is
896 case GL_INTERNALFORMAT_PREFERRED
:
897 /* The ARB_internalformat_query2 spec says:
899 * "- INTERNALFORMAT_PREFERRED: The implementation-preferred internal
900 * format for representing resources of the specified <internalformat> is
901 * returned in <params>.
903 * Therefore, we let the driver answer.
905 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
909 case GL_INTERNALFORMAT_RED_SIZE
:
910 case GL_INTERNALFORMAT_GREEN_SIZE
:
911 case GL_INTERNALFORMAT_BLUE_SIZE
:
912 case GL_INTERNALFORMAT_ALPHA_SIZE
:
913 case GL_INTERNALFORMAT_DEPTH_SIZE
:
914 case GL_INTERNALFORMAT_STENCIL_SIZE
:
915 case GL_INTERNALFORMAT_SHARED_SIZE
:
916 case GL_INTERNALFORMAT_RED_TYPE
:
917 case GL_INTERNALFORMAT_GREEN_TYPE
:
918 case GL_INTERNALFORMAT_BLUE_TYPE
:
919 case GL_INTERNALFORMAT_ALPHA_TYPE
:
920 case GL_INTERNALFORMAT_DEPTH_TYPE
:
921 case GL_INTERNALFORMAT_STENCIL_TYPE
: {
923 mesa_format texformat
;
925 if (target
!= GL_RENDERBUFFER
) {
926 if (!_mesa_legal_get_tex_level_parameter_target(ctx
, target
, true))
929 baseformat
= _mesa_base_tex_format(ctx
, internalformat
);
931 baseformat
= _mesa_base_fbo_format(ctx
, internalformat
);
934 /* Let the driver choose the texture format.
936 * Disclaimer: I am considering that drivers use for renderbuffers the
937 * same format-choice logic as for textures.
939 texformat
= ctx
->Driver
.ChooseTextureFormat(ctx
, target
, internalformat
,
940 GL_NONE
/*format */, GL_NONE
/* type */);
942 if (texformat
== MESA_FORMAT_NONE
|| baseformat
<= 0)
945 /* Implementation based on what Mesa does for glGetTexLevelParameteriv
946 * and glGetRenderbufferParameteriv functions.
948 if (pname
== GL_INTERNALFORMAT_SHARED_SIZE
) {
949 if (_mesa_has_EXT_texture_shared_exponent(ctx
) &&
950 target
!= GL_TEXTURE_BUFFER
&&
951 target
!= GL_RENDERBUFFER
&&
952 texformat
== MESA_FORMAT_R9G9B9E5_FLOAT
) {
958 if (!_mesa_base_format_has_channel(baseformat
, pname
))
962 case GL_INTERNALFORMAT_DEPTH_SIZE
:
963 if (!_mesa_has_ARB_depth_texture(ctx
) &&
964 target
!= GL_RENDERBUFFER
&&
965 target
!= GL_TEXTURE_BUFFER
)
968 case GL_INTERNALFORMAT_RED_SIZE
:
969 case GL_INTERNALFORMAT_GREEN_SIZE
:
970 case GL_INTERNALFORMAT_BLUE_SIZE
:
971 case GL_INTERNALFORMAT_ALPHA_SIZE
:
972 case GL_INTERNALFORMAT_STENCIL_SIZE
:
973 buffer
[0] = _mesa_get_format_bits(texformat
, pname
);
976 case GL_INTERNALFORMAT_DEPTH_TYPE
:
977 if (!_mesa_has_ARB_texture_float(ctx
))
980 case GL_INTERNALFORMAT_RED_TYPE
:
981 case GL_INTERNALFORMAT_GREEN_TYPE
:
982 case GL_INTERNALFORMAT_BLUE_TYPE
:
983 case GL_INTERNALFORMAT_ALPHA_TYPE
:
984 case GL_INTERNALFORMAT_STENCIL_TYPE
:
985 buffer
[0] = _mesa_get_format_datatype(texformat
);
995 /* For WIDTH/HEIGHT/DEPTH/LAYERS there is no reason to think that the
996 * returned values should be different to the values returned by
997 * GetInteger with MAX_TEXTURE_SIZE, MAX_3D_TEXTURE_SIZE, etc.*/
1000 case GL_MAX_DEPTH
: {
1003 GLint min_dimensions
;
1005 /* From query2:MAX_HEIGHT spec (as example):
1007 * "If the resource does not have at least two dimensions, or if the
1008 * resource is unsupported, zero is returned."
1010 dimensions
= get_target_dimensions(target
);
1011 min_dimensions
= get_min_dimensions(pname
);
1012 if (dimensions
< min_dimensions
)
1015 get_pname
= equivalentSizePname(target
, pname
);
1019 _mesa_GetIntegerv(get_pname
, buffer
);
1024 if (!_mesa_has_EXT_texture_array(ctx
))
1027 if (!_mesa_is_array_texture(target
))
1030 _mesa_GetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS
, buffer
);
1033 case GL_MAX_COMBINED_DIMENSIONS
:{
1034 GLint64 combined_value
= 1;
1035 GLenum max_dimensions_pnames
[] = {
1042 GLint current_value
;
1044 /* Combining the dimensions. Note that for array targets, this would
1045 * automatically include the value of MAX_LAYERS, as that value is
1046 * returned as MAX_HEIGHT or MAX_DEPTH */
1047 for (i
= 0; i
< 4; i
++) {
1048 if (max_dimensions_pnames
[i
] == GL_SAMPLES
&&
1049 !is_multisample_target(target
))
1052 _mesa_GetInternalformativ(target
, internalformat
,
1053 max_dimensions_pnames
[i
],
1056 if (current_value
!= 0)
1057 combined_value
*= current_value
;
1060 if (_mesa_is_cube_map_texture(target
))
1061 combined_value
*= 6;
1063 /* We pack the 64-bit value on two 32-bit values. Calling the 32-bit
1064 * query, this would work as far as the value can be hold on a 32-bit
1065 * signed integer. For the 64-bit query, the wrapper around the 32-bit
1066 * query will unpack the value */
1067 memcpy(buffer
, &combined_value
, sizeof(GLint64
));
1071 case GL_COLOR_COMPONENTS
:
1072 /* The ARB_internalformat_query2 spec says:
1074 * "- COLOR_COMPONENTS: If the internal format contains any color
1075 * components (R, G, B, or A), TRUE is returned in <params>.
1076 * If the internal format is unsupported or contains no color
1077 * components, FALSE is returned."
1079 if (_mesa_is_color_format(internalformat
))
1080 buffer
[0] = GL_TRUE
;
1083 case GL_DEPTH_COMPONENTS
:
1084 /* The ARB_internalformat_query2 spec says:
1086 * "- DEPTH_COMPONENTS: If the internal format contains a depth
1087 * component (D), TRUE is returned in <params>. If the internal format
1088 * is unsupported or contains no depth component, FALSE is returned."
1090 if (_mesa_is_depth_format(internalformat
) ||
1091 _mesa_is_depthstencil_format(internalformat
))
1092 buffer
[0] = GL_TRUE
;
1095 case GL_STENCIL_COMPONENTS
:
1096 /* The ARB_internalformat_query2 spec says:
1098 * "- STENCIL_COMPONENTS: If the internal format contains a stencil
1099 * component (S), TRUE is returned in <params>. If the internal format
1100 * is unsupported or contains no stencil component, FALSE is returned.
1102 if (_mesa_is_stencil_format(internalformat
) ||
1103 _mesa_is_depthstencil_format(internalformat
))
1104 buffer
[0] = GL_TRUE
;
1107 case GL_COLOR_RENDERABLE
:
1108 case GL_DEPTH_RENDERABLE
:
1109 case GL_STENCIL_RENDERABLE
:
1110 if (!_is_renderable(ctx
, internalformat
))
1113 if (pname
== GL_COLOR_RENDERABLE
) {
1114 if (!_mesa_is_color_format(internalformat
))
1117 GLenum baseFormat
= _mesa_base_fbo_format(ctx
, internalformat
);
1118 if (baseFormat
!= GL_DEPTH_STENCIL
&&
1119 ((pname
== GL_DEPTH_RENDERABLE
&& baseFormat
!= GL_DEPTH_COMPONENT
) ||
1120 (pname
== GL_STENCIL_RENDERABLE
&& baseFormat
!= GL_STENCIL_INDEX
)))
1124 buffer
[0] = GL_TRUE
;
1127 case GL_FRAMEBUFFER_RENDERABLE_LAYERED
:
1128 if (!_mesa_has_EXT_texture_array(ctx
) ||
1129 _legal_target_for_framebuffer_texture_layer(ctx
, target
))
1132 case GL_FRAMEBUFFER_RENDERABLE
:
1133 case GL_FRAMEBUFFER_BLEND
:
1134 if (!_mesa_has_ARB_framebuffer_object(ctx
))
1137 if (target
== GL_TEXTURE_BUFFER
||
1138 !_is_renderable(ctx
, internalformat
))
1141 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1145 case GL_READ_PIXELS
:
1146 case GL_READ_PIXELS_FORMAT
:
1147 case GL_READ_PIXELS_TYPE
:
1148 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1152 case GL_TEXTURE_IMAGE_FORMAT
:
1153 case GL_GET_TEXTURE_IMAGE_FORMAT
:
1154 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1158 case GL_TEXTURE_IMAGE_TYPE
:
1162 case GL_GET_TEXTURE_IMAGE_TYPE
:
1167 case GL_MANUAL_GENERATE_MIPMAP
:
1168 case GL_AUTO_GENERATE_MIPMAP
:
1169 if (!_mesa_is_valid_generate_texture_mipmap_target(ctx
, target
) ||
1170 !_mesa_is_valid_generate_texture_mipmap_internalformat(ctx
,
1175 if (pname
== GL_MIPMAP
) {
1176 buffer
[0] = GL_TRUE
;
1179 else if (pname
== GL_MANUAL_GENERATE_MIPMAP
) {
1180 if (!_mesa_has_ARB_framebuffer_object(ctx
))
1184 /* From ARB_internalformat_query2:
1185 * "Dependencies on OpenGL 3.2 (Core Profile)
1186 * In core profiles for OpenGL 3.2 and later versions, queries
1187 * for the AUTO_GENERATE_MIPMAP <pname> return the appropriate
1188 * unsupported response."
1190 if (_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 32)
1194 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1198 case GL_COLOR_ENCODING
:
1199 if (!_mesa_is_color_format(internalformat
))
1202 if (_mesa_is_srgb_format(internalformat
))
1203 buffer
[0] = GL_SRGB
;
1205 buffer
[0] = GL_LINEAR
;
1209 if (!_mesa_has_EXT_texture_sRGB(ctx
) ||
1210 !_mesa_is_srgb_format(internalformat
)) {
1214 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1219 if (!_mesa_has_EXT_framebuffer_sRGB(ctx
) ||
1220 !_mesa_is_color_format(internalformat
)) {
1224 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1228 case GL_SRGB_DECODE_ARB
:
1229 /* Presence of EXT_texture_sRGB_decode was already verified */
1230 if (!_mesa_has_EXT_texture_sRGB(ctx
) ||
1231 target
== GL_RENDERBUFFER
||
1232 !_mesa_is_srgb_format(internalformat
)) {
1236 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1241 /* If it doesn't allow to set sampler parameters then it would not allow
1242 * to set a filter different to GL_NEAREST. In practice, this method
1243 * only filters out MULTISAMPLE/MULTISAMPLE_ARRAY */
1244 if (!_mesa_target_allows_setting_sampler_parameters(target
))
1247 if (_mesa_is_enum_format_integer(internalformat
))
1250 if (target
== GL_TEXTURE_BUFFER
)
1253 /* At this point we know that multi-texel filtering is supported. We
1254 * need to call the driver to know if it is CAVEAT_SUPPORT or
1257 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1261 case GL_VERTEX_TEXTURE
:
1262 case GL_TESS_CONTROL_TEXTURE
:
1263 case GL_TESS_EVALUATION_TEXTURE
:
1264 case GL_GEOMETRY_TEXTURE
:
1265 case GL_FRAGMENT_TEXTURE
:
1266 case GL_COMPUTE_TEXTURE
:
1267 if (target
== GL_RENDERBUFFER
)
1270 if ((pname
== GL_TESS_CONTROL_TEXTURE
||
1271 pname
== GL_TESS_EVALUATION_TEXTURE
) &&
1272 !_mesa_has_tessellation(ctx
))
1275 if (pname
== GL_GEOMETRY_TEXTURE
&& !_mesa_has_geometry_shaders(ctx
))
1278 if (pname
== GL_COMPUTE_TEXTURE
&& !_mesa_has_compute_shaders(ctx
))
1281 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1285 case GL_TEXTURE_GATHER
:
1286 case GL_TEXTURE_GATHER_SHADOW
:
1287 if (!_mesa_has_ARB_texture_gather(ctx
))
1291 case GL_TEXTURE_SHADOW
:
1292 /* Only depth or depth-stencil image formats make sense in shadow
1294 if (pname
!= GL_TEXTURE_GATHER
&&
1295 !_mesa_is_depth_format(internalformat
) &&
1296 !_mesa_is_depthstencil_format(internalformat
))
1299 /* Validate the target for shadow and gather operations */
1302 case GL_TEXTURE_2D_ARRAY
:
1303 case GL_TEXTURE_CUBE_MAP
:
1304 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1305 case GL_TEXTURE_RECTANGLE
:
1309 case GL_TEXTURE_1D_ARRAY
:
1310 /* 1D and 1DArray textures are not admitted in gather operations */
1311 if (pname
!= GL_TEXTURE_SHADOW
)
1319 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1323 case GL_SHADER_IMAGE_LOAD
:
1324 case GL_SHADER_IMAGE_STORE
:
1325 if (!_mesa_has_ARB_shader_image_load_store(ctx
))
1328 /* We call to _mesa_is_shader_image_format_supported
1329 * using "internalformat" as parameter, because the
1330 * the ARB_internalformat_query2 spec says:
1331 * "In this case the <internalformat> is the value of the <format>
1332 * parameter that is passed to BindImageTexture."
1334 if (target
== GL_RENDERBUFFER
||
1335 !_mesa_is_shader_image_format_supported(ctx
, internalformat
))
1338 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1342 case GL_SHADER_IMAGE_ATOMIC
:
1343 if (!_mesa_has_ARB_shader_image_load_store(ctx
))
1346 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1350 case GL_IMAGE_TEXEL_SIZE
: {
1351 mesa_format image_format
;
1353 if (!_mesa_has_ARB_shader_image_load_store(ctx
) ||
1354 target
== GL_RENDERBUFFER
)
1357 image_format
= _mesa_get_shader_image_format(internalformat
);
1358 if (image_format
== MESA_FORMAT_NONE
)
1361 /* We return bits */
1362 buffer
[0] = (_mesa_get_format_bytes(image_format
) * 8);
1366 case GL_IMAGE_COMPATIBILITY_CLASS
:
1367 if (!_mesa_has_ARB_shader_image_load_store(ctx
) ||
1368 target
== GL_RENDERBUFFER
)
1371 buffer
[0] = _mesa_get_image_format_class(internalformat
);
1374 case GL_IMAGE_PIXEL_FORMAT
: {
1377 if (!_mesa_has_ARB_shader_image_load_store(ctx
) ||
1378 target
== GL_RENDERBUFFER
||
1379 !_mesa_is_shader_image_format_supported(ctx
, internalformat
))
1382 base_format
= _mesa_base_tex_format(ctx
, internalformat
);
1383 if (base_format
== -1)
1386 if (_mesa_is_enum_format_integer(internalformat
))
1387 buffer
[0] = _mesa_base_format_to_integer_format(base_format
);
1389 buffer
[0] = base_format
;
1393 case GL_IMAGE_PIXEL_TYPE
: {
1394 mesa_format image_format
;
1398 if (!_mesa_has_ARB_shader_image_load_store(ctx
) ||
1399 target
== GL_RENDERBUFFER
)
1402 image_format
= _mesa_get_shader_image_format(internalformat
);
1403 if (image_format
== MESA_FORMAT_NONE
)
1406 _mesa_uncompressed_format_to_type_and_comps(image_format
, &datatype
,
1411 buffer
[0] = datatype
;
1415 case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE
: {
1416 if (!_mesa_has_ARB_shader_image_load_store(ctx
))
1419 if (!_mesa_legal_get_tex_level_parameter_target(ctx
, target
, true))
1422 /* From spec: "Equivalent to calling GetTexParameter with <value> set
1423 * to IMAGE_FORMAT_COMPATIBILITY_TYPE."
1425 * GetTexParameter just returns
1426 * tex_obj->ImageFormatCompatibilityType. We create a fake tex_obj
1427 * just with the purpose of getting the value.
1429 struct gl_texture_object
*tex_obj
= _mesa_new_texture_object(ctx
, 0, target
);
1430 buffer
[0] = tex_obj
->ImageFormatCompatibilityType
;
1431 _mesa_delete_texture_object(ctx
, tex_obj
);
1436 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
:
1437 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
:
1438 case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
:
1439 case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
:
1440 if (target
== GL_RENDERBUFFER
)
1443 if (!_mesa_is_depthstencil_format(internalformat
)) {
1444 if (((pname
== GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST
||
1445 pname
== GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE
) &&
1446 !_mesa_is_depth_format(internalformat
)) ||
1447 ((pname
== GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST
||
1448 pname
== GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE
) &&
1449 !_mesa_is_stencil_format(internalformat
)))
1453 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1457 case GL_TEXTURE_COMPRESSED
:
1458 buffer
[0] = _mesa_is_compressed_format(ctx
, internalformat
);
1461 case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
:
1462 case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT
:
1463 case GL_TEXTURE_COMPRESSED_BLOCK_SIZE
: {
1464 mesa_format mesaformat
;
1467 mesaformat
= _mesa_glenum_to_compressed_format(internalformat
);
1468 if (mesaformat
== MESA_FORMAT_NONE
)
1471 block_size
= _mesa_get_format_bytes(mesaformat
);
1472 assert(block_size
> 0);
1474 if (pname
== GL_TEXTURE_COMPRESSED_BLOCK_SIZE
) {
1475 buffer
[0] = block_size
;
1477 GLuint bwidth
, bheight
;
1479 /* Returns the width and height in pixels. We return bytes */
1480 _mesa_get_format_block_size(mesaformat
, &bwidth
, &bheight
);
1481 assert(bwidth
> 0 && bheight
> 0);
1483 if (pname
== GL_TEXTURE_COMPRESSED_BLOCK_WIDTH
)
1484 buffer
[0] = block_size
/ bheight
;
1486 buffer
[0] = block_size
/ bwidth
;
1491 case GL_CLEAR_BUFFER
:
1492 if (target
!= GL_TEXTURE_BUFFER
)
1495 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1499 case GL_TEXTURE_VIEW
:
1500 case GL_VIEW_COMPATIBILITY_CLASS
:
1501 if (!_mesa_has_ARB_texture_view(ctx
) ||
1502 target
== GL_TEXTURE_BUFFER
||
1503 target
== GL_RENDERBUFFER
)
1506 if (pname
== GL_TEXTURE_VIEW
) {
1507 ctx
->Driver
.QueryInternalFormat(ctx
, target
, internalformat
, pname
,
1510 GLenum view_class
= _mesa_texture_view_lookup_view_class(ctx
,
1512 if (view_class
== GL_FALSE
)
1515 buffer
[0] = view_class
;
1520 unreachable("bad param");
1524 if (bufSize
!= 0 && params
== NULL
) {
1525 /* Emit a warning to aid application debugging, but go ahead and do the
1526 * memcpy (and probably crash) anyway.
1529 "glGetInternalformativ(bufSize = %d, but params = NULL)",
1533 /* Copy the data from the temporary buffer to the buffer supplied by the
1534 * application. Clamp the size of the copy to the size supplied by the
1537 memcpy(params
, buffer
, MIN2(bufSize
, 16) * sizeof(GLint
));
1543 _mesa_GetInternalformati64v(GLenum target
, GLenum internalformat
,
1544 GLenum pname
, GLsizei bufSize
, GLint64
*params
)
1548 GLsizei realSize
= MIN2(bufSize
, 16);
1551 GET_CURRENT_CONTEXT(ctx
);
1553 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1555 if (!_mesa_has_ARB_internalformat_query2(ctx
)) {
1556 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetInternalformati64v");
1560 /* For SAMPLES there are cases where params needs to remain unmodified. As
1561 * no pname can return a negative value, we fill params32 with negative
1562 * values as reference values, that can be used to know what copy-back to
1564 memset(params32
, -1, 16);
1566 /* For GL_MAX_COMBINED_DIMENSIONS we need to get back 2 32-bit integers,
1567 * and at the same time we only need 2. So for that pname, we call the
1568 * 32-bit query with bufSize 2, except on the case of bufSize 0, that is
1569 * basically like asking to not get the value, but that is a caller
1571 if (pname
== GL_MAX_COMBINED_DIMENSIONS
&& bufSize
> 0)
1576 _mesa_GetInternalformativ(target
, internalformat
, pname
, callSize
, params32
);
1578 if (pname
== GL_MAX_COMBINED_DIMENSIONS
) {
1579 memcpy(params
, params32
, sizeof(GLint64
));
1581 for (i
= 0; i
< realSize
; i
++) {
1582 /* We only copy back the values that changed */
1583 if (params32
[i
] < 0)
1585 params
[i
] = (GLint64
) params32
[i
];