• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2    QCOM_shader_framebuffer_fetch_rate
3
4Name Strings
5
6    GL_QCOM_shader_framebuffer_fetch_rate
7
8Contact
9
10    Jeff Leger ( jleger 'at' qti.qualcomm.com)
11
12Contributors
13
14    Jeff Leger, Qualcomm
15    Jonathan Wicks, Qualcomm
16
17Status
18
19    DRAFT
20
21Version
22
23    Last Modified Date:         August 20, 2018
24    Revision:                   1
25
26Number
27
28    OpenGL ES Extension #304
29
30
31Dependencies
32
33    OpenGL ES 2.0 and GLSL ES 1.00 are required.
34
35    This extension is written against the OpenGL ES 3.2 (May 14, 2018)
36    and the OpenGL ES Shading Language 3.20.4 Specification
37    (June 14, 2018) specifications.
38
39    This extension interacts with EXT_shader_framebuffer_fetch.
40    This extension interacts with ARM_shader_framebuffer_fetch_depth_stencil.
41
42Overview
43
44    When certain built-ins (e.g. gl_LastFragData, gl_LastFragStencilARM)
45    are referenced in the shader, the shader is required to execute at sample-rate
46    if the attachments are multisampled.  In some use-cases executing such shaders
47    at fragment-rate is actually the preferred behavior.  When this extension is
48    enabled, such GLSL shaders will execute at fragment-rate and the built-in
49    will return a per-fragment value.  This avoids the significant performance
50    penalty that would otherwise be incurred with sample-rate shading.
51
52    The following built-ins are affected when this extension is enabled:
53
54        gl_LastFragData      (from EXT_shader_framebuffer_fetch)
55        gl_LastFragDepthARM  (from ARM_shader_framebuffer_fetch_depth_stencil)
56
57    The following built-ins are disallowed when this extension is enabled:
58
59        gl_SampleID
60        gl_SamplePosition
61        interpolateAtSample()
62
63IP Status
64
65    No known IP claims.
66
67New Procedures and Functions
68
69    None
70
71New Tokens
72
73    None
74
75Additions to Chapter 13 of the OpenGL ES 3.2 Specification
76(Fixed-Function Primitive Assembly and Rasterization)
77
78    Modify Section 13.4.1, Sample Shading, p. 353
79
80    Modify the first paragraph:
81        "Sample shading can be used to specify a minimum number of unique samples
82        to process for each fragment. Sample shading is controlled by calling
83        Enable or Disable with target SAMPLE_SHADING."
84
85    by adding one sentence to the end:
86        "Sample shading can be used to specify a minimum number of unique samples
87        to process for each fragment. Sample shading is controlled by calling
88        Enable or Disable with target SAMPLE_SHADING.  For any fragment shader
89        that has forced fragment-rate by enabling QCOM_shader_framebuffer_fetch_rate,
90        such shader will execute as if SAMPLE_SHADING is disabled."
91
92Additions to Chapter 14 (Programmable Fragment Processing) of the OpenGL ES 3.2 Specification
93
94
95    Modify Section 14.2.2 (Shader Inputs), p. 372
96
97        Modify the sentence:
98            "Using gl_SampleID in a fragment shader causes the entire shader to
99            be executed per-sample."
100
101        to:
102            "Using gl_SampleID in a fragment shader causes the entire shader to
103            be executed per-sample.  If GL_QCOM_shader_framebuffer_fetch_rate is
104            enabled, any use of gl_SampleID will result in a compile or link error."
105
106        Modify the sentence:
107            "Using gl_SamplePosition in a fragment shader causes the entire shader to
108            be executed per-sample."
109
110        to:
111            "Using gl_SamplePosition in a fragment shader causes the entire shader to
112            be executed per-sample.  If GL_QCOM_shader_framebuffer_fetch_rate is
113            enabled, any use of gl_SamplePosition will result in a compile or link
114            error."
115
116
117    Modify Section 14.2.3 (Shader Outputs), p. 372
118
119        [[ The following applies if EXT_shader_framebuffer_fetch is supported ]]
120
121            In the new paragraphs added by EXT_shader_framebuffer_fetch to the end
122            this section, change the following added sentence:
123
124                From:
125                   "Reading from a user-defined fragment output declared inout
126                   causes the shader to be evaluated per-sample, since the
127                   framebuffer potentially contains different color values for
128                   each sample."
129
130                To:
131                  "If QCOM_shader_framebuffer_fetch_rate is not enabled, reading from
132                  a user-defined fragment output declared inout causes the shader
133                  to be evaluated per-sample, since the framebuffer potentially
134                  contains different color values for each sample."
135
136            Add the following paragraph to the end of "Shader Outputs" section:
137
138              "If the current rendertarget is multisampled and if
139              QCOM_shader_framebuffer_fetch_rate is enabled, then reading from
140              a user-defined fragment output declared inout will return an
141              implementation-dependent weighted average of the samples within
142              the destination pixel covered by the current fragment.  The value
143              will be between the minium and maximum value of the covered samples.
144              If the destination colors must be linearized from sRGB as
145              described in the preceding paragraphs, the conversion from sRGB
146              to linear happens before computing the weighted average.
147
148Additions to the EGL Specifications
149
150    None.
151
152Modifications to The OpenGL ES Shading Language Specification, Version 3.20.4
153
154    Changes to section 7.1.5. (Fragment Shader Special Variables), p 120.
155
156        Add the following at the start of this section:
157
158            "Static use of certain built-in variables described in this section
159            will cause the shader to be evaluated per-sample. This language feature
160            can be optionally disabled, forcing such shaders to evaluate per-
161            fragment.  The optional behavior can be enabled using:
162
163            #extension GL_QCOM_shader_framebuffer_fetch_rate : <behavior>
164
165            where <behavior> is as specified in section 3.4 (Preprocessor).
166
167            If GL_QCOM_shader_framebuffer_fetch_rate is enabled, it is a compile-time
168            or link-time error if any variable is declared with the "sample"
169            qualifier or if the built-in function interpolateAtSample() is statically
170            referenced."
171
172            Add the New preprocessor #defines are added to the OpenGL ES Shading Language:
173
174            "#define GL_QCOM_shader_framebuffer_fetch_rate  1"
175
176        Modify the last sentence of the paragraph starting with "The input variable
177        gl_SampleID is filled with the sample number of the sample currently being
178        processed"
179
180        from:
181            "Any static use of this variable in a fragment shader causes the entire
182            shader to be evaluated per-sample."
183        to
184            "If GL_QCOM_shader_framebuffer_fetch_rate is not enabled, any static use
185            of this variable in a fragment shader causes the entire shader to be evaluated
186            per-sample.  If GL_QCOM_shader_framebuffer_fetch_rate is enabled, an static
187            reference to gl_SampleID will cause a compile or link error."
188
189        Modify the last sentence of the paragraph starting with "The input variable
190        gl_SamplePosition contains the position of the current sample within the
191        multisample draw buffer."
192
193        from:
194            "Any static use of this variable in a fragment shader causes the entire
195            shader to be evaluated per-sample."
196        to
197            "If GL_QCOM_shader_framebuffer_fetch_rate is not enabled, any static use of
198            this variable in a fragment shader causes the entire shader to be evaluated
199            per-sample.  If GL_QCOM_shader_framebuffer_fetch_rate is enabled, an static
200            reference to gl_SamplePosition will cause a compile or link error."
201
202Interactions with EXT_shader_framebuffer_fetch.
203
204    Extension EXT_shader_framebuffer_fetch adds built-ins (gl_LastFragData[] for
205    version 1.0 shaders and inout variables version 3.0 shaders) that cause fragment
206    shaders to run at sample-rate.  This extension relaxes that requirement to
207    allow fragment-rate and specifies that the value returned from gl_LastFragData
208    will be an implementation-dependent weighted average of the covered pixels.
209
210Interactions with ARM_shader_framebuffer_fetch_depth_stencil.
211
212   Extension ARM_shader_framebuffer_fetch adds built-in "gl_LastFragDepthARM",
213   and specifies the value returned -- for both sample-rate and fragment-rate
214   execution.  This extension can be used to control whether sample-rate or
215   fragment-rate execution is used.
216
217Errors
218
219    None.
220
221New State
222
223    None.
224
225New Implementation Dependent State
226
227    None
228
229Issues
230
231    (1) Does it make sense to enable this extension for a shader that references
232        per-sample built-ins like gl_SampleID and gl_SamplePosition?
233
234        RESOLVED: No.  It doesn't make sense to force fragment-rate
235        execution using this extension, while also referencing per-sample
236        built-ins.  Since there is no known use-case, this will be a compile
237        or link error.
238
239        For the same reason, using the "sample" qualifier or using
240        interpolateAtSample() will cause a compile or link error.
241
242    (2) How does this extension interact with API-controlled sample-rate shading?
243
244        RESOLVED: For shaders that enable this this extension, those the shaders
245        will always execute at fragment-rate, regardless of other API states.
246        In particular, the enable/disable of SAMPLE_SHADING and the value of
247        MIN_SAMPLE_SHADING_VALUE will have no effect on such shaders.
248
249    (3) How does this extension differ from ARM_shader_framebuffer_fetch?
250
251        ARM_shader_framebuffer_fetch provides a means for controlling whether
252        shaders fetching color from the framebuffer should execute at sample-rate or
253        fragement rate.  The API state "FETCH_PER_SAMPLE_ARM" controls
254        this behavior.
255
256        This extension also provides control over sample-rate vs fragment-rate
257        for framebuffer fetch shaders, but does so in the GLSL shader.  Some
258        implementations require this information at shader compile time.
259
260Revision History
261
262    Rev.    Date      Author    Changes
263    ----  ----------  --------  -----------------------------------------
264    1     2018-08-20  jleger     initial version
265