mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make gl.useProgram(null) do the right thing
This commit is contained in:
parent
fc593c68c5
commit
15389586d9
5 changed files with 9 additions and 23 deletions
|
@ -826,8 +826,6 @@ impl WebGLImpl {
|
|||
ctx.gl().uniform_matrix_3fv(uniform_id, transpose, v),
|
||||
WebGLCommand::UniformMatrix4fv(uniform_id, transpose, ref v) =>
|
||||
ctx.gl().uniform_matrix_4fv(uniform_id, transpose, v),
|
||||
WebGLCommand::UseProgram(program_id) =>
|
||||
ctx.gl().use_program(program_id.get()),
|
||||
WebGLCommand::ValidateProgram(program_id) =>
|
||||
ctx.gl().validate_program(program_id.get()),
|
||||
WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) =>
|
||||
|
@ -965,6 +963,9 @@ impl WebGLImpl {
|
|||
WebGLCommand::LinkProgram(program_id, ref sender) => {
|
||||
return sender.send(Self::link_program(ctx.gl(), program_id)).unwrap();
|
||||
}
|
||||
WebGLCommand::UseProgram(program_id) => {
|
||||
ctx.gl().use_program(program_id.map_or(0, |p| p.get()))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: update test expectations in order to enable debug assertions
|
||||
|
|
|
@ -249,7 +249,7 @@ pub enum WebGLCommand {
|
|||
UniformMatrix2fv(i32, bool, Vec<f32>),
|
||||
UniformMatrix3fv(i32, bool, Vec<f32>),
|
||||
UniformMatrix4fv(i32, bool, Vec<f32>),
|
||||
UseProgram(WebGLProgramId),
|
||||
UseProgram(Option<WebGLProgramId>),
|
||||
ValidateProgram(WebGLProgramId),
|
||||
VertexAttrib(u32, f32, f32, f32, f32),
|
||||
VertexAttribPointer(u32, i32, u32, bool, i32, u32),
|
||||
|
|
|
@ -130,19 +130,6 @@ impl WebGLProgram {
|
|||
Ref::map(self.active_attribs.borrow(), |attribs| &**attribs)
|
||||
}
|
||||
|
||||
/// glUseProgram
|
||||
pub fn use_program(&self) -> WebGLResult<()> {
|
||||
if self.is_deleted() {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
if !self.linked.get() {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
|
||||
self.renderer.send(WebGLCommand::UseProgram(self.id)).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// glValidateProgram
|
||||
pub fn validate(&self) -> WebGLResult<()> {
|
||||
if self.is_deleted() {
|
||||
|
|
|
@ -2314,7 +2314,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||
fn GetActiveAttrib(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
|
||||
handle_potential_webgl_error!(self, program.get_active_attrib(index), None)
|
||||
handle_potential_webgl_error!(self, program.get_active_attrib(index).map(Some), None)
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||
|
@ -3242,11 +3242,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn UseProgram(&self, program: Option<&WebGLProgram>) {
|
||||
if let Some(program) = program {
|
||||
match program.use_program() {
|
||||
Ok(()) => self.current_program.set(Some(program)),
|
||||
Err(e) => self.webgl_error(e),
|
||||
if program.is_deleted() || !program.is_linked() {
|
||||
return self.webgl_error(InvalidOperation);
|
||||
}
|
||||
}
|
||||
self.send_command(WebGLCommand::UseProgram(program.map(|p| p.id())));
|
||||
self.current_program.set(program);
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
[program-test.html]
|
||||
[WebGL test #53: getError expected: INVALID_OPERATION. Was NO_ERROR : drawing with a null program should generate INVALID_OPERATION]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #64: getError expected: NO_ERROR. Was INVALID_OPERATION : delete the current program shouldn't change the current rendering state]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue