Skip to content

Commit bca6f4d

Browse files
authored
Clarify WebGL1 float color buffer extensions behaviors (#2505)
* Clarify WebGL1 float color buffer extensions behaviors and testing against them * Address kbr comment * fix typo * Revision * Remove RGB32F as supported renderbuffer format from extension spec.
1 parent 05e886c commit bca6f4d

6 files changed

Lines changed: 82 additions & 63 deletions

File tree

extensions/EXT_color_buffer_half_float/extension.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@
3737
Renderbuffers can be created in these formats. These and textures
3838
created with <code>type = HALF_FLOAT_OES</code>, which will have one
3939
of these internal formats, can be attached to framebuffer object color
40-
attachments for rendering.</p>
40+
attachments for rendering. Implementations supporting this extension is
41+
required to support rendering to <code>RGBA16F</code> format.
42+
Applications must check framebuffer completeness to determine if
43+
<code>RGA16F</code> is supported.
4144
</feature>
4245

4346
<feature>
4447
<p><span style="color: red">NOTE:</span> fragment shaders outputs
4548
gl_FragColor and gl_FragData[0] will only be clamped and converted
46-
when the color buffer is fixed-point and <code>BlendColor()</code> and
47-
<code>ClearColor()</code> will no longer clamp their parameter values
49+
when the color buffer is fixed-point and <code>blendColor()</code> and
50+
<code>clearColor()</code> will no longer clamp their parameter values
4851
on input. Clamping will be applied as necessary at draw time according
4952
to the type of color buffer in use.</p>
5053
</feature>
@@ -140,5 +143,9 @@ interface EXT_color_buffer_half_float {
140143
<revision date="2016/05/05">
141144
<change>Subsumed in WebGL 2.0 by EXT_color_buffer_float.</change>
142145
</revision>
146+
147+
<revision date="2017/09/14">
148+
<change>Require RGBA16F to be color-renderable and RGB16F to be optionally color-renderable.</change>
149+
</revision>
143150
</history>
144151
</extension>

extensions/OES_texture_float/extension.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<mirrors href="http://www.khronos.org/registry/gles/extensions/OES/OES_texture_float.txt"
2121
name="OES_texture_float">
2222
<addendum>Optional support for <code>FLOAT</code> textures as FBO
23-
attachments (deprecated).</addendum>
23+
attachments.</addendum>
2424
</mirrors>
2525

2626
<features>
@@ -35,15 +35,11 @@
3535
<code>HTMLVideoElement</code> are extended to accept the pixel type
3636
<code>FLOAT</code>. </feature>
3737

38-
<feature>Implementations supporting float rendering via this extension
39-
will implicitly enable the <a
40-
href="../WEBGL_color_buffer_float/">WEBGL_color_buffer_float</a>
41-
extension and follow its requirements. This ensures correct behavior
42-
when a texture with pixel type <code>FLOAT</code> is attached to an FBO.
43-
Although this feature has historically been allowed, new implementations
44-
should not implicitly support float rendering and applications should be
45-
modified to explicitly enable <a
46-
href="../WEBGL_color_buffer_float/">WEBGL_color_buffer_float</a>.</feature>
38+
<feature>Upon activation of this extension, implementations supporting
39+
<a href="../WEBGL_color_buffer_float/">WEBGL_color_buffer_float</a>
40+
shall implicitly enable it. This requirement maintains the historical
41+
behavior prior to the differentiation of float renderability from float
42+
textures, so as to not break existing content.</feature>
4743
</features>
4844
</overview>
4945

@@ -87,5 +83,9 @@ interface OES_texture_float { }; </idl>
8783
<revision date="2014/09/11">
8884
<change>Corrected link to WEBGL_color_buffer_float.</change>
8985
</revision>
86+
87+
<revision date="2017/09/14">
88+
<change>Clarify behaviors regarding WEBGL_color_buffer_float.</change>
89+
</revision>
9090
</history>
9191
</ratified>

extensions/OES_texture_half_float/extension.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<mirrors href="http://www.khronos.org/registry/gles/extensions/OES/OES_texture_float.txt"
2121
name="OES_texture_half_float">
2222
<addendum>Optional support for <code>HALF_FLOAT</code> textures as FBO
23-
attachments (deprecated).</addendum>
23+
attachments.</addendum>
2424
</mirrors>
2525

2626
<features>
@@ -35,15 +35,11 @@
3535
<code>HTMLVideoElement</code> are extended to accept the pixel type
3636
<code>HALF_FLOAT_OES</code>. </feature>
3737

38-
<feature>Implementations supporting float rendering via this extension
39-
will implicitly enable the <a
40-
href="../EXT_color_buffer_half_float/">EXT_color_buffer_half_float</a>
41-
extension and follow its requirements. This ensures correct behavior
42-
when a texture with pixel type <code>HALF_FLOAT_OES</code> is attached
43-
to an FBO. Although this feature has historically been allowed, new
44-
implementations should not implicitly support float rendering and
45-
applications should be modified to explicitly enable <a
46-
href="../EXT_color_buffer_half_float/">EXT_color_buffer_half_float</a>.</feature>
38+
<feature>Upon activation of this extension, implementations supporting
39+
<a href="../EXT_color_buffer_half_float/">EXT_color_buffer_half_float</a>
40+
shall implicitly enable it. This requirement maintains the historical
41+
behavior prior to the differentiation of float renderability from float
42+
textures, so as to not break existing content.</feature>
4743
</features>
4844
</overview>
4945

@@ -91,5 +87,9 @@ interface OES_texture_half_float {
9187
<revision date="2014/09/11">
9288
<change>Corrected link to EXT_color_buffer_half_float.</change>
9389
</revision>
90+
91+
<revision date="2017/09/14">
92+
<change>Clarify behaviors regarding EXT_color_buffer_half_float.</change>
93+
</revision>
9494
</history>
9595
</ratified>

extensions/WEBGL_color_buffer_float/extension.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,22 @@
3737
</p>
3838
</feature>
3939

40+
<feature>
41+
<p>The 32-bit floating-point type <code>RGB32F</code> may also optionally
42+
become available as a color-renderable format. These and textures created
43+
with <code>format = RGB</code> and <code>type = FLOAT</code> as specified in
44+
<a href="http://www.khronos.org/registry/webgl/extensions/OES_texture_float/">OES_texture_float</a>,
45+
can be attached to framebuffer object color attachments for rendering.
46+
Applications must check framebuffer completeness to determine if an
47+
implementation actually supports this format.
48+
</p>
49+
</feature>
50+
4051
<feature>
4152
<p><span style="color: red">NOTE:</span> fragment shaders outputs
4253
gl_FragColor and gl_FragData[0] will only be clamped and converted
43-
when the color buffer is fixed-point and <code>BlendColor()</code> and
44-
<code>ClearColor()</code> will no longer clamp their parameter values
54+
when the color buffer is fixed-point and <code>blendColor()</code> and
55+
<code>clearColor()</code> will no longer clamp their parameter values
4556
on input. Clamping will be applied as necessary at draw time according
4657
to the type of color buffer in use.</p>
4758
</feature>
@@ -126,5 +137,9 @@ interface WEBGL_color_buffer_float {
126137
<revision date="2016/05/05">
127138
<change>Subsumed in WebGL 2.0 by EXT_color_buffer_float.</change>
128139
</revision>
140+
141+
<revision date="2017/09/14">
142+
<change>Add optional RGB renderability.</change>
143+
</revision>
129144
</history>
130145
</extension>

sdk/tests/conformance/extensions/oes-texture-float.html

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,20 @@
114114

115115
(function() {
116116
debug("");
117+
var renderable = isRenderable(gl);
117118
var renderableExtName = "WEBGL_color_buffer_float";
118-
if (isRenderable(gl)) {
119-
var supported = gl.getSupportedExtensions();
120-
assertMsg(supported.includes(renderableExtName),
121-
"Implicit renderability requires exposing support for " + renderableExtName);
122-
} else {
123-
var renderableExt = gl.getExtension(renderableExtName);
124-
if (!renderableExt) {
125-
testPassed(renderableExtName + " not supported. This is fine.");
126-
return;
127-
}
128-
testPassed(renderableExtName + " supported. Proceeding to its tests.");
119+
var supported = gl.getSupportedExtensions().includes(renderableExtName);
120+
if (renderable && !supported) {
121+
testFailed("RGBA/FLOAT is color renderable but " + renderableExtName + " not exposed");
122+
} else if (supported && !renderable) {
123+
testFailed(renderableExtName + " is exposed but RGBA/FLOAT is not color renderable");
124+
}
125+
if (supported) {
126+
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0, true);
127+
runRenderTargetAndReadbackTest(testProgram, gl.RGB, 3, [10000, 10000, 10000, 1], 0, false);
128+
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 1, true);
129+
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0.5, true);
129130
}
130-
131-
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0);
132-
runRenderTargetAndReadbackTest(testProgram, gl.RGB, 3, [10000, 10000, 10000, 1], 0);
133-
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 1);
134-
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0.5);
135131
})();
136132

137133
runUniqueObjectTest();
@@ -224,7 +220,7 @@
224220
return out + "]";
225221
}
226222

227-
function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, subtractor, texSubImageCover)
223+
function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, subtractor, texSubImageCover, requireRenderable)
228224
{
229225
var formatString = wtu.glEnumToString(gl, format);
230226
debug("");
@@ -244,7 +240,10 @@
244240
// It is legal for a WebGL implementation exposing the OES_texture_float extension to
245241
// support floating-point textures but not as attachments to framebuffer objects.
246242
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
247-
debug("floating-point " + formatString + " render target not supported -- this is legal");
243+
if (requireRenderable)
244+
testFailed("floating-point " + formatString + " render target not supported");
245+
else
246+
debug("floating-point " + formatString + " render target not supported -- this is legal");
248247
return;
249248
}
250249

sdk/tests/conformance/extensions/oes-texture-half-float.html

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@
158158
// Next check that values outside the 0-1 range can be written.
159159
var halfFloatTenK = 0x70E2; // Half float 10000
160160
var uint16Formats2 = [
161-
{ format: gl.RGBA, subtractor: [10000, 10000, 10000, 10000], },
162-
{ format: gl.RGB, subtractor: [10000, 10000, 10000, 1], },
161+
{ format: gl.RGBA, subtractor: [10000, 10000, 10000, 10000], requireRenderable: true},
162+
{ format: gl.RGB, subtractor: [10000, 10000, 10000, 1], requireRenderable: false},
163163
];
164164

165165
uint16Formats2.forEach(function(f) {
@@ -171,28 +171,22 @@
171171
for (var ii = 0; ii < uint16Data.length; ii++) {
172172
uint16Data[ii] = halfFloatTenK;
173173
}
174-
runRenderTest(format, f.subtractor, uint16Data);
174+
runRenderTest(format, f.subtractor, uint16Data, f.requireRenderable);
175175
});
176176

177177
(function() {
178178
debug("");
179+
var renderable = isRenderable(gl, ext);
179180
var renderableExtName = "EXT_color_buffer_half_float";
180-
if (isRenderable(gl, ext)) {
181-
var supported = gl.getSupportedExtensions();
182-
assertMsg(supported.includes(renderableExtName),
183-
"Implicit renderability requires exposing support for " + renderableExtName);
184-
} else {
185-
var renderableExt = gl.getExtension(renderableExtName);
186-
if (!renderableExt) {
187-
testPassed(renderableExtName + " not supported. This is fine.");
188-
return;
189-
}
190-
testPassed(renderableExtName + " supported. Proceeding to its tests.");
181+
var supported = gl.getSupportedExtensions().includes(renderableExtName);
182+
if (renderable && !supported) {
183+
testFailed("RGBA/HALF_FLOAT_OES is color renderable but " + renderableExtName + " not exposed");
184+
} else if (supported && !renderable) {
185+
testFailed(renderableExtName + " is exposed but RGBA/HALF_FLOAT_OES is not color renderable");
191186
}
192-
193-
if (runFramebufferTest()) {
194-
runRenderTest(gl.RGBA, [10000, 10000, 10000, 10000], null);
195-
runRenderTest(gl.RGB, [10000, 10000, 10000, 1], null);
187+
if (supported) {
188+
runRenderTest(gl.RGBA, [10000, 10000, 10000, 10000], null, true);
189+
runRenderTest(gl.RGB, [10000, 10000, 10000, 1], null, false);
196190
}
197191
})();
198192

@@ -311,7 +305,7 @@
311305
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
312306
}
313307

314-
function runRenderTest(format, subtractor, data)
308+
function runRenderTest(format, subtractor, data, requireRenderable)
315309
{
316310
var formatString = wtu.glEnumToString(gl, format);
317311

@@ -340,7 +334,11 @@
340334
// It is legal for a WebGL implementation exposing the OES_texture_half_float extension to
341335
// support half floating point textures but not as attachments to framebuffer objects.
342336
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
343-
testFailed(formatString + " render targets not supported.");
337+
if (requireRenderable) {
338+
testFailed(formatString + " render targets not supported.");
339+
} else {
340+
debug(formatString + " render targets not supported -- this is legal");
341+
}
344342
return;
345343
}
346344

0 commit comments

Comments
 (0)