2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:09:55 -06:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/LightingShaderGen.h"
|
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
2016-07-21 17:04:57 -06:00
|
|
|
|
|
|
|
enum class APIType;
|
2021-02-10 19:11:31 -07:00
|
|
|
enum class AlphaTestResult;
|
|
|
|
enum class SrcBlendFactor : u32;
|
|
|
|
enum class DstBlendFactor : u32;
|
|
|
|
enum class CompareMode : u32;
|
|
|
|
enum class AlphaTestOp : u32;
|
|
|
|
enum class RasColorChan : u32;
|
|
|
|
enum class KonstSel : u32;
|
|
|
|
enum class FogProjection : u32;
|
|
|
|
enum class FogType : u32;
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2013-06-28 09:43:53 -06:00
|
|
|
#pragma pack(1)
|
2012-08-06 17:02:04 -06:00
|
|
|
struct pixel_shader_uid_data
|
|
|
|
{
|
2013-06-17 05:17:25 -06:00
|
|
|
// TODO: Optimize field order for easy access!
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-06-22 13:24:21 -06:00
|
|
|
u32 num_values; // TODO: Shouldn't be a u32
|
2013-06-28 09:43:53 -06:00
|
|
|
u32 NumValues() const { return num_values; }
|
2017-01-29 05:38:48 -07:00
|
|
|
u32 pad0 : 4;
|
2016-12-27 17:37:41 -07:00
|
|
|
u32 useDstAlpha : 1;
|
2021-02-10 19:11:31 -07:00
|
|
|
AlphaTestResult Pretest : 2;
|
2013-08-12 10:21:35 -06:00
|
|
|
u32 nIndirectStagesUsed : 4;
|
2013-05-01 03:39:30 -06:00
|
|
|
u32 genMode_numtexgens : 4;
|
|
|
|
u32 genMode_numtevstages : 4;
|
|
|
|
u32 genMode_numindstages : 3;
|
2021-02-10 19:11:31 -07:00
|
|
|
CompareMode alpha_test_comp0 : 3;
|
|
|
|
CompareMode alpha_test_comp1 : 3;
|
|
|
|
AlphaTestOp alpha_test_logic : 2;
|
2013-08-12 10:21:35 -06:00
|
|
|
u32 alpha_test_use_zcomploc_hack : 1;
|
2021-02-10 19:11:31 -07:00
|
|
|
FogProjection fog_proj : 1;
|
2016-01-14 21:51:54 -07:00
|
|
|
|
2021-02-10 19:11:31 -07:00
|
|
|
FogType fog_fsel : 3;
|
2013-08-12 10:21:35 -06:00
|
|
|
u32 fog_RangeBaseEnabled : 1;
|
|
|
|
u32 ztex_op : 2;
|
|
|
|
u32 per_pixel_depth : 1;
|
|
|
|
u32 forced_early_z : 1;
|
|
|
|
u32 early_ztest : 1;
|
2016-01-16 06:25:16 -07:00
|
|
|
u32 late_ztest : 1;
|
2014-11-13 15:26:49 -07:00
|
|
|
u32 bounding_box : 1;
|
2014-12-25 00:34:22 -07:00
|
|
|
u32 zfreeze : 1;
|
2016-09-28 15:31:10 -06:00
|
|
|
u32 numColorChans : 2;
|
2016-09-07 09:19:26 -06:00
|
|
|
u32 rgba6_format : 1;
|
2016-09-07 17:34:18 -06:00
|
|
|
u32 dither : 1;
|
2017-09-03 00:32:37 -06:00
|
|
|
u32 uint_output : 1;
|
2021-02-10 19:11:31 -07:00
|
|
|
u32 blend_enable : 1; // Only used with shader_framebuffer_fetch blend
|
|
|
|
SrcBlendFactor blend_src_factor : 3; // Only used with shader_framebuffer_fetch blend
|
|
|
|
SrcBlendFactor blend_src_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
|
|
|
DstBlendFactor blend_dst_factor : 3; // Only used with shader_framebuffer_fetch blend
|
|
|
|
DstBlendFactor blend_dst_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
|
|
|
u32 blend_subtract : 1; // Only used with shader_framebuffer_fetch blend
|
|
|
|
u32 blend_subtract_alpha : 1; // Only used with shader_framebuffer_fetch blend
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-05-01 03:39:30 -06: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;
|
2021-04-10 16:17:42 -06:00
|
|
|
u32 tevindref_bc2 : 3;
|
|
|
|
u32 tevindref_bi3 : 3;
|
2013-05-01 03:39:30 -06:00
|
|
|
u32 tevindref_bc3 : 3;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-02-27 13:46:58 -07:00
|
|
|
void SetTevindrefValues(int index, u32 texcoord, u32 texmap)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2013-05-01 03:39:30 -06:00
|
|
|
if (index == 0)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2013-05-01 03:39:30 -06:00
|
|
|
tevindref_bc0 = texcoord;
|
|
|
|
tevindref_bi0 = texmap;
|
|
|
|
}
|
|
|
|
else if (index == 1)
|
|
|
|
{
|
|
|
|
tevindref_bc1 = texcoord;
|
|
|
|
tevindref_bi1 = texmap;
|
|
|
|
}
|
|
|
|
else if (index == 2)
|
|
|
|
{
|
2021-04-10 16:17:42 -06:00
|
|
|
tevindref_bc2 = texcoord;
|
2013-05-01 03:39:30 -06:00
|
|
|
tevindref_bi2 = texmap;
|
|
|
|
}
|
|
|
|
else if (index == 3)
|
|
|
|
{
|
2021-04-10 16:17:42 -06:00
|
|
|
tevindref_bc3 = texcoord;
|
|
|
|
tevindref_bi3 = texmap;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2013-05-01 03:39:30 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-02-27 13:46:58 -07:00
|
|
|
u32 GetTevindirefCoord(int index) const
|
2016-01-16 06:25:16 -07:00
|
|
|
{
|
|
|
|
if (index == 0)
|
|
|
|
return tevindref_bc0;
|
|
|
|
else if (index == 1)
|
|
|
|
return tevindref_bc1;
|
|
|
|
else if (index == 2)
|
2021-04-10 16:17:42 -06:00
|
|
|
return tevindref_bc2;
|
2016-01-16 06:25:16 -07:00
|
|
|
else if (index == 3)
|
2021-04-10 16:17:42 -06:00
|
|
|
return tevindref_bc3;
|
2016-01-16 06:25:16 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-27 13:46:58 -07:00
|
|
|
u32 GetTevindirefMap(int index) const
|
2016-01-16 06:25:16 -07: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)
|
2021-04-10 16:17:42 -06:00
|
|
|
return tevindref_bi3;
|
2016-01-16 06:25:16 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-22 12:41:32 -06:00
|
|
|
struct
|
|
|
|
{
|
2013-06-28 09:43:53 -06:00
|
|
|
// TODO: Can save a lot space by removing the padding bits
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 cc : 24;
|
2016-01-15 17:01:04 -07:00
|
|
|
u32 ac : 24; // tswap and rswap are left blank (encoded into the tevksel fields below)
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 tevorders_texmap : 3;
|
|
|
|
u32 tevorders_texcoord : 3;
|
|
|
|
u32 tevorders_enable : 1;
|
2021-02-10 19:11:31 -07:00
|
|
|
RasColorChan tevorders_colorchan : 3;
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 pad1 : 6;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-06-22 13:24:21 -06:00
|
|
|
// TODO: Clean up the swapXY mess
|
2021-04-18 17:12:21 -06:00
|
|
|
// TODO: remove hasindstage, as it no longer does anything useful
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 hasindstage : 1;
|
|
|
|
u32 tevind : 21;
|
2013-06-22 13:24:21 -06:00
|
|
|
u32 tevksel_swap1a : 2;
|
|
|
|
u32 tevksel_swap2a : 2;
|
|
|
|
u32 tevksel_swap1b : 2;
|
|
|
|
u32 tevksel_swap2b : 2;
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 pad2 : 2;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-06-22 13:24:21 -06:00
|
|
|
u32 tevksel_swap1c : 2;
|
|
|
|
u32 tevksel_swap2c : 2;
|
|
|
|
u32 tevksel_swap1d : 2;
|
|
|
|
u32 tevksel_swap2d : 2;
|
2021-02-10 19:11:31 -07:00
|
|
|
KonstSel tevksel_kc : 5;
|
|
|
|
KonstSel tevksel_ka : 5;
|
2013-06-22 12:41:32 -06:00
|
|
|
u32 pad3 : 14;
|
|
|
|
} stagehash[16];
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-03-31 15:29:33 -06:00
|
|
|
LightingUidData lighting;
|
2012-08-06 17:02:04 -06:00
|
|
|
};
|
2013-06-28 09:43:53 -06:00
|
|
|
#pragma pack()
|
2012-08-06 17:02:04 -06:00
|
|
|
|
2019-05-29 23:05:06 -06:00
|
|
|
using PixelShaderUid = ShaderUid<pixel_shader_uid_data>;
|
2011-09-07 12:20:29 -06:00
|
|
|
|
2020-10-20 12:42:54 -06:00
|
|
|
ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& host_config,
|
2017-07-20 01:10:02 -06:00
|
|
|
const pixel_shader_uid_data* uid_data);
|
2021-04-17 10:57:16 -06:00
|
|
|
void WritePixelShaderCommonHeader(ShaderCode& out, APIType api_type,
|
2019-01-23 01:11:17 -07:00
|
|
|
const ShaderHostConfig& host_config, bool bounding_box);
|
2020-10-20 12:42:54 -06:00
|
|
|
void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config,
|
2018-05-25 08:09:10 -06:00
|
|
|
PixelShaderUid* uid);
|
2016-12-27 17:37:41 -07:00
|
|
|
PixelShaderUid GetPixelShaderUid();
|