Non-functional misc. changes. Slight increase in performance from moving two performance path methods into a header.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27835 e7fa87d3-cd2b-0410-9028-fcbf551c1848
diff --git a/BIL/BilDisassemble.cpp b/BIL/BilDisassemble.cpp
index 6425b86..25bbd00 100644
--- a/BIL/BilDisassemble.cpp
+++ b/BIL/BilDisassemble.cpp
@@ -33,3 +33,11 @@
//POSSIBILITY OF SUCH DAMAGE.
#include "BilDisassemble.h"
+
+namespace glbil {
+
+void Disassemble(std::ostream& out, const std::vector<unsigned int>&)
+{
+}
+
+}; // end glbil namespace
diff --git a/BIL/BilDisassemble.h b/BIL/BilDisassemble.h
index 3400675..eab6eb9 100644
--- a/BIL/BilDisassemble.h
+++ b/BIL/BilDisassemble.h
@@ -32,5 +32,19 @@
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
+#pragma once
+#ifndef BilDisassembler_H
+#define BilDisassembler_H
+
#include "Bil.h"
+#include <iostream>
+#include <vector>
+
+namespace glbil {
+
+ void Disassemble(std::ostream& out, const std::vector<unsigned int>&);
+
+}; // end glbil namespace
+
+#endif // BilDisassembler_H
diff --git a/BIL/GlslangToBil.cpp b/BIL/GlslangToBil.cpp
index bb48a6e..043d9d3 100644
--- a/BIL/GlslangToBil.cpp
+++ b/BIL/GlslangToBil.cpp
@@ -43,7 +43,11 @@
namespace glslang {
-void GlslangToBil(const glslang::TIntermediate& intermediate)
+void GlslangToBil(const glslang::TIntermediate& intermediate, std::vector<unsigned int> bil)
+{
+}
+
+void OutputBil(const std::vector<unsigned int>& bil, const char* baseName)
{
}
diff --git a/BIL/GlslangToBil.h b/BIL/GlslangToBil.h
index b030fe3..025bb08 100644
--- a/BIL/GlslangToBil.h
+++ b/BIL/GlslangToBil.h
@@ -36,6 +36,8 @@
namespace glslang {
-void GlslangToBil(const glslang::TIntermediate& intermediate);
+void GlslangToBil(const glslang::TIntermediate& intermediate, std::vector<unsigned int> bil);
+
+void OutputBil(const std::vector<unsigned int>& bil, const char* baseName);
};
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 06710f5..7f349fc 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -41,6 +41,7 @@
#include "./../glslang/Include/ShHandle.h"
#include "./../glslang/Public/ShaderLang.h"
#include "../BIL/GlslangToBil.h"
+#include "../BIL/BilDisassemble.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>
@@ -637,8 +638,22 @@
printf("Bil is not generated for failed compile or link\n");
else {
for (int stage = 0; stage < EShLangCount; ++stage) {
- if (program.getIntermediate((EShLanguage)stage))
- glslang::GlslangToBil(*program.getIntermediate((EShLanguage)stage));
+ if (program.getIntermediate((EShLanguage)stage)) {
+ std::vector<unsigned int> bil;
+ glslang::GlslangToBil(*program.getIntermediate((EShLanguage)stage), bil);
+ const char* name;
+ switch (stage) {
+ case EShLangVertex: name = "vert"; break;
+ case EShLangTessControl: name = "tesc"; break;
+ case EShLangTessEvaluation: name = "tese"; break;
+ case EShLangGeometry: name = "geom"; break;
+ case EShLangFragment: name = "frag"; break;
+ case EShLangCompute: name = "comp"; break;
+ default: name = "unknown"; break;
+ }
+ glbil::Disassemble(std::cout, bil);
+ glslang::OutputBil(bil, name);
+ }
}
}
}
diff --git a/Todo.txt b/Todo.txt
index 5f8b254..2b49dbc 100644
--- a/Todo.txt
+++ b/Todo.txt
@@ -85,7 +85,7 @@
+ frexp/ldexp
+ packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8()
+ 2DMS samplers and images
- - inheritance of memory qualifiers in block members
+ + inheritance of memory qualifiers in block members
GLSL 1.2
+ Handle multiple compilation units per stage
+ Allow initializers on uniform declarations
diff --git a/glslang/MachineIndependent/preprocessor/PpContext.h b/glslang/MachineIndependent/preprocessor/PpContext.h
index 4823b57..c75febf 100644
--- a/glslang/MachineIndependent/preprocessor/PpContext.h
+++ b/glslang/MachineIndependent/preprocessor/PpContext.h
@@ -373,8 +373,74 @@
public:
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
virtual int scan(TPpToken*);
- virtual int getch();
- virtual void ungetch();
+
+ // Scanner used to get source stream characters.
+ // - Escaped newlines are handled here, invisibly to the caller.
+ // - All forms of newline are handled, and turned into just a '\n'.
+ int tStringInput::getch()
+ {
+ int ch = input->get();
+
+ if (ch == '\\') {
+ // Move past escaped newlines, as many as sequentially exist
+ do {
+ if (input->peek() == '\r' || input->peek() == '\n') {
+ bool allowed = pp->parseContext.lineContinuationCheck(input->getSourceLoc(), pp->inComment);
+ if (! allowed && pp->inComment)
+ return '\\';
+
+ // escape one newline now
+ ch = input->get();
+ int nextch = input->get();
+ if (ch == '\r' && nextch == '\n')
+ ch = input->get();
+ else
+ ch = nextch;
+ } else
+ return '\\';
+ } while (ch == '\\');
+ }
+
+ // handle any non-escaped newline
+ if (ch == '\r' || ch == '\n') {
+ if (ch == '\r' && input->peek() == '\n')
+ ch = input->get();
+ return '\n';
+ }
+
+ return ch;
+ }
+
+ // Scanner used to backup the source stream characters. Newlines are
+ // handled here, invisibly to the caller, meaning have to undo exactly
+ // what getch() above does (e.g., don't leave things in the middle of a
+ // sequence of escaped newlines).
+ void tStringInput::ungetch()
+ {
+ input->unget();
+
+ do {
+ int ch = input->peek();
+ if (ch == '\r' || ch == '\n') {
+ if (ch == '\n') {
+ // correct for two-character newline
+ input->unget();
+ if (input->peek() != '\r')
+ input->get();
+ }
+ // now in front of a complete newline, move past an escape character
+ input->unget();
+ if (input->peek() == '\\')
+ input->unget();
+ else {
+ input->get();
+ break;
+ }
+ } else
+ break;
+ } while (true);
+ }
+
protected:
TInputScanner* input;
};
diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
index 4fa7ad5..afeff0f 100644
--- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp
+++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
@@ -670,77 +670,6 @@
}
//
-// Scanner used to get source stream characters.
-// - Escaped newlines are handled here, invisibly to the caller.
-// - All forms of newline are handled, and turned into just a '\n'.
-//
-int TPpContext::tStringInput::getch()
-{
- int ch = input->get();
-
- if (ch == '\\') {
- // Move past escaped newlines, as many as sequentially exist
- do {
- if (input->peek() == '\r' || input->peek() == '\n') {
- bool allowed = pp->parseContext.lineContinuationCheck(input->getSourceLoc(), pp->inComment);
- if (! allowed && pp->inComment)
- return '\\';
-
- // escape one newline now
- ch = input->get();
- int nextch = input->get();
- if (ch == '\r' && nextch == '\n')
- ch = input->get();
- else
- ch = nextch;
- } else
- return '\\';
- } while (ch == '\\');
- }
-
- // handle any non-escaped newline
- if (ch == '\r' || ch == '\n') {
- if (ch == '\r' && input->peek() == '\n')
- ch = input->get();
- return '\n';
- }
-
- return ch;
-}
-
-//
-// Scanner used to backup the source stream characters. Newlines are
-// handled here, invisibly to the caller, meaning have to undo exactly
-// what getch() above does (e.g., don't leave things in the middle of a
-// sequence of escaped newlines).
-//
-void TPpContext::tStringInput::ungetch()
-{
- input->unget();
-
- do {
- int ch = input->peek();
- if (ch == '\r' || ch == '\n') {
- if (ch == '\n') {
- // correct for two-character newline
- input->unget();
- if (input->peek() != '\r')
- input->get();
- }
- // now in front of a complete newline, move past an escape character
- input->unget();
- if (input->peek() == '\\')
- input->unget();
- else {
- input->get();
- break;
- }
- } else
- break;
- } while (true);
-}
-
-//
// The main functional entry-point into the preprocessor, which will
// scan the source strings to figure out and return the next processing token.
//