Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pixel-path performance warning: Pixel transfer is synchronized with 3D rendering

Tags:

c++

opengl

I am uploading image data into GL texture asynchronously.

In debug output I am getting these warnings during the rendering:

Source:OpenGL,type: Other, id: 131185, severity: Notification
Message: Buffer detailed info: Buffer object 1 (bound to GL_PIXEL_UNPACK_BUFFER_ARB, usage hint is GL_DYNAMIC_DRAW) has been mapped WRITE_ONLY in SYSTEM HEAP memory (fast). Source:OpenGL,type: Performance, id: 131154, severity: Medium Message: Pixel-path performance warning: Pixel transfer is synchronized with 3D rendering.

I can't see any wrong usage of PBOs in my case or any errors.So the questions is, if these warnings are safe to discard, or I am actually doing smth wrong.

My code for that part:

    //start copuying pixels into PBO from RAM:
    mPBOs[mCurrentPBO].Bind(GL_PIXEL_UNPACK_BUFFER);

    const uint32_t buffSize = pipe->GetBufferSize();
    GLubyte* ptr = (GLubyte*)mPBOs[mCurrentPBO].MapRange(0, buffSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
    if (ptr)
    {
        memcpy(ptr, pipe->GetBuffer(), buffSize);
        mPBOs[mCurrentPBO].Unmap();
    }

  //copy pixels from another already full PBO(except of first frame into texture //
    mPBOs[1 - mCurrentPBO].Bind(GL_PIXEL_UNPACK_BUFFER);
     //mCopyTex is bound to mCopyFBO as attachment
    glTextureSubImage2D(mCopyTex->GetHandle(), 0, 0, 0, mClientSize.x, mClientSize.y,
            GL_RGBA, GL_UNSIGNED_BYTE, 0);

    mCurrentPBO = 1 - mCurrentPBO;

Then I just blit the result to default frame buffer. No rendering of geometry or anything like that.

  glBlitNamedFramebuffer(
            mCopyFBO,
            0,//default FBO id
            0,
            0,
            mViewportSize.x,
            mViewportSize.y,
            0,
            0,
            mViewportSize.x,
            mViewportSize.y,
            GL_COLOR_BUFFER_BIT,
            GL_LINEAR);

Running on NVIDIA GTX 960 card.

like image 642
Michael IV Avatar asked Mar 19 '18 17:03

Michael IV


1 Answers

This performance warning is nividia-specific and it is intended as a hint to tell you that you're not going to use a separate hw transfer queue, which is no wonder since you use a single thread, single GL context model, where both rendering (at least your your blit) and transfer are carried out.

See this nvidia presentation for some details about how nvidia handles this. Page 22 also explains this specific warning. Note that this warnign does not mean that your transfer is not asynchronous. It is still fully asynchronous to the CPU thread. It will just be synchronously processed on the GPU, with respect to the render commands which are in the same command queue, and you're not using the asynchronous copy engine which could do these copies independent from the rendering commands in a separate command queue.

I can't see any wrong usage of PBOs in my case or any errors.So the questions is, if these warnings are safe to discard, or I am actually doing smth wrong.

There is nothing wrong with your PBO usage.

It is not clear if your specific application could even benefit from using a more elaborate separate transfer queue scheme.

like image 147
derhass Avatar answered Nov 06 '22 06:11

derhass