Bug 87725 - GraphicsSurface: allow importing and exporting of textures directly on GPU side.
Summary: GraphicsSurface: allow importing and exporting of textures directly on GPU side.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zeno Albisser
URL:
Keywords:
Depends on:
Blocks: 86214 87738
  Show dependency treegraph
 
Reported: 2012-05-29 03:58 PDT by Zeno Albisser
Modified: 2012-05-30 15:44 PDT (History)
7 users (show)

See Also:


Attachments
patch for review. (5.82 KB, patch)
2012-05-29 04:07 PDT, Zeno Albisser
noam: review-
Details | Formatted Diff | Diff
patch for review. - fixed issues as commented before. (5.81 KB, patch)
2012-05-29 07:14 PDT, Zeno Albisser
noam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zeno Albisser 2012-05-29 03:58:45 PDT
Add API to GraphicsSurface to allow reading in a texture directly from an FBO.
Further we should have a possibility to export a texture ID, so that the texture can directly be rebound in the GPU.
These changes should make the transferring of the texture from the UIProcess to the WebProcess much faster.
This is in particular necessary for WebGL.
Comment 1 Zeno Albisser 2012-05-29 04:07:30 PDT
Created attachment 144508 [details]
patch for review.
Comment 2 Kenneth Rohde Christiansen 2012-05-29 05:24:23 PDT
Up for review?
Comment 3 Zeno Albisser 2012-05-29 05:33:28 PDT
(In reply to comment #2)
> Up for review?

absolutely... if you have time. :)
Comment 4 Kenneth Rohde Christiansen 2012-05-29 05:43:57 PDT
Comment on attachment 144508 [details]
patch for review.

View in context: https://bugs.webkit.org/attachment.cgi?id=144508&action=review

> Source/WebCore/ChangeLog:9
> +        This allows binding/blitting the texture directly in the GPU.

on* ?

> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h:67
> +    void copyFromFramebuffer(uint32_t fbo, const IntRect& sourceRect);

FrameBuffer ? what is used elsewhere?

> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h:69
>      uint32_t exportToken();
> +    uint32_t exportTexture();

What does the exportToken do? Isn't it also like a texture id ?

> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:94
> +void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect)

Maybe FrameBufferObject? fbo?

> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:101
> +    glPushAttrib(GL_ALL_ATTRIB_BITS);
> +    if (!m_texture)
> +        m_texture = createTexture(m_platformSurface);
> +    if (!m_fbo)
> +        glGenFramebuffers(1, &m_fbo);
> +    GLint oldFBO;

I like newlines before and after if clauses
Comment 5 Noam Rosenthal 2012-05-29 06:03:52 PDT
Comment on attachment 144508 [details]
patch for review.

View in context: https://bugs.webkit.org/attachment.cgi?id=144508&action=review

Good direction, let's fix the nitpicks :)

> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp:49
> +uint32_t GraphicsSurface::exportTexture()

Let's call it getTextureID(). export is for cross-process sharing.

>> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h:69
>> +    uint32_t exportTexture();
> 
> What does the exportToken do? Isn't it also like a texture id ?

exportToken is a cross-process number that can mean anything.
Comment 6 Zeno Albisser 2012-05-29 07:12:24 PDT
Comment on attachment 144508 [details]
patch for review.

View in context: https://bugs.webkit.org/attachment.cgi?id=144508&action=review

>> Source/WebCore/ChangeLog:9
>> +        This allows binding/blitting the texture directly in the GPU.
> 
> on* ?

fixed.

>> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp:49
>> +uint32_t GraphicsSurface::exportTexture()
> 
> Let's call it getTextureID(). export is for cross-process sharing.

fixed.

>> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h:67
>> +    void copyFromFramebuffer(uint32_t fbo, const IntRect& sourceRect);
> 
> FrameBuffer ? what is used elsewhere?

The abbreviation fbo is used quite frequently in GraphicsContext3DQt/GraphicsContext3DOpenGLCommon. I think FBO is quite well known in this "context".

>>> Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h:69
>>> +    uint32_t exportTexture();
>> 
>> What does the exportToken do? Isn't it also like a texture id ?
> 
> exportToken is a cross-process number that can mean anything.

In this specific case, the token identifies a GraphicsSurface, where the texture is a texture id that can be used directly with GL on the GPU.
I renamed "exportTexture" to "getTextureID" as proposed by Noam.

>> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:94
>> +void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect)
> 
> Maybe FrameBufferObject? fbo?

dito.

>> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:101
>> +    GLint oldFBO;
> 
> I like newlines before and after if clauses

I don't, for single lines in a small function. :-$
Comment 7 Zeno Albisser 2012-05-29 07:14:36 PDT
Created attachment 144552 [details]
patch for review. - fixed issues as commented before.
Comment 8 Simon Fraser (smfr) 2012-05-30 09:57:55 PDT
This patch is changing GraphicsSurfaceMac.cpp, but how is it used? I don't think Mac even uses GraphicsSurface* anywhere.
Comment 9 Zeno Albisser 2012-05-30 10:33:42 PDT
(In reply to comment #8)
> This patch is changing GraphicsSurfaceMac.cpp, but how is it used? I don't think Mac even uses GraphicsSurface* anywhere.
As far as i know GraphicsSurfaceMac is currently only used by the Qt port. (when compiling Qt/WebKit for Mac)
Comment 10 Noam Rosenthal 2012-05-30 11:02:13 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > This patch is changing GraphicsSurfaceMac.cpp, but how is it used? I don't think Mac even uses GraphicsSurface* anywhere.
> As far as i know GraphicsSurfaceMac is currently only used by the Qt port. (when compiling Qt/WebKit for Mac)

It's a question I have.
GraphicsSurfaceMac is Mac-specific code, but we only use it in Qt.
There's nothing in the code that's Qt specific, but it's not used by "the mac port".
What would be the way to go about files like that? I want to do the right thing but I don't have a strong opinion other way.
Comment 11 Noam Rosenthal 2012-05-30 11:26:30 PDT
Comment on attachment 144552 [details]
patch for review. - fixed issues as commented before.

View in context: https://bugs.webkit.org/attachment.cgi?id=144552&action=review

> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:22
> +#include "GraphicsContext3D.h"

What is this for?
Comment 12 Zeno Albisser 2012-05-30 13:39:06 PDT
Comment on attachment 144552 [details]
patch for review. - fixed issues as commented before.

View in context: https://bugs.webkit.org/attachment.cgi?id=144552&action=review

>> Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:22
>> +#include "GraphicsContext3D.h"
> 
> What is this for?

I'll remove it.
Thanks for reviewing. :-)
Comment 13 Zeno Albisser 2012-05-30 15:44:05 PDT
Committed r118987: <http://trac.webkit.org/changeset/118987>