MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / PostSim

Method PostSim

Source/Engine/Particles/Graph/GPU/GPUParticles.cpp:279–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279void GPUParticles::PostSim(GPUContext* context, ParticleEmitter* emitter, ParticleEffect* effect, int32 emitterIndex, ParticleEmitterInstance& data)
280{
281 const uint32 counterOffset = data.Buffer->GPU.ParticleCounterOffset;
282
283 // Copy custom data
284 for (int32 i = 0; i < CustomDataSize; i += 4)
285 {
286 const uint32 offset = counterOffset + 4 + i * 4;
287 context->CopyBuffer(data.Buffer->GPU.Buffer, data.Buffer->GPU.BufferSecondary, 4, offset, offset);
288 }
289
290 // Update state
291 data.Buffer->GPU.ParticlesCountMax = Math::Min(data.Buffer->GPU.ParticlesCountMax + data.GPU.SpawnCount, data.Buffer->Capacity);
292 data.Buffer->GPU.HasValidCount = true;
293 data.GPU.DeltaTime = 0.0f;
294 data.GPU.SpawnCount = 0;
295
296 // Swap particle buffers
297 Swap(data.Buffer->GPU.Buffer, data.Buffer->GPU.BufferSecondary);
298
299 // Copy particles count if need to
300 if (effect->Instance.GPUParticlesCountReadback && effect->Instance.GPUParticlesCountReadback->IsAllocated())
301 {
302 context->CopyBuffer(effect->Instance.GPUParticlesCountReadback, data.Buffer->GPU.Buffer, sizeof(uint32), emitterIndex * sizeof(uint32), counterOffset);
303 }
304}
305
306#endif

Callers 1

UpdateGPUFunction · 0.80

Calls 4

IsAllocatedMethod · 0.80
MinFunction · 0.50
SwapFunction · 0.50
CopyBufferMethod · 0.45

Tested by

no test coverage detected