aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/webglprogram.rs22
-rw-r--r--components/script/dom/webglrenderingcontext.rs12
-rw-r--r--components/script/dom/webgluniformlocation.rs10
-rw-r--r--tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/uniform-location.html.ini7
4 files changed, 36 insertions, 15 deletions
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs
index 940d5d051e8..20a8eb1957b 100644
--- a/components/script/dom/webglprogram.rs
+++ b/components/script/dom/webglprogram.rs
@@ -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 {
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 45923d1b27c..5e2f26748ac 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -436,7 +436,10 @@ impl WebGLRenderingContext {
None => return,
};
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),
}
handle_potential_webgl_error!(self, f(location));
@@ -3612,7 +3615,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
) -> JSVal {
// 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);
return NullValue();
}
diff --git a/components/script/dom/webgluniformlocation.rs b/components/script/dom/webgluniformlocation.rs
index db44ff9c969..83ab87945a9 100644
--- a/components/script/dom/webgluniformlocation.rs
+++ b/components/script/dom/webgluniformlocation.rs
@@ -15,6 +15,7 @@ pub struct WebGLUniformLocation {
reflector_: Reflector,
id: i32,
program_id: WebGLProgramId,
+ link_generation: u64,
size: Option<i32>,
type_: u32,
}
@@ -23,6 +24,7 @@ impl WebGLUniformLocation {
fn new_inherited(
id: i32,
program_id: WebGLProgramId,
+ link_generation: u64,
size: Option<i32>,
type_: u32,
) -> Self {
@@ -30,6 +32,7 @@ impl WebGLUniformLocation {
reflector_: Reflector::new(),
id,
program_id,
+ link_generation,
size,
type_,
}
@@ -39,11 +42,12 @@ impl WebGLUniformLocation {
window: &Window,
id: i32,
program_id: WebGLProgramId,
+ link_generation: u64,
size: Option<i32>,
type_: u32,
) -> DomRoot<Self> {
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,
WebGLUniformLocationBinding::Wrap,
)
@@ -57,6 +61,10 @@ impl WebGLUniformLocation {
self.program_id
}
+ pub fn link_generation(&self) -> u64 {
+ self.link_generation
+ }
+
pub fn size(&self) -> Option<i32> {
self.size
}
diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/uniform-location.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/uniform-location.html.ini
deleted file mode 100644
index 0598a5b72a8..00000000000
--- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/uniform-location.html.ini
+++ /dev/null
@@ -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
-