-
Notifications
You must be signed in to change notification settings - Fork 282
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
Remove ResourceList structure and usage. #523
Conversation
Note: Let's get #512 reviewed and merged before landing this (and I'll rebase mine on top of it). This can still be reviewed now though :) |
if let Some(address) = metadata.clip_index { | ||
let clip = self.gpu_data32.get_slice_mut(address, 6); | ||
let old = clip[5].data; //TODO: avoid retaining the screen rectangle | ||
clip[5] = GpuBlock32::from(ImageMaskInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point I'd like to factor all these indices out into constants. (You don't have to do this now)
Maybe we could even make macros to make this stuff easier.
&text.glyph_indices, |index, uv0, uv1| { | ||
let dest_glyph = &mut dest_glyphs[index]; | ||
let dest: &mut GlyphPrimitive = unsafe { | ||
mem::transmute(dest_glyph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this transmute for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing data is a GpuBlock32 - I need to access it as the original type, in order to modify some fields of it. Is there a better way to express this (the From trait is used to create the GpuBlock32 initially)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got a few notes, otherwise looks good!
Size2D::new(old[6], old[7])), | ||
}); | ||
} | ||
resource_cache.request_image(mask_key, ImageRendering::Auto); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a next step, I suppose moving the request_*
logic out of ResourceCache
into a separate type/interface, to be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, agreed.
@@ -27,11 +26,24 @@ use webrender_traits::{GlyphDimensions, PipelineId, WebGLContextId}; | |||
|
|||
thread_local!(pub static FONT_CONTEXT: RefCell<FontContext> = RefCell::new(FontContext::new())); | |||
|
|||
pub struct CacheItem { | |||
pub texture_id: TextureId, | |||
pub uv0: Point2D<f32>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to specify that this is in texels, not actual normalized UVs, either by better naming, typing, or just comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment explaining that it is in texels, and why.
} | ||
|
||
enum ResourceRequest { | ||
Image(ImageResourceRequest), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer to just have Image(ImageKey, ImageRendeing)
, since ImageResourceRequest
is not used in any other context anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pub struct ResourceCache { | ||
cached_glyphs: ResourceClassCache<GlyphKey, Option<TextureCacheItemId>>, | ||
cached_images: ResourceClassCache<(ImageKey, ImageRendering), CachedImageInfo>, | ||
|
||
// TODO(pcwalton): Figure out the lifecycle of these. | ||
webgl_textures: HashMap<WebGLContextId, TextureId, BuildHasherDefault<FnvHasher>>, | ||
webgl_textures: HashMap<WebGLContextId, (TextureId, Size2D<i32>), BuildHasherDefault<FnvHasher>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This asks for a new type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pub fn request_image(&mut self, | ||
key: ImageKey, | ||
rendering: ImageRendering) { | ||
debug_assert!(self.state == State::AddResources); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will be converted to a type system rule/restriction later on
let uv1 = Point2D::new(cache_item.pixel_rect.bottom_right.x as f32, | ||
cache_item.pixel_rect.bottom_right.y as f32); | ||
f(loop_index, uv0, uv1); | ||
texture_id = cache_item.texture_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this texture_id
guaranteed to be the same for all glyphs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
layer_store: &'a Vec<StackingContext>, | ||
prim_store: &'a PrimitiveStore, | ||
render_task_id_counter: AtomicUsize, | ||
} | ||
|
||
struct RenderTargetContext<'a> { | ||
layer_store: &'a Vec<StackingContext>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use &'a [StackingContext]
? I think that would reduce the indirections on access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
color: color, | ||
// Build list of passes, target allocs that each tile needs. | ||
for screen_tile in screen_tiles { | ||
let rect = screen_tile.rect; // TODO(gw): Remove clone here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the clone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed comment
☔ The latest upstream changes (presumably #519) made this pull request unmergeable. Please resolve the merge conflicts. |
Previously, a resource list would be built at the start of the frame. This would allow glyphs missing from the texture cache to be rasterized. However, sometimes (e.g. with subpixel antialiasing) it's not possible to know right at the start of the frame exactly what needs to be rasterized yet. Instead, we now allow the resource cache to add requests during the prepare_prim_for_render() stage. Primitives that request resources are marked as needing a resolve operation. This allows primitives that request resources to update their UV coords etc before batching occurs (since texture IDs for resources must be known before batching can occur). This also lays most of the groundwork for running the resource cache rasterizer as a separate thread in the future. This will be used to ensure that if too many glyphs are requested in one frame, WR can continue running without blocking, using older glyphs and then re-render the scene when newer, high resolution glyphs are available.
In that case, you may add an assert to enforce this
|
e27cb5c
to
17a3629
Compare
@bors-servo: r+ |
📌 Commit 17a3629 has been approved by |
Remove ResourceList structure and usage. Previously, a resource list would be built at the start of the frame. This would allow glyphs missing from the texture cache to be rasterized. However, sometimes (e.g. with subpixel antialiasing) it's not possible to know right at the start of the frame exactly what needs to be rasterized yet. Instead, we now allow the resource cache to add requests during the prepare_prim_for_render() stage. Primitives that request resources are marked as needing a resolve operation. This allows primitives that request resources to update their UV coords etc before batching occurs (since texture IDs for resources must be known before batching can occur). This also lays most of the groundwork for running the resource cache rasterizer as a separate thread in the future. This will be used to ensure that if too many glyphs are requested in one frame, WR can continue running without blocking, using older glyphs and then re-render the scene when newer, high resolution glyphs are available. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/523) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
kvark has make several important contributions to webrender, both as a reviewer and committer. He also has significant Rust experience previously as the author of gfx-rs. Some examples of recent reviews: servo/webrender#546 servo/webrender#523 servo/webrender#561 servo/webrender#554
[Proposal] Give @kvark reviewer privileges. kvark has make several important contributions to webrender, both as a reviewer and committer. He also has significant Rust experience previously as the author of gfx-rs. Some examples of recent reviews: servo/webrender#546 servo/webrender#523 servo/webrender#561 servo/webrender#554 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/551) <!-- Reviewable:end -->
kvark has make several important contributions to webrender, both as a reviewer and committer. He also has significant Rust experience previously as the author of gfx-rs. Some examples of recent reviews: servo/webrender#546 servo/webrender#523 servo/webrender#561 servo/webrender#554
kvark has make several important contributions to webrender, both as a reviewer and committer. He also has significant Rust experience previously as the author of gfx-rs. Some examples of recent reviews: servo/webrender#546 servo/webrender#523 servo/webrender#561 servo/webrender#554
Previously, a resource list would be built at the start of the
frame. This would allow glyphs missing from the texture cache
to be rasterized.
However, sometimes (e.g. with subpixel antialiasing) it's not possible
to know right at the start of the frame exactly what needs to be
rasterized yet.
Instead, we now allow the resource cache to add requests during
the prepare_prim_for_render() stage. Primitives that request
resources are marked as needing a resolve operation. This allows
primitives that request resources to update their UV coords etc
before batching occurs (since texture IDs for resources must be
known before batching can occur).
This also lays most of the groundwork for running the resource
cache rasterizer as a separate thread in the future. This will be
used to ensure that if too many glyphs are requested in one frame,
WR can continue running without blocking, using older glyphs and
then re-render the scene when newer, high resolution glyphs are
available.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)