bgfx/examples/41-tess/cs_terrain_update_indirect.sc
Бранимир Караџић 267269f01b Cleanup.
2019-07-21 22:02:07 -07:00

24 lines
527 B
Python

#include "bgfx_compute.sh"
#include "uniforms.sh"
BUFFER_RW(indirectBuffer, uvec4, 3);
BUFFER_RW(atomicCounterBuffer, uint, 4);
NUM_THREADS(1u, 1u, 1u)
void main()
{
uint counter;
uint counter2;
atomicFetchAndExchange(atomicCounterBuffer[0], 0u, counter);
atomicFetchAndExchange(atomicCounterBuffer[1], 0u, counter2);
uint cnt = (counter / 2u) / UPDATE_INDIRECT_VALUE_DIVIDE + 1u;
uint tmp;
atomicFetchAndExchange(atomicCounterBuffer[2], (counter / 2), tmp);
dispatchIndirect(indirectBuffer, 1u, cnt, 1u, 1u);
}