Commit 29cd91af by alokp@chromium.org

Added an option for specifying language specification in preparation for…

Added an option for specifying language specification in preparation for supporting WebGL in addition to GLES2. This CL just replaces unused debugOptions variable with EShSpec variable. BUG=11 Review URL: http://codereview.appspot.com/1692051 git-svn-id: https://angleproject.googlecode.com/svn/trunk@344 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 01b666f2
...@@ -42,6 +42,15 @@ typedef enum { ...@@ -42,6 +42,15 @@ typedef enum {
} EShLanguage; } EShLanguage;
// //
// The language specification compiler conforms to.
// It currently supports OpenGL ES and WebGL specifications.
//
typedef enum {
EShSpecGLES2,
EShSpecWebGL,
} EShSpec;
//
// Types of output the linker will create. // Types of output the linker will create.
// //
typedef enum { typedef enum {
...@@ -88,7 +97,7 @@ typedef void* ShHandle; ...@@ -88,7 +97,7 @@ typedef void* ShHandle;
// Driver calls these to create and destroy compiler/linker // Driver calls these to create and destroy compiler/linker
// objects. // objects.
// //
ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); // one per shader ShHandle ShConstructCompiler(EShLanguage, EShSpec); // one per shader
ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair
ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object) ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
void ShDestruct(ShHandle); void ShDestruct(ShHandle);
......
...@@ -71,7 +71,7 @@ int C_DECL main(int argc, char* argv[]) ...@@ -71,7 +71,7 @@ int C_DECL main(int argc, char* argv[])
default: usage(); return EFailUsage; default: usage(); return EFailUsage;
} }
} else { } else {
compilers[numCompilers] = ShConstructCompiler(FindLanguage(argv[0]), debugOptions); compilers[numCompilers] = ShConstructCompiler(FindLanguage(argv[0]), EShSpecGLES2);
if (compilers[numCompilers] == 0) if (compilers[numCompilers] == 0)
return EFailCompilerCreate; return EFailCompilerCreate;
++numCompilers; ++numCompilers;
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
// compile object used by higher level code. It returns // compile object used by higher level code. It returns
// a subclass of TCompiler. // a subclass of TCompiler.
// //
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions) TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec)
{ {
return new TranslatorGLSL(language, debugOptions); return new TranslatorGLSL(language, spec);
} }
// //
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
// compile object used by higher level code. It returns // compile object used by higher level code. It returns
// a subclass of TCompiler. // a subclass of TCompiler.
// //
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions) TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec)
{ {
return new TranslatorHLSL(language, debugOptions); return new TranslatorHLSL(language, spec);
} }
// //
......
...@@ -56,7 +56,7 @@ class TIntermNode; ...@@ -56,7 +56,7 @@ class TIntermNode;
// //
class TCompiler : public TShHandleBase { class TCompiler : public TShHandleBase {
public: public:
TCompiler(EShLanguage l) : language(l), haveValidObjectCode(false) { } TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s), haveValidObjectCode(false) { }
virtual ~TCompiler() { } virtual ~TCompiler() { }
EShLanguage getLanguage() { return language; } EShLanguage getLanguage() { return language; }
virtual TInfoSink& getInfoSink() { return infoSink; } virtual TInfoSink& getInfoSink() { return infoSink; }
...@@ -69,6 +69,7 @@ public: ...@@ -69,6 +69,7 @@ public:
TInfoSink infoSink; TInfoSink infoSink;
protected: protected:
EShLanguage language; EShLanguage language;
EShSpec spec;
bool haveValidObjectCode; bool haveValidObjectCode;
}; };
...@@ -125,7 +126,7 @@ protected: ...@@ -125,7 +126,7 @@ protected:
// destroy the machine dependent objects, which contain the // destroy the machine dependent objects, which contain the
// above machine independent information. // above machine independent information.
// //
TCompiler* ConstructCompiler(EShLanguage, int); TCompiler* ConstructCompiler(EShLanguage, EShSpec);
TShHandleBase* ConstructLinker(EShExecutable, int); TShHandleBase* ConstructLinker(EShExecutable, int);
void DeleteLinker(TShHandleBase*); void DeleteLinker(TShHandleBase*);
......
...@@ -82,12 +82,12 @@ int ShInitialize() ...@@ -82,12 +82,12 @@ int ShInitialize()
// objects. // objects.
// //
ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions) ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec)
{ {
if (!InitThread()) if (!InitThread())
return 0; return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions)); TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, spec));
return reinterpret_cast<void*>(base); return reinterpret_cast<void*>(base);
} }
......
...@@ -8,9 +8,8 @@ ...@@ -8,9 +8,8 @@
#include "compiler/OutputGLSL.h" #include "compiler/OutputGLSL.h"
TranslatorGLSL::TranslatorGLSL(EShLanguage l, int dOptions) TranslatorGLSL::TranslatorGLSL(EShLanguage lang, EShSpec spec)
: TCompiler(l), : TCompiler(lang, spec) {
debugOptions(dOptions) {
} }
bool TranslatorGLSL::compile(TIntermNode* root) { bool TranslatorGLSL::compile(TIntermNode* root) {
......
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
class TranslatorGLSL : public TCompiler { class TranslatorGLSL : public TCompiler {
public: public:
TranslatorGLSL(EShLanguage l, int dOptions); TranslatorGLSL(EShLanguage lang, EShSpec spec);
virtual bool compile(TIntermNode* root); virtual bool compile(TIntermNode* root);
int debugOptions;
}; };
#endif // COMPILER_TRANSLATORGLSL_H_ #endif // COMPILER_TRANSLATORGLSL_H_
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "compiler/OutputHLSL.h" #include "compiler/OutputHLSL.h"
TranslatorHLSL::TranslatorHLSL(EShLanguage language, int debugOptions) TranslatorHLSL::TranslatorHLSL(EShLanguage lang, EShSpec spec)
: TCompiler(language), debugOptions(debugOptions) : TCompiler(lang, spec)
{ {
} }
......
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
class TranslatorHLSL : public TCompiler { class TranslatorHLSL : public TCompiler {
public: public:
TranslatorHLSL(EShLanguage l, int dOptions); TranslatorHLSL(EShLanguage lang, EShSpec spec);
virtual bool compile(TIntermNode* root); virtual bool compile(TIntermNode* root);
int debugOptions;
}; };
#endif // COMPILER_TRANSLATORHLSL_H_ #endif // COMPILER_TRANSLATORHLSL_H_
...@@ -34,8 +34,8 @@ Shader::Shader(Context *context, GLuint handle) : mHandle(handle), mContext(cont ...@@ -34,8 +34,8 @@ Shader::Shader(Context *context, GLuint handle) : mHandle(handle), mContext(cont
if (result) if (result)
{ {
mFragmentCompiler = ShConstructCompiler(EShLangFragment, EDebugOpObjectCode); mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2);
mVertexCompiler = ShConstructCompiler(EShLangVertex, EDebugOpObjectCode); mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2);
} }
} }
......
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