Marching-Cubes icon indicating copy to clipboard operation
Marching-Cubes copied to clipboard

blocking wait for GetComputeBufferData

Open SimLeek opened this issue 6 years ago • 6 comments

I've been trying to speed this thing up on my fork and render out further. Increasing the chunk size helps, but I noticed something in the performance window:

image

The main reason larger chunks take longer is because they take longer on the GPU. But the CPU and GPU are different devices, so they can operate concurrently. Unity has a function called AsyncGPUReadback that solves this, though it adds some latency. I think adding that to UpdateChunkMesh would work.

SimLeek avatar Jul 11 '19 07:07 SimLeek

It works, but not with collision meshes. Still good for clouds.

image

SimLeek avatar Jul 12 '19 04:07 SimLeek

How did you implement it?

michaelsakharov avatar Aug 11 '19 19:08 michaelsakharov

Er...

Here's my fork, though I may need to update it: https://github.com/SimLeek/Marching-Cubes

I tried to call replace the GPU functions with AsyncGPUReadback and other Async functions as much as possible, undoing a few times that broke things, and I found it works best for very, very large volumes, about 5-10x the size of a good value for the non-async chunks in each dimension.

SimLeek avatar Aug 14 '19 01:08 SimLeek

Yea the last update was Jul 3 and i dont see any signs of AsyncGPU. large scale voxels is what im working with, Im dealing with up to of 960 Chunks each one at 32x32x32 and updating them fairly frequently. I have got it running fairly smoothly but my attempts to intergrate Async Readback failed.

michaelsakharov avatar Aug 14 '19 06:08 michaelsakharov

Right. I'll add notes to my calendar to make sure I push that by Saturday then.

I believe I was able to do chunks with sizes 1024x1024x1024 iirc. Each one took a second or so to generate, and some didn't, but it still ended up with huge worlds.

SimLeek avatar Aug 14 '19 06:08 SimLeek

Here we go: https://github.com/SimLeek/Marching-Cubes/commit/b2a92dc8786d39f6e8da057565bcf8dfcea6a48e

Look for "blockingGpu"

SimLeek avatar Aug 17 '19 14:08 SimLeek