Skip to content

Conversation

@JerryShih
Copy link
Contributor

@JerryShih 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

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

Copy link
Member

@kvark kvark left a 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.

// 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>),
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

}

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>),
Copy link
Member

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.

Copy link
Contributor Author

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.

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

// 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),
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

}
}

pub fn insert_image_border_updating_operation(src: &[u8],
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

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

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

Copy link
Contributor Author

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.

@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

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

@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

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 January 31, 2017 14:45
…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 issue-723-handle-external-raw-buffer-rebase branch from caeb847 to d7e6e83 Compare January 31, 2017 06:59
@JerryShih
Copy link
Contributor Author

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

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JerryShih !

@kvark
Copy link
Member

kvark commented Jan 31, 2017

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit d7e6e83 has been approved by kvark

@bors-servo
Copy link
Contributor

⌛ Testing commit d7e6e83 with merge d119ded...

bors-servo pushed 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

@bors-servo clean retry force

@bors-servo
Copy link
Contributor

💥 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 r+

@bors-servo
Copy link
Contributor

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

@bors-servo
Copy link
Contributor

📌 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 r+

@bors-servo
Copy link
Contributor

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

@bors-servo
Copy link
Contributor

📌 Commit d7e6e83 has been approved by glennw

@glennw
Copy link
Member

glennw commented Feb 2, 2017

@bors-servo retry

@bors-servo
Copy link
Contributor

⌛ Testing commit d7e6e83 with merge feea6e0...

bors-servo pushed 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
@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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants