GPU (hardware) skinning with CPU fallback #3

Merged
dev merged 3 commits from devin/1795845494-gpu-skinning into main 2026-11-28 01:11:20 -05:00
Owner

Adds a hardware (GPU) skinning path next to the existing software (CPU) path.

  • Hardware (default): Poser only computes bone matrices; ModelNode::uploadBoneMatrices() writes them to an RGBA32F texture (3 texels per bone, 1024 bones per row) on unit 3, and the GLSL 1.20 vertex shader skins with texture2DLod. Bone indices/weights are vertex attributes 6/7.
  • Software: unchanged multithreaded CPU skinning.
  • GpuCapsProbe (realize operation, chained before ImGui's) checks vertex texture fetch + float textures; ModelNode falls back to software if either is missing.
  • Morphs stay on the CPU in both modes, but Poser now re-applies them only when morph weights change; hardware mode then re-uploads rest positions only in that case.
  • Since hardware mode keeps rest positions in the vertex arrays, drawables use a bounds callback built from posed bone positions plus the max vertex-to-bone distance, so culling and near/far stay correct.
  • UI: View menu radio buttons (GPU skinning greyed out if unsupported), "Skinning: GPU/CPU" in the Model window. CLI: --skinning gpu|cpu; --bench prints the active mode and GL renderer.
  • Test: emulates the shader's column layout on skinMatrices() + morphedPositions() and compares against software positions.

Verified CPU vs GPU renders are pixel-identical (no pixel differs by more than 16/255) for posed Miku PMD and Mixamo FBX on Linux (llvmpipe), and posed Karin PMX on the Intel HD 6000 Mac.

Mac, Karin CPU deform per change GPU deform per change
PMX (bench changes a bone + morph) 2.09 ms 0.37 ms
FBX (bench morph touches many verts) 1.88 ms 1.78 ms

Written by Devin

Adds a hardware (GPU) skinning path next to the existing software (CPU) path. - **Hardware (default):** `Poser` only computes bone matrices; `ModelNode::uploadBoneMatrices()` writes them to an RGBA32F texture (3 texels per bone, 1024 bones per row) on unit 3, and the GLSL 1.20 vertex shader skins with `texture2DLod`. Bone indices/weights are vertex attributes 6/7. - **Software:** unchanged multithreaded CPU skinning. - `GpuCapsProbe` (realize operation, chained before ImGui's) checks vertex texture fetch + float textures; `ModelNode` falls back to software if either is missing. - Morphs stay on the CPU in both modes, but `Poser` now re-applies them only when morph weights change; hardware mode then re-uploads rest positions only in that case. - Since hardware mode keeps rest positions in the vertex arrays, drawables use a bounds callback built from posed bone positions plus the max vertex-to-bone distance, so culling and near/far stay correct. - UI: View menu radio buttons (GPU skinning greyed out if unsupported), "Skinning: GPU/CPU" in the Model window. CLI: `--skinning gpu|cpu`; `--bench` prints the active mode and GL renderer. - Test: emulates the shader's column layout on `skinMatrices()` + `morphedPositions()` and compares against software positions. Verified CPU vs GPU renders are pixel-identical (no pixel differs by more than 16/255) for posed Miku PMD and Mixamo FBX on Linux (llvmpipe), and posed Karin PMX on the Intel HD 6000 Mac. | Mac, Karin | CPU deform per change | GPU deform per change | |---|---|---| | PMX (bench changes a bone + morph) | 2.09 ms | 0.37 ms | | FBX (bench morph touches many verts) | 1.88 ms | 1.78 ms | [Written by Devin](https://app.devin.ai/sessions/edc92906d52f4fb09179a164d60f5f27)
dev added 3 commits 2026-11-28 01:01:49 -05:00
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dev merged commit 77a6ff4550 into main 2026-11-28 01:11:20 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dev/3d-model-renderer#3