| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2009 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-17 23:29:41 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 16:54:31 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							|  |  |  | #include "VideoCommon/PerfQueryBase.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "VideoCommon/VideoCommon.h"
 | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace EfbInterface | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | const int DEPTH_BUFFER_START = EFB_WIDTH * EFB_HEIGHT * 3; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // xfb color format - packed so the compiler doesn't mess with alignment
 | 
					
						
							|  |  |  | #pragma pack(push, 1)
 | 
					
						
							|  |  |  | struct yuv422_packed | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   u8 Y; | 
					
						
							|  |  |  |   u8 UV; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-08-21 00:56:19 +12:00
										 |  |  | #pragma pack(pop)
 | 
					
						
							| 
									
										
										
										
											2013-08-20 23:51:39 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // But this struct is only used internally, so we could optimise alignment
 | 
					
						
							|  |  |  | struct yuv444 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   u8 Y; | 
					
						
							|  |  |  |   s8 U; | 
					
						
							|  |  |  |   s8 V; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | enum | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ALP_C, | 
					
						
							|  |  |  |   BLU_C, | 
					
						
							|  |  |  |   GRN_C, | 
					
						
							|  |  |  |   RED_C | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-08-23 00:07:21 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // color order is ABGR in order to emulate RGBA on little-endian hardware
 | 
					
						
							| 
									
										
										
										
											2013-08-23 00:07:21 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // does full blending of an incoming pixel
 | 
					
						
							|  |  |  | void BlendTev(u16 x, u16 y, u8* color); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // compare z at location x,y
 | 
					
						
							|  |  |  | // writes it if it passes
 | 
					
						
							|  |  |  | // returns result of compare.
 | 
					
						
							|  |  |  | bool ZCompare(u16 x, u16 y, u32 z); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | // sets the color and alpha
 | 
					
						
							|  |  |  | void SetColor(u16 x, u16 y, u8* color); | 
					
						
							|  |  |  | void SetDepth(u16 x, u16 y, u32 depth); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-21 18:53:13 -04:00
										 |  |  | u32 GetColor(u16 x, u16 y); | 
					
						
							|  |  |  | yuv444 GetColorYUV(u16 x, u16 y); | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | u32 GetDepth(u16 x, u16 y); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | u8* GetPixelPointer(u16 x, u16 y, bool depth); | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | void CopyToXFB(yuv422_packed* xfb_in_ram, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, | 
					
						
							|  |  |  |                float Gamma); | 
					
						
							|  |  |  | void BypassXFB(u8* texture, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma); | 
					
						
							| 
									
										
										
										
											2013-08-20 23:51:39 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | extern u32 perf_values[PQ_NUM_MEMBERS]; | 
					
						
							|  |  |  | inline void IncPerfCounterQuadCount(PerfQueryType type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   // NOTE: hardware doesn't process individual pixels but quads instead.
 | 
					
						
							|  |  |  |   // Current software renderer architecture works on pixels though, so
 | 
					
						
							|  |  |  |   // we have this "quad" hack here to only increment the registers on
 | 
					
						
							|  |  |  |   // every fourth rendered pixel
 | 
					
						
							|  |  |  |   static u32 quad[PQ_NUM_MEMBERS]; | 
					
						
							|  |  |  |   if (++quad[type] != 3) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   quad[type] = 0; | 
					
						
							|  |  |  |   ++perf_values[type]; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-06-09 01:37:08 +00:00
										 |  |  | } |