Skip to content

Commit

Permalink
Add support for WebGL2 unsigned uniform operations
Browse files Browse the repository at this point in the history
This adds support for the WebGL2 `uniform[1234]ui` and `uniform[1234]uiv`
operations.

See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.8
  • Loading branch information
mmatyas committed Jan 15, 2020
1 parent c6192dc commit bc91438
Show file tree
Hide file tree
Showing 10 changed files with 636 additions and 127 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/canvas/Cargo.toml
Expand Up @@ -34,7 +34,7 @@ num-traits = "0.2"
raqote = {git = "https://github.com/jrmuizel/raqote", optional = true}
pixels = {path = "../pixels"}
servo_config = {path = "../config"}
sparkle = "0.1.13"
sparkle = "0.1.14"
webrender = {git = "https://github.com/servo/webrender"}
webrender_api = {git = "https://github.com/servo/webrender"}
webrender_traits = {path = "../webrender_traits"}
Expand Down
38 changes: 38 additions & 0 deletions components/canvas/webgl_thread.rs
Expand Up @@ -1308,14 +1308,20 @@ impl WebGLImpl {
WebGLCommand::Uniform1fv(uniform_id, ref v) => gl.uniform_1fv(uniform_id, v),
WebGLCommand::Uniform1i(uniform_id, v) => gl.uniform_1i(uniform_id, v),
WebGLCommand::Uniform1iv(uniform_id, ref v) => gl.uniform_1iv(uniform_id, v),
WebGLCommand::Uniform1ui(uniform_id, v) => gl.uniform_1ui(uniform_id, v),
WebGLCommand::Uniform1uiv(uniform_id, ref v) => gl.uniform_1uiv(uniform_id, v),
WebGLCommand::Uniform2f(uniform_id, x, y) => gl.uniform_2f(uniform_id, x, y),
WebGLCommand::Uniform2fv(uniform_id, ref v) => gl.uniform_2fv(uniform_id, v),
WebGLCommand::Uniform2i(uniform_id, x, y) => gl.uniform_2i(uniform_id, x, y),
WebGLCommand::Uniform2iv(uniform_id, ref v) => gl.uniform_2iv(uniform_id, v),
WebGLCommand::Uniform2ui(uniform_id, x, y) => gl.uniform_2ui(uniform_id, x, y),
WebGLCommand::Uniform2uiv(uniform_id, ref v) => gl.uniform_2uiv(uniform_id, v),
WebGLCommand::Uniform3f(uniform_id, x, y, z) => gl.uniform_3f(uniform_id, x, y, z),
WebGLCommand::Uniform3fv(uniform_id, ref v) => gl.uniform_3fv(uniform_id, v),
WebGLCommand::Uniform3i(uniform_id, x, y, z) => gl.uniform_3i(uniform_id, x, y, z),
WebGLCommand::Uniform3iv(uniform_id, ref v) => gl.uniform_3iv(uniform_id, v),
WebGLCommand::Uniform3ui(uniform_id, x, y, z) => gl.uniform_3ui(uniform_id, x, y, z),
WebGLCommand::Uniform3uiv(uniform_id, ref v) => gl.uniform_3uiv(uniform_id, v),
WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => {
gl.uniform_4f(uniform_id, x, y, z, w)
},
Expand All @@ -1324,6 +1330,10 @@ impl WebGLImpl {
gl.uniform_4i(uniform_id, x, y, z, w)
},
WebGLCommand::Uniform4iv(uniform_id, ref v) => gl.uniform_4iv(uniform_id, v),
WebGLCommand::Uniform4ui(uniform_id, x, y, z, w) => {
gl.uniform_4ui(uniform_id, x, y, z, w)
},
WebGLCommand::Uniform4uiv(uniform_id, ref v) => gl.uniform_4uiv(uniform_id, v),
WebGLCommand::UniformMatrix2fv(uniform_id, ref v) => {
gl.uniform_matrix_2fv(uniform_id, false, v)
},
Expand Down Expand Up @@ -1703,6 +1713,34 @@ impl WebGLImpl {
}
sender.send(value).unwrap();
},
WebGLCommand::GetUniformUint(program_id, loc, ref sender) => {
let mut value = [0];
unsafe {
gl.get_uniform_uiv(program_id.get(), loc, &mut value);
}
sender.send(value[0]).unwrap();
},
WebGLCommand::GetUniformUint2(program_id, loc, ref sender) => {
let mut value = [0; 2];
unsafe {
gl.get_uniform_uiv(program_id.get(), loc, &mut value);
}
sender.send(value).unwrap();
},
WebGLCommand::GetUniformUint3(program_id, loc, ref sender) => {
let mut value = [0; 3];
unsafe {
gl.get_uniform_uiv(program_id.get(), loc, &mut value);
}
sender.send(value).unwrap();
},
WebGLCommand::GetUniformUint4(program_id, loc, ref sender) => {
let mut value = [0; 4];
unsafe {
gl.get_uniform_uiv(program_id.get(), loc, &mut value);
}
sender.send(value).unwrap();
},
WebGLCommand::GetUniformFloat(program_id, loc, ref sender) => {
let mut value = [0.];
unsafe {
Expand Down
12 changes: 12 additions & 0 deletions components/canvas_traits/webgl.rs
Expand Up @@ -327,19 +327,27 @@ pub enum WebGLCommand {
Uniform1f(i32, f32),
Uniform1fv(i32, Vec<f32>),
Uniform1i(i32, i32),
Uniform1ui(i32, u32),
Uniform1iv(i32, Vec<i32>),
Uniform1uiv(i32, Vec<u32>),
Uniform2f(i32, f32, f32),
Uniform2fv(i32, Vec<f32>),
Uniform2i(i32, i32, i32),
Uniform2ui(i32, u32, u32),
Uniform2iv(i32, Vec<i32>),
Uniform2uiv(i32, Vec<u32>),
Uniform3f(i32, f32, f32, f32),
Uniform3fv(i32, Vec<f32>),
Uniform3i(i32, i32, i32, i32),
Uniform3ui(i32, u32, u32, u32),
Uniform3iv(i32, Vec<i32>),
Uniform3uiv(i32, Vec<u32>),
Uniform4f(i32, f32, f32, f32, f32),
Uniform4fv(i32, Vec<f32>),
Uniform4i(i32, i32, i32, i32, i32),
Uniform4ui(i32, u32, u32, u32, u32),
Uniform4iv(i32, Vec<i32>),
Uniform4uiv(i32, Vec<u32>),
UniformMatrix2fv(i32, Vec<f32>),
UniformMatrix3fv(i32, Vec<f32>),
UniformMatrix4fv(i32, Vec<f32>),
Expand Down Expand Up @@ -456,6 +464,10 @@ pub enum WebGLCommand {
GetUniformInt2(WebGLProgramId, i32, WebGLSender<[i32; 2]>),
GetUniformInt3(WebGLProgramId, i32, WebGLSender<[i32; 3]>),
GetUniformInt4(WebGLProgramId, i32, WebGLSender<[i32; 4]>),
GetUniformUint(WebGLProgramId, i32, WebGLSender<u32>),
GetUniformUint2(WebGLProgramId, i32, WebGLSender<[u32; 2]>),
GetUniformUint3(WebGLProgramId, i32, WebGLSender<[u32; 3]>),
GetUniformUint4(WebGLProgramId, i32, WebGLSender<[u32; 4]>),
GetUniformFloat(WebGLProgramId, i32, WebGLSender<f32>),
GetUniformFloat2(WebGLProgramId, i32, WebGLSender<[f32; 2]>),
GetUniformFloat3(WebGLProgramId, i32, WebGLSender<[f32; 3]>),
Expand Down

0 comments on commit bc91438

Please sign in to comment.