RenderGPUMorphedDraws ( )

Parameters

None.

Description

Returns the number of draw calls that used GPU morph deformation in the last completed frame.

Read the counter after Flip; submitting RenderWorld alone does not execute the frame. It reports main-colour draw calls only.

This counts draw calls, not entities, vertices or targets. Compatible copies may share one instanced draw even with different expressions. Draws with no active morph weights do not contribute. The count is replaced each completed frame, not accumulated. Shadow and auxiliary view draws are excluded.

Use with RenderCPUMorphedDraws to observe automatic path selection. GPU morphing requires a compatible morph_v1 material and at most 32 active targets. Combined morph-plus-skin draws blend mesh-space deltas before applying skinning. CPU animation sampling and base-geometry queries remain unchanged.


See also: RenderCPUMorphedDraws, RenderGPUSkinnedDraws, RenderDrawCalls, AddMorphTarget.

Example

; RenderGPUMorphedDraws Example
; -----------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-6

light=CreateLight()
RotateEntity light,30,20,0

; A morphing sphere: one real stretched target
base=CreateSphere(16)
EntityColor base,80,180,240
pose=CopyMesh(base)
ScaleMesh pose,1,1.5,0.7
UpdateNormals pose
target=AddMorphTarget(base,pose,"Stretch",3)
FreeEntity pose

; 32 extra zero-offset targets; activating them all exceeds the 32-target
; GPU limit, so the GPU draw count drops to zero under the CPU fallback
For n=1 To 32
    AddMorphTarget base,base,"Zero "+n,1
Next

fallback=False
phase#=0
gpu_draws=0
cpu_draws=0

While Not KeyDown(1)

    ; Space toggles between one and 33 active targets
    If KeyHit(57) Then fallback=Not fallback

    phase=phase+2
    SetMorphWeight base,0,0.5+Sin(phase)*0.4
    For n=1 To 32
        SetMorphWeight base,n,fallback*0.1
    Next

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrow keys: move camera   Space: 1 / 33 active targets   Esc: exit"
    Text 0,20,"RenderGPUMorphedDraws() = "+gpu_draws+"   RenderCPUMorphedDraws() = "+cpu_draws
    Text 0,40,"One active target uses the GPU where supported: fallback = "+fallback

    Flip

    ; Counters describe the frame the Flip above completed
    gpu_draws=RenderGPUMorphedDraws()
    cpu_draws=RenderCPUMorphedDraws()

Wend

End

Index