| 576 | } |
| 577 | |
| 578 | void OnDrawFrame() override |
| 579 | { |
| 580 | UpdateScene(); |
| 581 | |
| 582 | // Record and submit compute commands |
| 583 | commands->Begin(); |
| 584 | { |
| 585 | // Update scene state constant buffer |
| 586 | commands->UpdateBuffer(*constantBuffer, 0, &sceneState, sizeof(sceneState)); |
| 587 | |
| 588 | // Run compute shader to apply particle forces |
| 589 | commands->PushDebugGroup("CSForces"); |
| 590 | { |
| 591 | commands->SetPipelineState(*computePipelines[CSForces]); |
| 592 | commands->SetResourceHeap(*computeResourceHeap, swapBufferIndex); |
| 593 | commands->Dispatch(clothSegmentsU + 1, clothSegmentsV + 1, 1); |
| 594 | } |
| 595 | commands->PopDebugGroup(); |
| 596 | |
| 597 | // Run compute shader to apply stretch constraints with number of integration steps |
| 598 | commands->PushDebugGroup("CSStretchConstraints"); |
| 599 | { |
| 600 | commands->SetPipelineState(*computePipelines[CSStretchConstraints]); |
| 601 | |
| 602 | for (std::uint32_t i = 0; i < numSolverIterations; ++i) |
| 603 | { |
| 604 | if (i > 0) |
| 605 | swapBufferIndex = (swapBufferIndex + 1) % 2; |
| 606 | commands->SetResourceHeap(*computeResourceHeap, swapBufferIndex); |
| 607 | commands->Dispatch(clothSegmentsU + 1, clothSegmentsV + 1, 1); |
| 608 | } |
| 609 | } |
| 610 | commands->PopDebugGroup(); |
| 611 | |
| 612 | // Run compute shader to adjust velocity of particles |
| 613 | commands->PushDebugGroup("CSRelaxation"); |
| 614 | { |
| 615 | commands->SetPipelineState(*computePipelines[CSRelaxation]); |
| 616 | commands->SetResourceHeap(*computeResourceHeap, swapBufferIndex); |
| 617 | commands->Dispatch(clothSegmentsU + 1, clothSegmentsV + 1, 1); |
| 618 | } |
| 619 | commands->PopDebugGroup(); |
| 620 | |
| 621 | // Draw scene |
| 622 | commands->BeginRenderPass(*swapChain); |
| 623 | { |
| 624 | // Clear color buffer and set viewport |
| 625 | commands->Clear(LLGL::ClearFlags::ColorDepth, backgroundColor); |
| 626 | commands->SetViewport(swapChain->GetResolution()); |
| 627 | |
| 628 | // Set vertex and index buffers |
| 629 | #ifdef ENABLE_STORAGE_TEXTURES |
| 630 | commands->SetVertexBuffer(*vertexBufferNull); |
| 631 | #else |
| 632 | commands->SetVertexBufferArray(*vertexBufferArray); |
| 633 | #endif |
| 634 | |
| 635 | commands->SetIndexBuffer(*indexBuffer); |
nothing calls this directly
no test coverage detected