Add support for WebGL2 unsigned uniform operations

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
This commit is contained in:
Mátyás Mustoha 2020-01-10 11:47:25 +01:00
parent c6192dc286
commit bc914381a8
10 changed files with 643 additions and 134 deletions

View file

@ -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)
},
@ -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)
},
@ -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 {