Commit 6407fe82 by Nicolas Capens

Eliminate the ShaderLang interface.

Bug 19331817 Change-Id: I6f5e0c1130974a16cec9575f0fefdd81707b648b Reviewed-on: https://swiftshader-review.googlesource.com/2153Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 21c51c7d
......@@ -4,11 +4,13 @@
// found in the LICENSE file.
//
#include "Compiler.h"
#include "AnalyzeCallDepth.h"
#include "Initialize.h"
#include "InitializeParseContext.h"
#include "InitializeGlobals.h"
#include "ParseHelper.h"
#include "Compiler.h"
#include "ValidateLimitations.h"
namespace
......@@ -31,6 +33,29 @@ private:
};
} // namespace
//
// Initialize built-in resources with minimum expected values.
//
ShBuiltInResources::ShBuiltInResources()
{
// Constants.
MaxVertexAttribs = 8;
MaxVertexUniformVectors = 128;
MaxVaryingVectors = 8;
MaxVertexTextureImageUnits = 0;
MaxCombinedTextureImageUnits = 8;
MaxTextureImageUnits = 8;
MaxFragmentUniformVectors = 16;
MaxDrawBuffers = 1;
// Extensions.
OES_standard_derivatives = 0;
OES_fragment_precision_high = 0;
OES_EGL_image_external = 0;
MaxCallStackDepth = UINT_MAX;
}
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
: shaderType(type),
shaderSpec(spec),
......@@ -210,3 +235,26 @@ const TExtensionBehavior& TCompiler::getExtensionBehavior() const
{
return extensionBehavior;
}
bool InitCompilerGlobals()
{
if(!InitializePoolIndex())
{
assert(0 && "InitCompilerGlobals(): Failed to initalize global pool");
return false;
}
if(!InitializeParseContextIndex())
{
assert(0 && "InitCompilerGlobals(): Failed to initalize parse context");
return false;
}
return true;
}
void FreeCompilerGlobals()
{
FreeParseContextIndex();
FreePoolIndex();
}
\ No newline at end of file
......@@ -4,16 +4,78 @@
// found in the LICENSE file.
//
#ifndef _SHHANDLE_INCLUDED_
#define _SHHANDLE_INCLUDED_
#include "GLSLANG/ShaderLang.h"
#ifndef _COMPILER_INCLUDED_
#define _COMPILER_INCLUDED_
#include "ExtensionBehavior.h"
#include "InfoSink.h"
#include "SymbolTable.h"
//
// The names of the following enums have been derived by replacing GL prefix
// with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH.
// The enum values are also equal to the values of their GL counterpart. This
// is done to make it easier for applications to use the shader library.
//
enum ShShaderType
{
SH_FRAGMENT_SHADER = 0x8B30,
SH_VERTEX_SHADER = 0x8B31
};
enum ShShaderSpec
{
SH_GLES2_SPEC = 0x8B40,
SH_WEBGL_SPEC = 0x8B41
};
enum ShShaderInfo
{
SH_INFO_LOG_LENGTH = 0x8B84,
SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH
SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A
};
enum ShCompileOptions
{
SH_VALIDATE = 0,
SH_VALIDATE_LOOP_INDEXING = 0x0001,
SH_INTERMEDIATE_TREE = 0x0002,
SH_OBJECT_CODE = 0x0004,
SH_ATTRIBUTES_UNIFORMS = 0x0008,
SH_LINE_DIRECTIVES = 0x0010,
SH_SOURCE_PATH = 0x0020
};
//
// Implementation dependent built-in resources (constants and extensions).
// The names for these resources has been obtained by stripping gl_/GL_.
//
struct ShBuiltInResources
{
ShBuiltInResources();
// Constants.
int MaxVertexAttribs;
int MaxVertexUniformVectors;
int MaxVaryingVectors;
int MaxVertexTextureImageUnits;
int MaxCombinedTextureImageUnits;
int MaxTextureImageUnits;
int MaxFragmentUniformVectors;
int MaxDrawBuffers;
// Extensions.
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_fragment_precision_high;
int OES_EGL_image_external;
unsigned int MaxCallStackDepth;
};
//
// The base class for the machine dependent compiler to derive from
// for managing object code from the compile.
//
......@@ -69,16 +131,7 @@ private:
TPoolAllocator allocator;
};
//
// This is the interface between the machine independent code
// and the machine dependent code.
//
// The machine dependent code should derive from the classes
// above. Then Construct*() and Delete*() will create and
// destroy the machine dependent objects, which contain the
// above machine independent information.
//
TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec);
void DeleteCompiler(TCompiler*);
bool InitCompilerGlobals();
void FreeCompilerGlobals();
#endif // _SHHANDLE_INCLUDED_
#endif // _COMPILER_INCLUDED_
......@@ -201,7 +201,6 @@
<ClCompile Include="DirectiveHandler.cpp" />
<ClCompile Include="InfoSink.cpp" />
<ClCompile Include="Initialize.cpp" />
<ClCompile Include="InitializeDll.cpp" />
<ClCompile Include="InitializeParseContext.cpp" />
<ClCompile Include="Intermediate.cpp" />
<ClCompile Include="intermOut.cpp" />
......@@ -211,7 +210,6 @@
<ClCompile Include="parseConst.cpp" />
<ClCompile Include="ParseHelper.cpp" />
<ClCompile Include="PoolAlloc.cpp" />
<ClCompile Include="ShaderLang.cpp" />
<ClCompile Include="SymbolTable.cpp" />
<ClCompile Include="TranslatorASM.cpp" />
<ClCompile Include="util.cpp" />
......@@ -292,7 +290,6 @@
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\GLSLANG\ShaderLang.h" />
<ClInclude Include="AnalyzeCallDepth.h" />
<ClInclude Include="BaseTypes.h" />
<ClInclude Include="Common.h" />
......@@ -302,7 +299,6 @@
<ClInclude Include="Diagnostics.h" />
<ClInclude Include="InfoSink.h" />
<ClInclude Include="Initialize.h" />
<ClInclude Include="InitializeDll.h" />
<ClInclude Include="InitializeGlobals.h" />
<ClInclude Include="InitializeParseContext.h" />
<ClInclude Include="intermediate.h" />
......
......@@ -26,9 +26,6 @@
<ClCompile Include="Initialize.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="InitializeDll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Intermediate.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -50,9 +47,6 @@
<ClCompile Include="PoolAlloc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ShaderLang.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SymbolTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -106,9 +100,6 @@
<ClInclude Include="Initialize.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InitializeDll.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InitializeGlobals.h">
<Filter>Header Files</Filter>
</ClInclude>
......@@ -148,9 +139,6 @@
<ClInclude Include="glslang_tab.h">
<Filter>Header Files\generated</Filter>
</ClInclude>
<ClInclude Include="..\include\GLSLANG\ShaderLang.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="OutputASM.h">
<Filter>Header Files</Filter>
</ClInclude>
......
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "InitializeDll.h"
#include "InitializeGlobals.h"
#include "InitializeParseContext.h"
#include "osinclude.h"
bool InitProcess()
{
if (!InitializePoolIndex()) {
assert(0 && "InitProcess(): Failed to initalize global pool");
return false;
}
if (!InitializeParseContextIndex()) {
assert(0 && "InitProcess(): Failed to initalize parse context");
return false;
}
return true;
}
void DetachProcess()
{
FreeParseContextIndex();
FreePoolIndex();
}
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef __INITIALIZEDLL_H
#define __INITIALIZEDLL_H
bool InitProcess();
void DetachProcess();
#endif // __INITIALIZEDLL_H
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
// Implement the top-level of interface to the compiler,
// as defined in ShaderLang.h
//
#include "GLSLANG/ShaderLang.h"
#include "InitializeDll.h"
#include "preprocessor/length_limits.h"
#include "Compiler.h"
#include <limits.h>
//
// Driver must call this first, once, before doing any other
// compiler operations.
//
int ShInitialize()
{
return InitProcess() ? 1 : 0;
}
//
// Cleanup symbol tables
//
int ShFinalize()
{
DetachProcess();
return 1;
}
//
// Initialize built-in resources with minimum expected values.
//
ShBuiltInResources::ShBuiltInResources()
{
// Constants.
MaxVertexAttribs = 8;
MaxVertexUniformVectors = 128;
MaxVaryingVectors = 8;
MaxVertexTextureImageUnits = 0;
MaxCombinedTextureImageUnits = 8;
MaxTextureImageUnits = 8;
MaxFragmentUniformVectors = 16;
MaxDrawBuffers = 1;
// Extensions.
OES_standard_derivatives = 0;
OES_fragment_precision_high = 0;
OES_EGL_image_external = 0;
MaxCallStackDepth = UINT_MAX;
}
......@@ -26,21 +26,3 @@ bool TranslatorASM::translate(TIntermNode* root)
return parseContext.numErrors() == 0;
}
//
// This function must be provided to create the actual
// compile object used by higher level code. It returns
// a subclass of TCompiler.
//
TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec)
{
return new TranslatorASM(0, type, spec);
}
//
// Delete the compiler made by ConstructCompiler
//
void DeleteCompiler(TCompiler* compiler)
{
delete compiler;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
#include "GLSLANG/ShaderLang.h"
#include "Compiler.h"
#include "intermediate.h"
class TInfoSinkBase;
......
......@@ -36,7 +36,6 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
#include "SymbolTable.h"
#include "ParseHelper.h"
#include "GLSLANG/ShaderLang.h"
#define YYENABLE_NLS 0
#define YYLTYPE_IS_TRIVIAL 1
......
......@@ -90,7 +90,6 @@
#include "SymbolTable.h"
#include "ParseHelper.h"
#include "GLSLANG/ShaderLang.h"
#define YYENABLE_NLS 0
#define YYLTYPE_IS_TRIVIAL 1
......@@ -661,27 +660,27 @@ static const yytype_int16 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 168, 168, 203, 206, 219, 224, 229, 235, 238,
317, 320, 421, 431, 444, 452, 552, 555, 563, 567,
574, 578, 585, 591, 600, 608, 663, 670, 680, 683,
693, 703, 724, 725, 726, 731, 732, 741, 753, 754,
762, 773, 777, 778, 788, 798, 808, 821, 822, 832,
845, 849, 853, 857, 858, 871, 872, 885, 886, 899,
900, 917, 918, 931, 932, 933, 934, 935, 939, 942,
953, 961, 988, 993, 1003, 1041, 1044, 1051, 1059, 1080,
1101, 1112, 1141, 1146, 1156, 1161, 1171, 1174, 1177, 1180,
1186, 1193, 1196, 1218, 1236, 1260, 1283, 1287, 1305, 1313,
1345, 1365, 1453, 1462, 1485, 1488, 1494, 1502, 1510, 1518,
1528, 1535, 1538, 1541, 1547, 1550, 1565, 1569, 1573, 1577,
1586, 1591, 1596, 1601, 1606, 1611, 1616, 1621, 1626, 1631,
1637, 1643, 1649, 1654, 1659, 1668, 1673, 1678, 1691, 1691,
1705, 1705, 1714, 1717, 1732, 1768, 1772, 1778, 1786, 1802,
1806, 1810, 1811, 1817, 1818, 1819, 1820, 1821, 1825, 1826,
1826, 1826, 1836, 1837, 1841, 1841, 1842, 1842, 1847, 1850,
1860, 1863, 1869, 1870, 1874, 1882, 1886, 1896, 1901, 1918,
1918, 1923, 1923, 1930, 1930, 1938, 1941, 1947, 1950, 1956,
1960, 1967, 1974, 1981, 1988, 1999, 2008, 2012, 2019, 2022,
2028, 2028
0, 167, 167, 202, 205, 218, 223, 228, 234, 237,
316, 319, 420, 430, 443, 451, 551, 554, 562, 566,
573, 577, 584, 590, 599, 607, 662, 669, 679, 682,
692, 702, 723, 724, 725, 730, 731, 740, 752, 753,
761, 772, 776, 777, 787, 797, 807, 820, 821, 831,
844, 848, 852, 856, 857, 870, 871, 884, 885, 898,
899, 916, 917, 930, 931, 932, 933, 934, 938, 941,
952, 960, 987, 992, 1002, 1040, 1043, 1050, 1058, 1079,
1100, 1111, 1140, 1145, 1155, 1160, 1170, 1173, 1176, 1179,
1185, 1192, 1195, 1217, 1235, 1259, 1282, 1286, 1304, 1312,
1344, 1364, 1452, 1461, 1484, 1487, 1493, 1501, 1509, 1517,
1527, 1534, 1537, 1540, 1546, 1549, 1564, 1568, 1572, 1576,
1585, 1590, 1595, 1600, 1605, 1610, 1615, 1620, 1625, 1630,
1636, 1642, 1648, 1653, 1658, 1667, 1672, 1677, 1690, 1690,
1704, 1704, 1713, 1716, 1731, 1767, 1771, 1777, 1785, 1801,
1805, 1809, 1810, 1816, 1817, 1818, 1819, 1820, 1824, 1825,
1825, 1825, 1835, 1836, 1840, 1840, 1841, 1841, 1846, 1849,
1859, 1862, 1868, 1869, 1873, 1881, 1885, 1895, 1900, 1917,
1917, 1922, 1922, 1929, 1929, 1937, 1940, 1946, 1949, 1955,
1959, 1966, 1973, 1980, 1987, 1998, 2007, 2011, 2018, 2021,
2027, 2027
};
#endif
......
......@@ -7,7 +7,6 @@
#ifndef _LOCAL_INTERMEDIATE_INCLUDED_
#define _LOCAL_INTERMEDIATE_INCLUDED_
#include "GLSLANG/ShaderLang.h"
#include "intermediate.h"
struct TVectorFields {
......
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_
//
// This is the platform independent interface between an OGL driver
// and the shading language compiler.
//
#ifdef __cplusplus
extern "C" {
#endif
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define SH_VERSION 105
//
// The names of the following enums have been derived by replacing GL prefix
// with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH.
// The enum values are also equal to the values of their GL counterpart. This
// is done to make it easier for applications to use the shader library.
//
typedef enum {
SH_FRAGMENT_SHADER = 0x8B30,
SH_VERTEX_SHADER = 0x8B31
} ShShaderType;
typedef enum {
SH_GLES2_SPEC = 0x8B40,
SH_WEBGL_SPEC = 0x8B41
} ShShaderSpec;
typedef enum {
SH_INFO_LOG_LENGTH = 0x8B84,
SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH
SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A
} ShShaderInfo;
// Compile options.
typedef enum {
SH_VALIDATE = 0,
SH_VALIDATE_LOOP_INDEXING = 0x0001,
SH_INTERMEDIATE_TREE = 0x0002,
SH_OBJECT_CODE = 0x0004,
SH_ATTRIBUTES_UNIFORMS = 0x0008,
SH_LINE_DIRECTIVES = 0x0010,
SH_SOURCE_PATH = 0x0020
} ShCompileOptions;
//
// Driver must call this first, once, before doing any other
// compiler operations.
// If the function succeeds, the return value is nonzero, else zero.
//
int ShInitialize();
//
// Driver should call this at shutdown.
// If the function succeeds, the return value is nonzero, else zero.
//
int ShFinalize();
//
// Implementation dependent built-in resources (constants and extensions).
// The names for these resources has been obtained by stripping gl_/GL_.
//
struct ShBuiltInResources
{
ShBuiltInResources();
// Constants.
int MaxVertexAttribs;
int MaxVertexUniformVectors;
int MaxVaryingVectors;
int MaxVertexTextureImageUnits;
int MaxCombinedTextureImageUnits;
int MaxTextureImageUnits;
int MaxFragmentUniformVectors;
int MaxDrawBuffers;
// Extensions.
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_fragment_precision_high;
int OES_EGL_image_external;
unsigned int MaxCallStackDepth;
};
#ifdef __cplusplus
}
#endif
#endif // _COMPILER_INTERFACE_INCLUDED_
......@@ -18,8 +18,6 @@
#include "main.h"
#include "utilities.h"
#include "GLSLANG/ShaderLang.h"
#include <string>
namespace gl
......@@ -158,7 +156,7 @@ TranslatorASM *Shader::createCompiler(ShShaderType type)
{
if(!compilerInitialized)
{
ShInitialize();
InitCompilerGlobals();
compilerInitialized = true;
}
......@@ -228,7 +226,7 @@ void Shader::flagForDeletion()
void Shader::releaseCompiler()
{
ShFinalize();
FreeCompilerGlobals();
compilerInitialized = false;
}
......
......@@ -18,8 +18,6 @@
#include "main.h"
#include "utilities.h"
#include "GLSLANG/ShaderLang.h"
#include <string>
namespace es2
......@@ -158,7 +156,7 @@ TranslatorASM *Shader::createCompiler(ShShaderType type)
{
if(!compilerInitialized)
{
ShInitialize();
InitCompilerGlobals();
compilerInitialized = true;
}
......@@ -228,7 +226,7 @@ void Shader::flagForDeletion()
void Shader::releaseCompiler()
{
ShFinalize();
FreeCompilerGlobals();
compilerInitialized = false;
}
......
......@@ -18,8 +18,6 @@
#include "main.h"
#include "utilities.h"
#include "GLSLANG/ShaderLang.h"
#include <string>
namespace es2
......@@ -158,7 +156,7 @@ TranslatorASM *Shader::createCompiler(ShShaderType type)
{
if(!compilerInitialized)
{
ShInitialize();
InitCompilerGlobals();
compilerInitialized = true;
}
......@@ -228,7 +226,7 @@ void Shader::flagForDeletion()
void Shader::releaseCompiler()
{
ShFinalize();
FreeCompilerGlobals();
compilerInitialized = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment