From 688b5f42e9bfe498d7af7075d4d8f4429867f3a3 Mon Sep 17 00:00:00 2001 From: Miles Macklin Date: Fri, 9 Jun 2017 13:41:15 +1200 Subject: 1.2.0.beta.1 --- doc/manual.html | 128 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 60 deletions(-) (limited to 'doc/manual.html') diff --git a/doc/manual.html b/doc/manual.html index be6fc69..6652a87 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -7,7 +7,7 @@ - Manual — NVIDIA Flex 1.1.0 documentation + Manual — NVIDIA Flex 1.2.0 documentation @@ -18,7 +18,7 @@ - + @@ -57,7 +57,7 @@
@@ -115,17 +115,18 @@
  • Release Notes
  • @@ -179,21 +180,26 @@

    Quick StartΒΆ

    The example code below shows how to initialize the library, create a new solver (similar to a scene in PhysX), and how to tick the solver:

    -
    #include <NvFlex.h>
    +
    NvFlexLibrary* library = NvFlexInit();
     
    -NvFlexLibrary* library = NvFlexInit();
    -NvFlexSolver* solver = NvFlexCreateSolver(library);
    +// create new solver
    +NvFlexSolverDesc solverDesc;
    +NvFlexSetSolverDescDefaults(&solverDesc);
    +solverDesc.maxParticles = n;
    +solverDesc.maxDiffuseParticles = 0;
     
    -NvFlexBuffer* particleBuffer = NvlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost);
    -NvFlexBuffer* velocityBuffer = NvlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost);
    -NvFlexBuffer* phaseBuffer = NvlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost);
    +NvFlexSolver* solver = NvFlexCreateSolver(library, &solverDesc);
    +
    +NvFlexBuffer* particleBuffer = NvFlexAllocBuffer(library, n, sizeof(float4), eNvFlexBufferHost);
    +NvFlexBuffer* velocityBuffer = NvFlexAllocBuffer(library, n, sizeof(float4), eNvFlexBufferHost);
    +NvFlexBuffer* phaseBuffer = NvFlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost);
     
     while(!done)
     {
             // map buffers for reading / writing
    -        float4* particles = (float4*)NvlexMap(particles, eNvFlexMapWait);
    -        float3* velocities  = (float3*)NvFlexMap(velocities, eNvFlexMapWait);
    -        int* phases = (int*)NvFlexMap(phases, eNvFlexMapWait);
    +        float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait);
    +        float3* velocities  = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait);
    +        int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait);
     
             // spawn (user method)
             SpawnParticles(particles, velocities, phases);
    @@ -207,17 +213,17 @@
             NvFlexUnmap(phaseBuffer);
     
             // write to device (async)
    -        NvFlexSetParticles(particleBuffer, n);
    -        NvFlexSetVelocities(velocityBuffer, n);
    -        NvFlexSetPhases(phaseBuffer, n);
    +        NvFlexSetParticles(solver, particleBuffer, NULL);
    +        NvFlexSetVelocities(solver, velocityBuffer, NULL);
    +        NvFlexSetPhases(solver, phaseBuffer, NULL);
     
             // tick
             NvFlexUpdateSolver(solver, dt, 1, false);
     
             // read back (async)
    -        NvFlexGetParticles(particleBuffer, n);
    -        NvFlexGetVelocities(velocityBuffer, n);
    -        NvFlexGetPhases(phaseBuffer, n);
    +        NvFlexGetParticles(solver, particleBuffer, NULL);
    +        NvFlexGetVelocities(solver, velocityBuffer, NULL);
    +        NvFlexGetPhases(solver, phaseBuffer, NULL);
     }
     
     NvFlexFreeBuffer(particleBuffer);
    @@ -250,9 +256,9 @@
     NvFlexBuffer* phaseBuffer = NvFlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost);
     
     // map buffers for reading / writing
    -float4* particles = (float4*)NvFlexMap(particles, eNvFlexMapWait);
    -float3* velocities = (float3*)NvFlexMap(velocities, eNvFlexMapWait);
    -int* phases = (int*)NvFlexMap(phases, eFlexMapWait);
    +float4* particles = (float4*)NvFlexMap(particlesBuffer, eNvFlexMapWait);
    +float3* velocities = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait);
    +int* phases = (int*)NvFlexMap(phaseBuffer, eFlexMapWait);
     
     // spawn particles
     for (int i=0; i < n; ++i)
    @@ -268,9 +274,9 @@
     NvFlexUnmap(phaseBuffer);
     
     // write to device (async)
    -NvFlexSetParticles(particleBuffer, n);
    -NvFlexSetVelocities(velocityBuffer, n);
    -NvFlexSetPhases(phaseBuffer, n);
    +NvFlexSetParticles(solver, particleBuffer, NULL);
    +NvFlexSetVelocities(solver, velocityBuffer, NULL);
    +NvFlexSetPhases(solver, phaseBuffer, NULL);
     
    @@ -309,7 +315,9 @@ activeIndices[i] = i; NvFlexUnmap(activeBuffer); -NvFlexSetActive(solver, activeBuffer, 10) + +NvFlexSetActive(solver, activeBuffer, NULL) +NvFlexSetActiveCount(solver, 10);

    Note: constraints referencing inactive particles may behave unexpectedly.

    @@ -634,34 +642,34 @@ simulation. Diffuse particles can be created through the NvFlexSetDiffus

    Synchronization occurs when you call NvFlexMap() on a simulation buffer. To avoid making the CPU wait a long time for the GPU to finish its work it is good practice to call NvFlexMap() as far away from the NvFlexUpdateSolver() and NvFlexGet*() as possible. This gives the GPU enough time to finish its work so that the new data is ready for when you call NvFlexMap(). The following snippet shows an example of this by performing the main game tick after the the read-back methods have been issued.:

    while (!done)
     {
    -        // map buffers for reading / writing (synchronizes with GPU)
    -        float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait);
    -        float3* velocities  = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait);
    -        int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait);
    +// map buffers for reading / writing (synchronizes with GPU)
    +float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait);
    +float3* velocities  = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait);
    +int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait);
     
    -        // application CPU-side particle update
    -        UpdateBuffers(particles, velocities, phases);
    +// application CPU-side particle update
    +UpdateBuffers(particles, velocities, phases);
     
    -        // unmap buffers
    -        NvFlexUnmap(particleBuffer);
    -        NvFlexUnmap(velocityBuffer);
    -        NvFlexUnmap(phaseBuffer);
    +// unmap buffers
    +NvFlexUnmap(particleBuffer);
    +NvFlexUnmap(velocityBuffer);
    +NvFlexUnmap(phaseBuffer);
     
    -        // write to device (async)
    -        NvFlexSetParticles(particleBuffer, n);
    -        NvFlexSetVelocities(velocityBuffer, n);
    -        NvFlexSetPhases(phaseBuffer, n);
    +// write to device (async)
    +NvFlexSetParticles(solver, particleBuffer, NULL);
    +NvFlexSetVelocities(solver, velocityBuffer, NULL);
    +NvFlexSetPhases(solver, phaseBuffer, NULL);
     
    -        // tick (async)
    -        NvFlexUpdateSolver(solver, dt, 1, NULL);
    +// tick (async)
    +NvFlexUpdateSolver(solver, dt, 1, NULL);
     
    -        // read back (async)
    -        NvFlexGetParticles(particleBuffer, n);
    -        NvFlexGetVelocities(velocityBuffer, n);
    -        NvFlexGetPhases(phaseBuffer, n);
    +// read back (async)
    +NvFlexGetParticles(solver, particleBuffer, NULL);
    +NvFlexGetVelocities(solver, velocityBuffer, NULL);
    +NvFlexGetPhases(solver, phaseBuffer, NULL);
     
    -        // Perform CPU work here while update and transfer are in flight
    -        TickGame()
    +// Perform CPU work here while update and transfer are in flight
    +TickGame()
     }
     
    @@ -708,7 +716,7 @@ simulation. Diffuse particles can be created through the NvFlexSetDiffus -- cgit v1.2.3