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

Trust image requests in their dirtyness and verify with an extra assertion #2829

Merged
merged 3 commits into from Jun 21, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Double check if a texture update is needed

  • Loading branch information
kvark committed Jun 19, 2018
commit 927f56c5f572c277ccec0d307428fe1849b12586
@@ -968,13 +968,6 @@ impl ResourceCache {

let clipped_tile_size = compute_tile_size(image_descriptor, tile_size, tile);

if let Some(dirty) = dirty_rect {
dirty_rect = intersect_for_tile(dirty, clipped_tile_size, tile_size, tile);
if dirty_rect.is_none() {
continue
}
}

// The tiled image could be stored on the CPU as one large image or be
// already broken up into tiles. This affects the way we compute the stride
// and offset.
@@ -1028,6 +1021,15 @@ impl ResourceCache {
};

let entry = self.cached_images.get_mut(&request).as_mut().unwrap();
if cfg!(debug_assertions) {
// confirm that we agree with the logic in `request_image` here, in debug builds only
if let (Some(tile), Some(dirty)) = (request.tile, dirty_rect) {
let needs_upload = self.texture_cache.needs_upload(&entry.texture_cache_handle);
let intersection = intersect_for_tile(dirty, descriptor.size, image_template.tiling.unwrap(), tile);
debug_assert!(needs_upload || intersection.is_some());
}
}

self.texture_cache.update(
&mut entry.texture_cache_handle,
descriptor,
@@ -380,6 +380,16 @@ impl TextureCache {
}
}

// Returns true if the image needs to be uploaded to the
// texture cache (either never uploaded, or has been
// evicted on a previous frame).
pub fn needs_upload(&self, handle: &TextureCacheHandle) -> bool {
match handle.entry {
Some(ref handle) => self.entries.get_opt(handle).is_none(),
None => true,
}
}

pub fn max_texture_size(&self) -> u32 {
self.max_texture_size
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.