-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test that context creation reclaims vram to prevent creation fail… #2984
Open
kdashg
wants to merge
1
commit into
KhronosGroup:main
Choose a base branch
from
kdashg:test-context-creation-vram
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
85 changes: 85 additions & 0 deletions
85
sdk/tests/conformance/context/context-creation-reclaims-vram.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,85 @@ | ||
<!-- | ||
Copyright (c) 2019 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>Test that contexts are freed and garbage collected reasonably</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> | ||
<div id="description"></div> | ||
<div id="console"></div> | ||
<script> | ||
"use strict"; | ||
description(); | ||
|
||
const CANVAS_COUNT = 100; | ||
const SIZE_REQUEST = 23170; // Chrome doesn't even try for >2GB backbuffers. | ||
|
||
debug(`SIZE_REQUEST: ${SIZE_REQUEST*SIZE_REQUEST*4/1024/1024|0} MB`); | ||
|
||
const wtu = WebGLTestUtils; | ||
|
||
const canvasList = []; // Keeps canvases alive | ||
|
||
function newCanvas() { | ||
const canvas = document.createElement('canvas'); | ||
canvas.width = canvas.height = SIZE_REQUEST; | ||
|
||
canvasList.push(canvas); | ||
canvas.id = canvasList.length; | ||
|
||
canvas.addEventListener("webglcontextlost", function(e) { | ||
//e.preventDefault(); // preventDefault enables context restore. | ||
debug(`(webglcontextlost on canvas ${canvas.id})`); | ||
}); | ||
|
||
return canvas; | ||
} | ||
|
||
function testNextContext(minSize) { | ||
const canvas = newCanvas(); | ||
const gl = wtu.create3DContext(canvas, { | ||
depth: false, | ||
antialias: false, | ||
}); | ||
assertMsg(gl, `Creating context ${canvas.id} should succeed.`); | ||
if (gl) { | ||
const width = gl.drawingBufferWidth; | ||
const height = gl.drawingBufferHeight; | ||
debug(` allocated size: ${width*height*4/1024/1024|0} MB`); | ||
assertMsg(width >= minSize, | ||
` drawingBufferWidth (${width}) should be >= ${minSize}`); | ||
assertMsg(height >= minSize, | ||
` drawingBufferHeight (${height}) should be >= ${minSize}`); | ||
} | ||
|
||
if (canvasList.length >= CANVAS_COUNT) { | ||
finishTest(); | ||
return; | ||
} | ||
|
||
wtu.dispatchPromise(() => { testNextContext(minSize); }); | ||
} | ||
|
||
(function() { | ||
const probeCanvas = newCanvas(); | ||
const probeGl = wtu.create3DContext(probeCanvas); | ||
const minSize = Math.min(probeGl.drawingBufferWidth, probeGl.drawingBufferHeight); | ||
|
||
testNextContext(minSize); | ||
})(); | ||
|
||
var successfullyParsed = true; | ||
</script> | ||
|
||
</body> | ||
</html> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chromium's WebGL implementation handles the scenario of users allocating many WebGL contexts with large back buffers by scaling down the size of newly created back buffers, rather than losing older contexts. We've tried in the past to lift the global limits on the amount of back buffer VRAM that can be allocated, but have never succeeded; crashes have been seen inside OpenGL drivers on various platforms, instead of GL_OUT_OF_MEMORY being reported. I'm not sure that requiring that newly-allocated contexts have the same back buffer size as the originally-allocated context is an invariant we should enforce; let's discuss in real time on tomorrow's working group conference call.