Commit acb4b81a by Jamie Madill Committed by Commit Bot

translator: Put ShaderLang APIs in "sh" namespace.

Working with glslang in Vulkan means we are static linking libANGLE with functions that have the same name as our translator APIs. We can fix this by scoping our APIs. We don't need to scope the types of the file, since they don't conflict. This will require a follow-up patch to remove the unscoped APIs once we switch over Chromium. We also scope TCompiler and some related classes to avoid multiply defined link errors with glslang. BUG=angleproject:1576 Change-Id: I729b19467d2ff7d374a82044b16dbebdf2dc8f16 Reviewed-on: https://chromium-review.googlesource.com/408337Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 01a80eeb
...@@ -49,7 +49,7 @@ static bool ParseIntValue(const std::string &, int emptyDefault, int *outValue); ...@@ -49,7 +49,7 @@ static bool ParseIntValue(const std::string &, int emptyDefault, int *outValue);
// //
void GenerateResources(ShBuiltInResources *resources) void GenerateResources(ShBuiltInResources *resources)
{ {
ShInitBuiltInResources(resources); sh::InitBuiltInResources(resources);
resources->MaxVertexAttribs = 8; resources->MaxVertexAttribs = 8;
resources->MaxVertexUniformVectors = 128; resources->MaxVertexUniformVectors = 128;
...@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) ...@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
ShShaderSpec spec = SH_GLES2_SPEC; ShShaderSpec spec = SH_GLES2_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShInitialize(); sh::Initialize();
ShBuiltInResources resources; ShBuiltInResources resources;
GenerateResources(&resources); GenerateResources(&resources);
...@@ -230,16 +230,16 @@ int main(int argc, char *argv[]) ...@@ -230,16 +230,16 @@ int main(int argc, char *argv[])
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
if (vertexCompiler == 0) if (vertexCompiler == 0)
{ {
vertexCompiler = ShConstructCompiler( vertexCompiler =
GL_VERTEX_SHADER, spec, output, &resources); sh::ConstructCompiler(GL_VERTEX_SHADER, spec, output, &resources);
} }
compiler = vertexCompiler; compiler = vertexCompiler;
break; break;
case GL_FRAGMENT_SHADER: case GL_FRAGMENT_SHADER:
if (fragmentCompiler == 0) if (fragmentCompiler == 0)
{ {
fragmentCompiler = ShConstructCompiler( fragmentCompiler =
GL_FRAGMENT_SHADER, spec, output, &resources); sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
} }
compiler = fragmentCompiler; compiler = fragmentCompiler;
break; break;
...@@ -247,7 +247,7 @@ int main(int argc, char *argv[]) ...@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
if (computeCompiler == 0) if (computeCompiler == 0)
{ {
computeCompiler = computeCompiler =
ShConstructCompiler(GL_COMPUTE_SHADER, spec, output, &resources); sh::ConstructCompiler(GL_COMPUTE_SHADER, spec, output, &resources);
} }
compiler = computeCompiler; compiler = computeCompiler;
break; break;
...@@ -259,7 +259,7 @@ int main(int argc, char *argv[]) ...@@ -259,7 +259,7 @@ int main(int argc, char *argv[])
bool compiled = CompileFile(argv[0], compiler, compileOptions); bool compiled = CompileFile(argv[0], compiler, compileOptions);
LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG"); LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG");
std::string log = ShGetInfoLog(compiler); std::string log = sh::GetInfoLog(compiler);
puts(log.c_str()); puts(log.c_str());
LogMsg("END", "COMPILER", numCompiles, "INFO LOG"); LogMsg("END", "COMPILER", numCompiles, "INFO LOG");
printf("\n\n"); printf("\n\n");
...@@ -267,7 +267,7 @@ int main(int argc, char *argv[]) ...@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
if (compiled && (compileOptions & SH_OBJECT_CODE)) if (compiled && (compileOptions & SH_OBJECT_CODE))
{ {
LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE"); LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE");
std::string code = ShGetObjectCode(compiler); std::string code = sh::GetObjectCode(compiler);
puts(code.c_str()); puts(code.c_str());
LogMsg("END", "COMPILER", numCompiles, "OBJ CODE"); LogMsg("END", "COMPILER", numCompiles, "OBJ CODE");
printf("\n\n"); printf("\n\n");
...@@ -296,13 +296,13 @@ int main(int argc, char *argv[]) ...@@ -296,13 +296,13 @@ int main(int argc, char *argv[])
usage(); usage();
if (vertexCompiler) if (vertexCompiler)
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
if (fragmentCompiler) if (fragmentCompiler)
ShDestruct(fragmentCompiler); sh::Destruct(fragmentCompiler);
if (computeCompiler) if (computeCompiler)
ShDestruct(computeCompiler); sh::Destruct(computeCompiler);
ShFinalize(); sh::Finalize();
return failCode; return failCode;
} }
...@@ -376,7 +376,7 @@ sh::GLenum FindShaderType(const char *fileName) ...@@ -376,7 +376,7 @@ sh::GLenum FindShaderType(const char *fileName)
} }
// //
// Read a file's data into a string, and compile it using ShCompile // Read a file's data into a string, and compile it using sh::Compile
// //
bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOptions) bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOptions)
{ {
...@@ -384,7 +384,7 @@ bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOpti ...@@ -384,7 +384,7 @@ bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOpti
if (!ReadShaderSource(fileName, source)) if (!ReadShaderSource(fileName, source))
return false; return false;
int ret = ShCompile(compiler, &source[0], source.size(), compileOptions); int ret = sh::Compile(compiler, &source[0], source.size(), compileOptions);
FreeShaderSource(source); FreeShaderSource(source);
return ret ? true : false; return ret ? true : false;
...@@ -447,10 +447,10 @@ void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVari ...@@ -447,10 +447,10 @@ void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVari
static void PrintActiveVariables(ShHandle compiler) static void PrintActiveVariables(ShHandle compiler)
{ {
const std::vector<sh::Uniform> *uniforms = ShGetUniforms(compiler); const std::vector<sh::Uniform> *uniforms = sh::GetUniforms(compiler);
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler);
const std::vector<sh::Attribute> *attributes = ShGetAttributes(compiler); const std::vector<sh::Attribute> *attributes = sh::GetAttributes(compiler);
const std::vector<sh::OutputVariable> *outputs = ShGetOutputVariables(compiler); const std::vector<sh::OutputVariable> *outputs = sh::GetOutputVariables(compiler);
for (size_t varCategory = 0; varCategory < 4; ++varCategory) for (size_t varCategory = 0; varCategory < 4; ++varCategory)
{ {
size_t numVars = 0; size_t numVars = 0;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "angle_gl.h" #include "angle_gl.h"
using namespace sh;
struct TranslatorCacheKey struct TranslatorCacheKey
{ {
bool operator==(const TranslatorCacheKey &other) const bool operator==(const TranslatorCacheKey &other) const
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "compiler/translator/TranslatorHLSL.h" #include "compiler/translator/TranslatorHLSL.h"
#endif // ANGLE_ENABLE_HLSL #endif // ANGLE_ENABLE_HLSL
namespace sh
{
// //
// This function must be provided to create the actual // This function must be provided to create the actual
// compile object used by higher level code. It returns // compile object used by higher level code. It returns
...@@ -29,10 +32,10 @@ TCompiler* ConstructCompiler( ...@@ -29,10 +32,10 @@ TCompiler* ConstructCompiler(
#ifdef ANGLE_ENABLE_ESSL #ifdef ANGLE_ENABLE_ESSL
return new TranslatorESSL(type, spec); return new TranslatorESSL(type, spec);
#else #else
// This compiler is not supported in this // This compiler is not supported in this configuration. Return NULL per the
// configuration. Return NULL per the ShConstructCompiler API. // sh::ConstructCompiler API.
return nullptr; return nullptr;
#endif // ANGLE_ENABLE_ESSL #endif // ANGLE_ENABLE_ESSL
case SH_GLSL_130_OUTPUT: case SH_GLSL_130_OUTPUT:
case SH_GLSL_140_OUTPUT: case SH_GLSL_140_OUTPUT:
case SH_GLSL_150_CORE_OUTPUT: case SH_GLSL_150_CORE_OUTPUT:
...@@ -47,23 +50,23 @@ TCompiler* ConstructCompiler( ...@@ -47,23 +50,23 @@ TCompiler* ConstructCompiler(
#ifdef ANGLE_ENABLE_GLSL #ifdef ANGLE_ENABLE_GLSL
return new TranslatorGLSL(type, spec, output); return new TranslatorGLSL(type, spec, output);
#else #else
// This compiler is not supported in this // This compiler is not supported in this configuration. Return NULL per the
// configuration. Return NULL per the ShConstructCompiler API. // sh::ConstructCompiler API.
return nullptr; return nullptr;
#endif // ANGLE_ENABLE_GLSL #endif // ANGLE_ENABLE_GLSL
case SH_HLSL_3_0_OUTPUT: case SH_HLSL_3_0_OUTPUT:
case SH_HLSL_4_1_OUTPUT: case SH_HLSL_4_1_OUTPUT:
case SH_HLSL_4_0_FL9_3_OUTPUT: case SH_HLSL_4_0_FL9_3_OUTPUT:
#ifdef ANGLE_ENABLE_HLSL #ifdef ANGLE_ENABLE_HLSL
return new TranslatorHLSL(type, spec, output); return new TranslatorHLSL(type, spec, output);
#else #else
// This compiler is not supported in this // This compiler is not supported in this configuration. Return NULL per the
// configuration. Return NULL per the ShConstructCompiler API. // sh::ConstructCompiler API.
return nullptr; return nullptr;
#endif // ANGLE_ENABLE_HLSL #endif // ANGLE_ENABLE_HLSL
default: default:
// Unknown format. Return NULL per the ShConstructCompiler API. // Unknown format. Return NULL per the sh::ConstructCompiler API.
return nullptr; return nullptr;
} }
} }
...@@ -74,3 +77,5 @@ void DeleteCompiler(TCompiler* compiler) ...@@ -74,3 +77,5 @@ void DeleteCompiler(TCompiler* compiler)
{ {
delete compiler; delete compiler;
} }
} // namespace sh
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "compiler/translator/VariableInfo.h" #include "compiler/translator/VariableInfo.h"
#include "third_party/compiler/ArrayBoundsClamper.h" #include "third_party/compiler/ArrayBoundsClamper.h"
namespace sh
{
class TCompiler; class TCompiler;
#ifdef ANGLE_ENABLE_HLSL #ifdef ANGLE_ENABLE_HLSL
class TranslatorHLSL; class TranslatorHLSL;
...@@ -257,4 +260,6 @@ TCompiler* ConstructCompiler( ...@@ -257,4 +260,6 @@ TCompiler* ConstructCompiler(
sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
void DeleteCompiler(TCompiler*); void DeleteCompiler(TCompiler*);
} // namespace sh
#endif // COMPILER_TRANSLATOR_COMPILER_H_ #endif // COMPILER_TRANSLATOR_COMPILER_H_
...@@ -716,6 +716,6 @@ bool EmulatePrecision::SupportedInLanguage(const ShShaderOutput outputLanguage) ...@@ -716,6 +716,6 @@ bool EmulatePrecision::SupportedInLanguage(const ShShaderOutput outputLanguage)
default: default:
// Other languages not yet supported // Other languages not yet supported
return (outputLanguage == SH_GLSL_COMPATIBILITY_OUTPUT || return (outputLanguage == SH_GLSL_COMPATIBILITY_OUTPUT ||
IsGLSL130OrNewer(outputLanguage)); sh::IsGLSL130OrNewer(outputLanguage));
} }
} }
...@@ -39,11 +39,11 @@ void TOutputGLSL::visitSymbol(TIntermSymbol *node) ...@@ -39,11 +39,11 @@ void TOutputGLSL::visitSymbol(TIntermSymbol *node)
{ {
out << "gl_FragDepth"; out << "gl_FragDepth";
} }
else if (symbol == "gl_FragColor" && IsGLSL130OrNewer(getShaderOutput())) else if (symbol == "gl_FragColor" && sh::IsGLSL130OrNewer(getShaderOutput()))
{ {
out << "webgl_FragColor"; out << "webgl_FragColor";
} }
else if (symbol == "gl_FragData" && IsGLSL130OrNewer(getShaderOutput())) else if (symbol == "gl_FragData" && sh::IsGLSL130OrNewer(getShaderOutput()))
{ {
out << "webgl_FragData"; out << "webgl_FragData";
} }
...@@ -89,8 +89,8 @@ TString TOutputGLSL::translateTextureFunction(TString &name) ...@@ -89,8 +89,8 @@ TString TOutputGLSL::translateTextureFunction(TString &name)
"textureCubeGradEXT", "textureGrad", "textureCubeGradEXT", "textureGrad",
NULL, NULL NULL, NULL
}; };
const char **mapping = (IsGLSL130OrNewer(getShaderOutput())) ? const char **mapping =
legacyToCoreRename : simpleRename; (sh::IsGLSL130OrNewer(getShaderOutput())) ? legacyToCoreRename : simpleRename;
for (int i = 0; mapping[i] != NULL; i += 2) for (int i = 0; mapping[i] != NULL; i += 2)
{ {
......
...@@ -150,7 +150,7 @@ void TOutputGLSLBase::writeVariableType(const TType &type) ...@@ -150,7 +150,7 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
{ {
TQualifier qualifier = type.getQualifier(); TQualifier qualifier = type.getQualifier();
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
bool removeInvariant = (qualifier == EvqVaryingIn && IsGLSL420OrNewer(mOutput) && bool removeInvariant = (qualifier == EvqVaryingIn && sh::IsGLSL420OrNewer(mOutput) &&
!(mCompileOptions & SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT)); !(mCompileOptions & SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT));
if (type.isInvariant() && !removeInvariant) if (type.isInvariant() && !removeInvariant)
{ {
...@@ -163,7 +163,7 @@ void TOutputGLSLBase::writeVariableType(const TType &type) ...@@ -163,7 +163,7 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
} }
if (qualifier != EvqTemporary && qualifier != EvqGlobal) if (qualifier != EvqTemporary && qualifier != EvqGlobal)
{ {
if (IsGLSL130OrNewer(mOutput)) if (sh::IsGLSL130OrNewer(mOutput))
{ {
switch (qualifier) switch (qualifier)
{ {
......
...@@ -65,6 +65,50 @@ bool ContainsImage(const TType &type) ...@@ -65,6 +65,50 @@ bool ContainsImage(const TType &type)
} // namespace } // namespace
TParseContext::TParseContext(TSymbolTable &symt,
TExtensionBehavior &ext,
sh::GLenum type,
ShShaderSpec spec,
ShCompileOptions options,
bool checksPrecErrors,
TInfoSink &is,
const ShBuiltInResources &resources)
: intermediate(),
symbolTable(symt),
mDeferredSingleDeclarationErrorCheck(false),
mShaderType(type),
mShaderSpec(spec),
mCompileOptions(options),
mShaderVersion(100),
mTreeRoot(nullptr),
mLoopNestingLevel(0),
mStructNestingLevel(0),
mSwitchNestingLevel(0),
mCurrentFunctionType(nullptr),
mFunctionReturnsValue(false),
mChecksPrecisionErrors(checksPrecErrors),
mFragmentPrecisionHighOnESSL1(false),
mDefaultMatrixPacking(EmpColumnMajor),
mDefaultBlockStorage(sh::IsWebGLBasedSpec(spec) ? EbsStd140 : EbsShared),
mDiagnostics(is),
mDirectiveHandler(ext,
mDiagnostics,
mShaderVersion,
mShaderType,
resources.WEBGL_debug_shader_precision == 1),
mPreprocessor(&mDiagnostics, &mDirectiveHandler),
mScanner(nullptr),
mUsesFragData(false),
mUsesFragColor(false),
mUsesSecondaryOutputs(false),
mMinProgramTexelOffset(resources.MinProgramTexelOffset),
mMaxProgramTexelOffset(resources.MaxProgramTexelOffset),
mComputeShaderLocalSizeDeclared(false),
mDeclaringFunction(false)
{
mComputeShaderLocalSize.fill(-1);
}
// //
// Look at a '.' field selector string and change it into offsets // Look at a '.' field selector string and change it into offsets
// for a vector. // for a vector.
...@@ -481,7 +525,7 @@ bool TParseContext::checkIsNotReserved(const TSourceLoc &line, const TString &id ...@@ -481,7 +525,7 @@ bool TParseContext::checkIsNotReserved(const TSourceLoc &line, const TString &id
error(line, reservedErrMsg, "gl_"); error(line, reservedErrMsg, "gl_");
return false; return false;
} }
if (IsWebGLBasedSpec(mShaderSpec)) if (sh::IsWebGLBasedSpec(mShaderSpec))
{ {
if (identifier.compare(0, 6, "webgl_") == 0) if (identifier.compare(0, 6, "webgl_") == 0)
{ {
...@@ -2844,7 +2888,7 @@ void TParseContext::exitStructDeclaration() ...@@ -2844,7 +2888,7 @@ void TParseContext::exitStructDeclaration()
void TParseContext::checkIsBelowStructNestingLimit(const TSourceLoc &line, const TField &field) void TParseContext::checkIsBelowStructNestingLimit(const TSourceLoc &line, const TField &field)
{ {
if (!IsWebGLBasedSpec(mShaderSpec)) if (!sh::IsWebGLBasedSpec(mShaderSpec))
{ {
return; return;
} }
...@@ -3134,7 +3178,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp ...@@ -3134,7 +3178,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp
if (qualifierType == "shared") if (qualifierType == "shared")
{ {
if (IsWebGLBasedSpec(mShaderSpec)) if (sh::IsWebGLBasedSpec(mShaderSpec))
{ {
error(qualifierTypeLine, "Only std140 layout is allowed in WebGL", "shared"); error(qualifierTypeLine, "Only std140 layout is allowed in WebGL", "shared");
} }
...@@ -3142,7 +3186,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp ...@@ -3142,7 +3186,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp
} }
else if (qualifierType == "packed") else if (qualifierType == "packed")
{ {
if (IsWebGLBasedSpec(mShaderSpec)) if (sh::IsWebGLBasedSpec(mShaderSpec))
{ {
error(qualifierTypeLine, "Only std140 layout is allowed in WebGL", "packed"); error(qualifierTypeLine, "Only std140 layout is allowed in WebGL", "packed");
} }
......
...@@ -36,42 +36,7 @@ class TParseContext : angle::NonCopyable ...@@ -36,42 +36,7 @@ class TParseContext : angle::NonCopyable
ShCompileOptions options, ShCompileOptions options,
bool checksPrecErrors, bool checksPrecErrors,
TInfoSink &is, TInfoSink &is,
const ShBuiltInResources &resources) const ShBuiltInResources &resources);
: intermediate(),
symbolTable(symt),
mDeferredSingleDeclarationErrorCheck(false),
mShaderType(type),
mShaderSpec(spec),
mCompileOptions(options),
mShaderVersion(100),
mTreeRoot(nullptr),
mLoopNestingLevel(0),
mStructNestingLevel(0),
mSwitchNestingLevel(0),
mCurrentFunctionType(nullptr),
mFunctionReturnsValue(false),
mChecksPrecisionErrors(checksPrecErrors),
mFragmentPrecisionHighOnESSL1(false),
mDefaultMatrixPacking(EmpColumnMajor),
mDefaultBlockStorage(IsWebGLBasedSpec(spec) ? EbsStd140 : EbsShared),
mDiagnostics(is),
mDirectiveHandler(ext,
mDiagnostics,
mShaderVersion,
mShaderType,
resources.WEBGL_debug_shader_precision == 1),
mPreprocessor(&mDiagnostics, &mDirectiveHandler),
mScanner(nullptr),
mUsesFragData(false),
mUsesFragColor(false),
mUsesSecondaryOutputs(false),
mMinProgramTexelOffset(resources.MinProgramTexelOffset),
mMaxProgramTexelOffset(resources.MaxProgramTexelOffset),
mComputeShaderLocalSizeDeclared(false),
mDeclaringFunction(false)
{
mComputeShaderLocalSize.fill(-1);
}
const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; } const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; }
pp::Preprocessor &getPreprocessor() { return mPreprocessor; } pp::Preprocessor &getPreprocessor() { return mPreprocessor; }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "compiler/translator/VariablePacker.h" #include "compiler/translator/VariablePacker.h"
#include "angle_gl.h" #include "angle_gl.h"
using namespace sh;
namespace namespace
{ {
...@@ -34,31 +36,31 @@ template <typename VarT> ...@@ -34,31 +36,31 @@ template <typename VarT>
const std::vector<VarT> *GetVariableList(const TCompiler *compiler); const std::vector<VarT> *GetVariableList(const TCompiler *compiler);
template <> template <>
const std::vector<sh::Uniform> *GetVariableList(const TCompiler *compiler) const std::vector<Uniform> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getUniforms(); return &compiler->getUniforms();
} }
template <> template <>
const std::vector<sh::Varying> *GetVariableList(const TCompiler *compiler) const std::vector<Varying> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getVaryings(); return &compiler->getVaryings();
} }
template <> template <>
const std::vector<sh::Attribute> *GetVariableList(const TCompiler *compiler) const std::vector<Attribute> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getAttributes(); return &compiler->getAttributes();
} }
template <> template <>
const std::vector<sh::OutputVariable> *GetVariableList(const TCompiler *compiler) const std::vector<OutputVariable> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getOutputVariables(); return &compiler->getOutputVariables();
} }
template <> template <>
const std::vector<sh::InterfaceBlock> *GetVariableList(const TCompiler *compiler) const std::vector<InterfaceBlock> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getInterfaceBlocks(); return &compiler->getInterfaceBlocks();
} }
...@@ -235,8 +237,9 @@ ShHandle ShConstructCompiler(sh::GLenum type, ShShaderSpec spec, ...@@ -235,8 +237,9 @@ ShHandle ShConstructCompiler(sh::GLenum type, ShShaderSpec spec,
} }
// Generate built-in symbol table. // Generate built-in symbol table.
if (!compiler->Init(*resources)) { if (!compiler->Init(*resources))
ShDestruct(base); {
sh::Destruct(base);
return 0; return 0;
} }
...@@ -332,32 +335,32 @@ const std::map<std::string, std::string> *ShGetNameHashingMap( ...@@ -332,32 +335,32 @@ const std::map<std::string, std::string> *ShGetNameHashingMap(
return &(compiler->getNameMap()); return &(compiler->getNameMap());
} }
const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle) const std::vector<Uniform> *ShGetUniforms(const ShHandle handle)
{ {
return GetShaderVariables<sh::Uniform>(handle); return GetShaderVariables<Uniform>(handle);
} }
const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle) const std::vector<Varying> *ShGetVaryings(const ShHandle handle)
{ {
return GetShaderVariables<sh::Varying>(handle); return GetShaderVariables<Varying>(handle);
} }
const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle) const std::vector<Attribute> *ShGetAttributes(const ShHandle handle)
{ {
return GetShaderVariables<sh::Attribute>(handle); return GetShaderVariables<Attribute>(handle);
} }
const std::vector<sh::OutputVariable> *ShGetOutputVariables(const ShHandle handle) const std::vector<OutputVariable> *ShGetOutputVariables(const ShHandle handle)
{ {
return GetShaderVariables<sh::OutputVariable>(handle); return GetShaderVariables<OutputVariable>(handle);
} }
const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle) const std::vector<InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle)
{ {
return GetShaderVariables<sh::InterfaceBlock>(handle); return GetShaderVariables<InterfaceBlock>(handle);
} }
sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle) WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle)
{ {
ASSERT(handle); ASSERT(handle);
...@@ -369,7 +372,7 @@ sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle) ...@@ -369,7 +372,7 @@ sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle)
} }
bool ShCheckVariablesWithinPackingLimits(int maxVectors, bool ShCheckVariablesWithinPackingLimits(int maxVectors,
const std::vector<sh::ShaderVariable> &variables) const std::vector<ShaderVariable> &variables)
{ {
VariablePacker packer; VariablePacker packer;
return packer.CheckVariablesWithinPackingLimits(maxVectors, variables); return packer.CheckVariablesWithinPackingLimits(maxVectors, variables);
...@@ -408,3 +411,123 @@ const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(const ShHandl ...@@ -408,3 +411,123 @@ const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(const ShHandl
return nullptr; return nullptr;
#endif // ANGLE_ENABLE_HLSL #endif // ANGLE_ENABLE_HLSL
} }
namespace sh
{
bool Initialize()
{
return ShInitialize();
}
bool Finalize()
{
return ShFinalize();
}
void InitBuiltInResources(ShBuiltInResources *resources)
{
ShInitBuiltInResources(resources);
}
const std::string &GetBuiltInResourcesString(const ShHandle handle)
{
return ShGetBuiltInResourcesString(handle);
}
ShHandle ConstructCompiler(sh::GLenum type,
ShShaderSpec spec,
ShShaderOutput output,
const ShBuiltInResources *resources)
{
return ShConstructCompiler(type, spec, output, resources);
}
void Destruct(ShHandle handle)
{
return ShDestruct(handle);
}
bool Compile(const ShHandle handle,
const char *const shaderStrings[],
size_t numStrings,
ShCompileOptions compileOptions)
{
return ShCompile(handle, shaderStrings, numStrings, compileOptions);
}
void ClearResults(const ShHandle handle)
{
return ShClearResults(handle);
}
int GetShaderVersion(const ShHandle handle)
{
return ShGetShaderVersion(handle);
}
ShShaderOutput GetShaderOutputType(const ShHandle handle)
{
return ShGetShaderOutputType(handle);
}
const std::string &GetInfoLog(const ShHandle handle)
{
return ShGetInfoLog(handle);
}
const std::string &GetObjectCode(const ShHandle handle)
{
return ShGetObjectCode(handle);
}
const std::map<std::string, std::string> *GetNameHashingMap(const ShHandle handle)
{
return ShGetNameHashingMap(handle);
}
const std::vector<sh::Uniform> *GetUniforms(const ShHandle handle)
{
return ShGetUniforms(handle);
}
const std::vector<sh::Varying> *GetVaryings(const ShHandle handle)
{
return ShGetVaryings(handle);
}
const std::vector<sh::Attribute> *GetAttributes(const ShHandle handle)
{
return ShGetAttributes(handle);
}
const std::vector<sh::OutputVariable> *GetOutputVariables(const ShHandle handle)
{
return ShGetOutputVariables(handle);
}
const std::vector<sh::InterfaceBlock> *GetInterfaceBlocks(const ShHandle handle)
{
return ShGetInterfaceBlocks(handle);
}
sh::WorkGroupSize GetComputeShaderLocalGroupSize(const ShHandle handle)
{
return ShGetComputeShaderLocalGroupSize(handle);
}
bool CheckVariablesWithinPackingLimits(int maxVectors,
const std::vector<sh::ShaderVariable> &variables)
{
return ShCheckVariablesWithinPackingLimits(maxVectors, variables);
}
bool GetInterfaceBlockRegister(const ShHandle handle,
const std::string &interfaceBlockName,
unsigned int *indexOut)
{
return ShGetInterfaceBlockRegister(handle, interfaceBlockName, indexOut);
}
const std::map<std::string, unsigned int> *GetUniformRegisterMap(const ShHandle handle)
{
return ShGetUniformRegisterMap(handle);
}
} // namespace sh
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "compiler/translator/OutputESSL.h" #include "compiler/translator/OutputESSL.h"
#include "angle_gl.h" #include "angle_gl.h"
namespace sh
{
TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec) TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec)
: TCompiler(type, spec, SH_ESSL_OUTPUT) : TCompiler(type, spec, SH_ESSL_OUTPUT)
{ {
...@@ -107,3 +110,5 @@ void TranslatorESSL::writeExtensionBehavior() { ...@@ -107,3 +110,5 @@ void TranslatorESSL::writeExtensionBehavior() {
} }
} }
} }
} // namespace sh
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
namespace sh
{
class TranslatorESSL : public TCompiler class TranslatorESSL : public TCompiler
{ {
public: public:
...@@ -22,4 +25,6 @@ class TranslatorESSL : public TCompiler ...@@ -22,4 +25,6 @@ class TranslatorESSL : public TCompiler
void writeExtensionBehavior(); void writeExtensionBehavior();
}; };
} // namespace sh
#endif // COMPILER_TRANSLATOR_TRANSLATORESSL_H_ #endif // COMPILER_TRANSLATOR_TRANSLATORESSL_H_
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#include "compiler/translator/RewriteTexelFetchOffset.h" #include "compiler/translator/RewriteTexelFetchOffset.h"
#include "compiler/translator/VersionGLSL.h" #include "compiler/translator/VersionGLSL.h"
namespace sh
{
TranslatorGLSL::TranslatorGLSL(sh::GLenum type, TranslatorGLSL::TranslatorGLSL(sh::GLenum type,
ShShaderSpec spec, ShShaderSpec spec,
ShShaderOutput output) ShShaderOutput output)
...@@ -296,3 +299,5 @@ void TranslatorGLSL::conditionallyOutputInvariantDeclaration(const char *builtin ...@@ -296,3 +299,5 @@ void TranslatorGLSL::conditionallyOutputInvariantDeclaration(const char *builtin
sink << "invariant " << builtinVaryingName << ";\n"; sink << "invariant " << builtinVaryingName << ";\n";
} }
} }
} // namespace sh
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
namespace sh
{
class TranslatorGLSL : public TCompiler class TranslatorGLSL : public TCompiler
{ {
public: public:
...@@ -28,4 +31,6 @@ class TranslatorGLSL : public TCompiler ...@@ -28,4 +31,6 @@ class TranslatorGLSL : public TCompiler
void conditionallyOutputInvariantDeclaration(const char *builtinVaryingName); void conditionallyOutputInvariantDeclaration(const char *builtinVaryingName);
}; };
} // namespace sh
#endif // COMPILER_TRANSLATOR_TRANSLATORGLSL_H_ #endif // COMPILER_TRANSLATOR_TRANSLATORGLSL_H_
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "compiler/translator/SplitSequenceOperator.h" #include "compiler/translator/SplitSequenceOperator.h"
#include "compiler/translator/UnfoldShortCircuitToIf.h" #include "compiler/translator/UnfoldShortCircuitToIf.h"
namespace sh
{
TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
: TCompiler(type, spec, output) : TCompiler(type, spec, output)
{ {
...@@ -141,3 +144,5 @@ const std::map<std::string, unsigned int> *TranslatorHLSL::getUniformRegisterMap ...@@ -141,3 +144,5 @@ const std::map<std::string, unsigned int> *TranslatorHLSL::getUniformRegisterMap
{ {
return &mUniformRegisterMap; return &mUniformRegisterMap;
} }
} // namespace sh
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
namespace sh
{
class TranslatorHLSL : public TCompiler class TranslatorHLSL : public TCompiler
{ {
public: public:
...@@ -31,4 +34,6 @@ class TranslatorHLSL : public TCompiler ...@@ -31,4 +34,6 @@ class TranslatorHLSL : public TCompiler
std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mUniformRegisterMap;
}; };
} // namespace sh
#endif // COMPILER_TRANSLATOR_TRANSLATORHLSL_H_ #endif // COMPILER_TRANSLATOR_TRANSLATORHLSL_H_
...@@ -599,7 +599,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[], ...@@ -599,7 +599,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
if (context->getFragmentPrecisionHigh()) if (context->getFragmentPrecisionHigh())
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); preprocessor->setMaxTokenSize(sh::GetGlobalMaxTokenSize(context->getShaderSpec()));
return 0; return 0;
} }
......
...@@ -3260,7 +3260,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[], ...@@ -3260,7 +3260,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
if (context->getFragmentPrecisionHigh()) if (context->getFragmentPrecisionHigh())
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); preprocessor->setMaxTokenSize(sh::GetGlobalMaxTokenSize(context->getShaderSpec()));
return 0; return 0;
} }
......
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
// These constants are factored out from the rest of the headers to // These constants are factored out from the rest of the headers to
// make it easier to reference them from the compiler sources. // make it easier to reference them from the compiler sources.
namespace sh
{
size_t GetGlobalMaxTokenSize(ShShaderSpec spec); size_t GetGlobalMaxTokenSize(ShShaderSpec spec);
} // namespace sh
#endif // COMPILER_TRANSLATOR_LENGTHLIMITS_H_ #endif // COMPILER_TRANSLATOR_LENGTHLIMITS_H_
...@@ -19,8 +19,8 @@ namespace gl ...@@ -19,8 +19,8 @@ namespace gl
namespace namespace
{ {
// Global count of active shader compiler handles. Needed to know when to call ShInitialize and // Global count of active shader compiler handles. Needed to know when to call sh::Initialize and
// ShFinalize. // sh::Finalize.
size_t activeCompilerHandles = 0; size_t activeCompilerHandles = 0;
ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion, bool isWebGL) ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion, bool isWebGL)
...@@ -57,7 +57,7 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) ...@@ -57,7 +57,7 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
const gl::Caps &caps = state.getCaps(); const gl::Caps &caps = state.getCaps();
const gl::Extensions &extensions = state.getExtensions(); const gl::Extensions &extensions = state.getExtensions();
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
mResources.MaxVertexAttribs = caps.maxVertexAttributes; mResources.MaxVertexAttribs = caps.maxVertexAttributes;
mResources.MaxVertexUniformVectors = caps.maxVertexUniformVectors; mResources.MaxVertexUniformVectors = caps.maxVertexUniformVectors;
mResources.MaxVaryingVectors = caps.maxVaryingVectors; mResources.MaxVaryingVectors = caps.maxVaryingVectors;
...@@ -122,7 +122,7 @@ Error Compiler::release() ...@@ -122,7 +122,7 @@ Error Compiler::release()
{ {
if (mFragmentCompiler) if (mFragmentCompiler)
{ {
ShDestruct(mFragmentCompiler); sh::Destruct(mFragmentCompiler);
mFragmentCompiler = nullptr; mFragmentCompiler = nullptr;
ASSERT(activeCompilerHandles > 0); ASSERT(activeCompilerHandles > 0);
...@@ -131,7 +131,7 @@ Error Compiler::release() ...@@ -131,7 +131,7 @@ Error Compiler::release()
if (mVertexCompiler) if (mVertexCompiler)
{ {
ShDestruct(mVertexCompiler); sh::Destruct(mVertexCompiler);
mVertexCompiler = nullptr; mVertexCompiler = nullptr;
ASSERT(activeCompilerHandles > 0); ASSERT(activeCompilerHandles > 0);
...@@ -140,7 +140,7 @@ Error Compiler::release() ...@@ -140,7 +140,7 @@ Error Compiler::release()
if (mComputeCompiler) if (mComputeCompiler)
{ {
ShDestruct(mComputeCompiler); sh::Destruct(mComputeCompiler);
mComputeCompiler = nullptr; mComputeCompiler = nullptr;
ASSERT(activeCompilerHandles > 0); ASSERT(activeCompilerHandles > 0);
...@@ -149,7 +149,7 @@ Error Compiler::release() ...@@ -149,7 +149,7 @@ Error Compiler::release()
if (activeCompilerHandles == 0) if (activeCompilerHandles == 0)
{ {
ShFinalize(); sh::Finalize();
} }
mImplementation->release(); mImplementation->release();
...@@ -181,10 +181,10 @@ ShHandle Compiler::getCompilerHandle(GLenum type) ...@@ -181,10 +181,10 @@ ShHandle Compiler::getCompilerHandle(GLenum type)
{ {
if (activeCompilerHandles == 0) if (activeCompilerHandles == 0)
{ {
ShInitialize(); sh::Initialize();
} }
*compiler = ShConstructCompiler(type, mSpec, mOutputType, &mResources); *compiler = sh::ConstructCompiler(type, mSpec, mOutputType, &mResources);
activeCompilerHandles++; activeCompilerHandles++;
} }
......
...@@ -266,17 +266,17 @@ void Shader::compile(Compiler *compiler) ...@@ -266,17 +266,17 @@ void Shader::compile(Compiler *compiler)
sourceCStrings.push_back(sourceString.c_str()); sourceCStrings.push_back(sourceString.c_str());
bool result = bool result =
ShCompile(compilerHandle, &sourceCStrings[0], sourceCStrings.size(), compileOptions); sh::Compile(compilerHandle, &sourceCStrings[0], sourceCStrings.size(), compileOptions);
if (!result) if (!result)
{ {
mInfoLog = ShGetInfoLog(compilerHandle); mInfoLog = sh::GetInfoLog(compilerHandle);
TRACE("\n%s", mInfoLog.c_str()); TRACE("\n%s", mInfoLog.c_str());
mCompiled = false; mCompiled = false;
return; return;
} }
mState.mTranslatedSource = ShGetObjectCode(compilerHandle); mState.mTranslatedSource = sh::GetObjectCode(compilerHandle);
#ifndef NDEBUG #ifndef NDEBUG
// Prefix translated shader with commented out un-translated shader. // Prefix translated shader with commented out un-translated shader.
...@@ -301,22 +301,22 @@ void Shader::compile(Compiler *compiler) ...@@ -301,22 +301,22 @@ void Shader::compile(Compiler *compiler)
#endif #endif
// Gather the shader information // Gather the shader information
mState.mShaderVersion = ShGetShaderVersion(compilerHandle); mState.mShaderVersion = sh::GetShaderVersion(compilerHandle);
mState.mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle)); mState.mVaryings = GetShaderVariables(sh::GetVaryings(compilerHandle));
mState.mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle)); mState.mUniforms = GetShaderVariables(sh::GetUniforms(compilerHandle));
mState.mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle)); mState.mInterfaceBlocks = GetShaderVariables(sh::GetInterfaceBlocks(compilerHandle));
switch (mState.mShaderType) switch (mState.mShaderType)
{ {
case GL_COMPUTE_SHADER: case GL_COMPUTE_SHADER:
{ {
mState.mLocalSize = ShGetComputeShaderLocalGroupSize(compilerHandle); mState.mLocalSize = sh::GetComputeShaderLocalGroupSize(compilerHandle);
break; break;
} }
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
{ {
mState.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle)); mState.mActiveAttributes = GetActiveShaderVariables(sh::GetAttributes(compilerHandle));
break; break;
} }
case GL_FRAGMENT_SHADER: case GL_FRAGMENT_SHADER:
...@@ -324,7 +324,7 @@ void Shader::compile(Compiler *compiler) ...@@ -324,7 +324,7 @@ void Shader::compile(Compiler *compiler)
// TODO(jmadill): Figure out why we only sort in the FS, and if we need to. // TODO(jmadill): Figure out why we only sort in the FS, and if we need to.
std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar); std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar);
mState.mActiveOutputVariables = mState.mActiveOutputVariables =
GetActiveShaderVariables(ShGetOutputVariables(compilerHandle)); GetActiveShaderVariables(sh::GetOutputVariables(compilerHandle));
break; break;
} }
default: default:
......
...@@ -21,7 +21,7 @@ class ShaderImpl : angle::NonCopyable ...@@ -21,7 +21,7 @@ class ShaderImpl : angle::NonCopyable
ShaderImpl(const gl::ShaderState &data) : mData(data) {} ShaderImpl(const gl::ShaderState &data) : mData(data) {}
virtual ~ShaderImpl() { } virtual ~ShaderImpl() { }
// Returns additional ShCompile options. // Returns additional sh::Compile options.
virtual ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, virtual ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) = 0; std::string *sourcePath) = 0;
// Returns success for compiling on the driver. Returns success. // Returns success for compiling on the driver. Returns success.
......
...@@ -201,7 +201,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo ...@@ -201,7 +201,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
ShHandle compilerHandle = compiler->getCompilerHandle(mData.getShaderType()); ShHandle compilerHandle = compiler->getCompilerHandle(mData.getShaderType());
mUniformRegisterMap = GetUniformRegisterMap(ShGetUniformRegisterMap(compilerHandle)); mUniformRegisterMap = GetUniformRegisterMap(sh::GetUniformRegisterMap(compilerHandle));
for (const sh::InterfaceBlock &interfaceBlock : mData.getInterfaceBlocks()) for (const sh::InterfaceBlock &interfaceBlock : mData.getInterfaceBlocks())
{ {
...@@ -209,7 +209,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo ...@@ -209,7 +209,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
{ {
unsigned int index = static_cast<unsigned int>(-1); unsigned int index = static_cast<unsigned int>(-1);
bool blockRegisterResult = bool blockRegisterResult =
ShGetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index); sh::GetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index);
ASSERT(blockRegisterResult); ASSERT(blockRegisterResult);
mInterfaceBlockRegisterMap[interfaceBlock.name] = index; mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
......
...@@ -21,7 +21,7 @@ class ShaderNULL : public ShaderImpl ...@@ -21,7 +21,7 @@ class ShaderNULL : public ShaderImpl
ShaderNULL(const gl::ShaderState &data); ShaderNULL(const gl::ShaderState &data);
~ShaderNULL() override; ~ShaderNULL() override;
// Returns additional ShCompile options. // Returns additional sh::Compile options.
ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override; std::string *sourcePath) override;
// Returns success for compiling on the driver. Returns success. // Returns success for compiling on the driver. Returns success.
......
...@@ -21,7 +21,7 @@ class ShaderVk : public ShaderImpl ...@@ -21,7 +21,7 @@ class ShaderVk : public ShaderImpl
ShaderVk(const gl::ShaderState &data); ShaderVk(const gl::ShaderState &data);
~ShaderVk() override; ~ShaderVk() override;
// Returns additional ShCompile options. // Returns additional sh::Compile options.
ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override; std::string *sourcePath) override;
// Returns success for compiling on the driver. Returns success. // Returns success for compiling on the driver. Returns success.
......
...@@ -10,17 +10,17 @@ ...@@ -10,17 +10,17 @@
class CompilerTestEnvironment : public testing::Environment class CompilerTestEnvironment : public testing::Environment
{ {
public: public:
virtual void SetUp() void SetUp() override
{ {
if (!ShInitialize()) if (!sh::Initialize())
{ {
FAIL() << "Failed to initialize the compiler."; FAIL() << "Failed to initialize the compiler.";
} }
} }
virtual void TearDown() void TearDown() override
{ {
if (!ShFinalize()) if (!sh::Finalize())
{ {
FAIL() << "Failed to finalize the compiler."; FAIL() << "Failed to finalize the compiler.";
} }
......
...@@ -15,11 +15,11 @@ TEST(APITest, CompareShBuiltInResources) ...@@ -15,11 +15,11 @@ TEST(APITest, CompareShBuiltInResources)
{ {
ShBuiltInResources a_resources; ShBuiltInResources a_resources;
memset(&a_resources, 88, sizeof(a_resources)); memset(&a_resources, 88, sizeof(a_resources));
ShInitBuiltInResources(&a_resources); sh::InitBuiltInResources(&a_resources);
ShBuiltInResources b_resources; ShBuiltInResources b_resources;
memset(&b_resources, 77, sizeof(b_resources)); memset(&b_resources, 77, sizeof(b_resources));
ShInitBuiltInResources(&b_resources); sh::InitBuiltInResources(&b_resources);
EXPECT_TRUE(memcmp(&a_resources, &b_resources, sizeof(a_resources)) == 0); EXPECT_TRUE(memcmp(&a_resources, &b_resources, sizeof(a_resources)) == 0);
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "compiler/translator/PoolAlloc.h" #include "compiler/translator/PoolAlloc.h"
#include "compiler/translator/TranslatorESSL.h" #include "compiler/translator/TranslatorESSL.h"
using namespace sh;
template <typename T> template <typename T>
class ConstantFinder : public TIntermTraverser class ConstantFinder : public TIntermTraverser
{ {
...@@ -107,7 +109,7 @@ class ConstantFoldingTest : public testing::Test ...@@ -107,7 +109,7 @@ class ConstantFoldingTest : public testing::Test
allocator.push(); allocator.push();
SetGlobalPoolAllocator(&allocator); SetGlobalPoolAllocator(&allocator);
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); InitBuiltInResources(&resources);
mTranslatorESSL = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC); mTranslatorESSL = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC);
ASSERT_TRUE(mTranslatorESSL->Init(resources)); ASSERT_TRUE(mTranslatorESSL->Init(resources));
......
...@@ -1037,7 +1037,7 @@ TEST(DebugShaderPrecisionNegativeTest, HLSL3Unsupported) ...@@ -1037,7 +1037,7 @@ TEST(DebugShaderPrecisionNegativeTest, HLSL3Unsupported)
std::string infoLog; std::string infoLog;
std::string translatedCode; std::string translatedCode;
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
resources.WEBGL_debug_shader_precision = 1; resources.WEBGL_debug_shader_precision = 1;
ASSERT_FALSE(compileTestShader(GL_FRAGMENT_SHADER, SH_GLES3_SPEC, SH_HLSL_3_0_OUTPUT, ASSERT_FALSE(compileTestShader(GL_FRAGMENT_SHADER, SH_GLES3_SPEC, SH_HLSL_3_0_OUTPUT,
shaderString, &resources, 0, &translatedCode, &infoLog)); shaderString, &resources, 0, &translatedCode, &infoLog));
......
...@@ -124,7 +124,7 @@ class EXTBlendFuncExtendedTest ...@@ -124,7 +124,7 @@ class EXTBlendFuncExtendedTest
protected: protected:
virtual void SetUp() virtual void SetUp()
{ {
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
// EXT_draw_buffers is used in some of the shaders for test purposes. // EXT_draw_buffers is used in some of the shaders for test purposes.
mResources.EXT_draw_buffers = 1; mResources.EXT_draw_buffers = 1;
mResources.NV_draw_buffers = 2; mResources.NV_draw_buffers = 2;
...@@ -137,7 +137,7 @@ class EXTBlendFuncExtendedTest ...@@ -137,7 +137,7 @@ class EXTBlendFuncExtendedTest
{ {
if (mCompiler) if (mCompiler)
{ {
ShDestruct(mCompiler); sh::Destruct(mCompiler);
mCompiler = NULL; mCompiler = NULL;
} }
} }
...@@ -145,8 +145,8 @@ class EXTBlendFuncExtendedTest ...@@ -145,8 +145,8 @@ class EXTBlendFuncExtendedTest
void InitializeCompiler() void InitializeCompiler()
{ {
DestroyCompiler(); DestroyCompiler();
mCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, testing::get<0>(GetParam()), mCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, testing::get<0>(GetParam()),
SH_GLSL_COMPATIBILITY_OUTPUT, &mResources); SH_GLSL_COMPATIBILITY_OUTPUT, &mResources);
ASSERT_TRUE(mCompiler != NULL) << "Compiler could not be constructed."; ASSERT_TRUE(mCompiler != NULL) << "Compiler could not be constructed.";
} }
...@@ -163,12 +163,12 @@ class EXTBlendFuncExtendedTest ...@@ -163,12 +163,12 @@ class EXTBlendFuncExtendedTest
const char *shader) const char *shader)
{ {
const char *shaderStrings[] = {version, pragma, shader}; const char *shaderStrings[] = {version, pragma, shader};
bool success = ShCompile(mCompiler, shaderStrings, 3, 0); bool success = sh::Compile(mCompiler, shaderStrings, 3, 0);
if (success) if (success)
{ {
return ::testing::AssertionSuccess() << "Compilation success"; return ::testing::AssertionSuccess() << "Compilation success";
} }
return ::testing::AssertionFailure() << ShGetInfoLog(mCompiler); return ::testing::AssertionFailure() << sh::GetInfoLog(mCompiler);
} }
protected: protected:
......
...@@ -32,7 +32,7 @@ protected: ...@@ -32,7 +32,7 @@ protected:
// Set up the per compile resources // Set up the per compile resources
static void GenerateResources(ShBuiltInResources *res) static void GenerateResources(ShBuiltInResources *res)
{ {
ShInitBuiltInResources(res); sh::InitBuiltInResources(res);
res->MaxVertexAttribs = 8; res->MaxVertexAttribs = 8;
res->MaxVertexUniformVectors = 128; res->MaxVertexUniformVectors = 128;
...@@ -179,14 +179,14 @@ protected: ...@@ -179,14 +179,14 @@ protected:
ShCompileOptions compileOptions, ShCompileOptions compileOptions,
const char *expected_error) const char *expected_error)
{ {
bool success = ShCompile(compiler, &source, 1, compileOptions) != 0; bool success = sh::Compile(compiler, &source, 1, compileOptions) != 0;
if (success) if (success)
{ {
success = !expected_error; success = !expected_error;
} }
else else
{ {
std::string log = ShGetInfoLog(compiler); std::string log = sh::GetInfoLog(compiler);
if (expected_error) if (expected_error)
success = log.find(expected_error) != std::string::npos; success = log.find(expected_error) != std::string::npos;
...@@ -211,8 +211,7 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity) ...@@ -211,8 +211,7 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test expression under the limit passes. // Test expression under the limit passes.
...@@ -233,15 +232,14 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity) ...@@ -233,15 +232,14 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity)
GenerateShaderWithLongExpression( GenerateShaderWithLongExpression(
kMaxExpressionComplexity + 10).c_str(), kMaxExpressionComplexity + 10).c_str(),
compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, NULL)); compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, NULL));
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
} }
TEST_F(ExpressionLimitTest, UnusedExpressionComplexity) TEST_F(ExpressionLimitTest, UnusedExpressionComplexity)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test expression under the limit passes. // Test expression under the limit passes.
...@@ -262,15 +260,14 @@ TEST_F(ExpressionLimitTest, UnusedExpressionComplexity) ...@@ -262,15 +260,14 @@ TEST_F(ExpressionLimitTest, UnusedExpressionComplexity)
GenerateShaderWithUnusedLongExpression( GenerateShaderWithUnusedLongExpression(
kMaxExpressionComplexity + 10).c_str(), kMaxExpressionComplexity + 10).c_str(),
compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, NULL)); compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, NULL));
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
} }
TEST_F(ExpressionLimitTest, CallStackDepth) TEST_F(ExpressionLimitTest, CallStackDepth)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = SH_LIMIT_CALL_STACK_DEPTH; ShCompileOptions compileOptions = SH_LIMIT_CALL_STACK_DEPTH;
// Test call stack under the limit passes. // Test call stack under the limit passes.
...@@ -291,15 +288,14 @@ TEST_F(ExpressionLimitTest, CallStackDepth) ...@@ -291,15 +288,14 @@ TEST_F(ExpressionLimitTest, CallStackDepth)
GenerateShaderWithDeepFunctionStack( GenerateShaderWithDeepFunctionStack(
kMaxCallStackDepth + 10).c_str(), kMaxCallStackDepth + 10).c_str(),
compileOptions & ~SH_LIMIT_CALL_STACK_DEPTH, NULL)); compileOptions & ~SH_LIMIT_CALL_STACK_DEPTH, NULL));
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
} }
TEST_F(ExpressionLimitTest, UnusedCallStackDepth) TEST_F(ExpressionLimitTest, UnusedCallStackDepth)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = SH_LIMIT_CALL_STACK_DEPTH; ShCompileOptions compileOptions = SH_LIMIT_CALL_STACK_DEPTH;
// Test call stack under the limit passes. // Test call stack under the limit passes.
...@@ -320,15 +316,14 @@ TEST_F(ExpressionLimitTest, UnusedCallStackDepth) ...@@ -320,15 +316,14 @@ TEST_F(ExpressionLimitTest, UnusedCallStackDepth)
GenerateShaderWithUnusedDeepFunctionStack( GenerateShaderWithUnusedDeepFunctionStack(
kMaxCallStackDepth + 10).c_str(), kMaxCallStackDepth + 10).c_str(),
compileOptions & ~SH_LIMIT_CALL_STACK_DEPTH, NULL)); compileOptions & ~SH_LIMIT_CALL_STACK_DEPTH, NULL));
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
} }
TEST_F(ExpressionLimitTest, Recursion) TEST_F(ExpressionLimitTest, Recursion)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = 0; ShCompileOptions compileOptions = 0;
static const char* shaderWithRecursion0 = SHADER( static const char* shaderWithRecursion0 = SHADER(
...@@ -536,14 +531,14 @@ TEST_F(ExpressionLimitTest, Recursion) ...@@ -536,14 +531,14 @@ TEST_F(ExpressionLimitTest, Recursion)
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
vertexCompiler, shaderWithNoRecursion, vertexCompiler, shaderWithNoRecursion,
compileOptions | SH_LIMIT_CALL_STACK_DEPTH, NULL)); compileOptions | SH_LIMIT_CALL_STACK_DEPTH, NULL));
ShDestruct(vertexCompiler); sh::Destruct(vertexCompiler);
} }
TEST_F(ExpressionLimitTest, FunctionParameterCount) TEST_F(ExpressionLimitTest, FunctionParameterCount)
{ {
ShShaderSpec spec = SH_WEBGL_SPEC; ShShaderSpec spec = SH_WEBGL_SPEC;
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle compiler = ShConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources); ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test parameters under the limit succeeds. // Test parameters under the limit succeeds.
...@@ -558,5 +553,5 @@ TEST_F(ExpressionLimitTest, FunctionParameterCount) ...@@ -558,5 +553,5 @@ TEST_F(ExpressionLimitTest, FunctionParameterCount)
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
compiler, GenerateShaderWithFunctionParameters(kMaxFunctionParameters + 1).c_str(), compiler, GenerateShaderWithFunctionParameters(kMaxFunctionParameters + 1).c_str(),
compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, nullptr)); compileOptions & ~SH_LIMIT_EXPRESSION_COMPLEXITY, nullptr));
ShDestruct(compiler); sh::Destruct(compiler);
} }
...@@ -23,7 +23,7 @@ class FragDepthTest : public testing::TestWithParam<bool> ...@@ -23,7 +23,7 @@ class FragDepthTest : public testing::TestWithParam<bool>
protected: protected:
void SetUp() override void SetUp() override
{ {
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
mCompiler = nullptr; mCompiler = nullptr;
mResources.EXT_frag_depth = GetParam(); mResources.EXT_frag_depth = GetParam();
} }
...@@ -33,7 +33,7 @@ class FragDepthTest : public testing::TestWithParam<bool> ...@@ -33,7 +33,7 @@ class FragDepthTest : public testing::TestWithParam<bool>
{ {
if (mCompiler) if (mCompiler)
{ {
ShDestruct(mCompiler); sh::Destruct(mCompiler);
mCompiler = nullptr; mCompiler = nullptr;
} }
} }
...@@ -41,8 +41,8 @@ class FragDepthTest : public testing::TestWithParam<bool> ...@@ -41,8 +41,8 @@ class FragDepthTest : public testing::TestWithParam<bool>
void InitializeCompiler() void InitializeCompiler()
{ {
DestroyCompiler(); DestroyCompiler();
mCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, SH_GLES3_SPEC, mCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_GLES3_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &mResources); SH_GLSL_COMPATIBILITY_OUTPUT, &mResources);
ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed."; ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed.";
} }
...@@ -51,12 +51,12 @@ class FragDepthTest : public testing::TestWithParam<bool> ...@@ -51,12 +51,12 @@ class FragDepthTest : public testing::TestWithParam<bool>
const char *shader) const char *shader)
{ {
const char *shaderStrings[] = {version, pragma, shader}; const char *shaderStrings[] = {version, pragma, shader};
bool success = ShCompile(mCompiler, shaderStrings, 3, 0); bool success = sh::Compile(mCompiler, shaderStrings, 3, 0);
if (success) if (success)
{ {
return ::testing::AssertionSuccess() << "Compilation success"; return ::testing::AssertionSuccess() << "Compilation success";
} }
return ::testing::AssertionFailure() << ShGetInfoLog(mCompiler); return ::testing::AssertionFailure() << sh::GetInfoLog(mCompiler);
} }
protected: protected:
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "compiler/translator/TranslatorESSL.h" #include "compiler/translator/TranslatorESSL.h"
using namespace sh;
class MalformedShaderTest : public testing::Test class MalformedShaderTest : public testing::Test
{ {
public: public:
...@@ -21,7 +23,7 @@ class MalformedShaderTest : public testing::Test ...@@ -21,7 +23,7 @@ class MalformedShaderTest : public testing::Test
virtual void SetUp() virtual void SetUp()
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC); mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
...@@ -63,7 +65,7 @@ class MalformedVertexShaderTest : public MalformedShaderTest ...@@ -63,7 +65,7 @@ class MalformedVertexShaderTest : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_SPEC); mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
...@@ -79,7 +81,7 @@ class MalformedWebGL2ShaderTest : public MalformedShaderTest ...@@ -79,7 +81,7 @@ class MalformedWebGL2ShaderTest : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_WEBGL2_SPEC); mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_WEBGL2_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
...@@ -95,7 +97,7 @@ class MalformedWebGL1ShaderTest : public MalformedShaderTest ...@@ -95,7 +97,7 @@ class MalformedWebGL1ShaderTest : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC); mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
...@@ -111,7 +113,7 @@ class MalformedVertexShaderGLES31Test : public MalformedShaderTest ...@@ -111,7 +113,7 @@ class MalformedVertexShaderGLES31Test : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_1_SPEC); mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
} }
...@@ -126,7 +128,7 @@ class MalformedFragmentShaderGLES31Test : public MalformedShaderTest ...@@ -126,7 +128,7 @@ class MalformedFragmentShaderGLES31Test : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_1_SPEC); mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
} }
...@@ -141,7 +143,7 @@ class MalformedComputeShaderTest : public MalformedShaderTest ...@@ -141,7 +143,7 @@ class MalformedComputeShaderTest : public MalformedShaderTest
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC); mTranslator = new TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "tests/test_utils/compiler_test.h" #include "tests/test_utils/compiler_test.h"
using namespace sh;
class QualificationVertexShaderTestESSL31 : public testing::Test class QualificationVertexShaderTestESSL31 : public testing::Test
{ {
public: public:
...@@ -22,7 +24,7 @@ class QualificationVertexShaderTestESSL31 : public testing::Test ...@@ -22,7 +24,7 @@ class QualificationVertexShaderTestESSL31 : public testing::Test
virtual void SetUp() virtual void SetUp()
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_1_SPEC); mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "compiler/translator/TranslatorESSL.h" #include "compiler/translator/TranslatorESSL.h"
using namespace sh;
class QualificationOrderShaderTest : public testing::Test class QualificationOrderShaderTest : public testing::Test
{ {
public: public:
...@@ -23,10 +25,10 @@ class QualificationOrderShaderTest : public testing::Test ...@@ -23,10 +25,10 @@ class QualificationOrderShaderTest : public testing::Test
virtual void TearDown() {} virtual void TearDown() {}
// Return true when compilation succeeds // Return true when compilation succeeds
bool compile(const std::string &shaderString, GLenum shaderType, ShShaderSpec spec) bool compile(const std::string &shaderString, ::GLenum shaderType, ShShaderSpec spec)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); InitBuiltInResources(&resources);
resources.MaxDrawBuffers = (spec == SH_GLES2_SPEC) ? 1 : 8; resources.MaxDrawBuffers = (spec == SH_GLES2_SPEC) ? 1 : 8;
TranslatorESSL *translator = new TranslatorESSL(shaderType, spec); TranslatorESSL *translator = new TranslatorESSL(shaderType, spec);
......
...@@ -24,8 +24,9 @@ class RemovePowTest : public testing::Test ...@@ -24,8 +24,9 @@ class RemovePowTest : public testing::Test
allocator.push(); allocator.push();
SetGlobalPoolAllocator(&allocator); SetGlobalPoolAllocator(&allocator);
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslatorGLSL = new TranslatorGLSL(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_GLSL_COMPATIBILITY_OUTPUT); mTranslatorGLSL =
new sh::TranslatorGLSL(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_GLSL_COMPATIBILITY_OUTPUT);
ASSERT_TRUE(mTranslatorGLSL->Init(resources)); ASSERT_TRUE(mTranslatorGLSL->Init(resources));
} }
...@@ -55,7 +56,7 @@ class RemovePowTest : public testing::Test ...@@ -55,7 +56,7 @@ class RemovePowTest : public testing::Test
} }
private: private:
TranslatorGLSL *mTranslatorGLSL; sh::TranslatorGLSL *mTranslatorGLSL;
TIntermNode *mASTRoot; TIntermNode *mASTRoot;
TPoolAllocator allocator; TPoolAllocator allocator;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// ShCompile_test.cpp // ShCompile_test.cpp
// Test the ShCompile interface with different parameters. // Test the sh::Compile interface with different parameters.
// //
#include "angle_gl.h" #include "angle_gl.h"
...@@ -19,9 +19,9 @@ class ShCompileTest : public testing::Test ...@@ -19,9 +19,9 @@ class ShCompileTest : public testing::Test
protected: protected:
void SetUp() override void SetUp() override
{ {
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
mCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC, mCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &mResources); SH_GLSL_COMPATIBILITY_OUTPUT, &mResources);
ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed."; ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed.";
} }
...@@ -29,15 +29,15 @@ class ShCompileTest : public testing::Test ...@@ -29,15 +29,15 @@ class ShCompileTest : public testing::Test
{ {
if (mCompiler) if (mCompiler)
{ {
ShDestruct(mCompiler); sh::Destruct(mCompiler);
mCompiler = nullptr; mCompiler = nullptr;
} }
} }
void testCompile(const char **shaderStrings, int stringCount, bool expectation) void testCompile(const char **shaderStrings, int stringCount, bool expectation)
{ {
bool success = ShCompile(mCompiler, shaderStrings, stringCount, 0); bool success = sh::Compile(mCompiler, shaderStrings, stringCount, 0);
const std::string &compileLog = ShGetInfoLog(mCompiler); const std::string &compileLog = sh::GetInfoLog(mCompiler);
EXPECT_EQ(expectation, success) << compileLog; EXPECT_EQ(expectation, success) << compileLog;
} }
...@@ -46,7 +46,7 @@ class ShCompileTest : public testing::Test ...@@ -46,7 +46,7 @@ class ShCompileTest : public testing::Test
ShHandle mCompiler; ShHandle mCompiler;
}; };
// Test calling ShCompile with more than one shader source string. // Test calling sh::Compile with more than one shader source string.
TEST_F(ShCompileTest, MultipleShaderStrings) TEST_F(ShCompileTest, MultipleShaderStrings)
{ {
const std::string &shaderString1 = const std::string &shaderString1 =
...@@ -61,7 +61,7 @@ TEST_F(ShCompileTest, MultipleShaderStrings) ...@@ -61,7 +61,7 @@ TEST_F(ShCompileTest, MultipleShaderStrings)
testCompile(shaderStrings, 2, true); testCompile(shaderStrings, 2, true);
} }
// Test calling ShCompile with a tokens split into different shader source strings. // Test calling sh::Compile with a tokens split into different shader source strings.
TEST_F(ShCompileTest, TokensSplitInShaderStrings) TEST_F(ShCompileTest, TokensSplitInShaderStrings)
{ {
const std::string &shaderString1 = const std::string &shaderString1 =
......
...@@ -52,7 +52,7 @@ class ShaderExtensionTest : public testing::Test ...@@ -52,7 +52,7 @@ class ShaderExtensionTest : public testing::Test
protected: protected:
virtual void SetUp() virtual void SetUp()
{ {
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
mCompiler = NULL; mCompiler = NULL;
} }
...@@ -65,7 +65,7 @@ class ShaderExtensionTest : public testing::Test ...@@ -65,7 +65,7 @@ class ShaderExtensionTest : public testing::Test
{ {
if (mCompiler) if (mCompiler)
{ {
ShDestruct(mCompiler); sh::Destruct(mCompiler);
mCompiler = NULL; mCompiler = NULL;
} }
} }
...@@ -73,15 +73,15 @@ class ShaderExtensionTest : public testing::Test ...@@ -73,15 +73,15 @@ class ShaderExtensionTest : public testing::Test
void InitializeCompiler() void InitializeCompiler()
{ {
DestroyCompiler(); DestroyCompiler();
mCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC, mCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &mResources); SH_GLSL_COMPATIBILITY_OUTPUT, &mResources);
ASSERT_TRUE(mCompiler != NULL) << "Compiler could not be constructed."; ASSERT_TRUE(mCompiler != NULL) << "Compiler could not be constructed.";
} }
void TestShaderExtension(const char **shaderStrings, int stringCount, bool expectation) void TestShaderExtension(const char **shaderStrings, int stringCount, bool expectation)
{ {
bool success = ShCompile(mCompiler, shaderStrings, stringCount, 0); bool success = sh::Compile(mCompiler, shaderStrings, stringCount, 0);
const std::string& compileLog = ShGetInfoLog(mCompiler); const std::string &compileLog = sh::GetInfoLog(mCompiler);
EXPECT_EQ(expectation, success) << compileLog; EXPECT_EQ(expectation, success) << compileLog;
} }
......
...@@ -112,9 +112,9 @@ class ShaderImageTest : public testing::Test ...@@ -112,9 +112,9 @@ class ShaderImageTest : public testing::Test
virtual void SetUp() virtual void SetUp()
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC); mTranslator = new sh::TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
} }
...@@ -134,7 +134,7 @@ class ShaderImageTest : public testing::Test ...@@ -134,7 +134,7 @@ class ShaderImageTest : public testing::Test
protected: protected:
std::string mTranslatedCode; std::string mTranslatedCode;
std::string mInfoLog; std::string mInfoLog;
TranslatorESSL *mTranslator; sh::TranslatorESSL *mTranslator;
TIntermNode *mASTRoot; TIntermNode *mASTRoot;
}; };
......
...@@ -229,10 +229,10 @@ TEST(ShaderVariableTest, IsSameVaryingWithDifferentInvariance) ...@@ -229,10 +229,10 @@ TEST(ShaderVariableTest, IsSameVaryingWithDifferentInvariance)
TEST(ShaderVariableTest, InvariantDoubleDeleteBug) TEST(ShaderVariableTest, InvariantDoubleDeleteBug)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, ShHandle compiler = sh::ConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program[] = const char *program[] =
...@@ -246,18 +246,18 @@ TEST(ShaderVariableTest, InvariantDoubleDeleteBug) ...@@ -246,18 +246,18 @@ TEST(ShaderVariableTest, InvariantDoubleDeleteBug)
"}" "}"
}; };
EXPECT_TRUE(ShCompile(compiler, program, 1, SH_OBJECT_CODE)); EXPECT_TRUE(sh::Compile(compiler, program, 1, SH_OBJECT_CODE));
EXPECT_TRUE(ShCompile(compiler, program, 1, SH_OBJECT_CODE)); EXPECT_TRUE(sh::Compile(compiler, program, 1, SH_OBJECT_CODE));
ShDestruct(compiler); sh::Destruct(compiler);
} }
TEST(ShaderVariableTest, IllegalInvariantVarying) TEST(ShaderVariableTest, IllegalInvariantVarying)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, ShHandle compiler = sh::ConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program1[] = const char *program1[] =
...@@ -284,17 +284,17 @@ TEST(ShaderVariableTest, IllegalInvariantVarying) ...@@ -284,17 +284,17 @@ TEST(ShaderVariableTest, IllegalInvariantVarying)
"}" "}"
}; };
EXPECT_TRUE(ShCompile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
EXPECT_FALSE(ShCompile(compiler, program2, 1, SH_VARIABLES)); EXPECT_FALSE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
} }
TEST(ShaderVariableTest, InvariantLeakAcrossShaders) TEST(ShaderVariableTest, InvariantLeakAcrossShaders)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, ShHandle compiler = sh::ConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program1[] = const char *program1[] =
...@@ -313,15 +313,15 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders) ...@@ -313,15 +313,15 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders)
"}" "}"
}; };
EXPECT_TRUE(ShCompile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(ShCompile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = ShGetVaryings(compiler); varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
...@@ -332,10 +332,10 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders) ...@@ -332,10 +332,10 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders)
TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders) TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, ShHandle compiler = sh::ConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program1[] = const char *program1[] =
...@@ -354,15 +354,15 @@ TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders) ...@@ -354,15 +354,15 @@ TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders)
"}" "}"
}; };
EXPECT_TRUE(ShCompile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(ShCompile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = ShGetVaryings(compiler); varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
...@@ -374,10 +374,10 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying) ...@@ -374,10 +374,10 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, ShHandle compiler = sh::ConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program1[] = const char *program1[] =
...@@ -401,21 +401,21 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying) ...@@ -401,21 +401,21 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying)
"}" "}"
}; };
EXPECT_TRUE(ShCompile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "gl_Position") if (varying.name == "gl_Position")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(ShCompile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = ShGetVaryings(compiler); varyings = sh::GetVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "gl_Position") if (varying.name == "gl_Position")
EXPECT_FALSE(varying.isInvariant); EXPECT_FALSE(varying.isInvariant);
} }
EXPECT_FALSE(ShCompile(compiler, program3, 1, SH_VARIABLES)); EXPECT_FALSE(sh::Compile(compiler, program3, 1, SH_VARIABLES));
} }
} // namespace sh } // namespace sh
...@@ -13,26 +13,25 @@ ...@@ -13,26 +13,25 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "compiler/translator/TranslatorESSL.h" #include "compiler/translator/TranslatorESSL.h"
using namespace sh;
class TypeTrackingTest : public testing::Test class TypeTrackingTest : public testing::Test
{ {
public: public:
TypeTrackingTest() {} TypeTrackingTest() {}
protected: protected:
virtual void SetUp() void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); InitBuiltInResources(&resources);
resources.FragmentPrecisionHigh = 1; resources.FragmentPrecisionHigh = 1;
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC); mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_GLES3_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
} }
virtual void TearDown() void TearDown() override { delete mTranslator; }
{
delete mTranslator;
}
void compile(const std::string& shaderString) void compile(const std::string& shaderString)
{ {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "compiler/translator/TranslatorESSL.h" #include "compiler/translator/TranslatorESSL.h"
#include "tests/test_utils/compiler_test.h" #include "tests/test_utils/compiler_test.h"
using namespace sh;
class WorkGroupSizeTest : public testing::Test class WorkGroupSizeTest : public testing::Test
{ {
public: public:
...@@ -22,7 +24,7 @@ class WorkGroupSizeTest : public testing::Test ...@@ -22,7 +24,7 @@ class WorkGroupSizeTest : public testing::Test
void SetUp() override void SetUp() override
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC); mTranslator = new TranslatorESSL(GL_COMPUTE_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources)); ASSERT_TRUE(mTranslator->Init(resources));
...@@ -56,7 +58,7 @@ TEST_F(WorkGroupSizeTest, OnlyLocalSizeXSpecified) ...@@ -56,7 +58,7 @@ TEST_F(WorkGroupSizeTest, OnlyLocalSizeXSpecified)
compile(shaderString); compile(shaderString);
const sh::WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize(); const WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize();
ASSERT_EQ(5, localSize[0]); ASSERT_EQ(5, localSize[0]);
ASSERT_EQ(1, localSize[1]); ASSERT_EQ(1, localSize[1]);
ASSERT_EQ(1, localSize[2]); ASSERT_EQ(1, localSize[2]);
...@@ -73,7 +75,7 @@ TEST_F(WorkGroupSizeTest, LocalSizeXandZ) ...@@ -73,7 +75,7 @@ TEST_F(WorkGroupSizeTest, LocalSizeXandZ)
compile(shaderString); compile(shaderString);
const sh::WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize(); const WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize();
ASSERT_EQ(5, localSize[0]); ASSERT_EQ(5, localSize[0]);
ASSERT_EQ(1, localSize[1]); ASSERT_EQ(1, localSize[1]);
ASSERT_EQ(10, localSize[2]); ASSERT_EQ(10, localSize[2]);
...@@ -90,7 +92,7 @@ TEST_F(WorkGroupSizeTest, LocalSizeAll) ...@@ -90,7 +92,7 @@ TEST_F(WorkGroupSizeTest, LocalSizeAll)
compile(shaderString); compile(shaderString);
const sh::WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize(); const WorkGroupSize &localSize = mTranslator->getComputeShaderLocalSize();
ASSERT_EQ(5, localSize[0]); ASSERT_EQ(5, localSize[0]);
ASSERT_EQ(15, localSize[1]); ASSERT_EQ(15, localSize[1]);
ASSERT_EQ(10, localSize[2]); ASSERT_EQ(10, localSize[2]);
......
...@@ -80,7 +80,7 @@ bool compileTestShader(GLenum type, ...@@ -80,7 +80,7 @@ bool compileTestShader(GLenum type,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog) std::string *infoLog)
{ {
TCompiler *translator = ConstructCompiler(type, spec, output); sh::TCompiler *translator = sh::ConstructCompiler(type, spec, output);
if (!translator->Init(*resources)) if (!translator->Init(*resources))
{ {
SafeDelete(translator); SafeDelete(translator);
...@@ -108,7 +108,7 @@ bool compileTestShader(GLenum type, ...@@ -108,7 +108,7 @@ bool compileTestShader(GLenum type,
std::string *infoLog) std::string *infoLog)
{ {
ShBuiltInResources resources; ShBuiltInResources resources;
ShInitBuiltInResources(&resources); sh::InitBuiltInResources(&resources);
return compileTestShader(type, spec, output, shaderString, &resources, compileOptions, translatedCode, infoLog); return compileTestShader(type, spec, output, shaderString, &resources, compileOptions, translatedCode, infoLog);
} }
...@@ -117,7 +117,7 @@ MatchOutputCodeTest::MatchOutputCodeTest(GLenum shaderType, ...@@ -117,7 +117,7 @@ MatchOutputCodeTest::MatchOutputCodeTest(GLenum shaderType,
ShShaderOutput outputType) ShShaderOutput outputType)
: mShaderType(shaderType), mDefaultCompileOptions(defaultCompileOptions) : mShaderType(shaderType), mDefaultCompileOptions(defaultCompileOptions)
{ {
ShInitBuiltInResources(&mResources); sh::InitBuiltInResources(&mResources);
mOutputCode[outputType] = std::string(); mOutputCode[outputType] = std::string();
} }
......
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