Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: Blit two textures

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    29

    Blit two textures

    Seems like General is locked so I'll post it here:

    Currently in OpenGL to blit two textures the following has to be done (in pseudo-code):

    Code :
    glBindFramebuffer(GL_READ_FRAMEBUFFER, srcFb);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dstFb);
     
    if (stencil && depth) {
        glFramebufferTexture2D(src); // bind depth+stencil
        glFramebufferTexture2D(dst);
        glFramebufferTexture2D(src); // unbind color
        glFramebufferTexture2D(dst);
    } else if (depth) {
        glFramebufferTexture2D(...); // bind depth
        glFramebufferTexture2D(...); // unbind stencil
        glFramebufferTexture2D(...); // unbind color
        // ...
    } else if (stencil) {
        // same for stencil-only
    } else if (color) {
        // same for color-only
    }
     
    glBlitFramebuffers(...);
     
    // restore previous state if it's not DSA

    It's a bit of a boilerplate to do this for every time two textures have to be blitted.
    ARB_copy_image is nice but it doesn't allow texture resizing or flipping. Vulkan introduced `vkCmdBlitImage` which does pretty much the same but without using framebuffers (that here are just a dummy container instead of a real framebuffer).

    My suggestion is an API similar to this:
    Code :
    glBlitImages(
            GLuint srcTex,
      	GLuint dstTex,
      	GLint srcX0,
      	GLint srcY0,
      	GLint srcZ0,
      	GLint srcX1,
      	GLint srcY1,
      	GLint srcZ1,
      	GLint dstX0,
      	GLint dstY0,
      	GLint dstZ0,
      	GLint dstX1,
      	GLint dstY1,
      	GLint dstZ1,
            GLenum filter?);

    I'm probably skipping some variables that come into play here, but it's a template.


    Looking forward to your opinions about this!
    Last edited by rodrigoloc; 09-11-2018 at 11:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •