mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
webgl: Improve debugging
Now we can keep track of errors more easily.
This commit is contained in:
parent
5c23c3851a
commit
48962bd6b6
2 changed files with 83 additions and 2 deletions
|
@ -46,6 +46,8 @@ impl WebGLPaintThread {
|
|||
/// NB: Not gl-related validations (names, lengths, accepted parameters...) are
|
||||
/// done in the corresponding DOM interfaces
|
||||
pub fn handle_webgl_message(&self, message: CanvasWebGLMsg) {
|
||||
debug!("WebGL message: {:?}", message);
|
||||
|
||||
match message {
|
||||
CanvasWebGLMsg::GetContextAttributes(sender) =>
|
||||
self.context_attributes(sender),
|
||||
|
@ -181,8 +183,9 @@ impl WebGLPaintThread {
|
|||
self.send_drawing_buffer_height(sender),
|
||||
}
|
||||
|
||||
// FIXME: Convert to `debug_assert!` once tests are run with debug assertions
|
||||
assert!(gl::get_error() == gl::NO_ERROR);
|
||||
// FIXME: Use debug_assertions once tests are run with them
|
||||
let error = gl::get_error();
|
||||
assert!(error == gl::NO_ERROR, "Unexpected WebGL error: 0x{:x} ({})", error, error);
|
||||
}
|
||||
|
||||
/// Creates a new `WebGLPaintThread` and returns the out-of-process sender and the in-process
|
||||
|
@ -299,6 +302,7 @@ impl WebGLPaintThread {
|
|||
} else {
|
||||
Some(unsafe { NonZero::new(program) })
|
||||
};
|
||||
|
||||
chan.send(program).unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ use layers::platform::surface::NativeSurface;
|
|||
use offscreen_gl_context::GLContextAttributes;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::sync::mpsc::Sender;
|
||||
use util::mem::HeapSizeOf;
|
||||
|
@ -193,6 +194,82 @@ pub enum CanvasWebGLMsg {
|
|||
DrawingBufferHeight(IpcSender<i32>),
|
||||
}
|
||||
|
||||
impl fmt::Debug for CanvasWebGLMsg {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use CanvasWebGLMsg::*;
|
||||
let name = match *self {
|
||||
GetContextAttributes(..) => "GetContextAttributes",
|
||||
ActiveTexture(..) => "ActiveTexture",
|
||||
BlendColor(..) => "BlendColor",
|
||||
BlendEquation(..) => "BlendEquation",
|
||||
BlendEquationSeparate(..) => "BlendEquationSeparate",
|
||||
BlendFunc(..) => "BlendFunc",
|
||||
BlendFuncSeparate(..) => "BlendFuncSeparate",
|
||||
AttachShader(..) => "AttachShader",
|
||||
BindAttribLocation(..) => "BindAttribLocation",
|
||||
BufferData(..) => "BufferData",
|
||||
BufferSubData(..) => "BufferSubData",
|
||||
Clear(..) => "Clear",
|
||||
ClearColor(..) => "ClearColor",
|
||||
ClearDepth(..) => "ClearDepth",
|
||||
ClearStencil(..) => "ClearStencil",
|
||||
ColorMask(..) => "ColorMask",
|
||||
CullFace(..) => "CullFace",
|
||||
FrontFace(..) => "FrontFace",
|
||||
DepthFunc(..) => "DepthFunc",
|
||||
DepthMask(..) => "DepthMask",
|
||||
DepthRange(..) => "DepthRange",
|
||||
Enable(..) => "Enable",
|
||||
Disable(..) => "Disable",
|
||||
CompileShader(..) => "CompileShader",
|
||||
CreateBuffer(..) => "CreateBuffer",
|
||||
CreateFramebuffer(..) => "CreateFramebuffer",
|
||||
CreateRenderbuffer(..) => "CreateRenderbuffer",
|
||||
CreateTexture(..) => "CreateTexture",
|
||||
CreateProgram(..) => "CreateProgram",
|
||||
CreateShader(..) => "CreateShader",
|
||||
DeleteBuffer(..) => "DeleteBuffer",
|
||||
DeleteFramebuffer(..) => "DeleteFramebuffer",
|
||||
DeleteRenderbuffer(..) => "DeleteRenderBuffer",
|
||||
DeleteTexture(..) => "DeleteTexture",
|
||||
DeleteProgram(..) => "DeleteProgram",
|
||||
DeleteShader(..) => "DeleteShader",
|
||||
BindBuffer(..) => "BindBuffer",
|
||||
BindFramebuffer(..) => "BindFramebuffer",
|
||||
BindRenderbuffer(..) => "BindRenderbuffer",
|
||||
BindTexture(..) => "BindTexture",
|
||||
DrawArrays(..) => "DrawArrays",
|
||||
DrawElements(..) => "DrawElements",
|
||||
EnableVertexAttribArray(..) => "EnableVertexAttribArray",
|
||||
GetBufferParameter(..) => "GetBufferParameter",
|
||||
GetParameter(..) => "GetParameter",
|
||||
GetProgramParameter(..) => "GetProgramParameter",
|
||||
GetShaderParameter(..) => "GetShaderParameter",
|
||||
GetAttribLocation(..) => "GetAttribLocation",
|
||||
GetUniformLocation(..) => "GetUniformLocation",
|
||||
PolygonOffset(..) => "PolygonOffset",
|
||||
Scissor(..) => "Scissor",
|
||||
Hint(..) => "Hint",
|
||||
LineWidth(..) => "LineWidth",
|
||||
PixelStorei(..) => "PixelStorei",
|
||||
LinkProgram(..) => "LinkProgram",
|
||||
Uniform4f(..) => "Uniform4f",
|
||||
Uniform1f(..) => "Uniform1f",
|
||||
UseProgram(..) => "UseProgram",
|
||||
VertexAttrib(..) => "VertexAttrib",
|
||||
VertexAttribPointer2f(..) => "VertexAttribPointer2f",
|
||||
Viewport(..) => "Viewport",
|
||||
TexImage2D(..) => "TexImage2D",
|
||||
TexParameteri(..) => "TexParameteri",
|
||||
TexParameterf(..) => "TexParameterf",
|
||||
DrawingBufferWidth(..) => "DrawingBufferWidth",
|
||||
DrawingBufferHeight(..) => "DrawingBufferHeight",
|
||||
};
|
||||
|
||||
write!(f, "CanvasWebGLMsg::{}(..)", name)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Deserialize, Serialize, HeapSizeOf)]
|
||||
pub enum WebGLError {
|
||||
InvalidEnum,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue