Debian Codegraph @

Source/Core/VideoCommon/ConstantManager.h

raw symbols SCIP
1 // Copyright 2013 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <array>
7
8 #include "Common/CommonTypes.h"
9
10 // all constant buffer attributes must be 16 bytes aligned, so this are the only allowed components:
11 using float4 = std::array<float, 4>;
12 using uint4 = std::array<u32, 4>;
13 using int4 = std::array<s32, 4>;
14
15 enum class DstBlendFactor : u32;
16 enum class SrcBlendFactor : u32;
17 enum class ZTexOp : u32;
18 enum class LogicOp : u32;
19
20 struct alignas(16) PixelShaderConstants
21 {
22 std::array<int4, 4> colors;
23 std::array<int4, 4> kcolors;
24 int4 alpha;
25 std::array<uint4, 8> texdims;
26 std::array<int4, 2> zbias;
27 std::array<int4, 2> indtexscale;
28 std::array<int4, 6> indtexmtx;
29 int4 fogcolor;
30 int4 fogi;
31 float4 fogf;
32 std::array<float4, 3> fogrange;
33 float4 zslope;
34 std::array<float, 2> efbscale; // .xy
35
36 // Constants from here onwards are only used in ubershaders, other than pack2.
37 u32 genmode; // .z
38 u32 alphaTest; // .w
39 u32 fogParam3; // .x
40 u32 fogRangeBase; // .y
41 u32 dstalpha; // .z
42 ZTexOp ztex_op; // .w
43 u32 late_ztest; // .x (bool)
44 u32 rgba6_format; // .y (bool)
45 u32 dither; // .z (bool)
46 u32 bounding_box; // .w (bool)
47 std::array<uint4, 16> pack1; // .xy - combiners, .z - tevind, .w - iref
48 std::array<uint4, 8> pack2; // .x - tevorder, .y - tevksel, .z/.w - SamplerState tm0/tm1
49 std::array<int4, 32> konst; // .rgba
50 // The following are used in ubershaders when using shader_framebuffer_fetch blending
51 u32 blend_enable;
52 SrcBlendFactor blend_src_factor;
53 SrcBlendFactor blend_src_factor_alpha;
54 DstBlendFactor blend_dst_factor;
55 DstBlendFactor blend_dst_factor_alpha;
56 u32 blend_subtract;
57 u32 blend_subtract_alpha;
58 // For shader_framebuffer_fetch logic ops:
59 u32 logic_op_enable; // bool
60 LogicOp logic_op_mode;
61 // For custom shaders...
62 u32 time_ms;
63 };
64
65 struct alignas(16) VertexShaderConstants
66 {
67 u32 components; // .x
68 u32 xfmem_dualTexInfo; // .y
69 u32 xfmem_numColorChans; // .z
70 u32 missing_color_hex; // .w, used for change detection but not directly by shaders
71 float4 missing_color_value;
72
73 std::array<float4, 6> posnormalmatrix;
74 std::array<float4, 4> projection;
75 std::array<int4, 4> materials;
76 struct Light
77 {
78 int4 color;
79 float4 cosatt;
80 float4 distatt;
81 float4 pos;
82 float4 dir;
83 };
84 std::array<Light, 8> lights;
85 std::array<float4, 24> texmatrices;
86 std::array<float4, 64> transformmatrices;
87 std::array<float4, 32> normalmatrices;
88 std::array<float4, 64> posttransformmatrices;
89 float4 pixelcentercorrection;
90 std::array<float, 2> viewport; // .xy
91 std::array<float, 2> pad2; // .zw
92
93 // .x - texMtxInfo, .y - postMtxInfo, [0..1].z = color, [0..1].w = alpha
94 std::array<uint4, 8> xfmem_pack1;
95
96 float4 cached_normal;
97 float4 cached_tangent;
98 float4 cached_binormal;
99 // For UberShader vertex loader
100 u32 vertex_stride;
101 std::array<u32, 3> vertex_offset_normals;
102 u32 vertex_offset_position;
103 u32 vertex_offset_posmtx;
104 std::array<u32, 2> vertex_offset_colors;
105 std::array<u32, 8> vertex_offset_texcoords;
106 };
107
108 enum class VSExpand : u32
109 {
110 None = 0,
111 Point,
112 Line,
113 };
114
115 struct alignas(16) GeometryShaderConstants
116 {
117 float4 stereoparams;
118 float4 lineptparams;
119 int4 texoffset;
120 VSExpand vs_expand; // Used by VS point/line expansion in ubershaders
121 u32 pad[3];
122 };