Debian Codegraph @

Source/Core/VideoCommon/LightingShaderGen.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <string_view>
7 #include "Common/CommonTypes.h"
8
9 class ShaderCode;
10
11 #define LIGHT_COL "{}[{}].color.{}"
12 #define LIGHT_COL_PARAMS(index, swizzle) (I_LIGHTS), (index), (swizzle)
13
14 #define LIGHT_COSATT "{}[{}].cosatt"
15 #define LIGHT_COSATT_PARAMS(index) (I_LIGHTS), (index)
16
17 #define LIGHT_DISTATT "{}[{}].distatt"
18 #define LIGHT_DISTATT_PARAMS(index) (I_LIGHTS), (index)
19
20 #define LIGHT_POS "{}[{}].pos"
21 #define LIGHT_POS_PARAMS(index) (I_LIGHTS), (index)
22
23 #define LIGHT_DIR "{}[{}].dir"
24 #define LIGHT_DIR_PARAMS(index) (I_LIGHTS), (index)
25
26 /**
27 * Common uid data used for shader generators that use lighting calculations.
28 */
29 struct LightingUidData
30 {
31 u32 matsource : 4; // 4x1 bit
32 u32 enablelighting : 4; // 4x1 bit
33 u32 ambsource : 4; // 4x1 bit
34 u32 diffusefunc : 8; // 4x2 bits
35 u32 attnfunc : 8; // 4x2 bits
36 u32 light_mask : 32; // 4x8 bits
37 };
38
39 constexpr char s_lighting_struct[] = "struct Light {\n"
40 "\tint4 color;\n"
41 "\tfloat4 cosatt;\n"
42 "\tfloat4 distatt;\n"
43 "\tfloat4 pos;\n"
44 "\tfloat4 dir;\n"
45 "};\n";
46
47 void GenerateLightingShaderHeader(ShaderCode& object, const LightingUidData& uid_data);
48 void GetLightingShaderUid(LightingUidData& uid_data);
49 void GenerateCustomLighting(ShaderCode* out, const LightingUidData& uid_data);