File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments