From 55742c212ba275200fccb0398f1a8f53801d39d4 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 16 Oct 2018 17:08:15 +0200 Subject: [PATCH] Properly support gl_PointSize and gl_PointCoord Fixes #21719. Fixes #20993. Fixes #20992. Fixes #21007. Fixes #20979. --- components/canvas/webgl_thread.rs | 11 + components/canvas_traits/webgl.rs | 6 + .../ext/extshadertexturelod.rs | 4 +- .../ext/oeselementindexuint.rs | 4 +- .../ext/oesstandardderivatives.rs | 4 +- components/script/dom/webglrenderbuffer.rs | 4 +- .../script/dom/webglrenderingcontext.rs | 6 - .../glsl/variables/gl-pointcoord.html.ini | 194 ------------------ .../conformance/rendering/point-size.html.ini | 7 - ...-gl-pointcoord-in-fragment-shader.html.ini | 4 - 10 files changed, 25 insertions(+), 219 deletions(-) delete mode 100644 tests/wpt/webgl/meta/conformance/glsl/variables/gl-pointcoord.html.ini delete mode 100644 tests/wpt/webgl/meta/conformance/rendering/point-size.html.ini delete mode 100644 tests/wpt/webgl/meta/conformance/rendering/point-with-gl-pointcoord-in-fragment-shader.html.ini diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 992416bc28c44..65639df81a5f4 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -122,6 +122,17 @@ impl WebGLThread { .expect("WebGLContext not found"); let glsl_version = Self::get_glsl_version(&data.ctx); + // FIXME(nox): Should probably be done by offscreen_gl_context. + if glsl_version.major < 2 { + // FIXME(nox): Should be gl::POINT_SPRITE but gleam only + // generates bindings for core profile stuff and this has + // been removed from core profile. + data.ctx.gl().enable(0x8861); + } + if !is_gles() { + data.ctx.gl().enable(gl::PROGRAM_POINT_SIZE); + } + WebGLCreateContextResult { sender: WebGLMsgSender::new(id, webgl_chan.clone()), limits, diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 43a24771ae158..c3912ad162694 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -605,3 +605,9 @@ parameters! { }), } } + +pub fn is_gles() -> bool { + // TODO: align this with the actual kind of graphics context in use, rather than + // making assumptions based on platform + cfg!(any(target_os = "android", target_os = "ios")) +} diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs index 9766032c0c593..2082d771f02c6 100644 --- a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs +++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas_traits::webgl::WebGLVersion; +use canvas_traits::webgl::{WebGLVersion, is_gles}; use dom::bindings::codegen::Bindings::EXTShaderTextureLodBinding; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::root::DomRoot; -use dom::webglrenderingcontext::{WebGLRenderingContext, is_gles}; +use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec}; diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs index 48e60b316ddfa..c3c96bd5891f4 100644 --- a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs +++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas_traits::webgl::WebGLVersion; +use canvas_traits::webgl::{WebGLVersion, is_gles}; use dom::bindings::codegen::Bindings::OESElementIndexUintBinding; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::root::DomRoot; -use dom::webglrenderingcontext::{WebGLRenderingContext, is_gles}; +use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec}; diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index 966a03505b667..a9142d2fb8824 100644 --- a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -2,12 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas_traits::webgl::WebGLVersion; +use canvas_traits::webgl::{WebGLVersion, is_gles}; use dom::bindings::codegen::Bindings::OESStandardDerivativesBinding; use dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::root::DomRoot; -use dom::webglrenderingcontext::{WebGLRenderingContext, is_gles}; +use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec}; diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index edfed388c39e4..7b9863257ded4 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult}; +use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, is_gles, webgl_channel}; use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as WebGl2Constants; use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -11,7 +11,7 @@ use dom::bindings::inheritance::Castable; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::root::DomRoot; use dom::webglobject::WebGLObject; -use dom::webglrenderingcontext::{WebGLRenderingContext, is_gles}; +use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use std::cell::Cell; diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index c8f2b1fce4f18..123e3e490befc 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -73,12 +73,6 @@ use std::cmp; use std::ptr::{self, NonNull}; use webrender_api; -pub fn is_gles() -> bool { - // TODO: align this with the actual kind of graphics context in use, rather than - // making assumptions based on platform - cfg!(any(target_os = "android", target_os = "ios")) -} - // From the GLES 2.0.25 spec, page 85: // // "If a texture that is currently bound to one of the targets diff --git a/tests/wpt/webgl/meta/conformance/glsl/variables/gl-pointcoord.html.ini b/tests/wpt/webgl/meta/conformance/glsl/variables/gl-pointcoord.html.ini deleted file mode 100644 index aa794bc8d38f8..0000000000000 --- a/tests/wpt/webgl/meta/conformance/glsl/variables/gl-pointcoord.html.ini +++ /dev/null @@ -1,194 +0,0 @@ -[gl-pointcoord.html] - bug: https://github.com/servo/servo/issues/21719 - [WebGL test #48: pixel 48,192 should be 65,125,0\nat (48, 192) expected: 65,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #67: pixel 160,208 should be 1,61,0\nat (160, 208) expected: 1,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #15: pixel 32,64 should be 1,125,0\nat (32, 64) expected: 1,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #45: pixel 64,176 should be 129,189,0\nat (64, 176) expected: 129,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #18: pixel 80,64 should be 193,125,0\nat (80, 64) expected: 193,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #47: pixel 32,192 should be 1,125,0\nat (32, 192) expected: 1,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #42: pixel 80,160 should be 193,253,0\nat (80, 160) expected: 193,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #34: pixel 208,64 should be 193,125,0\nat (208, 64) expected: 193,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #53: pixel 64,208 should be 129,61,0\nat (64, 208) expected: 129,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #29: pixel 192,48 should be 129,189,0\nat (192, 48) expected: 129,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #40: pixel 48,160 should be 65,253,0\nat (48, 160) expected: 65,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #59: pixel 160,176 should be 1,189,0\nat (160, 176) expected: 1,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #26: pixel 208,32 should be 193,253,0\nat (208, 32) expected: 193,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #62: pixel 208,176 should be 193,189,0\nat (208, 176) expected: 193,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #8: pixel 48,32 should be 65,253,0\nat (48, 32) expected: 65,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #31: pixel 160,64 should be 1,125,0\nat (160, 64) expected: 1,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #65: pixel 192,192 should be 129,125,0\nat (192, 192) expected: 129,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #55: pixel 160,160 should be 1,253,0\nat (160, 160) expected: 1,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #10: pixel 80,32 should be 193,253,0\nat (80, 32) expected: 193,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #11: pixel 32,48 should be 1,189,0\nat (32, 48) expected: 1,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #50: pixel 80,192 should be 193,125,0\nat (80, 192) expected: 193,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #51: pixel 32,208 should be 1,61,0\nat (32, 208) expected: 1,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #21: pixel 64,80 should be 129,61,0\nat (64, 80) expected: 129,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #54: pixel 80,208 should be 193,61,0\nat (80, 208) expected: 193,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #33: pixel 192,64 should be 129,125,0\nat (192, 64) expected: 129,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #17: pixel 64,64 should be 129,125,0\nat (64, 64) expected: 129,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #38: pixel 208,80 should be 193,61,0\nat (208, 80) expected: 193,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #49: pixel 64,192 should be 129,125,0\nat (64, 192) expected: 129,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #7: pixel 32,32 should be 1,253,0\nat (32, 32) expected: 1,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #13: pixel 64,48 should be 129,189,0\nat (64, 48) expected: 129,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #46: pixel 80,176 should be 193,189,0\nat (80, 176) expected: 193,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #9: pixel 64,32 should be 129,253,0\nat (64, 32) expected: 129,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #28: pixel 176,48 should be 65,189,0\nat (176, 48) expected: 65,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #25: pixel 192,32 should be 129,253,0\nat (192, 32) expected: 129,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #20: pixel 48,80 should be 65,61,0\nat (48, 80) expected: 65,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #57: pixel 192,160 should be 129,253,0\nat (192, 160) expected: 129,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #30: pixel 208,48 should be 193,189,0\nat (208, 48) expected: 193,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #36: pixel 176,80 should be 65,61,0\nat (176, 80) expected: 65,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #37: pixel 192,80 should be 129,61,0\nat (192, 80) expected: 129,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #52: pixel 48,208 should be 65,61,0\nat (48, 208) expected: 65,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #23: pixel 160,32 should be 1,253,0\nat (160, 32) expected: 1,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #16: pixel 48,64 should be 65,125,0\nat (48, 64) expected: 65,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #32: pixel 176,64 should be 65,125,0\nat (176, 64) expected: 65,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #24: pixel 176,32 should be 65,253,0\nat (176, 32) expected: 65,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #60: pixel 176,176 should be 65,189,0\nat (176, 176) expected: 65,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #43: pixel 32,176 should be 1,189,0\nat (32, 176) expected: 1,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #63: pixel 160,192 should be 1,125,0\nat (160, 192) expected: 1,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #64: pixel 176,192 should be 65,125,0\nat (176, 192) expected: 65,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #44: pixel 48,176 should be 65,189,0\nat (48, 176) expected: 65,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #56: pixel 176,160 should be 65,253,0\nat (176, 160) expected: 65,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #19: pixel 32,80 should be 1,61,0\nat (32, 80) expected: 1,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #35: pixel 160,80 should be 1,61,0\nat (160, 80) expected: 1,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #70: pixel 208,208 should be 193,61,0\nat (208, 208) expected: 193,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #58: pixel 208,160 should be 193,253,0\nat (208, 160) expected: 193,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #68: pixel 176,208 should be 65,61,0\nat (176, 208) expected: 65,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #22: pixel 80,80 should be 193,61,0\nat (80, 80) expected: 193,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #66: pixel 208,192 should be 193,125,0\nat (208, 192) expected: 193,125,0 was 0,0,0] - expected: FAIL - - [WebGL test #69: pixel 192,208 should be 129,61,0\nat (192, 208) expected: 129,61,0 was 0,0,0] - expected: FAIL - - [WebGL test #39: pixel 32,160 should be 1,253,0\nat (32, 160) expected: 1,253,0 was 0,0,0] - expected: FAIL - - [WebGL test #14: pixel 80,48 should be 193,189,0\nat (80, 48) expected: 193,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #12: pixel 48,48 should be 65,189,0\nat (48, 48) expected: 65,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #61: pixel 192,176 should be 129,189,0\nat (192, 176) expected: 129,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #27: pixel 160,48 should be 1,189,0\nat (160, 48) expected: 1,189,0 was 0,0,0] - expected: FAIL - - [WebGL test #41: pixel 64,160 should be 129,253,0\nat (64, 160) expected: 129,253,0 was 0,0,0] - expected: FAIL - diff --git a/tests/wpt/webgl/meta/conformance/rendering/point-size.html.ini b/tests/wpt/webgl/meta/conformance/rendering/point-size.html.ini deleted file mode 100644 index 08ac9e564ff6a..0000000000000 --- a/tests/wpt/webgl/meta/conformance/rendering/point-size.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[point-size.html] - [WebGL test #9: should be 255,0,0\nat (0, 0) expected: 255,0,0 was 0,0,0] - expected: FAIL - - [WebGL test #18: should be 255,0,0\nat (0, 0) expected: 255,0,0 was 0,0,0] - expected: FAIL - diff --git a/tests/wpt/webgl/meta/conformance/rendering/point-with-gl-pointcoord-in-fragment-shader.html.ini b/tests/wpt/webgl/meta/conformance/rendering/point-with-gl-pointcoord-in-fragment-shader.html.ini deleted file mode 100644 index f37a16c994a77..0000000000000 --- a/tests/wpt/webgl/meta/conformance/rendering/point-with-gl-pointcoord-in-fragment-shader.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[point-with-gl-pointcoord-in-fragment-shader.html] - [WebGL test #0: Center pixel should be green\nat (32, 32) expected: 0,255,0,255 was 0,0,0,255] - expected: FAIL -