1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
From 19579a11cdc6fc9714ebbfa969e77c0a2d1de8f9 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 25 Sep 2016 23:07:03 +0200
Subject: [PATCH 05/10] Export shader API via libGLESv2.dll
Required by Qt WebKit
---
include/GLSLANG/ShaderLang.h | 67 +++++++++++++++++--------------
include/GLSLANG/ShaderVars.h | 31 +++++++++-----
src/compiler/translator/blocklayout.h | 6 +--
src/compiler/translator/blocklayoutHLSL.h | 7 ++--
4 files changed, 64 insertions(+), 47 deletions(-)
diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
index 8448d06..7aa5281 100644
--- a/include/GLSLANG/ShaderLang.h
+++ b/include/GLSLANG/ShaderLang.h
@@ -369,19 +369,19 @@ using ShHandle = void *;
// compiler operations.
// If the function succeeds, the return value is true, else false.
//
-bool ShInitialize();
+COMPILER_EXPORT bool ShInitialize();
//
// Driver should call this at shutdown.
// If the function succeeds, the return value is true, else false.
//
-bool ShFinalize();
+COMPILER_EXPORT bool ShFinalize();
//
// Initialize built-in resources with minimum expected values.
// Parameters:
// resources: The object to initialize. Will be comparable with memcmp.
//
-void ShInitBuiltInResources(ShBuiltInResources *resources);
+COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources *resources);
//
// Returns the a concatenated list of the items in ShBuiltInResources as a
@@ -389,7 +389,7 @@ void ShInitBuiltInResources(ShBuiltInResources *resources);
// This function must be updated whenever ShBuiltInResources is changed.
// Parameters:
// handle: Specifies the handle of the compiler to be used.
-const std::string &ShGetBuiltInResourcesString(const ShHandle handle);
+COMPILER_EXPORT const std::string &ShGetBuiltInResourcesString(const ShHandle handle);
//
// Driver calls these to create and destroy compiler objects.
@@ -404,11 +404,12 @@ const std::string &ShGetBuiltInResourcesString(const ShHandle handle);
// SH_HLSL_3_0_OUTPUT or SH_HLSL_4_1_OUTPUT. Note: Each output type may only
// be supported in some configurations.
// resources: Specifies the built-in resources.
-ShHandle ShConstructCompiler(sh::GLenum type,
- ShShaderSpec spec,
- ShShaderOutput output,
- const ShBuiltInResources *resources);
-void ShDestruct(ShHandle handle);
+COMPILER_EXPORT ShHandle ShConstructCompiler(
+ sh::GLenum type,
+ ShShaderSpec spec,
+ ShShaderOutput output,
+ const ShBuiltInResources *resources);
+COMPILER_EXPORT void ShDestruct(ShHandle handle);
//
// Compiles the given shader source.
@@ -434,36 +435,38 @@ void ShDestruct(ShHandle handle);
// SH_VARIABLES: Extracts attributes, uniforms, and varyings.
// Can be queried by calling ShGetVariableInfo().
//
-bool ShCompile(const ShHandle handle,
- const char *const shaderStrings[],
- size_t numStrings,
- ShCompileOptions compileOptions);
+COMPILER_EXPORT bool ShCompile(const ShHandle handle,
+ const char *const shaderStrings[],
+ size_t numStrings,
+ ShCompileOptions compileOptions);
// Clears the results from the previous compilation.
-void ShClearResults(const ShHandle handle);
+COMPILER_EXPORT void ShClearResults(const ShHandle handle);
// Return the version of the shader language.
-int ShGetShaderVersion(const ShHandle handle);
+COMPILER_EXPORT int ShGetShaderVersion(const ShHandle handle);
// Return the currently set language output type.
-ShShaderOutput ShGetShaderOutputType(const ShHandle handle);
+COMPILER_EXPORT ShShaderOutput ShGetShaderOutputType(
+ const ShHandle handle);
// Returns null-terminated information log for a compiled shader.
// Parameters:
// handle: Specifies the compiler
-const std::string &ShGetInfoLog(const ShHandle handle);
+COMPILER_EXPORT const std::string &ShGetInfoLog(const ShHandle handle);
// Returns null-terminated object code for a compiled shader.
// Parameters:
// handle: Specifies the compiler
-const std::string &ShGetObjectCode(const ShHandle handle);
+COMPILER_EXPORT const std::string &ShGetObjectCode(const ShHandle handle);
// Returns a (original_name, hash) map containing all the user defined
// names in the shader, including variable names, function names, struct
// names, and struct field names.
// Parameters:
// handle: Specifies the compiler
-const std::map<std::string, std::string> *ShGetNameHashingMap(const ShHandle handle);
+COMPILER_EXPORT const std::map<std::string, std::string> *ShGetNameHashingMap(
+ const ShHandle handle);
// Shader variable inspection.
// Returns a pointer to a list of variables of the designated type.
@@ -471,12 +474,12 @@ const std::map<std::string, std::string> *ShGetNameHashingMap(const ShHandle han
// Returns NULL on failure.
// Parameters:
// handle: Specifies the compiler
-const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle);
-const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle);
-const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle);
-const std::vector<sh::OutputVariable> *ShGetOutputVariables(const ShHandle handle);
-const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle);
-sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle);
+COMPILER_EXPORT const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle);
+COMPILER_EXPORT const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle);
+COMPILER_EXPORT const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle);
+COMPILER_EXPORT const std::vector<sh::OutputVariable> *ShGetOutputVariables(const ShHandle handle);
+COMPILER_EXPORT const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle);
+COMPILER_EXPORT sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle);
// Returns true if the passed in variables pack in maxVectors following
// the packing rules from the GLSL 1.017 spec, Appendix A, section 7.
@@ -485,8 +488,9 @@ sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle);
// Parameters:
// maxVectors: the available rows of registers.
// variables: an array of variables.
-bool ShCheckVariablesWithinPackingLimits(int maxVectors,
- const std::vector<sh::ShaderVariable> &variables);
+COMPILER_EXPORT bool ShCheckVariablesWithinPackingLimits(
+ int maxVectors,
+ const std::vector<sh::ShaderVariable> &variables);
// Gives the compiler-assigned register for an interface block.
// The method writes the value to the output variable "indexOut".
@@ -495,14 +499,15 @@ bool ShCheckVariablesWithinPackingLimits(int maxVectors,
// handle: Specifies the compiler
// interfaceBlockName: Specifies the interface block
// indexOut: output variable that stores the assigned register
-bool ShGetInterfaceBlockRegister(const ShHandle handle,
- const std::string &interfaceBlockName,
- unsigned int *indexOut);
+COMPILER_EXPORT bool ShGetInterfaceBlockRegister(const ShHandle handle,
+ const std::string &interfaceBlockName,
+ unsigned int *indexOut);
// Gives a map from uniform names to compiler-assigned registers in the default
// interface block. Note that the map contains also registers of samplers that
// have been extracted from structs.
-const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(const ShHandle handle);
+COMPILER_EXPORT const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(
+ const ShHandle handle);
// Temporary duplicate of the scoped APIs, to be removed when we roll ANGLE and fix Chromium.
// TODO(jmadill): Consolidate with these APIs once we roll ANGLE.
diff --git a/include/GLSLANG/ShaderVars.h b/include/GLSLANG/ShaderVars.h
index aa7bc08..4856273 100644
--- a/include/GLSLANG/ShaderVars.h
+++ b/include/GLSLANG/ShaderVars.h
@@ -10,6 +10,17 @@
#ifndef GLSLANG_SHADERVARS_H_
#define GLSLANG_SHADERVARS_H_
+#if !defined(ANGLE_STATIC)
+#if defined(_WIN32) || defined(_WIN64)
+#define COMPILER_EXPORT __declspec(dllexport)
+#else // defined(_WIN32) || defined(_WIN64)
+#define COMPILER_EXPORT __attribute__((visibility("default")))
+#endif
+
+#else
+#define COMPILER_EXPORT
+#endif
+
#include <algorithm>
#include <string>
#include <vector>
@@ -31,7 +42,7 @@ enum InterpolationType
};
// Validate link & SSO consistency of interpolation qualifiers
-bool InterpolationTypesMatch(InterpolationType a, InterpolationType b);
+COMPILER_EXPORT bool InterpolationTypesMatch(InterpolationType a, InterpolationType b);
// Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
enum BlockLayoutType
@@ -45,7 +56,7 @@ enum BlockLayoutType
// Note: we must override the copy constructor and assignment operator so we can
// work around excessive GCC binary bloating:
// See https://code.google.com/p/angleproject/issues/detail?id=697
-struct ShaderVariable
+struct COMPILER_EXPORT ShaderVariable
{
ShaderVariable();
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn);
@@ -94,7 +105,7 @@ struct ShaderVariable
}
};
-struct Uniform : public ShaderVariable
+struct COMPILER_EXPORT Uniform : public ShaderVariable
{
Uniform();
~Uniform();
@@ -115,7 +126,7 @@ struct Uniform : public ShaderVariable
// An interface variable is a variable which passes data between the GL data structures and the
// shader execution: either vertex shader inputs or fragment shader outputs. These variables can
// have integer locations to pass back to the GL API.
-struct InterfaceVariable : public ShaderVariable
+struct COMPILER_EXPORT InterfaceVariable : public ShaderVariable
{
InterfaceVariable();
~InterfaceVariable();
@@ -127,7 +138,7 @@ struct InterfaceVariable : public ShaderVariable
int location;
};
-struct Attribute : public InterfaceVariable
+struct COMPILER_EXPORT Attribute : public InterfaceVariable
{
Attribute();
~Attribute();
@@ -137,7 +148,7 @@ struct Attribute : public InterfaceVariable
bool operator!=(const Attribute &other) const { return !operator==(other); }
};
-struct OutputVariable : public InterfaceVariable
+struct COMPILER_EXPORT OutputVariable : public InterfaceVariable
{
OutputVariable();
~OutputVariable();
@@ -147,7 +158,7 @@ struct OutputVariable : public InterfaceVariable
bool operator!=(const OutputVariable &other) const { return !operator==(other); }
};
-struct InterfaceBlockField : public ShaderVariable
+struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
{
InterfaceBlockField();
~InterfaceBlockField();
@@ -169,7 +180,7 @@ struct InterfaceBlockField : public ShaderVariable
bool isRowMajorLayout;
};
-struct Varying : public ShaderVariable
+struct COMPILER_EXPORT Varying : public ShaderVariable
{
Varying();
~Varying();
@@ -195,7 +206,7 @@ struct Varying : public ShaderVariable
bool isInvariant;
};
-struct InterfaceBlock
+struct COMPILER_EXPORT InterfaceBlock
{
InterfaceBlock();
~InterfaceBlock();
@@ -218,7 +229,7 @@ struct InterfaceBlock
std::vector<InterfaceBlockField> fields;
};
-struct WorkGroupSize
+struct COMPILER_EXPORT WorkGroupSize
{
void fill(int fillValue);
void setLocalSize(int localSizeX, int localSizeY, int localSizeZ);
diff --git a/src/compiler/translator/blocklayout.h b/src/compiler/translator/blocklayout.h
index 298a72c..dd5fe07 100644
--- a/src/compiler/translator/blocklayout.h
+++ b/src/compiler/translator/blocklayout.h
@@ -24,7 +24,7 @@ struct Uniform;
struct Varying;
struct InterfaceBlock;
-struct BlockMemberInfo
+struct COMPILER_EXPORT BlockMemberInfo
{
BlockMemberInfo() : offset(-1), arrayStride(-1), matrixStride(-1), isRowMajorMatrix(false) {}
@@ -46,7 +46,7 @@ struct BlockMemberInfo
bool isRowMajorMatrix;
};
-class BlockLayoutEncoder
+class COMPILER_EXPORT BlockLayoutEncoder
{
public:
BlockLayoutEncoder();
@@ -77,7 +77,7 @@ class BlockLayoutEncoder
// Block layout according to the std140 block layout
// See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification
-class Std140BlockEncoder : public BlockLayoutEncoder
+class COMPILER_EXPORT Std140BlockEncoder : public BlockLayoutEncoder
{
public:
Std140BlockEncoder();
diff --git a/src/compiler/translator/blocklayoutHLSL.h b/src/compiler/translator/blocklayoutHLSL.h
index 8d98847..c61cb1a 100644
--- a/src/compiler/translator/blocklayoutHLSL.h
+++ b/src/compiler/translator/blocklayoutHLSL.h
@@ -24,7 +24,7 @@ namespace sh
// The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED
// for everything else (D3D10+ constant blocks and all attributes/varyings).
-class HLSLBlockEncoder : public BlockLayoutEncoder
+class COMPILER_EXPORT HLSLBlockEncoder : public BlockLayoutEncoder
{
public:
enum HLSLBlockEncoderStrategy
@@ -54,8 +54,9 @@ class HLSLBlockEncoder : public BlockLayoutEncoder
// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
// class to count the number of used registers in a struct (which are individually packed according to the same rules).
-unsigned int HLSLVariableRegisterCount(const Varying &variable, bool transposeMatrices);
-unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType);
+COMPILER_EXPORT unsigned int HLSLVariableRegisterCount(const Varying &variable, bool transposeMatrices);
+COMPILER_EXPORT unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType);
+
}
#endif // COMMON_BLOCKLAYOUTHLSL_H_
--
2.10.2
|