Skip to content

When do shader uniform values get uploaded compared to compute shader dispatch? #3291

Answered by scewpsdev
scewpsdev asked this question in Q&A
Discussion options

You must be logged in to vote

Another update. I've pinpointed the issue.
What was happening was that the uniform wasnt one frame delayed, the dynamic vertex buffer update was one frame too early.
Usually the buffer update is written to the command buffer m_submit->m_cmdPre, and only after the frame swap it reaches the render thread and is uploaded together with the constant buffers.
However the command buffer takes the memory by reference, and since I'm using makeRef the memory is never copied:
bgfx::update(lightBuffer, 0, bgfx::makeRef(lightBufferData, numVisibleLights * 2 * sizeof(Vector4)));
Since I preallocated and reuse the data array which I'm passing to the buffer, writing to it also affects the reference store…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@bkaradzic
Comment options

@scewpsdev
Comment options

@scewpsdev
Comment options

@scewpsdev
Comment options

Answer selected by scewpsdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants