Skip to content

Commit 50668f5

Browse files
author
david.algis
committed
♻️🚧 Update vertex buffer to fixed the problem of freeze
Now it's only a getData of one octet...
1 parent 8e55570 commit 50668f5

18 files changed

+67
-23
lines changed

InteropUnityCUDA/Assets/Actions/InteropHandlerSample.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class InteropHandlerSample : InteropHandler
3333
private RenderTexture _renderTextureForDisplay0;
3434
private RenderTexture _renderTextureForDisplay1;
3535
private ComputeBuffer _computeBuffer;
36-
private float4[] _cpuArray;
3736

3837
/// <summary>
3938
/// Create a render texture _sizeTexture x _sizeTexture with 4 channel and and set _renderTexture with it
@@ -107,7 +106,6 @@ private void CreateBuffer()
107106
//allocate memory for compute buffer
108107
_computeBuffer = new ComputeBuffer(_sizeBuffer, stride);
109108
_particlesDrawer.InitParticlesBuffer(_computeBuffer, _sizeBuffer, 0.1f);
110-
_cpuArray = new float4[_sizeBuffer];
111109
}
112110

113111
/// <summary>
Binary file not shown.
Binary file not shown.

InteropUnityCUDA/Assets/Plugin/PluginInteropUnityCUDA.exp.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

InteropUnityCUDA/Assets/Plugin/PluginInteropUnityCUDA.lib.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-14.5 KB
Binary file not shown.
244 Bytes
Binary file not shown.
410 Bytes
Binary file not shown.

InteropUnityCUDA/Assets/Utilities/ParticlesDrawer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ public void InitParticlesBuffer(ComputeBuffer computeBuffer, int nbrParticles, f
3131
_particlesSizeForRender = particlesSizeForRender;
3232

3333
_material.SetBuffer(_particlesProp, computeBuffer);
34+
x = new float4[_nbrParticles];
3435
}
3536

37+
private float4[] x;
3638
private void OnPostRender()
3739
{
3840
_material.SetPass(0);
3941
_material.SetBuffer(_particlesProp, _particlesComputeBuffer);
42+
_particlesComputeBuffer.GetData(x,0,0,1);
43+
4044
_material.SetFloat(_sizeParticles, _particlesSizeForRender);
4145
Graphics.DrawProceduralNow(MeshTopology.Points, _nbrParticles, 1);
4246
}

0 commit comments

Comments
 (0)