CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/Shader.cpp
Views: 1401
1
#include "Common/GPU/Shader.h"
2
3
#ifdef USE_CRT_DBG
4
#undef new
5
#endif
6
7
#include "ext/glslang/SPIRV/GlslangToSpv.h"
8
9
const char *ShaderLanguageAsString(ShaderLanguage lang) {
10
switch (lang) {
11
case GLSL_1xx: return "GLSL 1.x";
12
case GLSL_3xx: return "GLSL 3.x";
13
case GLSL_VULKAN: return "GLSL-VK";
14
case HLSL_D3D9: return "HLSL-D3D9";
15
case HLSL_D3D11: return "HLSL-D3D11";
16
default: return "(combination)";
17
}
18
}
19
20
const char *ShaderStageAsString(ShaderStage stage) {
21
switch (stage) {
22
case ShaderStage::Fragment: return "Fragment";
23
case ShaderStage::Vertex: return "Vertex";
24
case ShaderStage::Geometry: return "Geometry";
25
case ShaderStage::Compute: return "Compute";
26
default: return "(unknown)";
27
}
28
}
29
30
ShaderLanguageDesc::ShaderLanguageDesc(ShaderLanguage lang) {
31
Init(lang);
32
}
33
34
void ShaderLanguageDesc::Init(ShaderLanguage lang) {
35
shaderLanguage = lang;
36
strcpy(driverInfo, "");
37
switch (lang) {
38
case GLSL_1xx:
39
// Just used in the shader test, and as a basis for the others in DetectShaderLanguage.
40
// The real OpenGL initialization happens in thin3d_gl.cpp.
41
glslVersionNumber = 110;
42
attribute = "attribute";
43
varying_vs = "varying";
44
varying_fs = "varying";
45
fragColor0 = "gl_FragColor";
46
fragColor1 = "fragColor1";
47
texture = "texture2D";
48
texture3D = "texture3D";
49
texelFetch = nullptr;
50
bitwiseOps = false;
51
lastFragData = nullptr;
52
gles = false;
53
forceMatrix4x4 = true;
54
break;
55
case GLSL_3xx:
56
// Just used in the shader test.
57
glslVersionNumber = 300; // GLSL ES 3.0
58
varying_vs = "out";
59
varying_fs = "in";
60
attribute = "in";
61
fragColor0 = "fragColor0";
62
fragColor1 = "fragColor1";
63
texture = "texture";
64
texture3D = "texture";
65
texelFetch = "texelFetch";
66
bitwiseOps = true;
67
lastFragData = nullptr;
68
gles = true;
69
forceMatrix4x4 = true;
70
glslES30 = true;
71
break;
72
case GLSL_VULKAN:
73
fragColor0 = "fragColor0";
74
fragColor1 = "fragColor1";
75
varying_fs = "in";
76
varying_vs = "out";
77
attribute = "in";
78
bitwiseOps = true;
79
framebufferFetchExtension = nullptr;
80
gles = false;
81
glslES30 = true;
82
glslVersionNumber = 450;
83
lastFragData = nullptr;
84
texture = "texture";
85
texture3D = "texture";
86
texelFetch = "texelFetch";
87
forceMatrix4x4 = false;
88
coefsFromBuffers = true;
89
vertexIndex = true;
90
break;
91
case HLSL_D3D9:
92
case HLSL_D3D11:
93
if (lang == HLSL_D3D11) {
94
fragColor0 = "outfragment.target";
95
fragColor1 = "outfragment.target1";
96
vertexIndex = true; // if declared as a semantic input
97
} else {
98
fragColor0 = "outfragment.target";
99
}
100
varying_fs = "in";
101
varying_vs = "out";
102
attribute = "in";
103
bitwiseOps = lang == HLSL_D3D11;
104
framebufferFetchExtension = nullptr;
105
gles = false;
106
glslES30 = true; // Hm, D3D9 too?
107
glslVersionNumber = 0;
108
lastFragData = nullptr;
109
texture = "texture";
110
texture3D = "texture";
111
texelFetch = "texelFetch";
112
forceMatrix4x4 = false;
113
coefsFromBuffers = true;
114
vsOutPrefix = "Out.";
115
viewportYSign = "-";
116
break;
117
}
118
}
119
120
void InitShaderResources(TBuiltInResource &Resources) {
121
Resources.maxLights = 32;
122
Resources.maxClipPlanes = 6;
123
Resources.maxTextureUnits = 32;
124
Resources.maxTextureCoords = 32;
125
Resources.maxVertexAttribs = 64;
126
Resources.maxVertexUniformComponents = 4096;
127
Resources.maxVaryingFloats = 64;
128
Resources.maxVertexTextureImageUnits = 32;
129
Resources.maxCombinedTextureImageUnits = 80;
130
Resources.maxTextureImageUnits = 32;
131
Resources.maxFragmentUniformComponents = 4096;
132
Resources.maxDrawBuffers = 32;
133
Resources.maxVertexUniformVectors = 128;
134
Resources.maxVaryingVectors = 8;
135
Resources.maxFragmentUniformVectors = 16;
136
Resources.maxVertexOutputVectors = 16;
137
Resources.maxFragmentInputVectors = 15;
138
Resources.minProgramTexelOffset = -8;
139
Resources.maxProgramTexelOffset = 7;
140
Resources.maxClipDistances = 8;
141
Resources.maxComputeWorkGroupCountX = 65535;
142
Resources.maxComputeWorkGroupCountY = 65535;
143
Resources.maxComputeWorkGroupCountZ = 65535;
144
Resources.maxComputeWorkGroupSizeX = 1024;
145
Resources.maxComputeWorkGroupSizeY = 1024;
146
Resources.maxComputeWorkGroupSizeZ = 64;
147
Resources.maxComputeUniformComponents = 1024;
148
Resources.maxComputeTextureImageUnits = 16;
149
Resources.maxComputeImageUniforms = 8;
150
Resources.maxComputeAtomicCounters = 8;
151
Resources.maxComputeAtomicCounterBuffers = 1;
152
Resources.maxVaryingComponents = 60;
153
Resources.maxVertexOutputComponents = 64;
154
Resources.maxGeometryInputComponents = 64;
155
Resources.maxGeometryOutputComponents = 128;
156
Resources.maxFragmentInputComponents = 128;
157
Resources.maxImageUnits = 8;
158
Resources.maxCombinedImageUnitsAndFragmentOutputs = 8;
159
Resources.maxCombinedShaderOutputResources = 8;
160
Resources.maxImageSamples = 0;
161
Resources.maxVertexImageUniforms = 0;
162
Resources.maxTessControlImageUniforms = 0;
163
Resources.maxTessEvaluationImageUniforms = 0;
164
Resources.maxGeometryImageUniforms = 0;
165
Resources.maxFragmentImageUniforms = 8;
166
Resources.maxCombinedImageUniforms = 8;
167
Resources.maxGeometryTextureImageUnits = 16;
168
Resources.maxGeometryOutputVertices = 256;
169
Resources.maxGeometryTotalOutputComponents = 1024;
170
Resources.maxGeometryUniformComponents = 1024;
171
Resources.maxGeometryVaryingComponents = 64;
172
Resources.maxTessControlInputComponents = 128;
173
Resources.maxTessControlOutputComponents = 128;
174
Resources.maxTessControlTextureImageUnits = 16;
175
Resources.maxTessControlUniformComponents = 1024;
176
Resources.maxTessControlTotalOutputComponents = 4096;
177
Resources.maxTessEvaluationInputComponents = 128;
178
Resources.maxTessEvaluationOutputComponents = 128;
179
Resources.maxTessEvaluationTextureImageUnits = 16;
180
Resources.maxTessEvaluationUniformComponents = 1024;
181
Resources.maxTessPatchComponents = 120;
182
Resources.maxPatchVertices = 32;
183
Resources.maxTessGenLevel = 64;
184
Resources.maxViewports = 16;
185
Resources.maxVertexAtomicCounters = 0;
186
Resources.maxTessControlAtomicCounters = 0;
187
Resources.maxTessEvaluationAtomicCounters = 0;
188
Resources.maxGeometryAtomicCounters = 0;
189
Resources.maxFragmentAtomicCounters = 8;
190
Resources.maxCombinedAtomicCounters = 8;
191
Resources.maxAtomicCounterBindings = 1;
192
Resources.maxVertexAtomicCounterBuffers = 0;
193
Resources.maxTessControlAtomicCounterBuffers = 0;
194
Resources.maxTessEvaluationAtomicCounterBuffers = 0;
195
Resources.maxGeometryAtomicCounterBuffers = 0;
196
Resources.maxFragmentAtomicCounterBuffers = 1;
197
Resources.maxCombinedAtomicCounterBuffers = 1;
198
Resources.maxAtomicCounterBufferSize = 16384;
199
Resources.maxTransformFeedbackBuffers = 4;
200
Resources.maxTransformFeedbackInterleavedComponents = 64;
201
Resources.maxCullDistances = 8;
202
Resources.maxCombinedClipAndCullDistances = 8;
203
Resources.maxSamples = 4;
204
Resources.maxDualSourceDrawBuffersEXT = 1;
205
Resources.limits.nonInductiveForLoops = 1;
206
Resources.limits.whileLoops = 1;
207
Resources.limits.doWhileLoops = 1;
208
Resources.limits.generalUniformIndexing = 1;
209
Resources.limits.generalAttributeMatrixVectorIndexing = 1;
210
Resources.limits.generalVaryingIndexing = 1;
211
Resources.limits.generalSamplerIndexing = 1;
212
Resources.limits.generalVariableIndexing = 1;
213
Resources.limits.generalConstantMatrixVectorIndexing = 1;
214
}
215
216