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
This commit is contained in:
parent
5041bcb35d
commit
a7a68a9b32
@ -33,3 +33,11 @@
|
|||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "BilDisassemble.h"
|
#include "BilDisassemble.h"
|
||||||
|
|
||||||
|
namespace glbil {
|
||||||
|
|
||||||
|
void Disassemble(std::ostream& out, const std::vector<unsigned int>&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // end glbil namespace
|
||||||
|
@ -32,5 +32,19 @@
|
|||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef BilDisassembler_H
|
||||||
|
#define BilDisassembler_H
|
||||||
|
|
||||||
#include "Bil.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
|
||||||
|
@ -43,7 +43,11 @@
|
|||||||
|
|
||||||
namespace glslang {
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
namespace glslang {
|
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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "./../glslang/Include/ShHandle.h"
|
#include "./../glslang/Include/ShHandle.h"
|
||||||
#include "./../glslang/Public/ShaderLang.h"
|
#include "./../glslang/Public/ShaderLang.h"
|
||||||
#include "../BIL/GlslangToBil.h"
|
#include "../BIL/GlslangToBil.h"
|
||||||
|
#include "../BIL/BilDisassemble.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -637,8 +638,22 @@ void CompileAndLinkShaders()
|
|||||||
printf("Bil is not generated for failed compile or link\n");
|
printf("Bil is not generated for failed compile or link\n");
|
||||||
else {
|
else {
|
||||||
for (int stage = 0; stage < EShLangCount; ++stage) {
|
for (int stage = 0; stage < EShLangCount; ++stage) {
|
||||||
if (program.getIntermediate((EShLanguage)stage))
|
if (program.getIntermediate((EShLanguage)stage)) {
|
||||||
glslang::GlslangToBil(*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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
Todo.txt
2
Todo.txt
@ -85,7 +85,7 @@ Shader Functionality to Implement/Finish
|
|||||||
+ frexp/ldexp
|
+ frexp/ldexp
|
||||||
+ packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8()
|
+ packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8()
|
||||||
+ 2DMS samplers and images
|
+ 2DMS samplers and images
|
||||||
- inheritance of memory qualifiers in block members
|
+ inheritance of memory qualifiers in block members
|
||||||
GLSL 1.2
|
GLSL 1.2
|
||||||
+ Handle multiple compilation units per stage
|
+ Handle multiple compilation units per stage
|
||||||
+ Allow initializers on uniform declarations
|
+ Allow initializers on uniform declarations
|
||||||
|
@ -373,8 +373,74 @@ protected:
|
|||||||
public:
|
public:
|
||||||
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
|
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
|
||||||
virtual int scan(TPpToken*);
|
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:
|
protected:
|
||||||
TInputScanner* input;
|
TInputScanner* input;
|
||||||
};
|
};
|
||||||
|
@ -669,77 +669,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// 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
|
// The main functional entry-point into the preprocessor, which will
|
||||||
// scan the source strings to figure out and return the next processing token.
|
// scan the source strings to figure out and return the next processing token.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user