-
Hey everyone. I'm wondering when shader uniforms get uploaded to the GPU on the BGFX side. My setup looks like this: [unrelated dispatch] Maybe the uniform only gets updated later when a draw call is submitted or something? Am I missing something obvious? Edit: Also it seems to only happen in release builds. Hope you can help, Scewps |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
The best is to create simple repro case that demonstrates the issue you're having, instead explaining in text... |
Beta Was this translation helpful? Give feedback.
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…