| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2008 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-17 23:09:55 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 16:54:31 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "VideoCommon/LightingShaderGen.h"
 | 
					
						
							|  |  |  | #include "VideoCommon/ShaderGenCommon.h"
 | 
					
						
							| 
									
										
										
										
											2016-07-21 19:04:57 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum class APIType; | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-28 17:43:53 +02:00
										 |  |  | #pragma pack(1)
 | 
					
						
							| 
									
										
										
										
											2012-08-07 01:02:04 +02:00
										 |  |  | struct pixel_shader_uid_data | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   // TODO: Optimize field order for easy access!
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   u32 num_values;  // TODO: Shouldn't be a u32
 | 
					
						
							|  |  |  |   u32 NumValues() const { return num_values; } | 
					
						
							| 
									
										
										
										
											2016-01-15 17:51:54 +13:00
										 |  |  |   u32 components : 2; | 
					
						
							| 
									
										
										
										
											2016-12-28 01:37:41 +01:00
										 |  |  |   u32 pad0 : 1; | 
					
						
							|  |  |  |   u32 useDstAlpha : 1; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 Pretest : 2; | 
					
						
							|  |  |  |   u32 nIndirectStagesUsed : 4; | 
					
						
							|  |  |  |   u32 stereo : 1; | 
					
						
							|  |  |  |   u32 genMode_numtexgens : 4; | 
					
						
							|  |  |  |   u32 genMode_numtevstages : 4; | 
					
						
							|  |  |  |   u32 genMode_numindstages : 3; | 
					
						
							|  |  |  |   u32 alpha_test_comp0 : 3; | 
					
						
							|  |  |  |   u32 alpha_test_comp1 : 3; | 
					
						
							|  |  |  |   u32 alpha_test_logic : 2; | 
					
						
							|  |  |  |   u32 alpha_test_use_zcomploc_hack : 1; | 
					
						
							|  |  |  |   u32 fog_proj : 1; | 
					
						
							| 
									
										
										
										
											2016-01-15 17:51:54 +13:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 fog_fsel : 3; | 
					
						
							|  |  |  |   u32 fog_RangeBaseEnabled : 1; | 
					
						
							|  |  |  |   u32 ztex_op : 2; | 
					
						
							|  |  |  |   u32 fast_depth_calc : 1; | 
					
						
							|  |  |  |   u32 per_pixel_depth : 1; | 
					
						
							| 
									
										
										
										
											2016-01-15 17:51:54 +13:00
										 |  |  |   u32 per_pixel_lighting : 1; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 forced_early_z : 1; | 
					
						
							|  |  |  |   u32 early_ztest : 1; | 
					
						
							| 
									
										
										
										
											2016-01-17 02:25:16 +13:00
										 |  |  |   u32 late_ztest : 1; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 bounding_box : 1; | 
					
						
							|  |  |  |   u32 zfreeze : 1; | 
					
						
							|  |  |  |   u32 msaa : 1; | 
					
						
							|  |  |  |   u32 ssaa : 1; | 
					
						
							| 
									
										
										
										
											2016-09-28 23:31:10 +02:00
										 |  |  |   u32 numColorChans : 2; | 
					
						
							| 
									
										
										
										
											2016-09-07 17:19:26 +02:00
										 |  |  |   u32 rgba6_format : 1; | 
					
						
							| 
									
										
										
										
											2016-09-08 01:34:18 +02:00
										 |  |  |   u32 dither : 1; | 
					
						
							|  |  |  |   u32 pad : 12; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   u32 texMtxInfo_n_projection : 8;  // 8x1 bit
 | 
					
						
							|  |  |  |   u32 tevindref_bi0 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bc0 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bi1 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bc1 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bi2 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bc3 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bi4 : 3; | 
					
						
							|  |  |  |   u32 tevindref_bc4 : 3; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-28 09:46:58 +13:00
										 |  |  |   void SetTevindrefValues(int index, u32 texcoord, u32 texmap) | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     if (index == 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       tevindref_bc0 = texcoord; | 
					
						
							|  |  |  |       tevindref_bi0 = texmap; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       tevindref_bc1 = texcoord; | 
					
						
							|  |  |  |       tevindref_bi1 = texmap; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 2) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       tevindref_bc3 = texcoord; | 
					
						
							|  |  |  |       tevindref_bi2 = texmap; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 3) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       tevindref_bc4 = texcoord; | 
					
						
							|  |  |  |       tevindref_bi4 = texmap; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-28 09:46:58 +13:00
										 |  |  |   u32 GetTevindirefCoord(int index) const | 
					
						
							| 
									
										
										
										
											2016-01-17 02:25:16 +13:00
										 |  |  |   { | 
					
						
							|  |  |  |     if (index == 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bc0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bc1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 2) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bc3; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 3) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bc4; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-28 09:46:58 +13:00
										 |  |  |   u32 GetTevindirefMap(int index) const | 
					
						
							| 
									
										
										
										
											2016-01-17 02:25:16 +13:00
										 |  |  |   { | 
					
						
							|  |  |  |     if (index == 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bi0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bi1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 2) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bi2; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (index == 3) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       return tevindref_bi4; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   struct | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     // TODO: Can save a lot space by removing the padding bits
 | 
					
						
							|  |  |  |     u32 cc : 24; | 
					
						
							| 
									
										
										
										
											2016-01-16 13:01:04 +13:00
										 |  |  |     u32 ac : 24;  // tswap and rswap are left blank (encoded into the tevksel fields below)
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     u32 tevorders_texmap : 3; | 
					
						
							|  |  |  |     u32 tevorders_texcoord : 3; | 
					
						
							|  |  |  |     u32 tevorders_enable : 1; | 
					
						
							|  |  |  |     u32 tevorders_colorchan : 3; | 
					
						
							|  |  |  |     u32 pad1 : 6; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // TODO: Clean up the swapXY mess
 | 
					
						
							|  |  |  |     u32 hasindstage : 1; | 
					
						
							|  |  |  |     u32 tevind : 21; | 
					
						
							|  |  |  |     u32 tevksel_swap1a : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap2a : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap1b : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap2b : 2; | 
					
						
							|  |  |  |     u32 pad2 : 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     u32 tevksel_swap1c : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap2c : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap1d : 2; | 
					
						
							|  |  |  |     u32 tevksel_swap2d : 2; | 
					
						
							|  |  |  |     u32 tevksel_kc : 5; | 
					
						
							|  |  |  |     u32 tevksel_ka : 5; | 
					
						
							|  |  |  |     u32 pad3 : 14; | 
					
						
							|  |  |  |   } stagehash[16]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   LightingUidData lighting; | 
					
						
							| 
									
										
										
										
											2012-08-07 01:02:04 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-06-28 17:43:53 +02:00
										 |  |  | #pragma pack()
 | 
					
						
							| 
									
										
										
										
											2012-08-07 01:02:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef ShaderUid<pixel_shader_uid_data> PixelShaderUid; | 
					
						
							| 
									
										
										
										
											2011-09-07 20:20:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-28 22:31:39 +02:00
										 |  |  | ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data* uid_data); | 
					
						
							| 
									
										
										
										
											2016-12-28 01:37:41 +01:00
										 |  |  | PixelShaderUid GetPixelShaderUid(); |