Skip to content

Commit

Permalink
Test that vertex attribute is preserved across context switches (Khro…
Browse files Browse the repository at this point in the history
…nosGroup#2843)

See http://crbug.com/920033 for rationale for this test.
  • Loading branch information
y-novikov authored and kdashg committed Mar 30, 2019
1 parent 7e8ca9f commit 291335b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/tests/conformance/attribs/00_test_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ gl-vertexattribpointer-offsets.html
--min-version 1.0.2 gl-vertex-attrib-render.html
gl-vertex-attrib-zero-issues.html
--min-version 1.0.4 gl-vertex-attrib-unconsumed-out-of-bounds.html
--min-version 1.0.4 gl-vertex-attrib-context-switch.html
79 changes: 79 additions & 0 deletions sdk/tests/conformance/attribs/gl-vertex-attrib-context-switch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--
/*
** Copyright (c) 2019 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Vertex Attrib Context Switch Test</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="one" width="50" height="50">
</canvas>
<canvas id="two" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("tests that vertex attrib value is preserved across context switches");
var wtu = WebGLTestUtils;
var positionLocation = 0;
var colorLocation = 1;
var gridRes = 1;

var canvas1 = document.getElementById("one");
var gl1 = wtu.create3DContext(canvas1);
var program1 = wtu.setupSimpleVertexColorProgram(gl1, positionLocation, colorLocation);
gl1.vertexAttrib4f(colorLocation, 0.0, 1.0, 0.0, 1.0);
wtu.setupIndexedQuad(gl1, gridRes, positionLocation);
wtu.clearAndDrawIndexedQuad(gl1, gridRes);
wtu.checkCanvas(gl1, [0, 255, 0, 255], "should be green 1");

var canvas2 = document.getElementById("two");
var gl2 = wtu.create3DContext(canvas2);
var program2 = wtu.setupSimpleVertexColorProgram(gl2, positionLocation, colorLocation);
wtu.setupIndexedQuad(gl2, gridRes, positionLocation);
wtu.clearAndDrawIndexedQuad(gl2, gridRes);
wtu.checkCanvas(gl2, [0, 0, 0, 255], "should be black 1");

wtu.checkCanvas(gl1, [0, 255, 0, 255], "should be green 2");

wtu.clearAndDrawIndexedQuad(gl2, gridRes);
wtu.checkCanvas(gl2, [0, 0, 0, 255], "should be black 2");

wtu.clearAndDrawIndexedQuad(gl1, gridRes);
wtu.checkCanvas(gl1, [0, 255, 0, 255], "should be green 3");

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>

</body>
</html>

0 comments on commit 291335b

Please sign in to comment.