| 
									
										
										
										
											2013-04-17 23:09:55 -04:00
										 |  |  | // Copyright 2013 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // ---------------------------------------------------------------------------------------------
 | 
					
						
							|  |  |  | // GC graphics pipeline
 | 
					
						
							|  |  |  | // ---------------------------------------------------------------------------------------------
 | 
					
						
							|  |  |  | // 3d commands are issued through the fifo. The gpu draws to the 2MB EFB.
 | 
					
						
							|  |  |  | // The efb can be copied back into ram in two forms: as textures or as XFB.
 | 
					
						
							|  |  |  | // The XFB is the region in RAM that the VI chip scans out to the television.
 | 
					
						
							|  |  |  | // So, after all rendering to EFB is done, the image is copied into one of two XFBs in RAM.
 | 
					
						
							|  |  |  | // Next frame, that one is scanned out and the other one gets the copy. = double buffering.
 | 
					
						
							|  |  |  | // ---------------------------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "RenderBase.h"
 | 
					
						
							|  |  |  | #include "Atomic.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | #include "BPMemory.h"
 | 
					
						
							|  |  |  | #include "CommandProcessor.h"
 | 
					
						
							|  |  |  | #include "CPMemory.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | #include "MainBase.h"
 | 
					
						
							|  |  |  | #include "VideoConfig.h"
 | 
					
						
							|  |  |  | #include "FramebufferManagerBase.h"
 | 
					
						
							| 
									
										
										
										
											2011-02-08 03:47:59 +00:00
										 |  |  | #include "TextureCacheBase.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | #include "Fifo.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | #include "OpcodeDecoding.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | #include "Timer.h"
 | 
					
						
							|  |  |  | #include "StringUtil.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-15 23:09:12 +00:00
										 |  |  | #include "Host.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | #include "XFMemory.h"
 | 
					
						
							|  |  |  | #include "FifoPlayer/FifoRecorder.h"
 | 
					
						
							| 
									
										
										
										
											2011-09-08 17:09:24 +02:00
										 |  |  | #include "AVIDump.h"
 | 
					
						
							| 
									
										
										
										
											2012-03-24 16:30:00 +01:00
										 |  |  | #include "VertexShaderManager.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <cmath>
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Move these out of here.
 | 
					
						
							|  |  |  | int frameCount; | 
					
						
							| 
									
										
										
										
											2011-01-31 03:02:23 +00:00
										 |  |  | int OSDChoice, OSDTime; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-02 15:13:13 +00:00
										 |  |  | Renderer *g_renderer = NULL; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-05 06:11:26 +00:00
										 |  |  | std::mutex Renderer::s_criticalScreenshot; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | std::string Renderer::s_sScreenshotName; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | volatile bool Renderer::s_bScreenshot; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // The framebuffer size
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | int Renderer::s_target_width; | 
					
						
							|  |  |  | int Renderer::s_target_height; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // TODO: Add functionality to reinit all the render targets when the window is resized.
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | int Renderer::s_backbuffer_width; | 
					
						
							|  |  |  | int Renderer::s_backbuffer_height; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | TargetRectangle Renderer::target_rc; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | int Renderer::s_LastEFBScale; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Renderer::s_skipSwap; | 
					
						
							|  |  |  | bool Renderer::XFBWrited; | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | bool Renderer::s_EnableDLCachingAfterRecording; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-27 21:56:20 +00:00
										 |  |  | unsigned int Renderer::prev_efb_format = (unsigned int)-1; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | unsigned int Renderer::efb_scale_numeratorX = 1; | 
					
						
							|  |  |  | unsigned int Renderer::efb_scale_numeratorY = 1; | 
					
						
							|  |  |  | unsigned int Renderer::efb_scale_denominatorX = 1; | 
					
						
							|  |  |  | unsigned int Renderer::efb_scale_denominatorY = 1; | 
					
						
							|  |  |  | unsigned int Renderer::ssaa_multiplier = 1; | 
					
						
							| 
									
										
										
										
											2010-12-27 21:56:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-28 11:31:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-26 20:47:48 -05:00
										 |  |  | Renderer::Renderer() | 
					
						
							|  |  |  | 	: frame_data() | 
					
						
							|  |  |  | 	, bLastFrameDumped(false) | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	UpdateActiveConfig(); | 
					
						
							| 
									
										
										
										
											2012-05-28 11:31:37 +02:00
										 |  |  | 	TextureCache::OnConfigChanged(g_ActiveConfig); | 
					
						
							| 
									
										
										
										
											2011-09-08 17:09:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined _WIN32 || defined HAVE_LIBAV
 | 
					
						
							|  |  |  | 	bAVIDumping = false; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	OSDChoice = 0; | 
					
						
							|  |  |  | 	OSDTime = 0; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Renderer::~Renderer() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-12-27 21:56:20 +00:00
										 |  |  | 	// invalidate previous efb format
 | 
					
						
							|  |  |  | 	prev_efb_format = (unsigned int)-1; | 
					
						
							| 
									
										
										
										
											2011-09-08 17:09:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 	efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = ssaa_multiplier = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-08 17:09:24 +02:00
										 |  |  | #if defined _WIN32 || defined HAVE_LIBAV
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.bDumpFrames && bLastFrameDumped && bAVIDumping) | 
					
						
							|  |  |  | 		AVIDump::Stop(); | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2011-09-09 16:30:29 +02:00
										 |  |  | 	if (pFrameDump.IsOpen()) | 
					
						
							|  |  |  | 		pFrameDump.Close(); | 
					
						
							| 
									
										
										
										
											2011-09-08 17:09:24 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-31 07:06:53 +00:00
										 |  |  | void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | 	CheckFifoRecording(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	if (!fbWidth || !fbHeight) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	s_skipSwap = g_bSkipCurrentFrame; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	VideoFifo_CheckEFBAccess(); | 
					
						
							|  |  |  | 	VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight); | 
					
						
							|  |  |  | 	XFBWrited = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.bUseXFB) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-12-27 03:18:01 +00:00
										 |  |  | 		FramebufferManagerBase::CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc,Gamma); | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-09-23 18:29:31 +12:00
										 |  |  | 		g_renderer->Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma); | 
					
						
							| 
									
										
										
										
											2011-02-02 04:40:27 +00:00
										 |  |  | 		Common::AtomicStoreRelease(s_swapRequested, false); | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | int Renderer::EFBToScaledX(int x) | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	switch (g_ActiveConfig.iEFBScale) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_AUTO: // fractional
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbWidth(x, s_backbuffer_width); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return x * (int)ssaa_multiplier * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int Renderer::EFBToScaledY(int y) | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	switch (g_ActiveConfig.iEFBScale) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 		case SCALE_AUTO: // fractional
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbHeight(y, s_backbuffer_height); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return y * (int)ssaa_multiplier * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY) | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL) | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		scaledX = x; | 
					
						
							|  |  |  | 		scaledY = y; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | 		scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX; | 
					
						
							|  |  |  | 		scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // return true if target size changed
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier) | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | 	int newEFBWidth, newEFBHeight; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// TODO: Ugly. Clean up
 | 
					
						
							|  |  |  | 	switch (s_LastEFBScale) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		case 2: // 1x
 | 
					
						
							|  |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 1; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 1; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 		case 3: // 1.5x
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 3; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 2; | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 		case 4: // 2x
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 2; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 1; | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 		case 5: // 2.5x
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 5; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 2; | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 		case 6: // 3x
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 3; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 1; | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 		case 7: // 4x
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = efb_scale_numeratorY = 4; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = efb_scale_denominatorY = 1; | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		default: // fractional & integral handled later
 | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	switch (s_LastEFBScale) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-12-20 09:17:21 +00:00
										 |  |  | 		case 0: // fractional
 | 
					
						
							|  |  |  | 		case 1: // integral
 | 
					
						
							| 
									
										
										
										
											2012-09-29 00:19:28 +02:00
										 |  |  | 			newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, framebuffer_width); | 
					
						
							|  |  |  | 			newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, framebuffer_height); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			if (s_LastEFBScale == 1) | 
					
						
							| 
									
										
										
										
											2012-09-29 00:19:28 +02:00
										 |  |  | 			{ | 
					
						
							|  |  |  | 				newEFBWidth = ((newEFBWidth-1) / EFB_WIDTH + 1) * EFB_WIDTH; | 
					
						
							|  |  |  | 				newEFBHeight = ((newEFBHeight-1) / EFB_HEIGHT + 1) * EFB_HEIGHT; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 			efb_scale_numeratorX = newEFBWidth; | 
					
						
							|  |  |  | 			efb_scale_denominatorX = EFB_WIDTH; | 
					
						
							|  |  |  | 			efb_scale_numeratorY = newEFBHeight; | 
					
						
							|  |  |  | 			efb_scale_denominatorY = EFB_HEIGHT; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-09-29 00:19:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight); | 
					
						
							| 
									
										
										
										
											2011-07-05 01:11:03 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2011-01-07 04:57:59 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-10 15:54:14 +00:00
										 |  |  | 	newEFBWidth *= multiplier; | 
					
						
							|  |  |  | 	newEFBHeight *= multiplier; | 
					
						
							| 
									
										
										
										
											2012-10-02 22:11:15 +02:00
										 |  |  | 	ssaa_multiplier = multiplier; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-10 15:54:14 +00:00
										 |  |  | 	if (newEFBWidth != s_target_width || newEFBHeight != s_target_height) | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-05-12 02:14:45 +00:00
										 |  |  | 		s_target_width  = newEFBWidth; | 
					
						
							|  |  |  | 		s_target_height = newEFBHeight; | 
					
						
							| 
									
										
										
										
											2012-03-24 16:30:00 +01:00
										 |  |  | 		VertexShaderManager::SetViewportChanged(); | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Renderer::SetScreenshot(const char *filename) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-03-05 06:11:26 +00:00
										 |  |  | 	std::lock_guard<std::mutex> lk(s_criticalScreenshot); | 
					
						
							| 
									
										
										
										
											2010-12-10 15:54:14 +00:00
										 |  |  | 	s_sScreenshotName = filename; | 
					
						
							|  |  |  | 	s_bScreenshot = true; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Create On-Screen-Messages
 | 
					
						
							|  |  |  | void Renderer::DrawDebugText() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// OSD Menu messages
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	if (OSDChoice > 0) | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		OSDTime = Common::Timer::GetTimeMs() + 3000; | 
					
						
							|  |  |  | 		OSDChoice = -OSDChoice; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	if ((u32)OSDTime <= Common::Timer::GetTimeMs()) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	const char* res_text = ""; | 
					
						
							|  |  |  | 	switch (g_ActiveConfig.iEFBScale) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_AUTO: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "Auto (fractional)"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_AUTO_INTEGRAL: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "Auto (integral)"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_1X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "Native"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_1_5X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "1.5x"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_2X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "2x"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_2_5X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "2.5x"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_3X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "3x"; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2013-04-06 01:48:00 -04:00
										 |  |  | 	case SCALE_4X: | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 		res_text = "4x"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	const char* ar_text = ""; | 
					
						
							|  |  |  | 	switch(g_ActiveConfig.iAspectRatio) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	case ASPECT_AUTO: | 
					
						
							|  |  |  | 		ar_text = "Auto"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ASPECT_FORCE_16_9: | 
					
						
							|  |  |  | 		ar_text = "16:9"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ASPECT_FORCE_4_3: | 
					
						
							|  |  |  | 		ar_text = "4:3"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ASPECT_STRETCH: | 
					
						
							|  |  |  | 		ar_text = "Stretch"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	const char* const efbcopy_text = g_ActiveConfig.bEFBCopyEnable ? | 
					
						
							|  |  |  | 		(g_ActiveConfig.bCopyEFBToTexture ? "to Texture" : "to RAM") : "Disabled"; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	// The rows
 | 
					
						
							|  |  |  | 	const std::string lines[] = | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		std::string("3: Internal Resolution: ") + res_text, | 
					
						
							|  |  |  | 		std::string("4: Aspect Ratio: ") + ar_text + (g_ActiveConfig.bCrop ? " (crop)" : ""), | 
					
						
							|  |  |  | 		std::string("5: Copy EFB: ") + efbcopy_text, | 
					
						
							|  |  |  | 		std::string("6: Fog: ") + (g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"), | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	enum { lines_count = sizeof(lines)/sizeof(*lines) }; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	std::string final_yellow, final_cyan; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	// If there is more text than this we will have a collision
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.bShowFPS) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		final_yellow = final_cyan = "\n\n"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The latest changed setting in yellow
 | 
					
						
							|  |  |  | 	for (int i = 0; i != lines_count; ++i) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (OSDChoice == -i - 1) | 
					
						
							|  |  |  | 			final_yellow += lines[i]; | 
					
						
							|  |  |  | 		final_yellow += '\n'; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 	// The other settings in cyan
 | 
					
						
							|  |  |  | 	for (int i = 0; i != lines_count; ++i) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (OSDChoice != -i - 1) | 
					
						
							|  |  |  | 			final_cyan += lines[i]; | 
					
						
							|  |  |  | 		final_cyan += '\n'; | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-12-31 16:21:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Render a shadow
 | 
					
						
							|  |  |  | 	g_renderer->RenderText(final_cyan.c_str(), 21, 21, 0xDD000000); | 
					
						
							|  |  |  | 	g_renderer->RenderText(final_yellow.c_str(), 21, 21, 0xDD000000); | 
					
						
							|  |  |  | 	//and then the text
 | 
					
						
							|  |  |  | 	g_renderer->RenderText(final_cyan.c_str(), 20, 20, 0xFF00FFFF); | 
					
						
							|  |  |  | 	g_renderer->RenderText(final_yellow.c_str(), 20, 20, 0xFFFFFF00); | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | // TODO: remove
 | 
					
						
							|  |  |  | extern bool g_aspect_wide; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 	float FloatGLWidth = (float)backbuffer_width; | 
					
						
							|  |  |  | 	float FloatGLHeight = (float)backbuffer_height; | 
					
						
							|  |  |  | 	float FloatXOffset = 0; | 
					
						
							|  |  |  | 	float FloatYOffset = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The rendering window size
 | 
					
						
							|  |  |  | 	const float WinWidth = FloatGLWidth; | 
					
						
							|  |  |  | 	const float WinHeight = FloatGLHeight; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Handle aspect ratio.
 | 
					
						
							|  |  |  | 	// Default to auto.
 | 
					
						
							|  |  |  | 	bool use16_9 = g_aspect_wide; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Update aspect ratio hack values
 | 
					
						
							|  |  |  | 	// Won't take effect until next frame
 | 
					
						
							|  |  |  | 	// Don't know if there is a better place for this code so there isn't a 1 frame delay
 | 
					
						
							|  |  |  | 	if ( g_ActiveConfig.bWidescreenHack ) | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 		float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f); | 
					
						
							|  |  |  | 		float target_aspect; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		switch ( g_ActiveConfig.iAspectRatio ) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		case ASPECT_FORCE_16_9 : | 
					
						
							|  |  |  | 			target_aspect = 16.0f / 9.0f; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ASPECT_FORCE_4_3 : | 
					
						
							|  |  |  | 			target_aspect = 4.0f / 3.0f; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ASPECT_STRETCH : | 
					
						
							|  |  |  | 			target_aspect = WinWidth / WinHeight; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default : | 
					
						
							|  |  |  | 			// ASPECT_AUTO == no hacking
 | 
					
						
							|  |  |  | 			target_aspect = source_aspect; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		float adjust = source_aspect / target_aspect; | 
					
						
							|  |  |  | 		if ( adjust > 1 ) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			// Vert+
 | 
					
						
							|  |  |  | 			g_Config.fAspectRatioHackW = 1; | 
					
						
							|  |  |  | 			g_Config.fAspectRatioHackH = 1/adjust; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			// Hor+
 | 
					
						
							|  |  |  | 			g_Config.fAspectRatioHackW = adjust; | 
					
						
							|  |  |  | 			g_Config.fAspectRatioHackH = 1; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 		// Hack is disabled
 | 
					
						
							|  |  |  | 		g_Config.fAspectRatioHackW = 1; | 
					
						
							|  |  |  | 		g_Config.fAspectRatioHackH = 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Check for force-settings and override.
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9) | 
					
						
							|  |  |  | 		use16_9 = true; | 
					
						
							|  |  |  | 	else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3) | 
					
						
							|  |  |  | 		use16_9 = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
 | 
					
						
							|  |  |  | 		float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f)); | 
					
						
							|  |  |  | 		// Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
 | 
					
						
							|  |  |  | 		if (Ratio > 1.0f) | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 			// Scale down and center in the X direction.
 | 
					
						
							|  |  |  | 			FloatGLWidth /= Ratio; | 
					
						
							|  |  |  | 			FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f; | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 		// The window is too high, we have to limit the height
 | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 		else | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 			// Scale down and center in the Y direction.
 | 
					
						
							|  |  |  | 			FloatGLHeight *= Ratio; | 
					
						
							|  |  |  | 			FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f; | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-09-29 00:04:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// -----------------------------------------------------------------------
 | 
					
						
							|  |  |  | 	// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
 | 
					
						
							|  |  |  | 	//		Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
 | 
					
						
							|  |  |  | 	// ------------------
 | 
					
						
							|  |  |  | 	if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f))); | 
					
						
							|  |  |  | 		// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
 | 
					
						
							|  |  |  | 		float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth; | 
					
						
							|  |  |  | 		float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight; | 
					
						
							|  |  |  | 		// The new width and height
 | 
					
						
							|  |  |  | 		FloatGLWidth = FloatGLWidth * Ratio; | 
					
						
							|  |  |  | 		FloatGLHeight = FloatGLHeight * Ratio; | 
					
						
							|  |  |  | 		// Adjust the X and Y offset
 | 
					
						
							|  |  |  | 		FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f); | 
					
						
							|  |  |  | 		FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int XOffset = (int)(FloatXOffset + 0.5f); | 
					
						
							|  |  |  | 	int YOffset = (int)(FloatYOffset + 0.5f); | 
					
						
							|  |  |  | 	int iWhidth = (int)ceil(FloatGLWidth); | 
					
						
							|  |  |  | 	int iHeight = (int)ceil(FloatGLHeight); | 
					
						
							|  |  |  | 	iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
 | 
					
						
							|  |  |  | 	iHeight -= iHeight % 4; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	target_rc.left = XOffset; | 
					
						
							|  |  |  | 	target_rc.top = YOffset; | 
					
						
							|  |  |  | 	target_rc.right = XOffset + iWhidth; | 
					
						
							|  |  |  | 	target_rc.bottom = YOffset + iHeight; | 
					
						
							| 
									
										
										
										
											2010-11-18 03:50:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:46:11 -05:00
										 |  |  | void Renderer::SetWindowSize(int width, int height) | 
					
						
							| 
									
										
										
										
											2011-03-15 23:09:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (width < 1) | 
					
						
							|  |  |  | 		width = 1; | 
					
						
							|  |  |  | 	if (height < 1) | 
					
						
							|  |  |  | 		height = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Scale the window size by the EFB scale.
 | 
					
						
							|  |  |  | 	CalculateTargetScale(width, height, width, height); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Host_RequestRenderWindowSize(width, height); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-27 02:55:08 +00:00
										 |  |  | void Renderer::CheckFifoRecording() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	bool wasRecording = g_bRecordFifoData; | 
					
						
							|  |  |  | 	g_bRecordFifoData = FifoRecorder::GetInstance().IsRecording(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (g_bRecordFifoData) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (!wasRecording) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			// Disable display list caching because the recorder does not handle it
 | 
					
						
							|  |  |  | 			s_EnableDLCachingAfterRecording = g_ActiveConfig.bDlistCachingEnable; | 
					
						
							|  |  |  | 			g_ActiveConfig.bDlistCachingEnable = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			RecordVideoMemory(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		FifoRecorder::GetInstance().EndFrame(CommandProcessor::fifo.CPBase, CommandProcessor::fifo.CPEnd); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (wasRecording) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		g_ActiveConfig.bDlistCachingEnable = s_EnableDLCachingAfterRecording; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Renderer::RecordVideoMemory() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 *bpMem = (u32*)&bpmem; | 
					
						
							|  |  |  | 	u32 cpMem[256]; | 
					
						
							|  |  |  | 	u32 *xfMem = (u32*)xfmem; | 
					
						
							|  |  |  | 	u32 *xfRegs = (u32*)&xfregs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	memset(cpMem, 0, 256 * 4); | 
					
						
							|  |  |  | 	FillCPMemoryArray(cpMem); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	FifoRecorder::GetInstance().SetVideoMemory(bpMem, cpMem, xfMem, xfRegs, sizeof(XFRegisters) / 4); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-12 02:14:45 +00:00
										 |  |  | void UpdateViewport(Matrix44& vpCorrection) | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-07 01:34:20 +02:00
										 |  |  | 	if (xfregs.viewport.wd != 0 && xfregs.viewport.ht != 0) | 
					
						
							|  |  |  | 		g_renderer->UpdateViewport(vpCorrection); | 
					
						
							| 
									
										
										
										
											2010-11-18 02:21:26 +00:00
										 |  |  | } |