| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include "Common/CommonTypes.h" |
| 7 |
#include "Common/EnumFormatter.h" |
| 8 |
|
| 9 |
#include "VideoCommon/LightingShaderGen.h" |
| 10 |
#include "VideoCommon/ShaderGenCommon.h" |
| 11 |
|
| 12 |
enum class APIType; |
| 13 |
enum class TexInputForm : u32; |
| 14 |
enum class TexGenType : u32; |
| 15 |
enum class SourceRow : u32; |
| 16 |
enum class VSExpand : u32; |
| 17 |
|
| 18 |
|
| 19 |
enum class ShaderAttrib : u32 |
| 20 |
{ |
| 21 |
Position = 0, |
| 22 |
PositionMatrix = 1, |
| 23 |
Normal = 2, |
| 24 |
Tangent = 3, |
| 25 |
Binormal = 4, |
| 26 |
Color0 = 5, |
| 27 |
Color1 = 6, |
| 28 |
|
| 29 |
TexCoord0 = 8, |
| 30 |
TexCoord1 = 9, |
| 31 |
TexCoord2 = 10, |
| 32 |
TexCoord3 = 11, |
| 33 |
TexCoord4 = 12, |
| 34 |
TexCoord5 = 13, |
| 35 |
TexCoord6 = 14, |
| 36 |
TexCoord7 = 15 |
| 37 |
}; |
| 38 |
template <> |
| 39 |
struct fmt::formatter<ShaderAttrib> : EnumFormatter<ShaderAttrib::TexCoord7> |
| 40 |
{ |
| 41 |
static constexpr array_type names = { |
| 42 |
"Position", "Position Matrix", "Normal", "Tangent", "Binormal", "Color 0", |
| 43 |
"Color 1", nullptr, "Tex Coord 0", "Tex Coord 1", "Tex Coord 2", "Tex Coord 3", |
| 44 |
"Tex Coord 4", "Tex Coord 5", "Tex Coord 6", "Tex Coord 7"}; |
| 45 |
constexpr formatter() : EnumFormatter(names) {} |
| 46 |
}; |
| 47 |
|
| 48 |
constexpr ShaderAttrib operator+(ShaderAttrib attrib, int offset) |
| 49 |
{ |
| 50 |
return static_cast<ShaderAttrib>(static_cast<u8>(attrib) + offset); |
| 51 |
} |
| 52 |
|
| 53 |
#pragma pack(1) |
| 54 |
|
| 55 |
struct vertex_shader_uid_data |
| 56 |
{ |
| 57 |
u32 NumValues() const { return sizeof(vertex_shader_uid_data); } |
| 58 |
u32 components : 23; |
| 59 |
u32 numTexGens : 4; |
| 60 |
u32 numColorChans : 2; |
| 61 |
u32 dualTexTrans_enabled : 1; |
| 62 |
VSExpand vs_expand : 2; |
| 63 |
u32 position_has_3_elems : 1; |
| 64 |
|
| 65 |
u16 texcoord_elem_count; |
| 66 |
u16 texMtxInfo_n_projection; |
| 67 |
|
| 68 |
|
| 69 |
struct |
| 70 |
{ |
| 71 |
TexInputForm inputform : 2; |
| 72 |
TexGenType texgentype : 3; |
| 73 |
SourceRow sourcerow : 5; |
| 74 |
u32 embosssourceshift : 3; |
| 75 |
u32 embosslightshift : 3; |
| 76 |
} texMtxInfo[8]; |
| 77 |
|
| 78 |
struct |
| 79 |
{ |
| 80 |
u32 index : 6; |
| 81 |
u32 normalize : 1; |
| 82 |
u32 pad : 1; |
| 83 |
} postMtxInfo[8]; |
| 84 |
|
| 85 |
LightingUidData lighting; |
| 86 |
}; |
| 87 |
#pragma pack() |
| 88 |
|
| 89 |
using VertexShaderUid = ShaderUid<vertex_shader_uid_data>; |
| 90 |
|
| 91 |
struct CustomVertexContents |
| 92 |
{ |
| 93 |
std::string_view shader = ""; |
| 94 |
std::string_view uniforms = ""; |
| 95 |
}; |
| 96 |
|
| 97 |
VertexShaderUid GetVertexShaderUid(); |
| 98 |
ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& host_config, |
| 99 |
const vertex_shader_uid_data* uid_data, |
| 100 |
CustomVertexContents custom_contents); |
| 101 |
void WriteVertexBody(APIType api_type, const ShaderHostConfig& host_config, |
| 102 |
const vertex_shader_uid_data* uid_data, ShaderCode& out); |