Skip to content

Commit 5a01424

Browse files
authored
Fix incorrect assumptions in drawingbuffer-storage-test. (#3770)
It is not guaranteed that WebGL implementations can allocate a drawing buffer at any specific size. Avoid asserting that allocations up to the maximum renderbuffer size will succeed. Associated with https://crbug.com/332743717 .
1 parent 216b10f commit 5a01424

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

sdk/tests/js/tests/drawingbuffer-storage-test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ let height;
1313
let format;
1414
let hasDrawingBufferStorage;
1515
let maxRenderbufferSize;
16+
let currentWidth;
17+
let currentHeight;
1618

1719
function runTest(contextVersion) {
1820
description();
@@ -185,19 +187,25 @@ function runTest(contextVersion) {
185187
return;
186188
}
187189

190+
// https://registry.khronos.org/webgl/specs/latest/1.0/#2.2 does
191+
// not guarantee that a drawing buffer of a given width and height
192+
// can be allocated at exactly that size.
193+
188194
debug('Testing maximum size');
189195
gl.drawingBufferStorage(gl.RGBA8, maxRenderbufferSize, maxRenderbufferSize);
190196
shouldBe('gl.getError()', 'gl.NONE');
191-
shouldBe('gl.drawingBufferWidth', 'maxRenderbufferSize');
192-
shouldBe('gl.drawingBufferHeight', 'maxRenderbufferSize');
197+
shouldBeTrue('gl.drawingBufferWidth <= maxRenderbufferSize');
198+
shouldBeTrue('gl.drawingBufferHeight <= maxRenderbufferSize');
199+
currentWidth = gl.drawingBufferWidth;
200+
currentHeight = gl.drawingBufferHeight;
193201

194-
debug('Testing over-maximum width and ehgith');
202+
debug('Testing over-maximum width and height');
195203
gl.drawingBufferStorage(gl.RGBA8, maxRenderbufferSize+1, 16);
196204
shouldBe('gl.getError()', 'gl.INVALID_VALUE');
197205
gl.drawingBufferStorage(gl.RGBA8, 16, maxRenderbufferSize+1);
198206
shouldBe('gl.getError()', 'gl.INVALID_VALUE');
199-
shouldBe('gl.drawingBufferWidth', 'maxRenderbufferSize');
200-
shouldBe('gl.drawingBufferHeight', 'maxRenderbufferSize');
207+
shouldBe('gl.drawingBufferWidth', 'currentWidth');
208+
shouldBe('gl.drawingBufferHeight', 'currentHeight');
201209
}
202210

203211
function testDrawToCanvas() {

0 commit comments

Comments
 (0)