diff --git a/sdk/tests/conformance2/wasm/00_test_list.txt b/sdk/tests/conformance2/wasm/00_test_list.txt index d188fc30a..fe31a7e18 100644 --- a/sdk/tests/conformance2/wasm/00_test_list.txt +++ b/sdk/tests/conformance2/wasm/00_test_list.txt @@ -1,12 +1,18 @@ ---min-version 2.0.1 readpixels-16gb-wasm-memory.html ---min-version 2.0.1 readpixels-4gb-wasm-memory.html ---min-version 2.0.1 teximage2d-16gb-wasm-memory.html ---min-version 2.0.1 teximage2d-4gb-wasm-memory.html ---min-version 2.0.1 texsubimage2d-16gb-wasm-memory.html ---min-version 2.0.1 texsubimage2d-4gb-wasm-memory.html ---min-version 2.0.1 bufferdata-16gb-wasm-memory.html +--min-version 2.0.1 bufferdata-2gb-in-4gb-wasm-memory.html --min-version 2.0.1 bufferdata-4gb-wasm-memory.html ---min-version 2.0.1 buffersubdata-16gb-wasm-memory.html +--min-version 2.0.1 bufferdata-16gb-wasm-memory.html +--min-version 2.0.1 buffersubdata-2gb-in-4gb-wasm-memory.html --min-version 2.0.1 buffersubdata-4gb-wasm-memory.html +--min-version 2.0.1 buffersubdata-16gb-wasm-memory.html +--min-version 2.0.1 getbuffersubdata-2gb-in-4gb-wasm-memory.html +--min-version 2.0.1 getbuffersubdata-4gb-wasm-memory.html --min-version 2.0.1 getbuffersubdata-16gb-wasm-memory.html ---min-version 2.0.1 getbuffersubdata-4gb-wasm-memory.html \ No newline at end of file +--min-version 2.0.1 readpixels-2gb-in-4gb-wasm-memory.html +--min-version 2.0.1 readpixels-4gb-wasm-memory.html +--min-version 2.0.1 readpixels-16gb-wasm-memory.html +--min-version 2.0.1 teximage2d-2gb-in-4gb-wasm-memory.html +--min-version 2.0.1 teximage2d-4gb-wasm-memory.html +--min-version 2.0.1 teximage2d-16gb-wasm-memory.html +--min-version 2.0.1 texsubimage2d-2gb-in-4gb-wasm-memory.html +--min-version 2.0.1 texsubimage2d-4gb-wasm-memory.html +--min-version 2.0.1 texsubimage2d-16gb-wasm-memory.html diff --git a/sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html index 0dd21bf64..aa7f488f9 100644 --- a/sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html @@ -26,23 +26,35 @@ const PAGE = 65536; const SIZE = 16 * 1024 * 1024 * 1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2, 3, 4]); -const length = expectedData.length; -const offset = SIZE - length; -view.set(expectedData, offset); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let expectedData = new Uint8Array([1, 2, 3, 4]); + const length = expectedData.length; + const offset = SIZE - length; + view.set(expectedData, offset); -let actualData = new Uint8Array(length); -gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -for (let i = 0; i < length; i++) { - shouldBe(`actualData[${i}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + try { + gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length); + } catch (e) { + testFailed(`bufferData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + + let actualData = new Uint8Array(length); + gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData); + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/bufferdata-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/bufferdata-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..822e11485 --- /dev/null +++ b/sdk/tests/conformance2/wasm/bufferdata-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,64 @@ + + + + + +bufferData test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html index 2296c3a5e..fbb1fa473 100644 --- a/sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html @@ -26,23 +26,35 @@ const PAGE = 65536; const SIZE = 4 * 1024 * 1024 * 1024 - PAGE; -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2, 3, 4]); -const length = expectedData.length; -const offset = SIZE - length; -view.set(expectedData, offset); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let expectedData = new Uint8Array([1, 2, 3, 4]); + const length = expectedData.length; + const offset = SIZE - length; + view.set(expectedData, offset); -let actualData = new Uint8Array(length); -gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -for (let i = 0; i < length; i++) { - shouldBe(`actualData[${i}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + try { + gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length); + } catch (e) { + testFailed(`bufferData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + + let actualData = new Uint8Array(length); + gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData); + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html index 08d6d1df5..c7f355e39 100644 --- a/sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html @@ -26,24 +26,36 @@ const PAGE = 65536; const SIZE = 16 * 1024 * 1024 * 1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2]); -const length = expectedData.length; -let srcOffset = SIZE - length; -view.set(expectedData, srcOffset); -const dstByteOffset = 4; +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW); -gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let expectedData = new Uint8Array([1, 2]); + const length = expectedData.length; + let srcOffset = SIZE - length; + view.set(expectedData, srcOffset); + const dstByteOffset = 4; -let actualData = new Uint8Array(length); -gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData); -for (let i = 0; i < length; i++) { - shouldBe(`actualData[${i}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW); + try { + gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length); + } catch (e) { + testFailed(`bufferSubData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + + let actualData = new Uint8Array(length); + gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/buffersubdata-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/buffersubdata-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..e7d65cc00 --- /dev/null +++ b/sdk/tests/conformance2/wasm/buffersubdata-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,65 @@ + + + + + +bufferSubData test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html index 2834a6901..6d84468fa 100644 --- a/sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html @@ -26,24 +26,36 @@ const PAGE = 65536; const SIZE = 4 * 1024 * 1024 * 1024 - PAGE; -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2]); -const length = expectedData.length; -let srcOffset = SIZE - length; -view.set(expectedData, srcOffset); -const dstByteOffset = 4; +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW); -gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let expectedData = new Uint8Array([1, 2]); + const length = expectedData.length; + let srcOffset = SIZE - length; + view.set(expectedData, srcOffset); + const dstByteOffset = 4; -let actualData = new Uint8Array(length); -gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData); -for (let i = 0; i < length; i++) { - shouldBe(`actualData[${i}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW); + try { + gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length); + } catch (e) { + testFailed(`bufferSubData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + + let actualData = new Uint8Array(length); + gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html index 8390957b0..1b7dc5f65 100644 --- a/sdk/tests/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html @@ -26,20 +26,33 @@ const PAGE = 65536; const SIZE = 16 * 1024 * 1024 * 1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2, 3, 4]); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW); + let expectedData = new Uint8Array([1, 2, 3, 4]); -const length = expectedData.length; -const offset = SIZE - length; -gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -for (let i = 0; i < length; i++) { - shouldBe(`view[${i + offset}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW); + + const length = expectedData.length; + const offset = SIZE - length; + try { + gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length); + } catch (e) { + testFailed(`getBufferSubData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let actualData = view.subarray(offset, offset+4); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/getbuffersubdata-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/getbuffersubdata-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..667c9fb99 --- /dev/null +++ b/sdk/tests/conformance2/wasm/getbuffersubdata-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,62 @@ + + + + + +getBufferSubData test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html index 09a336b75..dd90040f5 100644 --- a/sdk/tests/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html @@ -26,20 +26,33 @@ const PAGE = 65536; const SIZE = 4 * 1024 * 1024 * 1024 - PAGE; -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); -let expectedData = new Uint8Array([1, 2, 3, 4]); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -let buf = gl.createBuffer(); -gl.bindBuffer(gl.ARRAY_BUFFER, buf); -gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW); + let expectedData = new Uint8Array([1, 2, 3, 4]); -const length = expectedData.length; -const offset = SIZE - length; -gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -for (let i = 0; i < length; i++) { - shouldBe(`view[${i + offset}]`, `expectedData[${i}]`); -} + let buf = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buf); + gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW); + + const length = expectedData.length; + const offset = SIZE - length; + try { + gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length); + } catch (e) { + testFailed(`getBufferSubData from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let actualData = view.subarray(offset, offset+4); + expectArray(actualData, expectedData); +})(); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/readpixels-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/readpixels-16gb-wasm-memory.html index af74678dd..ab4991847 100644 --- a/sdk/tests/conformance2/wasm/readpixels-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/readpixels-16gb-wasm-memory.html @@ -27,23 +27,34 @@ const PAGE = 65536; const SIZE = 16*1024*1024*1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -// Clear the canvas to a specific color -const expectedColor = [42, 84, 128, 255]; -gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0); -gl.clear(gl.COLOR_BUFFER_BIT); + // Clear the canvas to a specific color + const expectedColor = [42, 84, 128, 255]; + gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // Test that gl.readPixels() can be called with a high offset to Memory + const offset = SIZE - 4; + view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading + try { + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`readPixels from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let obtainedColor = view.subarray(offset, offset+4); + expectArray(obtainedColor, expectedColor); +})(); -// Test that gl.readPixels() can be called with a high offset to Memory -const offset = SIZE - 4; -view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading -gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -let obtainedColor = view.subarray(offset, offset+4); -shouldBe('obtainedColor[0]', 'expectedColor[0]'); -shouldBe('obtainedColor[1]', 'expectedColor[1]'); -shouldBe('obtainedColor[2]', 'expectedColor[2]'); -shouldBe('obtainedColor[3]', 'expectedColor[3]'); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..14f93831c --- /dev/null +++ b/sdk/tests/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,62 @@ + + + + + +gl.readPixels() test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/readpixels-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/readpixels-4gb-wasm-memory.html index f97a3ccba..09a8af37a 100644 --- a/sdk/tests/conformance2/wasm/readpixels-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/readpixels-4gb-wasm-memory.html @@ -26,23 +26,34 @@ const PAGE = 65536; const SIZE = 4*1024*1024*1024 - PAGE; // when uint32_t size is max, we can only reach one page short of full 4GB -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -// Clear the canvas to a specific color -const expectedColor = [42, 84, 128, 255]; -gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0); -gl.clear(gl.COLOR_BUFFER_BIT); + // Clear the canvas to a specific color + const expectedColor = [42, 84, 128, 255]; + gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // Test that gl.readPixels() can be called with a high offset to Memory + const offset = SIZE - 4; + view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading + try { + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`readPixels from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let obtainedColor = view.subarray(offset, offset+4); + expectArray(obtainedColor, expectedColor); +})(); -// Test that gl.readPixels() can be called with a high offset to Memory -const offset = SIZE - 4; -view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading -gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); -let obtainedColor = view.subarray(offset, offset+4); -shouldBe('obtainedColor[0]', 'expectedColor[0]'); -shouldBe('obtainedColor[1]', 'expectedColor[1]'); -shouldBe('obtainedColor[2]', 'expectedColor[2]'); -shouldBe('obtainedColor[3]', 'expectedColor[3]'); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/teximage2d-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/teximage2d-16gb-wasm-memory.html index 8ce511195..b2e7615f1 100644 --- a/sdk/tests/conformance2/wasm/teximage2d-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/teximage2d-16gb-wasm-memory.html @@ -26,58 +26,72 @@ const PAGE = 65536; const SIZE = 16*1024*1024*1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -function compileShader(type, src) { - let shader = gl.createShader(type); - gl.shaderSource(shader, src); - gl.compileShader(shader); - let log = gl.getShaderInfoLog(shader); - if (log) debug(log); - return shader; -} + function compileShader(type, src) { + let shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + let log = gl.getShaderInfoLog(shader); + if (log) debug(log); + return shader; + } -function createProgram(vs, fs) { - let program = gl.createProgram(); - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.bindAttribLocation(program, 0, 'pos'); - gl.linkProgram(program); - gl.useProgram(program); - return program; -} + function createProgram(vs, fs) { + let program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.bindAttribLocation(program, 0, 'pos'); + gl.linkProgram(program); + gl.useProgram(program); + return program; + } -let program = createProgram( - compileShader(gl.VERTEX_SHADER, ` - varying vec2 uv; - attribute vec2 pos; - void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), - compileShader(gl.FRAGMENT_SHADER, ` - precision lowp float; - uniform sampler2D tex; - varying vec2 uv; - void main() { gl_FragColor = texture2D(tex,uv); }`)); + let program = createProgram( + compileShader(gl.VERTEX_SHADER, ` + varying vec2 uv; + attribute vec2 pos; + void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), + compileShader(gl.FRAGMENT_SHADER, ` + precision lowp float; + uniform sampler2D tex; + varying vec2 uv; + void main() { gl_FragColor = texture2D(tex,uv); }`)); -gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); -gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); -gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); -gl.enableVertexAttribArray(0); + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); + gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); + gl.enableVertexAttribArray(0); -let texture = gl.createTexture(); -gl.bindTexture(gl.TEXTURE_2D, texture); + let texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); -// Test uploading an image -const expectedColor = [42, 84, 128, 255]; -const offset = SIZE - 4; -view.set(expectedColor, offset); -gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + // Test uploading an image + const expectedColor = [42, 84, 128, 255]; + const offset = SIZE - 4; + view.set(expectedColor, offset); + try { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`texImage2D from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); -// Test rendering with that image -gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + // Test rendering with that image + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Verify that we rendered what we expected + wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color"); +})(); -// Verify that we rendered what we expected -wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color"); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/teximage2d-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/teximage2d-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..bacabcf39 --- /dev/null +++ b/sdk/tests/conformance2/wasm/teximage2d-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,101 @@ + + + + + +gl.texImage2D() test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/teximage2d-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/teximage2d-4gb-wasm-memory.html index 5d6897347..20a47a527 100644 --- a/sdk/tests/conformance2/wasm/teximage2d-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/teximage2d-4gb-wasm-memory.html @@ -26,58 +26,73 @@ const PAGE = 65536; const SIZE = 4*1024*1024*1024 - PAGE; // when uint32_t size is max, we can only reach one page short of full 4GB -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -function compileShader(type, src) { - let shader = gl.createShader(type); - gl.shaderSource(shader, src); - gl.compileShader(shader); - let log = gl.getShaderInfoLog(shader); - if (log) debug(log); - return shader; -} -function createProgram(vs, fs) { - let program = gl.createProgram(); - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.bindAttribLocation(program, 0, 'pos'); - gl.linkProgram(program); - gl.useProgram(program); - return program; -} + function compileShader(type, src) { + let shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + let log = gl.getShaderInfoLog(shader); + if (log) debug(log); + return shader; + } -let program = createProgram( - compileShader(gl.VERTEX_SHADER, ` - varying vec2 uv; - attribute vec2 pos; - void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), - compileShader(gl.FRAGMENT_SHADER, ` - precision lowp float; - uniform sampler2D tex; - varying vec2 uv; - void main() { gl_FragColor = texture2D(tex,uv); }`)); + function createProgram(vs, fs) { + let program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.bindAttribLocation(program, 0, 'pos'); + gl.linkProgram(program); + gl.useProgram(program); + return program; + } -gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); -gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); -gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); -gl.enableVertexAttribArray(0); + let program = createProgram( + compileShader(gl.VERTEX_SHADER, ` + varying vec2 uv; + attribute vec2 pos; + void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), + compileShader(gl.FRAGMENT_SHADER, ` + precision lowp float; + uniform sampler2D tex; + varying vec2 uv; + void main() { gl_FragColor = texture2D(tex,uv); }`)); -let texture = gl.createTexture(); -gl.bindTexture(gl.TEXTURE_2D, texture); + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); + gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); + gl.enableVertexAttribArray(0); -// Test uploading an image -const expectedColor = [42, 84, 128, 255]; -const offset = SIZE - 4; -view.set(expectedColor, offset); -gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + let texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); -// Test rendering with that image -gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + // Test uploading an image + const expectedColor = [42, 84, 128, 255]; + const offset = SIZE - 4; + view.set(expectedColor, offset); + try { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`texImage2D from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); + + // Test rendering with that image + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Verify that we rendered what we expected + wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color"); +})(); -// Verify that we rendered what we expected -wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color"); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html b/sdk/tests/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html index 328d42ec4..df3c3eef5 100644 --- a/sdk/tests/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html @@ -26,59 +26,73 @@ const PAGE = 65536; const SIZE = 16*1024*1024*1024; -let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -function compileShader(type, src) { - let shader = gl.createShader(type); - gl.shaderSource(shader, src); - gl.compileShader(shader); - let log = gl.getShaderInfoLog(shader); - if (log) debug(log); - return shader; -} + function compileShader(type, src) { + let shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + let log = gl.getShaderInfoLog(shader); + if (log) debug(log); + return shader; + } -function createProgram(vs, fs) { - let program = gl.createProgram(); - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.bindAttribLocation(program, 0, 'pos'); - gl.linkProgram(program); - gl.useProgram(program); - return program; -} + function createProgram(vs, fs) { + let program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.bindAttribLocation(program, 0, 'pos'); + gl.linkProgram(program); + gl.useProgram(program); + return program; + } -let program = createProgram( - compileShader(gl.VERTEX_SHADER, ` - varying vec2 uv; - attribute vec2 pos; - void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), - compileShader(gl.FRAGMENT_SHADER, ` - precision lowp float; - uniform sampler2D tex; - varying vec2 uv; - void main() { gl_FragColor = texture2D(tex,uv); }`)); + let program = createProgram( + compileShader(gl.VERTEX_SHADER, ` + varying vec2 uv; + attribute vec2 pos; + void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), + compileShader(gl.FRAGMENT_SHADER, ` + precision lowp float; + uniform sampler2D tex; + varying vec2 uv; + void main() { gl_FragColor = texture2D(tex,uv); }`)); -gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); -gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); -gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); -gl.enableVertexAttribArray(0); + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); + gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); + gl.enableVertexAttribArray(0); -let texture = gl.createTexture(); -gl.bindTexture(gl.TEXTURE_2D, texture); + let texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); -// Test uploading an image -const expectedColor = [42, 84, 128, 255]; -const offset = SIZE - 4; -view.set(expectedColor, offset); -gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1); -gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + // Test uploading an image + const expectedColor = [42, 84, 128, 255]; + const offset = SIZE - 4; + view.set(expectedColor, offset); + gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1); + try { + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`texSubImage2D from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); -// Test rendering with that image -gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + // Test rendering with that image + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Verify that we rendered what we expected + wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color"); +})(); -// Verify that we rendered what we expected -wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color"); var successfullyParsed = true; diff --git a/sdk/tests/conformance2/wasm/texsubimage2d-2gb-in-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/texsubimage2d-2gb-in-4gb-wasm-memory.html new file mode 100644 index 000000000..f8acb2645 --- /dev/null +++ b/sdk/tests/conformance2/wasm/texsubimage2d-2gb-in-4gb-wasm-memory.html @@ -0,0 +1,101 @@ + + + + + +gl.texSubImage2D() test to Wasm Memory 4GB in size. + + + + + + +
+
+ + + + diff --git a/sdk/tests/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html b/sdk/tests/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html index d7756629a..c065bafb5 100644 --- a/sdk/tests/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html +++ b/sdk/tests/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html @@ -26,59 +26,73 @@ const PAGE = 65536; const SIZE = 4*1024*1024*1024 - PAGE; // when uint32_t size is max, we can only reach one page short of full 4GB -let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer); +(() => { + let view; + try { + view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); + } catch (e) { + testPassed(`Allocating ${SIZE} threw: ${e}`); + return; + } -function compileShader(type, src) { - let shader = gl.createShader(type); - gl.shaderSource(shader, src); - gl.compileShader(shader); - let log = gl.getShaderInfoLog(shader); - if (log) debug(log); - return shader; -} + function compileShader(type, src) { + let shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + let log = gl.getShaderInfoLog(shader); + if (log) debug(log); + return shader; + } -function createProgram(vs, fs) { - let program = gl.createProgram(); - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.bindAttribLocation(program, 0, 'pos'); - gl.linkProgram(program); - gl.useProgram(program); - return program; -} + function createProgram(vs, fs) { + let program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.bindAttribLocation(program, 0, 'pos'); + gl.linkProgram(program); + gl.useProgram(program); + return program; + } -let program = createProgram( - compileShader(gl.VERTEX_SHADER, ` - varying vec2 uv; - attribute vec2 pos; - void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), - compileShader(gl.FRAGMENT_SHADER, ` - precision lowp float; - uniform sampler2D tex; - varying vec2 uv; - void main() { gl_FragColor = texture2D(tex,uv); }`)); + let program = createProgram( + compileShader(gl.VERTEX_SHADER, ` + varying vec2 uv; + attribute vec2 pos; + void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`), + compileShader(gl.FRAGMENT_SHADER, ` + precision lowp float; + uniform sampler2D tex; + varying vec2 uv; + void main() { gl_FragColor = texture2D(tex,uv); }`)); -gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); -gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); -gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); -gl.enableVertexAttribArray(0); + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW); + gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0); + gl.enableVertexAttribArray(0); -let texture = gl.createTexture(); -gl.bindTexture(gl.TEXTURE_2D, texture); + let texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); -// Test uploading an image -const expectedColor = [42, 84, 128, 255]; -const offset = SIZE - 4; -view.set(expectedColor, offset); -gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1); -gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); -wtu.glErrorShouldBe(gl, gl.NO_ERROR); + // Test uploading an image + const expectedColor = [42, 84, 128, 255]; + const offset = SIZE - 4; + view.set(expectedColor, offset); + gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1); + try { + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset); + } catch (e) { + testFailed(`texSubImage2D from ${view.length} byte view threw: ${e}`); + return; + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR); -// Test rendering with that image -gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + // Test rendering with that image + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Verify that we rendered what we expected + wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color"); +})(); -// Verify that we rendered what we expected -wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color"); var successfullyParsed = true;