Changeset 224207 in webkit


Ignore:
Timestamp:
Oct 30, 2017 3:43:56 PM (6 years ago)
Author:
jer.noble@apple.com
Message:

[WebGL] Optimization to skip painting if texture and source surface hasn't changed isn't working; re-optimize.
https://bugs.webkit.org/show_bug.cgi?id=178953

Reviewed by Dean Jackson.

The "seed" value of the current bound texture never matches the last saved value in
VideoTextureCopierCV::copyImageToPlatformTexture(). The value is modified by the function
itself, so a fresh value needs to be re-queried after the image's surface is attached to the
texture.

Once this fix is in, however, the <canvas> being painted will flash when no new image is
available. This is because the wrong texture target is being restored by the GC3DStateSaver
at the end of copyImageToPlatformTexture(). While we're fixing that, we may as well use the
texture state saved by the GraphicsContext3D itself to restore the correct texture unit,
texture target, and texture.

  • platform/graphics/GraphicsContext3D.h:

(WebCore::GraphicsContext3D::activeTextureUnit const):
(WebCore::GraphicsContext3D::currentBoundTexture const):
(WebCore::GraphicsContext3D::currentBoundTarget const):
(WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTexture const):
(WebCore::GraphicsContext3D::GraphicsContext3DState::boundTexture const):
(WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTarget const):
(WebCore::GraphicsContext3D::GraphicsContext3DState::boundTarget const):
(WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTexture): Deleted.
(WebCore::GraphicsContext3D::GraphicsContext3DState::boundTexture): Deleted.
(WebCore::GraphicsContext3D::GraphicsContext3DState::boundTarget): Deleted.

  • platform/graphics/cv/VideoTextureCopierCV.cpp:

(WebCore::VideoTextureCopierCV::copyImageToPlatformTexture):
(WebCore::VideoTextureCopierCV::GC3DStateSaver::GC3DStateSaver):
(WebCore::VideoTextureCopierCV::GC3DStateSaver::~GC3DStateSaver):

  • platform/graphics/cv/VideoTextureCopierCV.h:
  • platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:

(WebCore::GraphicsContext3D::prepareTexture):
(WebCore::GraphicsContext3D::activeTexture):
(WebCore::GraphicsContext3D::bindTexture):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224206 r224207  
     12017-10-30  Jer Noble  <jer.noble@apple.com>
     2
     3        [WebGL] Optimization to skip painting if texture and source surface hasn't changed isn't working; re-optimize.
     4        https://bugs.webkit.org/show_bug.cgi?id=178953
     5
     6        Reviewed by Dean Jackson.
     7
     8        The "seed" value of the current bound texture never matches the last saved value in
     9        VideoTextureCopierCV::copyImageToPlatformTexture(). The value is modified by the function
     10        itself, so a fresh value needs to be re-queried after the image's surface is attached to the
     11        texture.
     12
     13        Once this fix is in, however, the <canvas> being painted will flash when no new image is
     14        available. This is because the wrong texture target is being restored by the GC3DStateSaver
     15        at the end of copyImageToPlatformTexture(). While we're fixing that, we may as well use the
     16        texture state saved by the GraphicsContext3D itself to restore the correct texture unit,
     17        texture target, and texture.
     18
     19        * platform/graphics/GraphicsContext3D.h:
     20        (WebCore::GraphicsContext3D::activeTextureUnit const):
     21        (WebCore::GraphicsContext3D::currentBoundTexture const):
     22        (WebCore::GraphicsContext3D::currentBoundTarget const):
     23        (WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTexture const):
     24        (WebCore::GraphicsContext3D::GraphicsContext3DState::boundTexture const):
     25        (WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTarget const):
     26        (WebCore::GraphicsContext3D::GraphicsContext3DState::boundTarget const):
     27        (WebCore::GraphicsContext3D::GraphicsContext3DState::currentBoundTexture): Deleted.
     28        (WebCore::GraphicsContext3D::GraphicsContext3DState::boundTexture): Deleted.
     29        (WebCore::GraphicsContext3D::GraphicsContext3DState::boundTarget): Deleted.
     30        * platform/graphics/cv/VideoTextureCopierCV.cpp:
     31        (WebCore::VideoTextureCopierCV::copyImageToPlatformTexture):
     32        (WebCore::VideoTextureCopierCV::GC3DStateSaver::GC3DStateSaver):
     33        (WebCore::VideoTextureCopierCV::GC3DStateSaver::~GC3DStateSaver):
     34        * platform/graphics/cv/VideoTextureCopierCV.h:
     35        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
     36        (WebCore::GraphicsContext3D::prepareTexture):
     37        (WebCore::GraphicsContext3D::activeTexture):
     38        (WebCore::GraphicsContext3D::bindTexture):
     39
    1402017-10-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    241
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r223728 r224207  
    12861286    void setFailNextGPUStatusCheck() { m_failNextStatusCheck = true; }
    12871287
     1288    GC3Denum activeTextureUnit() const { return m_state.activeTextureUnit; }
     1289    GC3Denum currentBoundTexture() const { return m_state.currentBoundTexture(); }
     1290    GC3Denum currentBoundTarget() const { return m_state.currentBoundTarget(); }
    12881291    unsigned textureSeed(GC3Duint texture) { return m_state.textureSeedCount.count(texture); }
    12891292
     
    14321435    struct GraphicsContext3DState {
    14331436        GC3Duint boundFBO { 0 };
    1434         GC3Denum activeTexture { GraphicsContext3D::TEXTURE0 };
     1437        GC3Denum activeTextureUnit { GraphicsContext3D::TEXTURE0 };
    14351438
    14361439        using BoundTextureMap = HashMap<GC3Denum,
     
    14411444        >;
    14421445        BoundTextureMap boundTextureMap;
    1443         GC3Duint currentBoundTexture() { return boundTexture(activeTexture); }
    1444         GC3Duint boundTexture(GC3Denum textureUnit)
     1446        GC3Duint currentBoundTexture() const { return boundTexture(activeTextureUnit); }
     1447        GC3Duint boundTexture(GC3Denum textureUnit) const
    14451448        {
    14461449            auto iterator = boundTextureMap.find(textureUnit);
     
    14501453        }
    14511454
    1452         GC3Denum boundTarget(GC3Denum textureUnit)
     1455        GC3Duint currentBoundTarget() const { return boundTarget(activeTextureUnit); }
     1456        GC3Denum boundTarget(GC3Denum textureUnit) const
    14531457        {
    14541458            auto iterator = boundTextureMap.find(textureUnit);
  • trunk/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp

    r223974 r224207  
    518518
    519519    auto newSurfaceSeed = IOSurfaceGetSeed(surface);
    520     auto newTextureSeed = m_context->textureSeed(outputTexture);
    521520    if (flipY == m_lastFlipY
    522521        && surface == m_lastSurface
    523522        && newSurfaceSeed == m_lastSurfaceSeed
    524         && lastTextureSeed(outputTexture) == newTextureSeed) {
     523        && lastTextureSeed(outputTexture) == m_context->textureSeed(outputTexture)) {
    525524        // If the texture hasn't been modified since the last time we copied to it, and the
    526525        // image hasn't been modified since the last time it was copied, this is a no-op.
     
    620619    m_lastSurface = surface;
    621620    m_lastSurfaceSeed = newSurfaceSeed;
    622     m_lastTextureSeed.set(outputTexture, newTextureSeed);
     621    m_lastTextureSeed.set(outputTexture, m_context->textureSeed(outputTexture));
    623622    m_lastFlipY = flipY;
    624623
     
    724723    : m_context(context)
    725724{
    726     m_context.getIntegerv(GraphicsContext3D::TEXTURE_BINDING_2D, &m_texture);
     725    m_activeTextureUnit = m_context.activeTextureUnit();
     726    m_boundTarget = m_context.currentBoundTarget();
     727    m_boundTexture = m_context.currentBoundTexture();
    727728    m_context.getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &m_framebuffer);
    728729    m_context.getIntegerv(GraphicsContext3D::CURRENT_PROGRAM, &m_program);
     
    742743    m_context.vertexAttribPointer(m_vertexAttribIndex, m_vertexAttribSize, m_vertexAttribType, m_vertexAttribNormalized, m_vertexAttribStride, m_vertexAttribPointer);
    743744
    744     m_context.bindTexture(GraphicsContext3D::TEXTURE_BINDING_2D, m_texture);
     745    m_context.activeTexture(m_activeTextureUnit);
     746    m_context.bindTexture(m_boundTarget, m_boundTexture);
    745747    m_context.bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebuffer);
    746748    m_context.useProgram(m_program);
  • trunk/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.h

    r223315 r224207  
    6767    private:
    6868        GraphicsContext3D& m_context;
    69         GC3Dint m_texture { 0 };
     69        GC3Denum m_activeTextureUnit { 0 };
     70        GC3Denum m_boundTarget { 0 };
     71        GC3Denum m_boundTexture { 0 };
    7072        GC3Dint m_framebuffer { 0 };
    7173        GC3Dint m_program { 0 };
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r223887 r224207  
    263263    ::glActiveTexture(GL_TEXTURE0);
    264264    ::glBindTexture(GL_TEXTURE_2D, m_state.boundTarget(GL_TEXTURE0) == GL_TEXTURE_2D ? m_state.boundTexture(GL_TEXTURE0) : 0);
    265     ::glActiveTexture(m_state.activeTexture);
     265    ::glActiveTexture(m_state.activeTextureUnit);
    266266    if (m_state.boundFBO != m_fbo)
    267267        ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);
     
    453453{
    454454    makeContextCurrent();
    455     m_state.activeTexture = texture;
     455    m_state.activeTextureUnit = texture;
    456456    ::glActiveTexture(texture);
    457457}
     
    506506{
    507507    makeContextCurrent();
    508     m_state.setBoundTexture(m_state.activeTexture, texture, target);
     508    m_state.setBoundTexture(m_state.activeTextureUnit, texture, target);
    509509    ::glBindTexture(target, texture);
    510510}
Note: See TracChangeset for help on using the changeset viewer.