summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/DebugUtil.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-06-24 10:43:46 +0200
committerPierre Bourdon <delroth@gmail.com>2016-06-24 10:43:46 +0200
commit3570c7f03a2aa90aa634f96c0af1969af610f14d (patch)
tree4252e03c0e853ba7cffe022937698c854ad0eaa9 /Source/Core/VideoBackends/Software/DebugUtil.cpp
parent2115e8a4a6814e32107b5205ff5c95bbd3c6e99c (diff)
Reformat all the things. Have fun with merge conflicts.
Diffstat (limited to 'Source/Core/VideoBackends/Software/DebugUtil.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/DebugUtil.cpp289
1 files changed, 145 insertions, 144 deletions
diff --git a/Source/Core/VideoBackends/Software/DebugUtil.cpp b/Source/Core/VideoBackends/Software/DebugUtil.cpp
index 0e2b4e1934..4d0d73137e 100644
--- a/Source/Core/VideoBackends/Software/DebugUtil.cpp
+++ b/Source/Core/VideoBackends/Software/DebugUtil.cpp
@@ -21,10 +21,9 @@
namespace DebugUtil
{
-
static const int NUM_OBJECT_BUFFERS = 40;
-static u32 *ObjectBuffer[NUM_OBJECT_BUFFERS];
+static u32* ObjectBuffer[NUM_OBJECT_BUFFERS];
static u32 TempBuffer[NUM_OBJECT_BUFFERS];
static bool DrawnToBuffer[NUM_OBJECT_BUFFERS];
@@ -33,197 +32,199 @@ static int BufferBase[NUM_OBJECT_BUFFERS];
void Init()
{
- for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
- {
- ObjectBuffer[i] = new u32[EFB_WIDTH*EFB_HEIGHT]();
- DrawnToBuffer[i] = false;
- ObjectBufferName[i] = nullptr;
- BufferBase[i] = 0;
- }
+ for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
+ {
+ ObjectBuffer[i] = new u32[EFB_WIDTH * EFB_HEIGHT]();
+ DrawnToBuffer[i] = false;
+ ObjectBufferName[i] = nullptr;
+ BufferBase[i] = 0;
+ }
}
void Shutdown()
{
- for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
- {
- delete[] ObjectBuffer[i];
- }
+ for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
+ {
+ delete[] ObjectBuffer[i];
+ }
}
static void SaveTexture(const std::string& filename, u32 texmap, s32 mip)
{
- FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
- u8 subTexmap = texmap & 3;
-
- TexImage0& ti0 = texUnit.texImage0[subTexmap];
+ FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
+ u8 subTexmap = texmap & 3;
- u32 width = ti0.width + 1;
- u32 height = ti0.height + 1;
+ TexImage0& ti0 = texUnit.texImage0[subTexmap];
- u8 *data = new u8[width * height * 4];
+ u32 width = ti0.width + 1;
+ u32 height = ti0.height + 1;
- GetTextureRGBA(data, texmap, mip, width, height);
+ u8* data = new u8[width * height * 4];
- TextureToPng(data, width*4, filename, width, height, true);
- delete[] data;
+ GetTextureRGBA(data, texmap, mip, width, height);
+ TextureToPng(data, width * 4, filename, width, height, true);
+ delete[] data;
}
-void GetTextureRGBA(u8 *dst, u32 texmap, s32 mip, u32 width, u32 height)
+void GetTextureRGBA(u8* dst, u32 texmap, s32 mip, u32 width, u32 height)
{
- for (u32 y = 0; y < height; y++)
- {
- for (u32 x = 0; x < width; x++)
- {
- TextureSampler::SampleMip(x << 7, y << 7, mip, false, texmap, dst);
- dst += 4;
- }
- }
+ for (u32 y = 0; y < height; y++)
+ {
+ for (u32 x = 0; x < width; x++)
+ {
+ TextureSampler::SampleMip(x << 7, y << 7, mip, false, texmap, dst);
+ dst += 4;
+ }
+ }
}
static s32 GetMaxTextureLod(u32 texmap)
{
- FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
- u8 subTexmap = texmap & 3;
+ FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
+ u8 subTexmap = texmap & 3;
- u8 maxLod = texUnit.texMode1[subTexmap].max_lod;
- u8 mip = maxLod >> 4;
- u8 fract = maxLod & 0xf;
+ u8 maxLod = texUnit.texMode1[subTexmap].max_lod;
+ u8 mip = maxLod >> 4;
+ u8 fract = maxLod & 0xf;
- if (fract)
- ++mip;
+ if (fract)
+ ++mip;
- return (s32)mip;
+ return (s32)mip;
}
void DumpActiveTextures()
{
- for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++)
- {
- u32 texmap = bpmem.tevindref.getTexMap(stageNum);
-
- s32 maxLod = GetMaxTextureLod(texmap);
- for (s32 mip = 0; mip <= maxLod; ++mip)
- {
- SaveTexture(StringFromFormat("%star%i_ind%i_map%i_mip%i.png",
- File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
- stats.thisFrame.numDrawnObjects, stageNum, texmap, mip), texmap, mip);
- }
- }
-
- for (unsigned int stageNum = 0; stageNum <= bpmem.genMode.numtevstages; stageNum++)
- {
- int stageNum2 = stageNum >> 1;
- int stageOdd = stageNum&1;
- TwoTevStageOrders &order = bpmem.tevorders[stageNum2];
-
- int texmap = order.getTexMap(stageOdd);
-
- s32 maxLod = GetMaxTextureLod(texmap);
- for (s32 mip = 0; mip <= maxLod; ++mip)
- {
- SaveTexture(StringFromFormat("%star%i_stage%i_map%i_mip%i.png",
- File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
- stats.thisFrame.numDrawnObjects, stageNum, texmap, mip), texmap, mip);
- }
- }
+ for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++)
+ {
+ u32 texmap = bpmem.tevindref.getTexMap(stageNum);
+
+ s32 maxLod = GetMaxTextureLod(texmap);
+ for (s32 mip = 0; mip <= maxLod; ++mip)
+ {
+ SaveTexture(StringFromFormat("%star%i_ind%i_map%i_mip%i.png",
+ File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
+ stats.thisFrame.numDrawnObjects, stageNum, texmap, mip),
+ texmap, mip);
+ }
+ }
+
+ for (unsigned int stageNum = 0; stageNum <= bpmem.genMode.numtevstages; stageNum++)
+ {
+ int stageNum2 = stageNum >> 1;
+ int stageOdd = stageNum & 1;
+ TwoTevStageOrders& order = bpmem.tevorders[stageNum2];
+
+ int texmap = order.getTexMap(stageOdd);
+
+ s32 maxLod = GetMaxTextureLod(texmap);
+ for (s32 mip = 0; mip <= maxLod; ++mip)
+ {
+ SaveTexture(StringFromFormat("%star%i_stage%i_map%i_mip%i.png",
+ File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
+ stats.thisFrame.numDrawnObjects, stageNum, texmap, mip),
+ texmap, mip);
+ }
+ }
}
static void DumpEfb(const std::string& filename)
{
- u8 *data = new u8[EFB_WIDTH * EFB_HEIGHT * 4];
- u8 *writePtr = data;
- u8 sample[4];
-
- for (int y = 0; y < EFB_HEIGHT; y++)
- {
- for (int x = 0; x < EFB_WIDTH; x++)
- {
- EfbInterface::GetColor(x, y, sample);
- // ABGR to RGBA
- *(writePtr++) = sample[3];
- *(writePtr++) = sample[2];
- *(writePtr++) = sample[1];
- *(writePtr++) = sample[0];
- }
- }
-
- TextureToPng(data, EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
- delete[] data;
+ u8* data = new u8[EFB_WIDTH * EFB_HEIGHT * 4];
+ u8* writePtr = data;
+ u8 sample[4];
+
+ for (int y = 0; y < EFB_HEIGHT; y++)
+ {
+ for (int x = 0; x < EFB_WIDTH; x++)
+ {
+ EfbInterface::GetColor(x, y, sample);
+ // ABGR to RGBA
+ *(writePtr++) = sample[3];
+ *(writePtr++) = sample[2];
+ *(writePtr++) = sample[1];
+ *(writePtr++) = sample[0];
+ }
+ }
+
+ TextureToPng(data, EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
+ delete[] data;
}
-void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name)
+void DrawObjectBuffer(s16 x, s16 y, u8* color, int bufferBase, int subBuffer, const char* name)
{
- int buffer = bufferBase + subBuffer;
-
- u32 offset = (x + y * EFB_WIDTH) * 4;
- u8 *dst = (u8*)&ObjectBuffer[buffer][offset];
- *(dst++) = color[2];
- *(dst++) = color[1];
- *(dst++) = color[0];
- *(dst++) = color[3];
-
- DrawnToBuffer[buffer] = true;
- ObjectBufferName[buffer] = name;
- BufferBase[buffer] = bufferBase;
+ int buffer = bufferBase + subBuffer;
+
+ u32 offset = (x + y * EFB_WIDTH) * 4;
+ u8* dst = (u8*)&ObjectBuffer[buffer][offset];
+ *(dst++) = color[2];
+ *(dst++) = color[1];
+ *(dst++) = color[0];
+ *(dst++) = color[3];
+
+ DrawnToBuffer[buffer] = true;
+ ObjectBufferName[buffer] = name;
+ BufferBase[buffer] = bufferBase;
}
-void DrawTempBuffer(u8 *color, int buffer)
+void DrawTempBuffer(u8* color, int buffer)
{
- u8 *dst = (u8*)&TempBuffer[buffer];
- *(dst++) = color[2];
- *(dst++) = color[1];
- *(dst++) = color[0];
- *(dst++) = color[3];
+ u8* dst = (u8*)&TempBuffer[buffer];
+ *(dst++) = color[2];
+ *(dst++) = color[1];
+ *(dst++) = color[0];
+ *(dst++) = color[3];
}
-void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char *name)
+void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char* name)
{
- int buffer = bufferBase + subBuffer;
+ int buffer = bufferBase + subBuffer;
- u32 offset = (x + y * EFB_WIDTH);
- ObjectBuffer[buffer][offset] = TempBuffer[buffer];
+ u32 offset = (x + y * EFB_WIDTH);
+ ObjectBuffer[buffer][offset] = TempBuffer[buffer];
- DrawnToBuffer[buffer] = true;
- ObjectBufferName[buffer] = name;
- BufferBase[buffer] = bufferBase;
+ DrawnToBuffer[buffer] = true;
+ ObjectBufferName[buffer] = name;
+ BufferBase[buffer] = bufferBase;
}
void OnObjectBegin()
{
- if (!Fifo::WillSkipCurrentFrame())
- {
- if (g_ActiveConfig.bDumpTextures && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart && stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
- DumpActiveTextures();
- }
+ if (!Fifo::WillSkipCurrentFrame())
+ {
+ if (g_ActiveConfig.bDumpTextures &&
+ stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
+ stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
+ DumpActiveTextures();
+ }
}
void OnObjectEnd()
{
- if (!Fifo::WillSkipCurrentFrame())
- {
- if (g_ActiveConfig.bDumpObjects && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart && stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
- DumpEfb(StringFromFormat("%sobject%i.png",
- File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
- stats.thisFrame.numDrawnObjects));
-
- for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
- {
- if (DrawnToBuffer[i])
- {
- DrawnToBuffer[i] = false;
- std::string filename = StringFromFormat("%sobject%i_%s(%i).png",
- File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
- stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]);
-
- TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
- memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32));
-
- }
- }
-
- stats.thisFrame.numDrawnObjects++;
- }
+ if (!Fifo::WillSkipCurrentFrame())
+ {
+ if (g_ActiveConfig.bDumpObjects &&
+ stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
+ stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
+ DumpEfb(StringFromFormat("%sobject%i.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
+ stats.thisFrame.numDrawnObjects));
+
+ for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
+ {
+ if (DrawnToBuffer[i])
+ {
+ DrawnToBuffer[i] = false;
+ std::string filename = StringFromFormat(
+ "%sobject%i_%s(%i).png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
+ stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]);
+
+ TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
+ memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32));
+ }
+ }
+
+ stats.thisFrame.numDrawnObjects++;
+ }
}
-
}