Skip to content

Commit f7b897e

Browse files
committed
fix AlembicPointsRenderer instance count issue
1 parent 20f9909 commit f7b897e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicPointsRenderer.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,22 @@ public void Flush()
233233
// update argument buffer
234234
if (m_cbArgs == null || m_cbArgs.Length != submeshCount)
235235
{
236-
m_cbArgs = new ComputeBuffer[submeshCount];
237-
for (int si = 0; si < submeshCount; ++si)
236+
if (m_cbArgs != null)
238237
{
239-
var cbArgs = new ComputeBuffer(1, m_args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);
240-
m_cbArgs[si] = cbArgs;
241-
m_args[0] = (int)mesh.GetIndexCount(si);
242-
m_args[1] = numInstances;
243-
cbArgs.SetData(m_args);
238+
foreach (var cb in m_cbArgs)
239+
cb.Release();
240+
m_cbArgs = null;
244241
}
242+
243+
m_cbArgs = new ComputeBuffer[submeshCount];
244+
for (int si = 0; si < submeshCount; ++si)
245+
m_cbArgs[si] = new ComputeBuffer(1, m_args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);
246+
}
247+
for (int si = 0; si < submeshCount; ++si)
248+
{
249+
m_args[0] = (int)mesh.GetIndexCount(si);
250+
m_args[1] = numInstances;
251+
m_cbArgs[si].SetData(m_args);
245252
}
246253

247254
// issue drawcalls

0 commit comments

Comments
 (0)