15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_shading_rate_image 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_shading_rate_image 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Daniel Koch, NVIDIA 165bd8deadSopenharmony_ci Mark Kilgard, NVIDIA 175bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 185bd8deadSopenharmony_ci Mathias Schott, NVIDIA 195bd8deadSopenharmony_ci Pyarelal Knowles, NVIDIA 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciStatus 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Shipping 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ciVersion 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ci Last Modified: March 16, 2020 285bd8deadSopenharmony_ci Revision: 3 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ciNumber 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ci OpenGL Extension #531 335bd8deadSopenharmony_ci OpenGL ES Extension #315 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci This extension is written against the OpenGL 4.5 Specification 385bd8deadSopenharmony_ci (Compatibility Profile), dated October 24, 2016. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci OpenGL 4.5 or OpenGL ES 3.2 is required. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci This extension requires support for the OpenGL Shading Language (GLSL) 435bd8deadSopenharmony_ci extension "NV_shading_rate_image", which can be found at the Khronos Group 445bd8deadSopenharmony_ci Github site here: 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci https://github.com/KhronosGroup/GLSL 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci This extension interacts trivially with ARB_sample_locations and 495bd8deadSopenharmony_ci NV_sample_locations. 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci This extension interacts with NV_scissor_exclusive. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci This extension interacts with NV_conservative_raster. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci This extension interacts with NV_conservative_raster_underestimation. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci This extension interacts with EXT_raster_multisample. 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci NV_framebuffer_mixed_samples is required. 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci If implemented in OpenGL ES, at least one of NV_viewport_array or 625bd8deadSopenharmony_ci OES_viewport_array is required. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ciOverview 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci By default, OpenGL runs a fragment shader once for each pixel covered by a 675bd8deadSopenharmony_ci primitive being rasterized. When using multisampling, the outputs of that 685bd8deadSopenharmony_ci fragment shader are broadcast to each covered sample of the fragment's 695bd8deadSopenharmony_ci pixel. When using multisampling, applications can also request that the 705bd8deadSopenharmony_ci fragment shader be run once per color sample (when using the "sample" 715bd8deadSopenharmony_ci qualifier on one or more active fragment shader inputs), or run a fixed 725bd8deadSopenharmony_ci number of times per pixel using SAMPLE_SHADING enable and the 735bd8deadSopenharmony_ci MinSampleShading frequency value. In all of these approaches, the number 745bd8deadSopenharmony_ci of fragment shader invocations per pixel is fixed, based on API state. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci This extension allows applications to bind and enable a shading rate image 775bd8deadSopenharmony_ci that can be used to vary the number of fragment shader invocations across 785bd8deadSopenharmony_ci the framebuffer. This can be useful for applications like eye tracking 795bd8deadSopenharmony_ci for virtual reality, where the portion of the framebuffer that the user is 805bd8deadSopenharmony_ci looking at directly can be processed at high frequency, while distant 815bd8deadSopenharmony_ci corners of the image can be processed at lower frequency. The shading 825bd8deadSopenharmony_ci rate image is an immutable-format two-dimensional or two-dimensional array 835bd8deadSopenharmony_ci texture that uses a format of R8UI. Each texel represents a fixed-size 845bd8deadSopenharmony_ci rectangle in the framebuffer, covering 16x16 pixels in the initial 855bd8deadSopenharmony_ci implementation of this extension. When rasterizing a primitive covering 865bd8deadSopenharmony_ci one of these rectangles, the OpenGL implementation reads the texel in the 875bd8deadSopenharmony_ci bound shading rate image and looks up the fetched value in a palette of 885bd8deadSopenharmony_ci shading rates. The shading rate used can vary from (finest) 16 fragment 895bd8deadSopenharmony_ci shader invocations per pixel to (coarsest) one fragment shader invocation 905bd8deadSopenharmony_ci for each 4x4 block of pixels. 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci When this extension is advertised by an OpenGL implementation, the 935bd8deadSopenharmony_ci implementation must also support the GLSL extension 945bd8deadSopenharmony_ci "GL_NV_shading_rate_image" (documented separately), which provides new 955bd8deadSopenharmony_ci built-in variables that allow fragment shaders to determine the effective 965bd8deadSopenharmony_ci shading rate used for each fragment. Additionally, the GLSL extension also 975bd8deadSopenharmony_ci provides new layout qualifiers allowing the interlock functionality provided 985bd8deadSopenharmony_ci by ARB_fragment_shader_interlock to guarantee mutual exclusion across an 995bd8deadSopenharmony_ci entire fragment when the shading rate specifies multiple pixels per fragment 1005bd8deadSopenharmony_ci shader invocation. 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci Note that this extension requires the use of a framebuffer object; the 1035bd8deadSopenharmony_ci shading rate image and related state are ignored when rendering to the 1045bd8deadSopenharmony_ci default framebuffer. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ciNew Procedures and Functions 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci void BindShadingRateImageNV(uint texture); 1095bd8deadSopenharmony_ci void ShadingRateImagePaletteNV(uint viewport, uint first, sizei count, 1105bd8deadSopenharmony_ci const enum *rates); 1115bd8deadSopenharmony_ci void GetShadingRateImagePaletteNV(uint viewport, uint entry, 1125bd8deadSopenharmony_ci enum *rate); 1135bd8deadSopenharmony_ci void ShadingRateImageBarrierNV(boolean synchronize); 1145bd8deadSopenharmony_ci void ShadingRateSampleOrderNV(enum order); 1155bd8deadSopenharmony_ci void ShadingRateSampleOrderCustomNV(enum rate, uint samples, 1165bd8deadSopenharmony_ci const int *locations); 1175bd8deadSopenharmony_ci void GetShadingRateSampleLocationivNV(enum rate, uint samples, 1185bd8deadSopenharmony_ci uint index, int *location); 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ciNew Tokens 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by the 1235bd8deadSopenharmony_ci <target> parameter of Enablei, Disablei, IsEnabledi, EnableIndexedEXT, 1245bd8deadSopenharmony_ci DisableIndexedEXT, and IsEnabledIndexedEXT, and by the <pname> parameter 1255bd8deadSopenharmony_ci of GetBooleanv, GetIntegerv, GetInteger64v, GetFloatv, GetDoublev, 1265bd8deadSopenharmony_ci GetDoubleIndexedv, GetBooleani_v, GetIntegeri_v, GetInteger64i_v, 1275bd8deadSopenharmony_ci GetFloati_v, GetDoublei_v, GetBooleanIndexedvEXT, GetIntegerIndexedvEXT, 1285bd8deadSopenharmony_ci and GetFloatIndexedvEXT: 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV 0x9563 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci Accepted in the <rates> parameter of ShadingRateImagePaletteNV and the 1335bd8deadSopenharmony_ci <rate> parameter of ShadingRateSampleOrderCustomNV and 1345bd8deadSopenharmony_ci GetShadingRateSampleLocationivNV; returned in the <rate> parameter of 1355bd8deadSopenharmony_ci GetShadingRateImagePaletteNV: 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci SHADING_RATE_NO_INVOCATIONS_NV 0x9564 1385bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 1395bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 1405bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 1415bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 1425bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 1435bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A 1445bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B 1455bd8deadSopenharmony_ci SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C 1465bd8deadSopenharmony_ci SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D 1475bd8deadSopenharmony_ci SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E 1485bd8deadSopenharmony_ci SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetDoublev, 1515bd8deadSopenharmony_ci GetIntegerv, and GetFloatv: 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci SHADING_RATE_IMAGE_BINDING_NV 0x955B 1545bd8deadSopenharmony_ci SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C 1555bd8deadSopenharmony_ci SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D 1565bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E 1575bd8deadSopenharmony_ci MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci Accepted by the <order> parameter of ShadingRateSampleOrderNV: 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE 1625bd8deadSopenharmony_ci SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF 1635bd8deadSopenharmony_ci SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ciModifications to the OpenGL 4.5 Specification (Compatibility Profile) 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci Modify Section 14.3.1, Multisampling, p. 532 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci (add to the end of the section) 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci When using a shading rate image (Section 14.4.1), rasterization may 1735bd8deadSopenharmony_ci produce fragments covering multiple pixels, where each pixel is treated as 1745bd8deadSopenharmony_ci a sample. If SHADING_RATE_IMAGE_NV is enabled for any viewport, 1755bd8deadSopenharmony_ci primitives will be processed with multisample rasterization rules, 1765bd8deadSopenharmony_ci regardless of the MULTISAMPLE enable or the value of SAMPLE_BUFFERS. If 1775bd8deadSopenharmony_ci the framebuffer has no multisample buffers, each pixel is treated as 1785bd8deadSopenharmony_ci having a single sample located at the pixel center. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci Delete Section 14.3.1.1, Sample Shading, p. 532. The functionality in 1825bd8deadSopenharmony_ci this section is moved to the new Section 14.4, "Shading Rate Control". 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci Add new section before Section 14.4, Points, p. 533 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci Section 14.4, Shading Rate Control 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci By default, each fragment processed by programmable fragment processing 1905bd8deadSopenharmony_ci (chapter 15) [[compatibility only: or fixed-function fragment processing 1915bd8deadSopenharmony_ci (chapter 16)]] corresponds to a single pixel with a single (x,y) 1925bd8deadSopenharmony_ci coordinate. When using multisampling, implementations are permitted to run 1935bd8deadSopenharmony_ci separate fragment shader invocations for each sample, but often only run a 1945bd8deadSopenharmony_ci single invocation for all samples of the fragment. We will refer to the 1955bd8deadSopenharmony_ci density of fragment shader invocations in a particular framebuffer region 1965bd8deadSopenharmony_ci as the _shading rate_. Applications can use the shading rate to increase 1975bd8deadSopenharmony_ci the size of fragments to cover multiple pixels and reduce the amount of 1985bd8deadSopenharmony_ci fragment shader work. Applications can also use the shading rate to 1995bd8deadSopenharmony_ci explicitly control the minimum number of fragment shader invocations when 2005bd8deadSopenharmony_ci multisampling. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci Section 14.4.1, Shading Rate Image 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci Applications can specify the use of a shading rate that varies by (x,y) 2065bd8deadSopenharmony_ci location using a _shading rate image_. Use of a shading rate image is 2075bd8deadSopenharmony_ci enabled or disabled for all viewports using Enable or Disable with target 2085bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV. Use of a shading rate image is enabled or disabled 2095bd8deadSopenharmony_ci for a specific viewport using Enablei or Disablei with the constant 2105bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV and the index of the selected viewport. The shading 2115bd8deadSopenharmony_ci rate image may only be used with a framebuffer object. When rendering to 2125bd8deadSopenharmony_ci the default framebuffer, the shading rate image operations in this section 2135bd8deadSopenharmony_ci are disabled. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci The shading rate image is a texture that can be bound with the command 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci void BindShadingRateImageNV(uint texture); 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci This command unbinds the current shading rate image, if any. If <texture> 2205bd8deadSopenharmony_ci is zero, no new texture is bound. If <texture> is non-zero, it must be 2215bd8deadSopenharmony_ci the name of an existing immutable-format texture with a target of 2225bd8deadSopenharmony_ci TEXTURE_2D or TEXTURE_2D_ARRAY with a format of R8UI. If <texture> has 2235bd8deadSopenharmony_ci multiple mipmap levels, only the base level will be used as the shading 2245bd8deadSopenharmony_ci rate image. 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci Errors 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci INVALID_VALUE is generated if <texture> is not zero and is not the 2295bd8deadSopenharmony_ci name of an existing texture object. 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci INVALID_OPERATION is generated if <texture> is not an immutable-format 2325bd8deadSopenharmony_ci texture, has a format other than R8UI, or has a texture target other 2335bd8deadSopenharmony_ci than TEXTURE_2D or TEXTURE_2D_ARRAY. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci When rasterizing a primitive covering pixel (x,y) with a shading rate 2365bd8deadSopenharmony_ci image having a target of TEXTURE_2D, a two-dimensional texel coordinate 2375bd8deadSopenharmony_ci (u,v) is generated, where: 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci u = floor(x / SHADING_RATE_IMAGE_TEXEL_WIDTH_NV) 2405bd8deadSopenharmony_ci v = floor(y / SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV) 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ci and where SHADING_RATE_IMAGE_TEXEL_WIDTH_NV and 2435bd8deadSopenharmony_ci SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV are the width and height of the 2445bd8deadSopenharmony_ci implementation-dependent footprint of each shading rate image texel in the 2455bd8deadSopenharmony_ci framebuffer. If the bound shading rate image has a target of 2465bd8deadSopenharmony_ci TEXTURE_2D_ARRAY, a three-dimensional texture coordinate (u,v,w) is 2475bd8deadSopenharmony_ci generated, where u and v are computed as above. The coordinate w is set 2485bd8deadSopenharmony_ci to the layer L of the framebuffer being rendered to if L is less than the 2495bd8deadSopenharmony_ci number of layers in the shading rate image, or zero otherwise. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci If a texel with coordinates (u,v) or (u,v,w) exists in the bound shading 2525bd8deadSopenharmony_ci rate image, the value of the 8-bit R component of the texel is used as the 2535bd8deadSopenharmony_ci shading rate index. If the (u,v) or (u,v,w) coordinate is outside the 2545bd8deadSopenharmony_ci extent of the shading rate image, or if no shading rate image is bound, 2555bd8deadSopenharmony_ci zero will be used as the shading rate index. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci A shading rate index is mapped to a _base shading rate_ using a lookup 2585bd8deadSopenharmony_ci table called the shading rate image palette. There is a separate palette 2595bd8deadSopenharmony_ci for each viewport. The number of entries in each palette is given by the 2605bd8deadSopenharmony_ci implementation-dependent constant SHADING_RATE_IMAGE_PALETTE_SIZE_NV. The 2615bd8deadSopenharmony_ci base shading rate for an (x,y) coordinate with a shading rate index of <i> 2625bd8deadSopenharmony_ci will be given by palette entry <i>. If the shading rate index is greater 2635bd8deadSopenharmony_ci than or equal to the palette size, the results of the palette lookup are 2645bd8deadSopenharmony_ci undefined. 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Shading rate image palettes are updated using the command 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci void ShadingRateImagePaletteNV(uint viewport, uint first, sizei count, 2695bd8deadSopenharmony_ci const enum *rates); 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ci <viewport> specifies the number of the viewport whose palette should be 2725bd8deadSopenharmony_ci updated. <rates> is an array of <count> shading rate enums and is used to 2735bd8deadSopenharmony_ci update entries <first> through <first> + <count> - 1 in the palette. The 2745bd8deadSopenharmony_ci set of shading rate values accepted in <rates> is given in Table X.1. The 2755bd8deadSopenharmony_ci default value for all palette entries is 2765bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_PIXEL_NV. 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ci Shading Rate Size Invocations 2795bd8deadSopenharmony_ci ------------------------------------------- ----- ----------- 2805bd8deadSopenharmony_ci SHADING_RATE_NO_INVOCATIONS_NV - 0 2815bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 1x1 1 2825bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 1x2 1 2835bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 2x1 1 2845bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 2x2 1 2855bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 2x4 1 2865bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 4x2 1 2875bd8deadSopenharmony_ci SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 4x4 1 2885bd8deadSopenharmony_ci SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 1x1 2 2895bd8deadSopenharmony_ci SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 1x1 4 2905bd8deadSopenharmony_ci SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 1x1 8 2915bd8deadSopenharmony_ci SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 1x1 16 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci Table X.1: Shading rates accepted by ShadingRateImagePaletteNV. An 2945bd8deadSopenharmony_ci entry of "<W>x<H>" in the "Size" column indicates that the shading 2955bd8deadSopenharmony_ci rate results in fragments with a width and height (in pixels) of <W> 2965bd8deadSopenharmony_ci and <H>, respectively. The entry in the "Invocations" column 2975bd8deadSopenharmony_ci specifies the number of fragment shader invocations that should be 2985bd8deadSopenharmony_ci generated for each fragment. 2995bd8deadSopenharmony_ci 3005bd8deadSopenharmony_ci Errors 3015bd8deadSopenharmony_ci 3025bd8deadSopenharmony_ci INVALID_VALUE is generated if <viewport> is greater than or equal to 3035bd8deadSopenharmony_ci MAX_VIEWPORTS or if <first> plus <count> is greater than 3045bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV. 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci INVALID_ENUM is generated if any entry in <rates> is not a valid 3075bd8deadSopenharmony_ci shading rate. 3085bd8deadSopenharmony_ci 3095bd8deadSopenharmony_ci Individual entries in the shading rate palette can be queried using the 3105bd8deadSopenharmony_ci command: 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ci void GetShadingRateImagePaletteNV(uint viewport, uint entry, 3135bd8deadSopenharmony_ci enum *rate); 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci where <viewport> specifies the viewport of the palette to query and 3165bd8deadSopenharmony_ci <entry> specifies the palette entry number. A single enum from Table X.1 3175bd8deadSopenharmony_ci is returned in <rate>. 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ci Errors 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci INVALID_VALUE is generated if <viewport> is greater than or equal to 3225bd8deadSopenharmony_ci MAX_VIEWPORTS or if <entry> is greater than or equal to 3235bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV. 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci If the shading rate image is enabled, a base shading rate will be obtained 3265bd8deadSopenharmony_ci as described above. If the shading rate image is disabled, the base 3275bd8deadSopenharmony_ci shading rate will be SHADING_RATE_1_INVOCATION_PER_PIXEL_NV. In either 3285bd8deadSopenharmony_ci case, the shading rate will be adjusted as described in the following 3295bd8deadSopenharmony_ci sections. 3305bd8deadSopenharmony_ci 3315bd8deadSopenharmony_ci The rasterization hardware that reads from the shading rate image may 3325bd8deadSopenharmony_ci cache texels it reads for maximum performance. If the shading rate image 3335bd8deadSopenharmony_ci is updated using commands such as TexSubImage2D, image stores in shaders, 3345bd8deadSopenharmony_ci or by framebuffer writes performed when the shading rate image is bound to 3355bd8deadSopenharmony_ci a framebuffer object, this cache may retain out-of-date texture data. 3365bd8deadSopenharmony_ci Calling 3375bd8deadSopenharmony_ci 3385bd8deadSopenharmony_ci void ShadingRateImageBarrierNV(boolean synchronize); 3395bd8deadSopenharmony_ci 3405bd8deadSopenharmony_ci with <synchronize> set to TRUE ensures that rendering commands submitted 3415bd8deadSopenharmony_ci after the barrier don't access old shading rate image data updated 3425bd8deadSopenharmony_ci directly (TexSubImage2D) or indirectly (rendering, image stores) by 3435bd8deadSopenharmony_ci commands submitted before the barrier. If <synchronize> is set to FALSE, 3445bd8deadSopenharmony_ci ShadingRateImageBarrierNV doesn't wait on the completion of commands 3455bd8deadSopenharmony_ci submitted before the barrier. If an application has ensured that all 3465bd8deadSopenharmony_ci prior commands updating the shading rate image have completed using sync 3475bd8deadSopenharmony_ci objects or other mechanism, <synchronize> can be safely set to FALSE. 3485bd8deadSopenharmony_ci Otherwise, the lack of synchronization may cause subsequent rendering 3495bd8deadSopenharmony_ci commands to source the shading rate image before prior updates have 3505bd8deadSopenharmony_ci completed. 3515bd8deadSopenharmony_ci 3525bd8deadSopenharmony_ci 3535bd8deadSopenharmony_ci Section 14.4.2, Sample Shading 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci When the shading rate image is disabled, sample shading can be used to 3565bd8deadSopenharmony_ci specify a minimum number of fragment shader invocations to generate for 3575bd8deadSopenharmony_ci each fragment. When the shading rate image is enabled, sample shading can 3585bd8deadSopenharmony_ci be used to adjust the shading rate to increase the number of fragment 3595bd8deadSopenharmony_ci shader invocations generated for each primitive. Sample shading is 3605bd8deadSopenharmony_ci controlled by calling Enable or Disable with target SAMPLE_SHADING. If 3615bd8deadSopenharmony_ci MULTISAMPLE or SAMPLE_SHADING is disabled, sample shading has no effect. 3625bd8deadSopenharmony_ci 3635bd8deadSopenharmony_ci When sample shading is active, an integer sample shading factor is derived 3645bd8deadSopenharmony_ci based on the value provided in the command: 3655bd8deadSopenharmony_ci 3665bd8deadSopenharmony_ci void MinSampleShading(float value); 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ci When the shading rate image is disabled, a <value> of 0.0 specifies that 3695bd8deadSopenharmony_ci the minimum number of fragment shader invocations for the shading rate be 3705bd8deadSopenharmony_ci executed and a <value> of 1.0 specifies that a fragment shader should be 3715bd8deadSopenharmony_ci on each shadeable sample with separate values per sample. When the 3725bd8deadSopenharmony_ci shading rate image is enabled, <value> is used to derive a sample shading 3735bd8deadSopenharmony_ci rate that can adjust the shading rate. <value> is not clamped to [0.0, 3745bd8deadSopenharmony_ci 1.0]; values larger than 1.0 can be used to force larger adjustments to 3755bd8deadSopenharmony_ci the shading rate. 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci The sample shading factor is computed from <value> in an 3785bd8deadSopenharmony_ci implementation-dependent manner but must be greater than or equal to: 3795bd8deadSopenharmony_ci 3805bd8deadSopenharmony_ci factor = max(ceil(value * max_shaded_samples), 1) 3815bd8deadSopenharmony_ci 3825bd8deadSopenharmony_ci In this computation, <max_shaded_samples> is the maximum number of 3835bd8deadSopenharmony_ci fragment shader invocations per fragment, and is equal to: 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ci - the number of color samples, if the framebuffer has color attachments; 3865bd8deadSopenharmony_ci 3875bd8deadSopenharmony_ci - the number of depth/stencil samples, if the framebuffer has 3885bd8deadSopenharmony_ci depth/stencil attachments but no color attachments; or 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci - the value of FRAMEBUFFER_DEFAULT_SAMPLES if the framebuffer has no 3915bd8deadSopenharmony_ci attachments. 3925bd8deadSopenharmony_ci 3935bd8deadSopenharmony_ci If the framebuffer has non-multisample attachments, the maximum number of 3945bd8deadSopenharmony_ci shaded samples per pixel is always one. 3955bd8deadSopenharmony_ci 3965bd8deadSopenharmony_ci 3975bd8deadSopenharmony_ci Section 14.4.3, Shading Rate Adjustment 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci Once a base shading rate has been established, it is adjusted to produce a 4005bd8deadSopenharmony_ci final shading rate. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci First, if the base shading rate specifies multiple pixels for a fragment, 4035bd8deadSopenharmony_ci the shading rate is adjusted in an implementation-dependent manner to 4045bd8deadSopenharmony_ci limit the total number of coverage samples for the "coarse" fragment. 4055bd8deadSopenharmony_ci After adjustment, the maximum number of samples will not exceed the 4065bd8deadSopenharmony_ci implementation-dependent maximum MAX_COARSE_FRAGMENT_SAMPLES_NV. However, 4075bd8deadSopenharmony_ci implementations are permitted to clamp to a lower number of coverage 4085bd8deadSopenharmony_ci samples if required. Table X.2 describes the clamping performed in the 4095bd8deadSopenharmony_ci initial implementation of this extension. 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ci Coverage Samples per Pixel 4125bd8deadSopenharmony_ci Base rate 2 4 8 16 4135bd8deadSopenharmony_ci --------- ----- ----- ----- ----- 4145bd8deadSopenharmony_ci 1x2 - - - 1x1 4155bd8deadSopenharmony_ci 2x1 - - 1x1 1x1 4165bd8deadSopenharmony_ci 2x2 - - 1x2 1x1 4175bd8deadSopenharmony_ci 2x4 - 2x2 1x2 1x1 4185bd8deadSopenharmony_ci 4x2 2x2 2x2 1x2 1x1 4195bd8deadSopenharmony_ci 4x4 2x4 2x2 1x2 1x1 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci Table X.2, Coarse shading rate adjustment for total coverage sample 4225bd8deadSopenharmony_ci count for the initial implementation of this extension, where 4235bd8deadSopenharmony_ci MAX_COARSE_FRAGMENT_SAMPLES_NV is 16. The entries in the "2", "4", "8", 4245bd8deadSopenharmony_ci and "16" columns indicate the fragment size for the adjusted shading 4255bd8deadSopenharmony_ci rate. 4265bd8deadSopenharmony_ci 4275bd8deadSopenharmony_ci If sample shading is enabled and the sample shading factor is greater than 4285bd8deadSopenharmony_ci one, the base shading rate is further adjusted to result in more shader 4295bd8deadSopenharmony_ci invocations per pixel. Table X.3 describes how the shading rate is 4305bd8deadSopenharmony_ci adjusted in the initial implementation of this extension. 4315bd8deadSopenharmony_ci 4325bd8deadSopenharmony_ci Sample Shading Factor 4335bd8deadSopenharmony_ci Base rate 2 4 8 16 4345bd8deadSopenharmony_ci ---------- --------- ------- -------- -------- 4355bd8deadSopenharmony_ci 1x1 / 1 1x1 / 2 1x1 / 4 1x1 / 8 1x1 / 16 4365bd8deadSopenharmony_ci 1x2 / 1 1x1 / 1 1x1 / 2 1x1 / 4 1x1 / 8 4375bd8deadSopenharmony_ci 2x1 / 1 1x1 / 1 1x1 / 2 1x1 / 4 1x1 / 8 4385bd8deadSopenharmony_ci 2x2 / 1 1x2 / 1 1x1 / 1 1x1 / 2 1x1 / 4 4395bd8deadSopenharmony_ci 2x4 / 1 2x2 / 1 1x2 / 1 1x1 / 1 1x1 / 2 4405bd8deadSopenharmony_ci 4x2 / 1 2x2 / 1 2x1 / 1 1x1 / 1 1x1 / 2 4415bd8deadSopenharmony_ci 4x4 / 1 2x4 / 1 2x2 / 1 1x2 / 1 1x1 / 1 4425bd8deadSopenharmony_ci 1x1 / 2 1x1 / 4 1x1 / 8 1x1 / 16 1x1 / 16 4435bd8deadSopenharmony_ci 1x1 / 4 1x1 / 8 1x1 / 16 1x1 / 16 1x1 / 16 4445bd8deadSopenharmony_ci 1x1 / 8 1x1 / 16 1x1 / 16 1x1 / 16 1x1 / 16 4455bd8deadSopenharmony_ci 1x1 / 16 1x1 / 16 1x1 / 16 1x1 / 16 1x1 / 16 4465bd8deadSopenharmony_ci 4475bd8deadSopenharmony_ci Table X.3, Shading rate adjustment based on the sample shading factor in 4485bd8deadSopenharmony_ci the initial implementation of this extension. All rates in this table 4495bd8deadSopenharmony_ci are of the form "<W>x<H> / <I>", indicating a fragment size of <W>x<H> 4505bd8deadSopenharmony_ci pixels with <I> invocations per fragment. 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci If RASTER_MULTISAMPLE_EXT is enabled and the shading rate indicates 4535bd8deadSopenharmony_ci multiple fragment shader invocations per pixel, implementations are 4545bd8deadSopenharmony_ci permitted to adjust the shading rate to reduce the number of invocations 4555bd8deadSopenharmony_ci per pixel. In this case, implementations are not required to support more 4565bd8deadSopenharmony_ci than one invocations per pixel. 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci If the active fragment shader uses any inputs that are qualified with 4595bd8deadSopenharmony_ci "sample" (unique values per sample), including the built-ins "gl_SampleID" 4605bd8deadSopenharmony_ci and "gl_SamplePosition", the shader code is written to expect a separate 4615bd8deadSopenharmony_ci shader invocation for each shaded sample. For such fragment shaders, the 4625bd8deadSopenharmony_ci shading rate is set to the maximum number of shader invocations per pixel 4635bd8deadSopenharmony_ci (SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV). This adjustment effectively 4645bd8deadSopenharmony_ci disables the shading rate image. 4655bd8deadSopenharmony_ci 4665bd8deadSopenharmony_ci Finally, if the shading rate indicates multiple fragment shader 4675bd8deadSopenharmony_ci invocations per sample, the total number of invocations per fragment in 4685bd8deadSopenharmony_ci the shading rate is clamped to the maximum number of shaded samples per 4695bd8deadSopenharmony_ci pixel described in section 14.4.2. 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci 4725bd8deadSopenharmony_ci Section 14.4.4, Shading Rate Application 4735bd8deadSopenharmony_ci 4745bd8deadSopenharmony_ci If the palette indicates a shading rate of SHADING_RATE_NO_INVOCATIONS_NV, 4755bd8deadSopenharmony_ci for pixel (x,y), no fragments will be generated for that pixel. 4765bd8deadSopenharmony_ci 4775bd8deadSopenharmony_ci When the final shading rate for pixel (x,y) is results in fragments with a 4785bd8deadSopenharmony_ci width and height of <W> and <H>, where either <W> or <H> is greater than 4795bd8deadSopenharmony_ci one, a single fragment will be produced for that pixel that also includes 4805bd8deadSopenharmony_ci all other pixels covered by the same primitive whose coordinates (x',y') 4815bd8deadSopenharmony_ci satisfy: 4825bd8deadSopenharmony_ci 4835bd8deadSopenharmony_ci floor(x / W) == floor(x' / W), and 4845bd8deadSopenharmony_ci floor(y / H) == floor(y' / H). 4855bd8deadSopenharmony_ci 4865bd8deadSopenharmony_ci This combined fragment is considered to have multiple coverage samples; 4875bd8deadSopenharmony_ci the total number of samples in this fragment is given by 4885bd8deadSopenharmony_ci 4895bd8deadSopenharmony_ci samples = A * B * S 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci where <A> and <B> are the width and height of the combined fragment, in 4925bd8deadSopenharmony_ci pixels, and <S> is the number of coverage samples per pixel in the draw 4935bd8deadSopenharmony_ci framebuffer. The set of coverage samples in the fragment is the union of 4945bd8deadSopenharmony_ci the per-pixel coverage samples in each of the fragment's pixels. The 4955bd8deadSopenharmony_ci location and order of coverage samples within each pixel in the combined 4965bd8deadSopenharmony_ci fragment are the same as the location and order used for single-pixel 4975bd8deadSopenharmony_ci fragments. Each coverage sample in the set of pixels belonging to the 4985bd8deadSopenharmony_ci combined fragment is assigned a unique sample number in the range 4995bd8deadSopenharmony_ci [0,<S>-1]. When rendering to a framebuffer object, the order of coverage 5005bd8deadSopenharmony_ci samples can be specified for each combination of fragment size and 5015bd8deadSopenharmony_ci coverage sample count. When using the default framebuffer, the coverage 5025bd8deadSopenharmony_ci samples are ordered in an implementation-dependent manner. The command 5035bd8deadSopenharmony_ci 5045bd8deadSopenharmony_ci void ShadingRateSampleOrderNV(enum order); 5055bd8deadSopenharmony_ci 5065bd8deadSopenharmony_ci sets the coverage sample order for all valid combinations of shading rate 5075bd8deadSopenharmony_ci and per-pixel sample coverage count. If <order> is 5085bd8deadSopenharmony_ci COARSE_SAMPLE_ORDER_DEFAULT_NV, coverage samples are ordered in an 5095bd8deadSopenharmony_ci implementation-dependent default order. If <order> is 5105bd8deadSopenharmony_ci COARSE_SAMPLE_ORDER_PIXEL_MAJOR_NV, coverage samples in the combined 5115bd8deadSopenharmony_ci fragment will be ordered sequentially, sorted first by pixel coordinate 5125bd8deadSopenharmony_ci (in row-major order) and then by per-pixel coverage sample number. If 5135bd8deadSopenharmony_ci <order> is COARSE_SAMPLE_ORDER_SAMPLE_MAJOR_NV, coverage samples in the 5145bd8deadSopenharmony_ci combined fragment will be ordered sequentially, sorted first by per-pixel 5155bd8deadSopenharmony_ci coverage sample number and then by pixel coordinate (in row-major order). 5165bd8deadSopenharmony_ci 5175bd8deadSopenharmony_ci When processing a fragment using an ordering specified by 5185bd8deadSopenharmony_ci COARSE_SAMPLE_ORDER_PIXEL_MAJOR_NV sample <cs> in the combined fragment 5195bd8deadSopenharmony_ci will be assigned to coverage sample <ps> of pixel (px,py) specified by: 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci px = fx + (floor(cs / fsc) % fw) 5225bd8deadSopenharmony_ci py = fy + floor(cs / (fsc * fw)) 5235bd8deadSopenharmony_ci ps = cs % fsc 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci where the lower-leftmost pixel in the fragment has coordinates (fx,fy), 5265bd8deadSopenharmony_ci the fragment width and height are <fw> and <fh>, respectively, and there 5275bd8deadSopenharmony_ci are <fsc> coverage samples per pixel. When processing a fragment with an 5285bd8deadSopenharmony_ci ordering specified by COARSE_SAMPLE_ORDER_SAMPLE_MAJOR_NV, sample <cs> in 5295bd8deadSopenharmony_ci the combined fragment will be assigned using: 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ci px = fx + (cs % fw) 5325bd8deadSopenharmony_ci py = fy + (floor(cs / fw) % fh) 5335bd8deadSopenharmony_ci ps = floor(cs / (fw * fh)) 5345bd8deadSopenharmony_ci 5355bd8deadSopenharmony_ci Additionally, the command 5365bd8deadSopenharmony_ci 5375bd8deadSopenharmony_ci void ShadingRateSampleOrderCustomNV(enum rate, uint samples, 5385bd8deadSopenharmony_ci const int *locations); 5395bd8deadSopenharmony_ci 5405bd8deadSopenharmony_ci specifies the order of coverage samples for fragments using a shading rate 5415bd8deadSopenharmony_ci of <rate> with <samples> coverage samples per pixel. <rate> must be one 5425bd8deadSopenharmony_ci of the shading rates specified in Table X.1 and must specify a shading 5435bd8deadSopenharmony_ci rate with more than one pixel per fragment. <locations> specifies an 5445bd8deadSopenharmony_ci array of N (x,y,s) tuples, where N is the product the fragment width 5455bd8deadSopenharmony_ci indicated by <rate>, the fragment height indicated by <rate>, and 5465bd8deadSopenharmony_ci <samples>. For each (x,y,s) tuple specified in <locations>, <x> must be 5475bd8deadSopenharmony_ci in the range [0,fw-1], y must be in the range [0,fh-1], and s must be in 5485bd8deadSopenharmony_ci the range [0,fsc-1]. No two tuples in <locations> may have the same 5495bd8deadSopenharmony_ci values. 5505bd8deadSopenharmony_ci 5515bd8deadSopenharmony_ci When using a sample order specified by ShadingRateSampleOrderCustomNV, 5525bd8deadSopenharmony_ci sample <cs> in the combined fragment will be assigned using: 5535bd8deadSopenharmony_ci 5545bd8deadSopenharmony_ci px = fx + locations[3 * cs + 0] 5555bd8deadSopenharmony_ci py = fy + locations[3 * cs + 1] 5565bd8deadSopenharmony_ci ps = locations[3 * cs + 2] 5575bd8deadSopenharmony_ci 5585bd8deadSopenharmony_ci where all terms in these equations are defined as in the equations 5595bd8deadSopenharmony_ci specified for ShadingRateSampleOrderNV and are consistent with a shading 5605bd8deadSopenharmony_ci rate of <rate> and a per-pixel sample count of <samples>. 5615bd8deadSopenharmony_ci 5625bd8deadSopenharmony_ci Errors 5635bd8deadSopenharmony_ci 5645bd8deadSopenharmony_ci * INVALID_ENUM is generated if <rate> is not one of the enums in Table 5655bd8deadSopenharmony_ci X.1. 5665bd8deadSopenharmony_ci 5675bd8deadSopenharmony_ci * INVALID_OPERATION is generated if <rate> does not specify a 5685bd8deadSopenharmony_ci shading rate palette entry that specifies fragments with more than 5695bd8deadSopenharmony_ci one pixel. 5705bd8deadSopenharmony_ci 5715bd8deadSopenharmony_ci * INVALID_VALUE is generated if <sampleCount> is not 1, 2, 4, or 8. 5725bd8deadSopenharmony_ci 5735bd8deadSopenharmony_ci * INVALID_OPERATION is generated if the product of the fragment width 5745bd8deadSopenharmony_ci indicated by <rate>, the fragment height indicated by <rate>, and 5755bd8deadSopenharmony_ci samples is greater than MAX_COARSE_FRAGMENT_SAMPLES_NV. 5765bd8deadSopenharmony_ci 5775bd8deadSopenharmony_ci * INVALID_VALUE is generated if any (x,y,s) tuple in <locations> has 5785bd8deadSopenharmony_ci negative values of <x>, <y>, or <s>, has an <x> value greater than or 5795bd8deadSopenharmony_ci equal to the width of fragments using <rate>, has a <y> value greater 5805bd8deadSopenharmony_ci than or equal to the height of fragments using <rate>, or has an <s> 5815bd8deadSopenharmony_ci value greater than or equal to <sampleCount>. 5825bd8deadSopenharmony_ci 5835bd8deadSopenharmony_ci * INVALID_OPERATION is generated if any pair of (x,y,s) tuples in 5845bd8deadSopenharmony_ci <locations> have identical values. 5855bd8deadSopenharmony_ci 5865bd8deadSopenharmony_ci In the initial state, the order of coverage samples in combined fragments 5875bd8deadSopenharmony_ci is implementation-dependent, but will be identical to the order obtained 5885bd8deadSopenharmony_ci by passing COARSE_SAMPLE_ORDER_DEFAULT_NV to ShadingRateSampleOrderNV. 5895bd8deadSopenharmony_ci 5905bd8deadSopenharmony_ci The command 5915bd8deadSopenharmony_ci 5925bd8deadSopenharmony_ci void GetShadingRateSampleLocationivNV(enum rate, uint samples, 5935bd8deadSopenharmony_ci uint index, int *location); 5945bd8deadSopenharmony_ci 5955bd8deadSopenharmony_ci can be used to determine the specific pixel and sample number for each 5965bd8deadSopenharmony_ci numbered sample in a single- or multi-pixel fragment when the final 5975bd8deadSopenharmony_ci shading rate is <rate> and uses <samples> coverage samples per pixel. 5985bd8deadSopenharmony_ci <index> specifies a sample number in the fragment. Three integers are 5995bd8deadSopenharmony_ci returned in <location>, and are interpreted in the same manner as each 6005bd8deadSopenharmony_ci (x,y,s) tuples passed to ShadingRateSampleOrderCustomNV. The command 6015bd8deadSopenharmony_ci GetMultisamplefv can be used to determine the location of the identified 6025bd8deadSopenharmony_ci sample <s> within a combined fragment pixel identified by (x,y). 6035bd8deadSopenharmony_ci 6045bd8deadSopenharmony_ci Errors 6055bd8deadSopenharmony_ci 6065bd8deadSopenharmony_ci INVALID_OPERATION is returned if <rate> is 6075bd8deadSopenharmony_ci SHADING_RATE_NO_INVOCATIONS_NV. 6085bd8deadSopenharmony_ci 6095bd8deadSopenharmony_ci INVALID_VALUE is returned if <index> is greater than or equal to the 6105bd8deadSopenharmony_ci number of coverage samples in the draw framebuffer in a combined pixel 6115bd8deadSopenharmony_ci for a shading rate given by <rate>. 6125bd8deadSopenharmony_ci 6135bd8deadSopenharmony_ci When the final shading rate for pixel (x,y) specifies single-pixel 6145bd8deadSopenharmony_ci fragments, a single fragment with S samples numbered in the range 6155bd8deadSopenharmony_ci [0,<S>-1] will be generated when (x,y) is covered. 6165bd8deadSopenharmony_ci 6175bd8deadSopenharmony_ci If the final shading rate for the fragment containing pixel (x,y) produces 6185bd8deadSopenharmony_ci fragments covering multiple pixels, a single fragment shader invocation 6195bd8deadSopenharmony_ci will be generated for the combined fragment. When using fragments with 6205bd8deadSopenharmony_ci multiple pixels per fragment, fragment shader outputs (e.g., color values 6215bd8deadSopenharmony_ci and gl_FragDepth) will be broadcast to all covered pixels/samples of the 6225bd8deadSopenharmony_ci fragment. If a "discard" is used in a fragment shader, none of the 6235bd8deadSopenharmony_ci pixels/samples of the fragment will be updated. 6245bd8deadSopenharmony_ci 6255bd8deadSopenharmony_ci If the final shading rate for pixel (x,y) indicates <N> fragment shader 6265bd8deadSopenharmony_ci invocations per fragment, <N> separate fragment shader invocations will be 6275bd8deadSopenharmony_ci generated for the single-pixel fragment. Each coverage sample in the 6285bd8deadSopenharmony_ci fragment is assigned to one of the <N> fragment shader invocations in an 6295bd8deadSopenharmony_ci implementation-dependent manner. 6305bd8deadSopenharmony_ci 6315bd8deadSopenharmony_ci If sample shading is enabled and the final shading rate results in 6325bd8deadSopenharmony_ci multiple fragment shader invocations per pixel, each fragment shader 6335bd8deadSopenharmony_ci invocation for a pixel will have a separate set of interpolated input 6345bd8deadSopenharmony_ci values. If sample shading is disabled, interpolated fragment shader 6355bd8deadSopenharmony_ci inputs not qualified with "centroid" may have the same value for each 6365bd8deadSopenharmony_ci invocation. 6375bd8deadSopenharmony_ci 6385bd8deadSopenharmony_ci 6395bd8deadSopenharmony_ci Modify Section 14.6.X, Conservative Rasterization from the 6405bd8deadSopenharmony_ci NV_conservative_raster extension specification 6415bd8deadSopenharmony_ci 6425bd8deadSopenharmony_ci (add to the end of the section) 6435bd8deadSopenharmony_ci 6445bd8deadSopenharmony_ci When the shading rate results in fragments covering more than one pixel, 6455bd8deadSopenharmony_ci coverage evaluation for conservative rasterization will be performed 6465bd8deadSopenharmony_ci independently for each pixel. In a such a case, a pixel considered not to 6475bd8deadSopenharmony_ci be covered by a conservatively rasterized primitive will still be 6485bd8deadSopenharmony_ci considered uncovered even if a neighboring pixel in the same fragment is 6495bd8deadSopenharmony_ci covered. 6505bd8deadSopenharmony_ci 6515bd8deadSopenharmony_ci 6525bd8deadSopenharmony_ci Modify Section 14.9.2, Scissor Test 6535bd8deadSopenharmony_ci 6545bd8deadSopenharmony_ci (add to the end of the section) 6555bd8deadSopenharmony_ci 6565bd8deadSopenharmony_ci When the shading rate results in fragments covering more than one pixel, 6575bd8deadSopenharmony_ci the scissor tests are performed separately for each pixel in the fragment. 6585bd8deadSopenharmony_ci If a pixel covered by a fragment fails either the scissor or exclusive 6595bd8deadSopenharmony_ci scissor test, that pixel is treated as though it was not covered by the 6605bd8deadSopenharmony_ci primitive. If all pixels covered by a fragment are either not covered by 6615bd8deadSopenharmony_ci the primitive being rasterized or fail either scissor test, the fragment 6625bd8deadSopenharmony_ci is discarded. 6635bd8deadSopenharmony_ci 6645bd8deadSopenharmony_ci 6655bd8deadSopenharmony_ci Modify Section 14.9.3, Multisample Fragment Operations (p. 562) 6665bd8deadSopenharmony_ci 6675bd8deadSopenharmony_ci (modify the end of the first paragraph to indicate that sample mask 6685bd8deadSopenharmony_ci operations are performed when using the shading rate image, which can 6695bd8deadSopenharmony_ci produce coarse fragments where each pixel is considered a "sample") 6705bd8deadSopenharmony_ci 6715bd8deadSopenharmony_ci ... This step is skipped if MULTISAMPLE is disabled or if the value of 6725bd8deadSopenharmony_ci SAMPLE_BUFFERS is not one, unless SHADING_RATE_IMAGE_NV is enabled for one 6735bd8deadSopenharmony_ci or more viewports. 6745bd8deadSopenharmony_ci 6755bd8deadSopenharmony_ci (add to the end of the section) 6765bd8deadSopenharmony_ci 6775bd8deadSopenharmony_ci When the shading rate results in fragments covering more than one pixel, 6785bd8deadSopenharmony_ci each fragment will a composite coverage mask that includes separate 6795bd8deadSopenharmony_ci coverage bits for each sample in each pixel covered by the fragment. This 6805bd8deadSopenharmony_ci composite coverage mask will be used by the GLSL built-in input variable 6815bd8deadSopenharmony_ci gl_SampleMaskIn[] and updated according to the built-in output variable 6825bd8deadSopenharmony_ci gl_SampleMask[]. Each bit number in this composite mask maps to a 6835bd8deadSopenharmony_ci specific pixel and sample number within that pixel. 6845bd8deadSopenharmony_ci 6855bd8deadSopenharmony_ci When building the composite coverage mask for a fragment, rasterization 6865bd8deadSopenharmony_ci logic evaluates separate per-pixel coverage masks and then modifies each 6875bd8deadSopenharmony_ci per-pixel mask as described in this section. After that, it assembles the 6885bd8deadSopenharmony_ci composite mask by applying the mapping of composite mask bits to 6895bd8deadSopenharmony_ci pixels/samples, which can be queried using GetShadingRateSampleLocationfvNV. 6905bd8deadSopenharmony_ci When using the output sample mask gl_SampleMask[] to determine which 6915bd8deadSopenharmony_ci samples should be updated by subsequent per-fragment operations, a set of 6925bd8deadSopenharmony_ci separate per-pixel output masks is extracted by reversing the mapping used 6935bd8deadSopenharmony_ci to generate the composite sample mask. 6945bd8deadSopenharmony_ci 6955bd8deadSopenharmony_ci 6965bd8deadSopenharmony_ci Modify Section 15.1, Fragment Shader Variables (p. 566) 6975bd8deadSopenharmony_ci 6985bd8deadSopenharmony_ci (modify fourth paragraph, p. 567, specifying how "centroid" works for 6995bd8deadSopenharmony_ci multi-pixel fragments) 7005bd8deadSopenharmony_ci 7015bd8deadSopenharmony_ci When interpolating input variables, the default screen-space location at 7025bd8deadSopenharmony_ci which these variables are sampled is defined in previous rasterization 7035bd8deadSopenharmony_ci sections. The default location may be overriden by interpolation 7045bd8deadSopenharmony_ci qualifiers. When interpolating variables declared using "centroid in", 7055bd8deadSopenharmony_ci the variable is sampled at a location inside the area of the fragment that 7065bd8deadSopenharmony_ci is covered by the primitive generating the fragment. ... 7075bd8deadSopenharmony_ci 7085bd8deadSopenharmony_ci 7095bd8deadSopenharmony_ci Modify Section 15.2.2, Shader Inputs (p. 566), as edited by 7105bd8deadSopenharmony_ci NV_conservative_raster_underestimation 7115bd8deadSopenharmony_ci 7125bd8deadSopenharmony_ci (add to new paragraph on gl_FragFullyCoveredNV) 7135bd8deadSopenharmony_ci 7145bd8deadSopenharmony_ci When CONSERVATIVE_RASTERIZATION_NV or CONSERVATIVE_RASTERIZATION2_NV is 7155bd8deadSopenharmony_ci enabled, the built-in read-only variable gl_FragFullyCoveredNV is set to 7165bd8deadSopenharmony_ci true if the fragment is fully covered by the generating primitive, and 7175bd8deadSopenharmony_ci false otherwise. When the shading rate results in fragments covering more 7185bd8deadSopenharmony_ci than one pixel, gl_FragFullyCoveredNV will be true if and only if all 7195bd8deadSopenharmony_ci pixels covered by the fragment are fully covered by the primitive being 7205bd8deadSopenharmony_ci rasterized. 7215bd8deadSopenharmony_ci 7225bd8deadSopenharmony_ci 7235bd8deadSopenharmony_ci Modify Section 17.3, Per-Fragment Operations (p. 587) 7245bd8deadSopenharmony_ci 7255bd8deadSopenharmony_ci (insert a new paragraph after the first paragraph of the section) 7265bd8deadSopenharmony_ci 7275bd8deadSopenharmony_ci If the fragment covers multiple pixels, the operations described in the 7285bd8deadSopenharmony_ci section are performed independently for each pixel covered by the 7295bd8deadSopenharmony_ci fragment. The set of samples covered by each pixel is determined by 7305bd8deadSopenharmony_ci extracting the portion of the fragment's composite coverage that applies 7315bd8deadSopenharmony_ci to that pixel, as described in section 14.9.3. 7325bd8deadSopenharmony_ci 7335bd8deadSopenharmony_ci 7345bd8deadSopenharmony_ciDependencies on ARB_sample_locations and NV_sample_locations 7355bd8deadSopenharmony_ci 7365bd8deadSopenharmony_ci If ARB_sample_locations or NV_sample_locations is supported, applications 7375bd8deadSopenharmony_ci can enable programmable sample locations instead of the default sample 7385bd8deadSopenharmony_ci locations, and also configure sample locations that may vary from pixel to 7395bd8deadSopenharmony_ci pixel. 7405bd8deadSopenharmony_ci 7415bd8deadSopenharmony_ci When using "coarse" shading rates covering multiple pixels, the coarse 7425bd8deadSopenharmony_ci fragment is considered to include the samples of all the pixels it 7435bd8deadSopenharmony_ci contains. Each sample of each pixel in the coarse fragment is mapped to 7445bd8deadSopenharmony_ci exactly one sample in the coarse fragment. The location of each sample in 7455bd8deadSopenharmony_ci the coarse fragment is determined by mapping the sample to a pixel (px,py) 7465bd8deadSopenharmony_ci and a sample <s> within the identified pixel. The exact location of that 7475bd8deadSopenharmony_ci identified sample is the same as it would be for one-pixel fragments. If 7485bd8deadSopenharmony_ci programmable sample locations are enabled, those locations will be used. 7495bd8deadSopenharmony_ci If the sample location pixel grid is enabled, those locations will depend 7505bd8deadSopenharmony_ci on the (x,y) coordinate of the containing pixel. 7515bd8deadSopenharmony_ci 7525bd8deadSopenharmony_ciDependencies on NV_scissor_exclusive 7535bd8deadSopenharmony_ci 7545bd8deadSopenharmony_ci If NV_scissor_exclusive is not supported, remove references to the 7555bd8deadSopenharmony_ci exclusive scissor test in section 14.9.2. 7565bd8deadSopenharmony_ci 7575bd8deadSopenharmony_ciDependencies on NV_sample_mask_override_coverage 7585bd8deadSopenharmony_ci 7595bd8deadSopenharmony_ci If NV_sample_mask_override_coverage is supported, applications are able to 7605bd8deadSopenharmony_ci use the sample mask to enable coverage for samples not covered by the 7615bd8deadSopenharmony_ci primitive being rasterized. When this extension is used in conjunction 7625bd8deadSopenharmony_ci with a shading rate where fragments cover multiple pixels, it's possible 7635bd8deadSopenharmony_ci for the sample mask override to enable coverage for pixels that would 7645bd8deadSopenharmony_ci normally be discarded. For example, this can enable coverage in pixels 7655bd8deadSopenharmony_ci that are not covered by the primitive being rasterized or that fail the 7665bd8deadSopenharmony_ci scissor test. 7675bd8deadSopenharmony_ci 7685bd8deadSopenharmony_ciDependencies on NV_conservative_raster 7695bd8deadSopenharmony_ci 7705bd8deadSopenharmony_ci If NV_conservative_raster is supported, conservative rasterization 7715bd8deadSopenharmony_ci evaluates coverage per pixel, even when using a shading rate that 7725bd8deadSopenharmony_ci specifies multiple pixels per fragment. 7735bd8deadSopenharmony_ci 7745bd8deadSopenharmony_ci If NV_conservative_raster is not supported, remove edits to the "Section 7755bd8deadSopenharmony_ci 14.6.X" section from that extension. 7765bd8deadSopenharmony_ci 7775bd8deadSopenharmony_ciDependencies on NV_conservative_raster_underestimation 7785bd8deadSopenharmony_ci 7795bd8deadSopenharmony_ci If NV_conservative_raster_underestimation is supported, and conservative 7805bd8deadSopenharmony_ci rasterization is enabled with a shading rate that specifies multiple 7815bd8deadSopenharmony_ci pixels per fragment, gl_FragFullyCoveredNV will be true if and only if all 7825bd8deadSopenharmony_ci pixels covered by the fragment are fully covered by the primitive being 7835bd8deadSopenharmony_ci rasterized. 7845bd8deadSopenharmony_ci 7855bd8deadSopenharmony_ci If NV_conservative_raster_underestimation is not supported, remove edits 7865bd8deadSopenharmony_ci to Section 15.2.2 related to gl_FragFullyCoveredNV. 7875bd8deadSopenharmony_ci 7885bd8deadSopenharmony_ciDependencies on EXT_raster_multisample 7895bd8deadSopenharmony_ci 7905bd8deadSopenharmony_ci If EXT_raster_multisample is not supported, remove the language allowing 7915bd8deadSopenharmony_ci implementations to reduce the number of fragment shader invocations 7925bd8deadSopenharmony_ci per pixel if RASTER_MULTISAMPLE_EXT is enabled. 7935bd8deadSopenharmony_ci 7945bd8deadSopenharmony_ciInteractions with NV_viewport_array or OES_viewport_array 7955bd8deadSopenharmony_ci 7965bd8deadSopenharmony_ci If NV_viewport_array is supported, references to MAX_VIEWPORTS and 7975bd8deadSopenharmony_ci GetFloati_v apply to MAX_VIEWPORTS_NV and GetFloati_vNV respecively. 7985bd8deadSopenharmony_ci 7995bd8deadSopenharmony_ci If OES_viewport_array is supported, references to MAX_VIEWPORTS and 8005bd8deadSopenharmony_ci GetFloati_v apply to MAX_VIEWPORTS_OES and GetFloati_vOES respectively. 8015bd8deadSopenharmony_ci 8025bd8deadSopenharmony_ciInteractions with OpenGL ES 3.2 8035bd8deadSopenharmony_ci 8045bd8deadSopenharmony_ci If implemented in OpenGL ES, remove all references to GetDoublev, 8055bd8deadSopenharmony_ci GetDoublei_v, EnableIndexedEXT, DisableIndexedEXT, IsEnabledIndexedEXT, 8065bd8deadSopenharmony_ci GetBooleanIndexedvEXT, GetIntegerIndexedvEXT, GetFloatIndexedvEXT and 8075bd8deadSopenharmony_ci GetDoubleIndexedv. 8085bd8deadSopenharmony_ci 8095bd8deadSopenharmony_ci If implemented in OpenGL ES, remove all references to the MULTISAMPLE enable 8105bd8deadSopenharmony_ci state. 8115bd8deadSopenharmony_ci 8125bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 8135bd8deadSopenharmony_ci 8145bd8deadSopenharmony_ci None 8155bd8deadSopenharmony_ci 8165bd8deadSopenharmony_ciErrors 8175bd8deadSopenharmony_ci 8185bd8deadSopenharmony_ci See the "Errors" sections for individual commands above. 8195bd8deadSopenharmony_ci 8205bd8deadSopenharmony_ciNew State 8215bd8deadSopenharmony_ci 8225bd8deadSopenharmony_ci Get Value Get Command Type Initial Value Description Sec. Attribute 8235bd8deadSopenharmony_ci --------- --------------- ---- ------------- ----------- ---- --------- 8245bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV IsEnabledi 16+ x FALSE Use shading rate image to 14.4.1 enable 8255bd8deadSopenharmony_ci B determine shading rate for 8265bd8deadSopenharmony_ci a given viewport 8275bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ GetIntegerv Z 0 Texture object bound for 14.4.1 none 8285bd8deadSopenharmony_ci BINDING_NV use as a shading rate image 8295bd8deadSopenharmony_ci <none> GetShadingRate- 16+ x SHADING_RATE_1_- Shading rate palette 14.4.1 none 8305bd8deadSopenharmony_ci ImagePaletteNV 16+ x INVOCATION_PER_- entries 8315bd8deadSopenharmony_ci Z12 PIXEL_NV 8325bd8deadSopenharmony_ci <none> GetShadingRate- many n/a Locations of individual 14.4.3 none 8335bd8deadSopenharmony_ci SampleLocation- 3xZ+ samples in "coarse" 8345bd8deadSopenharmony_ci fragments 8355bd8deadSopenharmony_ci 8365bd8deadSopenharmony_ciNew Implementation Dependent State 8375bd8deadSopenharmony_ci 8385bd8deadSopenharmony_ci Minimum 8395bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 8405bd8deadSopenharmony_ci --------- ----- --------------- ------- ------------------------ ------ 8415bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ Z+ GetIntegerv 1 Width (in pixels) covered by 14.4.1 8425bd8deadSopenharmony_ci TEXEL_WIDTH_NV each shading rate image texel 8435bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ Z+ GetIntegerv 1 Height (in pixels) covered by 14.4.1 8445bd8deadSopenharmony_ci TEXEL_HEIGHT_NV each shading rate image texel 8455bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ Z+ GetIntegerv 16 Number of entries in each 14.4.1 8465bd8deadSopenharmony_ci PALETTE_SIZE_NV viewport's shading rate 8475bd8deadSopenharmony_ci palette 8485bd8deadSopenharmony_ci MAX_COARSE_FRAGMENT_ Z+ GetIntegerv 1 Maximum number of samples in 14.4.3 8495bd8deadSopenharmony_ci PALETTE_SIZE_NV "coarse" fragments 8505bd8deadSopenharmony_ci 8515bd8deadSopenharmony_ciIssues 8525bd8deadSopenharmony_ci 8535bd8deadSopenharmony_ci (1) How should we name this extension? 8545bd8deadSopenharmony_ci 8555bd8deadSopenharmony_ci RESOLVED: We are calling this extension NV_shading_rate_image. We use 8565bd8deadSopenharmony_ci the term "shading rate" to indicate the variable number of fragment 8575bd8deadSopenharmony_ci shader invocations that will be spawned for a particular neighborhood of 8585bd8deadSopenharmony_ci covered pixels. The extension can support shading rates running one 8595bd8deadSopenharmony_ci invocation for multiple pixels and/or multiple invocations for a single 8605bd8deadSopenharmony_ci pixel. We use "image" in the extension name because we allow 8615bd8deadSopenharmony_ci applications to control the shading rate using an image, where each 8625bd8deadSopenharmony_ci pixel specifies a shading rate for a portion of the framebuffer. 8635bd8deadSopenharmony_ci 8645bd8deadSopenharmony_ci We considered a name like "NV_variable_rate_shading", but decided that 8655bd8deadSopenharmony_ci name didn't sufficiently distinguish between this extension (where 8665bd8deadSopenharmony_ci shading rate varies across the framebuffer at once) from an extension 8675bd8deadSopenharmony_ci where an API is provided to change the shading rate for the entire 8685bd8deadSopenharmony_ci framebuffer. For example, the MinSampleShadingARB() API in 8695bd8deadSopenharmony_ci ARB_sample_shading allows an application to run one thread per pixel 8705bd8deadSopenharmony_ci (0.0) for some draw calls and one thread per sample (1.0) for others. 8715bd8deadSopenharmony_ci 8725bd8deadSopenharmony_ci (2) Should this extension support only off-screen (FBO) rendering or can 8735bd8deadSopenharmony_ci it also support on-screen rendering? 8745bd8deadSopenharmony_ci 8755bd8deadSopenharmony_ci RESOLVED: This extension only supports rendering to a framebuffer 8765bd8deadSopenharmony_ci object; the feature is disabled when rendering to the default 8775bd8deadSopenharmony_ci framebuffer. In some window system environments, the default 8785bd8deadSopenharmony_ci framebuffer may be a subset of a larger framebuffer allocation 8795bd8deadSopenharmony_ci corresponding the full screen. Because the initial hardware 8805bd8deadSopenharmony_ci implementation of this extension always uses (x,y) coordinates relative 8815bd8deadSopenharmony_ci to the framebuffer allocation to determine the shading rate, the shading 8825bd8deadSopenharmony_ci rate would depend on the location of a window on the screen and change 8835bd8deadSopenharmony_ci as the window moves. While some window systems may have separate 8845bd8deadSopenharmony_ci default framebuffer allocations for each window, we've chosen to 8855bd8deadSopenharmony_ci disallow use of the shading rate image with the default framebuffer 8865bd8deadSopenharmony_ci globally instead of adding a "Can I use the shading rate image with a 8875bd8deadSopenharmony_ci default framebuffer?" query. 8885bd8deadSopenharmony_ci 8895bd8deadSopenharmony_ci (3) How does this feature work with per-sample shading? 8905bd8deadSopenharmony_ci 8915bd8deadSopenharmony_ci RESOLVED: When using per-sample shading, an application is expecting a 8925bd8deadSopenharmony_ci fragment shader to run with a separate invocation per sample. The 8935bd8deadSopenharmony_ci shading rate image might allow for a "coarsening" that would break such 8945bd8deadSopenharmony_ci shaders. We've chosen to override the shading rate (effectively 8955bd8deadSopenharmony_ci disabling the shading rate image) when per-sample shading is used. 8965bd8deadSopenharmony_ci 8975bd8deadSopenharmony_ci (4) Should BindShadingRateImageNV take any arguments to bind a subset of 8985bd8deadSopenharmony_ci a complex texture (e.g., a specific layer of an array texture or a 8995bd8deadSopenharmony_ci non-base mipmap level)? 9005bd8deadSopenharmony_ci 9015bd8deadSopenharmony_ci RESOLVED: No. Applications can use texture views to create texture 9025bd8deadSopenharmony_ci that refer to the desired subset of a more complex texture, if required. 9035bd8deadSopenharmony_ci 9045bd8deadSopenharmony_ci (5) Does a shading rate image need to be bound in order to use the shading 9055bd8deadSopenharmony_ci rate feature? 9065bd8deadSopenharmony_ci 9075bd8deadSopenharmony_ci RESOLVED: No. The behavior where there is no texture bound when 9085bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV is enabled is explicitly defined to behave as if a 9095bd8deadSopenharmony_ci lookup was performed and returned zero. If an application wants to use 9105bd8deadSopenharmony_ci a constant rate other than SHADING_RATE_1_INVOCATION_PER_PIXEL_NV, it 9115bd8deadSopenharmony_ci can enable SHADING_RATE_IMAGE_NV, ensure no image is bound, and define 9125bd8deadSopenharmony_ci the entries for index zero in the relevant palette(s) to contain the 9135bd8deadSopenharmony_ci desired shading rate. This technique can be used to emulate 16x 9145bd8deadSopenharmony_ci multisampling on implementations that don't support it by binding larger 9155bd8deadSopenharmony_ci 4x multisample textures to the framebuffer and then setting a shading 9165bd8deadSopenharmony_ci rate of SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV. 9175bd8deadSopenharmony_ci 9185bd8deadSopenharmony_ci (6) How is the FRAGMENT_SHADER_INVOCATIONS_ARB query (from 9195bd8deadSopenharmony_ci ARB_pipeline_statistics_query) handled with fragments covering 9205bd8deadSopenharmony_ci multiple pixels? 9215bd8deadSopenharmony_ci 9225bd8deadSopenharmony_ci RESOLVED: The fragment shader invocation for each multi-pixel fragment 9235bd8deadSopenharmony_ci is counted exactly once. 9245bd8deadSopenharmony_ci 9255bd8deadSopenharmony_ci (7) How do we handle the combination of variable-rate shading (including 9265bd8deadSopenharmony_ci multiple invocations per pixel) and target-independent rasterization 9275bd8deadSopenharmony_ci (i.e., RASTER_MULTISAMPLE_EXT)? 9285bd8deadSopenharmony_ci 9295bd8deadSopenharmony_ci RESOLVED: In EXT_raster_multisample, the specification allows 9305bd8deadSopenharmony_ci implementations to run a single fragment shader invocation for each 9315bd8deadSopenharmony_ci pixel, even if sample shading would normally call for multiple 9325bd8deadSopenharmony_ci invocations per pixel: 9335bd8deadSopenharmony_ci 9345bd8deadSopenharmony_ci If RASTER_MULTISAMPLE_EXT is enabled, the number of unique samples to 9355bd8deadSopenharmony_ci process is implementation-dependent and need not be more than one. 9365bd8deadSopenharmony_ci 9375bd8deadSopenharmony_ci The shading rates in this extension calling for multiple fragment shader 9385bd8deadSopenharmony_ci invocations per pixel behave similarly to sample shading, so we extend 9395bd8deadSopenharmony_ci the allowance to this extension as well. If the shading rate in a 9405bd8deadSopenharmony_ci region of the framebuffer calls for multiple fragment shader invocations 9415bd8deadSopenharmony_ci per pixel, implementations are permitted to modify the shading rate and 9425bd8deadSopenharmony_ci need not support more than one invocation per pixel. 9435bd8deadSopenharmony_ci 9445bd8deadSopenharmony_ci (8) Both the shading rate image and the framebuffer attachments can be 9455bd8deadSopenharmony_ci layered or non-layered. Do they have to match? 9465bd8deadSopenharmony_ci 9475bd8deadSopenharmony_ci RESOLVED: No. When using a shading rate image with a target of 9485bd8deadSopenharmony_ci TEXTURE_2D with a layered framebuffer, all layers in the framebuffer 9495bd8deadSopenharmony_ci will use the same two-dimensional shading rate image. When using a 9505bd8deadSopenharmony_ci shading rate image with a target of TEXTURE_2D_ARRAY with a non-layered 9515bd8deadSopenharmony_ci framebuffer, layer zero of the shading rate image will be used, except 9525bd8deadSopenharmony_ci perhaps in the (undefined behavior) case where a shader writes a 9535bd8deadSopenharmony_ci non-zero value to gl_Layer. 9545bd8deadSopenharmony_ci 9555bd8deadSopenharmony_ci (9) When using shading rates that specify "coarse" fragments covering 9565bd8deadSopenharmony_ci multiple pixels, we will generate a combined coverage mask that 9575bd8deadSopenharmony_ci combines the coverage masks of all pixels covered by the fragment. By 9585bd8deadSopenharmony_ci default, these masks are combined in an implementation-dependent 9595bd8deadSopenharmony_ci order. Should we provide a mechanism allowing applications to query 9605bd8deadSopenharmony_ci or specify an exact order? 9615bd8deadSopenharmony_ci 9625bd8deadSopenharmony_ci RESOLVED: Yes, this feature is useful for cases where most of the 9635bd8deadSopenharmony_ci fragment shader can be evaluated once for an entire coarse fragment, but 9645bd8deadSopenharmony_ci where some per-pixel computations are also required. For example, a 9655bd8deadSopenharmony_ci per-pixel alpha test may want to kill all the samples for some pixels in 9665bd8deadSopenharmony_ci a coarse fragment. This sort of test can be implemented using an output 9675bd8deadSopenharmony_ci sample mask, but such a shader would need to know which bit in the mask 9685bd8deadSopenharmony_ci corresponds to each sample in the coarse fragment. The command 9695bd8deadSopenharmony_ci ShadingRateSampleOrderNV allows applications to specify simple orderings 9705bd8deadSopenharmony_ci for all combinations, while ShadingRateSampleOrderCustomNV allows for 9715bd8deadSopenharmony_ci completely customized orders for each combination. 9725bd8deadSopenharmony_ci 9735bd8deadSopenharmony_ci (10) How do centroid-sampled variables work with fragments larger than one 9745bd8deadSopenharmony_ci pixel? 9755bd8deadSopenharmony_ci 9765bd8deadSopenharmony_ci RESOLVED: For single-pixel fragments, attributes declared with 9775bd8deadSopenharmony_ci "centroid" are sampled at an implementation-dependent location in the 9785bd8deadSopenharmony_ci intersection of the area of the primitive being rasterized and the area 9795bd8deadSopenharmony_ci of the pixel that corresponds to the fragment. With multi-pixel 9805bd8deadSopenharmony_ci fragments, we follow a similar pattern, using the intersection of the 9815bd8deadSopenharmony_ci primitive and the *set* of pixels corresponding to the fragment. 9825bd8deadSopenharmony_ci 9835bd8deadSopenharmony_ci One important thing to keep in mind when using such "coarse" shading 9845bd8deadSopenharmony_ci rates is that fragment attributes are sampled at the center of the 9855bd8deadSopenharmony_ci fragment by default, regardless of the set of pixels/samples covered by 9865bd8deadSopenharmony_ci the fragment. For fragments with a size of 4x4 pixels, this center 9875bd8deadSopenharmony_ci location will be more than two pixels (1.5 * sqrt(2)) away from the 9885bd8deadSopenharmony_ci center of the pixels at the corners of the fragment. When rendering a 9895bd8deadSopenharmony_ci primitive that covers only a small part of a coarse fragment, 9905bd8deadSopenharmony_ci interpolating a color outside the primitive can produce overly bright or 9915bd8deadSopenharmony_ci dark color values if the color values have a large gradient. To deal 9925bd8deadSopenharmony_ci with this, an application can use centroid sampling on attributes where 9935bd8deadSopenharmony_ci "extrapolation" artifacts can lead to overly bright or dark pixels. 9945bd8deadSopenharmony_ci Note that this same problem also exists for multisampling with 9955bd8deadSopenharmony_ci single-pixel fragments, but is less severe because it only affects 9965bd8deadSopenharmony_ci certain samples of a pixel and such bright/dark samples may be averaged 9975bd8deadSopenharmony_ci with other samples that don't have a similar problem. 9985bd8deadSopenharmony_ci 9995bd8deadSopenharmony_ci (11) How does this feature interact with multisampling? 10005bd8deadSopenharmony_ci 10015bd8deadSopenharmony_ci RESOLVED: The shading rate image can produce "coarse" fragments larger 10025bd8deadSopenharmony_ci than one pixel, which we want to behave a lot like regular multisample. 10035bd8deadSopenharmony_ci One can consider each coarse fragment to be a lot like a "pixel", where 10045bd8deadSopenharmony_ci the individual pixels covered by the fragment are treated as "samples". 10055bd8deadSopenharmony_ci 10065bd8deadSopenharmony_ci When the shading rate is enabled, we override several rules related to 10075bd8deadSopenharmony_ci multisampling: 10085bd8deadSopenharmony_ci 10095bd8deadSopenharmony_ci (a) Multisample rasterization rules apply, even if we don't have 10105bd8deadSopenharmony_ci multisample buffers or if MULTISAMPLE is disabled. 10115bd8deadSopenharmony_ci 10125bd8deadSopenharmony_ci (b) Coverage for the pixels comprising a coarse fragment is combined 10135bd8deadSopenharmony_ci into a single aggregate coverage mask that can be read using the 10145bd8deadSopenharmony_ci fragment shader input "gl_SampleMaskIn[]". 10155bd8deadSopenharmony_ci 10165bd8deadSopenharmony_ci (c) Coverage for pixels comprising a coarse fragment can be modified using 10175bd8deadSopenharmony_ci the fragment shader output "gl_SampleMask[]", which is also 10185bd8deadSopenharmony_ci interpreted as an aggregate coverage mask. 10195bd8deadSopenharmony_ci 10205bd8deadSopenharmony_ci Note that (a) means that point and line primitives may be rasterized 10215bd8deadSopenharmony_ci differently depending on whether the shading rate image is enabled or 10225bd8deadSopenharmony_ci disabled. 10235bd8deadSopenharmony_ci 10245bd8deadSopenharmony_ci Also, please refer to issues in the GLSL extension specification. 10255bd8deadSopenharmony_ci 10265bd8deadSopenharmony_ciRevision History 10275bd8deadSopenharmony_ci 10285bd8deadSopenharmony_ci Revision 3 (pbrown), March 16, 2020 10295bd8deadSopenharmony_ci - Fix cut-and-paste error in "New Procedures and Functions" incorrectly 10305bd8deadSopenharmony_ci listing ShadingRateSampleOrderNV as a second instance of 10315bd8deadSopenharmony_ci ShadingRateImageBarrier. 10325bd8deadSopenharmony_ci 10335bd8deadSopenharmony_ci Revision 2 (pknowles) 10345bd8deadSopenharmony_ci - ES interactions. 10355bd8deadSopenharmony_ci 10365bd8deadSopenharmony_ci Revision 1 (pbrown) 10375bd8deadSopenharmony_ci - Internal revisions. 1038