Skip to content

Commit a961bf2

Browse files
committed
Fix a bunch of byte swaps
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent f192d5b commit a961bf2

3 files changed

Lines changed: 77 additions & 1 deletion

File tree

MarathonRecomp/gpu/video.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ struct SharedConstants
166166
uint32_t samplerIndices[16]{};
167167
uint32_t booleans{};
168168
uint32_t swappedTexcoords{};
169+
uint32_t swappedNormals{};
170+
uint32_t swappedBinormals{};
171+
uint32_t swappedTangents{};
172+
uint32_t swappedBlendWeights{};
169173
float halfPixelOffsetX{};
170174
float halfPixelOffsetY{};
171175
float alphaThreshold{};
@@ -4890,6 +4894,70 @@ static GuestVertexDeclaration* CreateVertexDeclarationWithoutAddRef(GuestVertexE
48904894

48914895
switch (vertexElement->usage)
48924896
{
4897+
case D3DDECLUSAGE_NORMAL:
4898+
switch (vertexElement->type)
4899+
{
4900+
case D3DDECLTYPE_SHORT2:
4901+
case D3DDECLTYPE_SHORT4:
4902+
case D3DDECLTYPE_SHORT2N:
4903+
case D3DDECLTYPE_SHORT4N:
4904+
case D3DDECLTYPE_USHORT2N:
4905+
case D3DDECLTYPE_USHORT4N:
4906+
case D3DDECLTYPE_FLOAT16_2:
4907+
case D3DDECLTYPE_FLOAT16_4:
4908+
vertexDeclaration->swappedNormals |= 1 << vertexElement->usageIndex;
4909+
break;
4910+
}
4911+
4912+
break;
4913+
case D3DDECLUSAGE_BINORMAL:
4914+
switch (vertexElement->type)
4915+
{
4916+
case D3DDECLTYPE_SHORT2:
4917+
case D3DDECLTYPE_SHORT4:
4918+
case D3DDECLTYPE_SHORT2N:
4919+
case D3DDECLTYPE_SHORT4N:
4920+
case D3DDECLTYPE_USHORT2N:
4921+
case D3DDECLTYPE_USHORT4N:
4922+
case D3DDECLTYPE_FLOAT16_2:
4923+
case D3DDECLTYPE_FLOAT16_4:
4924+
vertexDeclaration->swappedBinormals |= 1 << vertexElement->usageIndex;
4925+
break;
4926+
}
4927+
4928+
break;
4929+
case D3DDECLUSAGE_TANGENT:
4930+
switch (vertexElement->type)
4931+
{
4932+
case D3DDECLTYPE_SHORT2:
4933+
case D3DDECLTYPE_SHORT4:
4934+
case D3DDECLTYPE_SHORT2N:
4935+
case D3DDECLTYPE_SHORT4N:
4936+
case D3DDECLTYPE_USHORT2N:
4937+
case D3DDECLTYPE_USHORT4N:
4938+
case D3DDECLTYPE_FLOAT16_2:
4939+
case D3DDECLTYPE_FLOAT16_4:
4940+
vertexDeclaration->swappedTangents |= 1 << vertexElement->usageIndex;
4941+
break;
4942+
}
4943+
4944+
break;
4945+
case D3DDECLUSAGE_BLENDWEIGHT:
4946+
switch (vertexElement->type)
4947+
{
4948+
case D3DDECLTYPE_SHORT2:
4949+
case D3DDECLTYPE_SHORT4:
4950+
case D3DDECLTYPE_SHORT2N:
4951+
case D3DDECLTYPE_SHORT4N:
4952+
case D3DDECLTYPE_USHORT2N:
4953+
case D3DDECLTYPE_USHORT4N:
4954+
case D3DDECLTYPE_FLOAT16_2:
4955+
case D3DDECLTYPE_FLOAT16_4:
4956+
vertexDeclaration->swappedBlendWeights |= 1 << vertexElement->usageIndex;
4957+
break;
4958+
}
4959+
4960+
break;
48934961
case D3DDECLUSAGE_POSITION:
48944962
if (vertexElement->usageIndex == 1)
48954963
vertexDeclaration->indexVertexStream = vertexElement->stream;
@@ -5006,6 +5074,10 @@ static void ProcSetVertexDeclaration(const RenderCommand& cmd)
50065074
if (args.vertexDeclaration != nullptr)
50075075
{
50085076
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.swappedTexcoords, args.vertexDeclaration->swappedTexcoords);
5077+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.swappedNormals, args.vertexDeclaration->swappedNormals);
5078+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.swappedBinormals, args.vertexDeclaration->swappedBinormals);
5079+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.swappedTangents, args.vertexDeclaration->swappedTangents);
5080+
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.swappedBlendWeights, args.vertexDeclaration->swappedBlendWeights);
50095081

50105082
uint32_t specConstants = g_pipelineState.specConstants;
50115083
if (args.vertexDeclaration->hasR11G11B10Normal)

MarathonRecomp/gpu/video.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ struct GuestVertexDeclaration : GuestResource
298298
uint32_t inputElementCount = 0;
299299
uint32_t vertexElementCount = 0;
300300
uint32_t swappedTexcoords = 0;
301+
uint32_t swappedNormals = 0;
302+
uint32_t swappedBinormals = 0;
303+
uint32_t swappedTangents = 0;
304+
uint32_t swappedBlendWeights = 0;
301305
bool hasR11G11B10Normal = false;
302306
bool vertexStreams[16]{};
303307
uint32_t indexVertexStream = 0;

tools/XenosRecomp

0 commit comments

Comments
 (0)