339 lines
14 KiB
Diff
339 lines
14 KiB
Diff
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
|
|
|