Skip to content

Commit

Permalink
Fix highp precision in shaders & Implement WebGL::GetShaderPrecisionF…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
MortimerGoro committed Apr 21, 2017
1 parent 7f825d2 commit 6b0c898
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 346 deletions.
22 changes: 22 additions & 0 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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>,
Expand Down
4 changes: 3 additions & 1 deletion components/script/dom/webglshader.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/WebGLRenderingContext.webidl
Expand Up @@ -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);
Expand Down
@@ -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]
Expand All @@ -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]
expected: FAIL

[WebGL test #4: Property either does not exist or is not a function: getTexParameter]
[WebGL test #3: Property either does not exist or is not a function: getTexParameter]
expected: FAIL

[WebGL test #5: Property either does not exist or is not a function: getUniform]
[WebGL test #4: Property either does not exist or is not a function: getUniform]
expected: FAIL

[WebGL test #6: Property either does not exist or is not a function: getVertexAttribOffset]
[WebGL test #5: 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

This file was deleted.

This file was deleted.

0 comments on commit 6b0c898

Please sign in to comment.