mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 23:29:44 -06:00
Fix scons build.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7415 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -52,6 +52,12 @@ files = [
|
|||||||
'Src/Debugger/Debugger_SymbolMap.cpp',
|
'Src/Debugger/Debugger_SymbolMap.cpp',
|
||||||
'Src/Debugger/Dump.cpp',
|
'Src/Debugger/Dump.cpp',
|
||||||
'Src/Debugger/PPCDebugInterface.cpp',
|
'Src/Debugger/PPCDebugInterface.cpp',
|
||||||
|
'Src/FifoPlayer/FifoAnalyzer.cpp',
|
||||||
|
'Src/FifoPlayer/FifoDataFile.cpp',
|
||||||
|
'Src/FifoPlayer/FifoPlaybackAnalyzer.cpp',
|
||||||
|
'Src/FifoPlayer/FifoPlayer.cpp',
|
||||||
|
'Src/FifoPlayer/FifoRecordAnalyzer.cpp',
|
||||||
|
'Src/FifoPlayer/FifoRecorder.cpp',
|
||||||
'Src/GeckoCode.cpp',
|
'Src/GeckoCode.cpp',
|
||||||
'Src/GeckoCodeConfig.cpp',
|
'Src/GeckoCodeConfig.cpp',
|
||||||
'Src/HLE/HLE.cpp',
|
'Src/HLE/HLE.cpp',
|
||||||
|
@ -1,235 +1,235 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "FifoAnalyzer.h"
|
#include "FifoAnalyzer.h"
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "VertexLoader_Position.h"
|
#include "VertexLoader_Position.h"
|
||||||
#include "VertexLoader_Normal.h"
|
#include "VertexLoader_Normal.h"
|
||||||
#include "VertexLoader_TextCoord.h"
|
#include "VertexLoader_TextCoord.h"
|
||||||
|
|
||||||
namespace FifoAnalyzer
|
namespace FifoAnalyzer
|
||||||
{
|
{
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
VertexLoader_Normal::Init();
|
VertexLoader_Normal::Init();
|
||||||
VertexLoader_Position::Init();
|
VertexLoader_Position::Init();
|
||||||
VertexLoader_TextCoord::Init();
|
VertexLoader_TextCoord::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 ReadFifo8(u8 *&data)
|
u8 ReadFifo8(u8 *&data)
|
||||||
{
|
{
|
||||||
u8 value = data[0];
|
u8 value = data[0];
|
||||||
data += 1;
|
data += 1;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 ReadFifo16(u8 *&data)
|
u16 ReadFifo16(u8 *&data)
|
||||||
{
|
{
|
||||||
u16 value = Common::swap16(data);
|
u16 value = Common::swap16(data);
|
||||||
data += 2;
|
data += 2;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 ReadFifo32(u8 *&data)
|
u32 ReadFifo32(u8 *&data)
|
||||||
{
|
{
|
||||||
u32 value = Common::swap32(data);
|
u32 value = Common::swap32(data);
|
||||||
data += 4;
|
data += 4;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitBPMemory(BPMemory *bpMem)
|
void InitBPMemory(BPMemory *bpMem)
|
||||||
{
|
{
|
||||||
memset(bpMem, 0, sizeof(BPMemory));
|
memset(bpMem, 0, sizeof(BPMemory));
|
||||||
bpMem->bpMask = 0x00FFFFFF;
|
bpMem->bpMask = 0x00FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPCmd DecodeBPCmd(u32 value, const BPMemory &bpMem)
|
BPCmd DecodeBPCmd(u32 value, const BPMemory &bpMem)
|
||||||
{
|
{
|
||||||
//handle the mask register
|
//handle the mask register
|
||||||
int opcode = value >> 24;
|
int opcode = value >> 24;
|
||||||
int oldval = ((u32*)&bpMem)[opcode];
|
int oldval = ((u32*)&bpMem)[opcode];
|
||||||
int newval = (oldval & ~bpMem.bpMask) | (value & bpMem.bpMask);
|
int newval = (oldval & ~bpMem.bpMask) | (value & bpMem.bpMask);
|
||||||
int changes = (oldval ^ newval) & 0xFFFFFF;
|
int changes = (oldval ^ newval) & 0xFFFFFF;
|
||||||
|
|
||||||
BPCmd bp = {opcode, changes, newval};
|
BPCmd bp = {opcode, changes, newval};
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadBPReg(const BPCmd &bp, BPMemory &bpMem)
|
void LoadBPReg(const BPCmd &bp, BPMemory &bpMem)
|
||||||
{
|
{
|
||||||
((u32*)&bpMem)[bp.address] = bp.newvalue;
|
((u32*)&bpMem)[bp.address] = bp.newvalue;
|
||||||
|
|
||||||
//reset the mask register
|
//reset the mask register
|
||||||
if (bp.address != 0xFE)
|
if (bp.address != 0xFE)
|
||||||
bpMem.bpMask = 0xFFFFFF;
|
bpMem.bpMask = 0xFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTlutLoadData(u32 &tlutAddr, u32 &memAddr, u32 &tlutXferCount, BPMemory &bpMem)
|
void GetTlutLoadData(u32 &tlutAddr, u32 &memAddr, u32 &tlutXferCount, BPMemory &bpMem)
|
||||||
{
|
{
|
||||||
tlutAddr = (bpMem.tlutXferDest & 0x3FF) << 9;
|
tlutAddr = (bpMem.tlutXferDest & 0x3FF) << 9;
|
||||||
tlutXferCount = (bpMem.tlutXferDest & 0x1FFC00) >> 5;
|
tlutXferCount = (bpMem.tlutXferDest & 0x1FFC00) >> 5;
|
||||||
|
|
||||||
// TODO - figure out a cleaner way.
|
// TODO - figure out a cleaner way.
|
||||||
if (Core::g_CoreStartupParameter.bWii)
|
if (Core::g_CoreStartupParameter.bWii)
|
||||||
memAddr = bpmem.tlutXferSrc << 5;
|
memAddr = bpmem.tlutXferSrc << 5;
|
||||||
else
|
else
|
||||||
memAddr = (bpmem.tlutXferSrc & 0xFFFFF) << 5;
|
memAddr = (bpmem.tlutXferSrc & 0xFFFFF) << 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadCPReg(u32 subCmd, u32 value, CPMemory &cpMem)
|
void LoadCPReg(u32 subCmd, u32 value, CPMemory &cpMem)
|
||||||
{
|
{
|
||||||
switch (subCmd & 0xF0)
|
switch (subCmd & 0xF0)
|
||||||
{
|
{
|
||||||
case 0x50:
|
case 0x50:
|
||||||
cpMem.vtxDesc.Hex &= ~0x1FFFF; // keep the Upper bits
|
cpMem.vtxDesc.Hex &= ~0x1FFFF; // keep the Upper bits
|
||||||
cpMem.vtxDesc.Hex |= value;
|
cpMem.vtxDesc.Hex |= value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x60:
|
case 0x60:
|
||||||
cpMem.vtxDesc.Hex &= 0x1FFFF; // keep the lower 17Bits
|
cpMem.vtxDesc.Hex &= 0x1FFFF; // keep the lower 17Bits
|
||||||
cpMem.vtxDesc.Hex |= (u64)value << 17;
|
cpMem.vtxDesc.Hex |= (u64)value << 17;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x70:
|
case 0x70:
|
||||||
_assert_((subCmd & 0x0F) < 8);
|
_assert_((subCmd & 0x0F) < 8);
|
||||||
cpMem.vtxAttr[subCmd & 7].g0.Hex = value;
|
cpMem.vtxAttr[subCmd & 7].g0.Hex = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80:
|
case 0x80:
|
||||||
_assert_((subCmd & 0x0F) < 8);
|
_assert_((subCmd & 0x0F) < 8);
|
||||||
cpMem.vtxAttr[subCmd & 7].g1.Hex = value;
|
cpMem.vtxAttr[subCmd & 7].g1.Hex = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x90:
|
case 0x90:
|
||||||
_assert_((subCmd & 0x0F) < 8);
|
_assert_((subCmd & 0x0F) < 8);
|
||||||
cpMem.vtxAttr[subCmd & 7].g2.Hex = value;
|
cpMem.vtxAttr[subCmd & 7].g2.Hex = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xA0:
|
case 0xA0:
|
||||||
cpMem.arrayBases[subCmd & 0xF] = value;
|
cpMem.arrayBases[subCmd & 0xF] = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xB0:
|
case 0xB0:
|
||||||
cpMem.arrayStrides[subCmd & 0xF] = value & 0xFF;
|
cpMem.arrayStrides[subCmd & 0xF] = value & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CalculateVertexSize(int vatIndex, const CPMemory &cpMem)
|
u32 CalculateVertexSize(int vatIndex, const CPMemory &cpMem)
|
||||||
{
|
{
|
||||||
u32 vertexSize = 0;
|
u32 vertexSize = 0;
|
||||||
|
|
||||||
int sizes[21];
|
int sizes[21];
|
||||||
CalculateVertexElementSizes(sizes, vatIndex, cpMem);
|
CalculateVertexElementSizes(sizes, vatIndex, cpMem);
|
||||||
|
|
||||||
for (int i = 0; i < 21; ++i)
|
for (int i = 0; i < 21; ++i)
|
||||||
vertexSize += sizes[i];
|
vertexSize += sizes[i];
|
||||||
|
|
||||||
return vertexSize;
|
return vertexSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory &cpMem)
|
void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory &cpMem)
|
||||||
{
|
{
|
||||||
const TVtxDesc &vtxDesc = cpMem.vtxDesc;
|
const TVtxDesc &vtxDesc = cpMem.vtxDesc;
|
||||||
const VAT &vtxAttr = cpMem.vtxAttr[vatIndex];
|
const VAT &vtxAttr = cpMem.vtxAttr[vatIndex];
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
const int colDesc[2] = {vtxDesc.Color0, vtxDesc.Color1};
|
const int colDesc[2] = {vtxDesc.Color0, vtxDesc.Color1};
|
||||||
const int colComp[2] = {vtxAttr.g0.Color0Comp, vtxAttr.g0.Color1Comp};
|
const int colComp[2] = {vtxAttr.g0.Color0Comp, vtxAttr.g0.Color1Comp};
|
||||||
|
|
||||||
const int tcElements[8] =
|
const int tcElements[8] =
|
||||||
{
|
{
|
||||||
vtxAttr.g0.Tex0CoordElements, vtxAttr.g1.Tex1CoordElements, vtxAttr.g1.Tex2CoordElements,
|
vtxAttr.g0.Tex0CoordElements, vtxAttr.g1.Tex1CoordElements, vtxAttr.g1.Tex2CoordElements,
|
||||||
vtxAttr.g1.Tex3CoordElements, vtxAttr.g1.Tex4CoordElements, vtxAttr.g2.Tex5CoordElements,
|
vtxAttr.g1.Tex3CoordElements, vtxAttr.g1.Tex4CoordElements, vtxAttr.g2.Tex5CoordElements,
|
||||||
vtxAttr.g2.Tex6CoordElements, vtxAttr.g2.Tex7CoordElements
|
vtxAttr.g2.Tex6CoordElements, vtxAttr.g2.Tex7CoordElements
|
||||||
};
|
};
|
||||||
|
|
||||||
const int tcFormat[8] =
|
const int tcFormat[8] =
|
||||||
{
|
{
|
||||||
vtxAttr.g0.Tex0CoordFormat, vtxAttr.g1.Tex1CoordFormat, vtxAttr.g1.Tex2CoordFormat,
|
vtxAttr.g0.Tex0CoordFormat, vtxAttr.g1.Tex1CoordFormat, vtxAttr.g1.Tex2CoordFormat,
|
||||||
vtxAttr.g1.Tex3CoordFormat, vtxAttr.g1.Tex4CoordFormat, vtxAttr.g2.Tex5CoordFormat,
|
vtxAttr.g1.Tex3CoordFormat, vtxAttr.g1.Tex4CoordFormat, vtxAttr.g2.Tex5CoordFormat,
|
||||||
vtxAttr.g2.Tex6CoordFormat, vtxAttr.g2.Tex7CoordFormat
|
vtxAttr.g2.Tex6CoordFormat, vtxAttr.g2.Tex7CoordFormat
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add position and texture matrix indices
|
// Add position and texture matrix indices
|
||||||
u64 vtxDescHex = cpMem.vtxDesc.Hex;
|
u64 vtxDescHex = cpMem.vtxDesc.Hex;
|
||||||
for (int i = 0; i < 9; ++i)
|
for (int i = 0; i < 9; ++i)
|
||||||
{
|
{
|
||||||
sizes[i] = vtxDescHex & 1;
|
sizes[i] = vtxDescHex & 1;
|
||||||
vtxDescHex >>= 1;
|
vtxDescHex >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
sizes[9] = VertexLoader_Position::GetSize(vtxDesc.Position, vtxAttr.g0.PosFormat, vtxAttr.g0.PosElements);
|
sizes[9] = VertexLoader_Position::GetSize(vtxDesc.Position, vtxAttr.g0.PosFormat, vtxAttr.g0.PosElements);
|
||||||
|
|
||||||
// Normals
|
// Normals
|
||||||
if (vtxDesc.Normal != NOT_PRESENT)
|
if (vtxDesc.Normal != NOT_PRESENT)
|
||||||
{
|
{
|
||||||
sizes[10] = VertexLoader_Normal::GetSize(vtxDesc.Normal, vtxAttr.g0.NormalFormat, vtxAttr.g0.NormalElements, vtxAttr.g0.NormalIndex3);
|
sizes[10] = VertexLoader_Normal::GetSize(vtxDesc.Normal, vtxAttr.g0.NormalFormat, vtxAttr.g0.NormalElements, vtxAttr.g0.NormalIndex3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sizes[10] = 0;
|
sizes[10] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
switch (colDesc[i])
|
switch (colDesc[i])
|
||||||
{
|
{
|
||||||
case NOT_PRESENT:
|
case NOT_PRESENT:
|
||||||
break;
|
break;
|
||||||
case DIRECT:
|
case DIRECT:
|
||||||
switch (colComp[i])
|
switch (colComp[i])
|
||||||
{
|
{
|
||||||
case FORMAT_16B_565: size = 2; break;
|
case FORMAT_16B_565: size = 2; break;
|
||||||
case FORMAT_24B_888: size = 3; break;
|
case FORMAT_24B_888: size = 3; break;
|
||||||
case FORMAT_32B_888x: size = 4; break;
|
case FORMAT_32B_888x: size = 4; break;
|
||||||
case FORMAT_16B_4444: size = 2; break;
|
case FORMAT_16B_4444: size = 2; break;
|
||||||
case FORMAT_24B_6666: size = 3; break;
|
case FORMAT_24B_6666: size = 3; break;
|
||||||
case FORMAT_32B_8888: size = 4; break;
|
case FORMAT_32B_8888: size = 4; break;
|
||||||
default: _assert_(0); break;
|
default: _assert_(0); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEX8:
|
case INDEX8:
|
||||||
size = 1;
|
size = 1;
|
||||||
break;
|
break;
|
||||||
case INDEX16:
|
case INDEX16:
|
||||||
size = 2;
|
size = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes[11 + i] = size;
|
sizes[11 + i] = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture coordinates
|
// Texture coordinates
|
||||||
vtxDescHex = vtxDesc.Hex >> 17;
|
vtxDescHex = vtxDesc.Hex >> 17;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
sizes[13 + i] = VertexLoader_TextCoord::GetSize(vtxDescHex & 3, tcFormat[i], tcElements[i]);
|
sizes[13 + i] = VertexLoader_TextCoord::GetSize(vtxDescHex & 3, tcFormat[i], tcElements[i]);
|
||||||
vtxDescHex >>= 2;
|
vtxDescHex >>= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,54 +1,54 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _FIFOANALYZER_H
|
#ifndef _FIFOANALYZER_H
|
||||||
#define _FIFOANALYZER_H
|
#define _FIFOANALYZER_H
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "BPMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "CPMemory.h"
|
#include "CPMemory.h"
|
||||||
|
|
||||||
namespace FifoAnalyzer
|
namespace FifoAnalyzer
|
||||||
{
|
{
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
u8 ReadFifo8(u8 *&data);
|
u8 ReadFifo8(u8 *&data);
|
||||||
u16 ReadFifo16(u8 *&data);
|
u16 ReadFifo16(u8 *&data);
|
||||||
u32 ReadFifo32(u8 *&data);
|
u32 ReadFifo32(u8 *&data);
|
||||||
|
|
||||||
// TODO- move to video common
|
// TODO- move to video common
|
||||||
void InitBPMemory(BPMemory *bpMem);
|
void InitBPMemory(BPMemory *bpMem);
|
||||||
BPCmd DecodeBPCmd(u32 value, const BPMemory &bpMem);
|
BPCmd DecodeBPCmd(u32 value, const BPMemory &bpMem);
|
||||||
void LoadBPReg(const BPCmd &bp, BPMemory &bpMem);
|
void LoadBPReg(const BPCmd &bp, BPMemory &bpMem);
|
||||||
void GetTlutLoadData(u32 &tlutAddr, u32 &memAddr, u32 &tlutXferCount, BPMemory &bpMem);
|
void GetTlutLoadData(u32 &tlutAddr, u32 &memAddr, u32 &tlutXferCount, BPMemory &bpMem);
|
||||||
|
|
||||||
struct CPMemory
|
struct CPMemory
|
||||||
{
|
{
|
||||||
TVtxDesc vtxDesc;
|
TVtxDesc vtxDesc;
|
||||||
VAT vtxAttr[8];
|
VAT vtxAttr[8];
|
||||||
u32 arrayBases[16];
|
u32 arrayBases[16];
|
||||||
u32 arrayStrides[16];
|
u32 arrayStrides[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoadCPReg(u32 subCmd, u32 value, CPMemory &cpMem);
|
void LoadCPReg(u32 subCmd, u32 value, CPMemory &cpMem);
|
||||||
|
|
||||||
u32 CalculateVertexSize(int vatIndex, const CPMemory &cpMem);
|
u32 CalculateVertexSize(int vatIndex, const CPMemory &cpMem);
|
||||||
void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory &cpMem);
|
void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory &cpMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,346 +1,346 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "FifoAnalyzer.h"
|
#include "FifoAnalyzer.h"
|
||||||
#include "FifoDataFile.h"
|
#include "FifoDataFile.h"
|
||||||
#include "FifoPlaybackAnalyzer.h"
|
#include "FifoPlaybackAnalyzer.h"
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace FifoAnalyzer;
|
using namespace FifoAnalyzer;
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
#define LOG_FIFO_CMDS 0
|
#define LOG_FIFO_CMDS 0
|
||||||
struct CmdData
|
struct CmdData
|
||||||
{
|
{
|
||||||
u32 size;
|
u32 size;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u8 *ptr;
|
u8 *ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
FifoPlaybackAnalyzer::FifoPlaybackAnalyzer()
|
FifoPlaybackAnalyzer::FifoPlaybackAnalyzer()
|
||||||
{
|
{
|
||||||
FifoAnalyzer::Init();
|
FifoAnalyzer::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile *file, std::vector<AnalyzedFrameInfo> &frameInfo)
|
void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile *file, std::vector<AnalyzedFrameInfo> &frameInfo)
|
||||||
{
|
{
|
||||||
// Load BP memory
|
// Load BP memory
|
||||||
u32 *bpMem = file->GetBPMem();
|
u32 *bpMem = file->GetBPMem();
|
||||||
memcpy(&m_BpMem, bpMem, sizeof(BPMemory));
|
memcpy(&m_BpMem, bpMem, sizeof(BPMemory));
|
||||||
|
|
||||||
u32 *cpMem = file->GetCPMem();
|
u32 *cpMem = file->GetCPMem();
|
||||||
FifoAnalyzer::LoadCPReg(0x50, cpMem[0x50], m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x50, cpMem[0x50], m_CpMem);
|
||||||
FifoAnalyzer::LoadCPReg(0x60, cpMem[0x60], m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x60, cpMem[0x60], m_CpMem);
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
FifoAnalyzer::LoadCPReg(0x70 + i, cpMem[0x70 + i], m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x70 + i, cpMem[0x70 + i], m_CpMem);
|
||||||
FifoAnalyzer::LoadCPReg(0x80 + i, cpMem[0x80 + i], m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x80 + i, cpMem[0x80 + i], m_CpMem);
|
||||||
FifoAnalyzer::LoadCPReg(0x90 + i, cpMem[0x90 + i], m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x90 + i, cpMem[0x90 + i], m_CpMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
frameInfo.clear();
|
frameInfo.clear();
|
||||||
frameInfo.resize(file->GetFrameCount());
|
frameInfo.resize(file->GetFrameCount());
|
||||||
|
|
||||||
for (int frameIdx = 0; frameIdx < file->GetFrameCount(); ++frameIdx)
|
for (int frameIdx = 0; frameIdx < file->GetFrameCount(); ++frameIdx)
|
||||||
{
|
{
|
||||||
const FifoFrameInfo& frame = file->GetFrame(frameIdx);
|
const FifoFrameInfo& frame = file->GetFrame(frameIdx);
|
||||||
AnalyzedFrameInfo& analyzed = frameInfo[frameIdx];
|
AnalyzedFrameInfo& analyzed = frameInfo[frameIdx];
|
||||||
|
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmdStart = 0;
|
u32 cmdStart = 0;
|
||||||
u32 nextMemUpdate = 0;
|
u32 nextMemUpdate = 0;
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
vector<CmdData> prevCmds;
|
vector<CmdData> prevCmds;
|
||||||
|
|
||||||
while (cmdStart < frame.fifoDataSize)
|
while (cmdStart < frame.fifoDataSize)
|
||||||
{
|
{
|
||||||
// Add memory updates that have occured before this point in the frame
|
// Add memory updates that have occured before this point in the frame
|
||||||
while (nextMemUpdate < frame.memoryUpdates.size() && frame.memoryUpdates[nextMemUpdate].fifoPosition <= cmdStart)
|
while (nextMemUpdate < frame.memoryUpdates.size() && frame.memoryUpdates[nextMemUpdate].fifoPosition <= cmdStart)
|
||||||
{
|
{
|
||||||
AddMemoryUpdate(frame.memoryUpdates[nextMemUpdate], analyzed);
|
AddMemoryUpdate(frame.memoryUpdates[nextMemUpdate], analyzed);
|
||||||
++nextMemUpdate;
|
++nextMemUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wasDrawing = m_DrawingObject;
|
bool wasDrawing = m_DrawingObject;
|
||||||
|
|
||||||
u32 cmdSize = DecodeCommand(&frame.fifoData[cmdStart]);
|
u32 cmdSize = DecodeCommand(&frame.fifoData[cmdStart]);
|
||||||
|
|
||||||
#if (LOG_FIFO_CMDS)
|
#if (LOG_FIFO_CMDS)
|
||||||
CmdData cmdData;
|
CmdData cmdData;
|
||||||
cmdData.offset = cmdStart;
|
cmdData.offset = cmdStart;
|
||||||
cmdData.ptr = &frame.fifoData[cmdStart];
|
cmdData.ptr = &frame.fifoData[cmdStart];
|
||||||
cmdData.size = cmdSize;
|
cmdData.size = cmdSize;
|
||||||
prevCmds.push_back(cmdData);
|
prevCmds.push_back(cmdData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for error
|
// Check for error
|
||||||
if (cmdSize == 0)
|
if (cmdSize == 0)
|
||||||
{
|
{
|
||||||
// Clean up frame analysis
|
// Clean up frame analysis
|
||||||
analyzed.objectStarts.clear();
|
analyzed.objectStarts.clear();
|
||||||
analyzed.objectEnds.clear();
|
analyzed.objectEnds.clear();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasDrawing != m_DrawingObject)
|
if (wasDrawing != m_DrawingObject)
|
||||||
{
|
{
|
||||||
if (m_DrawingObject)
|
if (m_DrawingObject)
|
||||||
analyzed.objectStarts.push_back(cmdStart);
|
analyzed.objectStarts.push_back(cmdStart);
|
||||||
else
|
else
|
||||||
analyzed.objectEnds.push_back(cmdStart);
|
analyzed.objectEnds.push_back(cmdStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdStart += cmdSize;
|
cmdStart += cmdSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (analyzed.objectEnds.size() < analyzed.objectStarts.size())
|
if (analyzed.objectEnds.size() < analyzed.objectStarts.size())
|
||||||
analyzed.objectEnds.push_back(cmdStart);
|
analyzed.objectEnds.push_back(cmdStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlaybackAnalyzer::AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo &frameInfo)
|
void FifoPlaybackAnalyzer::AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo &frameInfo)
|
||||||
{
|
{
|
||||||
u32 begin = memUpdate.address;
|
u32 begin = memUpdate.address;
|
||||||
u32 end = memUpdate.address + memUpdate.size;
|
u32 end = memUpdate.address + memUpdate.size;
|
||||||
|
|
||||||
// Remove portions of memUpdate that overlap with memory ranges that have been written by the GP
|
// Remove portions of memUpdate that overlap with memory ranges that have been written by the GP
|
||||||
for (unsigned int i = 0; i < m_WrittenMemory.size(); ++i)
|
for (unsigned int i = 0; i < m_WrittenMemory.size(); ++i)
|
||||||
{
|
{
|
||||||
const MemoryRange &range = m_WrittenMemory[i];
|
const MemoryRange &range = m_WrittenMemory[i];
|
||||||
|
|
||||||
if (range.begin < end &&
|
if (range.begin < end &&
|
||||||
range.end > begin)
|
range.end > begin)
|
||||||
{
|
{
|
||||||
s32 preSize = range.begin - begin;
|
s32 preSize = range.begin - begin;
|
||||||
s32 postSize = end - range.end;
|
s32 postSize = end - range.end;
|
||||||
|
|
||||||
if (postSize > 0)
|
if (postSize > 0)
|
||||||
{
|
{
|
||||||
if (preSize > 0)
|
if (preSize > 0)
|
||||||
{
|
{
|
||||||
memUpdate.size = preSize;
|
memUpdate.size = preSize;
|
||||||
AddMemoryUpdate(memUpdate, frameInfo);
|
AddMemoryUpdate(memUpdate, frameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 bytesToRangeEnd = range.end - memUpdate.address;
|
u32 bytesToRangeEnd = range.end - memUpdate.address;
|
||||||
memUpdate.data += bytesToRangeEnd;
|
memUpdate.data += bytesToRangeEnd;
|
||||||
memUpdate.size = postSize;
|
memUpdate.size = postSize;
|
||||||
memUpdate.address = range.end;
|
memUpdate.address = range.end;
|
||||||
}
|
}
|
||||||
else if (preSize > 0)
|
else if (preSize > 0)
|
||||||
{
|
{
|
||||||
memUpdate.size = preSize;
|
memUpdate.size = preSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ignore all of memUpdate
|
// Ignore all of memUpdate
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frameInfo.memoryUpdates.push_back(memUpdate);
|
frameInfo.memoryUpdates.push_back(memUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 FifoPlaybackAnalyzer::DecodeCommand(u8 *data)
|
u32 FifoPlaybackAnalyzer::DecodeCommand(u8 *data)
|
||||||
{
|
{
|
||||||
u8 *dataStart = data;
|
u8 *dataStart = data;
|
||||||
|
|
||||||
int cmd = ReadFifo8(data);
|
int cmd = ReadFifo8(data);
|
||||||
|
|
||||||
switch(cmd)
|
switch(cmd)
|
||||||
{
|
{
|
||||||
case GX_NOP:
|
case GX_NOP:
|
||||||
case 0x44:
|
case 0x44:
|
||||||
case GX_CMD_INVL_VC:
|
case GX_CMD_INVL_VC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_CP_REG:
|
case GX_LOAD_CP_REG:
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmd2 = ReadFifo8(data);
|
u32 cmd2 = ReadFifo8(data);
|
||||||
u32 value = ReadFifo32(data);
|
u32 value = ReadFifo32(data);
|
||||||
FifoAnalyzer::LoadCPReg(cmd2, value, m_CpMem);
|
FifoAnalyzer::LoadCPReg(cmd2, value, m_CpMem);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_XF_REG:
|
case GX_LOAD_XF_REG:
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmd2 = ReadFifo32(data);
|
u32 cmd2 = ReadFifo32(data);
|
||||||
u8 streamSize = ((cmd2 >> 16) & 15) + 1;
|
u8 streamSize = ((cmd2 >> 16) & 15) + 1;
|
||||||
|
|
||||||
data += streamSize * 4;
|
data += streamSize * 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_INDX_A:
|
case GX_LOAD_INDX_A:
|
||||||
case GX_LOAD_INDX_B:
|
case GX_LOAD_INDX_B:
|
||||||
case GX_LOAD_INDX_C:
|
case GX_LOAD_INDX_C:
|
||||||
case GX_LOAD_INDX_D:
|
case GX_LOAD_INDX_D:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
data += 4;
|
data += 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_CMD_CALL_DL:
|
case GX_CMD_CALL_DL:
|
||||||
// The recorder should have expanded display lists into the fifo stream and skipped the call to start them
|
// The recorder should have expanded display lists into the fifo stream and skipped the call to start them
|
||||||
// That is done to make it easier to track where memory is updated
|
// That is done to make it easier to track where memory is updated
|
||||||
_assert_(false);
|
_assert_(false);
|
||||||
data += 8;
|
data += 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_BP_REG:
|
case GX_LOAD_BP_REG:
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmd2 = ReadFifo32(data);
|
u32 cmd2 = ReadFifo32(data);
|
||||||
BPCmd bp = FifoAnalyzer::DecodeBPCmd(cmd2, m_BpMem);
|
BPCmd bp = FifoAnalyzer::DecodeBPCmd(cmd2, m_BpMem);
|
||||||
|
|
||||||
FifoAnalyzer::LoadBPReg(bp, m_BpMem);
|
FifoAnalyzer::LoadBPReg(bp, m_BpMem);
|
||||||
|
|
||||||
if (bp.address == BPMEM_TRIGGER_EFB_COPY)
|
if (bp.address == BPMEM_TRIGGER_EFB_COPY)
|
||||||
StoreEfbCopyRegion();
|
StoreEfbCopyRegion();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (cmd & 0x80)
|
if (cmd & 0x80)
|
||||||
{
|
{
|
||||||
m_DrawingObject = true;
|
m_DrawingObject = true;
|
||||||
|
|
||||||
u32 vtxAttrGroup = cmd & GX_VAT_MASK;
|
u32 vtxAttrGroup = cmd & GX_VAT_MASK;
|
||||||
int vertexSize = FifoAnalyzer::CalculateVertexSize(vtxAttrGroup, m_CpMem);
|
int vertexSize = FifoAnalyzer::CalculateVertexSize(vtxAttrGroup, m_CpMem);
|
||||||
|
|
||||||
u16 streamSize = ReadFifo16(data);
|
u16 streamSize = ReadFifo16(data);
|
||||||
|
|
||||||
data += streamSize * vertexSize;
|
data += streamSize * vertexSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PanicAlert("FifoPlayer: Unknown Opcode (0x%x).\nAborting frame analysis.\n", cmd);
|
PanicAlert("FifoPlayer: Unknown Opcode (0x%x).\nAborting frame analysis.\n", cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data - dataStart;
|
return data - dataStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlaybackAnalyzer::StoreEfbCopyRegion()
|
void FifoPlaybackAnalyzer::StoreEfbCopyRegion()
|
||||||
{
|
{
|
||||||
UPE_Copy peCopy = m_BpMem.triggerEFBCopy;
|
UPE_Copy peCopy = m_BpMem.triggerEFBCopy;
|
||||||
|
|
||||||
u32 copyfmt = peCopy.tp_realFormat();
|
u32 copyfmt = peCopy.tp_realFormat();
|
||||||
bool bFromZBuffer = m_BpMem.zcontrol.pixel_format == PIXELFMT_Z24;
|
bool bFromZBuffer = m_BpMem.zcontrol.pixel_format == PIXELFMT_Z24;
|
||||||
u32 address = bpmem.copyTexDest << 5;
|
u32 address = bpmem.copyTexDest << 5;
|
||||||
|
|
||||||
u32 format = copyfmt;
|
u32 format = copyfmt;
|
||||||
|
|
||||||
if (peCopy.copy_to_xfb)
|
if (peCopy.copy_to_xfb)
|
||||||
{
|
{
|
||||||
// Fake format to calculate size correctly
|
// Fake format to calculate size correctly
|
||||||
format = GX_TF_IA8;
|
format = GX_TF_IA8;
|
||||||
}
|
}
|
||||||
else if (bFromZBuffer)
|
else if (bFromZBuffer)
|
||||||
{
|
{
|
||||||
format |= _GX_TF_ZTF;
|
format |= _GX_TF_ZTF;
|
||||||
if (copyfmt == 11)
|
if (copyfmt == 11)
|
||||||
format = GX_TF_Z16;
|
format = GX_TF_Z16;
|
||||||
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
||||||
format |= _GX_TF_CTF;
|
format |= _GX_TF_CTF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !peCopy.intensity_fmt))
|
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !peCopy.intensity_fmt))
|
||||||
format |= _GX_TF_CTF;
|
format |= _GX_TF_CTF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = (m_BpMem.copyTexSrcWH.x + 1) >> peCopy.half_scale;
|
int width = (m_BpMem.copyTexSrcWH.x + 1) >> peCopy.half_scale;
|
||||||
int height = (m_BpMem.copyTexSrcWH.y + 1) >> peCopy.half_scale;
|
int height = (m_BpMem.copyTexSrcWH.y + 1) >> peCopy.half_scale;
|
||||||
|
|
||||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
||||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
||||||
|
|
||||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
s32 expandedWidth = (width + blkW) & (~blkW);
|
||||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
s32 expandedHeight = (height + blkH) & (~blkH);
|
||||||
|
|
||||||
int sizeInBytes = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, format);
|
int sizeInBytes = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, format);
|
||||||
|
|
||||||
StoreWrittenRegion(address, sizeInBytes);
|
StoreWrittenRegion(address, sizeInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlaybackAnalyzer::StoreWrittenRegion(u32 address, u32 size)
|
void FifoPlaybackAnalyzer::StoreWrittenRegion(u32 address, u32 size)
|
||||||
{
|
{
|
||||||
u32 end = address + size;
|
u32 end = address + size;
|
||||||
vector<MemoryRange>::iterator newRangeIter = m_WrittenMemory.end();
|
vector<MemoryRange>::iterator newRangeIter = m_WrittenMemory.end();
|
||||||
|
|
||||||
// Search for overlapping memory regions and expand them to include the new region
|
// Search for overlapping memory regions and expand them to include the new region
|
||||||
for (vector<MemoryRange>::iterator iter = m_WrittenMemory.begin(); iter != m_WrittenMemory.end();)
|
for (vector<MemoryRange>::iterator iter = m_WrittenMemory.begin(); iter != m_WrittenMemory.end();)
|
||||||
{
|
{
|
||||||
MemoryRange &range = *iter;
|
MemoryRange &range = *iter;
|
||||||
|
|
||||||
if (range.begin < end && range.end > address)
|
if (range.begin < end && range.end > address)
|
||||||
{
|
{
|
||||||
// range at iterator and new range overlap
|
// range at iterator and new range overlap
|
||||||
|
|
||||||
if (newRangeIter == m_WrittenMemory.end())
|
if (newRangeIter == m_WrittenMemory.end())
|
||||||
{
|
{
|
||||||
// Expand range to include the written region
|
// Expand range to include the written region
|
||||||
range.begin = std::min(address, range.begin);
|
range.begin = std::min(address, range.begin);
|
||||||
range.end = std::max(end, range.end);
|
range.end = std::max(end, range.end);
|
||||||
newRangeIter = iter;
|
newRangeIter = iter;
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Expand region at rangeIter to include this range
|
// Expand region at rangeIter to include this range
|
||||||
MemoryRange &used = *newRangeIter;
|
MemoryRange &used = *newRangeIter;
|
||||||
used.begin = std::min(used.begin, range.begin);
|
used.begin = std::min(used.begin, range.begin);
|
||||||
used.end = std::max(used.end, range.end);
|
used.end = std::max(used.end, range.end);
|
||||||
|
|
||||||
// Remove this entry
|
// Remove this entry
|
||||||
iter = m_WrittenMemory.erase(iter);
|
iter = m_WrittenMemory.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRangeIter == m_WrittenMemory.end())
|
if (newRangeIter == m_WrittenMemory.end())
|
||||||
{
|
{
|
||||||
MemoryRange range;
|
MemoryRange range;
|
||||||
range.begin = address;
|
range.begin = address;
|
||||||
range.end = end;
|
range.end = end;
|
||||||
|
|
||||||
m_WrittenMemory.push_back(range);
|
m_WrittenMemory.push_back(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,64 +1,64 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _FIFOPLAYBACKANALYZER_H_
|
#ifndef _FIFOPLAYBACKANALYZER_H_
|
||||||
#define _FIFOPLAYBACKANALYZER_H_
|
#define _FIFOPLAYBACKANALYZER_H_
|
||||||
|
|
||||||
#include "FifoAnalyzer.h"
|
#include "FifoAnalyzer.h"
|
||||||
#include "FifoDataFile.h"
|
#include "FifoDataFile.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct AnalyzedFrameInfo
|
struct AnalyzedFrameInfo
|
||||||
{
|
{
|
||||||
std::vector<u32> objectStarts;
|
std::vector<u32> objectStarts;
|
||||||
std::vector<u32> objectEnds;
|
std::vector<u32> objectEnds;
|
||||||
std::vector<MemoryUpdate> memoryUpdates;
|
std::vector<MemoryUpdate> memoryUpdates;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FifoPlaybackAnalyzer
|
class FifoPlaybackAnalyzer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FifoPlaybackAnalyzer();
|
FifoPlaybackAnalyzer();
|
||||||
|
|
||||||
void AnalyzeFrames(FifoDataFile *file, std::vector<AnalyzedFrameInfo> &frameInfo);
|
void AnalyzeFrames(FifoDataFile *file, std::vector<AnalyzedFrameInfo> &frameInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MemoryRange
|
struct MemoryRange
|
||||||
{
|
{
|
||||||
u32 begin;
|
u32 begin;
|
||||||
u32 end;
|
u32 end;
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo &frameInfo);
|
void AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo &frameInfo);
|
||||||
|
|
||||||
u32 DecodeCommand(u8 *data);
|
u32 DecodeCommand(u8 *data);
|
||||||
void LoadBP(u32 value0);
|
void LoadBP(u32 value0);
|
||||||
|
|
||||||
void StoreEfbCopyRegion();
|
void StoreEfbCopyRegion();
|
||||||
void StoreWrittenRegion(u32 address, u32 size);
|
void StoreWrittenRegion(u32 address, u32 size);
|
||||||
|
|
||||||
bool m_DrawingObject;
|
bool m_DrawingObject;
|
||||||
|
|
||||||
std::vector<MemoryRange> m_WrittenMemory;
|
std::vector<MemoryRange> m_WrittenMemory;
|
||||||
|
|
||||||
BPMemory m_BpMem;
|
BPMemory m_BpMem;
|
||||||
FifoAnalyzer::CPMemory m_CpMem;
|
FifoAnalyzer::CPMemory m_CpMem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,305 +1,305 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "FifoAnalyzer.h"
|
#include "FifoAnalyzer.h"
|
||||||
#include "FifoRecordAnalyzer.h"
|
#include "FifoRecordAnalyzer.h"
|
||||||
#include "FifoRecorder.h"
|
#include "FifoRecorder.h"
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "HW/Memmap.h"
|
#include "HW/Memmap.h"
|
||||||
|
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
|
|
||||||
using namespace FifoAnalyzer;
|
using namespace FifoAnalyzer;
|
||||||
|
|
||||||
|
|
||||||
FifoRecordAnalyzer::FifoRecordAnalyzer() :
|
FifoRecordAnalyzer::FifoRecordAnalyzer() :
|
||||||
m_DrawingObject(false),
|
m_DrawingObject(false),
|
||||||
m_BpMem(NULL)
|
m_BpMem(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::Initialize(u32 *bpMem, u32 *cpMem)
|
void FifoRecordAnalyzer::Initialize(u32 *bpMem, u32 *cpMem)
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
m_BpMem = (BPMemory*)bpMem;
|
m_BpMem = (BPMemory*)bpMem;
|
||||||
|
|
||||||
FifoAnalyzer::LoadCPReg(0x50, *(cpMem + 0x50), m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x50, *(cpMem + 0x50), m_CpMem);
|
||||||
FifoAnalyzer::LoadCPReg(0x60, *(cpMem + 0x60), m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x60, *(cpMem + 0x60), m_CpMem);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
FifoAnalyzer::LoadCPReg(0x70 + i, *(cpMem + 0x70 + i), m_CpMem);
|
FifoAnalyzer::LoadCPReg(0x70 + i, *(cpMem + 0x70 + i), m_CpMem);
|
||||||
|
|
||||||
memcpy(m_CpMem.arrayBases, cpMem + 0xA0, 16 * 4);
|
memcpy(m_CpMem.arrayBases, cpMem + 0xA0, 16 * 4);
|
||||||
memcpy(m_CpMem.arrayStrides, cpMem + 0xB0, 16 * 4);
|
memcpy(m_CpMem.arrayStrides, cpMem + 0xB0, 16 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::AnalyzeGPCommand(u8 *data)
|
void FifoRecordAnalyzer::AnalyzeGPCommand(u8 *data)
|
||||||
{
|
{
|
||||||
DecodeOpcode(data);
|
DecodeOpcode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::DecodeOpcode(u8 *data)
|
void FifoRecordAnalyzer::DecodeOpcode(u8 *data)
|
||||||
{
|
{
|
||||||
int cmd = ReadFifo8(data);
|
int cmd = ReadFifo8(data);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case GX_NOP:
|
case GX_NOP:
|
||||||
case 0x44:
|
case 0x44:
|
||||||
case GX_CMD_INVL_VC:
|
case GX_CMD_INVL_VC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_CP_REG:
|
case GX_LOAD_CP_REG:
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmd2 = ReadFifo8(data);
|
u32 cmd2 = ReadFifo8(data);
|
||||||
u32 value = ReadFifo32(data);
|
u32 value = ReadFifo32(data);
|
||||||
FifoAnalyzer::LoadCPReg(cmd2, value, m_CpMem);
|
FifoAnalyzer::LoadCPReg(cmd2, value, m_CpMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_XF_REG:
|
case GX_LOAD_XF_REG:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_INDX_A:
|
case GX_LOAD_INDX_A:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
ProcessLoadIndexedXf(ReadFifo32(data), 0xc);
|
ProcessLoadIndexedXf(ReadFifo32(data), 0xc);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_B:
|
case GX_LOAD_INDX_B:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
ProcessLoadIndexedXf(ReadFifo32(data), 0xd);
|
ProcessLoadIndexedXf(ReadFifo32(data), 0xd);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_C:
|
case GX_LOAD_INDX_C:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
ProcessLoadIndexedXf(ReadFifo32(data), 0xe);
|
ProcessLoadIndexedXf(ReadFifo32(data), 0xe);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_D:
|
case GX_LOAD_INDX_D:
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
ProcessLoadIndexedXf(ReadFifo32(data), 0xf);
|
ProcessLoadIndexedXf(ReadFifo32(data), 0xf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_CMD_CALL_DL:
|
case GX_CMD_CALL_DL:
|
||||||
{
|
{
|
||||||
// The recorder should have expanded display lists into the fifo stream and skipped the call to start them
|
// The recorder should have expanded display lists into the fifo stream and skipped the call to start them
|
||||||
// That is done to make it easier to track where memory is updated
|
// That is done to make it easier to track where memory is updated
|
||||||
_assert_(false);
|
_assert_(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_BP_REG:
|
case GX_LOAD_BP_REG:
|
||||||
{
|
{
|
||||||
m_DrawingObject = false;
|
m_DrawingObject = false;
|
||||||
|
|
||||||
u32 cmd2 = ReadFifo32(data);
|
u32 cmd2 = ReadFifo32(data);
|
||||||
BPCmd bp = FifoAnalyzer::DecodeBPCmd(cmd2, *m_BpMem);
|
BPCmd bp = FifoAnalyzer::DecodeBPCmd(cmd2, *m_BpMem);
|
||||||
|
|
||||||
if (bp.address == BPMEM_LOADTLUT1)
|
if (bp.address == BPMEM_LOADTLUT1)
|
||||||
ProcessLoadTlut1();
|
ProcessLoadTlut1();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (cmd & 0x80)
|
if (cmd & 0x80)
|
||||||
{
|
{
|
||||||
if (!m_DrawingObject)
|
if (!m_DrawingObject)
|
||||||
{
|
{
|
||||||
m_DrawingObject = true;
|
m_DrawingObject = true;
|
||||||
ProcessTexMaps();
|
ProcessTexMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessVertexArrays(data, cmd & GX_VAT_MASK);
|
ProcessVertexArrays(data, cmd & GX_VAT_MASK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PanicAlert("FifoRecordAnalyzer: Unknown Opcode (0x%x).\n", cmd);
|
PanicAlert("FifoRecordAnalyzer: Unknown Opcode (0x%x).\n", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::ProcessLoadTlut1()
|
void FifoRecordAnalyzer::ProcessLoadTlut1()
|
||||||
{
|
{
|
||||||
u32 tlutXferCount;
|
u32 tlutXferCount;
|
||||||
u32 tlutMemAddr;
|
u32 tlutMemAddr;
|
||||||
u32 memAddr;
|
u32 memAddr;
|
||||||
|
|
||||||
GetTlutLoadData(tlutMemAddr, memAddr, tlutXferCount, *m_BpMem);
|
GetTlutLoadData(tlutMemAddr, memAddr, tlutXferCount, *m_BpMem);
|
||||||
|
|
||||||
FifoRecorder::GetInstance().WriteMemory(memAddr, tlutXferCount, MemoryUpdate::TLUT);
|
FifoRecorder::GetInstance().WriteMemory(memAddr, tlutXferCount, MemoryUpdate::TLUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::ProcessLoadIndexedXf(u32 val, int array)
|
void FifoRecordAnalyzer::ProcessLoadIndexedXf(u32 val, int array)
|
||||||
{
|
{
|
||||||
int index = val >> 16;
|
int index = val >> 16;
|
||||||
int size = ((val >> 12) & 0xF) + 1;
|
int size = ((val >> 12) & 0xF) + 1;
|
||||||
|
|
||||||
u32 address = m_CpMem.arrayBases[array] + m_CpMem.arrayStrides[array] * index;
|
u32 address = m_CpMem.arrayBases[array] + m_CpMem.arrayStrides[array] * index;
|
||||||
|
|
||||||
FifoRecorder::GetInstance().WriteMemory(address, size * 4, MemoryUpdate::XF_DATA);
|
FifoRecorder::GetInstance().WriteMemory(address, size * 4, MemoryUpdate::XF_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::ProcessVertexArrays(u8 *data, u8 vtxAttrGroup)
|
void FifoRecordAnalyzer::ProcessVertexArrays(u8 *data, u8 vtxAttrGroup)
|
||||||
{
|
{
|
||||||
int sizes[21];
|
int sizes[21];
|
||||||
FifoAnalyzer::CalculateVertexElementSizes(sizes, vtxAttrGroup, m_CpMem);
|
FifoAnalyzer::CalculateVertexElementSizes(sizes, vtxAttrGroup, m_CpMem);
|
||||||
|
|
||||||
// Determine offset of each element from start of vertex data
|
// Determine offset of each element from start of vertex data
|
||||||
int offsets[12];
|
int offsets[12];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int i = 0; i < 12; ++i)
|
for (int i = 0; i < 12; ++i)
|
||||||
{
|
{
|
||||||
offsets[i] = offset;
|
offsets[i] = offset;
|
||||||
offset += sizes[i + 9];
|
offset += sizes[i + 9];
|
||||||
}
|
}
|
||||||
|
|
||||||
int vertexSize = offset;
|
int vertexSize = offset;
|
||||||
int numVertices = ReadFifo16(data);
|
int numVertices = ReadFifo16(data);
|
||||||
|
|
||||||
if (numVertices > 0)
|
if (numVertices > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 12; ++i)
|
for (int i = 0; i < 12; ++i)
|
||||||
{
|
{
|
||||||
WriteVertexArray(i, data + offsets[i], vertexSize, numVertices);
|
WriteVertexArray(i, data + offsets[i], vertexSize, numVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::WriteVertexArray(int arrayIndex, u8 *vertexData, int vertexSize, int numVertices)
|
void FifoRecordAnalyzer::WriteVertexArray(int arrayIndex, u8 *vertexData, int vertexSize, int numVertices)
|
||||||
{
|
{
|
||||||
// Skip if not indexed array
|
// Skip if not indexed array
|
||||||
int arrayType = (m_CpMem.vtxDesc.Hex >> (9 + (arrayIndex * 2))) & 3;
|
int arrayType = (m_CpMem.vtxDesc.Hex >> (9 + (arrayIndex * 2))) & 3;
|
||||||
if (arrayType < 2)
|
if (arrayType < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int maxIndex = 0;
|
int maxIndex = 0;
|
||||||
|
|
||||||
// Determine min and max indices
|
// Determine min and max indices
|
||||||
if (arrayType == INDEX8)
|
if (arrayType == INDEX8)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numVertices; ++i)
|
for (int i = 0; i < numVertices; ++i)
|
||||||
{
|
{
|
||||||
int index = *vertexData;
|
int index = *vertexData;
|
||||||
vertexData += vertexSize;
|
vertexData += vertexSize;
|
||||||
|
|
||||||
// 0xff skips the vertex
|
// 0xff skips the vertex
|
||||||
if (index != 0xff)
|
if (index != 0xff)
|
||||||
{
|
{
|
||||||
if (index > maxIndex)
|
if (index > maxIndex)
|
||||||
maxIndex = index;
|
maxIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numVertices; ++i)
|
for (int i = 0; i < numVertices; ++i)
|
||||||
{
|
{
|
||||||
int index = Common::swap16(vertexData);
|
int index = Common::swap16(vertexData);
|
||||||
vertexData += vertexSize;
|
vertexData += vertexSize;
|
||||||
|
|
||||||
// 0xffff skips the vertex
|
// 0xffff skips the vertex
|
||||||
if (index != 0xffff)
|
if (index != 0xffff)
|
||||||
{
|
{
|
||||||
if (index > maxIndex)
|
if (index > maxIndex)
|
||||||
maxIndex = index;
|
maxIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 arrayStart = m_CpMem.arrayBases[arrayIndex];
|
u32 arrayStart = m_CpMem.arrayBases[arrayIndex];
|
||||||
u32 arraySize = m_CpMem.arrayStrides[arrayIndex] * (maxIndex + 1);
|
u32 arraySize = m_CpMem.arrayStrides[arrayIndex] * (maxIndex + 1);
|
||||||
|
|
||||||
FifoRecorder::GetInstance().WriteMemory(arrayStart, arraySize, MemoryUpdate::VERTEX_STREAM);
|
FifoRecorder::GetInstance().WriteMemory(arrayStart, arraySize, MemoryUpdate::VERTEX_STREAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::ProcessTexMaps()
|
void FifoRecordAnalyzer::ProcessTexMaps()
|
||||||
{
|
{
|
||||||
u32 writtenTexMaps = 0;
|
u32 writtenTexMaps = 0;
|
||||||
|
|
||||||
// Texture maps used in TEV indirect stages
|
// Texture maps used in TEV indirect stages
|
||||||
for (u32 i = 0; i < m_BpMem->genMode.numindstages; ++i)
|
for (u32 i = 0; i < m_BpMem->genMode.numindstages; ++i)
|
||||||
{
|
{
|
||||||
u32 texMap = m_BpMem->tevindref.getTexMap(i);
|
u32 texMap = m_BpMem->tevindref.getTexMap(i);
|
||||||
|
|
||||||
WriteTexMapMemory(texMap, writtenTexMaps);
|
WriteTexMapMemory(texMap, writtenTexMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture maps used in TEV direct stages
|
// Texture maps used in TEV direct stages
|
||||||
for (u32 i = 0; i <= m_BpMem->genMode.numtevstages; ++i)
|
for (u32 i = 0; i <= m_BpMem->genMode.numtevstages; ++i)
|
||||||
{
|
{
|
||||||
int stageNum2 = i >> 1;
|
int stageNum2 = i >> 1;
|
||||||
int stageOdd = i & 1;
|
int stageOdd = i & 1;
|
||||||
TwoTevStageOrders &order = m_BpMem->tevorders[stageNum2];
|
TwoTevStageOrders &order = m_BpMem->tevorders[stageNum2];
|
||||||
int texMap = order.getTexMap(stageOdd);
|
int texMap = order.getTexMap(stageOdd);
|
||||||
|
|
||||||
if (order.getEnable(stageOdd))
|
if (order.getEnable(stageOdd))
|
||||||
WriteTexMapMemory(texMap, writtenTexMaps);
|
WriteTexMapMemory(texMap, writtenTexMaps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoRecordAnalyzer::WriteTexMapMemory(int texMap, u32 &writtenTexMaps)
|
void FifoRecordAnalyzer::WriteTexMapMemory(int texMap, u32 &writtenTexMaps)
|
||||||
{
|
{
|
||||||
// Avoid rechecking the same texture map
|
// Avoid rechecking the same texture map
|
||||||
u32 texMapMask = 1 << texMap;
|
u32 texMapMask = 1 << texMap;
|
||||||
if (writtenTexMaps & texMapMask)
|
if (writtenTexMaps & texMapMask)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
writtenTexMaps |= texMapMask;
|
writtenTexMaps |= texMapMask;
|
||||||
|
|
||||||
FourTexUnits& texUnit = m_BpMem->tex[(texMap >> 2) & 1];
|
FourTexUnits& texUnit = m_BpMem->tex[(texMap >> 2) & 1];
|
||||||
u8 subTexmap = texMap & 3;
|
u8 subTexmap = texMap & 3;
|
||||||
|
|
||||||
TexImage0& ti0 = texUnit.texImage0[subTexmap];
|
TexImage0& ti0 = texUnit.texImage0[subTexmap];
|
||||||
|
|
||||||
u32 width = ti0.width + 1;
|
u32 width = ti0.width + 1;
|
||||||
u32 height = ti0.height + 1;
|
u32 height = ti0.height + 1;
|
||||||
u32 imageBase = texUnit.texImage3[subTexmap].image_base << 5;
|
u32 imageBase = texUnit.texImage3[subTexmap].image_base << 5;
|
||||||
|
|
||||||
u32 fmtWidth = TexDecoder_GetBlockWidthInTexels(ti0.format) - 1;
|
u32 fmtWidth = TexDecoder_GetBlockWidthInTexels(ti0.format) - 1;
|
||||||
u32 fmtHeight = TexDecoder_GetBlockHeightInTexels(ti0.format) - 1;
|
u32 fmtHeight = TexDecoder_GetBlockHeightInTexels(ti0.format) - 1;
|
||||||
int fmtDepth = TexDecoder_GetTexelSizeInNibbles(ti0.format);
|
int fmtDepth = TexDecoder_GetTexelSizeInNibbles(ti0.format);
|
||||||
|
|
||||||
// Round width and height up to the next block
|
// Round width and height up to the next block
|
||||||
width = (width + fmtWidth) & (~fmtWidth);
|
width = (width + fmtWidth) & (~fmtWidth);
|
||||||
height = (height + fmtHeight) & (~fmtHeight);
|
height = (height + fmtHeight) & (~fmtHeight);
|
||||||
|
|
||||||
u32 textureSize = (width * height * fmtDepth) / 2;
|
u32 textureSize = (width * height * fmtDepth) / 2;
|
||||||
|
|
||||||
// TODO: mip maps
|
// TODO: mip maps
|
||||||
int mip = texUnit.texMode1[subTexmap].max_lod;
|
int mip = texUnit.texMode1[subTexmap].max_lod;
|
||||||
if ((texUnit.texMode0[subTexmap].min_filter & 3) == 0)
|
if ((texUnit.texMode0[subTexmap].min_filter & 3) == 0)
|
||||||
mip = 0;
|
mip = 0;
|
||||||
|
|
||||||
while (mip)
|
while (mip)
|
||||||
{
|
{
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
height >>= 1;
|
height >>= 1;
|
||||||
|
|
||||||
width = max(width, fmtWidth);
|
width = max(width, fmtWidth);
|
||||||
height = max(height, fmtHeight);
|
height = max(height, fmtHeight);
|
||||||
u32 size = (width * height * fmtDepth) >> 1;
|
u32 size = (width * height * fmtDepth) >> 1;
|
||||||
|
|
||||||
textureSize += size;
|
textureSize += size;
|
||||||
|
|
||||||
mip--;
|
mip--;
|
||||||
}
|
}
|
||||||
|
|
||||||
FifoRecorder::GetInstance().WriteMemory(imageBase, textureSize, MemoryUpdate::TEXTURE_MAP);
|
FifoRecorder::GetInstance().WriteMemory(imageBase, textureSize, MemoryUpdate::TEXTURE_MAP);
|
||||||
}
|
}
|
@ -1,56 +1,56 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _FIFORECORDANALYZER_H_
|
#ifndef _FIFORECORDANALYZER_H_
|
||||||
#define _FIFORECORDANALYZER_H_
|
#define _FIFORECORDANALYZER_H_
|
||||||
|
|
||||||
#include "FifoAnalyzer.h"
|
#include "FifoAnalyzer.h"
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "BPMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
class FifoRecordAnalyzer
|
class FifoRecordAnalyzer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FifoRecordAnalyzer();
|
FifoRecordAnalyzer();
|
||||||
|
|
||||||
// Must call this before analyzing GP commands
|
// Must call this before analyzing GP commands
|
||||||
void Initialize(u32 *bpMem, u32 *cpMem);
|
void Initialize(u32 *bpMem, u32 *cpMem);
|
||||||
|
|
||||||
// Assumes data contains all information for the command
|
// Assumes data contains all information for the command
|
||||||
// Calls FifoRecorder::WriteMemory
|
// Calls FifoRecorder::WriteMemory
|
||||||
void AnalyzeGPCommand(u8 *data);
|
void AnalyzeGPCommand(u8 *data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DecodeOpcode(u8 *data);
|
void DecodeOpcode(u8 *data);
|
||||||
|
|
||||||
void ProcessLoadTlut1();
|
void ProcessLoadTlut1();
|
||||||
void ProcessLoadIndexedXf(u32 val, int array);
|
void ProcessLoadIndexedXf(u32 val, int array);
|
||||||
void ProcessVertexArrays(u8 *data, u8 vtxAttrGroup);
|
void ProcessVertexArrays(u8 *data, u8 vtxAttrGroup);
|
||||||
void ProcessTexMaps();
|
void ProcessTexMaps();
|
||||||
|
|
||||||
void WriteVertexArray(int arrayIndex, u8 *vertexData, int vertexSize, int numVertices);
|
void WriteVertexArray(int arrayIndex, u8 *vertexData, int vertexSize, int numVertices);
|
||||||
void WriteTexMapMemory(int texMap, u32 &writtenTexMaps);
|
void WriteTexMapMemory(int texMap, u32 &writtenTexMaps);
|
||||||
|
|
||||||
bool m_DrawingObject;
|
bool m_DrawingObject;
|
||||||
|
|
||||||
BPMemory *m_BpMem;
|
BPMemory *m_BpMem;
|
||||||
FifoAnalyzer::CPMemory m_CpMem;
|
FifoAnalyzer::CPMemory m_CpMem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -28,6 +28,7 @@ else:
|
|||||||
'Src/Debugger/MemoryWindow.cpp',
|
'Src/Debugger/MemoryWindow.cpp',
|
||||||
'Src/Debugger/RegisterView.cpp',
|
'Src/Debugger/RegisterView.cpp',
|
||||||
'Src/Debugger/RegisterWindow.cpp',
|
'Src/Debugger/RegisterWindow.cpp',
|
||||||
|
'Src/FifoPlayerDlg.cpp',
|
||||||
'Src/Frame.cpp',
|
'Src/Frame.cpp',
|
||||||
'Src/FrameAui.cpp',
|
'Src/FrameAui.cpp',
|
||||||
'Src/FrameTools.cpp',
|
'Src/FrameTools.cpp',
|
||||||
|
Reference in New Issue
Block a user