Skip to content

Commit

Permalink
Hack in the same CPU skinning from DX for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Jan 2, 2023
1 parent b10eb9b commit 5ee82a8
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,15 @@ plProfile_Extern(TotalTexSize);
plProfile_Extern(LayChange);
plProfile_Extern(DrawTriangles);
plProfile_Extern(MatChange);
plProfile_Extern(NumSkin);

plProfile_CreateCounterNoReset("Reload", "PipeC", PipeReload);

plProfile_CreateTimer("PrepShadows", "PipeT", PrepShadows);
plProfile_CreateTimer("PrepDrawable", "PipeT", PrepDrawable);
plProfile_CreateTimer(" Skin", "PipeT", Skin);
plProfile_CreateTimer(" AvSort", "PipeT", AvatarSort);
plProfile_CreateTimer(" ClearLights", "PipeT", ClearLights);
plProfile_Extern(PrepShadows);
plProfile_Extern(PrepDrawable);
plProfile_Extern(Skin);
plProfile_Extern(AvatarSort);
plProfile_Extern(ClearLights);
plProfile_Extern(RenderSpan);
plProfile_Extern(MergeCheck);
plProfile_Extern(MergeSpan);
Expand All @@ -314,7 +315,6 @@ plProfile_CreateMemCounterReset("fVtxManaged", "PipeC", fVtxManaged);
plProfile_CreateCounter("Merge", "PipeC", SpanMerge);
plProfile_CreateCounter("TexNum", "PipeC", NumTex);
plProfile_CreateCounter("LiState", "PipeC", MatLightState);
plProfile_CreateCounter("NumSkin", "PipeC", NumSkin);
plProfile_CreateCounter("AvatarFaces", "PipeC", AvatarFaces);
plProfile_CreateCounter("VertexChange", "PipeC", VertexChange);
plProfile_CreateCounter("IndexChange", "PipeC", IndexChange);
Expand Down
32 changes: 28 additions & 4 deletions Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,38 @@ bool plGLDevice::EndRender()
return false;
}

static uint32_t IGetBufferFormatSize(uint8_t format)
{
uint32_t size = sizeof( float ) * 6 + sizeof( uint32_t ) * 2; // Position and normal, and two packed colors

switch (format & plGBufferGroup::kSkinWeightMask)
{
case plGBufferGroup::kSkinNoWeights:
break;
case plGBufferGroup::kSkin1Weight:
size += sizeof(float);
break;
default:
hsAssert( false, "Invalid skin weight value in IGetBufferFormatSize()" );
}

size += sizeof( float ) * 3 * plGBufferGroup::CalcNumUVs(format);

return size;
}

void plGLDevice::SetupVertexBufferRef(plGBufferGroup* owner, uint32_t idx, VertexBufferRef* vRef)
{
uint8_t format = owner->GetVertexFormat();

uint32_t vertSize = owner->GetVertexSize(); //IGetBufferFormatSize(format); // vertex stride
if (format & plGBufferGroup::kSkinIndices) {
format &= ~(plGBufferGroup::kSkinWeightMask | plGBufferGroup::kSkinIndices);
format |= plGBufferGroup::kSkinNoWeights; // Should do nothing, but just in case...
vRef->SetSkinned(true);
vRef->SetVolatile(true);
}

uint32_t vertSize = IGetBufferFormatSize(format); // vertex stride
uint32_t numVerts = owner->GetVertBufferCount(idx);

vRef->fOwner = owner;
Expand All @@ -504,9 +531,6 @@ void plGLDevice::SetupVertexBufferRef(plGBufferGroup* owner, uint32_t idx, Verte
vRef->SetRebuiltSinceUsed(true);
vRef->fData = nullptr;

if (format & plGBufferGroup::kSkinIndices)
vRef->SetSkinned(true);

vRef->SetVolatile(vRef->Volatile() || owner->AreVertsVolatile());

vRef->fIndex = idx;
Expand Down
Loading

0 comments on commit 5ee82a8

Please sign in to comment.