15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_primitive_shading_rate 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_primitive_shading_rate 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciStatus 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Shipping 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciVersion 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Last Modified: October 30, 2020 245bd8deadSopenharmony_ci Revision: 1 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciNumber 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci OpenGL Extension #554 295bd8deadSopenharmony_ci OpenGL ES Extension #332 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciDependencies 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension is written against the OpenGL 4.6 Specification 345bd8deadSopenharmony_ci (Compatibility Profile), dated February 2, 2019. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci OpenGL 4.5 or OpenGL ES 3.2 is required. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci NV_shading_rate_image is required. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci This extension requires support from the OpenGL Shading Language (GLSL) 415bd8deadSopenharmony_ci extension "NV_primitive_shading_rate", which can be found at the Khronos 425bd8deadSopenharmony_ci Group Github site here: 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci https://github.com/KhronosGroup/GLSL 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci This extension interacts with NV_mesh_shader. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciOverview 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci This extension builds on top of the NV_shading_rate_image extension to 515bd8deadSopenharmony_ci provide OpenGL API support for using a per-primitive shading rate value to 525bd8deadSopenharmony_ci control the computation of the rate used to process each fragment. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci In the NV_shading_rate_image extension, the shading rate for each fragment 555bd8deadSopenharmony_ci produced by a primitive is determined by looking up a texel in the bound 565bd8deadSopenharmony_ci shading rate image and using that value as an index into a shading rate 575bd8deadSopenharmony_ci palette. That extension provides a separate shading rate image lookup 585bd8deadSopenharmony_ci enable and palette for each viewport. When a primitive is rasterized, the 595bd8deadSopenharmony_ci implementation uses the enable and palette associated with the primitive's 605bd8deadSopenharmony_ci viewport to determine the shading rate. 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci This extension decouples the shading rate image enables and palettes from 635bd8deadSopenharmony_ci viewports. The number of enables/palettes now comes from the 645bd8deadSopenharmony_ci implementation-dependent constant SHADING_RATE_IMAGE_PALETTE_COUNT_NV. When 655bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PER_PRIMITIVE_NV (added here) is enabled, the value of 665bd8deadSopenharmony_ci the new gl_ShadingRateNV built-in output is used to select an enable and 675bd8deadSopenharmony_ci palette to determine the shading rate. Otherwise, the viewport number for 685bd8deadSopenharmony_ci the primitive is used, as in NV_shading_rate_image. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ciNew Procedures and Functions 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ci None. 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ciNew Tokens 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci Accepted by the <cap> parameter of Enable, Disable, and IsEnabled and by the 795bd8deadSopenharmony_ci <pname> parameter of GetBooleanv, GetIntegerv, GetInteger64v, GetFloatv, 805bd8deadSopenharmony_ci GetDoublev: 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetDoublev, 855bd8deadSopenharmony_ci GetIntegerv, and GetFloatv: 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ciModifications to the OpenGL 4.6 Specification (Compatibility Profile) 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci Modify Section 14.3.1, Multisampling, as modified by the 935bd8deadSopenharmony_ci NV_shading_rate_image extension. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci (modify the introduction of the shading rate image functionality to decouple 965bd8deadSopenharmony_ci shading rate image enables and viewports) 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci When using a shading rate image (Section 14.4.1), rasterization may produce 995bd8deadSopenharmony_ci fragments covering multiple pixels, where each pixel is treated as a sample. 1005bd8deadSopenharmony_ci If any of the SHADING_RATE_IMAGE_NV enables is enabled, primitives will be 1015bd8deadSopenharmony_ci processed with multisample rasterization rules, regardless of the 1025bd8deadSopenharmony_ci MULTISAMPLE enable or the value of SAMPLE_BUFFERS. ... 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Modify Section 14.4.1, Shading Rate Image, as added by the 1065bd8deadSopenharmony_ci NV_shading_rate_image extension. 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci (rework the introduction of the shading rate image functionality to decouple 1095bd8deadSopenharmony_ci shading rate image enables and viewports) 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci Applications can specify the use of a shading rate that varies by (x,y) 1125bd8deadSopenharmony_ci location using a _shading rate image_. For each primitive, the shading rate 1135bd8deadSopenharmony_ci image is enabled or disabled by selecting a single enable in an array of 1145bd8deadSopenharmony_ci enables whose size is given by the implementation-dependent constant 1155bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_COUNT_NV. Use of a shading rate image is enabled 1165bd8deadSopenharmony_ci or disabled globally by using Enable or Disable with target 1175bd8deadSopenharmony_ci SHADING_RATE_IMAGE_NV. A single shading rate image enable can be modified 1185bd8deadSopenharmony_ci by calling Enablei or Disablei with the constant SHADING_RATE_IMAGE_NV and 1195bd8deadSopenharmony_ci the index of the selected enable. The shading rate image may only be used 1205bd8deadSopenharmony_ci with a framebuffer object. When rendering to the default framebuffer, the 1215bd8deadSopenharmony_ci shading rate image enables are ignored and operations in this section are 1225bd8deadSopenharmony_ci disabled. In the initial state, all shading rate image enables are 1235bd8deadSopenharmony_ci disabled. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci The method used to select a single shading rate image enable used to process 1265bd8deadSopenharmony_ci each primitive is controlled by calling Enable or Disable with the target 1275bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PER_PRIMITIVE_NV. When enabled, a shading rate enable 1285bd8deadSopenharmony_ci used for a primitive is selected using an index taken from the value of the 1295bd8deadSopenharmony_ci built-in output gl_ShadingRateNV for the primitive's provoking vertex. If 1305bd8deadSopenharmony_ci the value of gl_ShadingRateNV is negative or greater than or equal to the 1315bd8deadSopenharmony_ci number of shading rate enables, the shading rate used for a primitive is 1325bd8deadSopenharmony_ci undefined. When SHADING_RATE_IMAGE_PER_PRIMITIVE_NV is disabled, a shading 1335bd8deadSopenharmony_ci rate enable is selected using the index of the viewport used for processing 1345bd8deadSopenharmony_ci the primitive. In the initial state, SHADING_RATE_IMAGE_PER_PRIMITIVE_NV is 1355bd8deadSopenharmony_ci disabled. 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci (rework the introduction of the shading rate image functionality to decouple 1395bd8deadSopenharmony_ci shading rate image palettes and viewports) 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci A shading rate index is mapped to a _base shading rate_ using a lookup table 1425bd8deadSopenharmony_ci called the shading rate image palette. There is a separate palette 1435bd8deadSopenharmony_ci associated with each shading rate image enable. As with the shading rate 1445bd8deadSopenharmony_ci image enables, a single palette is selected for a primitive according to the 1455bd8deadSopenharmony_ci enable SHADING_RATE_IMAGE_PER_PRIMITIVE_NV. The number of palettes and the 1465bd8deadSopenharmony_ci number of entries in each palette are given by the implementation-dependent 1475bd8deadSopenharmony_ci constants SHADING_RATE_IMAGE_PALETTE_COUNT_NV and 1485bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV, respectively. The base shading rate for 1495bd8deadSopenharmony_ci an (x,y) coordinate with a shading rate index of <i> will be given by entry 1505bd8deadSopenharmony_ci <i> of the selected palette. If the shading rate index is greater than or 1515bd8deadSopenharmony_ci equal to the palette size, the results of the palette lookup are undefined. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci (rework the introduction of ShadingRateImagePaletteNV to decouple shading 1555bd8deadSopenharmony_ci rate image palettes and viewports) 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci Shading rate image palettes are updated using the command 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci void ShadingRateImagePaletteNV(uint viewport, uint first, sizei count, 1605bd8deadSopenharmony_ci const enum *rates); 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci <viewport> specifies the number of the palette that should be updated. 1635bd8deadSopenharmony_ci [[ Note: The formal parameter name <viewport> is a remnant of the 1645bd8deadSopenharmony_ci original NV_shading_rate_image extension, where palettes were tightly 1655bd8deadSopenharmony_ci coupled with viewports. ]] <rates> is an array ... 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci (modify the discussion of ShadingRateImagePaletteNV errors to decouple 1695bd8deadSopenharmony_ci shading rate image palettes and viewports) 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci INVALID_VALUE is generated if <viewport> is greater than or equal to 1725bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_COUNT_NV. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci INVALID_VALUE is generated if <first> plus <count> is greater than 1755bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV. 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci (modify the discussion of GetShadingRateImagePaletteNV to decouple shading 1795bd8deadSopenharmony_ci rate image palettes and viewports) 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci Individual entries in the shading rate palette can be queried using the 1825bd8deadSopenharmony_ci command: 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci void GetShadingRateImagePaletteNV(uint viewport, uint entry, 1855bd8deadSopenharmony_ci enum *rate); 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci where <viewport> specifies the number of the palette to query and... 1885bd8deadSopenharmony_ci <entry> specifies the palette entry number. [[ Note: The formal 1895bd8deadSopenharmony_ci parameter name <viewport> is a remnant of the original 1905bd8deadSopenharmony_ci NV_shading_rate_image extension, where palettes were tightly coupled 1915bd8deadSopenharmony_ci with viewports. ]] A single enum from Table X.1 is returned in <rate>. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci Errors 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ci INVALID_VALUE is generated if <viewport> is greater than or equal to 1965bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_COUNT_NV. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci INVALID_VALUE is generated if <first> plus <count> is greater than 1995bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PALETTE_SIZE_NV. 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci Modify Section 14.9.3, Multisample Fragment Operations, as edited by 2035bd8deadSopenharmony_ci NV_shading_rate_image. 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci (modify the discussion of the shading rate image multisample functionality 2065bd8deadSopenharmony_ci to decouple shading rate image enables and viewports) 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci ... This step is skipped if MULTISAMPLE is disabled or if the value of 2095bd8deadSopenharmony_ci SAMPLE_BUFFERS is not one, unless one or more of the SHADING_RATE_IMAGE_NV 2105bd8deadSopenharmony_ci enables are enabled. 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ciDependencies on NV_mesh_shader 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci When NV_mesh_shader is supported, the "NV_primitive_shading_rate" GLSL 2165bd8deadSopenharmony_ci extension allows multi-view mesh shaders to write separate per-primitive 2175bd8deadSopenharmony_ci shading rates for each view using the built-in gl_ShadingRatePerViewNV[]. 2185bd8deadSopenharmony_ci When gl_ShadingRatePerViewNV[] is used with 2195bd8deadSopenharmony_ci SHADING_RATE_IMAGE_PER_PRIMITIVE_NV enabled, a separate shading rate image 2205bd8deadSopenharmony_ci enable and palette will be used for each view. 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci None 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ciErrors 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci See the "Errors" sections for individual commands above. 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ciNew State 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci Get Value Get Command Type Initial Value Description Sec. Attribute 2345bd8deadSopenharmony_ci --------- --------------- ---- ------------- ----------- ---- --------- 2355bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ IsEnabled B FALSE Use per-primitive shading 14.4.1 enable 2365bd8deadSopenharmony_ci PER_PRIMITIVE_NV rate to select shading 2375bd8deadSopenharmony_ci rate images/palettes 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ciNew Implementation Dependent State 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci Minimum 2425bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 2435bd8deadSopenharmony_ci --------- ----- --------------- ------- ------------------------ ------ 2445bd8deadSopenharmony_ci SHADING_RATE_IMAGE_ Z+ GetIntegerv 16 Number of shading rate image 14.4.1 2455bd8deadSopenharmony_ci PALETTE_COUNT_NV enables/palettes supported 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ciIssues 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci (1) How should we name this extension? 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci RESOLVED: We are calling this extension "NV_primitive_shading_rate" 2525bd8deadSopenharmony_ci because it adds a new per-primitive shading rate to the variable-rate 2535bd8deadSopenharmony_ci shading functionality added by NV_shading_rate_image. 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ci (2) Do we need to add queries like LAYER_PROVOKING_VERTEX and 2565bd8deadSopenharmony_ci VIEWPORT_INDEX_PROVOKING_VERTEX to determine the vertex used to obtain 2575bd8deadSopenharmony_ci the per-primitive shading rate for each primitive? 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci RESOLVED: No -- we will always use the provoking vertex. In the event 2605bd8deadSopenharmony_ci that this extension is standardized in the future with behavior that 2615bd8deadSopenharmony_ci diverges between implementations, such a query could be added as part of 2625bd8deadSopenharmony_ci that effort. 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ciRevision History 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Revision 1 (pbrown) 2675bd8deadSopenharmony_ci - Internal revisions. 268