mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Fix gl.getShaderSource and gl.getShaderInfoLog
It only returns null if there was an error, and the only error isn't implemented yet.
This commit is contained in:
parent
0e93f06d8d
commit
6996d1ce36
3 changed files with 13 additions and 29 deletions
|
@ -2527,7 +2527,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn GetShaderInfoLog(&self, shader: &WebGLShader) -> Option<DOMString> {
|
fn GetShaderInfoLog(&self, shader: &WebGLShader) -> Option<DOMString> {
|
||||||
shader.info_log().map(DOMString::from)
|
// TODO(nox): https://github.com/servo/servo/issues/21133
|
||||||
|
Some(shader.info_log())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -2973,7 +2974,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn GetShaderSource(&self, shader: &WebGLShader) -> Option<DOMString> {
|
fn GetShaderSource(&self, shader: &WebGLShader) -> Option<DOMString> {
|
||||||
shader.source()
|
// TODO(nox): https://github.com/servo/servo/issues/21133
|
||||||
|
Some(shader.source())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
|
|
|
@ -35,8 +35,8 @@ pub struct WebGLShader {
|
||||||
webgl_object: WebGLObject,
|
webgl_object: WebGLObject,
|
||||||
id: WebGLShaderId,
|
id: WebGLShaderId,
|
||||||
gl_type: u32,
|
gl_type: u32,
|
||||||
source: DomRefCell<Option<DOMString>>,
|
source: DomRefCell<DOMString>,
|
||||||
info_log: DomRefCell<Option<String>>,
|
info_log: DomRefCell<DOMString>,
|
||||||
is_deleted: Cell<bool>,
|
is_deleted: Cell<bool>,
|
||||||
attached_counter: Cell<u32>,
|
attached_counter: Cell<u32>,
|
||||||
compilation_status: Cell<ShaderCompilationStatus>,
|
compilation_status: Cell<ShaderCompilationStatus>,
|
||||||
|
@ -56,8 +56,8 @@ impl WebGLShader {
|
||||||
webgl_object: WebGLObject::new_inherited(),
|
webgl_object: WebGLObject::new_inherited(),
|
||||||
id: id,
|
id: id,
|
||||||
gl_type: shader_type,
|
gl_type: shader_type,
|
||||||
source: DomRefCell::new(None),
|
source: Default::default(),
|
||||||
info_log: DomRefCell::new(None),
|
info_log: Default::default(),
|
||||||
is_deleted: Cell::new(false),
|
is_deleted: Cell::new(false),
|
||||||
attached_counter: Cell::new(0),
|
attached_counter: Cell::new(0),
|
||||||
compilation_status: Cell::new(ShaderCompilationStatus::NotCompiled),
|
compilation_status: Cell::new(ShaderCompilationStatus::NotCompiled),
|
||||||
|
@ -113,10 +113,6 @@ impl WebGLShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
let source = self.source.borrow();
|
let source = self.source.borrow();
|
||||||
let source = match source.as_ref() {
|
|
||||||
Some(source) => source,
|
|
||||||
None => return Ok(()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let params = BuiltInResources {
|
let params = BuiltInResources {
|
||||||
MaxVertexAttribs: limits.max_vertex_attribs as c_int,
|
MaxVertexAttribs: limits.max_vertex_attribs as c_int,
|
||||||
|
@ -166,7 +162,7 @@ impl WebGLShader {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
match validator.compile_and_translate(&[source]) {
|
match validator.compile_and_translate(&[&source]) {
|
||||||
Ok(translated_source) => {
|
Ok(translated_source) => {
|
||||||
debug!("Shader translated: {}", translated_source);
|
debug!("Shader translated: {}", translated_source);
|
||||||
// NOTE: At this point we should be pretty sure that the compilation in the paint thread
|
// NOTE: At this point we should be pretty sure that the compilation in the paint thread
|
||||||
|
@ -182,7 +178,7 @@ impl WebGLShader {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.info_log.borrow_mut() = Some(validator.info_log());
|
*self.info_log.borrow_mut() = validator.info_log().into();
|
||||||
|
|
||||||
// TODO(emilio): More data (like uniform data) should be collected
|
// TODO(emilio): More data (like uniform data) should be collected
|
||||||
// here to properly validate uniforms.
|
// here to properly validate uniforms.
|
||||||
|
@ -220,18 +216,18 @@ impl WebGLShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// glGetShaderInfoLog
|
/// glGetShaderInfoLog
|
||||||
pub fn info_log(&self) -> Option<String> {
|
pub fn info_log(&self) -> DOMString {
|
||||||
self.info_log.borrow().clone()
|
self.info_log.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the shader source
|
/// Get the shader source
|
||||||
pub fn source(&self) -> Option<DOMString> {
|
pub fn source(&self) -> DOMString {
|
||||||
self.source.borrow().clone()
|
self.source.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// glShaderSource
|
/// glShaderSource
|
||||||
pub fn set_source(&self, source: DOMString) {
|
pub fn set_source(&self, source: DOMString) {
|
||||||
*self.source.borrow_mut() = Some(source);
|
*self.source.borrow_mut() = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn successfully_compiled(&self) -> bool {
|
pub fn successfully_compiled(&self) -> bool {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
[functions-returning-strings.html]
|
|
||||||
type: testharness
|
|
||||||
[WebGL test #0: gl.getShaderSource(vs) should return a string. Returns: "null"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #1: gl.getShaderInfoLog(vs) should return a string. Returns: "null"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #4: gl.getShaderSource(fs) should return a string. Returns: "null"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #5: gl.getShaderInfoLog(fs) should return a string. Returns: "null"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue