-
Notifications
You must be signed in to change notification settings - Fork 306
handle external raw buffer #776
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
handle external raw buffer #776
Conversation
|
☔ The latest upstream changes (presumably #750) made this pull request unmergeable. Please resolve the merge conflicts. |
kvark
left a comment
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.
Looks sane, thanks @JerryShih !
Need to clean up the change a bit before merging.
webrender/src/internal_types.rs
Outdated
| // UpdateExternalBuffer(alloc.x, alloc.y, alloc.width, alloc.height, | ||
| // request.x, request.y, request.width, request.height, | ||
| // external_image_id, bpp, stride) | ||
| UpdateForExternalBuffer(u32, u32, u32, u32, u32, u32, u32, u32, ExternalImageId, u32, Option<u32>), |
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.
Can we use DeviceUintRect 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.
checked
webrender/src/internal_types.rs
Outdated
| } | ||
|
|
||
| pub enum TextureUpdateOp { | ||
| // Create(image.width, image.height, format, filter, mode, buffer) |
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 believe, a better option than doing comments in this style is to use stronger types and/or the named fields, which are self-descriptive. E.g:
Create {
width: u32,
height: u32,
format: ImageFormat,
filter: TextureFilter,
mode: RenderTargetMode,
buffer: Option<Arc<Vec<u8>>>,
}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.
checked
webrender/src/internal_types.rs
Outdated
| // UpdateExternalBuffer(alloc.x, alloc.y, alloc.width, alloc.height, | ||
| // request.x, request.y, request.width, request.height, | ||
| // external_image_id, bpp, stride) | ||
| UpdateForExternalBuffer(u32, u32, u32, u32, u32, u32, u32, u32, ExternalImageId, u32, Option<u32>), |
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.
Do we have to pass the bpp with the update? It seems to me that this should be derived from the ImageFormat, which is either taken from the (already created) texture info.
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.
If we try to find the texture info at renderer, we should reference to the texture structure in device[1]. Then, we need to have additional accessor for this texture structure and a bpp calculation function in render or device. Just pass a bpp is the simplest way.
webrender/src/internal_types.rs
Outdated
| // Create(image.width, image.height, format, filter, mode, buffer) | ||
| Create(u32, u32, ImageFormat, TextureFilter, RenderTargetMode, Option<Arc<Vec<u8>>>), | ||
| // Create(image.width, image.height, format, filter, mode, external_image_id) | ||
| CreateForExternalBuffer(u32, u32, ImageFormat, TextureFilter, RenderTargetMode, ExternalImageId), |
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.
It looks like the handling of Create versus CreateForExternalBuffer shares a lot of code. I think it would be cleaner to merge those by just having Option<ImageData> as the last parameter.
The Update cases are much different though, so it's reasonable to keep them separate.
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.
checked
webrender/src/texture_cache.rs
Outdated
| } | ||
| } | ||
|
|
||
| pub fn insert_image_border_updating_operation(src: &[u8], |
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 we can shorten it out to just insert_image_border.
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.
checked
webrender/src/texture_cache.rs
Outdated
| pub fn insert_image_border_updating_operation(src: &[u8], | ||
| alloc_x: u32, | ||
| alloc_y: u32, | ||
| alloc_width: u32, |
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.
let's use rectangles (DeviceUintRect) here for both the allocation and request regions
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.
checked
webrender/src/texture_cache.rs
Outdated
| request_height: u32, | ||
| stride: Option<u32>, | ||
| bpp: u32, | ||
| op: &mut BorderUpdatingMethod) { |
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.
Let's pass this in as a closure. You only use it with temporary structs anyway, and using a closure would remove a lot of boilerplate.
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.
checked
webrender/src/texture_cache.rs
Outdated
| ImageData::ExternalBuffer(id) => { | ||
| match result.kind { | ||
| AllocationKind::TexturePage => { | ||
| let update_op = TextureUpdate { |
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.
let's move the assignment and self.pending_updates population to after the match, as in:
let update_op = match result.kind {...};
self.pending_updates(update_op);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.
Please check whether if it's still a problem after reordering the match expressions in my new patch.
|
These changes look good to me once the comments from @kvark are resolved. The texture cache in general could do with some refactoring and cleanup, but that can happen later (and include the improved ideas for border updating). |
|
Reviewed 4 of 7 files at r1, 1 of 3 files at r2, 2 of 2 files at r3. Comments from Reviewable |
|
This looks good - let's get it rebased and squashed, then we should be ready for merge (@kvark may want to do a final pass over it too). |
|
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. webrender/src/internal_types.rs, line 345 at r1 (raw file): Previously, JerryShih (Jerry) wrote…
Done. webrender/src/internal_types.rs, line 348 at r1 (raw file): Previously, JerryShih (Jerry) wrote…
Done. webrender/src/texture_cache.rs, line 603 at r1 (raw file): Previously, JerryShih (Jerry) wrote…
Done. webrender/src/texture_cache.rs, line 606 at r1 (raw file): Previously, JerryShih (Jerry) wrote…
Done. webrender/src/texture_cache.rs, line 614 at r1 (raw file): Previously, JerryShih (Jerry) wrote…
Done. Comments from Reviewable |
…ge buffer. Turn to use named field in TextureUpdateOp enum. Defer texture_cache updating command.
Read the external raw buffer using ExternalImageHandler. Upload the external raw buffer into texture.
caeb847 to
d7e6e83
Compare
kvark
left a comment
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.
Thanks @JerryShih !
|
@bors-servo r+ |
|
📌 Commit d7e6e83 has been approved by |
…ebase, r=kvark handle external raw buffer @nical @glennw @kvark Here are the patch sets to support external raw buffer. What I do here are: 1) extract texture border updating into utility function[[1]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603). 2) if the imageData is an external raw buffer, pass all parameters used by the utility function[[1]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603) to renderer. Then, replay that function at renderer with all passed parameters. 3) at the renderer side, use ExternalImageHandler[[2]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-f5062b694b9fe53fc1757ed483d577d9R959) to get the external buffer from WR client. [1] https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603 [2] https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-f5062b694b9fe53fc1757ed483d577d9R959 <!-- 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/776) <!-- Reviewable:end -->
|
@bors-servo clean retry force |
|
💥 Test timed out |
|
@bors-servo retry |
|
@bors-servo r+ |
|
💡 This pull request was already approved, no need to approve it again.
|
|
📌 Commit d7e6e83 has been approved by |
|
@bors-servo retry |
|
@bors-servo r+ |
|
💡 This pull request was already approved, no need to approve it again.
|
|
📌 Commit d7e6e83 has been approved by |
|
@bors-servo retry |
…ebase, r=glennw handle external raw buffer @nical @glennw @kvark Here are the patch sets to support external raw buffer. What I do here are: 1) extract texture border updating into utility function[[1]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603). 2) if the imageData is an external raw buffer, pass all parameters used by the utility function[[1]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603) to renderer. Then, replay that function at renderer with all passed parameters. 3) at the renderer side, use ExternalImageHandler[[2]](https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-f5062b694b9fe53fc1757ed483d577d9R959) to get the external buffer from WR client. [1] https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603 [2] https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-f5062b694b9fe53fc1757ed483d577d9R959 <!-- 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/776) <!-- Reviewable:end -->
|
Merging manually while bors is broken. |
#723
@nical @glennw @kvark
Here are the patch sets to support external raw buffer.
What I do here are:
[1]
https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-d52ac938b0c681e0d7bb3f946e47489fR603
[2]
https://github.com/servo/webrender/compare/master...JerryShih:issue-723-handle-external-raw-buffer-rebase?expand=1#diff-f5062b694b9fe53fc1757ed483d577d9R959
This change is