Skip to content
Permalink
Browse files

Auto merge of #24514 - imiklos:webgl_transform_feedback, r=<try>

[WIP] Add WebGL Transformfeedback support

Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.15
cc @mmatyas @jdm @zakorgy

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
  • Loading branch information...
bors-servo committed Nov 8, 2019
2 parents 8cb6145 + bb2ec69 commit d9419b27f4a5ad5284df92b97f70e94481e4778c

Some generated files are not rendered by default. Learn more.

@@ -20,6 +20,8 @@ impl GLLimitsDetect for GLLimits {
let max_renderbuffer_size = gl.get_integer(gl::MAX_RENDERBUFFER_SIZE);
let max_texture_image_units = gl.get_integer(gl::MAX_TEXTURE_IMAGE_UNITS);
let max_vertex_texture_image_units = gl.get_integer(gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS);
let max_transform_feedback_separate_attribs =
gl.get_integer(gl::MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);

// TODO: better value for this?
let max_client_wait_timeout_webgl = std::time::Duration::new(1, 0);
@@ -67,6 +69,7 @@ impl GLLimitsDetect for GLLimits {
max_vertex_texture_image_units,
max_vertex_uniform_vectors,
max_client_wait_timeout_webgl,
max_transform_feedback_separate_attribs,
}
}
}
@@ -1180,6 +1180,41 @@ impl WebGLImpl {
WebGLCommand::GetRenderbufferParameter(target, pname, ref chan) => {
Self::get_renderbuffer_parameter(gl, target, pname, chan)
},
WebGLCommand::CreateTransformFeedback(ref sender) => {
let value = gl.gen_transform_feedbacks();
sender.send(value).unwrap()
},
WebGLCommand::DeleteTransformFeedback(id) => {
gl.delete_transform_feedbacks(id);
},
WebGLCommand::IsTransformFeedback(id, ref sender) => {
let value = gl.is_transform_feedback(id);
sender.send(value).unwrap()
},
WebGLCommand::BindTransformFeedback(target, id) => {
gl.bind_transform_feedback(target, id);
},
WebGLCommand::BeginTransformFeedback(mode) => {
gl.begin_transform_feedback(mode);
},
WebGLCommand::EndTransformFeedback() => {
gl.end_transform_feedback();
},
WebGLCommand::PauseTransformFeedback() => {
gl.pause_transform_feedback();
},
WebGLCommand::ResumeTransformFeedback() => {
gl.resume_transform_feedback();
},
WebGLCommand::GetTransformFeedbackVarying(program, index, ref sender) => {
let (size, ty, mut name) = gl.get_transform_feedback_varying(program.get(), index);
// We need to split, because the name starts with '_u' prefix.
name = name.split_off(2);
sender.send((size, ty, name)).unwrap();
},
WebGLCommand::TransformFeedbackVaryings(program, ref varyings, buffer_mode) => {
gl.transform_feedback_varyings(program.get(), varyings.as_slice(), buffer_mode);
},
WebGLCommand::GetFramebufferAttachmentParameter(
target,
attachment,
@@ -1814,9 +1849,10 @@ impl WebGLImpl {
linked: false,
active_attribs: vec![].into(),
active_uniforms: vec![].into(),
transform_feedback_length: Default::default(),
transform_feedback_mode: Default::default(),
};
}

let mut num_active_attribs = [0];
unsafe {
gl.get_program_iv(
@@ -1868,11 +1904,28 @@ impl WebGLImpl {
})
.collect::<Vec<_>>()
.into();

let mut transform_feedback_length = [0];
unsafe {
gl.get_program_iv(
program.get(),
gl::TRANSFORM_FEEDBACK_VARYINGS,
&mut transform_feedback_length,
);
}
let mut transform_feedback_mode = [0];
unsafe {
gl.get_program_iv(
program.get(),
gl::TRANSFORM_FEEDBACK_BUFFER_MODE,
&mut transform_feedback_mode,
);
}
ProgramLinkInfo {
linked: true,
active_attribs,
active_uniforms,
transform_feedback_length: transform_feedback_length[0],
transform_feedback_mode: transform_feedback_mode[0],
}
}

@@ -292,6 +292,16 @@ pub enum WebGLCommand {
GetProgramInfoLog(WebGLProgramId, WebGLSender<String>),
GetFramebufferAttachmentParameter(u32, u32, u32, WebGLSender<i32>),
GetRenderbufferParameter(u32, u32, WebGLSender<i32>),
CreateTransformFeedback(WebGLSender<u32>),
DeleteTransformFeedback(u32),
IsTransformFeedback(u32, WebGLSender<bool>),
BindTransformFeedback(u32, u32),
BeginTransformFeedback(u32),
EndTransformFeedback(),
PauseTransformFeedback(),
ResumeTransformFeedback(),
GetTransformFeedbackVarying(WebGLProgramId, u32, WebGLSender<(i32, u32, String)>),
TransformFeedbackVaryings(WebGLProgramId, Vec<String>, u32),
PolygonOffset(f32, f32),
RenderbufferStorage(u32, u32, i32, i32),
ReadPixels(Rect<u32>, u32, u32, IpcBytesSender),
@@ -660,6 +670,10 @@ pub struct ProgramLinkInfo {
pub active_attribs: Box<[ActiveAttribInfo]>,
/// The list of active uniforms.
pub active_uniforms: Box<[ActiveUniformInfo]>,
/// The number of varying variables
pub transform_feedback_length: i32,
/// The buffer mode used when transform feedback is active
pub transform_feedback_mode: i32,
}

/// Description of a single active attribute.
@@ -733,6 +747,8 @@ parameters! {
Bool(ParameterBool {
DepthWritemask = gl::DEPTH_WRITEMASK,
SampleCoverageInvert = gl::SAMPLE_COVERAGE_INVERT,
TransformFeedbackActive = gl::TRANSFORM_FEEDBACK_ACTIVE,
TransformFeedbackPaused = gl::TRANSFORM_FEEDBACK_PAUSED,
}),
Bool4(ParameterBool4 {
ColorWritemask = gl::COLOR_WRITEMASK,
@@ -774,6 +790,12 @@ parameters! {
StencilValueMask = gl::STENCIL_VALUE_MASK,
StencilWritemask = gl::STENCIL_WRITEMASK,
SubpixelBits = gl::SUBPIXEL_BITS,
TransformFeedbackBinding = gl::TRANSFORM_FEEDBACK_BINDING,
MaxTransformFeedbackInterleavedComponents = gl::MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
MaxTransformFeedbackSeparateAttribs = gl::MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
MaxTransformFeedbackSeparateComponents = gl::MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,
TransformFeedbackBufferSize = gl::TRANSFORM_FEEDBACK_BUFFER_SIZE,
TransformFeedbackBufferStart = gl::TRANSFORM_FEEDBACK_BUFFER_START,
}),
Int2(ParameterInt2 {
MaxViewportDims = gl::MAX_VIEWPORT_DIMS,
@@ -968,4 +990,5 @@ pub struct GLLimits {
pub max_vertex_texture_image_units: u32,
pub max_vertex_uniform_vectors: u32,
pub max_client_wait_timeout_webgl: std::time::Duration,
pub max_transform_feedback_separate_attribs: u32,
}
@@ -532,6 +532,7 @@ pub mod webglshader;
pub mod webglshaderprecisionformat;
pub mod webglsync;
pub mod webgltexture;
pub mod webgltransformfeedback;
pub mod webgluniformlocation;
pub mod webglvertexarrayobjectoes;
pub mod websocket;

0 comments on commit d9419b2

Please sign in to comment.
You can’t perform that action at this time.