cginternals / gloperate

C++ library for defining and controlling modern GPU rendering/processing operations.
MIT License
43 stars 26 forks source link

Bind target FBO before blitting #423

Closed Tobias1595 closed 6 years ago

Tobias1595 commented 6 years ago

Prevents fatal error "INVALID_OPERATION: Draw buffer invalid" (even if operation succeeded anyway)

scheibel commented 6 years ago

Can you specify on which graphics card this error occurs? Internally, one three implementations is used for Framebuffer blitting:

  1. The legacy implementation, which calls
    
    sourceFbo->bind(GL_READ_FRAMEBUFFER);
    targetFbo->bind(GL_DRAW_FRAMEBUFFER);

glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, destX0, destY0, destX1, destY1, mask, filter);

2. The direct state access extension, implemented same as the legacy implementation: 
```cpp
sourceFbo->bind(GL_READ_FRAMEBUFFER);
targetFbo->bind(GL_DRAW_FRAMEBUFFER);

glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, destX0, destY0, destX1, destY1, mask, filter);
  1. Last, the direct state access ARB extension:
    glBlitNamedFramebuffer(sourceFbo->id(), targetFbo->id(), srcX0, srcY0, srcX1, srcY1, destX0, destY0, destX1, destY1, mask, filter);

    Only in the last case there is no explicit bind of the framebuffers (but there should be no need as their name is passed as parameters). There may be a difference between a framebuffer bound to GL_DRAW_FRAMEBUFFER and GL_FRAMEBUFFER (which should represent a framebuffer bound to both read and draw target), so this may be a driver bug or I misread some specification.

Tobias1595 commented 6 years ago

I'm currently using an nVidia GeForce GTX 1050 Ti, driver version 398.11 By stepping through I can confirm that the 3rd implementation (ARB extension) is used. The full error message (output by globjects) reads

#fatal: error: 0x502, high severity (API)
        GL_INVALID_OPERATION error generated. Draw buffer is invalid.
scheibel commented 6 years ago

Can you check if the PR https://github.com/cginternals/globjects/pull/371 fixes the issue? I'd prefer this over a fix here.