Path: blob/21.2-virgl/docs/_extra/specs/EXT_shader_samples_identical.txt
4566 views
Name12EXT_shader_samples_identical34Name Strings56GL_EXT_shader_samples_identical78Contact910Ian Romanick, Intel (ian.d.romanick 'at' intel.com)1112Contributors1314Chris Forbes, Mesa15Magnus Wendt, Intel16Neil S. Roberts, Intel17Graham Sellers, AMD1819Status2021XXX - Not complete yet.2223Version2425Last Modified Date: November 19, 201526Revision: 62728Number2930TBD3132Dependencies3334OpenGL 3.2, or OpenGL ES 3.1, or ARB_texture_multisample is required.3536This extension is written against the OpenGL 4.5 (Core Profile)37Specification3839Overview4041Multisampled antialiasing has become a common method for improving the42quality of rendered images. Multisampling differs from supersampling in43that the color of a primitive that covers all or part of a pixel is44resolved once, regardless of the number of samples covered. If a large45polygon is rendered, the colors of all samples in each interior pixel will46be the same. This suggests a simple compression scheme that can reduce47the necessary memory bandwidth requirements. In one such scheme, each48sample is stored in a separate slice of the multisample surface. An49additional multisample control surface (MCS) contains a mapping from pixel50samples to slices.5152If all the values stored in the MCS for a particular pixel are the same,53then all the samples have the same value. Applications can take advantage54of this information to reduce the bandwidth of reading multisample55textures. A custom multisample resolve filter could optimize resolving56pixels where every sample is identical by reading the color once.5758color = texelFetch(sampler, coordinate, 0);59if (!textureSamplesIdenticalEXT(sampler, coordinate)) {60for (int i = 1; i < MAX_SAMPLES; i++) {61vec4 c = texelFetch(sampler, coordinate, i);6263//... accumulate c into color6465}66}6768New Procedures and Functions6970None.7172New Tokens7374None.7576Additions to the OpenGL 4.5 (Core Profile) Specification7778None.7980Modifications to The OpenGL Shading Language Specification, Version 4.50.58182Including the following line in a shader can be used to control the83language features described in this extension:8485#extension GL_EXT_shader_samples_identical8687A new preprocessor #define is added to the OpenGL Shading Language:8889#define GL_EXT_shader_samples_identical9091Add to the table in section 8.7 "Texture Lookup Functions"9293Syntax:9495bool textureSamplesIdenticalEXT(gsampler2DMS sampler, ivec2 coord)9697bool textureSamplesIdenticalEXT(gsampler2DMSArray sampler,98ivec3 coord)99100Description:101102Returns true if it can be determined that all samples within the texel103of the multisample texture bound to <sampler> at <coord> contain the104same values or false if this cannot be determined."105106Additions to the AGL/EGL/GLX/WGL Specifications107108None109110Errors111112None113114New State115116None117118New Implementation Dependent State119120None121122Issues1231241) What should the new functions be called?125126RESOLVED: textureSamplesIdenticalEXT. Initially127textureAllSamplesIdenticalEXT was considered, but128textureSamplesIdenticalEXT is more similar to the existing textureSamples129function.1301312) It seems like applications could implement additional optimization if132they were provided with raw MCS data. Should this extension also133provide that data?134135There are a number of challenges in providing raw MCS data. The biggest136problem being that the amount of MCS data depends on the number of137samples, and that is not known at compile time. Additionally, without new138texelFetch functions, applications would have difficulty utilizing the139information.140141Another option is to have a function that returns an array of tuples of142sample number and count. This also has difficulties with the maximum143array size not being known at compile time.144145RESOLVED: Do not expose raw MCS data in this extension.1461473) Should this extension also extend SPIR-V?148149RESOLVED: Yes, but this has not yet been written.1501514) Is it possible for textureSamplesIdenticalEXT to report false negatives?152153RESOLVED: Yes. It is possible that the underlying hardware may not detect154that separate writes of the same color to different samples of a pixel are155the same. The shader function is at the whim of the underlying hardware156implementation. It is also possible that a compressed multisample surface157is not used. In that case the function will likely always return false.158159Revision History160161Rev Date Author Changes162--- ---------- -------- ---------------------------------------------1631 2014/08/20 cforbes Initial version1642 2015/10/23 idr Change from MESA to EXT. Rebase on OpenGL 4.5,165and add dependency on OpenGL ES 3.1. Initial166draft of overview section and issues 1 through1673.1683 2015/10/27 idr Typo fixes.1694 2015/11/10 idr Rename extension from EXT_shader_multisample_compression170to EXT_shader_samples_identical.171Add issue #4.1725 2015/11/18 idr Fix some typos spotted by gsellers. Change the173name of the name of the function to174textureSamplesIdenticalEXT.1756 2015/11/19 idr Fix more typos spotted by Nicolai Hähnle.176177178