1b8e80941SmrgName
2b8e80941Smrg
3b8e80941Smrg    EXT_shader_samples_identical
4b8e80941Smrg
5b8e80941SmrgName Strings
6b8e80941Smrg
7b8e80941Smrg    GL_EXT_shader_samples_identical
8b8e80941Smrg
9b8e80941SmrgContact
10b8e80941Smrg
11b8e80941Smrg    Ian Romanick, Intel (ian.d.romanick 'at' intel.com)
12b8e80941Smrg
13b8e80941SmrgContributors
14b8e80941Smrg
15b8e80941Smrg    Chris Forbes, Mesa
16b8e80941Smrg    Magnus Wendt, Intel
17b8e80941Smrg    Neil S. Roberts, Intel
18b8e80941Smrg    Graham Sellers, AMD
19b8e80941Smrg
20b8e80941SmrgStatus
21b8e80941Smrg
22b8e80941Smrg    XXX - Not complete yet.
23b8e80941Smrg
24b8e80941SmrgVersion
25b8e80941Smrg
26b8e80941Smrg    Last Modified Date: November 19, 2015
27b8e80941Smrg    Revision: 6
28b8e80941Smrg
29b8e80941SmrgNumber
30b8e80941Smrg
31b8e80941Smrg    TBD
32b8e80941Smrg
33b8e80941SmrgDependencies
34b8e80941Smrg
35b8e80941Smrg    OpenGL 3.2, or OpenGL ES 3.1, or ARB_texture_multisample is required.
36b8e80941Smrg
37b8e80941Smrg    This extension is written against the OpenGL 4.5 (Core Profile)
38b8e80941Smrg    Specification
39b8e80941Smrg
40b8e80941SmrgOverview
41b8e80941Smrg
42b8e80941Smrg    Multisampled antialiasing has become a common method for improving the
43b8e80941Smrg    quality of rendered images.  Multisampling differs from supersampling in
44b8e80941Smrg    that the color of a primitive that covers all or part of a pixel is
45b8e80941Smrg    resolved once, regardless of the number of samples covered.  If a large
46b8e80941Smrg    polygon is rendered, the colors of all samples in each interior pixel will
47b8e80941Smrg    be the same.  This suggests a simple compression scheme that can reduce
48b8e80941Smrg    the necessary memory bandwidth requirements.  In one such scheme, each
49b8e80941Smrg    sample is stored in a separate slice of the multisample surface.  An
50b8e80941Smrg    additional multisample control surface (MCS) contains a mapping from pixel
51b8e80941Smrg    samples to slices.
52b8e80941Smrg
53b8e80941Smrg    If all the values stored in the MCS for a particular pixel are the same,
54b8e80941Smrg    then all the samples have the same value.  Applications can take advantage
55b8e80941Smrg    of this information to reduce the bandwidth of reading multisample
56b8e80941Smrg    textures.  A custom multisample resolve filter could optimize resolving
57b8e80941Smrg    pixels where every sample is identical by reading the color once.
58b8e80941Smrg
59b8e80941Smrg    color = texelFetch(sampler, coordinate, 0);
60b8e80941Smrg    if (!textureSamplesIdenticalEXT(sampler, coordinate)) {
61b8e80941Smrg        for (int i = 1; i < MAX_SAMPLES; i++) {
62b8e80941Smrg            vec4 c = texelFetch(sampler, coordinate, i);
63b8e80941Smrg
64b8e80941Smrg            //... accumulate c into color
65b8e80941Smrg
66b8e80941Smrg        }
67b8e80941Smrg    }
68b8e80941Smrg
69b8e80941SmrgNew Procedures and Functions
70b8e80941Smrg
71b8e80941Smrg    None.
72b8e80941Smrg
73b8e80941SmrgNew Tokens
74b8e80941Smrg
75b8e80941Smrg    None.
76b8e80941Smrg
77b8e80941SmrgAdditions to the OpenGL 4.5 (Core Profile) Specification
78b8e80941Smrg
79b8e80941Smrg    None.
80b8e80941Smrg
81b8e80941SmrgModifications to The OpenGL Shading Language Specification, Version 4.50.5
82b8e80941Smrg
83b8e80941Smrg    Including the following line in a shader can be used to control the
84b8e80941Smrg    language features described in this extension:
85b8e80941Smrg
86b8e80941Smrg        #extension GL_EXT_shader_samples_identical
87b8e80941Smrg
88b8e80941Smrg    A new preprocessor #define is added to the OpenGL Shading Language:
89b8e80941Smrg
90b8e80941Smrg        #define GL_EXT_shader_samples_identical
91b8e80941Smrg
92b8e80941Smrg    Add to the table in section 8.7 "Texture Lookup Functions"
93b8e80941Smrg
94b8e80941Smrg    Syntax:
95b8e80941Smrg
96b8e80941Smrg        bool textureSamplesIdenticalEXT(gsampler2DMS sampler, ivec2 coord)
97b8e80941Smrg
98b8e80941Smrg        bool textureSamplesIdenticalEXT(gsampler2DMSArray sampler,
99b8e80941Smrg                                        ivec3 coord)
100b8e80941Smrg
101b8e80941Smrg    Description:
102b8e80941Smrg
103b8e80941Smrg        Returns true if it can be determined that all samples within the texel
104b8e80941Smrg        of the multisample texture bound to <sampler> at <coord> contain the
105b8e80941Smrg        same values or false if this cannot be determined."
106b8e80941Smrg
107b8e80941SmrgAdditions to the AGL/EGL/GLX/WGL Specifications
108b8e80941Smrg
109b8e80941Smrg    None
110b8e80941Smrg
111b8e80941SmrgErrors
112b8e80941Smrg
113b8e80941Smrg    None
114b8e80941Smrg
115b8e80941SmrgNew State
116b8e80941Smrg
117b8e80941Smrg    None
118b8e80941Smrg
119b8e80941SmrgNew Implementation Dependent State
120b8e80941Smrg
121b8e80941Smrg    None
122b8e80941Smrg
123b8e80941SmrgIssues
124b8e80941Smrg
125b8e80941Smrg    1) What should the new functions be called?
126b8e80941Smrg
127b8e80941Smrg    RESOLVED: textureSamplesIdenticalEXT.  Initially
128b8e80941Smrg    textureAllSamplesIdenticalEXT was considered, but
129b8e80941Smrg    textureSamplesIdenticalEXT is more similar to the existing textureSamples
130b8e80941Smrg    function.
131b8e80941Smrg
132b8e80941Smrg    2) It seems like applications could implement additional optimization if
133b8e80941Smrg       they were provided with raw MCS data.  Should this extension also
134b8e80941Smrg       provide that data?
135b8e80941Smrg
136b8e80941Smrg    There are a number of challenges in providing raw MCS data.  The biggest
137b8e80941Smrg    problem being that the amount of MCS data depends on the number of
138b8e80941Smrg    samples, and that is not known at compile time.  Additionally, without new
139b8e80941Smrg    texelFetch functions, applications would have difficulty utilizing the
140b8e80941Smrg    information.
141b8e80941Smrg
142b8e80941Smrg    Another option is to have a function that returns an array of tuples of
143b8e80941Smrg    sample number and count.  This also has difficulties with the maximum
144b8e80941Smrg    array size not being known at compile time.
145b8e80941Smrg
146b8e80941Smrg    RESOLVED: Do not expose raw MCS data in this extension.
147b8e80941Smrg
148b8e80941Smrg    3) Should this extension also extend SPIR-V?
149b8e80941Smrg
150b8e80941Smrg    RESOLVED: Yes, but this has not yet been written.
151b8e80941Smrg
152b8e80941Smrg    4) Is it possible for textureSamplesIdenticalEXT to report false negatives?
153b8e80941Smrg
154b8e80941Smrg    RESOLVED: Yes.  It is possible that the underlying hardware may not detect
155b8e80941Smrg    that separate writes of the same color to different samples of a pixel are
156b8e80941Smrg    the same.  The shader function is at the whim of the underlying hardware
157b8e80941Smrg    implementation.  It is also possible that a compressed multisample surface
158b8e80941Smrg    is not used.  In that case the function will likely always return false.
159b8e80941Smrg
160b8e80941SmrgRevision History
161b8e80941Smrg
162b8e80941Smrg    Rev  Date        Author    Changes
163b8e80941Smrg    ---  ----------  --------  ---------------------------------------------
164b8e80941Smrg      1  2014/08/20  cforbes   Initial version
165b8e80941Smrg      2  2015/10/23  idr       Change from MESA to EXT.  Rebase on OpenGL 4.5,
166b8e80941Smrg                               and add dependency on OpenGL ES 3.1.  Initial
167b8e80941Smrg                               draft of overview section and issues 1 through
168b8e80941Smrg                               3.
169b8e80941Smrg      3  2015/10/27  idr       Typo fixes.
170b8e80941Smrg      4  2015/11/10  idr       Rename extension from EXT_shader_multisample_compression
171b8e80941Smrg                               to EXT_shader_samples_identical.
172b8e80941Smrg                               Add issue #4.
173b8e80941Smrg      5  2015/11/18  idr       Fix some typos spotted by gsellers.  Change the
174b8e80941Smrg                               name of the name of the function to
175b8e80941Smrg                               textureSamplesIdenticalEXT.
176b8e80941Smrg      6  2015/11/19  idr       Fix more typos spotted by Nicolai Hähnle.
177