• ccameron's avatar
    Add a glBegin/End pair to make glBindFramebuffer work · 4ff12a73
    ccameron authored
    It appears that this fixes the issue where rendered contents wouldn't
    appear on the screen. I say "it appears" because this bug is very
    difficult to repro, and so I can never say it's actually gone, just
    that I wasn't able to make it happen anymore.
    
    I can come up with a line of reasoning that the glBegin/End causes
    the driver to go and validate its internal state. Perhaps sometimes the
    dirty bit for the FBO is missed (and doing the glBegin/End immediately
    after changing the FBO ensure it's picked up). Ultimately it is just a
    guess.
    
    This workaround was discovered by accident through the following
    sequence of steps when debugging:
    1. Draw a triangle to the CAOpenGLLayer after drawing the texture, to
       ensure that we are actually getting draw calls
       - This appeared and kept updating even when the texture stopped
         updating
    2. Draw a triangle to the FBO's texture from the CAOpenGLLayer's
       context, to make sure changes to the texture would go through
       - This appeared and kept updating even when the textures topped
         updating (so it's probably a problem with the command buffer
         context).
    3. Draw a triangle to the FBO's texture from the command buffer's
       context just before glSwapBuffers
       - This triangle never appeared, so I tried the next experiment.
    4. Draw a triangle to the FBO's texture right after it is bound using
       glBindFramebufferEXT
       - Suddenly the bug went away (and I never saw the triangle, because
         it was drawn over).
    5. Just do a glBegin/End with program 0, since we found this was enough to
       work around driver bugs in the past.
       - Still couldn't repro the bug with this.
    
    BUG=435786
    
    Review URL: https://codereview.chromium.org/797533002
    
    Cr-Commit-Position: refs/heads/master@{#308166}
    4ff12a73
gl_surface.cc 9.44 KB