mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Invalidate all WebGLUniformLocation values on program relink
This commit is contained in:
parent
8fabc6660a
commit
b64232d77b
4 changed files with 36 additions and 15 deletions
|
@ -28,6 +28,7 @@ pub struct WebGLProgram {
|
|||
is_deleted: Cell<bool>,
|
||||
link_called: Cell<bool>,
|
||||
linked: Cell<bool>,
|
||||
link_generation: Cell<u64>,
|
||||
fragment_shader: MutNullableDom<WebGLShader>,
|
||||
vertex_shader: MutNullableDom<WebGLShader>,
|
||||
#[ignore_malloc_size_of = "Defined in ipc-channel"]
|
||||
|
@ -37,15 +38,14 @@ pub struct WebGLProgram {
|
|||
}
|
||||
|
||||
impl WebGLProgram {
|
||||
fn new_inherited(renderer: WebGLMsgSender,
|
||||
id: WebGLProgramId)
|
||||
-> WebGLProgram {
|
||||
WebGLProgram {
|
||||
fn new_inherited(renderer: WebGLMsgSender, id: WebGLProgramId) -> Self {
|
||||
Self {
|
||||
webgl_object: WebGLObject::new_inherited(),
|
||||
id: id,
|
||||
is_deleted: Cell::new(false),
|
||||
link_called: Cell::new(false),
|
||||
linked: Cell::new(false),
|
||||
link_generation: Default::default(),
|
||||
fragment_shader: Default::default(),
|
||||
vertex_shader: Default::default(),
|
||||
renderer: renderer,
|
||||
|
@ -109,6 +109,7 @@ impl WebGLProgram {
|
|||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
self.linked.set(false);
|
||||
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([]);
|
||||
|
||||
|
@ -355,7 +356,14 @@ impl WebGLProgram {
|
|||
.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
|
||||
|
@ -389,6 +397,10 @@ impl WebGLProgram {
|
|||
(None, None) => vec![]
|
||||
})
|
||||
}
|
||||
|
||||
pub fn link_generation(&self) -> u64 {
|
||||
self.link_generation.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLProgram {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue