Auto merge of #23226 - mmatyas:webgl_compressed_textures, r=jdm

Add initial support for WebGL compressed textures

This patch is an initial implementation of WebGL compressed texture support, it contains

- functions for registering and querying compressed texture extensions
- initial implementation of `CompressedTexImage2D` and `CompressedTexSubImage2D` and their parameter validation
- implementation of S3TC (DXT1, DXT3, DXT5) and ETC1 extensions as examples

What's still missing:

- some of the parameter validation steps are missing
- the pixel comparison tests fail for more complex cases (I'm probably missing something trivial at the GL calls)

Related: #10209 and #20594

cc @jdm @zakorgy

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] Related issues: #10209, #20594
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23226)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-05-21 17:10:24 -04:00 committed by GitHub
commit 123f58592c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 792 additions and 37 deletions

View file

@ -10888,7 +10888,9 @@
"conformance/extensions/webgl-compressed-texture-s3tc.html": [
[
"conformance/extensions/webgl-compressed-texture-s3tc.html",
{}
{
"timeout": "long"
}
]
],
"conformance/extensions/webgl-compressed-texture-size-limit.html": [
@ -27817,7 +27819,7 @@
"testharness"
],
"conformance/extensions/webgl-compressed-texture-s3tc.html": [
"28e3cfc5628760d1ae27166612f17ed46fa12b88",
"ea56180224af7537748a649a724563a86c431710",
"testharness"
],
"conformance/extensions/webgl-compressed-texture-size-limit.html": [

View file

@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
<meta name="timeout" content="long">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
@ -694,13 +695,6 @@ function compareRect(width, height, channels, expectedData, filteringMode) {
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, actual);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "reading back pixels");
var div = document.createElement("div");
div.className = "testimages";
insertImg(div, "expected", makeImage(width, height, expectedData, channels == 4));
insertImg(div, "actual", makeImage(width, height, actual, channels == 4));
div.appendChild(document.createElement('br'));
document.getElementById("console").appendChild(div);
var failed = false;
for (var yy = 0; yy < height; ++yy) {
for (var xx = 0; xx < width; ++xx) {
@ -714,6 +708,13 @@ function compareRect(width, height, channels, expectedData, filteringMode) {
for (var jj = 0; jj < 4; ++jj) {
if (actual[offset + jj] != expected[jj]) {
failed = true;
var div = document.createElement("div");
div.className = "testimages";
insertImg(div, "expected", makeImage(width, height, expectedData, channels == 4));
insertImg(div, "actual", makeImage(width, height, actual, channels == 4));
div.appendChild(document.createElement('br'));
document.getElementById("console").appendChild(div);
var was = actual[offset + 0].toString();
for (var j = 1; j < 4; ++j) {
was += "," + actual[offset + j];

View file

@ -0,0 +1,32 @@
diff --git a/tests/wpt/webgl/tests/conformance/extensions/webgl-compressed-texture-s3tc.html b/tests/wpt/webgl/tests/conformance/extensions/webgl-compressed-texture-s3tc.html
index 308e8577a8..ea56180224 100644
--- a/tests/wpt/webgl/tests/conformance/extensions/webgl-compressed-texture-s3tc.html
+++ b/tests/wpt/webgl/tests/conformance/extensions/webgl-compressed-texture-s3tc.html
@@ -695,13 +695,6 @@ function compareRect(width, height, channels, expectedData, filteringMode) {
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, actual);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "reading back pixels");
- var div = document.createElement("div");
- div.className = "testimages";
- insertImg(div, "expected", makeImage(width, height, expectedData, channels == 4));
- insertImg(div, "actual", makeImage(width, height, actual, channels == 4));
- div.appendChild(document.createElement('br'));
- document.getElementById("console").appendChild(div);
-
var failed = false;
for (var yy = 0; yy < height; ++yy) {
for (var xx = 0; xx < width; ++xx) {
@@ -715,6 +708,13 @@ function compareRect(width, height, channels, expectedData, filteringMode) {
for (var jj = 0; jj < 4; ++jj) {
if (actual[offset + jj] != expected[jj]) {
failed = true;
+ var div = document.createElement("div");
+ div.className = "testimages";
+ insertImg(div, "expected", makeImage(width, height, expectedData, channels == 4));
+ insertImg(div, "actual", makeImage(width, height, actual, channels == 4));
+ div.appendChild(document.createElement('br'));
+ document.getElementById("console").appendChild(div);
+
var was = actual[offset + 0].toString();
for (var j = 1; j < 4; ++j) {
was += "," + actual[offset + j];

View file

@ -15,6 +15,7 @@ PATCHES = [
("unit.patch", "conformance/more/unit.js"),
("timeout.patch", None),
("set-zero-timeout.patch", "js/webgl-test-utils.js"),
("compressed-images.patch", "conformance/extensions/webgl-compressed-texture-s3tc.html"),
]
# Fix for 'UnicodeDecodeError: 'ascii' codec can't decode byte'

View file

@ -92,3 +92,15 @@ index c1542f4fa9..b3ee786e0b 100644
<title>WebGL uniform packing restrctions Conformance Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
diff --git i/conformance/extensions/webgl-compressed-texture-s3tc.html w/conformance/extensions/webgl-compressed-texture-s3tc.html
index 28e3cfc562..308e8577a8 100644
--- i/conformance/extensions/webgl-compressed-texture-s3tc.html
+++ w/conformance/extensions/webgl-compressed-texture-s3tc.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>