Closed Bug 1155495 Opened 9 years ago Closed 9 years ago

refactor the part of android fence in TextureHostOGL

Categories

(Core :: Graphics: Layers, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: ethlin, Assigned: chenpighead)

References

(Blocks 1 open bug)

Details

(Whiteboard: [gfx-noted])

Attachments

(2 files, 5 obsolete files)

All functions and members in TextureHostOGL is for android fence. Each time using these functions will call AsHostOGL() to cast TextureHost to TextureHostOGL and check if the platform is WIDGE_GONK [1]. And there should be only GrallocTextureHost uses these members and functions.
I think there may be some way to refactor it to make the code more clear.

[1] https://dxr.mozilla.org/mozilla-central/source/gfx/layers/ipc/LayerTransactionParent.cpp#926
Whiteboard: [gfx-noted]
Jeremy, I think this is a good practice for you to study the gfx code flow related to textureclient/host
Flags: needinfo?(jeremychen)
Thank you, Peter. I'll study this once I finished my work in hand.
Flags: needinfo?(jeremychen)
Assignee: nobody → jeremychen
Depends on: 1155498
Remove TextureHostOGL class and integrate the Android platform specific version API into TextureHost class.
From part1 patch, we've removed TextureHostOGL class. So, we can Remove unnecessary class inheritance and class casting in the implementations.
Attachment #8604556 - Flags: feedback?(etlin)
Attachment #8604556 - Flags: feedback?(chung)
Attachment #8604558 - Flags: feedback?(etlin)
Attachment #8604558 - Flags: feedback?(chung)
Attachment #8604556 - Flags: feedback?(etlin)
Attachment #8604556 - Flags: feedback?(chung)
Attachment #8604558 - Flags: feedback?(etlin)
Attachment #8604558 - Flags: feedback?(chung)
Remove feedback request for now, cause I've got some feedback from Ethan.
Remove TextureHostOGL and integrate the Android platform specific version API into TextureHost.
Attachment #8604556 - Attachment is obsolete: true
Attachment #8607437 - Flags: feedback?(etlin)
From part1 patch, we've removed TextureHostOGL. So, we can Remove unnecessary class multi-inheritance and class casting in the implementations.
Attachment #8604558 - Attachment is obsolete: true
Attachment #8607441 - Flags: feedback?(etlin)
Comment on attachment 8607441 [details] [diff] [review]
Bug 1155495 - part2: Remove unnecessary class inheritance and casting. (v2)

Review of attachment 8607441 [details] [diff] [review]:
-----------------------------------------------------------------

It looks good to me.
Attachment #8607441 - Flags: feedback?(etlin) → feedback+
Comment on attachment 8607437 [details] [diff] [review]
Bug 1155495 - part1: Remove TextureHostOGL and integrate the platform specific API into TextureHost. (v2)

Review of attachment 8607437 [details] [diff] [review]:
-----------------------------------------------------------------

f+ if the comments are addressed.

::: gfx/layers/composite/TextureHost.cpp
@@ +165,5 @@
> +  return true;
> +}
> +
> +FenceHandle
> +TextureHost::GetAndResetReleaseFence()

Since there is already a function named GetAndResetReleaseFenceHandle, you may combine GetAndResetReleaseFenceHandle and GetAndResetReleaseFence in the TextureHost and remove the GetAndResetReleaseFenceHandle in GrallocTextureHost.

::: gfx/layers/composite/TextureHost.h
@@ +521,5 @@
> +  /**
> +   * Store a fence that will signal when the current buffer is no longer being read.
> +   * Similar to android's GLConsumer::setReleaseFence()
> +   */
> +  virtual bool SetReleaseFence(const FenceHandle& aReleaseFence);

We should unify the function name. Maybe this function name should be SetReleaseFenceHandle. And it doesn't need to be virtual.

@@ +526,5 @@
> +
> +  /**
> +   * Return a releaseFence's Fence and clear a reference to the Fence.
> +   */
> +  virtual FenceHandle GetAndResetReleaseFence();

Combine with GetAndResetReleaseFenceHandle and remove virtual.

@@ +528,5 @@
> +   * Return a releaseFence's Fence and clear a reference to the Fence.
> +   */
> +  virtual FenceHandle GetAndResetReleaseFence();
> +
> +  virtual void SetAcquireFence(const FenceHandle& aAcquireFence);

Ditto.

@@ +533,5 @@
> +
> +  /**
> +   * Return a acquireFence's Fence and clear a reference to the Fence.
> +   */
> +  virtual FenceHandle GetAndResetAcquireFence();

Ditto.

@@ +535,5 @@
> +   * Return a acquireFence's Fence and clear a reference to the Fence.
> +   */
> +  virtual FenceHandle GetAndResetAcquireFence();
> +
> +  virtual void WaitAcquireFenceSyncComplete();

Remove virtual.
Attachment #8607437 - Flags: feedback?(etlin) → feedback+
In part1 patch, I remove TextureHostOGL and integrate the platform specific API into TextureHost. GetAndResetReleaseFenceHandle and GetAndResetReleaseFence are combined to one unified version in the TextureHost. Function names with "Fence" are fixed with "FenceHandle", which is now agree with those in TextureClient.

In part2 patch, we no longer need multi-inheritance and AsHostOGL() for GrallocTextureHost to use the platform specific API anymore.

Hi Sotaro, could you review these two patches?
Attachment #8607999 - Flags: review?(sotaro.ikeda.g)
Attachment #8608001 - Flags: review?(sotaro.ikeda.g)
Comment on attachment 8607999 [details] [diff] [review]
Bug 1155495 - part1: (v3) Remove TextureHostOGL and integrate the platform specific API into TextureHost.

Review of attachment 8607999 [details] [diff] [review]:
-----------------------------------------------------------------

The implementation looks good. But TextureHost::WaitAcquireFenceHandleSyncComplete() is OpenGL specific. So, it is not clear for me that is OK to move the implementation from TextureHostOGL to TextureHost. Then, I forward the review to nical.
Attachment #8607999 - Flags: review?(sotaro.ikeda.g) → review?(nical.bugzilla)
Comment on attachment 8607999 [details] [diff] [review]
Bug 1155495 - part1: (v3) Remove TextureHostOGL and integrate the platform specific API into TextureHost.

Review of attachment 8607999 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/composite/TextureHost.cpp
@@ +180,5 @@
> +  return FenceHandle(fdObj);
> +}
> +
> +void
> +TextureHost::WaitAcquireFenceHandleSyncComplete()

Can this function's implementation be moved into FenceHandle? If it is done, we could remove dependence to EGL from TextureHost.
Comment on attachment 8607999 [details] [diff] [review]
Bug 1155495 - part1: (v3) Remove TextureHostOGL and integrate the platform specific API into TextureHost.

Review of attachment 8607999 [details] [diff] [review]:
-----------------------------------------------------------------

I like the idea of removing TextureHostOGL but let's not put EGL specific code in TextureHost. r+ if you implement sotaro's suggestion of abstracting away the EGL fence logic under FenceHandle or some kind of abstract fence.
Attachment #8607999 - Flags: review?(nical.bugzilla) → review-
If we put EGL fence logic into FenceHandle, would it affect the generality of FenceHandle? To remove dependence to EGL from TextureHost, could we set WaitAcquireFenceHandleSyncComplete() to virtual in TextureHost, and let GrallocTextureHost implement it? In that case, we could keep the generality of FenceHandle. We also could keep TextureHost away from platform specific code, and leave it to be implemented in any platform specific class.
Flags: needinfo?(sotaro.ikeda.g)
(In reply to Jeremy Chen [:jeremychen] from comment #16)
> To remove dependence to EGL from TextureHost, could we set
> WaitAcquireFenceHandleSyncComplete() to virtual in TextureHost, and let
> GrallocTextureHost implement it? In that case, we could keep the generality
> of FenceHandle.

Sounds good to me.
(In reply to Nicolas Silva [:nical] from comment #17)
> (In reply to Jeremy Chen [:jeremychen] from comment #16)
> > To remove dependence to EGL from TextureHost, could we set
> > WaitAcquireFenceHandleSyncComplete() to virtual in TextureHost, and let
> > GrallocTextureHost implement it? In that case, we could keep the generality
> > of FenceHandle.
> 
> Sounds good to me.

me too.
Flags: needinfo?(sotaro.ikeda.g)
Remove dependence to EGL from TextureHost. Set WaitAcquireFenceHandleSyncComplete() to virtual in TextureHost, and let GrallocTextureHost implement it.
Attachment #8607999 - Attachment is obsolete: true
Attachment #8609259 - Flags: review?(sotaro.ikeda.g)
Attachment #8609259 - Flags: review?(nical.bugzilla)
Attachment #8608001 - Flags: review?(nical.bugzilla)
Attachment #8609259 - Flags: review?(nical.bugzilla) → review+
Attachment #8608001 - Flags: review?(nical.bugzilla) → review+
Attachment #8608001 - Flags: review?(sotaro.ikeda.g) → review+
Attachment #8609259 - Flags: review?(sotaro.ikeda.g) → review+
try result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=c38b2d46d8cb

It looks positive except for Linux debug reftest R(R1), which has nothing to do with this patch but always timeout lately.
try result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ed51d0c3b74f

Linux debug reftest R(R1) still timeout, like other similar jobs.
(In reply to Jeremy Chen [:jeremychen] from comment #21)
> try result:
> https://treeherder.mozilla.org/#/jobs?repo=try&revision=ed51d0c3b74f
> 
> Linux debug reftest R(R1) still timeout, like other similar jobs.

Don't know why all B2G Desktop Linux x64 opt tests are showing exception now, while they were passed successfully before. Resend patches to try and wait for positive results. Clear checkin-needed keyword first.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: