From 6b0c898e1a2cde3d47ca6593b8250b765cc06771 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Thu, 20 Apr 2017 14:55:43 +0200 Subject: [PATCH] Fix highp precision in shaders & Implement WebGL::GetShaderPrecisionFormat --- .../script/dom/webglrenderingcontext.rs | 22 ++ components/script/dom/webglshader.rs | 4 +- .../dom/webidls/WebGLRenderingContext.webidl | 2 +- .../conformance/context/methods.html.ini | 292 +----------------- .../constant-precision-qualifier.html.ini | 6 - .../shader-precision-format-obeyed.html.ini | 6 - .../misc/shader-precision-format.html.ini | 45 --- 7 files changed, 31 insertions(+), 346 deletions(-) delete mode 100644 tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/bugs/constant-precision-qualifier.html.ini delete mode 100644 tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/misc/shader-precision-format-obeyed.html.ini delete mode 100644 tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/shader-precision-format.html.ini diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 8d99e1303d0..34f5b368a42 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -31,6 +31,7 @@ use dom::webglframebuffer::WebGLFramebuffer; use dom::webglprogram::WebGLProgram; use dom::webglrenderbuffer::WebGLRenderbuffer; use dom::webglshader::WebGLShader; +use dom::webglshaderprecisionformat::WebGLShaderPrecisionFormat; use dom::webgltexture::{TexParameterValue, WebGLTexture}; use dom::webgluniformlocation::WebGLUniformLocation; use dom::window::Window; @@ -1902,6 +1903,27 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } } + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 + fn GetShaderPrecisionFormat(&self, + shader_type: u32, + precision_type: u32) + -> Option> { + let (sender, receiver) = webrender_traits::channel::msg_channel().unwrap(); + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::GetShaderPrecisionFormat(shader_type, + precision_type, + sender))) + .unwrap(); + match receiver.recv().unwrap() { + Ok((range_min, range_max, precision)) => { + Some(WebGLShaderPrecisionFormat::new(self.global().as_window(), range_min, range_max, precision)) + }, + Err(error) => { + self.webgl_error(error); + None + } + } + } + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn GetUniformLocation(&self, program: Option<&WebGLProgram>, diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 1526b5303f7..b66151bf353 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -106,9 +106,11 @@ impl WebGLShader { } if let Some(ref source) = *self.source.borrow() { + let mut params = BuiltInResources::default(); + params.FragmentPrecisionHigh = 1; let validator = ShaderValidator::for_webgl(self.gl_type, SHADER_OUTPUT_FORMAT, - &BuiltInResources::default()).unwrap(); + ¶ms).unwrap(); match validator.compile_and_translate(&[source]) { Ok(translated_source) => { debug!("Shader translated: {}", translated_source); diff --git a/components/script/dom/webidls/WebGLRenderingContext.webidl b/components/script/dom/webidls/WebGLRenderingContext.webidl index ef0be0f9465..0d4c14a05df 100644 --- a/components/script/dom/webidls/WebGLRenderingContext.webidl +++ b/components/script/dom/webidls/WebGLRenderingContext.webidl @@ -595,7 +595,7 @@ interface WebGLRenderingContextBase DOMString? getProgramInfoLog(WebGLProgram? program); //any getRenderbufferParameter(GLenum target, GLenum pname); any getShaderParameter(WebGLShader? shader, GLenum pname); - //WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype); + WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype); DOMString? getShaderInfoLog(WebGLShader? shader); DOMString? getShaderSource(WebGLShader? shader); diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini index 9623b70fe74..42c964913f8 100644 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini +++ b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini @@ -1,285 +1,6 @@ [methods.html] type: testharness - [WebGL test #1: Property either does not exist or is not a function: copyTexImage2D] - expected: FAIL - - [WebGL test #2: Property either does not exist or is not a function: copyTexSubImage2D] - expected: FAIL - - [WebGL test #3: Property either does not exist or is not a function: detachShader] - expected: FAIL - - [WebGL test #4: Property either does not exist or is not a function: disableVertexAttribArray] - expected: FAIL - - [WebGL test #5: Property either does not exist or is not a function: finish] - expected: FAIL - - [WebGL test #6: Property either does not exist or is not a function: flush] - expected: FAIL - - [WebGL test #9: Property either does not exist or is not a function: generateMipmap] - expected: FAIL - - [WebGL test #10: Property either does not exist or is not a function: getActiveAttrib] - expected: FAIL - - [WebGL test #11: Property either does not exist or is not a function: getActiveUniform] - expected: FAIL - - [WebGL test #12: Property either does not exist or is not a function: getAttachedShaders] - expected: FAIL - - [WebGL test #13: Property either does not exist or is not a function: getFramebufferAttachmentParameter] - expected: FAIL - - [WebGL test #14: Property either does not exist or is not a function: getProgramInfoLog] - expected: FAIL - - [WebGL test #15: Property either does not exist or is not a function: getRenderbufferParameter] - expected: FAIL - - [WebGL test #16: Property either does not exist or is not a function: getShaderPrecisionFormat] - expected: FAIL - - [WebGL test #17: Property either does not exist or is not a function: getTexParameter] - expected: FAIL - - [WebGL test #18: Property either does not exist or is not a function: getUniform] - expected: FAIL - - [WebGL test #19: Property either does not exist or is not a function: getVertexAttrib] - expected: FAIL - - [WebGL test #20: Property either does not exist or is not a function: getVertexAttribOffset] - expected: FAIL - - [WebGL test #21: Property either does not exist or is not a function: isBuffer] - expected: FAIL - - [WebGL test #22: Property either does not exist or is not a function: isContextLost] - expected: FAIL - - [WebGL test #24: Property either does not exist or is not a function: isFramebuffer] - expected: FAIL - - [WebGL test #25: Property either does not exist or is not a function: isProgram] - expected: FAIL - - [WebGL test #26: Property either does not exist or is not a function: isRenderbuffer] - expected: FAIL - - [WebGL test #27: Property either does not exist or is not a function: isShader] - expected: FAIL - - [WebGL test #28: Property either does not exist or is not a function: isTexture] - expected: FAIL - - [WebGL test #29: Property either does not exist or is not a function: readPixels] - expected: FAIL - - [WebGL test #31: Property either does not exist or is not a function: sampleCoverage] - expected: FAIL - - [WebGL test #32: Property either does not exist or is not a function: stencilFunc] - expected: FAIL - - [WebGL test #33: Property either does not exist or is not a function: stencilFuncSeparate] - expected: FAIL - - [WebGL test #34: Property either does not exist or is not a function: stencilMask] - expected: FAIL - - [WebGL test #35: Property either does not exist or is not a function: stencilMaskSeparate] - expected: FAIL - - [WebGL test #36: Property either does not exist or is not a function: stencilOp] - expected: FAIL - - [WebGL test #37: Property either does not exist or is not a function: stencilOpSeparate] - expected: FAIL - - [WebGL test #38: Property either does not exist or is not a function: texSubImage2D] - expected: FAIL - - [WebGL test #39: Property either does not exist or is not a function: uniform1i] - expected: FAIL - - [WebGL test #40: Property either does not exist or is not a function: uniform1iv] - expected: FAIL - - [WebGL test #41: Property either does not exist or is not a function: uniform2f] - expected: FAIL - - [WebGL test #42: Property either does not exist or is not a function: uniform2fv] - expected: FAIL - - [WebGL test #43: Property either does not exist or is not a function: uniform2i] - expected: FAIL - - [WebGL test #44: Property either does not exist or is not a function: uniform2iv] - expected: FAIL - - [WebGL test #45: Property either does not exist or is not a function: uniform3f] - expected: FAIL - - [WebGL test #46: Property either does not exist or is not a function: uniform3fv] - expected: FAIL - - [WebGL test #47: Property either does not exist or is not a function: uniform3i] - expected: FAIL - - [WebGL test #48: Property either does not exist or is not a function: uniform3iv] - expected: FAIL - - [WebGL test #49: Property either does not exist or is not a function: uniform4i] - expected: FAIL - - [WebGL test #50: Property either does not exist or is not a function: uniform4iv] - expected: FAIL - - [WebGL test #51: Property either does not exist or is not a function: uniformMatrix2fv] - expected: FAIL - - [WebGL test #52: Property either does not exist or is not a function: uniformMatrix3fv] - expected: FAIL - - [WebGL test #53: Property either does not exist or is not a function: uniformMatrix4fv] - expected: FAIL - - [WebGL test #54: Property either does not exist or is not a function: validateProgram] - expected: FAIL - - [WebGL test #3: Property either does not exist or is not a function: disableVertexAttribArray] - expected: FAIL - - [WebGL test #6: Property either does not exist or is not a function: getActiveAttrib] - expected: FAIL - - [WebGL test #7: Property either does not exist or is not a function: getActiveUniform] - expected: FAIL - - [WebGL test #8: Property either does not exist or is not a function: getAttachedShaders] - expected: FAIL - - [WebGL test #9: Property either does not exist or is not a function: getFramebufferAttachmentParameter] - expected: FAIL - - [WebGL test #10: Property either does not exist or is not a function: getProgramInfoLog] - expected: FAIL - - [WebGL test #11: Property either does not exist or is not a function: getRenderbufferParameter] - expected: FAIL - - [WebGL test #12: Property either does not exist or is not a function: getShaderPrecisionFormat] - expected: FAIL - - [WebGL test #13: Property either does not exist or is not a function: getTexParameter] - expected: FAIL - - [WebGL test #14: Property either does not exist or is not a function: getUniform] - expected: FAIL - - [WebGL test #15: Property either does not exist or is not a function: getVertexAttrib] - expected: FAIL - - [WebGL test #16: Property either does not exist or is not a function: getVertexAttribOffset] - expected: FAIL - - [WebGL test #17: Property either does not exist or is not a function: isBuffer] - expected: FAIL - - [WebGL test #18: Property either does not exist or is not a function: isContextLost] - expected: FAIL - - [WebGL test #20: Property either does not exist or is not a function: isFramebuffer] - expected: FAIL - - [WebGL test #21: Property either does not exist or is not a function: isProgram] - expected: FAIL - - [WebGL test #22: Property either does not exist or is not a function: isRenderbuffer] - expected: FAIL - - [WebGL test #23: Property either does not exist or is not a function: isShader] - expected: FAIL - - [WebGL test #24: Property either does not exist or is not a function: isTexture] - expected: FAIL - - [WebGL test #25: Property either does not exist or is not a function: readPixels] - expected: FAIL - - [WebGL test #27: Property either does not exist or is not a function: sampleCoverage] - expected: FAIL - - [WebGL test #28: Property either does not exist or is not a function: stencilFunc] - expected: FAIL - - [WebGL test #29: Property either does not exist or is not a function: stencilFuncSeparate] - expected: FAIL - - [WebGL test #30: Property either does not exist or is not a function: stencilMask] - expected: FAIL - - [WebGL test #31: Property either does not exist or is not a function: stencilMaskSeparate] - expected: FAIL - - [WebGL test #32: Property either does not exist or is not a function: stencilOp] - expected: FAIL - - [WebGL test #33: Property either does not exist or is not a function: stencilOpSeparate] - expected: FAIL - - [WebGL test #34: Property either does not exist or is not a function: texSubImage2D] - expected: FAIL - - [WebGL test #35: Property either does not exist or is not a function: uniform1iv] - expected: FAIL - - [WebGL test #36: Property either does not exist or is not a function: uniform2f] - expected: FAIL - - [WebGL test #37: Property either does not exist or is not a function: uniform2fv] - expected: FAIL - - [WebGL test #38: Property either does not exist or is not a function: uniform2i] - expected: FAIL - - [WebGL test #39: Property either does not exist or is not a function: uniform2iv] - expected: FAIL - - [WebGL test #40: Property either does not exist or is not a function: uniform3f] - expected: FAIL - - [WebGL test #41: Property either does not exist or is not a function: uniform3fv] - expected: FAIL - - [WebGL test #42: Property either does not exist or is not a function: uniform3i] - expected: FAIL - - [WebGL test #43: Property either does not exist or is not a function: uniform3iv] - expected: FAIL - - [WebGL test #44: Property either does not exist or is not a function: uniform4i] - expected: FAIL - - [WebGL test #45: Property either does not exist or is not a function: uniform4iv] - expected: FAIL - - [WebGL test #46: Property either does not exist or is not a function: uniformMatrix2fv] - expected: FAIL - - [WebGL test #47: Property either does not exist or is not a function: uniformMatrix3fv] - expected: FAIL - - [WebGL test #48: Property either does not exist or is not a function: uniformMatrix4fv] - expected: FAIL - - [WebGL test #49: Property either does not exist or is not a function: validateProgram] - expected: FAIL - - [WebGL test #0: Property either does not exist or is not a function: getAttachedShaders] + [WebGL test #0: Property either does not exist or is not a function: getAttachedShaders] expected: FAIL [WebGL test #1: Property either does not exist or is not a function: getFramebufferAttachmentParameter] @@ -288,18 +9,15 @@ [WebGL test #2: Property either does not exist or is not a function: getRenderbufferParameter] expected: FAIL - [WebGL test #3: Property either does not exist or is not a function: getShaderPrecisionFormat] + [WebGL test #3: Property either does not exist or is not a function: getTexParameter] expected: FAIL - [WebGL test #4: Property either does not exist or is not a function: getTexParameter] + [WebGL test #4: Property either does not exist or is not a function: getUniform] expected: FAIL - [WebGL test #5: Property either does not exist or is not a function: getUniform] + [WebGL test #5: Property either does not exist or is not a function: getVertexAttribOffset] expected: FAIL - [WebGL test #6: Property either does not exist or is not a function: getVertexAttribOffset] - expected: FAIL - - [WebGL test #7: Property either does not exist or is not a function: isContextLost] + [WebGL test #6: Property either does not exist or is not a function: isContextLost] expected: FAIL diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/bugs/constant-precision-qualifier.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/bugs/constant-precision-qualifier.html.ini deleted file mode 100644 index 95ec36b9832..00000000000 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/bugs/constant-precision-qualifier.html.ini +++ /dev/null @@ -1,6 +0,0 @@ -[constant-precision-qualifier.html] - type: testharness - expected: ERROR - [Overall test] - expected: NOTRUN - diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/misc/shader-precision-format-obeyed.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/misc/shader-precision-format-obeyed.html.ini deleted file mode 100644 index 8bd3dff859e..00000000000 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/glsl/misc/shader-precision-format-obeyed.html.ini +++ /dev/null @@ -1,6 +0,0 @@ -[shader-precision-format-obeyed.html] - type: testharness - expected: ERROR - [Overall test] - expected: NOTRUN - diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/shader-precision-format.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/shader-precision-format.html.ini deleted file mode 100644 index 7ebc47ba3e6..00000000000 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/shader-precision-format.html.ini +++ /dev/null @@ -1,45 +0,0 @@ -[shader-precision-format.html] - type: testharness - expected: ERROR - [WebGL test #0: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #1: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #2: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #3: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #4: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #5: gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #6: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #7: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #8: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #9: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #10: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #11: gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT) instanceof WebGLShaderPrecisionFormat should be true. Threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [WebGL test #12: gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER) threw exception TypeError: gl.getShaderPrecisionFormat is not a function] - expected: FAIL - - [Overall test] - expected: NOTRUN -