mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #21207 - servo:webgl, r=emilio
Some WebGL drive-by fixes <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21207) <!-- Reviewable:end -->
This commit is contained in:
commit
48db1ed65e
4 changed files with 38 additions and 16 deletions
|
@ -28,6 +28,7 @@ pub struct WebGLProgram {
|
||||||
is_deleted: Cell<bool>,
|
is_deleted: Cell<bool>,
|
||||||
link_called: Cell<bool>,
|
link_called: Cell<bool>,
|
||||||
linked: Cell<bool>,
|
linked: Cell<bool>,
|
||||||
|
link_generation: Cell<u64>,
|
||||||
fragment_shader: MutNullableDom<WebGLShader>,
|
fragment_shader: MutNullableDom<WebGLShader>,
|
||||||
vertex_shader: MutNullableDom<WebGLShader>,
|
vertex_shader: MutNullableDom<WebGLShader>,
|
||||||
#[ignore_malloc_size_of = "Defined in ipc-channel"]
|
#[ignore_malloc_size_of = "Defined in ipc-channel"]
|
||||||
|
@ -37,15 +38,14 @@ pub struct WebGLProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebGLProgram {
|
impl WebGLProgram {
|
||||||
fn new_inherited(renderer: WebGLMsgSender,
|
fn new_inherited(renderer: WebGLMsgSender, id: WebGLProgramId) -> Self {
|
||||||
id: WebGLProgramId)
|
Self {
|
||||||
-> WebGLProgram {
|
|
||||||
WebGLProgram {
|
|
||||||
webgl_object: WebGLObject::new_inherited(),
|
webgl_object: WebGLObject::new_inherited(),
|
||||||
id: id,
|
id: id,
|
||||||
is_deleted: Cell::new(false),
|
is_deleted: Cell::new(false),
|
||||||
link_called: Cell::new(false),
|
link_called: Cell::new(false),
|
||||||
linked: Cell::new(false),
|
linked: Cell::new(false),
|
||||||
|
link_generation: Default::default(),
|
||||||
fragment_shader: Default::default(),
|
fragment_shader: Default::default(),
|
||||||
vertex_shader: Default::default(),
|
vertex_shader: Default::default(),
|
||||||
renderer: renderer,
|
renderer: renderer,
|
||||||
|
@ -109,7 +109,9 @@ impl WebGLProgram {
|
||||||
return Err(WebGLError::InvalidOperation);
|
return Err(WebGLError::InvalidOperation);
|
||||||
}
|
}
|
||||||
self.linked.set(false);
|
self.linked.set(false);
|
||||||
*self.active_attribs.borrow_mut() = vec![].into();
|
self.link_generation.set(self.link_generation.get().checked_add(1).unwrap());
|
||||||
|
*self.active_attribs.borrow_mut() = Box::new([]);
|
||||||
|
*self.active_uniforms.borrow_mut() = Box::new([]);
|
||||||
|
|
||||||
match self.fragment_shader.get() {
|
match self.fragment_shader.get() {
|
||||||
Some(ref shader) if shader.successfully_compiled() => {},
|
Some(ref shader) if shader.successfully_compiled() => {},
|
||||||
|
@ -354,7 +356,14 @@ impl WebGLProgram {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let location = receiver.recv().unwrap();
|
let location = receiver.recv().unwrap();
|
||||||
|
|
||||||
Ok(Some(WebGLUniformLocation::new(self.global().as_window(), location, self.id, size, type_)))
|
Ok(Some(WebGLUniformLocation::new(
|
||||||
|
self.global().as_window(),
|
||||||
|
location,
|
||||||
|
self.id,
|
||||||
|
self.link_generation.get(),
|
||||||
|
size,
|
||||||
|
type_,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// glGetProgramInfoLog
|
/// glGetProgramInfoLog
|
||||||
|
@ -388,6 +397,10 @@ impl WebGLProgram {
|
||||||
(None, None) => vec![]
|
(None, None) => vec![]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn link_generation(&self) -> u64 {
|
||||||
|
self.link_generation.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for WebGLProgram {
|
impl Drop for WebGLProgram {
|
||||||
|
|
|
@ -436,7 +436,10 @@ impl WebGLRenderingContext {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
match self.current_program.get() {
|
match self.current_program.get() {
|
||||||
Some(ref program) if program.id() == location.program_id() => {}
|
Some(ref program) if
|
||||||
|
program.id() == location.program_id() &&
|
||||||
|
program.link_generation() == location.link_generation()
|
||||||
|
=> {}
|
||||||
_ => return self.webgl_error(InvalidOperation),
|
_ => return self.webgl_error(InvalidOperation),
|
||||||
}
|
}
|
||||||
handle_potential_webgl_error!(self, f(location));
|
handle_potential_webgl_error!(self, f(location));
|
||||||
|
@ -3612,7 +3615,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
) -> JSVal {
|
) -> JSVal {
|
||||||
// FIXME(nox): https://github.com/servo/servo/issues/21133
|
// FIXME(nox): https://github.com/servo/servo/issues/21133
|
||||||
|
|
||||||
if program.is_deleted() || !program.is_linked() || program.id() != location.program_id() {
|
if
|
||||||
|
program.is_deleted() ||
|
||||||
|
!program.is_linked() ||
|
||||||
|
program.id() != location.program_id() ||
|
||||||
|
program.link_generation() != location.link_generation()
|
||||||
|
{
|
||||||
self.webgl_error(InvalidOperation);
|
self.webgl_error(InvalidOperation);
|
||||||
return NullValue();
|
return NullValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub struct WebGLUniformLocation {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
id: i32,
|
id: i32,
|
||||||
program_id: WebGLProgramId,
|
program_id: WebGLProgramId,
|
||||||
|
link_generation: u64,
|
||||||
size: Option<i32>,
|
size: Option<i32>,
|
||||||
type_: u32,
|
type_: u32,
|
||||||
}
|
}
|
||||||
|
@ -23,6 +24,7 @@ impl WebGLUniformLocation {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
id: i32,
|
id: i32,
|
||||||
program_id: WebGLProgramId,
|
program_id: WebGLProgramId,
|
||||||
|
link_generation: u64,
|
||||||
size: Option<i32>,
|
size: Option<i32>,
|
||||||
type_: u32,
|
type_: u32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -30,6 +32,7 @@ impl WebGLUniformLocation {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
id,
|
id,
|
||||||
program_id,
|
program_id,
|
||||||
|
link_generation,
|
||||||
size,
|
size,
|
||||||
type_,
|
type_,
|
||||||
}
|
}
|
||||||
|
@ -39,11 +42,12 @@ impl WebGLUniformLocation {
|
||||||
window: &Window,
|
window: &Window,
|
||||||
id: i32,
|
id: i32,
|
||||||
program_id: WebGLProgramId,
|
program_id: WebGLProgramId,
|
||||||
|
link_generation: u64,
|
||||||
size: Option<i32>,
|
size: Option<i32>,
|
||||||
type_: u32,
|
type_: u32,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(Self::new_inherited(id, program_id, size, type_)),
|
Box::new(Self::new_inherited(id, program_id, link_generation, size, type_)),
|
||||||
window,
|
window,
|
||||||
WebGLUniformLocationBinding::Wrap,
|
WebGLUniformLocationBinding::Wrap,
|
||||||
)
|
)
|
||||||
|
@ -57,6 +61,10 @@ impl WebGLUniformLocation {
|
||||||
self.program_id
|
self.program_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn link_generation(&self) -> u64 {
|
||||||
|
self.link_generation
|
||||||
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> Option<i32> {
|
pub fn size(&self) -> Option<i32> {
|
||||||
self.size
|
self.size
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[uniform-location.html]
|
|
||||||
[WebGL test #20: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: contextA.uniform1i(locationSx, 3)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #21: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: contextA.getUniform(programS, locationSx)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue