• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    AMD_texture_gather_bias_lod
4
5Name Strings
6
7    GL_AMD_texture_gather_bias_lod
8
9Contact
10
11    Rex Xu, AMD (Rex.Xu 'at' amd.com)
12
13Contributors
14
15    Rex Xu, AMD
16    Timothy Lottes, AMD
17    Qun Lin, AMD
18    Daniel Rakos, AMD
19    Graham Sellers, AMD
20    Dominik Witczak, AMD
21    Matthäus G. Chajdas, AMD
22
23
24Status
25
26    Shipping
27
28Version
29
30    Last Modified Date:         05/10/2017
31    Author Revision:            5
32
33Number
34
35    502
36
37Dependencies
38
39    This extension is written against the OpenGL 4.5 (Core Profile) Specification.
40
41    This extension is written against version 4.50 of the OpenGL Shading Language Specification.
42
43    OpenGL 4.0 and GLSL 4.00 are required.
44
45    This extension interacts with ARB_sparse_texture2.
46
47Overview
48
49    This extension was developed based on existing built-in texture gather functions to allow
50    implementations supporting bias of implicit level of detail and explicit control of level of
51    detail in texture gather operations.
52
53New Procedures and Functions
54
55    None.
56
57New Tokens
58
59    None.
60
61Modifications to the OpenGL Shading Language Specification, Version 4.50
62
63    Including the following line in a shader can be used to control the language features described
64    in this extension:
65
66        #extension GL_AMD_texture_gather_bias_lod : <behavior>
67
68    where <behavior> is as specified in section 3.3.
69
70    New preprocessor #defines are added to the OpenGL Shading Language:
71
72        #define GL_AMD_texture_gather_bias_lod      1
73
74Additions to Chapter 8 of the OpenGL Shading Language Specification (Built-in Functions)
75
76    Modify Section 8.9.3 Texture Gather Functions
77
78    (modify the first sentence of the first paragraph on p. 170)
79
80    The texture gather functions take components of a single floating-point vector operand as a
81    texture coordinate, determine a set of four texels to sample either from the base level of
82    detail and its bias (if present) of the specified texture image or from the explicit level of
83    detail (if present) of this texture image, and return one component from each texel in a four-
84    component result vector.
85
86    (modify certain functions in the "Syntax" table cell of each gather function group, adding
87     an optional <bias> parameter for those sampler types: gsampler2D, gsampler2DArray,
88     gsamplerCube, gsamplerCubeArray, and modify four-texel sampling formulas in the "Description"
89     table cell of textureGather() on p. 171-172)
90
91    +--------------------------------------------------------------+------------------------------+
92    | Syntax                                                       | Description                  |
93    +--------------------------------------------------------------+------------------------------+
94    | gvec4 textureGather(gsampler2D sampler, vec2 P [, int comp   | Returns the value            |
95    |                     [, float bias]])                         |                              |
96    | gvec4 textureGather(gsampler2DArray sampler, vec3 P          | gvec4(                       |
97    |                     [, int comp [, float bias]])             |   Sample_i0_j1(              |
98    | gvec4 textureGather(gsamplerCube sampler, vec3 P             |     P, base, bias).comp,     |
99    |                     [, int comp [, float bias]])             |   Sample_i1_j1(              |
100    | gvec4 textureGather(gsamplerCubeArray sampler, vec4 P        |     P, base, bias).comp,     |
101    |                     [, int comp [, float bias]])             |   Sample_i1_j0(              |
102    | ...                                                          |     P, base, bias).comp,     |
103    |                                                              |   Sample_i0_j0(              |
104    |                                                              |     P, base, bias).comp)     |
105    |                                                              | ...                          |
106    +--------------------------------------------------------------+------------------------------+
107    | gvec4 textureGatherOffset(gsampler2D sampler, vec2 P,        | Perform a texture gather     |
108    |                           ivec2 offset [, int comp           | operation as in              |
109    |                           [, float bias]])                   | textureGather() by <offset>  |
110    | gvec4 textureGatherOffset(gsampler2DArray sampler, vec3 P,   | as described in              |
111    |                           ivec2 offset [, int comp           | textureOffset() except that  |
112    |                           [, float bias]])                   | the <offset> can be variable |
113    | ...                                                          | (non constant) and ...       |
114    +--------------------------------------------------------------+------------------------------+
115    | gvec4 textureGatherOffsets(gsampler2D sampler, vec2 P,       | Operate identically to       |
116    |                            ivec2 offsets[4] [, int comp      | textureGatherOffset() except |
117    |                            [, float bias]])                  | that <offsets> is used to    |
118    | gvec4 textureGatherOffsets(gsampler2DArray sampler, vec3 P,  | determine the location of the|
119    |                            ivec2 offsets[4] [, int comp      | four texels to sample. ...   |
120    |                            [, float bias]])                  |                              |
121    | ...                                                          |                              |
122    +--------------------------------------------------------------+------------------------------+
123
124    (insert new gather function table cells, at the end of the section, p. 172)
125
126    +--------------------------------------------------------------+------------------------------+
127    | Syntax                                                       | Description                  |
128    +--------------------------------------------------------------+------------------------------+
129    | gvec4 textureGatherLodAMD(gsampler2D sampler, vec2 P,        | Perform a texture gather     |
130    |                           float lod [, int comp])            | operation as in              |
131    | gvec4 textureGatherLodAMD(gsampler2DArray sampler, vec3 P,   | textureGather() with explicit|
132    |                           float lod [, int comp])            | LOD, but the four-texel      |
133    | gvec4 textureGatherLodAMD(gsamplerCube sampler, vec3 P,      | sampling is modified as      |
134    |                           float lod [, int comp])            | follow:                      |
135    | gvec4 textureGatherLodAMD(gsamplerCubeArray sampler, vec4 P, |                              |
136    |                           float lod [, int comp])            | gvec4(                       |
137    |                                                              |   Sample_i0_j1(P, lod).comp, |
138    |                                                              |   Sample_i1_j1(P, lod).comp, |
139    |                                                              |   Sample_i1_j0(P, lod).comp, |
140    |                                                              |   Sample_i0_j0(P, lod).comp) |
141    +--------------------------------------------------------------+------------------------------+
142    | gvec4 textureGatherLodOffsetAMD(gsampler2D sampler, vec2 P,  | Perform a texture gather     |
143    |                                 float lod, ivec2 offset      | operation as in              |
144    |                                 [, int comp])                | textureGatherOffset() but    |
145    | gvec4 textureGatherLodOffsetAMD(gsampler2DArray sampler,     | with explicit LOD.           |
146    |                                 vec3 P, float lod,           |                              |
147    |                                 ivec2 offset [, int comp])   |                              |
148    +--------------------------------------------------------------+------------------------------+
149    | gvec4 textureGatherLodOffsetsAMD(gsampler2D sampler, vec2 P, | Perform a texture gather     |
150    |                                  float lod, ivec2 offsets[4] | operation as in              |
151    |                                  [, int comp])               | textureGatherOffsets() but   |
152    | gvec4 textureGatherLodOffsetsAMD(gsampler2DArray sampler,    | with explicit LOD.           |
153    |                                  vec3 P, float lod,          |                              |
154    |                                  ivec2 offsets[4]            |                              |
155    |                                  [, int comp])               |                              |
156    +--------------------------------------------------------------+------------------------------+
157
158Dependencies on ARB_sparse_texture2
159
160    If the shader enables ARB_sparse_texture2, this extension modifies certain variants of
161    sparseTextureGather*(), adding optional <bias> parameter for those sampler types: gsampler2D,
162    gsampler2DArray, gsamplerCube, gsamplerCubeArray.
163
164    +--------------------------------------------------------------+------------------------------+
165    | Syntax                                                       | Description                  |
166    +--------------------------------------------------------------+------------------------------+
167    | int sparseTextureGatherARB(gsampler2D sampler, vec2 P,       | Do a texture gather operation|
168    |                            out gvec4 texel [, int comp       | as in textureGather(), but   |
169    |                            [, float bias]])                  | return texture access        |
170    | int sparseTextureGatherARB(gsampler2DArray sampler, vec3 P,  | residency information from   |
171    |                            out gvec4 texel [, int comp       | the function and the filtered|
172    |                            [, float bias]])                  | lookup result in the out     |
173    | int sparseTextureGatherARB(gsamplerCube sampler, vec3 P,     | parameter <texel>.           |
174    |                            out gvec4 texel [, int comp       |                              |
175    |                            [, float bias]])                  |                              |
176    | int sparseTextureGatherARB(gsamplerCubeArray sampler, vec4 P,|                              |
177    |                            out gvec4 texel [, int comp       |                              |
178    |                            [, float bias]])                  |                              |
179    | ...                                                          |                              |
180    +--------------------------------------------------------------+------------------------------+
181    | int sparseTextureGatherOffsetARB(gsampler2D sampler, vec2 P, | Do a texture gather operation|
182    |                                  ivec2 offset,               | as in textureGatherOffset(), |
183    |                                  out gvec4 texel             | but return texture access    |
184    |                                  [, int comp [, float bias]])| residency information from   |
185    | int sparseTextureGatherOffsetARB(gsampler2DArray sampler,    | the function and the filtered|
186    |                                  vec3 P, ivec2 offset,       | lookup result in the out     |
187    |                                  out gvec4 texel             | parameter <texel>.           |
188    |                                  [, int comp [, float bias]])|                              |
189    | ...                                                          |                              |
190    +--------------------------------------------------------------+------------------------------+
191    | int sparseTextureGatherOffsetsARB(gsampler2D sampler, vec2 P,| Do a texture gather operation|
192    |                                   ivec2 offsets[4],          | as in textureGatherOffsets(),|
193    |                                   out gvec4 texel            | but return texture access    |
194    |                                   [, int comp                | residency information from   |
195    |                                   [, float bias]])           | the function and the filtered|
196    | int sparseTextureGatherOffsetsARB(gsampler2DArray sampler,   | lookup result in the out     |
197    |                                   vec3 P, ivec2 offsets[4],  | parameter <texel>.           |
198    |                                   out gvec4 texel            |                              |
199    |                                   [, int comp                |                              |
200    |                                   [, float bias]])           |                              |
201    | ...                                                          |                              |
202    +--------------------------------------------------------------+------------------------------+
203
204    Meanwhile, this extension adds additional texture gather functions as follow if the shader
205    enables ARB_sparse_texture2, providing explicit control of level of detail.
206
207    +--------------------------------------------------------------+------------------------------+
208    | Syntax                                                       | Description                  |
209    +--------------------------------------------------------------+------------------------------+
210    | int sparseTextureGatherLodAMD(gsampler2D sampler, vec2 P,    | Do a texture gather operation|
211    |                               float lod, out gvec4 texel     | as in textureGather() with,  |
212    |                               [, int comp])                  | explicit LOD, but return     |
213    | int sparseTextureGatherLodAMD(gsampler2DArray sampler,       | texture access residency     |
214    |                               vec3 P, float lod,             | information from the function|
215    |                               out gvec4 texel [, int comp])  | and the filtered lookup      |
216    | int sparseTextureGatherLodAMD(gsamplerCube sampler, vec3 P,  | result in the out parameter  |
217    |                               float lod, out gvec4 texel     | <texel>.                     |
218    |                               [, int comp])                  |                              |
219    | int sparseTextureGatherLodAMD(gsamplerCubeArray sampler,     |                              |
220    |                               vec4 P, float lod,             |                              |
221    |                               out gvec4 texel [, int comp])  |                              |
222    +--------------------------------------------------------------+------------------------------+
223    | int sparseTextureGatherLodOffsetAMD(gsampler2D sampler,      | Do a texture gather operation|
224    |                                     vec2 P, float lod,       | as in textureGatherOffset()  |
225    |                                     ivec2 offset,            | with explicit LOD, but return|
226    |                                     out gvec4 texel          | texture access residency     |
227    |                                     [, int comp])            | information from the function|
228    | int sparseTextureGatherLodOffsetAMD(gsampler2DArray sampler, | and the filtered lookup      |
229    |                                     vec3 P, float lod,       | result in the out parameter  |
230    |                                     ivec2 offset,            | <texel>.                     |
231    |                                     out gvec4 texel          |                              |
232    |                                     [, int comp])            |                              |
233    +--------------------------------------------------------------+------------------------------+
234    | int sparseTextureGatherLodOffsetsAMD(gsampler2D sampler,     | Do a texture gather operation|
235    |                                      vec2 P, float lod,      | as in textureGatherOffsets() |
236    |                                      ivec2 offsets[4],       | with explicit LOD, but return|
237    |                                      out gvec4 texel         | texture access residency     |
238    |                                      [, int comp])           | information from the function|
239    | int sparseTextureGatherLodOffsetsAMD(gsampler2DArray sampler,| and the filtered lookup      |
240    |                                      vec3 P, float lod,      | result in the out parameter  |
241    |                                      ivec2 offsets[4],       | <texel>.                     |
242    |                                      out gvec4 texel         |                              |
243    |                                      [, int comp])           |                              |
244    +--------------------------------------------------------------+------------------------------+
245
246Errors
247
248    None.
249
250New State
251
252    None.
253
254New Implementation Dependent State
255
256    None.
257
258Issues
259
260    (1) Could you explain the function syntax since <bias> is added as another optional parameter?
261
262      RESOLVED: This extension adds <bias> as another optional parameter apart from the existing
263      parameter <comp>. The function syntax is somewhat similar to rules of default parameters in
264      C++. To be exact, when <comp> is not specified, <bias> should not be specified as well; when
265      <comp> is specified, <bias> could be specified or not. For example,
266
267          uniform sampler2D samp2D;
268
269          vec2  P;
270          int   comp;
271          float bias;
272
273          ...
274
275          textureGather(samp2D, P);              // legal, both comp and bias are not specified
276          textureGather(samp2D, P, bias);        // illegal, bias is specified while comp is not
277          textureGather(samp2D, P, comp);        // legal, comp is specified while bias is not
278          textureGather(samp2D, p, comp, bias);  // legal both comp and bias are specified
279
280    (2) Which level-of-detail do texture gather functions use, if the extension is defined?
281
282      RESOLVED: If GL_AMD_texture_gather_bias_lod extension is *enabled*, *all* texture
283      gather functions (ie. the ones which do not take the extra bias argument and
284      the ones that do) fetch texels from implicit LOD in fragment shader stage. In all
285      other shader stages, base level is used instead.
286
287      If the extension is *disabled*, all texture gather functions always fetch texels
288      from the base mip level.
289
290
291Revision History
292
293    Rev.    Date    Author    Changes
294    ----  --------  --------  ---------------------------------------------------------------------
295     5    05/10/17  dwitczak  Added issue 2.
296
297     4    01/24/17  dwitczak  Fix sparseTextureGatherOffsetsARB() and
298                              sparseTextureGatherLodOffsetAMD() function prototypes.
299
300     3    11/17/16  rexu      Clarify that when <bias> parameter is specified, the optional <comp>
301                              parameter, prior to <bias>, should be specified as well based on
302                              the calling rules of default parameters.
303
304     2    11/16/16  rexu      Add the interaction with ARB_sparse_texture2.
305
306     1    11/15/16  rexu      Initial draft.
307