summaryrefslogtreecommitdiffstats
path: root/gfx/wr/webrender/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/wr/webrender/src/renderer')
-rw-r--r--gfx/wr/webrender/src/renderer/gpu_buffer.rs173
-rw-r--r--gfx/wr/webrender/src/renderer/mod.rs121
-rw-r--r--gfx/wr/webrender/src/renderer/shade.rs20
-rw-r--r--gfx/wr/webrender/src/renderer/upload.rs12
-rw-r--r--gfx/wr/webrender/src/renderer/vertex.rs67
5 files changed, 190 insertions, 203 deletions
diff --git a/gfx/wr/webrender/src/renderer/gpu_buffer.rs b/gfx/wr/webrender/src/renderer/gpu_buffer.rs
index 58a8aa6cbd..c8a2b87b0c 100644
--- a/gfx/wr/webrender/src/renderer/gpu_buffer.rs
+++ b/gfx/wr/webrender/src/renderer/gpu_buffer.rs
@@ -13,21 +13,57 @@
use crate::renderer::MAX_VERTEX_TEXTURE_WIDTH;
use api::units::{DeviceIntRect, DeviceIntSize, LayoutRect, PictureRect, DeviceRect};
-use api::{PremultipliedColorF};
+use api::{PremultipliedColorF, ImageFormat};
use crate::device::Texel;
use crate::render_task_graph::{RenderTaskGraph, RenderTaskId};
+pub struct GpuBufferBuilder {
+ pub i32: GpuBufferBuilderI,
+ pub f32: GpuBufferBuilderF,
+}
+
+pub type GpuBufferF = GpuBuffer<GpuBufferBlockF>;
+pub type GpuBufferBuilderF = GpuBufferBuilderImpl<GpuBufferBlockF>;
+
+pub type GpuBufferI = GpuBuffer<GpuBufferBlockI>;
+pub type GpuBufferBuilderI = GpuBufferBuilderImpl<GpuBufferBlockI>;
+
+unsafe impl Texel for GpuBufferBlockF {
+ fn image_format() -> ImageFormat { ImageFormat::RGBAF32 }
+}
+
+unsafe impl Texel for GpuBufferBlockI {
+ fn image_format() -> ImageFormat { ImageFormat::RGBAI32 }
+}
-unsafe impl Texel for GpuBufferBlock {}
+impl Default for GpuBufferBlockF {
+ fn default() -> Self {
+ GpuBufferBlockF::EMPTY
+ }
+}
+
+impl Default for GpuBufferBlockI {
+ fn default() -> Self {
+ GpuBufferBlockI::EMPTY
+ }
+}
/// A single texel in RGBAF32 texture - 16 bytes.
#[derive(Copy, Clone, Debug, MallocSizeOf)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
-pub struct GpuBufferBlock {
+pub struct GpuBufferBlockF {
data: [f32; 4],
}
+/// A single texel in RGBAI32 texture - 16 bytes.
+#[derive(Copy, Clone, Debug, MallocSizeOf)]
+#[cfg_attr(feature = "capture", derive(Serialize))]
+#[cfg_attr(feature = "replay", derive(Deserialize))]
+pub struct GpuBufferBlockI {
+ data: [i32; 4],
+}
+
#[derive(Copy, Debug, Clone, MallocSizeOf, Eq, PartialEq)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
@@ -48,13 +84,17 @@ impl GpuBufferAddress {
pub const INVALID: GpuBufferAddress = GpuBufferAddress { u: !0, v: !0 };
}
-impl GpuBufferBlock {
- pub const EMPTY: Self = GpuBufferBlock { data: [0.0; 4] };
+impl GpuBufferBlockF {
+ pub const EMPTY: Self = GpuBufferBlockF { data: [0.0; 4] };
+}
+
+impl GpuBufferBlockI {
+ pub const EMPTY: Self = GpuBufferBlockI { data: [0; 4] };
}
-impl Into<GpuBufferBlock> for LayoutRect {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl Into<GpuBufferBlockF> for LayoutRect {
+ fn into(self) -> GpuBufferBlockF {
+ GpuBufferBlockF {
data: [
self.min.x,
self.min.y,
@@ -65,9 +105,9 @@ impl Into<GpuBufferBlock> for LayoutRect {
}
}
-impl Into<GpuBufferBlock> for PictureRect {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl Into<GpuBufferBlockF> for PictureRect {
+ fn into(self) -> GpuBufferBlockF {
+ GpuBufferBlockF {
data: [
self.min.x,
self.min.y,
@@ -78,9 +118,9 @@ impl Into<GpuBufferBlock> for PictureRect {
}
}
-impl Into<GpuBufferBlock> for DeviceRect {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl Into<GpuBufferBlockF> for DeviceRect {
+ fn into(self) -> GpuBufferBlockF {
+ GpuBufferBlockF {
data: [
self.min.x,
self.min.y,
@@ -91,9 +131,9 @@ impl Into<GpuBufferBlock> for DeviceRect {
}
}
-impl Into<GpuBufferBlock> for PremultipliedColorF {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl Into<GpuBufferBlockF> for PremultipliedColorF {
+ fn into(self) -> GpuBufferBlockF {
+ GpuBufferBlockF {
data: [
self.r,
self.g,
@@ -104,22 +144,43 @@ impl Into<GpuBufferBlock> for PremultipliedColorF {
}
}
-impl Into<GpuBufferBlock> for DeviceIntRect {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl From<DeviceIntRect> for GpuBufferBlockF {
+ fn from(rect: DeviceIntRect) -> Self {
+ GpuBufferBlockF {
+ data: [
+ rect.min.x as f32,
+ rect.min.y as f32,
+ rect.max.x as f32,
+ rect.max.y as f32,
+ ],
+ }
+ }
+}
+
+impl From<DeviceIntRect> for GpuBufferBlockI {
+ fn from(rect: DeviceIntRect) -> Self {
+ GpuBufferBlockI {
data: [
- self.min.x as f32,
- self.min.y as f32,
- self.max.x as f32,
- self.max.y as f32,
+ rect.min.x,
+ rect.min.y,
+ rect.max.x,
+ rect.max.y,
],
}
}
}
-impl Into<GpuBufferBlock> for [f32; 4] {
- fn into(self) -> GpuBufferBlock {
- GpuBufferBlock {
+impl Into<GpuBufferBlockF> for [f32; 4] {
+ fn into(self) -> GpuBufferBlockF {
+ GpuBufferBlockF {
+ data: self,
+ }
+ }
+}
+
+impl Into<GpuBufferBlockI> for [i32; 4] {
+ fn into(self) -> GpuBufferBlockI {
+ GpuBufferBlockI {
data: self,
}
}
@@ -132,16 +193,16 @@ struct DeferredBlock {
}
/// Interface to allow writing multiple GPU blocks, possibly of different types
-pub struct GpuBufferWriter<'a> {
- buffer: &'a mut Vec<GpuBufferBlock>,
+pub struct GpuBufferWriter<'a, T> {
+ buffer: &'a mut Vec<T>,
deferred: &'a mut Vec<DeferredBlock>,
index: usize,
block_count: usize,
}
-impl<'a> GpuBufferWriter<'a> {
+impl<'a, T> GpuBufferWriter<'a, T> where T: Texel {
fn new(
- buffer: &'a mut Vec<GpuBufferBlock>,
+ buffer: &'a mut Vec<T>,
deferred: &'a mut Vec<DeferredBlock>,
index: usize,
block_count: usize,
@@ -155,7 +216,7 @@ impl<'a> GpuBufferWriter<'a> {
}
/// Push one (16 byte) block of data in to the writer
- pub fn push_one<B>(&mut self, block: B) where B: Into<GpuBufferBlock> {
+ pub fn push_one<B>(&mut self, block: B) where B: Into<T> {
self.buffer.push(block.into());
}
@@ -166,7 +227,7 @@ impl<'a> GpuBufferWriter<'a> {
task_id,
index: self.buffer.len(),
});
- self.buffer.push(GpuBufferBlock::EMPTY);
+ self.buffer.push(T::default());
}
/// Close this writer, returning the GPU address of this set of block(s).
@@ -180,20 +241,20 @@ impl<'a> GpuBufferWriter<'a> {
}
}
-impl<'a> Drop for GpuBufferWriter<'a> {
+impl<'a, T> Drop for GpuBufferWriter<'a, T> {
fn drop(&mut self) {
assert_eq!(self.buffer.len(), self.index + self.block_count, "Claimed block_count was not written");
}
}
-pub struct GpuBufferBuilder {
- data: Vec<GpuBufferBlock>,
+pub struct GpuBufferBuilderImpl<T> {
+ data: Vec<T>,
deferred: Vec<DeferredBlock>,
}
-impl GpuBufferBuilder {
+impl<T> GpuBufferBuilderImpl<T> where T: Texel + std::convert::From<DeviceIntRect> {
pub fn new() -> Self {
- GpuBufferBuilder {
+ GpuBufferBuilderImpl {
data: Vec::new(),
deferred: Vec::new(),
}
@@ -202,13 +263,13 @@ impl GpuBufferBuilder {
#[allow(dead_code)]
pub fn push(
&mut self,
- blocks: &[GpuBufferBlock],
+ blocks: &[T],
) -> GpuBufferAddress {
assert!(blocks.len() <= MAX_VERTEX_TEXTURE_WIDTH);
if (self.data.len() % MAX_VERTEX_TEXTURE_WIDTH) + blocks.len() > MAX_VERTEX_TEXTURE_WIDTH {
while self.data.len() % MAX_VERTEX_TEXTURE_WIDTH != 0 {
- self.data.push(GpuBufferBlock::EMPTY);
+ self.data.push(T::default());
}
}
@@ -226,12 +287,12 @@ impl GpuBufferBuilder {
pub fn write_blocks(
&mut self,
block_count: usize,
- ) -> GpuBufferWriter {
+ ) -> GpuBufferWriter<T> {
assert!(block_count <= MAX_VERTEX_TEXTURE_WIDTH);
if (self.data.len() % MAX_VERTEX_TEXTURE_WIDTH) + block_count > MAX_VERTEX_TEXTURE_WIDTH {
while self.data.len() % MAX_VERTEX_TEXTURE_WIDTH != 0 {
- self.data.push(GpuBufferBlock::EMPTY);
+ self.data.push(T::default());
}
}
@@ -248,11 +309,11 @@ impl GpuBufferBuilder {
pub fn finalize(
mut self,
render_tasks: &RenderTaskGraph,
- ) -> GpuBuffer {
+ ) -> GpuBuffer<T> {
let required_len = (self.data.len() + MAX_VERTEX_TEXTURE_WIDTH-1) & !(MAX_VERTEX_TEXTURE_WIDTH-1);
for _ in 0 .. required_len - self.data.len() {
- self.data.push(GpuBufferBlock::EMPTY);
+ self.data.push(T::default());
}
let len = self.data.len();
@@ -271,18 +332,20 @@ impl GpuBufferBuilder {
GpuBuffer {
data: self.data,
size: DeviceIntSize::new(MAX_VERTEX_TEXTURE_WIDTH as i32, (len / MAX_VERTEX_TEXTURE_WIDTH) as i32),
+ format: T::image_format(),
}
}
}
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
-pub struct GpuBuffer {
- pub data: Vec<GpuBufferBlock>,
+pub struct GpuBuffer<T> {
+ pub data: Vec<T>,
pub size: DeviceIntSize,
+ pub format: ImageFormat,
}
-impl GpuBuffer {
+impl<T> GpuBuffer<T> {
pub fn is_empty(&self) -> bool {
self.data.is_empty()
}
@@ -292,13 +355,13 @@ impl GpuBuffer {
#[test]
fn test_gpu_buffer_sizing_push() {
let render_task_graph = RenderTaskGraph::new_for_testing();
- let mut builder = GpuBufferBuilder::new();
+ let mut builder = GpuBufferBuilderF::new();
- let row = vec![GpuBufferBlock::EMPTY; MAX_VERTEX_TEXTURE_WIDTH];
+ let row = vec![GpuBufferBlockF::EMPTY; MAX_VERTEX_TEXTURE_WIDTH];
builder.push(&row);
- builder.push(&[GpuBufferBlock::EMPTY]);
- builder.push(&[GpuBufferBlock::EMPTY]);
+ builder.push(&[GpuBufferBlockF::EMPTY]);
+ builder.push(&[GpuBufferBlockF::EMPTY]);
let buffer = builder.finalize(&render_task_graph);
assert_eq!(buffer.data.len(), MAX_VERTEX_TEXTURE_WIDTH * 2);
@@ -307,20 +370,20 @@ fn test_gpu_buffer_sizing_push() {
#[test]
fn test_gpu_buffer_sizing_writer() {
let render_task_graph = RenderTaskGraph::new_for_testing();
- let mut builder = GpuBufferBuilder::new();
+ let mut builder = GpuBufferBuilderF::new();
let mut writer = builder.write_blocks(MAX_VERTEX_TEXTURE_WIDTH);
for _ in 0 .. MAX_VERTEX_TEXTURE_WIDTH {
- writer.push_one(GpuBufferBlock::EMPTY);
+ writer.push_one(GpuBufferBlockF::EMPTY);
}
writer.finish();
let mut writer = builder.write_blocks(1);
- writer.push_one(GpuBufferBlock::EMPTY);
+ writer.push_one(GpuBufferBlockF::EMPTY);
writer.finish();
let mut writer = builder.write_blocks(1);
- writer.push_one(GpuBufferBlock::EMPTY);
+ writer.push_one(GpuBufferBlockF::EMPTY);
writer.finish();
let buffer = builder.finalize(&render_task_graph);
diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs
index 0eded7ffb4..3a058ae8f4 100644
--- a/gfx/wr/webrender/src/renderer/mod.rs
+++ b/gfx/wr/webrender/src/renderer/mod.rs
@@ -59,7 +59,7 @@ use crate::composite::{CompositorConfig, NativeSurfaceOperationDetails, NativeSu
use crate::composite::{TileKind};
use crate::debug_colors;
use crate::device::{DepthFunction, Device, DrawTarget, ExternalTexture, GpuFrameId, UploadPBOPool};
-use crate::device::{ReadTarget, ShaderError, Texture, TextureFilter, TextureFlags, TextureSlot};
+use crate::device::{ReadTarget, ShaderError, Texture, TextureFilter, TextureFlags, TextureSlot, Texel};
use crate::device::query::{GpuSampler, GpuTimer};
#[cfg(feature = "capture")]
use crate::device::FBOId;
@@ -127,7 +127,7 @@ pub(crate) mod init;
pub use debug::DebugRenderer;
pub use shade::{Shaders, SharedShaders};
pub use vertex::{desc, VertexArrayKind, MAX_VERTEX_TEXTURE_WIDTH};
-pub use gpu_buffer::{GpuBuffer, GpuBufferBuilder, GpuBufferAddress};
+pub use gpu_buffer::{GpuBuffer, GpuBufferF, GpuBufferBuilderF, GpuBufferI, GpuBufferBuilderI, GpuBufferAddress, GpuBufferBuilder};
/// The size of the array of each type of vertex data texture that
/// is round-robin-ed each frame during bind_frame_data. Doing this
@@ -341,7 +341,8 @@ pub(crate) enum TextureSampler {
PrimitiveHeadersF,
PrimitiveHeadersI,
ClipMask,
- GpuBuffer,
+ GpuBufferF,
+ GpuBufferI,
}
impl TextureSampler {
@@ -370,7 +371,8 @@ impl Into<TextureSlot> for TextureSampler {
TextureSampler::PrimitiveHeadersF => TextureSlot(7),
TextureSampler::PrimitiveHeadersI => TextureSlot(8),
TextureSampler::ClipMask => TextureSlot(9),
- TextureSampler::GpuBuffer => TextureSlot(10),
+ TextureSampler::GpuBufferF => TextureSlot(10),
+ TextureSampler::GpuBufferI => TextureSlot(11),
}
}
}
@@ -3616,7 +3618,6 @@ impl Renderer {
fn draw_clip_batch_list(
&mut self,
list: &ClipBatchList,
- draw_target: &DrawTarget,
projection: &default::Transform3D<f32>,
stats: &mut RendererStats,
) {
@@ -3671,42 +3672,6 @@ impl Renderer {
stats,
);
}
-
- // draw image masks
- let mut using_scissor = false;
- for ((mask_texture_id, clip_rect), items) in list.images.iter() {
- let _gm2 = self.gpu_profiler.start_marker("clip images");
- // Some image masks may require scissoring to ensure they don't draw
- // outside their task's target bounds. Axis-aligned primitives will
- // be clamped inside the shader and should not require scissoring.
- // TODO: We currently assume scissor state is off by default for
- // alpha targets here, but in the future we may want to track the
- // current scissor state so that this can be properly saved and
- // restored here.
- if let Some(clip_rect) = clip_rect {
- if !using_scissor {
- self.device.enable_scissor();
- using_scissor = true;
- }
- let scissor_rect = draw_target.build_scissor_rect(Some(*clip_rect));
- self.device.set_scissor_rect(scissor_rect);
- } else if using_scissor {
- self.device.disable_scissor();
- using_scissor = false;
- }
- let textures = BatchTextures::composite_rgb(*mask_texture_id);
- self.shaders.borrow_mut().cs_clip_image
- .bind(&mut self.device, projection, None, &mut self.renderer_errors, &mut self.profile);
- self.draw_instanced_batch(
- items,
- VertexArrayKind::ClipImage,
- &textures,
- stats,
- );
- }
- if using_scissor {
- self.device.disable_scissor();
- }
}
fn draw_alpha_target(
@@ -3861,7 +3826,6 @@ impl Renderer {
self.set_blend(false, FramebufferKind::Other);
self.draw_clip_batch_list(
&target.clip_batcher.primary_clips,
- &draw_target,
projection,
stats,
);
@@ -3872,7 +3836,6 @@ impl Renderer {
self.set_blend_mode_multiply(FramebufferKind::Other);
self.draw_clip_batch_list(
&target.clip_batcher.secondary_clips,
- &draw_target,
projection,
stats,
);
@@ -4452,6 +4415,38 @@ impl Renderer {
}
}
+ fn create_gpu_buffer_texture<T: Texel>(
+ &mut self,
+ buffer: &GpuBuffer<T>,
+ sampler: TextureSampler,
+ ) -> Option<Texture> {
+ if buffer.is_empty() {
+ None
+ } else {
+ let gpu_buffer_texture = self.device.create_texture(
+ ImageBufferKind::Texture2D,
+ buffer.format,
+ buffer.size.width,
+ buffer.size.height,
+ TextureFilter::Nearest,
+ None,
+ );
+
+ self.device.bind_texture(
+ sampler,
+ &gpu_buffer_texture,
+ Swizzle::default(),
+ );
+
+ self.device.upload_texture_immediate(
+ &gpu_buffer_texture,
+ &buffer.data,
+ );
+
+ Some(gpu_buffer_texture)
+ }
+ }
+
fn draw_frame(
&mut self,
frame: &mut Frame,
@@ -4478,31 +4473,14 @@ impl Renderer {
// Upload experimental GPU buffer texture if there is any data present
// TODO: Recycle these textures, upload via PBO or best approach for platform
- let gpu_buffer_texture = if frame.gpu_buffer.is_empty() {
- None
- } else {
- let gpu_buffer_texture = self.device.create_texture(
- ImageBufferKind::Texture2D,
- ImageFormat::RGBAF32,
- frame.gpu_buffer.size.width,
- frame.gpu_buffer.size.height,
- TextureFilter::Nearest,
- None,
- );
-
- self.device.bind_texture(
- TextureSampler::GpuBuffer,
- &gpu_buffer_texture,
- Swizzle::default(),
- );
-
- self.device.upload_texture_immediate(
- &gpu_buffer_texture,
- &frame.gpu_buffer.data,
- );
-
- Some(gpu_buffer_texture)
- };
+ let gpu_buffer_texture_f = self.create_gpu_buffer_texture(
+ &frame.gpu_buffer_f,
+ TextureSampler::GpuBufferF,
+ );
+ let gpu_buffer_texture_i = self.create_gpu_buffer_texture(
+ &frame.gpu_buffer_i,
+ TextureSampler::GpuBufferI,
+ );
// Determine the present mode and dirty rects, if device_size
// is Some(..). If it's None, no composite will occur and only
@@ -4761,8 +4739,11 @@ impl Renderer {
present_mode,
);
- if let Some(gpu_buffer_texture) = gpu_buffer_texture {
- self.device.delete_texture(gpu_buffer_texture);
+ if let Some(gpu_buffer_texture_f) = gpu_buffer_texture_f {
+ self.device.delete_texture(gpu_buffer_texture_f);
+ }
+ if let Some(gpu_buffer_texture_i) = gpu_buffer_texture_i {
+ self.device.delete_texture(gpu_buffer_texture_i);
}
frame.has_been_rendered = true;
diff --git a/gfx/wr/webrender/src/renderer/shade.rs b/gfx/wr/webrender/src/renderer/shade.rs
index 30baee0a19..777bfab44a 100644
--- a/gfx/wr/webrender/src/renderer/shade.rs
+++ b/gfx/wr/webrender/src/renderer/shade.rs
@@ -254,7 +254,6 @@ impl LazilyCompiledShader {
VertexArrayKind::RadialGradient => &desc::RADIAL_GRADIENT,
VertexArrayKind::ConicGradient => &desc::CONIC_GRADIENT,
VertexArrayKind::Blur => &desc::BLUR,
- VertexArrayKind::ClipImage => &desc::CLIP_IMAGE,
VertexArrayKind::ClipRect => &desc::CLIP_RECT,
VertexArrayKind::ClipBoxShadow => &desc::CLIP_BOX_SHADOW,
VertexArrayKind::VectorStencil => &desc::VECTOR_STENCIL,
@@ -282,7 +281,8 @@ impl LazilyCompiledShader {
("sGpuCache", TextureSampler::GpuCache),
("sPrimitiveHeadersF", TextureSampler::PrimitiveHeadersF),
("sPrimitiveHeadersI", TextureSampler::PrimitiveHeadersI),
- ("sGpuBuffer", TextureSampler::GpuBuffer),
+ ("sGpuBufferF", TextureSampler::GpuBufferF),
+ ("sGpuBufferI", TextureSampler::GpuBufferI),
],
);
}
@@ -300,7 +300,8 @@ impl LazilyCompiledShader {
("sPrimitiveHeadersF", TextureSampler::PrimitiveHeadersF),
("sPrimitiveHeadersI", TextureSampler::PrimitiveHeadersI),
("sClipMask", TextureSampler::ClipMask),
- ("sGpuBuffer", TextureSampler::GpuBuffer),
+ ("sGpuBufferF", TextureSampler::GpuBufferF),
+ ("sGpuBufferI", TextureSampler::GpuBufferI),
],
);
}
@@ -617,7 +618,6 @@ pub struct Shaders {
pub cs_clip_rectangle_slow: LazilyCompiledShader,
pub cs_clip_rectangle_fast: LazilyCompiledShader,
pub cs_clip_box_shadow: LazilyCompiledShader,
- pub cs_clip_image: LazilyCompiledShader,
// The are "primitive shaders". These shaders draw and blend
// final results on screen. They are aware of tile boundaries.
@@ -817,16 +817,6 @@ impl Shaders {
profile,
)?;
- let cs_clip_image = LazilyCompiledShader::new(
- ShaderKind::ClipCache(VertexArrayKind::ClipImage),
- "cs_clip_image",
- &["TEXTURE_2D"],
- device,
- options.precache_flags,
- &shader_list,
- profile,
- )?;
-
let mut cs_scale = Vec::new();
let scale_shader_num = IMAGE_BUFFER_KINDS.len();
// PrimitiveShader is not clonable. Use push() to initialize the vec.
@@ -1128,7 +1118,6 @@ impl Shaders {
cs_clip_rectangle_slow,
cs_clip_rectangle_fast,
cs_clip_box_shadow,
- cs_clip_image,
ps_text_run,
ps_text_run_dual_source,
ps_quad_textured,
@@ -1274,7 +1263,6 @@ impl Shaders {
self.cs_clip_rectangle_slow.deinit(device);
self.cs_clip_rectangle_fast.deinit(device);
self.cs_clip_box_shadow.deinit(device);
- self.cs_clip_image.deinit(device);
self.ps_text_run.deinit(device);
if let Some(shader) = self.ps_text_run_dual_source {
shader.deinit(device);
diff --git a/gfx/wr/webrender/src/renderer/upload.rs b/gfx/wr/webrender/src/renderer/upload.rs
index 0ba053cd76..c987038651 100644
--- a/gfx/wr/webrender/src/renderer/upload.rs
+++ b/gfx/wr/webrender/src/renderer/upload.rs
@@ -43,6 +43,7 @@ use crate::profiler;
use crate::render_api::MemoryReport;
pub const BATCH_UPLOAD_TEXTURE_SIZE: DeviceIntSize = DeviceIntSize::new(512, 512);
+const BATCH_UPLOAD_FORMAT_COUNT: usize = 4;
/// Upload a number of items to texture cache textures.
///
@@ -627,10 +628,10 @@ pub struct UploadTexturePool {
/// The textures in the pool associated with a last used frame index.
///
/// The outer array corresponds to each of teh three supported texture formats.
- textures: [VecDeque<(Texture, u64)>; 3],
+ textures: [VecDeque<(Texture, u64)>; BATCH_UPLOAD_FORMAT_COUNT],
// Frame at which to deallocate some textures if there are too many in the pool,
// for each format.
- delay_texture_deallocation: [u64; 3],
+ delay_texture_deallocation: [u64; BATCH_UPLOAD_FORMAT_COUNT],
current_frame: u64,
/// Temporary buffers that are used when using staging uploads + glTexImage2D.
@@ -646,8 +647,8 @@ pub struct UploadTexturePool {
impl UploadTexturePool {
pub fn new() -> Self {
UploadTexturePool {
- textures: [VecDeque::new(), VecDeque::new(), VecDeque::new()],
- delay_texture_deallocation: [0; 3],
+ textures: [VecDeque::new(), VecDeque::new(), VecDeque::new(), VecDeque::new()],
+ delay_texture_deallocation: [0; BATCH_UPLOAD_FORMAT_COUNT],
current_frame: 0,
temporary_buffers: Vec::new(),
min_temporary_buffers: 0,
@@ -660,7 +661,8 @@ impl UploadTexturePool {
ImageFormat::RGBA8 => 0,
ImageFormat::BGRA8 => 1,
ImageFormat::R8 => 2,
- _ => { panic!("unexpected format"); }
+ ImageFormat::R16 => 3,
+ _ => { panic!("unexpected format {:?}", format); }
}
}
diff --git a/gfx/wr/webrender/src/renderer/vertex.rs b/gfx/wr/webrender/src/renderer/vertex.rs
index ff555363d8..cd73975ddd 100644
--- a/gfx/wr/webrender/src/renderer/vertex.rs
+++ b/gfx/wr/webrender/src/renderer/vertex.rs
@@ -49,12 +49,12 @@ pub mod desc {
VertexAttribute {
name: "aBlurRenderTaskAddress",
count: 1,
- kind: VertexAttributeKind::U16,
+ kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aBlurSourceTaskAddress",
count: 1,
- kind: VertexAttributeKind::U16,
+ kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aBlurDirection",
@@ -488,53 +488,6 @@ pub mod desc {
],
};
- pub const CLIP_IMAGE: VertexDescriptor = VertexDescriptor {
- vertex_attributes: &[VertexAttribute {
- name: "aPosition",
- count: 2,
- kind: VertexAttributeKind::U8Norm,
- }],
- instance_attributes: &[
- // common clip attributes
- VertexAttribute {
- name: "aClipDeviceArea",
- count: 4,
- kind: VertexAttributeKind::F32,
- },
- VertexAttribute {
- name: "aClipOrigins",
- count: 4,
- kind: VertexAttributeKind::F32,
- },
- VertexAttribute {
- name: "aDevicePixelScale",
- count: 1,
- kind: VertexAttributeKind::F32,
- },
- VertexAttribute {
- name: "aTransformIds",
- count: 2,
- kind: VertexAttributeKind::I32,
- },
- // specific clip attributes
- VertexAttribute {
- name: "aClipTileRect",
- count: 4,
- kind: VertexAttributeKind::F32,
- },
- VertexAttribute {
- name: "aClipDataResourceAddress",
- count: 2,
- kind: VertexAttributeKind::U16,
- },
- VertexAttribute {
- name: "aClipLocalRect",
- count: 4,
- kind: VertexAttributeKind::F32,
- },
- ],
- };
-
pub const GPU_CACHE_UPDATE: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[
VertexAttribute {
@@ -574,17 +527,17 @@ pub mod desc {
VertexAttribute {
name: "aFilterRenderTaskAddress",
count: 1,
- kind: VertexAttributeKind::U16,
+ kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterInput1TaskAddress",
count: 1,
- kind: VertexAttributeKind::U16,
+ kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterInput2TaskAddress",
count: 1,
- kind: VertexAttributeKind::U16,
+ kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterKind",
@@ -602,6 +555,11 @@ pub mod desc {
kind: VertexAttributeKind::U16,
},
VertexAttribute {
+ name: "aUnused",
+ count: 1,
+ kind: VertexAttributeKind::U16,
+ },
+ VertexAttribute {
name: "aFilterExtraDataAddress",
count: 2,
kind: VertexAttributeKind::U16,
@@ -809,7 +767,6 @@ pub mod desc {
pub enum VertexArrayKind {
Primitive,
Blur,
- ClipImage,
ClipRect,
ClipBoxShadow,
VectorStencil,
@@ -1038,7 +995,6 @@ pub struct RendererVAOs {
blur_vao: VAO,
clip_rect_vao: VAO,
clip_box_shadow_vao: VAO,
- clip_image_vao: VAO,
border_vao: VAO,
line_vao: VAO,
scale_vao: VAO,
@@ -1086,7 +1042,6 @@ impl RendererVAOs {
clip_rect_vao: device.create_vao_with_new_instances(&desc::CLIP_RECT, &prim_vao),
clip_box_shadow_vao: device
.create_vao_with_new_instances(&desc::CLIP_BOX_SHADOW, &prim_vao),
- clip_image_vao: device.create_vao_with_new_instances(&desc::CLIP_IMAGE, &prim_vao),
border_vao: device.create_vao_with_new_instances(&desc::BORDER, &prim_vao),
scale_vao: device.create_vao_with_new_instances(&desc::SCALE, &prim_vao),
line_vao: device.create_vao_with_new_instances(&desc::LINE, &prim_vao),
@@ -1109,7 +1064,6 @@ impl RendererVAOs {
device.delete_vao(self.resolve_vao);
device.delete_vao(self.clip_rect_vao);
device.delete_vao(self.clip_box_shadow_vao);
- device.delete_vao(self.clip_image_vao);
device.delete_vao(self.fast_linear_gradient_vao);
device.delete_vao(self.linear_gradient_vao);
device.delete_vao(self.radial_gradient_vao);
@@ -1131,7 +1085,6 @@ impl ops::Index<VertexArrayKind> for RendererVAOs {
fn index(&self, kind: VertexArrayKind) -> &VAO {
match kind {
VertexArrayKind::Primitive => &self.prim_vao,
- VertexArrayKind::ClipImage => &self.clip_image_vao,
VertexArrayKind::ClipRect => &self.clip_rect_vao,
VertexArrayKind::ClipBoxShadow => &self.clip_box_shadow_vao,
VertexArrayKind::Blur => &self.blur_vao,