summaryrefslogtreecommitdiffstats
path: root/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-16 16:25:10 +0100
committerBen Murdoch <benm@google.com>2011-05-23 18:54:14 +0100
commitab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch)
treedb769fadd053248f85db67434a5b275224defef7 /Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
parent52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff)
downloadexternal_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp')
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
index 7b8d903..7a63ae1 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
@@ -7,14 +7,31 @@
#include "compiler/TranslatorGLSL.h"
#include "compiler/OutputGLSL.h"
+#include "compiler/VersionGLSL.h"
-TranslatorGLSL::TranslatorGLSL(EShLanguage lang, EShSpec spec)
- : TCompiler(lang, spec) {
+static void writeVersion(ShShaderType type, TIntermNode* root,
+ TInfoSinkBase& sink) {
+ TVersionGLSL versionGLSL(type);
+ root->traverse(&versionGLSL);
+ int version = versionGLSL.getVersion();
+ // We need to write version directive only if it is greater than 110.
+ // If there is no version directive in the shader, 110 is implied.
+ if (version > 110) {
+ sink << "#version " << version << "\n";
+ }
}
-bool TranslatorGLSL::compile(TIntermNode* root) {
- TOutputGLSL outputGLSL(infoSink.obj);
- root->traverse(&outputGLSL);
+TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
+ : TCompiler(type, spec) {
+}
+
+void TranslatorGLSL::translate(TIntermNode* root) {
+ TInfoSinkBase& sink = getInfoSink().obj;
- return true;
+ // Write GLSL version.
+ writeVersion(getShaderType(), root, sink);
+
+ // Write translated shader.
+ TOutputGLSL outputGLSL(sink);
+ root->traverse(&outputGLSL);
}