Commit 7ebb97fc by Qiankun Miao Committed by Commit Bot

Use 64-bits compile options

BUG=chromium:645071 Change-Id: I31825123bf4cb45fb37a93f538e8936487beb5ff Reviewed-on: https://chromium-review.googlesource.com/382712 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 47cb73ab
...@@ -28,7 +28,7 @@ enum TFailCode ...@@ -28,7 +28,7 @@ enum TFailCode
static void usage(); static void usage();
static sh::GLenum FindShaderType(const char *fileName); static sh::GLenum FindShaderType(const char *fileName);
static bool CompileFile(char *fileName, ShHandle compiler, int compileOptions); static bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOptions);
static void LogMsg(const char *msg, const char *name, const int num, const char *logName); static void LogMsg(const char *msg, const char *name, const int num, const char *logName);
static void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVariable &var); static void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVariable &var);
static void PrintActiveVariables(ShHandle compiler); static void PrintActiveVariables(ShHandle compiler);
...@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) ...@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
{ {
TFailCode failCode = ESuccess; TFailCode failCode = ESuccess;
int compileOptions = 0; ShCompileOptions compileOptions = 0;
int numCompiles = 0; int numCompiles = 0;
ShHandle vertexCompiler = 0; ShHandle vertexCompiler = 0;
ShHandle fragmentCompiler = 0; ShHandle fragmentCompiler = 0;
...@@ -378,7 +378,7 @@ sh::GLenum FindShaderType(const char *fileName) ...@@ -378,7 +378,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 ShCompile
// //
bool CompileFile(char *fileName, ShHandle compiler, int compileOptions) bool CompileFile(char *fileName, ShHandle compiler, ShCompileOptions compileOptions)
{ {
ShaderSource source; ShaderSource source;
if (!ReadShaderSource(fileName, source)) if (!ReadShaderSource(fileName, source))
......
...@@ -154,7 +154,7 @@ TCompiler::~TCompiler() ...@@ -154,7 +154,7 @@ TCompiler::~TCompiler()
{ {
} }
bool TCompiler::shouldRunLoopAndIndexingValidation(int compileOptions) const bool TCompiler::shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const
{ {
// If compiling an ESSL 1.00 shader for WebGL, or if its been requested through the API, // If compiling an ESSL 1.00 shader for WebGL, or if its been requested through the API,
// validate loop and indexing as well (to verify that the shader only uses minimal functionality // validate loop and indexing as well (to verify that the shader only uses minimal functionality
...@@ -189,15 +189,16 @@ bool TCompiler::Init(const ShBuiltInResources& resources) ...@@ -189,15 +189,16 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
return true; return true;
} }
TIntermNode *TCompiler::compileTreeForTesting(const char* const shaderStrings[], TIntermNode *TCompiler::compileTreeForTesting(const char *const shaderStrings[],
size_t numStrings, int compileOptions) size_t numStrings,
ShCompileOptions compileOptions)
{ {
return compileTreeImpl(shaderStrings, numStrings, compileOptions); return compileTreeImpl(shaderStrings, numStrings, compileOptions);
} }
TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[], TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
size_t numStrings, size_t numStrings,
const int compileOptions) const ShCompileOptions compileOptions)
{ {
clearResults(); clearResults();
...@@ -393,12 +394,14 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -393,12 +394,14 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
return NULL; return NULL;
} }
bool TCompiler::compile(const char *const shaderStrings[], size_t numStrings, int compileOptionsIn) bool TCompiler::compile(const char *const shaderStrings[],
size_t numStrings,
ShCompileOptions compileOptionsIn)
{ {
if (numStrings == 0) if (numStrings == 0)
return true; return true;
int compileOptions = compileOptionsIn; ShCompileOptions compileOptions = compileOptionsIn;
// Apply key workarounds. // Apply key workarounds.
if (shouldFlattenPragmaStdglInvariantAll()) if (shouldFlattenPragmaStdglInvariantAll())
...@@ -852,7 +855,7 @@ const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const ...@@ -852,7 +855,7 @@ const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const
return builtInFunctionEmulator; return builtInFunctionEmulator;
} }
void TCompiler::writePragma(int compileOptions) void TCompiler::writePragma(ShCompileOptions compileOptions)
{ {
if (!(compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL)) if (!(compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL))
{ {
......
...@@ -73,11 +73,13 @@ class TCompiler : public TShHandleBase ...@@ -73,11 +73,13 @@ class TCompiler : public TShHandleBase
// compileTreeForTesting should be used only when tests require access to // compileTreeForTesting should be used only when tests require access to
// the AST. Users of this function need to manually manage the global pool // the AST. Users of this function need to manually manage the global pool
// allocator. Returns NULL whenever there are compilation errors. // allocator. Returns NULL whenever there are compilation errors.
TIntermNode *compileTreeForTesting(const char* const shaderStrings[], TIntermNode *compileTreeForTesting(const char *const shaderStrings[],
size_t numStrings, int compileOptions); size_t numStrings,
ShCompileOptions compileOptions);
bool compile(const char* const shaderStrings[], bool compile(const char *const shaderStrings[],
size_t numStrings, int compileOptions); size_t numStrings,
ShCompileOptions compileOptions);
// Get results of the last compilation. // Get results of the last compilation.
int getShaderVersion() const { return shaderVersion; } int getShaderVersion() const { return shaderVersion; }
...@@ -102,7 +104,7 @@ class TCompiler : public TShHandleBase ...@@ -102,7 +104,7 @@ class TCompiler : public TShHandleBase
ShShaderOutput getOutputType() const { return outputType; } ShShaderOutput getOutputType() const { return outputType; }
const std::string &getBuiltInResourcesString() const { return builtInResourcesString; } const std::string &getBuiltInResourcesString() const { return builtInResourcesString; }
bool shouldRunLoopAndIndexingValidation(int compileOptions) const; bool shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const;
// Get the resources set by InitBuiltInSymbolTable // Get the resources set by InitBuiltInSymbolTable
const ShBuiltInResources& getResources() const; const ShBuiltInResources& getResources() const;
...@@ -123,9 +125,10 @@ class TCompiler : public TShHandleBase ...@@ -123,9 +125,10 @@ class TCompiler : public TShHandleBase
// Collect info for all attribs, uniforms, varyings. // Collect info for all attribs, uniforms, varyings.
void collectVariables(TIntermNode* root); void collectVariables(TIntermNode* root);
// Add emulated functions to the built-in function emulator. // Add emulated functions to the built-in function emulator.
virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) {}; virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions){};
// Translate to object code. // Translate to object code.
virtual void translate(TIntermNode *root, int compileOptions) = 0; virtual void translate(TIntermNode *root, ShCompileOptions compileOptions) = 0;
// Returns true if, after applying the packing rules in the GLSL 1.017 spec // Returns true if, after applying the packing rules in the GLSL 1.017 spec
// Appendix A, section 7, the shader does not use too many uniforms. // Appendix A, section 7, the shader does not use too many uniforms.
bool enforcePackingRestrictions(); bool enforcePackingRestrictions();
...@@ -143,7 +146,7 @@ class TCompiler : public TShHandleBase ...@@ -143,7 +146,7 @@ class TCompiler : public TShHandleBase
const TExtensionBehavior& getExtensionBehavior() const; const TExtensionBehavior& getExtensionBehavior() const;
const char *getSourcePath() const; const char *getSourcePath() const;
const TPragma& getPragma() const { return mPragma; } const TPragma& getPragma() const { return mPragma; }
void writePragma(int compileOptions); void writePragma(ShCompileOptions compileOptions);
unsigned int *getTemporaryIndex() { return &mTemporaryIndex; } unsigned int *getTemporaryIndex() { return &mTemporaryIndex; }
// Relies on collectVariables having been called. // Relies on collectVariables having been called.
bool isVaryingDefined(const char *varyingName); bool isVaryingDefined(const char *varyingName);
...@@ -152,7 +155,7 @@ class TCompiler : public TShHandleBase ...@@ -152,7 +155,7 @@ class TCompiler : public TShHandleBase
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const; ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const; const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
virtual bool shouldCollectVariables(int compileOptions) virtual bool shouldCollectVariables(ShCompileOptions compileOptions)
{ {
return (compileOptions & SH_VARIABLES) != 0; return (compileOptions & SH_VARIABLES) != 0;
} }
...@@ -182,7 +185,7 @@ class TCompiler : public TShHandleBase ...@@ -182,7 +185,7 @@ class TCompiler : public TShHandleBase
TIntermNode *compileTreeImpl(const char *const shaderStrings[], TIntermNode *compileTreeImpl(const char *const shaderStrings[],
size_t numStrings, size_t numStrings,
const int compileOptions); const ShCompileOptions compileOptions);
sh::GLenum shaderType; sh::GLenum shaderType;
ShShaderSpec shaderSpec; ShShaderSpec shaderSpec;
......
...@@ -80,11 +80,14 @@ const TConstantUnion *WriteConstantUnionArray(TInfoSinkBase &out, ...@@ -80,11 +80,14 @@ const TConstantUnion *WriteConstantUnionArray(TInfoSinkBase &out,
namespace sh namespace sh
{ {
OutputHLSL::OutputHLSL(sh::GLenum shaderType, int shaderVersion, OutputHLSL::OutputHLSL(sh::GLenum shaderType,
const TExtensionBehavior &extensionBehavior, int shaderVersion,
const char *sourcePath, ShShaderOutput outputType, const TExtensionBehavior &extensionBehavior,
int numRenderTargets, const std::vector<Uniform> &uniforms, const char *sourcePath,
int compileOptions) ShShaderOutput outputType,
int numRenderTargets,
const std::vector<Uniform> &uniforms,
ShCompileOptions compileOptions)
: TIntermTraverser(true, true, true), : TIntermTraverser(true, true, true),
mShaderType(shaderType), mShaderType(shaderType),
mShaderVersion(shaderVersion), mShaderVersion(shaderVersion),
......
...@@ -30,11 +30,14 @@ typedef std::map<TString, TIntermSymbol*> ReferencedSymbols; ...@@ -30,11 +30,14 @@ typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
class OutputHLSL : public TIntermTraverser class OutputHLSL : public TIntermTraverser
{ {
public: public:
OutputHLSL(sh::GLenum shaderType, int shaderVersion, OutputHLSL(sh::GLenum shaderType,
const TExtensionBehavior &extensionBehavior, int shaderVersion,
const char *sourcePath, ShShaderOutput outputType, const TExtensionBehavior &extensionBehavior,
int numRenderTargets, const std::vector<Uniform> &uniforms, const char *sourcePath,
int compileOptions); ShShaderOutput outputType,
int numRenderTargets,
const std::vector<Uniform> &uniforms,
ShCompileOptions compileOptions);
~OutputHLSL(); ~OutputHLSL();
...@@ -118,7 +121,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -118,7 +121,7 @@ class OutputHLSL : public TIntermTraverser
const TExtensionBehavior &mExtensionBehavior; const TExtensionBehavior &mExtensionBehavior;
const char *mSourcePath; const char *mSourcePath;
const ShShaderOutput mOutputType; const ShShaderOutput mOutputType;
int mCompileOptions; ShCompileOptions mCompileOptions;
bool mInsideFunction; bool mInsideFunction;
......
...@@ -33,7 +33,7 @@ class TParseContext : angle::NonCopyable ...@@ -33,7 +33,7 @@ class TParseContext : angle::NonCopyable
TExtensionBehavior &ext, TExtensionBehavior &ext,
sh::GLenum type, sh::GLenum type,
ShShaderSpec spec, ShShaderSpec spec,
int options, ShCompileOptions options,
bool checksPrecErrors, bool checksPrecErrors,
TInfoSink &is, TInfoSink &is,
const ShBuiltInResources &resources) const ShBuiltInResources &resources)
...@@ -407,16 +407,18 @@ class TParseContext : angle::NonCopyable ...@@ -407,16 +407,18 @@ class TParseContext : angle::NonCopyable
bool mDeferredSingleDeclarationErrorCheck; bool mDeferredSingleDeclarationErrorCheck;
sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack) sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
int mCompileOptions; // Options passed to TCompiler ShCompileOptions mCompileOptions; // Options passed to TCompiler
int mShaderVersion; int mShaderVersion;
TIntermNode *mTreeRoot; // root of parse tree being created TIntermNode *mTreeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops int mLoopNestingLevel; // 0 if outside all loops
int mStructNestingLevel; // incremented while parsing a struct declaration int mStructNestingLevel; // incremented while parsing a struct declaration
int mSwitchNestingLevel; // 0 if outside all switch statements int mSwitchNestingLevel; // 0 if outside all switch statements
const TType *mCurrentFunctionType; // the return type of the function that's currently being parsed const TType
*mCurrentFunctionType; // the return type of the function that's currently being parsed
bool mFunctionReturnsValue; // true if a non-void function has a return bool mFunctionReturnsValue; // true if a non-void function has a return
bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit. bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared
// without precision, explicit or implicit.
bool mFragmentPrecisionHighOnESSL1; // true if highp precision is supported when compiling bool mFragmentPrecisionHighOnESSL1; // true if highp precision is supported when compiling
// ESSL1. // ESSL1.
TLayoutMatrixPacking mDefaultMatrixPacking; TLayoutMatrixPacking mDefaultMatrixPacking;
......
...@@ -268,11 +268,10 @@ const std::string &ShGetBuiltInResourcesString(const ShHandle handle) ...@@ -268,11 +268,10 @@ const std::string &ShGetBuiltInResourcesString(const ShHandle handle)
// Return: The return value of ShCompile is really boolean, indicating // Return: The return value of ShCompile is really boolean, indicating
// success or failure. // success or failure.
// //
bool ShCompile( bool ShCompile(const ShHandle handle,
const ShHandle handle, const char *const shaderStrings[],
const char *const shaderStrings[], size_t numStrings,
size_t numStrings, ShCompileOptions compileOptions)
int compileOptions)
{ {
TCompiler *compiler = GetCompilerFromHandle(handle); TCompiler *compiler = GetCompilerFromHandle(handle);
ASSERT(compiler); ASSERT(compiler);
......
...@@ -16,7 +16,7 @@ TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec) ...@@ -16,7 +16,7 @@ TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec)
{ {
} }
void TranslatorESSL::translate(TIntermNode *root, int compileOptions) void TranslatorESSL::translate(TIntermNode *root, ShCompileOptions compileOptions)
{ {
TInfoSinkBase& sink = getInfoSink().obj; TInfoSinkBase& sink = getInfoSink().obj;
......
...@@ -15,7 +15,7 @@ class TranslatorESSL : public TCompiler ...@@ -15,7 +15,7 @@ class TranslatorESSL : public TCompiler
TranslatorESSL(sh::GLenum type, ShShaderSpec spec); TranslatorESSL(sh::GLenum type, ShShaderSpec spec);
protected: protected:
void translate(TIntermNode *root, int compileOptions) override; void translate(TIntermNode *root, ShCompileOptions compileOptions) override;
bool shouldFlattenPragmaStdglInvariantAll() override; bool shouldFlattenPragmaStdglInvariantAll() override;
private: private:
......
...@@ -20,7 +20,8 @@ TranslatorGLSL::TranslatorGLSL(sh::GLenum type, ...@@ -20,7 +20,8 @@ TranslatorGLSL::TranslatorGLSL(sh::GLenum type,
: TCompiler(type, spec, output) { : TCompiler(type, spec, output) {
} }
void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions)
{ {
if (compileOptions & SH_EMULATE_ABS_INT_FUNCTION) if (compileOptions & SH_EMULATE_ABS_INT_FUNCTION)
{ {
...@@ -31,7 +32,7 @@ void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, i ...@@ -31,7 +32,7 @@ void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, i
InitBuiltInFunctionEmulatorForGLSLMissingFunctions(emu, getShaderType(), targetGLSLVersion); InitBuiltInFunctionEmulatorForGLSLMissingFunctions(emu, getShaderType(), targetGLSLVersion);
} }
void TranslatorGLSL::translate(TIntermNode *root, int compileOptions) void TranslatorGLSL::translate(TIntermNode *root, ShCompileOptions compileOptions)
{ {
TInfoSinkBase& sink = getInfoSink().obj; TInfoSinkBase& sink = getInfoSink().obj;
......
...@@ -15,9 +15,10 @@ class TranslatorGLSL : public TCompiler ...@@ -15,9 +15,10 @@ class TranslatorGLSL : public TCompiler
TranslatorGLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); TranslatorGLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
protected: protected:
void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) override; void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions) override;
void translate(TIntermNode *root, int compileOptions) override; void translate(TIntermNode *root, ShCompileOptions compileOptions) override;
bool shouldFlattenPragmaStdglInvariantAll() override; bool shouldFlattenPragmaStdglInvariantAll() override;
private: private:
......
...@@ -28,7 +28,7 @@ TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutpu ...@@ -28,7 +28,7 @@ TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutpu
{ {
} }
void TranslatorHLSL::translate(TIntermNode *root, int compileOptions) void TranslatorHLSL::translate(TIntermNode *root, ShCompileOptions compileOptions)
{ {
const ShBuiltInResources &resources = getResources(); const ShBuiltInResources &resources = getResources();
int numRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1; int numRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
......
...@@ -21,11 +21,11 @@ class TranslatorHLSL : public TCompiler ...@@ -21,11 +21,11 @@ class TranslatorHLSL : public TCompiler
const std::map<std::string, unsigned int> *getUniformRegisterMap() const; const std::map<std::string, unsigned int> *getUniformRegisterMap() const;
protected: protected:
void translate(TIntermNode *root, int compileOptions) override; void translate(TIntermNode *root, ShCompileOptions compileOptions) override;
bool shouldFlattenPragmaStdglInvariantAll() override; bool shouldFlattenPragmaStdglInvariantAll() override;
// collectVariables needs to be run always so registers can be assigned. // collectVariables needs to be run always so registers can be assigned.
bool shouldCollectVariables(int compileOptions) override { return true; } bool shouldCollectVariables(ShCompileOptions compileOptions) override { return true; }
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap; std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mUniformRegisterMap;
......
...@@ -243,9 +243,9 @@ void Shader::compile(Compiler *compiler) ...@@ -243,9 +243,9 @@ void Shader::compile(Compiler *compiler)
std::stringstream sourceStream; std::stringstream sourceStream;
std::string sourcePath; std::string sourcePath;
int additionalOptions = ShCompileOptions additionalOptions =
mImplementation->prepareSourceAndReturnOptions(&sourceStream, &sourcePath); mImplementation->prepareSourceAndReturnOptions(&sourceStream, &sourcePath);
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions); ShCompileOptions compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions);
// Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes // Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes
// in fragment shaders. Shader compilation will fail. To provide a better error message we can // in fragment shaders. Shader compilation will fail. To provide a better error message we can
......
...@@ -22,8 +22,8 @@ class ShaderImpl : angle::NonCopyable ...@@ -22,8 +22,8 @@ class ShaderImpl : angle::NonCopyable
virtual ~ShaderImpl() { } virtual ~ShaderImpl() { }
// Returns additional ShCompile options. // Returns additional ShCompile options.
virtual int 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.
virtual bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) = 0; virtual bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) = 0;
......
...@@ -133,12 +133,12 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const ...@@ -133,12 +133,12 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const
return mCompilerOutputType; return mCompilerOutputType;
} }
int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream, ShCompileOptions ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream,
std::string *sourcePath) std::string *sourcePath)
{ {
uncompile(); uncompile();
int additionalOptions = 0; ShCompileOptions additionalOptions = 0;
const std::string &source = mData.getSource(); const std::string &source = mData.getSource();
......
...@@ -28,8 +28,8 @@ class ShaderD3D : public ShaderImpl ...@@ -28,8 +28,8 @@ class ShaderD3D : public ShaderImpl
virtual ~ShaderD3D(); virtual ~ShaderD3D();
// ShaderImpl implementation // ShaderImpl implementation
int prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override; std::string *sourcePath) override;
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override; std::string getDebugInfo() const override;
...@@ -77,7 +77,7 @@ class ShaderD3D : public ShaderImpl ...@@ -77,7 +77,7 @@ class ShaderD3D : public ShaderImpl
mutable std::string mDebugInfo; mutable std::string mDebugInfo;
std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap; std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
int mAdditionalOptions; ShCompileOptions mAdditionalOptions;
}; };
} // namespace rx } // namespace rx
......
...@@ -36,8 +36,8 @@ ShaderGL::~ShaderGL() ...@@ -36,8 +36,8 @@ ShaderGL::~ShaderGL()
} }
} }
int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string * /*sourcePath*/) std::string * /*sourcePath*/)
{ {
// Reset the previous state // Reset the previous state
if (mShaderID != 0) if (mShaderID != 0)
...@@ -48,7 +48,7 @@ int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream, ...@@ -48,7 +48,7 @@ int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
*sourceStream << mData.getSource(); *sourceStream << mData.getSource();
int options = SH_INIT_GL_POSITION; ShCompileOptions options = SH_INIT_GL_POSITION;
if (mWorkarounds.doWhileGLSLCausesGPUHang) if (mWorkarounds.doWhileGLSLCausesGPUHang)
{ {
......
...@@ -25,8 +25,8 @@ class ShaderGL : public ShaderImpl ...@@ -25,8 +25,8 @@ class ShaderGL : public ShaderImpl
~ShaderGL() override; ~ShaderGL() override;
// ShaderImpl implementation // ShaderImpl implementation
int prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override; std::string *sourcePath) override;
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override; std::string getDebugInfo() const override;
......
...@@ -22,8 +22,8 @@ ShaderVk::~ShaderVk() ...@@ -22,8 +22,8 @@ ShaderVk::~ShaderVk()
{ {
} }
int ShaderVk::prepareSourceAndReturnOptions(std::stringstream *sourceStream, ShCompileOptions ShaderVk::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) std::string *sourcePath)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return int(); return int();
......
...@@ -22,8 +22,8 @@ class ShaderVk : public ShaderImpl ...@@ -22,8 +22,8 @@ class ShaderVk : public ShaderImpl
~ShaderVk() override; ~ShaderVk() override;
// Returns additional ShCompile options. // Returns additional ShCompile options.
int 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.
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
......
...@@ -176,7 +176,7 @@ protected: ...@@ -176,7 +176,7 @@ protected:
// to the issue we are testing. // to the issue we are testing.
bool CheckShaderCompilation(ShHandle compiler, bool CheckShaderCompilation(ShHandle compiler,
const char *source, const char *source,
int compileOptions, ShCompileOptions compileOptions,
const char *expected_error) const char *expected_error)
{ {
bool success = ShCompile(compiler, &source, 1, compileOptions) != 0; bool success = ShCompile(compiler, &source, 1, compileOptions) != 0;
...@@ -213,7 +213,7 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity) ...@@ -213,7 +213,7 @@ TEST_F(ExpressionLimitTest, ExpressionComplexity)
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = ShConstructCompiler(
GL_FRAGMENT_SHADER, spec, output, &resources); GL_FRAGMENT_SHADER, spec, output, &resources);
int compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test expression under the limit passes. // Test expression under the limit passes.
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
...@@ -242,7 +242,7 @@ TEST_F(ExpressionLimitTest, UnusedExpressionComplexity) ...@@ -242,7 +242,7 @@ TEST_F(ExpressionLimitTest, UnusedExpressionComplexity)
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = ShConstructCompiler(
GL_FRAGMENT_SHADER, spec, output, &resources); GL_FRAGMENT_SHADER, spec, output, &resources);
int compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test expression under the limit passes. // Test expression under the limit passes.
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
...@@ -271,7 +271,7 @@ TEST_F(ExpressionLimitTest, CallStackDepth) ...@@ -271,7 +271,7 @@ TEST_F(ExpressionLimitTest, CallStackDepth)
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = ShConstructCompiler(
GL_FRAGMENT_SHADER, spec, output, &resources); GL_FRAGMENT_SHADER, spec, output, &resources);
int 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.
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
...@@ -300,7 +300,7 @@ TEST_F(ExpressionLimitTest, UnusedCallStackDepth) ...@@ -300,7 +300,7 @@ TEST_F(ExpressionLimitTest, UnusedCallStackDepth)
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = ShConstructCompiler(
GL_FRAGMENT_SHADER, spec, output, &resources); GL_FRAGMENT_SHADER, spec, output, &resources);
int 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.
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
...@@ -329,7 +329,7 @@ TEST_F(ExpressionLimitTest, Recursion) ...@@ -329,7 +329,7 @@ TEST_F(ExpressionLimitTest, Recursion)
ShShaderOutput output = SH_ESSL_OUTPUT; ShShaderOutput output = SH_ESSL_OUTPUT;
ShHandle vertexCompiler = ShConstructCompiler( ShHandle vertexCompiler = ShConstructCompiler(
GL_FRAGMENT_SHADER, spec, output, &resources); GL_FRAGMENT_SHADER, spec, output, &resources);
int compileOptions = 0; ShCompileOptions compileOptions = 0;
static const char* shaderWithRecursion0 = SHADER( static const char* shaderWithRecursion0 = SHADER(
precision mediump float; precision mediump float;
...@@ -544,7 +544,7 @@ TEST_F(ExpressionLimitTest, FunctionParameterCount) ...@@ -544,7 +544,7 @@ 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 = ShConstructCompiler(GL_FRAGMENT_SHADER, spec, output, &resources);
int compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY; ShCompileOptions compileOptions = SH_LIMIT_EXPRESSION_COMPLEXITY;
// Test parameters under the limit succeeds. // Test parameters under the limit succeeds.
EXPECT_TRUE(CheckShaderCompilation( EXPECT_TRUE(CheckShaderCompilation(
......
...@@ -51,7 +51,7 @@ class MalformedShaderTest : public testing::Test ...@@ -51,7 +51,7 @@ class MalformedShaderTest : public testing::Test
protected: protected:
std::string mInfoLog; std::string mInfoLog;
TranslatorESSL *mTranslator; TranslatorESSL *mTranslator;
int mExtraCompileOptions; ShCompileOptions mExtraCompileOptions;
}; };
class MalformedVertexShaderTest : public MalformedShaderTest class MalformedVertexShaderTest : public MalformedShaderTest
......
...@@ -49,7 +49,7 @@ bool compileTestShader(GLenum type, ...@@ -49,7 +49,7 @@ bool compileTestShader(GLenum type,
ShShaderOutput output, ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
ShBuiltInResources *resources, ShBuiltInResources *resources,
int compileOptions, ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog) std::string *infoLog)
{ {
...@@ -76,7 +76,7 @@ bool compileTestShader(GLenum type, ...@@ -76,7 +76,7 @@ bool compileTestShader(GLenum type,
ShShaderSpec spec, ShShaderSpec spec,
ShShaderOutput output, ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
int compileOptions, ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog) std::string *infoLog)
{ {
...@@ -86,7 +86,7 @@ bool compileTestShader(GLenum type, ...@@ -86,7 +86,7 @@ bool compileTestShader(GLenum type,
} }
MatchOutputCodeTest::MatchOutputCodeTest(GLenum shaderType, MatchOutputCodeTest::MatchOutputCodeTest(GLenum shaderType,
int defaultCompileOptions, ShCompileOptions defaultCompileOptions,
ShShaderOutput outputType) ShShaderOutput outputType)
: mShaderType(shaderType), mDefaultCompileOptions(defaultCompileOptions) : mShaderType(shaderType), mDefaultCompileOptions(defaultCompileOptions)
{ {
...@@ -109,7 +109,8 @@ void MatchOutputCodeTest::compile(const std::string &shaderString) ...@@ -109,7 +109,8 @@ void MatchOutputCodeTest::compile(const std::string &shaderString)
compile(shaderString, mDefaultCompileOptions); compile(shaderString, mDefaultCompileOptions);
} }
void MatchOutputCodeTest::compile(const std::string &shaderString, const int compileOptions) void MatchOutputCodeTest::compile(const std::string &shaderString,
const ShCompileOptions compileOptions)
{ {
std::string infoLog; std::string infoLog;
for (auto &code : mOutputCode) for (auto &code : mOutputCode)
...@@ -125,7 +126,7 @@ void MatchOutputCodeTest::compile(const std::string &shaderString, const int com ...@@ -125,7 +126,7 @@ void MatchOutputCodeTest::compile(const std::string &shaderString, const int com
bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output, bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
const int compileOptions, const ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog) std::string *infoLog)
{ {
......
...@@ -22,7 +22,7 @@ bool compileTestShader(GLenum type, ...@@ -22,7 +22,7 @@ bool compileTestShader(GLenum type,
ShShaderOutput output, ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
ShBuiltInResources *resources, ShBuiltInResources *resources,
int compileOptions, ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog); std::string *infoLog);
...@@ -30,14 +30,16 @@ bool compileTestShader(GLenum type, ...@@ -30,14 +30,16 @@ bool compileTestShader(GLenum type,
ShShaderSpec spec, ShShaderSpec spec,
ShShaderOutput output, ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
int compileOptions, ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog); std::string *infoLog);
class MatchOutputCodeTest : public testing::Test class MatchOutputCodeTest : public testing::Test
{ {
protected: protected:
MatchOutputCodeTest(GLenum shaderType, int defaultCompileOptions, ShShaderOutput outputType); MatchOutputCodeTest(GLenum shaderType,
ShCompileOptions defaultCompileOptions,
ShShaderOutput outputType);
void addOutputType(const ShShaderOutput outputType); void addOutputType(const ShShaderOutput outputType);
...@@ -45,7 +47,7 @@ class MatchOutputCodeTest : public testing::Test ...@@ -45,7 +47,7 @@ class MatchOutputCodeTest : public testing::Test
// Compile functions clear any results from earlier calls to them. // Compile functions clear any results from earlier calls to them.
void compile(const std::string &shaderString); void compile(const std::string &shaderString);
void compile(const std::string &shaderString, const int compileOptions); void compile(const std::string &shaderString, const ShCompileOptions compileOptions);
bool foundInESSLCode(const char *stringToFind) const bool foundInESSLCode(const char *stringToFind) const
{ {
...@@ -76,12 +78,12 @@ class MatchOutputCodeTest : public testing::Test ...@@ -76,12 +78,12 @@ class MatchOutputCodeTest : public testing::Test
private: private:
bool compileWithSettings(ShShaderOutput output, bool compileWithSettings(ShShaderOutput output,
const std::string &shaderString, const std::string &shaderString,
int compileOptions, ShCompileOptions compileOptions,
std::string *translatedCode, std::string *translatedCode,
std::string *infoLog); std::string *infoLog);
GLenum mShaderType; GLenum mShaderType;
int mDefaultCompileOptions; ShCompileOptions mDefaultCompileOptions;
ShBuiltInResources mResources; ShBuiltInResources mResources;
std::map<ShShaderOutput, std::string> mOutputCode; std::map<ShShaderOutput, std::string> mOutputCode;
......
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