• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_internalformat_query
4
5Name Strings
6
7    GL_ARB_internalformat_query
8
9Contact
10
11    Jan-Harald Fredriksen (jan-harald.fredriksen 'at' arm.com)
12    Daniel Koch (daniel 'at' transgaming 'dot' com)
13
14Contributors
15
16    Bruce Merry, ARM
17    Daniel Koch, Transgaming
18    Acorn Pooley, NVIDIA
19    Christophe Riccio, Imagination Technologies
20
21Notice
22
23    Copyright (c) 2011-2013 The Khronos Group Inc. Copyright terms at
24        http://www.khronos.org/registry/speccopyright.html
25
26Specification Update Policy
27
28    Khronos-approved extension specifications are updated in response to
29    issues and bugs prioritized by the Khronos OpenGL Working Group. For
30    extensions which have been promoted to a core Specification, fixes will
31    first appear in the latest version of that core Specification, and will
32    eventually be backported to the extension document. This policy is
33    described in more detail at
34        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
35
36Status
37
38    Complete. Approved by the ARB on 2011/06/20.
39    Approved by the Khronos Promoters on 2011/07/29.
40
41Version
42
43    Last Modified Date: June 13, 2011
44    Revision: 7
45
46Number
47
48    ARB Extension #112
49
50Dependencies
51
52    OpenGL 3.0 or ARB_framebuffer_object is required.
53
54    This extension is written against the OpenGL 4.1 (Core Profile)
55    Specification (July 25, 2010).
56
57    ARB_texture_multisample affects the definition of this extension.
58
59Overview
60
61    OpenGL 4.1 has a number of queries to indicate the maximum number of
62    samples available for different formats. These give a coarse-grained
63    query mechanism e.g. an implementation can expose different sample
64    counts for integer and floating-point formats, but not for different
65    floating-point formats. There is also no convenient way for the user
66    to determine the granularity of sample counts available, only the
67    maximum.
68
69    This extension adds a query mechanism that allows the user to
70    determine which sample counts are available for a specific internal
71    format.
72
73IP Status
74
75    No known IP claims.
76
77New Procedures and Functions
78
79    void GetInternalformativ(enum target, enum internalformat,
80                             enum pname, sizei bufSize, int *params);
81
82New Types
83
84    None.
85
86New Tokens
87
88    Accepted by the <target> parameter of GetInternalformativ:
89
90        RENDERBUFFER
91        TEXTURE_2D_MULTISAMPLE
92        TEXTURE_2D_MULTISAMPLE_ARRAY
93
94    Accepted by the <pname> parameter of GetInternalformativ:
95
96        SAMPLES
97        NUM_SAMPLE_COUNTS                          0x9380
98
99Additions to Chapter 2 of the OpenGL 4.1 (Core Profile) Specification
100(OpenGL Operation)
101
102    None.
103
104Additions to Chapter 3 of the OpenGL 4.1 (Core Profile) Specification
105(Rasterization)
106
107    In section 3.8.6 (Multisample Textures), replace the bulleted
108    list of error conditions (for exceeding MAX_*_SAMPLES) and the
109    preceeding sentence with:
110
111        "The error INVALID_OPERATION will be generated if <samples> is
112        greater than the maximum number of samples supported for this
113        <target> and <internalformat>, which can be determined by
114        calling GetInternalformativ with a <pname> of SAMPLES (see
115        section 6.X)."
116
117    In the following paragraph, remove "or if samples is greater
118    than MAX_SAMPLES".
119
120Additions to Chapter 4 of the OpenGL 4.1 (Core Profile) Specification
121(Per-Fragment Operations and the Frame Buffer)
122
123    In section 4.4.2 (Attaching Images to Framebuffer Objects), under
124    the description of RenderbufferStorageMultisample:
125
126    Replace
127
128        "If either <width> or <height> is greater than the value of
129        MAX_RENDERBUFFER_SIZE, or if <samples> is greater than the value
130        of MAX_SAMPLES, then the error INVALID_VALUE is generated. If
131        <internalformat> is a signed or unsigned integer format and
132        <samples> is greater than the value of MAX_INTEGER_SAMPLES, then
133        the error INVALID_OPERATION is generated (see ``Required
134        Renderbuffer Formats'' below)."
135
136    with
137
138        "If either <width> or <height> is greater than the value of
139        MAX_RENDERBUFFER_SIZE then the error INVALID_VALUE is
140        generated. If <samples> is greater than the maximum number of
141        samples supported for <internalformat> then the error
142        INVALID_OPERATION is generated (see GetInternalformativ in
143        section 6.X)."
144
145Additions to Chapter 5 of the OpenGL 4.1 (Compatibility Profile)
146Specification (Special Functions)
147
148    Add GetInternalformativ to the list of commands not included in
149    display lists.
150
151Additions to Chapter 6 of the OpenGL 4.1 (Core Profile) Specification
152(State and State Requests)
153
154    Add a new section 6.1.X "Internalformat queries"
155
156    Information about implementation-dependent support for internal
157    formats can be queried with the command
158
159    void GetInternalformativ(enum target, enum internalformat,
160                             enum pname, sizei bufSize, int *params);
161
162    <internalformat> must be color-renderable, depth-renderable or
163    stencil-renderable (as defined in section 4.4.4).
164
165    <target> indicates the usage of the <internalformat>, and must be
166    one of RENDERBUFFER, TEXTURE_2D_MULTISAMPLE, or
167    TEXTURE_2D_MULTISAMPLE_ARRAY, corresponding to usage as a
168    renderbuffer, 2D multisample texture, or 2D multisample array
169    texture.
170
171    No more than <bufSize> integers will be written into <params>. If
172    more data are available, they will be ignored and no error will be
173    generated.
174
175    <pname> indicates the information to query, and is one of the
176    following:
177
178    - SAMPLES: The sample counts supported for this <format> and
179      <target> are written into <params>, in descending order. Only
180      positive values are returned.
181    - NUM_SAMPLE_COUNTS: The number of sample counts that would be
182      returned by querying SAMPLES is returned in <params>.
183
184    Note that querying SAMPLES with a <bufSize> of 1 will return just
185    the maximum supported number of samples for this format.
186
187    The maximum value in SAMPLES is guaranteed to be at least the lowest
188    of the following:
189    - The value of GetIntegerv(MAX_INTEGER_SAMPLES), if <internalformat>
190      is a signed or unsigned integer format.
191    - The value of GetIntegerv(MAX_DEPTH_TEXTURE_SAMPLES), if
192      <internalformat> is a depth/stencil-renderable format and <target>
193      is TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY.
194    - The value of GetIntegerv(MAX_COLOR_TEXTURE_SAMPLES), if
195      <internalformat> is a color-renderable format and <target> is
196      TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY.
197    - The value of GetIntegerv(MAX_SAMPLES).
198
199Additions to Appendix A of the OpenGL 4.1 (Core Profile) Specification
200(Invariance)
201
202    None.
203
204Additions to Appendix D of the OpenGL 4.1 (Core Profile) Specification
205(Shared Objects and Multiple Contexts)
206
207    None.
208
209GLX Protocol
210
211    XXX - TODO.
212
213Dependencies on ARB_texture_multisample
214
215    If OpenGL 3.2 or ARB_texture_multisample is not supported, then
216    TEXTURE_2D_MULTISAMPLE and TEXTURE_2D_MULTISAMPLE_ARRAY are not
217    supported <target> parameters to GetInternalformativ.
218
219Dependencies on OpenGL ES
220
221    If implemented on OpenGL ES (together with an extension adding
222    RenderbufferStorageMultisample), then this extension behaves as
223    specified, except:
224
225    - Ignore all references to multisample textures and display lists.
226    - Ignore all references to MAX_COLOR_TEXTURE_SAMPLES,
227      MAX_DEPTH_TEXTURE_SAMPLES, MAX_INTEGER_SAMPLES and MAX_SAMPLES.
228
229Errors
230
231    If the <internalformat> parameter to GetInternalformativ is not
232    color-, depth- or stencil-renderable, then an INVALID_ENUM error is
233    generated.
234
235    If the <target> parameter to GetInternalformativ is not one of
236    TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY or RENDERBUFFER
237    then an INVALID_ENUM error is generated.
238
239    If the <pname> parameter to GetInternalformativ is not SAMPLES
240    or NUM_SAMPLE_COUNTS, then an INVALID_ENUM error is generated.
241
242    If the <bufSize> parameter to GetInternalformativ is negative,
243    then an INVALID_VALUE error is generated.
244
245    If the <samples> parameter to TexImage2DMultisample,
246    TexImage3DMultisample or RenderbufferStorageMultisample is greater
247    than the maximum number of samples supported for the target and
248    internalformat, an INVALID_OPERATION error is generated.
249
250    An INVALID_VALUE error is no longer generated if the <samples>
251    argument to TexImage2DMultisample, TexImage3DMultisample or
252    RenderbufferStorageMultisample is greater than the value of
253    GetIntegerv(MAX_SAMPLES).
254
255New State
256
257    None.
258
259New Implementation Dependent State
260
261    Changes to table 6.52, p. 393 (Implementation Dependent Values)
262
263                                                                Minimum
264    Get Value                  Type    Get Command              Value    Description                            Sec.
265    ---------                  ----    -----------              -------  ------------------------------------   -----
266    MAX_DEPTH_TEXTURE_SAMPLES  Z+      GetIntegerv               1       Maximum number of samples supported    6.1.X
267                                                                         for all depth/stencil formats in a
268                                                                         multisample texture
269    MAX_COLOR_TEXTURE_SAMPLES  Z+      GetIntegerv               1       Maximum number of samples supported    6.1.X
270                                                                         for all color formats in a
271                                                                         multisample texture
272    MAX_INTEGER_SAMPLES        Z+      GetIntegerv               1       Maximum number of samples supported    6.1.X
273                                                                         for all integer format multisample
274                                                                         buffers
275
276    (only the description and section numbers change)
277
278    Changes to table 6.54, p. 395 (Framebuffer Dependent Values)
279
280                                                                Minimum
281    Get Value                  Type    Get Command              Value    Description                            Sec.
282    ---------                  ----    -----------              -------  ------------------------------------   -----
283    MAX_SAMPLES                Z+      GetIntegerv               4       Maximum number of samples supported    6.1.X
284                                                                         for all non-integer formats
285
286    (only the description and section number change - note this query should
287    probably be in table 6.52 to start with)
288
289    Add new table 6.X Internalformat-specific Implementation Dependent Values after 6.52
290
291                                                                Minimum
292    Get Value                  Type    Get Command              Value    Description                            Sec.
293    ---------                  ----    -----------              -------  ------------------------------------   -----
294    SAMPLES                    0*xZ+   GetInternalformativ       fn1     Supported sample counts                6.X
295    NUM_SAMPLE_COUNTS          Z+      GetInternalformativ       1       Number of supported sample counts      6.X
296
297    fn1: see section 6.X.
298
299Sample Code
300
301    To determine all the sample counts available for a specific
302    renderbuffer format:
303
304    GLint *samples;
305    GLint samples_length, i;
306
307    glGetInternalformativ(GL_RENDERBUFFER, format,
308                          GL_NUM_SAMPLE_COUNTS, 1, &samples_length);
309    samples = malloc(samples_length * sizeof(GLint));
310    glGetInternalformativ(GL_RENDERBUFFER, format,
311                          GL_SAMPLES, samples_length, samples);
312    for (i = 0; i < samples_length; i++)
313    {
314        printf("Format %#x supports %d samples\n", samples[i]);
315    }
316
317    To determine the maximum sample count available for a specific
318    renderbuffer format:
319
320    GLint max_samples;
321    glGetInternalformativ(GL_RENDERBUFFER, format,
322                          GL_SAMPLES, 1, &max_samples);
323
324Conformance Tests
325
326    1. Test each of the error conditions described in Errors.
327
328    2. For each format that is not color-, depth- or stencil-renderable
329    (if any), test that INVALID_ENUM is generated if passed to
330    GetInternalformativ (e.g. LUMINANCE_ALPHA).
331
332    3. Call GetInternalformativ for each <pname> in turn with a
333    <bufSize> of zero; check that <params> is not modified and that no
334    error results.
335
336    4. For each color-, depth- or stencil-renderable format and each
337    target:
338       4.1. Query NUM_SAMPLE_COUNTS and verify that it is greater than
339       zero.
340       4.2. Query SAMPLES, using a larger-than-necessary buffer, and
341       check that only NUM_SAMPLE_COUNTS values are written.
342       4.3. Check that the values returned by SAMPLES are all positive
343       and strictly decreasing.
344       4.4. Query MAX_SAMPLES and check that it matches the first value
345       returned by SAMPLES.
346       4.5. Check that MAX_SAMPLES is at least the lower bound computed
347       from MAX_SAMPLES, MAX_INTEGER_SAMPLES, MAX_COLOR_TEXTURE_SAMPLES
348       and MAX_DEPTH_TEXTURE_SAMPLES.
349       4.6. Check that MAX_SAMPLE_MASK_WORDS is at least
350       ceil(MAX_SAMPLES / 32).
351
352Issues
353
354    1) Should we have the MAX_SAMPLES query as well as the SAMPLES
355    query? It's syntactic sugar (since you can just take the largest
356    value in the SAMPLES array), but very convenient sugar since you
357    don't have to allocate a dynamically-sized array. It also simplifies
358    the specification.
359
360    RESOLVED: no, we don't need it. Passing a <bufSize> of 1 when
361    querying SAMPLES gives the same effect.
362
363    2) Should we explicitly include 0 in the list of sample counts
364    (meaning "not multisampled")? It might allow one to indicate that certain
365    formats are flat-out unsupported with certain targets but supported with
366    others.
367
368    RESOLVED: no, we would rather layer on a separate <pname> later.
369
370    3) For multisample textures, is a per-target query too fine-grained?
371    Should the <target> just be TEXTURE instead of
372    TEXTURE_2D_MULTISAMPLE[_ARRAY]?
373
374    RESOLVED: Keep the per-target query as it may useful to distinguish
375    results for some future values of <pname>.
376
377    4) What should the new command be called?
378
379    RESOLVED: GetInternalformativ
380
381    GetInternalformativ is potentially confusing, but consistent with
382    GL precedent such as GetQueryiv (which returns information such as
383    the number of bits supported for a specific query target).
384
385    5) What should the query of the number of samples counts be called?
386
387    RESOLVED: NUM_SAMPLE_COUNTS
388
389    The original proposal was NUM_SAMPLES, which is consistent with
390    NUM_COMPRESSED_TEXTURE_FORMATS. However, it's confusing because what
391    is being queried is not the number of samples (whereas
392    NUM_COMPRESSED_TEXTURE_FORMATS is the number of compressed texture
393    formats). NUM_SAMPLE_COUNTS is also consistent with the
394    NUM_COMPRESSED_TEXTURE_FORMATS precedent and the description of this
395    value.
396
397    Another proposal was SAMPLES_LENGTH, but this is misleading
398    because in OpenGL LENGTH is only used for string length.
399
400    6) What should GetIntegerv(MAX_INTEGER_SAMPLES) and similar queries
401    return (excluding MAX_SAMPLES - see next issue)?
402
403    Discussion: there are (at least) two options:
404
405    A. Querying MAX_INTEGER_SAMPLES returns a count that is guaranteed
406    to be supported for all integer formats, but some integer formats
407    may support more samples and the existing errors are relaxed to
408    allow this.
409
410    B. Require that all integer formats support the same maximum number
411    of samples, and GetInternalformativ becomes an alternative
412    interface to the same set of limits.
413
414    RESOLVED: option A.
415
416    7) What should GetIntegerv(MAX_SAMPLES) return?
417
418    In OpenGL 4.1, MAX_SAMPLES serves two purposes.
419    A. An upper bound on the number of samples supported for any format.
420    This manifests in INVALID_VALUE errors when trying to use more than
421    this number.
422    B. A number of samples that is guaranteed to be supported for all
423    formats that don't fall into certain classes (such as integer
424    formats).
425
426    Backwards compatibility would suggest that it should return option
427    B in future, although this leaves no way to determine the maximum
428    number of samples supported for any format unless a new query is
429    introduced.
430
431    RESOLVED: option B.
432
433    8) Does this extension make the MAX_SAMPLES query unnecessary?
434
435    RESOLVED: MAX_SAMPLES will need to be retained in API versions where
436    it already exists (for backwards compatibilities), but there is no
437    need to add it as this query provides more accurate information and
438    it is expected that shipping hardware will support different numbers
439    of samples for different formats.
440
441    9) Can we query additional properties supported for an internal format
442    in addition to multisample-related information with this API?
443
444    RESOLVED: DEFERRED. Yes this API is suitable for that, but the
445    specification is left for a layered extension.
446
447    Other possible <pnames> include:
448      MAX_WIDTH
449        - maximum width of object
450      MAX_HEIGHT
451        - maximum height of object
452      MAX_DEPTH
453        - maximum depth/# of layers of object
454      MAX_COMBINED_SIZE
455        - maximum size of object (w*h*d) (due to implementation-specific
456          limitations)
457      FRAMEBUFFER_RENDERABLE
458        - can be rendered to via FBO attachment
459      FRAMEBUFFER_RENDERABLE_BLEND
460        - can be rendered to via FBO attachment when blending is enabled
461      MIPMAPS
462        - more than one mipmap can be supported
463      GENERATE_MIPMAPS
464        - is generate mipmaps supported
465      READPIXEL
466        - framebuffers with this internal format can be read directly with
467          an appropriate format/type by ReadPixels
468      FILTER_LINEAR
469        - can the MIN/MAG filter be set to LINEAR values? Are filters other
470          than NEAREST supported?
471      SRGB_READ
472        - texture reads from this internalformat occur in SRGB colorspace
473      SRGB_WRITE
474        - framebuffers with this internalformat can be rendered to with
475          FRAMEBUFFER_SRGB enabled
476      SRGB_DECODE
477        - textures of this format support toggling TEXTURE_SRGB_DECODE
478          (ie EXT_texture_sRGB_decode)
479      VERTEX_TEXTURE
480        - textures with this internalformat can be sampled from vertex shaders
481      TESS_CONTROL_TEXTURE
482        - textures with this internalformat can be sampled from tessellation
483          control shaders
484      TESS_EVALUATION_TEXTURE
485        - textures with this internalformat can be sampled from tessellation
486          evaluation shaders
487      GEOMETRY_TEXTURE
488        - textures with this internalformat can be sampled from geometry shaders
489      FRAGMENT_TEXTURE
490        - textures with this internalformat can be sampled from fragment shaders
491      TEXTURE_SHADOW
492        - textures with this internalformat support shadow samplers
493      TEXTURE_GATHER
494        - textures with this internalformat support texture gather operations
495      TEXTURE_GATHER_SHADOW
496        - textures with this internalformat support texture gather operations
497          with shadow samplers
498      SHADER_IMAGE_LOAD
499        - textures with this internalformat support image load operations
500          from shaders
501      SHADER_IMAGE_STORE
502        - textures with this internalformat support image store operations
503          from shaders
504      SHADER_IMAGE_ATOMIC
505        - textures with this internalformat support atomic memory operations
506          from shaders
507      FORMAT_SUPPORTED
508        - the requested internal format is known and supported for at least
509          some subset of the possible operations
510      ACTUAL_INTERNALFORMAT
511        - the actual internalformat used by the implementation when the
512          specified internalformat is requested
513      PERFORMANCE_HINT
514        - an indication that this format will or may operate at reduced
515          performance in some cases (should this be a bitfield, array,
516          or a specific bit on each of the other queries?)
517
518    Possible values for some of the above pnames:
519        - HARDWARE (or SUPPORTED), SOFTWARE (or CAVEAT), UNSUPPORTED.
520
521    Additional Values for <target> that would be valid for
522      TEXTURE_1D
523      TEXTURE_1D_ARRAY
524      TEXTURE_2D
525      TEXTURE_2D_ARRAY
526      TEXTURE_3D
527      TEXTURE_CUBE_MAP
528      TEXTURE_CUBE_MAP_ARRAY
529      TEXTURE_RECTANGLE
530      TEXTURE_BUFFER
531    Could also consider meta targets such as:
532      ALL
533      ANY
534      TEXTURE
535
536
537    10) Is the <target> parameter required?  If so, should it be the first or
538    second parameter?
539
540    RESOLVED:
541    a) Yes. It is possible that in some implementations and for some of the possible
542    uses of this query, that the results will depend on the texture target.
543    b) First parameter. All other entry points that take a <target> have it as the
544    first parameter.
545
546Revision History
547
548    Revision 7, 2011/06/13 dgkoch
549      - recast as ARB extension
550
551    Revision 6, 2011/05/19 dgkoch
552      - resolved issue 3, 9 per F2F.
553
554    Revision 5, 2011/05/16 dgkoch
555      - resolved issue 10 per F2F. Keep target; as the first parameter.
556      - fix extension name
557      - updates to Issue 9
558
559    Revision 4, 2011/05/11 dgkoch
560      - also fix the formal paramter in the New Functions area
561      - updates to issue 9, added issue 10
562
563    Revision 3, 2011/05/05 dgkoch
564      - rename the formal parameter from 'format' to 'internalformat'
565        to match the spec body.
566      - changed SAMPLES_LENGTH to NUM_SAMPLE_COUNTS
567      - added issue 9
568
569    Revision 2, 2011/04/21 bmerry
570      - Fix typo InternalFormat -> Internalformat
571      - Removed per-format MAX_SAMPLES query
572      - Marked issues 1, 2, and 4-7 as resolved
573
574    Revision 1, 2011/04/13 bmerry
575      - First draft.
576