Skip to content

Commit

Permalink
perf: fix skinning performance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan hoffstadt committed Jan 23, 2025
1 parent 36cda69 commit 40dad64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions extensions/pl_renderer_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ pl_refr_perform_skinning(plCommandBuffer* ptCommandBuffer, uint32_t uSceneHandle
int iSourceDataOffset;
int iDestDataOffset;
int iDestVertexOffset;
int iUnused;
uint32_t uMaxSize;
} SkinDynamicData;

if(uSkinCount)
Expand All @@ -772,12 +772,13 @@ pl_refr_perform_skinning(plCommandBuffer* ptCommandBuffer, uint32_t uSceneHandle
ptDynamicData->iSourceDataOffset = ptScene->sbtSkinData[i].iSourceDataOffset;
ptDynamicData->iDestDataOffset = ptScene->sbtSkinData[i].iDestDataOffset;
ptDynamicData->iDestVertexOffset = ptScene->sbtSkinData[i].iDestVertexOffset;
ptDynamicData->uMaxSize = ptScene->sbtSkinData[i].uVertexCount;

const plDispatch tDispach = {
.uGroupCountX = ptScene->sbtSkinData[i].uVertexCount,
.uGroupCountX = (uint32_t)ceilf((float)ptScene->sbtSkinData[i].uVertexCount / 64.0f),
.uGroupCountY = 1,
.uGroupCountZ = 1,
.uThreadPerGroupX = 1,
.uThreadPerGroupX = 64,
.uThreadPerGroupY = 1,
.uThreadPerGroupZ = 1
};
Expand Down
9 changes: 6 additions & 3 deletions shaders/skinning.comp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ layout(set = 3, binding = 0) uniform PL_DYNAMIC_DATA
int iSourceDataOffset;
int iDestDataOffset;
int iDestVertexOffset;
int iUnused;
uint uMaxSize;
} tObjectInfo;

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -108,13 +108,16 @@ get_skinning_matrix(vec4 inJoints0, vec4 inWeights0)
// [SECTION] entry
//-----------------------------------------------------------------------------

layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;

void
main()
{

const uint iVertexIndex = gl_WorkGroupID.x;
const uint iVertexIndex = gl_WorkGroupID.x * 64 + gl_LocalInvocationID.x;

if(iVertexIndex > tObjectInfo.uMaxSize)
return;

vec4 inPosition = vec4(0.0, 0.0, 0.0, 1.0);
vec3 inNormal = vec3(0.0, 0.0, 0.0);
Expand Down

0 comments on commit 40dad64

Please sign in to comment.