• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    INTEL_conservative_rasterization
4
5Name Strings
6
7    GL_INTEL_conservative_rasterization
8
9Contact
10
11    Slawomir Grajewski, Intel Corporation (slawomir.grajewski 'at' intel.com)
12
13Contributors
14
15    Petrik Clarberg, Intel Corporation
16    Jon Kennedy, Intel Corporation
17    Slawomir Cygan, Intel Corporation
18
19Status
20
21    Draft.
22
23Version
24
25    Last Modified Date:         11/2/2016
26    Intel Revision:             2
27
28Number
29
30    OpenGL Extension #491
31    OpenGL ES Extension #265
32
33Dependencies
34
35    This extension is written against the OpenGL 4.5 (Core Profile)
36    Specification (May 28, 2015)
37
38    This extension is written against Version 4.50.5 of the OpenGL Shading
39    Language Specification.
40
41    OpenGL 4.2 and GLSL 4.2 are required.
42
43    This extension is written against the OpenGL ES 3.2 Specification
44    (August 10, 2015)
45
46    This extension is written against Version 3.20.2 of the OpenGL ES Shading
47    Language Specification (August 6, 2015)
48
49    This extension interacts with ARB_post_depth_coverage.
50
51Overview
52
53    Regular rasterization includes fragments with at least one
54    sample covered by a polygon. Conservative rasterization includes all
55    fragments that are at least partially covered by the polygon.
56
57    In some use cases, it is also important to know if a fragment is fully
58    covered by a polygon, i.e. if all parts of the fragment are within the
59    polygon. An application may, for example, want to process fully covered
60    fragments different from the "edge" pixels. This extension adds an option
61    for the fragment shader to receive this information via gl_SampleMaskIn[].
62
63    This extension affects only polygons in FILL mode and specifically does not
64    imply any changes in processing of lines or points.
65
66    Conservative rasterization automatically disables polygon antialiasing
67    rasterization if enabled by POLYGON_SMOOTH.
68
69New Procedures and Functions
70
71    None.
72
73New Tokens
74
75    Accepted by the <target> parameter of Enable, Disable, IsEnabled:
76
77        CONSERVATIVE_RASTERIZATION_INTEL  0x83FE
78
79Additions to Chapter 14.6, Polygons of the OpenGL 4.5 Specification
80
81    Modify Section 14.6.1, Basic Polygon Rasterization
82
83    (insert before the paragraph starting with "As for the data associated...")
84
85    The determination of which fragments are produced by polygon rasterization
86    can be modified by the conservative rasterization option (as described in
87    section 14.6.4).
88
89    Modify Section 14.6.3, Antialiasing
90
91    (add a new paragraph to the end of the section)
92
93    Conservative rasterization automatically disables polygon antialiasing
94    rasterization if enabled by POLYGON_SMOOTH.
95
96    Modify Section 14.6.4, Options Controlling Polygon Rasterization
97
98    (add a new paragraph to the end of the section)
99
100    The determination of which fragments are produced as a result of polygon
101    rasterization in FILL state can be modified by enabling the conservative
102    rasterization option. Conservative rasterization is enabled or disabled
103    with the generic Enable and Disable commands using the symbolic constant
104    CONSERVATIVE_RASTERIZATION_INTEL. When disabled, the fragments are
105    determined as described in section 14.6.1. When enabled the polygon
106    rasterization produces all fragments for which any part of their squares
107    are inside the polygon, after expanding the polygon by 1/512th of a pixel
108    in both x and y dimensions. Polygons with an area of zero do generate
109    fragments.
110
111    The conservative rasterization option applies only to polygons with
112    PolygonMode state set to FILL. Draw requests for polygons with different
113    PolygonMode setting or for other primitive types (points/lines) generate
114    INVALID_OPERATION error.
115
116    Modify Section 14.6.6, Polygon Multisample Rasterization
117
118    (modify the first paragraph)
119
120    If MULTISAMPLE is enabled, and the value of SAMPLE_BUFFERS is one, then
121    polygons are rasterized using the following algorithm, regardless of
122    whether polygon antialiasing (POLYGON_SMOOTH) is enabled or disabled. When
123    conservative rasterization is disabled as described in section 14.6.4,
124    polygon rasterization produces a fragment for each framebuffer pixel with
125    one or more sample points that satisfy the point sampling criteria
126    described in section 14.6.1. When conservative rasterization is
127    enabled, polygon rasterization produces exactly the same fragments as with
128    MULTISAMPLE disabled and the value of SAMPLE_BUFFERS set to zero. If a
129    polygon is culled, based on its orientation and the CullFace mode, then no
130    fragments are produced during rasterization. When conservative
131    rasterization is disabled, coverage bits that correspond to sample points
132    that satisfy the point sampling criteria are 1, other coverage bits are
133    0. When conservative rasterization is enabled all sample coverage bits for
134    fragments produced by rasterization are 1, other coverage bits are 0.
135
136Additions to Chapter 15.2.2, Shader Inputs of the OpenGL 4.5 Specification
137
138    (replace the sentence starting with "Bit<n> of element<w> in the array...")
139
140    Bit <n> of element <w> in the array is set if and only if the sample
141    numbered <32w + n> is considered covered for this fragment shader
142    invocation. If the fragment shader specifies the "early_fragment_tests" and
143    "post_depth_coverage" layout qualifiers, then the sample is considered
144    covered if and only if the sample is covered by the primitive and the
145    sample passes the early fragment tests (as described in Section 15.2.4). If
146    these layout qualifiers are not specified, then the sample is considered
147    covered if the sample is covered by the primitive, regardless of the result
148    of the fragment tests. If the fragment shader specifies the
149    "inner_coverage" layout qualifier the sample is considered covered only if
150    the sample is covered by the primitive and passes the inner coverage
151    test. Layout qualifier "inner_coverage" is in effect only if conservative
152    is enabled and is mutually exclusive with "post_depth_coverage".
153
154    During the conservative rasterization process (section 14.6.4) for the
155    purpose of the inner coverage test the determination is made if the
156    fragment is entirely contained within the polygon. This determination is
157    made by shrinking the polygon by 1/512th of pixel along the x and y
158    dimensions. The result of the inner coverage test is available in
159    gl_SampleMaskIn if "inner_coverage" layout qualifier is present.
160
161    (replace the paragraph starting with "When per-sample shading is active due
162    to the use of a fragment input qualified...")
163
164    In the case of per-sample shading the information delivered via
165    gl_SampleMaskIn depends on the conservative rasterization state and
166    possibly on the layout qualifier. Regardless of the conservative
167    rasterization state, samples killed due to SAMPLE_COVERAGE or SAMPLE_MASK
168    are never reported in gl_SampleMaskIn regardless of the qualifier.
169
170    With conservative rasterization disabled, when per-sample shading is active
171    due to the use of a fragment input qualified by sample or due to the use of
172    the gl_SampleID or gl_SamplePosition variables, only the bit for the
173    current sample is set in gl_SampleMaskIn. When state specifies multiple
174    fragment shader invocations for a given fragment, the sample mask for any
175    single fragment shader invocation may specify a subset of the covered
176    samples for the fragment. In this case, the bit corresponding to each
177    covered sample will be set in exactly one fragment shader invocation.
178
179    With conservative rasterization enabled, regardless of whether per-sample
180    shading is active due to fragment input qualified by sample or by state,
181    the meaning of the gl_SampleMaskIn depends on layout qualifier and is the
182    same for both per-sample triggering conditions. Moreover as a consequence
183    of rasterization rules described in section 14.6.6, when conservative
184    rasterization is enabled and MULITISAMPLE is enabled and the value of
185    SAMPLE_BUFFERS is one, either all samples of a given fragment are covered,
186    or none.
187
188    * No layout qualifier present:
189      The sample mask for any single fragment shader invocation specifies all
190      samples covered by a conservatively rasterized fragment.
191
192    * Layout qualifier "inner_coverage":
193      The sample mask for any single fragment shader invocation specifies all
194      samples covered by a conservatively rasterized fragment that passed inner
195      coverage test.
196
197    * Layout qualifier "post_depth_coverage":
198      The sample mask for any single fragment shader invocation specifies all
199      samples covered by a conservatively rasterized fragment that passed early
200      depth/stencil tests if enforced by early_fragment_tests layout qualifier
201      as described in section 15.2.4.
202
203    If MULTISAMPLE is enabled and the value of SAMPLE_BUFFERS is one, and per
204    sample shading is not active, the meaning of gl_SampleMaskIn[] and its
205    modifications due to layout qualifier are exactly the same as described
206    above.
207
208Additions to the OpenGL Shading Language Specification, version 4.50.5
209
210    Including the following line in a shader can be used to control the
211    language features described in this extension:
212
213      #extension GL_INTEL_conservative_rasterization : <behavior>
214
215    where <behavior> is as specified in section 3.3.
216
217    A new preprocessor #define is added to the OpenGL Shading Language:
218
219      #define GL_INTEL_conservative_rasterization 1
220
221    Modify section 4.4.1.3, Fragment Shader Inputs
222
223    (replace the discussion of early_fragment_tests)
224
225    Fragment shaders also allow the following layout qualifiers on "in" only (not
226    with variable declarations)
227
228        layout-qualifier-id
229            early_fragment_tests
230            post_depth_coverage
231            inner_coverage
232
233    For example,
234
235        layout(early_fragment_tests) in;
236        layout(post_depth_coverage) in;
237        layout(inner_coverage) in;
238
239    "early_fragment_tests" requests that fragment tests be performed before
240    fragment shader execution, as described in section 15.2.4 "Early Fragment
241    Tests" of the OpenGL Specification. If neither this nor post_depth_coverage
242    are declared, per-fragment tests will be performed after fragment shader
243    execution.
244
245    "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will
246    reflect the result of the early fragment tests, as described in section
247    15.2.2 "Shader Inputs" of the OpenGL Specification. Use of this
248    qualifier implicitly requests that fragment tests be performed before
249    fragment shader execution.
250
251    "inner_coverage" requests that the built-in "gl_SampleMaskIn[]" will
252    reflect the result of the inner coverage test as described in section
253    15.2.2 "Shader Inputs" of the OpenGL Specification. It has an effect on
254    "gl_SampleMaskIn[]" only if conservative rasterization is enabled.
255
256    "post_depth_coverage" and "inner_coverage" are mutually
257    exclusive. Declaring both for fragment shader will result in compile or
258    link error.
259
260    Only one fragment shader (compilation unit) need declare these, though
261    more than one can. If at least one fragment shader declares one of these,
262    then it is enabled.
263
264Additions to Chapter 13.7, Polygons of the OpenGL ES 3.2 Specification
265
266    Modify Section 13.7.1, Basic Polygon Rasterization
267
268    (insert before the paragraph starting with "As for the data associated...")
269
270    The determination of which fragments are produced by polygon rasterization
271    can be modified by the conservative rasterization option (as described in
272    section 13.7.1).
273
274    Modify Section 13.7.1, Basic Polygon Rasterization
275
276    (add at the end)
277
278    The determination of which fragments are produced as a result of polygon
279    rasterization can be modified by enabling the conservative rasterization
280    option. Conservative rasterization is enabled or disabled with the generic
281    Enable and Disable commands using the symbolic constant
282    CONSERVATIVE_RASTERIZATION_INTEL. When disabled, the fragments are
283    determined as described in this section. When enabled the polygon
284    rasterization produces all fragments for which any part of their squares
285    are inside the polygon, after expanding the polygon by 1/512th of pixel in
286    both x and y dimensions. Polygons with an area of zero do generate
287    fragments.
288
289    The conservative rasterization option applies only to polygons. Draw
290    requests for other primitive types (points/lines) generate
291    INVALID_OPERATION error.
292
293    Modify Section 13.7.3, Polygon Multisample Rasterization
294
295    (modify the first paragraph)
296
297    If the value of SAMPLE_BUFFERS is one, then polygons are rasterized using
298    the following algorithm. When conservative rasterization is disabled,
299    polygon rasterization produces a fragment for each framebuffer pixel with
300    one or more sample points that satisfy the point sampling criteria
301    described in section 13.7.1. If a polygon is culled, based on its
302    orientation and the CullFace mode, then no fragments are produced during
303    rasterization.
304
305    If conservative rasterization is enabled, polygon rasterization produces
306    exactly the same fragments as with the value of SAMPLE_BUFFERS set to
307    zero. Also, all sample coverage bits for fragments produced by
308    rasterization are 1, other coverage bits are 0. If a polygon is culled,
309    based on its orientation and the CullFace mode, then no fragments are
310    produced during rasterization.
311
312
313Additions to Chapter 14.2.2, Shader Inputs of the OpenGL ES 3.2 Specification
314
315    (replace the sentence starting with "Bit<n> of element<w> in the array...")
316
317    Bit <n> of element <w> in the array is set if and only if the sample
318    numbered <32w + n> is considered covered for this fragment shader
319    invocation. If the fragment shader specifies the "early_fragment_tests" and
320    "post_depth_coverage" layout qualifiers, then the sample is considered
321    covered if and only if the sample is covered by the primitive and the
322    sample passes the early fragment tests (as described in Section 15.2.4). If
323    these layout qualifiers are not specified, then the sample is considered
324    covered if the sample is covered by the primitive, regardless of the result
325    of the fragment tests. If the fragment shader specifies the
326    "inner_coverage" layout qualifier the sample is considered covered only if
327    the sample is covered by the primitive and passes the inner coverage
328    test. Layout qualifier "inner_coverage" is in effect only if conservative
329    is enabled and is mutually exclusive with "post_depth_coverage".
330
331    During the conservative rasterization process (section 13.7.2) for the
332    purpose of the inner coverage test the determination is made if the
333    fragment is entirely contained within the polygon. This determination is
334    made by shrinking the polygon by 1/512th of pixel along the x and y
335    dimensions. The result of the inner coverage test is available in
336    gl_SampleMaskIn if "inner_coverage" layout qualifier is present.
337
338    (replace the paragraph starting with "When per-sample shading is active due
339    to the use of a fragment input qualified...")
340
341    In the case of per-sample shading the information delivered via
342    gl_SampleMaskIn depends on the conservative rasterization state and
343    possibly on the layout qualifier. Regardless of the conservative
344    rasterization state, samples killed due to SAMPLE_COVERAGE or SAMPLE_MASK
345    are never reported in gl_SampleMaskIn regardless of the qualifier.
346
347    With conservative rasterization disabled, when per-sample shading is active
348    due to the use of a fragment input qualified by sample or due to the use of
349    the gl_SampleID or gl_SamplePosition variables, only the bit for the
350    current sample is set in gl_SampleMaskIn. When state specifies multiple
351    fragment shader invocations for a given fragment, the sample mask for any
352    single fragment shader invocation may specify a subset of the covered
353    samples for the fragment. In this case, the bit corresponding to each
354    covered sample will be set in exactly one fragment shader invocation.
355
356    With conservative rasterization enabled, regardless of whether per-sample
357    shading is active due to fragment input qualified by sample or by state,
358    the meaning of the gl_SampleMaskIn depends on layout qualifier and is the
359    same for both per-sample triggering conditions. Moreover as a consequence
360    of rasterization rules described in section 13.7.3, when conservative
361    rasterization is enabled and MULITISAMPLE is enabled and the value of
362    SAMPLE_BUFFERS is one, either all samples of a given fragment are covered, or
363    none.
364
365    * No layout qualifier present:
366      The sample mask for any single fragment shader invocation specifies all
367      samples covered by a conservatively rasterized fragment.
368
369    * Layout qualifier "inner_coverage":
370      The sample mask for any single fragment shader invocation specifies all
371      samples covered by a conservatively rasterized fragment that passed inner
372      coverage test.
373
374    * Layout qualifier "post_depth_coverage":
375      The sample mask for any single fragment shader invocation specifies all
376      samples covered by a conservatively rasterized fragment that passed early
377      depth/stencil tests if enforced by early_fragment_tests layout qualifier.
378
379    If the value of SAMPLE_BUFFERS is one, and per sample shading is not
380    active, the meaning of gl_SampleMaskIn[] and its modifications due to
381    layout qualifier are exactly the same as described above.
382
383
384Additions to the OpenGL ES Shading Language Specification, version 3.20.2
385
386    Including the following line in a shader can be used to control the
387    language features described in this extension:
388
389      #extension GL_INTEL_conservative_rasterization : <behavior>
390
391    where <behavior> is as specified in section 3.3.
392
393    A new preprocessor #define is added to the OpenGL Shading Language:
394
395      #define GL_INTEL_conservative_rasterization 1
396
397    Modify section 4.4.1.3, Fragment Shader Inputs
398
399    (replace the discussion of early_fragment_tests)
400
401    Fragment shaders also allow the following layout qualifiers on "in" only (not
402    with variable declarations)
403
404        layout-qualifier-id
405            early_fragment_tests
406            post_depth_coverage
407            inner_coverage
408
409    For example,
410
411        layout(early_fragment_tests) in;
412        layout(post_depth_coverage) in;
413        layout(inner_coverage) in;
414
415    "early_fragment_tests" requests that fragment tests be performed before
416    fragment shader execution, as described in section 13.8 "Early Fragment
417    Tests" of the OpenGL ES Specification. If neither this nor post_depth_coverage
418    are declared, per-fragment tests will be performed after fragment shader
419    execution.
420
421    "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will
422    reflect the result of the early fragment tests, as described in section
423    14.2.2 "Shader Inputs" of the OpenGL ES 3.2 Specification. Use of this
424    qualifier implicitly requests that fragment tests be performed before
425    fragment shader execution.
426
427    "inner_coverage" requests that the built-in
428    "gl_SampleMaskIn[]" will reflect the result of the inner coverage test
429    as described in section 14.2.2 "Shader Inputs" of the OpenGL ES 3.2
430    Specification. It has an effect on "gl_SampleMaskIn[]" only if conservative
431    rasterization is enabled.
432
433    "post_depth_coverage" and "inner_coverage" are mutually
434    exclusive. Declaring both for a fragment shader will result in compile or
435    link error.
436
437Additions to the AGL/GLX/WGL Specifications
438
439    None.
440
441GLX Protocol
442
443    None.
444
445Interactions with ARB_post_depth_coverage
446
447    This extension is a fully compatible superset of ARB_post_depth_coverage
448    extension. Implementations supporting INTEL_conservative_rasterization may
449    or may not advertise ARB_post_depth_coverage without any changes in
450    functionality.
451
452Errors
453
454    None.
455
456New State in OpenGL 4.5 Core Profile
457
458    (add new row to the Table 23.10, Rasterization (cont.)
459
460                                     Initial
461    Get Value      Type  Get Command  Value  Description                 Sec.
462    -------------  ----  ----------- ------- -------------------------   ------
463    CONSERVATIVE_  B     IsEnabled()  FALSE  Conservative Rasterization  14.6.4
464    RASTERIZATION_                           setting
465    INTEL
466
467New State in OpenGL ES 3.2
468
469    (add new row to the Table 21.7, Rasterization)
470
471                                     Initial
472    Get Value      Type  Get Command  Value  Description                 Sec.
473    -------------  ----  ----------- ------- -------------------------   ------
474    CONSERVATIVE_  B     IsEnabled()  FALSE  Conservative Rasterization  3.6
475    RASTERIZATION_                           setting
476    INTEL
477
478Issues
479
480    (1) Why in per-sample shading case, when conservative rasterization is
481        disabled, each sample is reported exactly once in gl_SampleMaskIn
482        across all invocations of fragment shader for given fragment, while
483        when conservative rasterization is enabled, all eligible samples from
484        the given fragment are reported for each fragment shader invocation for
485        this fragment?
486
487        Resolved. The former behavior is enforced by existing OpenGL
488        spec. The latter, provided by this extension, gives more information to
489        the user about neighboring samples. In the extended version, the
490        information about current sample can be obtained in the
491        gl_SampleMaskIn[] as indicated by gl_SampleID.
492
493
494Revision History
495
496    Rev.     Date       Author       Changes
497    ----  ----------  ----------  -----------------------------------------
498      2    11/2/2016  sgrajewski  Updated to OpenGL 4.5 and OpenGL ES 3.2.
499                                  Aligned with ARB_post_dept_coverage extension.
500
501      1    10/1/2013  sgrajewski  Initial revision.
502