mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Add support for WebGL2 GetFragDataLocation
Adds support for the `GetFragDataLocation` WebGL2 call. See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.7
This commit is contained in:
parent
e1f6dfd716
commit
ced67af6b2
9 changed files with 62 additions and 32 deletions
|
@ -35,7 +35,7 @@ raqote = {git = "https://github.com/jrmuizel/raqote"}
|
|||
time = { version = "0.1.0", optional = true }
|
||||
pixels = {path = "../pixels"}
|
||||
servo_config = {path = "../config"}
|
||||
sparkle = "0.1.20"
|
||||
sparkle = "0.1.22"
|
||||
webrender = {git = "https://github.com/servo/webrender"}
|
||||
webrender_api = {git = "https://github.com/servo/webrender"}
|
||||
webrender_traits = {path = "../webrender_traits"}
|
||||
|
|
|
@ -1287,6 +1287,12 @@ impl WebGLImpl {
|
|||
Self::shader_precision_format(gl, shader_type, precision_type, chan)
|
||||
},
|
||||
WebGLCommand::GetExtensions(ref chan) => Self::get_extensions(gl, chan),
|
||||
WebGLCommand::GetFragDataLocation(program_id, ref name, ref sender) => {
|
||||
let location =
|
||||
gl.get_frag_data_location(program_id.get(), &to_name_in_compiled_shader(name));
|
||||
assert!(location >= 0);
|
||||
sender.send(location).unwrap();
|
||||
},
|
||||
WebGLCommand::GetUniformLocation(program_id, ref name, ref chan) => {
|
||||
Self::uniform_location(gl, program_id, &name, chan)
|
||||
},
|
||||
|
|
|
@ -305,6 +305,7 @@ pub enum WebGLCommand {
|
|||
FramebufferTexture2D(u32, u32, u32, Option<WebGLTextureId>, i32),
|
||||
GetExtensions(WebGLSender<String>),
|
||||
GetShaderPrecisionFormat(u32, u32, WebGLSender<(i32, i32, i32)>),
|
||||
GetFragDataLocation(WebGLProgramId, String, WebGLSender<i32>),
|
||||
GetUniformLocation(WebGLProgramId, String, WebGLSender<i32>),
|
||||
GetShaderInfoLog(WebGLShaderId, WebGLSender<String>),
|
||||
GetProgramInfoLog(WebGLProgramId, WebGLSender<String>),
|
||||
|
|
|
@ -1467,6 +1467,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
self.base.GetAttribLocation(program, name)
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.7
|
||||
fn GetFragDataLocation(&self, program: &WebGLProgram, name: DOMString) -> i32 {
|
||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(program), return -1);
|
||||
handle_potential_webgl_error!(self.base, program.get_frag_data_location(name), -1)
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> {
|
||||
self.base.GetProgramInfoLog(program)
|
||||
|
|
|
@ -365,6 +365,30 @@ impl WebGLProgram {
|
|||
Ok(location)
|
||||
}
|
||||
|
||||
/// glGetFragDataLocation
|
||||
pub fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> {
|
||||
if !self.is_linked() || self.is_deleted() {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
|
||||
if !validate_glsl_name(&name)? {
|
||||
return Ok(-1);
|
||||
}
|
||||
if name.starts_with("gl_") {
|
||||
return Ok(-1);
|
||||
}
|
||||
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.upcast::<WebGLObject>()
|
||||
.context()
|
||||
.send_command(WebGLCommand::GetFragDataLocation(
|
||||
self.id,
|
||||
name.into(),
|
||||
sender,
|
||||
));
|
||||
Ok(receiver.recv().unwrap())
|
||||
}
|
||||
|
||||
/// glGetUniformLocation
|
||||
pub fn get_uniform_location(
|
||||
&self,
|
||||
|
|
|
@ -422,7 +422,7 @@ interface mixin WebGL2RenderingContextBase
|
|||
// optional GLuint srcLengthOverride = 0);
|
||||
|
||||
/* Programs and shaders */
|
||||
// [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name);
|
||||
[WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name);
|
||||
|
||||
/* Uniforms */
|
||||
void uniform1ui(WebGLUniformLocation? location, GLuint v0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue