-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tolerate throws in wasm/* tests, add 2gb-in-4gb variants. (#3665)
* Tolerate throws in wasm/* tests, add 2gb-in-4gb variants. For browsers that don't support this large of wasm memory sizes, consider as PASS, so that browser features don't block webgl conformance. For UAs that throw on use of large TypedArrays, FAIL but safely. Also, Firefox *does* support ~4GB wasm memory sizes, but currently throws when >2GB TypedArray views are passed to entrypoints. However, Firefox does support <2GB-sized views of >2GB ArrayBuffers, so add tests for that. This reflects the ability for apps to use large WASM heaps, so long as only smaller views are passed to webgl.
- Loading branch information
Showing
19 changed files
with
929 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
--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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sdk/tests/conformance2/wasm/bufferdata-2gb-in-4gb-wasm-memory.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!-- | ||
Copyright (c) 2024 The Khronos Group Inc. | ||
Use of this source code is governed by an MIT-style license that can be | ||
found in the LICENSE.txt file. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>bufferData test to Wasm Memory 4GB in size.</title> | ||
<link rel="stylesheet" href="../../resources/js-test-style.css"/> | ||
<script src="../../js/js-test-pre.js"></script> | ||
<script src="../../js/webgl-test-utils.js"> </script> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas> | ||
<div id="description"></div> | ||
<div id="console"></div> | ||
<script> | ||
"use strict"; | ||
description(document.title); | ||
debug("Tests that bufferData can be called on the end of a ~2GB view into ~4GB of WebAssembly Memory."); | ||
debug(""); | ||
let wtu = WebGLTestUtils; | ||
let gl = wtu.create3DContext("canvas", undefined, 2); | ||
|
||
const PAGE = 65536; | ||
const HEAP_SIZE = 4 * 1024 * 1024 * 1024 - PAGE; | ||
const VIEW_SIZE = 2 * 1024 * 1024 * 1024 - PAGE; | ||
(() => { | ||
let view; | ||
try { | ||
view = new Uint8Array(new WebAssembly.Memory({ initial: HEAP_SIZE / PAGE }).buffer, 0, VIEW_SIZE); | ||
} catch (e) { | ||
testPassed(`Allocating ${HEAP_SIZE} threw: ${e}`); | ||
return; | ||
} | ||
|
||
let expectedData = new Uint8Array([1, 2, 3, 4]); | ||
const length = expectedData.length; | ||
const offset = view.length - length; | ||
view.set(expectedData, offset); | ||
|
||
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; | ||
</script> | ||
<script src="../../js/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
sdk/tests/conformance2/wasm/buffersubdata-2gb-in-4gb-wasm-memory.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!-- | ||
Copyright (c) 2024 The Khronos Group Inc. | ||
Use of this source code is governed by an MIT-style license that can be | ||
found in the LICENSE.txt file. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>bufferSubData test to Wasm Memory 4GB in size.</title> | ||
<link rel="stylesheet" href="../../resources/js-test-style.css"/> | ||
<script src="../../js/js-test-pre.js"></script> | ||
<script src="../../js/webgl-test-utils.js"> </script> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas> | ||
<div id="description"></div> | ||
<div id="console"></div> | ||
<script> | ||
"use strict"; | ||
description(document.title); | ||
debug("Tests that bufferSubData can be called on the end of a ~2GB view into ~4GB of WebAssembly Memory."); | ||
debug(""); | ||
let wtu = WebGLTestUtils; | ||
let gl = wtu.create3DContext("canvas", undefined, 2); | ||
|
||
const PAGE = 65536; | ||
const HEAP_SIZE = 4 * 1024 * 1024 * 1024 - PAGE; | ||
const VIEW_SIZE = 2 * 1024 * 1024 * 1024 - PAGE; | ||
(() => { | ||
let view; | ||
try { | ||
view = new Uint8Array(new WebAssembly.Memory({ initial: HEAP_SIZE / PAGE }).buffer, 0, VIEW_SIZE); | ||
} catch (e) { | ||
testPassed(`Allocating ${HEAP_SIZE} threw: ${e}`); | ||
return; | ||
} | ||
|
||
let expectedData = new Uint8Array([1, 2]); | ||
const length = expectedData.length; | ||
let srcOffset = view.length - length; | ||
view.set(expectedData, srcOffset); | ||
const dstByteOffset = 4; | ||
|
||
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; | ||
</script> | ||
<script src="../../js/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.