• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_primitive_shading_rate
4
5Name Strings
6
7    GL_NV_primitive_shading_rate
8
9Contact
10
11    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
12
13Contributors
14
15    Jeff Bolz, NVIDIA
16
17Status
18
19    Shipping
20
21Version
22
23    Last Modified:      October 30, 2020
24    Revision:           1
25
26Number
27
28    OpenGL Extension #554
29    OpenGL ES Extension #332
30
31Dependencies
32
33    This extension is written against the OpenGL 4.6 Specification
34    (Compatibility Profile), dated February 2, 2019.
35
36    OpenGL 4.5 or OpenGL ES 3.2 is required.
37
38    NV_shading_rate_image is required.
39
40    This extension requires support from the OpenGL Shading Language (GLSL)
41    extension "NV_primitive_shading_rate", which can be found at the Khronos
42    Group Github site here:
43
44        https://github.com/KhronosGroup/GLSL
45
46    This extension interacts with NV_mesh_shader.
47
48Overview
49
50    This extension builds on top of the NV_shading_rate_image extension to
51    provide OpenGL API support for using a per-primitive shading rate value to
52    control the computation of the rate used to process each fragment.
53
54    In the NV_shading_rate_image extension, the shading rate for each fragment
55    produced by a primitive is determined by looking up a texel in the bound
56    shading rate image and using that value as an index into a shading rate
57    palette.  That extension provides a separate shading rate image lookup
58    enable and palette for each viewport.  When a primitive is rasterized, the
59    implementation uses the enable and palette associated with the primitive's
60    viewport to determine the shading rate.
61
62    This extension decouples the shading rate image enables and palettes from
63    viewports.  The number of enables/palettes now comes from the
64    implementation-dependent constant SHADING_RATE_IMAGE_PALETTE_COUNT_NV.  When
65    SHADING_RATE_IMAGE_PER_PRIMITIVE_NV (added here) is enabled, the value of
66    the new gl_ShadingRateNV built-in output is used to select an enable and
67    palette to determine the shading rate.  Otherwise, the viewport number for
68    the primitive is used, as in NV_shading_rate_image.
69
70
71New Procedures and Functions
72
73    None.
74
75
76New Tokens
77
78    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled and by the
79    <pname> parameter of GetBooleanv, GetIntegerv, GetInteger64v, GetFloatv,
80    GetDoublev:
81
82        SHADING_RATE_IMAGE_PER_PRIMITIVE_NV             0x95B1
83
84    Accepted by the <pname> parameter of GetBooleanv, GetDoublev,
85    GetIntegerv, and GetFloatv:
86
87        SHADING_RATE_IMAGE_PALETTE_COUNT_NV             0x95B2
88
89
90Modifications to the OpenGL 4.6 Specification (Compatibility Profile)
91
92    Modify Section 14.3.1, Multisampling, as modified by the
93    NV_shading_rate_image extension.
94
95    (modify the introduction of the shading rate image functionality to decouple
96    shading rate image enables and viewports)
97
98    When using a shading rate image (Section 14.4.1), rasterization may produce
99    fragments covering multiple pixels, where each pixel is treated as a sample.
100    If any of the SHADING_RATE_IMAGE_NV enables is enabled, primitives will be
101    processed with multisample rasterization rules, regardless of the
102    MULTISAMPLE enable or the value of SAMPLE_BUFFERS.  ...
103
104
105    Modify Section 14.4.1, Shading Rate Image, as added by the
106    NV_shading_rate_image extension.
107
108    (rework the introduction of the shading rate image functionality to decouple
109    shading rate image enables and viewports)
110
111    Applications can specify the use of a shading rate that varies by (x,y)
112    location using a _shading rate image_.  For each primitive, the shading rate
113    image is enabled or disabled by selecting a single enable in an array of
114    enables whose size is given by the implementation-dependent constant
115    SHADING_RATE_IMAGE_PALETTE_COUNT_NV.  Use of a shading rate image is enabled
116    or disabled globally by using Enable or Disable with target
117    SHADING_RATE_IMAGE_NV.  A single shading rate image enable can be modified
118    by calling Enablei or Disablei with the constant SHADING_RATE_IMAGE_NV and
119    the index of the selected enable.  The shading rate image may only be used
120    with a framebuffer object.  When rendering to the default framebuffer, the
121    shading rate image enables are ignored and operations in this section are
122    disabled.  In the initial state, all shading rate image enables are
123    disabled.
124
125    The method used to select a single shading rate image enable used to process
126    each primitive is controlled by calling Enable or Disable with the target
127    SHADING_RATE_IMAGE_PER_PRIMITIVE_NV.  When enabled, a shading rate enable
128    used for a primitive is selected using an index taken from the value of the
129    built-in output gl_ShadingRateNV for the primitive's provoking vertex.  If
130    the value of gl_ShadingRateNV is negative or greater than or equal to the
131    number of shading rate enables, the shading rate used for a primitive is
132    undefined.  When SHADING_RATE_IMAGE_PER_PRIMITIVE_NV is disabled, a shading
133    rate enable is selected using the index of the viewport used for processing
134    the primitive.  In the initial state, SHADING_RATE_IMAGE_PER_PRIMITIVE_NV is
135    disabled.
136
137
138    (rework the introduction of the shading rate image functionality to decouple
139    shading rate image palettes and viewports)
140
141    A shading rate index is mapped to a _base shading rate_ using a lookup table
142    called the shading rate image palette.  There is a separate palette
143    associated with each shading rate image enable.  As with the shading rate
144    image enables, a single palette is selected for a primitive according to the
145    enable SHADING_RATE_IMAGE_PER_PRIMITIVE_NV.  The number of palettes and the
146    number of entries in each palette are given by the implementation-dependent
147    constants SHADING_RATE_IMAGE_PALETTE_COUNT_NV and
148    SHADING_RATE_IMAGE_PALETTE_SIZE_NV, respectively.  The base shading rate for
149    an (x,y) coordinate with a shading rate index of <i> will be given by entry
150    <i> of the selected palette.  If the shading rate index is greater than or
151    equal to the palette size, the results of the palette lookup are undefined.
152
153
154    (rework the introduction of ShadingRateImagePaletteNV to decouple shading
155    rate image palettes and viewports)
156
157      Shading rate image palettes are updated using the command
158
159        void ShadingRateImagePaletteNV(uint viewport, uint first, sizei count,
160                                       const enum *rates);
161
162      <viewport> specifies the number of the palette that should be updated.
163      [[ Note:  The formal parameter name <viewport> is a remnant of the
164      original NV_shading_rate_image extension, where palettes were tightly
165      coupled with viewports. ]]  <rates> is an array ...
166
167
168    (modify the discussion of ShadingRateImagePaletteNV errors to decouple
169    shading rate image palettes and viewports)
170
171        INVALID_VALUE is generated if <viewport> is greater than or equal to
172        SHADING_RATE_IMAGE_PALETTE_COUNT_NV.
173
174        INVALID_VALUE is generated if <first> plus <count> is greater than
175        SHADING_RATE_IMAGE_PALETTE_SIZE_NV.
176
177
178    (modify the discussion of GetShadingRateImagePaletteNV to decouple shading
179    rate image palettes and viewports)
180
181      Individual entries in the shading rate palette can be queried using the
182      command:
183
184        void GetShadingRateImagePaletteNV(uint viewport, uint entry,
185                                          enum *rate);
186
187      where <viewport> specifies the number of the palette to query and...
188      <entry> specifies the palette entry number.  [[ Note:  The formal
189      parameter name <viewport> is a remnant of the original
190      NV_shading_rate_image extension, where palettes were tightly coupled
191      with viewports. ]]  A single enum from Table X.1 is returned in <rate>.
192
193      Errors
194
195        INVALID_VALUE is generated if <viewport> is greater than or equal to
196        SHADING_RATE_IMAGE_PALETTE_COUNT_NV.
197
198        INVALID_VALUE is generated if <first> plus <count> is greater than
199        SHADING_RATE_IMAGE_PALETTE_SIZE_NV.
200
201
202    Modify Section 14.9.3, Multisample Fragment Operations, as edited by
203    NV_shading_rate_image.
204
205    (modify the discussion of the shading rate image multisample functionality
206    to decouple shading rate image enables and viewports)
207
208    ... This step is skipped if MULTISAMPLE is disabled or if the value of
209    SAMPLE_BUFFERS is not one, unless one or more of the SHADING_RATE_IMAGE_NV
210    enables are enabled.
211
212
213Dependencies on NV_mesh_shader
214
215    When NV_mesh_shader is supported, the "NV_primitive_shading_rate" GLSL
216    extension allows multi-view mesh shaders to write separate per-primitive
217    shading rates for each view using the built-in gl_ShadingRatePerViewNV[].
218    When gl_ShadingRatePerViewNV[] is used with
219    SHADING_RATE_IMAGE_PER_PRIMITIVE_NV enabled, a separate shading rate image
220    enable and palette will be used for each view.
221
222
223Additions to the AGL/GLX/WGL Specifications
224
225    None
226
227Errors
228
229    See the "Errors" sections for individual commands above.
230
231New State
232
233    Get Value                   Get Command        Type    Initial Value    Description                 Sec.    Attribute
234    ---------                   ---------------    ----    -------------    -----------                 ----    ---------
235    SHADING_RATE_IMAGE_         IsEnabled           B      FALSE            Use per-primitive shading   14.4.1  enable
236      PER_PRIMITIVE_NV                                                      rate to select shading
237                                                                            rate images/palettes
238
239New Implementation Dependent State
240
241                                                    Minimum
242    Get Value                Type  Get Command      Value   Description                   Sec.
243    ---------                ----- ---------------  ------- ------------------------      ------
244    SHADING_RATE_IMAGE_      Z+    GetIntegerv      16      Number of shading rate image  14.4.1
245      PALETTE_COUNT_NV                                      enables/palettes supported
246
247Issues
248
249    (1) How should we name this extension?
250
251      RESOLVED:  We are calling this extension "NV_primitive_shading_rate"
252      because it adds a new per-primitive shading rate to the variable-rate
253      shading functionality added by NV_shading_rate_image.
254
255    (2) Do we need to add queries like LAYER_PROVOKING_VERTEX and
256        VIEWPORT_INDEX_PROVOKING_VERTEX to determine the vertex used to obtain
257        the per-primitive shading rate for each primitive?
258
259      RESOLVED:  No -- we will always use the provoking vertex.  In the event
260      that this extension is standardized in the future with behavior that
261      diverges between implementations, such a query could be added as part of
262      that effort.
263
264Revision History
265
266    Revision 1 (pbrown)
267    - Internal revisions.
268