I try to develop compute shader for Marching Cubes algorithm.
I setup all using Temaran guide GitHub - Temaran/UE4ShaderPluginDemo: A tutorial project that shows how to implement HLSL Pixel and Compute shaders in UE4
I successfully setup shader but have the problem data exchange between shader and C++ program.
I upload around 700 Mb voxel data to shader but when I try to get more 31 Kb data from shader I get only zeros. When I get less data, all fine.
I actually need to take more 10 Mb data back. How can I achieve this?
Data is stored in AppendStructuredBuffer and I copy it with this code:
srcPtr = (uint8*)RHILockStructuredBuffer(shaderOutDataBuffer, 0, sizeof(FOutTriangle) * total_size, EResourceLockMode::RLM_ReadOnly); // Reference pointer to first element for our destination ComputedColors uint8* dstPtr = (uint8*)_meshData.GetData(); // Copy from GPU to main memory FMemory::Memcpy(dstPtr, srcPtr, sizeof(FOutTriangle) * total_size); //Unlock texture RHIUnlockStructuredBuffer(shaderOutDataBuffer);
If total_size less than 450, all works fine but I have much more triangles in out.