Fix highp precision in shaders & Implement WebGL::GetShaderPrecisionFormat

This commit is contained in:
Imanol Fernandez 2017-04-20 14:55:43 +02:00
parent 7f825d2119
commit 6b0c898e1a
7 changed files with 31 additions and 346 deletions

View file

@ -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<Root<WebGLShaderPrecisionFormat>> {
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>,

View file

@ -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();
&params).unwrap();
match validator.compile_and_translate(&[source]) {
Ok(translated_source) => {
debug!("Shader translated: {}", translated_source);

View file

@ -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);

View file

@ -1,284 +1,5 @@
[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]
expected: FAIL
@ -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

View file

@ -1,6 +0,0 @@
[constant-precision-qualifier.html]
type: testharness
expected: ERROR
[Overall test]
expected: NOTRUN

View file

@ -1,6 +0,0 @@
[shader-precision-format-obeyed.html]
type: testharness
expected: ERROR
[Overall test]
expected: NOTRUN

View file

@ -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