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

handle external raw buffer #776

Merged

Conversation

@JerryShih
Copy link
Contributor

JerryShih commented Jan 24, 2017

#723
@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].
  2. if the imageData is an external raw buffer, pass all parameters used by the utility function[1] to renderer. Then, replay that function at renderer with all passed parameters.
  3. at the renderer side, use ExternalImageHandler[2] 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


This change is Reviewable

@JerryShih JerryShih changed the title handle external raw buffer #723 handle external raw buffer Jan 24, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Jan 26, 2017

The latest upstream changes (presumably #750) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

kvark left a comment

Looks sane, thanks @JerryShih !
Need to clean up the change a bit before merging.

// 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>),

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

Can we use DeviceUintRect here?

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

@@ -342,10 +342,18 @@ pub enum RenderTargetMode {
}

pub enum TextureUpdateOp {
// Create(image.width, image.height, format, filter, mode, buffer)

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

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>>>,
}

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

// 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>),

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

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.

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

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.

[1]
https://github.com/JerryShih/webrender/blob/23123c85ddfccf4c458b9c3856890869644be667/webrender/src/device.rs#L804

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),

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

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.

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

@@ -594,6 +600,42 @@ impl TextureCache {
}
}

pub fn insert_image_border_updating_operation(src: &[u8],

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

I think we can shorten it out to just insert_image_border.

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

pub fn insert_image_border_updating_operation(src: &[u8],
alloc_x: u32,
alloc_y: u32,
alloc_width: u32,

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

let's use rectangles (DeviceUintRect) here for both the allocation and request regions

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

request_height: u32,
stride: Option<u32>,
bpp: u32,
op: &mut BorderUpdatingMethod) {

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

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.

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

checked

ImageData::ExternalBuffer(id) => {
match result.kind {
AllocationKind::TexturePage => {
let update_op = TextureUpdate {

This comment has been minimized.

@kvark

kvark Jan 26, 2017

Member

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);

This comment has been minimized.

@JerryShih

JerryShih Jan 28, 2017

Author Contributor

Please check whether if it's still a problem after reordering the match expressions in my new patch.

@glennw
Copy link
Member

glennw commented Jan 26, 2017

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).

@JerryShih
Copy link
Contributor Author

JerryShih commented Jan 28, 2017

I address all review comments after the commit [1].
If these patch sets look good, I will fix the conflicts to the latest revision of WR and do squash.

[1]
6baa756

@JerryShih
Copy link
Contributor Author

JerryShih commented Jan 28, 2017

@glennw @kvark
The new patches are ready.

@glennw
Copy link
Member

glennw commented Jan 31, 2017

Reviewed 4 of 7 files at r1, 1 of 3 files at r2, 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed.


Comments from Reviewable

@glennw
Copy link
Member

glennw commented Jan 31, 2017

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).

@JerryShih
Copy link
Contributor Author

JerryShih commented Jan 31, 2017

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…

checked

Done.


webrender/src/internal_types.rs, line 348 at r1 (raw file):

Previously, JerryShih (Jerry) wrote…

checked

Done.


webrender/src/texture_cache.rs, line 603 at r1 (raw file):

Previously, JerryShih (Jerry) wrote…

checked

Done.


webrender/src/texture_cache.rs, line 606 at r1 (raw file):

Previously, JerryShih (Jerry) wrote…

checked

Done.


webrender/src/texture_cache.rs, line 614 at r1 (raw file):

Previously, JerryShih (Jerry) wrote…

checked

Done.


Comments from Reviewable

JerryShih added 4 commits Jan 24, 2017
…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.
@JerryShih JerryShih force-pushed the JerryShih:issue-723-handle-external-raw-buffer-rebase branch from caeb847 to d7e6e83 Jan 31, 2017
@JerryShih
Copy link
Contributor Author

JerryShih commented Jan 31, 2017

This is the rebased and squashed commit.

The remaining issues are:
a) should we pass the bpp in textureOP? <= We need to have the additional accessor for bpp in device. Please check the comment in reviewable.
b) merge self.pending_updates() calls. <= I think it's merged right now.

@kvark @glennw

@kvark
kvark approved these changes Jan 31, 2017
Copy link
Member

kvark left a comment

Thanks @JerryShih !

@kvark
Copy link
Member

kvark commented Jan 31, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jan 31, 2017

📌 Commit d7e6e83 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Feb 1, 2017

Testing commit d7e6e83 with merge d119ded...

bors-servo added a commit that referenced this pull request Feb 1, 2017
…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 -->
@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 1, 2017

@bors-servo clean retry force

@bors-servo
Copy link
Contributor

bors-servo commented Feb 1, 2017

💥 Test timed out

@glennw
Copy link
Member

glennw commented Feb 1, 2017

@bors-servo retry

@glennw glennw closed this Feb 1, 2017
@glennw glennw reopened this Feb 1, 2017
@glennw
Copy link
Member

glennw commented Feb 1, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Feb 1, 2017

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: #802
@bors-servo
Copy link
Contributor

bors-servo commented Feb 1, 2017

📌 Commit d7e6e83 has been approved by glennw

@glennw glennw closed this Feb 1, 2017
@glennw glennw reopened this Feb 1, 2017
@glennw
Copy link
Member

glennw commented Feb 1, 2017

@bors-servo retry

@glennw
Copy link
Member

glennw commented Feb 2, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Feb 2, 2017

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: #768
@bors-servo
Copy link
Contributor

bors-servo commented Feb 2, 2017

📌 Commit d7e6e83 has been approved by glennw

@glennw
Copy link
Member

glennw commented Feb 2, 2017

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Feb 2, 2017

Testing commit d7e6e83 with merge feea6e0...

bors-servo added a commit that referenced this pull request Feb 2, 2017
…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 -->
@glennw
Copy link
Member

glennw commented Feb 2, 2017

Merging manually while bors is broken.

@glennw glennw merged commit ff3226f into servo:master Feb 2, 2017
2 of 4 checks passed
2 of 4 checks passed
code-review/reviewable 5 files, 7 discussions left (glennw, kvark)
Details
homu Testing commit d7e6e83 with merge feea6e0...
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bors-servo bors-servo mentioned this pull request Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.