| 
									
										
										
										
											2013-04-17 23:29:41 -04:00
										 |  |  | // Copyright 2013 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "Common/Common.h"
 | 
					
						
							|  |  |  | #include "Common/FileUtil.h"
 | 
					
						
							|  |  |  | #include "Common/StringUtil.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/BPMemLoader.h"
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/DebugUtil.h"
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/EfbInterface.h"
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/HwRasterizer.h"
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/SWCommandProcessor.h"
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | #include "VideoBackends/Software/SWRenderer.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-19 12:14:09 +01:00
										 |  |  | #include "VideoBackends/Software/SWStatistics.h"
 | 
					
						
							|  |  |  | #include "VideoBackends/Software/SWVideoConfig.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "VideoBackends/Software/TextureSampler.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 16:49:33 +02:00
										 |  |  | #include "VideoCommon/Fifo.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "VideoCommon/ImageWrite.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace DebugUtil | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-05 15:19:10 +01:00
										 |  |  | static bool drawingHwTriangles = false; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | static const int NUM_OBJECT_BUFFERS = 40; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | static u32 *ObjectBuffer[NUM_OBJECT_BUFFERS]; | 
					
						
							|  |  |  | static u32 TempBuffer[NUM_OBJECT_BUFFERS]; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | static bool DrawnToBuffer[NUM_OBJECT_BUFFERS]; | 
					
						
							|  |  |  | static const char* ObjectBufferName[NUM_OBJECT_BUFFERS]; | 
					
						
							|  |  |  | static int BufferBase[NUM_OBJECT_BUFFERS]; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Init() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | 	for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2014-03-05 15:19:10 +01:00
										 |  |  | 		ObjectBuffer[i] = new u32[EFB_WIDTH*EFB_HEIGHT](); | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		DrawnToBuffer[i] = false; | 
					
						
							| 
									
										
										
										
											2014-03-09 21:14:26 +01:00
										 |  |  | 		ObjectBufferName[i] = nullptr; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 		BufferBase[i] = 0; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-05 15:19:10 +01:00
										 |  |  | void Shutdown() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | 	for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) | 
					
						
							| 
									
										
										
										
											2014-03-05 15:19:10 +01:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		delete[] ObjectBuffer[i]; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:29:26 +02:00
										 |  |  | static void SaveTexture(const std::string& filename, u32 texmap, s32 mip) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; | 
					
						
							|  |  |  | 	u8 subTexmap = texmap & 3; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	TexImage0& ti0 = texUnit.texImage0[subTexmap]; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-14 16:29:52 -05:00
										 |  |  | 	u32 width = ti0.width + 1; | 
					
						
							|  |  |  | 	u32 height = ti0.height + 1; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	u8 *data = new u8[width * height * 4]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 	GetTextureRGBA(data, texmap, mip, width, height); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | 	TextureToPng(data, width*4, filename, width, height, true); | 
					
						
							| 
									
										
										
										
											2013-11-17 10:34:34 +13:00
										 |  |  | 	delete[] data; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | void GetTextureRGBA(u8 *dst, u32 texmap, s32 mip, u32 width, u32 height) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	for (u32 y = 0; y < height; y++) | 
					
						
							| 
									
										
										
										
											2013-01-14 16:29:52 -05:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		for (u32 x = 0; x < width; x++) | 
					
						
							| 
									
										
										
										
											2013-01-14 16:29:52 -05:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			TextureSampler::SampleMip(x << 7, y << 7, mip, false, texmap, dst); | 
					
						
							|  |  |  | 			dst += 4; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-01-14 16:29:52 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:29:26 +02:00
										 |  |  | static s32 GetMaxTextureLod(u32 texmap) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	u8 subTexmap = texmap & 3; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	u8 maxLod = texUnit.texMode1[subTexmap].max_lod; | 
					
						
							|  |  |  | 	u8 mip = maxLod >> 4; | 
					
						
							|  |  |  | 	u8 fract = maxLod & 0xf; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-11 00:30:55 +13:00
										 |  |  | 	if (fract) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 		++mip; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return (s32)mip; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DumpActiveTextures() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		u32 texmap = bpmem.tevindref.getTexMap(stageNum); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		s32 maxLod = GetMaxTextureLod(texmap); | 
					
						
							|  |  |  | 		for (s32 mip = 0; mip <= maxLod; ++mip) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			SaveTexture(StringFromFormat("%star%i_ind%i_map%i_mip%i.png", | 
					
						
							| 
									
										
										
										
											2013-11-17 11:28:11 +13:00
										 |  |  | 						File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(), | 
					
						
							| 
									
										
										
										
											2013-11-17 11:25:12 +13:00
										 |  |  | 						swstats.thisFrame.numDrawnObjects, stageNum, texmap, mip), texmap, mip); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	for (unsigned int stageNum = 0; stageNum <= bpmem.genMode.numtevstages; stageNum++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int stageNum2 = stageNum >> 1; | 
					
						
							|  |  |  | 		int stageOdd = stageNum&1; | 
					
						
							|  |  |  | 		TwoTevStageOrders &order = bpmem.tevorders[stageNum2]; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		int texmap = order.getTexMap(stageOdd); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		s32 maxLod = GetMaxTextureLod(texmap); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 		for (s32 mip = 0; mip <= maxLod; ++mip) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			SaveTexture(StringFromFormat("%star%i_stage%i_map%i_mip%i.png", | 
					
						
							| 
									
										
										
										
											2013-11-17 11:28:11 +13:00
										 |  |  | 						File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(), | 
					
						
							| 
									
										
										
										
											2013-11-17 11:25:12 +13:00
										 |  |  | 						swstats.thisFrame.numDrawnObjects, stageNum, texmap, mip), texmap, mip); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:29:26 +02:00
										 |  |  | static void DumpEfb(const std::string& filename) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			// ABGR to RGBA
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 			*(writePtr++) = sample[3]; | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			*(writePtr++) = sample[2]; | 
					
						
							|  |  |  | 			*(writePtr++) = sample[1]; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 			*(writePtr++) = sample[0]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | 	TextureToPng(data, EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true); | 
					
						
							| 
									
										
										
										
											2013-11-17 10:34:34 +13:00
										 |  |  | 	delete[] data; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | static void DumpColorTexture(const std::string& filename, u32 width, u32 height) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-10 22:01:42 -04:00
										 |  |  | 	TextureToPng(SWRenderer::GetCurrentColorTexture(), width * 4, filename, width, height, true); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	int buffer = bufferBase + subBuffer; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	u32 offset = (x + y * EFB_WIDTH) * 4; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	u8 *dst = (u8*)&ObjectBuffer[buffer][offset]; | 
					
						
							|  |  |  | 	*(dst++) = color[2]; | 
					
						
							|  |  |  | 	*(dst++) = color[1]; | 
					
						
							|  |  |  | 	*(dst++) = color[0]; | 
					
						
							|  |  |  | 	*(dst++) = color[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DrawnToBuffer[buffer] = true; | 
					
						
							|  |  |  | 	ObjectBufferName[buffer] = name; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 	BufferBase[buffer] = bufferBase; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DrawTempBuffer(u8 *color, int buffer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 *dst = (u8*)&TempBuffer[buffer]; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	*(dst++) = color[2]; | 
					
						
							|  |  |  | 	*(dst++) = color[1]; | 
					
						
							|  |  |  | 	*(dst++) = color[0]; | 
					
						
							|  |  |  | 	*(dst++) = color[3]; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char *name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int buffer = bufferBase + subBuffer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	u32 offset = (x + y * EFB_WIDTH); | 
					
						
							|  |  |  | 	ObjectBuffer[buffer][offset] = TempBuffer[buffer]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DrawnToBuffer[buffer] = true; | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	ObjectBufferName[buffer] = name; | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 	BufferBase[buffer] = bufferBase; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void OnObjectBegin() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	if (!g_bSkipCurrentFrame) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (g_SWVideoConfig.bDumpTextures && swstats.thisFrame.numDrawnObjects >= g_SWVideoConfig.drawStart && swstats.thisFrame.numDrawnObjects < g_SWVideoConfig.drawEnd) | 
					
						
							|  |  |  | 			DumpActiveTextures(); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		if (g_SWVideoConfig.bHwRasterizer) | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 			HwRasterizer::BeginTriangles(); | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 			drawingHwTriangles = true; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void OnObjectEnd() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	if (!g_bSkipCurrentFrame) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (g_SWVideoConfig.bDumpObjects && swstats.thisFrame.numDrawnObjects >= g_SWVideoConfig.drawStart && swstats.thisFrame.numDrawnObjects < g_SWVideoConfig.drawEnd) | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 			DumpEfb(StringFromFormat("%sobject%i.png", | 
					
						
							| 
									
										
										
										
											2011-02-28 20:40:15 +00:00
										 |  |  | 						File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), | 
					
						
							| 
									
										
										
										
											2013-11-17 11:25:12 +13:00
										 |  |  | 						swstats.thisFrame.numDrawnObjects)); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		if (g_SWVideoConfig.bHwRasterizer || drawingHwTriangles) | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 			HwRasterizer::EndTriangles(); | 
					
						
							| 
									
										
										
										
											2010-12-02 05:38:48 +00:00
										 |  |  | 			drawingHwTriangles = false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-10 20:51:10 -04:00
										 |  |  | 		for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			if (DrawnToBuffer[i]) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				DrawnToBuffer[i] = false; | 
					
						
							| 
									
										
										
										
											2013-11-16 15:59:59 +13:00
										 |  |  | 				std::string filename = StringFromFormat("%sobject%i_%s(%i).png", | 
					
						
							|  |  |  | 					File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), | 
					
						
							|  |  |  | 					swstats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | 				TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true); | 
					
						
							| 
									
										
										
										
											2014-03-05 15:19:10 +01:00
										 |  |  | 				memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32)); | 
					
						
							| 
									
										
										
										
											2013-11-17 10:34:34 +13:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		swstats.thisFrame.numDrawnObjects++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | // If frame dumping is enabled, dump whatever is drawn to the screen.
 | 
					
						
							|  |  |  | void OnFrameEnd(u32 width, u32 height) | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 	if (!g_bSkipCurrentFrame) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (g_SWVideoConfig.bDumpFrames) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2014-07-14 23:51:55 +12:00
										 |  |  | 			DumpColorTexture(StringFromFormat("%sframe%i_color.png", | 
					
						
							|  |  |  | 					File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), swstats.frameCount), width, height); | 
					
						
							| 
									
										
										
										
											2013-04-13 23:54:02 -04:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |