2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>Texture uploading from video through tex unit
1 bug
</title>
12 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
13 <script src=
"../../../js/js-test-pre.js"></script>
14 <script src=
"../../../js/webgl-test-utils.js"></script>
17 <canvas id=
"example" width=
"640" height=
"480"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
21 <script id=
"shader-fs" type=
"x-shader/x-fragment">
22 precision mediump float;
24 uniform sampler2D uTexture0;
25 uniform sampler2D uTexture1;
30 vec4 texture0Color = texture2D(uTexture0, vUV);
31 vec4 texture1Color = texture2D(uTexture1, vUV);
33 gl_FragColor = mix(texture0Color, texture1Color,
0.5);
36 <script id=
"shader-vs" type=
"x-shader/x-vertex">
37 attribute vec3 aVertexPosition;
38 attribute vec2 aTextureCoord;
44 gl_Position = vec4(aVertexPosition,
1.0);
51 (async
function test() {
52 var wtu
= WebGLTestUtils
;
53 description("Regression test for crbug.com/676719");
55 var gl
= wtu
.create3DContext("example", {preserveDrawingBuffer
: true});
58 testFailed("context does not exist");
63 var program
= wtu
.setupProgram(gl
, ["shader-vs", "shader-fs"],
64 ["aVertexPosition", "aTextureCoord"], [0, 1]);
67 testFailed("program does not exist");
72 var loc0
= gl
.getUniformLocation(program
, "uTexture0");
73 var loc1
= gl
.getUniformLocation(program
, "uTexture1");
75 testFailed("Failed to query uniform locations");
79 gl
.uniform1i(loc0
, 0);
80 gl
.uniform1i(loc1
, 1);
82 wtu
.setupUnitQuad(gl
, 0, 1);
85 var imageSrc
= "data:type/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AwVEx4QrzHJHAAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAB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QAACAAAAABAAAIAABAAAAAAgAAEAAAgAAAAN7o/wMPKI9LWOVgigAAAABJRU5ErkJggg==";
86 var imageElement
= document
.getElementById("src-image");
87 imageElement
.src
= imageSrc
;
88 await imageElement
.decode();
90 var resourcePath
= "../../../resources/";
93 { src
: resourcePath
+ "red-green.mp4",
94 type
: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' },
95 { src
: resourcePath
+ "red-green.webmvp8.webm",
96 type
: 'video/webm; codecs="vp8, vorbis"' },
97 { src
: resourcePath
+ "red-green.bt601.vp9.webm",
98 type
: 'video/webm; codecs="vp9"' },
100 var currentVideo
= null;
102 for (const info
of videos
) {
105 debug("testing: " + info
.type
);
106 const video
= document
.createElement("video");
109 if (!video
.canPlayType
) {
110 testFailed("video.canPlayType required method missing");
113 if(!video
.canPlayType(info
.type
).replace(/no/, '')) {
114 debug(info
.type
+ " unsupported");
117 document
.body
.appendChild(video
);
118 video
.type
= info
.type
;
119 video
.src
= info
.src
;
120 await
new Promise(res
=> {
121 wtu
.startPlayingAndWaitForVideo(video
, res
);
125 var texture0
= gl
.createTexture();
126 gl
.bindTexture(gl
.TEXTURE_2D
, texture0
);
127 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, video
);
128 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.LINEAR
);
129 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.LINEAR
);
130 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
131 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
132 gl
.bindTexture(gl
.TEXTURE_2D
, null);
134 var texture1
= gl
.createTexture();
135 gl
.bindTexture(gl
.TEXTURE_2D
, texture1
);
136 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, imageElement
);
137 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.LINEAR
);
138 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.LINEAR
);
139 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
140 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
141 gl
.bindTexture(gl
.TEXTURE_2D
, null);
143 // <-- Begin Observed -->
144 gl
.activeTexture(gl
.TEXTURE1
);
145 gl
.bindTexture(gl
.TEXTURE_2D
, texture1
);
147 gl
.activeTexture(gl
.TEXTURE0
);
148 gl
.bindTexture(gl
.TEXTURE_2D
, texture0
);
149 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, video
);
151 wtu
.clearAndDrawUnitQuad(gl
, [255, 0, 255, 255]);
153 var observedPixels
= new Uint8Array(640 * 480 * 4);
154 gl
.readPixels(0, 0, 640, 480, gl
.RGBA
, gl
.UNSIGNED_BYTE
, observedPixels
);
155 // <-- End Observed -->
157 // <-- Begin Expected -->
158 gl
.activeTexture(gl
.TEXTURE0
);
159 gl
.bindTexture(gl
.TEXTURE_2D
, texture0
);
160 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, video
);
162 gl
.activeTexture(gl
.TEXTURE1
);
163 gl
.bindTexture(gl
.TEXTURE_2D
, texture1
);
165 wtu
.clearAndDrawUnitQuad(gl
, [255, 0, 255, 255]);
167 var expectedPixels
= new Uint8Array(640 * 480 * 4);
168 gl
.readPixels(0, 0, 640, 480, gl
.RGBA
, gl
.UNSIGNED_BYTE
, expectedPixels
);
169 // <-- End Expected -->
173 var numDifferentPixels
= wtu
.comparePixels(observedPixels
, expectedPixels
, tolerance
, undefined);
174 if (numDifferentPixels
) {
175 testFailed("Texture states were incorrect for " + currentVideo
.type
+
176 ", rendering was wrong: found " + numDifferentPixels
+ " differing pixels");
178 testPassed(`Texture states were correct +/-${tolerance}, rendering as expected`);
180 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);