Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU cache invalidation fix and extra checks #2671

Merged
merged 3 commits into from Apr 18, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -24,6 +24,7 @@ use render_task::{RenderTaskAddress, RenderTaskId, RenderTaskKind, RenderTaskTre
use renderer::{BlendMode, ImageBufferKind};
use renderer::BLOCKS_PER_UV_RECT;
use resource_cache::{CacheItem, GlyphFetchResult, ImageRequest, ResourceCache};
use scene::FilterOpHelpers;
use std::{usize, f32, i32};
use tiling::{RenderTargetContext};
use util::{MatrixHelpers, TransformedRectKind};
@@ -598,6 +599,9 @@ impl AlphaBatchBuilder {
) {
let z = z_generator.next();
let prim_metadata = ctx.prim_store.get_metadata(prim_index);
#[cfg(debug_assertions)] //TODO: why is this needed?
debug_assert_eq!(prim_metadata.prepared_frame_id, render_tasks.frame_id());

let scroll_node = &ctx.node_data[scroll_id.0 as usize];
// TODO(gw): Calculating this for every primitive is a bit
// wasteful. We should probably cache this in
@@ -670,6 +674,7 @@ impl AlphaBatchBuilder {

let add_to_parent_pic = match picture.composite_mode {
Some(PictureCompositeMode::Filter(filter)) => {
assert!(filter.is_visible());
match filter {
FilterOp::Blur(..) => {
match picture.surface {
@@ -558,7 +558,10 @@ impl GpuCache {
pub fn invalidate(&mut self, handle: &GpuCacheHandle) {
if let Some(ref location) = handle.location {
let block = &mut self.texture.blocks[location.block_index.0];
block.epoch.next();
// don't invalidate blocks that are already re-assigned
if block.epoch == location.epoch {
block.epoch.next();
}
}
}

@@ -20,6 +20,8 @@ use gpu_cache::{GpuBlockData, GpuCache, GpuCacheAddress, GpuCacheHandle, GpuData
ToGpuBlocks};
use gpu_types::{ClipChainRectIndex};
use picture::{PictureCompositeMode, PictureId, PicturePrimitive};
#[cfg(debug_assertions)]
use render_backend::FrameId;
use render_task::{BlitSource, RenderTask, RenderTaskCacheKey};
use render_task::{RenderTaskCacheKeyKind, RenderTaskId, RenderTaskCacheEntryHandle};
use renderer::{MAX_VERTEX_TEXTURE_WIDTH};
@@ -191,6 +193,11 @@ pub struct PrimitiveMetadata {
/// A tag used to identify this primitive outside of WebRender. This is
/// used for returning useful data during hit testing.
pub tag: Option<ItemTag>,

/// The last frame ID (of the `RenderTaskTree`) this primitive
/// was prepared for rendering in.
#[cfg(debug_assertions)]
pub prepared_frame_id: FrameId,
}

#[derive(Debug)]
@@ -1083,6 +1090,8 @@ impl PrimitiveStore {
opacity: PrimitiveOpacity::translucent(),
prim_kind: PrimitiveKind::Brush,
cpu_prim_index: SpecificPrimitiveIndex(0),
#[cfg(debug_assertions)]
prepared_frame_id: FrameId(0),
};

let metadata = match container {
@@ -1167,6 +1176,11 @@ impl PrimitiveStore {
frame_state: &mut FrameBuildingState,
) {
let metadata = &mut self.cpu_metadata[prim_index.0];
#[cfg(debug_assertions)]
{
metadata.prepared_frame_id = frame_state.render_tasks.frame_id();
}

match metadata.prim_kind {
PrimitiveKind::Border => {}
PrimitiveKind::TextRun => {
@@ -142,6 +142,11 @@ impl RenderTaskTree {
self.next_saved.0 += 1;
id
}

#[cfg(debug_assertions)]
pub fn frame_id(&self) -> FrameId {
self.frame_id
}
}

impl ops::Index<RenderTaskId> for RenderTaskTree {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.