diff options
Diffstat (limited to 'components/canvas')
-rw-r--r-- | components/canvas/Cargo.toml | 2 | ||||
-rw-r--r-- | components/canvas/webgl_limits.rs | 40 | ||||
-rw-r--r-- | components/canvas/webgl_thread.rs | 67 |
3 files changed, 107 insertions, 2 deletions
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index daa07fab430..2f9495c961d 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -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.12" +sparkle = "0.1.13" webrender = {git = "https://github.com/servo/webrender"} webrender_api = {git = "https://github.com/servo/webrender"} webrender_traits = {path = "../webrender_traits"} diff --git a/components/canvas/webgl_limits.rs b/components/canvas/webgl_limits.rs index d910be71d99..1a08dfea945 100644 --- a/components/canvas/webgl_limits.rs +++ b/components/canvas/webgl_limits.rs @@ -65,14 +65,24 @@ impl GLLimitsDetect for GLLimits { }; let ( + max_uniform_block_size, max_uniform_buffer_bindings, min_program_texel_offset, max_program_texel_offset, max_transform_feedback_separate_attribs, max_draw_buffers, max_color_attachments, + max_combined_uniform_blocks, + max_combined_vertex_uniform_components, + max_combined_fragment_uniform_components, + max_vertex_uniform_blocks, + max_vertex_uniform_components, + max_fragment_uniform_blocks, + max_fragment_uniform_components, + uniform_buffer_offset_alignment, ); if webgl_version == WebGLVersion::WebGL2 { + max_uniform_block_size = gl.get_integer(gl::MAX_UNIFORM_BLOCK_SIZE); max_uniform_buffer_bindings = gl.get_integer(gl::MAX_UNIFORM_BUFFER_BINDINGS); min_program_texel_offset = gl.get_integer(gl::MIN_PROGRAM_TEXEL_OFFSET); max_program_texel_offset = gl.get_integer(gl::MAX_PROGRAM_TEXEL_OFFSET); @@ -81,14 +91,33 @@ impl GLLimitsDetect for GLLimits { max_color_attachments = gl.get_integer(gl::MAX_COLOR_ATTACHMENTS); max_draw_buffers = gl .get_integer(gl::MAX_DRAW_BUFFERS) - .min(max_color_attachments) + .min(max_color_attachments); + max_combined_uniform_blocks = gl.get_integer(gl::MAX_COMBINED_UNIFORM_BLOCKS); + max_combined_vertex_uniform_components = + gl.get_integer(gl::MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS); + max_combined_fragment_uniform_components = + gl.get_integer(gl::MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS); + max_vertex_uniform_blocks = gl.get_integer(gl::MAX_VERTEX_UNIFORM_BLOCKS); + max_vertex_uniform_components = gl.get_integer(gl::MAX_VERTEX_UNIFORM_COMPONENTS); + max_fragment_uniform_blocks = gl.get_integer(gl::MAX_FRAGMENT_UNIFORM_BLOCKS); + max_fragment_uniform_components = gl.get_integer(gl::MAX_FRAGMENT_UNIFORM_COMPONENTS); + uniform_buffer_offset_alignment = gl.get_integer(gl::UNIFORM_BUFFER_OFFSET_ALIGNMENT); } else { + max_uniform_block_size = 0; max_uniform_buffer_bindings = 0; min_program_texel_offset = 0; max_program_texel_offset = 0; max_transform_feedback_separate_attribs = 0; max_color_attachments = 1; max_draw_buffers = 1; + max_combined_uniform_blocks = 0; + max_combined_vertex_uniform_components = 0; + max_combined_fragment_uniform_components = 0; + max_vertex_uniform_blocks = 0; + max_vertex_uniform_components = 0; + max_fragment_uniform_blocks = 0; + max_fragment_uniform_components = 0; + uniform_buffer_offset_alignment = 0; } GLLimits { @@ -111,6 +140,15 @@ impl GLLimitsDetect for GLLimits { max_program_texel_offset, max_color_attachments, max_draw_buffers, + max_uniform_block_size, + max_combined_uniform_blocks, + max_combined_vertex_uniform_components, + max_combined_fragment_uniform_components, + max_vertex_uniform_blocks, + max_vertex_uniform_components, + max_fragment_uniform_blocks, + max_fragment_uniform_components, + uniform_buffer_offset_alignment, } } } diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index b9a4533f134..46ea56c1c4f 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -6,6 +6,7 @@ use crate::webgl_limits::GLLimitsDetect; use byteorder::{ByteOrder, NativeEndian, WriteBytesExt}; use canvas_traits::webgl; use canvas_traits::webgl::ActiveAttribInfo; +use canvas_traits::webgl::ActiveUniformBlockInfo; use canvas_traits::webgl::ActiveUniformInfo; use canvas_traits::webgl::AlphaTreatment; use canvas_traits::webgl::DOMToTextureCommand; @@ -1744,6 +1745,40 @@ impl WebGLImpl { } sender.send(value).unwrap(); }, + WebGLCommand::GetUniformBlockIndex(program_id, ref name, ref sender) => { + let name = to_name_in_compiled_shader(name); + let index = gl.get_uniform_block_index(program_id.get(), &name); + sender.send(index).unwrap(); + }, + WebGLCommand::GetUniformIndices(program_id, ref names, ref sender) => { + let names = names + .iter() + .map(|name| to_name_in_compiled_shader(name)) + .collect::<Vec<_>>(); + let name_strs = names.iter().map(|name| name.as_str()).collect::<Vec<_>>(); + let indices = gl.get_uniform_indices(program_id.get(), &name_strs); + sender.send(indices).unwrap(); + }, + WebGLCommand::GetActiveUniforms(program_id, ref indices, pname, ref sender) => { + let results = gl.get_active_uniforms_iv(program_id.get(), indices, pname); + sender.send(results).unwrap(); + }, + WebGLCommand::GetActiveUniformBlockName(program_id, block_idx, ref sender) => { + let name = gl.get_active_uniform_block_name(program_id.get(), block_idx); + sender.send(name).unwrap(); + }, + WebGLCommand::GetActiveUniformBlockParameter( + program_id, + block_idx, + pname, + ref sender, + ) => { + let results = gl.get_active_uniform_block_iv(program_id.get(), block_idx, pname); + sender.send(results).unwrap(); + }, + WebGLCommand::UniformBlockBinding(program_id, block_idx, block_binding) => { + gl.uniform_block_binding(program_id.get(), block_idx, block_binding) + }, WebGLCommand::InitializeFramebuffer { color, depth, @@ -1790,6 +1825,16 @@ impl WebGLImpl { let value = gl.get_sampler_parameter_fv(sampler_id.get(), pname)[0]; sender.send(value).unwrap(); }, + WebGLCommand::BindBufferBase(target, index, id) => { + gl.bind_buffer_base(target, index, id.map_or(0, WebGLBufferId::get)) + }, + WebGLCommand::BindBufferRange(target, index, id, offset, size) => gl.bind_buffer_range( + target, + index, + id.map_or(0, WebGLBufferId::get), + offset as isize, + size as isize, + ), } // If debug asertions are enabled, then check the error state. @@ -1890,6 +1935,7 @@ impl WebGLImpl { linked: false, active_attribs: vec![].into(), active_uniforms: vec![].into(), + active_uniform_blocks: vec![].into(), transform_feedback_length: Default::default(), transform_feedback_mode: Default::default(), }; @@ -1945,6 +1991,26 @@ impl WebGLImpl { }) .collect::<Vec<_>>() .into(); + + let mut num_active_uniform_blocks = [0]; + unsafe { + gl.get_program_iv( + program.get(), + gl::ACTIVE_UNIFORM_BLOCKS, + &mut num_active_uniform_blocks, + ); + } + let active_uniform_blocks = (0..num_active_uniform_blocks[0] as u32) + .map(|i| { + let name = gl.get_active_uniform_block_name(program.get(), i); + let size = + gl.get_active_uniform_block_iv(program.get(), i, gl::UNIFORM_BLOCK_DATA_SIZE) + [0]; + ActiveUniformBlockInfo { name, size } + }) + .collect::<Vec<_>>() + .into(); + let mut transform_feedback_length = [0]; unsafe { gl.get_program_iv( @@ -1965,6 +2031,7 @@ impl WebGLImpl { linked: true, active_attribs, active_uniforms, + active_uniform_blocks, transform_feedback_length: transform_feedback_length[0], transform_feedback_mode: transform_feedback_mode[0], } |