This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Render to portion of a frame

I am trying to render to just a rectangular portion of the frame. To my knowledge there are two options for this - glScissors and glViewport.

When profiling with DS-5 Streamline on both Mali-400 MP and Mali-450 MP, the number of rasterized fragments is always equal to the number of pixels in the frame. It does not matter if only a portion of the frame is specified. My understanding is, that the driver does not understand, that I have set glScissors or glViewport only once and the fragment shader still processes all pixels of the frame.

Does anyone know of a way to really render to just a portion of the frame?

To be more precise, I am rendering to a texture using OpenGL ES 2.0. I was thinking to attach just a part of the texture to the frame buffer, but I am not aware of any such functionality.

Parents
  • Below is a trace of the calls to OpenGL. Basically it draws into a texture one triangle that covers half of the viewport, which is 100x100. The whole texture is 1920x1200. The prior contents of the texture, where it is not drawn must be preserved, so glClear is not used. What I observe in streamline is that the total data written to and read from the bus is equal to the size in bytes of the whole buffer. This leads me to believe, that there is no optimization, where only the area under the viewport is rendered.

    1    glCreateShader    type=GL_VERTEX_SHADER

    null    glShaderSource    shader=1    count=1    string="attribute vec4 vPosition;

    void main()

    {

      gl_Position = vPosition;

    }

    "    length=0x0

    null    glCompileShader    shader=1

    null    glGetShaderiv    shader=1    pname=GL_COMPILE_STATUS    params=1

    2    glCreateShader    type=GL_FRAGMENT_SHADER

    null    glShaderSource    shader=2    count=1    string="precision mediump float;

    void main()

    {

      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

    }

    "    length=0x0

    null    glCompileShader    shader=2

    null    glGetShaderiv    shader=2    pname=GL_COMPILE_STATUS    params=1

    3    glCreateProgram

    null    glAttachShader    program=3    shader=1

    null    glAttachShader    program=3    shader=2

    null    glLinkProgram    program=3

    null    glGetProgramiv    program=3    pname=GL_LINK_STATUS    params=1

    0    glGetAttribLocation    program=3    name="vPosition"

    null    glViewport    x=0    y=0    width=100    height=100

    null    glGenFramebuffers    n=1    framebuffers=[1]

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=1

    null    glGenTextures    n=1    textures=[1]

    null    glBindTexture    target=GL_TEXTURE_2D    texture=1

    null    glTexImage2D    target=GL_TEXTURE_2D    level=0    internalformat=GL_RGBA    width=1920    height=1200    border=0    format=GL_RGBA    type=GL_UNSIGNED_BYTE    pixels=0x0

    null    glTexParameteri    target=GL_TEXTURE_2D    pname=GL_TEXTURE_MAG_FILTER    param=GL_NEAREST

    null    glTexParameteri    target=GL_TEXTURE_2D    pname=GL_TEXTURE_MIN_FILTER    param=GL_NEAREST

    null    glFramebufferTexture2D    target=GL_FRAMEBUFFER    attachment=GL_COLOR_ATTACHMENT0    textarget=GL_TEXTURE_2D    texture=1    level=0

    null    glBindTexture    target=GL_TEXTURE_2D    texture=0

    GL_FRAMEBUFFER_COMPLETE    glCheckFramebufferStatus    target=GL_FRAMEBUFFER

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=0

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=1

    null    glUseProgram    program=3

    null    glVertexAttribPointer    index=0    size=2    type=GL_FLOAT    normalized=GL_FALSE    stride=0    pointer=0x77d66e2c

    null    glEnableVertexAttribArray    index=0

    null    glDrawArrays    mode=GL_TRIANGLES    first=0    count=3

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=0

Reply
  • Below is a trace of the calls to OpenGL. Basically it draws into a texture one triangle that covers half of the viewport, which is 100x100. The whole texture is 1920x1200. The prior contents of the texture, where it is not drawn must be preserved, so glClear is not used. What I observe in streamline is that the total data written to and read from the bus is equal to the size in bytes of the whole buffer. This leads me to believe, that there is no optimization, where only the area under the viewport is rendered.

    1    glCreateShader    type=GL_VERTEX_SHADER

    null    glShaderSource    shader=1    count=1    string="attribute vec4 vPosition;

    void main()

    {

      gl_Position = vPosition;

    }

    "    length=0x0

    null    glCompileShader    shader=1

    null    glGetShaderiv    shader=1    pname=GL_COMPILE_STATUS    params=1

    2    glCreateShader    type=GL_FRAGMENT_SHADER

    null    glShaderSource    shader=2    count=1    string="precision mediump float;

    void main()

    {

      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

    }

    "    length=0x0

    null    glCompileShader    shader=2

    null    glGetShaderiv    shader=2    pname=GL_COMPILE_STATUS    params=1

    3    glCreateProgram

    null    glAttachShader    program=3    shader=1

    null    glAttachShader    program=3    shader=2

    null    glLinkProgram    program=3

    null    glGetProgramiv    program=3    pname=GL_LINK_STATUS    params=1

    0    glGetAttribLocation    program=3    name="vPosition"

    null    glViewport    x=0    y=0    width=100    height=100

    null    glGenFramebuffers    n=1    framebuffers=[1]

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=1

    null    glGenTextures    n=1    textures=[1]

    null    glBindTexture    target=GL_TEXTURE_2D    texture=1

    null    glTexImage2D    target=GL_TEXTURE_2D    level=0    internalformat=GL_RGBA    width=1920    height=1200    border=0    format=GL_RGBA    type=GL_UNSIGNED_BYTE    pixels=0x0

    null    glTexParameteri    target=GL_TEXTURE_2D    pname=GL_TEXTURE_MAG_FILTER    param=GL_NEAREST

    null    glTexParameteri    target=GL_TEXTURE_2D    pname=GL_TEXTURE_MIN_FILTER    param=GL_NEAREST

    null    glFramebufferTexture2D    target=GL_FRAMEBUFFER    attachment=GL_COLOR_ATTACHMENT0    textarget=GL_TEXTURE_2D    texture=1    level=0

    null    glBindTexture    target=GL_TEXTURE_2D    texture=0

    GL_FRAMEBUFFER_COMPLETE    glCheckFramebufferStatus    target=GL_FRAMEBUFFER

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=0

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=1

    null    glUseProgram    program=3

    null    glVertexAttribPointer    index=0    size=2    type=GL_FLOAT    normalized=GL_FALSE    stride=0    pointer=0x77d66e2c

    null    glEnableVertexAttribArray    index=0

    null    glDrawArrays    mode=GL_TRIANGLES    first=0    count=3

    null    glBindFramebuffer    target=GL_FRAMEBUFFER    framebuffer=0

Children
No data