-------------------------------------------------------------------------------------- Description: Emits new particles into the system. Uses constant buffer to pass emitter parameters to the shader. --------------------------------------------------------------------------------------
| 560 | // to the shader. |
| 561 | // -------------------------------------------------------------------------------------- |
| 562 | void Tr2GpuParticleSystem::EmitParticles( Tr2RenderContext& renderContext ) |
| 563 | { |
| 564 | struct EmitterCBPrefix |
| 565 | { |
| 566 | uint32_t count; |
| 567 | float padding[3]; |
| 568 | }; |
| 569 | |
| 570 | static const size_t maxSize = TRINITY_PLATFORM_MAX_CONSTANT_BUFFER_SIZE; |
| 571 | static const size_t emitsPerDispatch = ( maxSize - sizeof( EmitterCBPrefix ) ) / sizeof( EmitterGpu ); |
| 572 | struct CB |
| 573 | { |
| 574 | EmitterCBPrefix prefix; |
| 575 | EmitterGpu emitters[emitsPerDispatch]; |
| 576 | } cb; |
| 577 | |
| 578 | m_emitTimer.Begin( renderContext ); |
| 579 | ON_BLOCK_EXIT( [&] { m_emitTimer.End( renderContext ); } ); |
| 580 | |
| 581 | for( size_t i = 0; i < m_emitRequests.GetCount(); i += emitsPerDispatch ) |
| 582 | { |
| 583 | cb.prefix.count = uint32_t( std::min( m_emitRequests.GetCount() - i, emitsPerDispatch ) ); |
| 584 | for( size_t j = 0; j < cb.prefix.count; ++j ) |
| 585 | { |
| 586 | cb.emitters[j] = m_emitRequests[i + j].emitter; |
| 587 | } |
| 588 | FillAndSetConstants( |
| 589 | m_emitCB, |
| 590 | &cb, |
| 591 | sizeof( EmitterCBPrefix ) + cb.prefix.count * sizeof( EmitterGpu ), |
| 592 | Tr2RenderContextEnum::COMPUTE_SHADER, |
| 593 | Tr2Renderer::GetPerObjectVSStartRegister(), |
| 594 | renderContext ); |
| 595 | |
| 596 | Tr2Renderer::RunComputeShader( m_emit, cb.prefix.count, 1, 1, renderContext ); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | // -------------------------------------------------------------------------------------- |
| 601 | // Description: |
nothing calls this directly
no test coverage detected