1 // Copyright 2008 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include "Common/CommonTypes.h"
8 #include "VideoCommon/LightingShaderGen.h"
9 #include "VideoCommon/ShaderGenCommon.h"
10 
11 enum class APIType;
12 
13 // TODO should be reordered
14 enum : int
15 {
16   SHADER_POSITION_ATTRIB = 0,
17   SHADER_POSMTX_ATTRIB = 1,
18   SHADER_NORM0_ATTRIB = 2,
19   SHADER_NORM1_ATTRIB = 3,
20   SHADER_NORM2_ATTRIB = 4,
21   SHADER_COLOR0_ATTRIB = 5,
22   SHADER_COLOR1_ATTRIB = 6,
23 
24   SHADER_TEXTURE0_ATTRIB = 8,
25   SHADER_TEXTURE1_ATTRIB = 9,
26   SHADER_TEXTURE2_ATTRIB = 10,
27   SHADER_TEXTURE3_ATTRIB = 11,
28   SHADER_TEXTURE4_ATTRIB = 12,
29   SHADER_TEXTURE5_ATTRIB = 13,
30   SHADER_TEXTURE6_ATTRIB = 14,
31   SHADER_TEXTURE7_ATTRIB = 15
32 };
33 
34 #pragma pack(1)
35 
36 struct vertex_shader_uid_data
37 {
NumValuesvertex_shader_uid_data38   u32 NumValues() const { return sizeof(vertex_shader_uid_data); }
39   u32 components : 23;
40   u32 numTexGens : 4;
41   u32 numColorChans : 2;
42   u32 dualTexTrans_enabled : 1;
43 
44   u32 texMtxInfo_n_projection : 16;  // Stored separately to guarantee that the texMtxInfo struct is
45                                      // 8 bits wide
46   u32 pad : 18;
47 
48   struct
49   {
50     u32 inputform : 2;
51     u32 texgentype : 3;
52     u32 sourcerow : 5;
53     u32 embosssourceshift : 3;
54     u32 embosslightshift : 3;
55   } texMtxInfo[8];
56 
57   struct
58   {
59     u32 index : 6;
60     u32 normalize : 1;
61     u32 pad : 1;
62   } postMtxInfo[8];
63 
64   LightingUidData lighting;
65 };
66 #pragma pack()
67 
68 using VertexShaderUid = ShaderUid<vertex_shader_uid_data>;
69 
70 VertexShaderUid GetVertexShaderUid();
71 ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& host_config,
72                                     const vertex_shader_uid_data* uid_data);
73