Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
94a81fbd
Commit
94a81fbd
authored
Aug 31, 2013
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Option rationalization and minor clean up.
git-svn-id:
https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22907
e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent
8700e9e6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
64 deletions
+72
-64
StandAlone.cpp
StandAlone/StandAlone.cpp
+36
-21
Todo.txt
Todo.txt
+1
-4
intermediate.h
glslang/Include/intermediate.h
+2
-1
Constant.cpp
glslang/MachineIndependent/Constant.cpp
+2
-0
RemoveTree.cpp
glslang/MachineIndependent/RemoveTree.cpp
+20
-4
ShaderLang.cpp
glslang/MachineIndependent/ShaderLang.cpp
+8
-8
ShaderLang.h
glslang/Public/ShaderLang.h
+3
-26
No files found.
StandAlone/StandAlone.cpp
View file @
94a81fbd
...
@@ -46,6 +46,17 @@ extern "C" {
...
@@ -46,6 +46,17 @@ extern "C" {
SH_IMPORT_EXPORT
void
ShOutputHtml
();
SH_IMPORT_EXPORT
void
ShOutputHtml
();
}
}
// Command-line options
enum
TOptions
{
EOptionNone
=
0x000
,
EOptionIntermediate
=
0x001
,
EOptionSuppressInfolog
=
0x002
,
EOptionMemoryLeakMode
=
0x004
,
EOptionRelaxedErrors
=
0x008
,
EOptionGiveWarnings
=
0x010
,
EOptionsLinkProgram
=
0x020
,
};
//
//
// Return codes from main.
// Return codes from main.
//
//
...
@@ -109,7 +120,7 @@ void GenerateResources(TBuiltInResource& resources)
...
@@ -109,7 +120,7 @@ void GenerateResources(TBuiltInResource& resources)
}
}
glslang
::
TWorklist
Worklist
;
glslang
::
TWorklist
Worklist
;
int
Debug
Options
=
0
;
int
Options
=
0
;
bool
Delay
=
false
;
bool
Delay
=
false
;
bool
ProcessArguments
(
int
argc
,
char
*
argv
[])
bool
ProcessArguments
(
int
argc
,
char
*
argv
[])
...
@@ -123,19 +134,19 @@ bool ProcessArguments(int argc, char* argv[])
...
@@ -123,19 +134,19 @@ bool ProcessArguments(int argc, char* argv[])
Delay
=
true
;
Delay
=
true
;
break
;
break
;
case
'i'
:
case
'i'
:
DebugOptions
|=
EDebugOp
Intermediate
;
Options
|=
EOption
Intermediate
;
break
;
break
;
case
'l'
:
case
'l'
:
DebugOptions
|=
EDebugOpMemoryLeakMode
;
Options
|=
EOptionsLinkProgram
;
break
;
case
'm'
:
Options
|=
EOptionMemoryLeakMode
;
break
;
break
;
case
'r'
:
case
'r'
:
DebugOptions
|=
EDebugOp
RelaxedErrors
;
Options
|=
EOption
RelaxedErrors
;
break
;
break
;
case
's'
:
case
's'
:
DebugOptions
|=
EDebugOpSuppressInfolog
;
Options
|=
EOptionSuppressInfolog
;
break
;
case
't'
:
DebugOptions
|=
EDebugOpTexturePrototypes
;
break
;
break
;
default:
default:
return
false
;
return
false
;
...
@@ -155,21 +166,21 @@ unsigned int
...
@@ -155,21 +166,21 @@ unsigned int
#ifdef _WIN32
#ifdef _WIN32
__stdcall
__stdcall
#endif
#endif
CompileShaders
(
void
*
)
CompileShaders
(
void
*
)
{
{
ShHandle
compiler
;
ShHandle
compiler
;
std
::
string
shaderName
;
std
::
string
shaderName
;
while
(
Worklist
.
remove
(
shaderName
))
{
while
(
Worklist
.
remove
(
shaderName
))
{
compiler
=
ShConstructCompiler
(
FindLanguage
(
shaderName
),
Debug
Options
);
compiler
=
ShConstructCompiler
(
FindLanguage
(
shaderName
),
Options
);
if
(
compiler
==
0
)
if
(
compiler
==
0
)
return
false
;
return
false
;
TBuiltInResource
resources
;
TBuiltInResource
resources
;
GenerateResources
(
resources
);
GenerateResources
(
resources
);
CompileFile
(
shaderName
.
c_str
(),
compiler
,
Debug
Options
,
&
resources
);
CompileFile
(
shaderName
.
c_str
(),
compiler
,
Options
,
&
resources
);
if
(
!
(
DebugOptions
&
EDebugOp
SuppressInfolog
))
if
(
!
(
Options
&
EOption
SuppressInfolog
))
puts
(
ShGetInfoLog
(
compiler
));
puts
(
ShGetInfoLog
(
compiler
));
ShDestruct
(
compiler
);
ShDestruct
(
compiler
);
...
@@ -231,6 +242,7 @@ int C_DECL main(int argc, char* argv[])
...
@@ -231,6 +242,7 @@ int C_DECL main(int argc, char* argv[])
// .tese = tessellation evaluation
// .tese = tessellation evaluation
// .geom = geometry
// .geom = geometry
// .frag = fragment
// .frag = fragment
// .comp = compute
//
//
EShLanguage
FindLanguage
(
const
std
::
string
&
name
)
EShLanguage
FindLanguage
(
const
std
::
string
&
name
)
{
{
...
@@ -261,7 +273,7 @@ EShLanguage FindLanguage(const std::string& name)
...
@@ -261,7 +273,7 @@ EShLanguage FindLanguage(const std::string& name)
//
//
// 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
(
const
char
*
fileName
,
ShHandle
compiler
,
int
debug
Options
,
const
TBuiltInResource
*
resources
)
bool
CompileFile
(
const
char
*
fileName
,
ShHandle
compiler
,
int
Options
,
const
TBuiltInResource
*
resources
)
{
{
int
ret
;
int
ret
;
char
**
shaderStrings
=
ReadFileData
(
fileName
);
char
**
shaderStrings
=
ReadFileData
(
fileName
);
...
@@ -280,18 +292,20 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
...
@@ -280,18 +292,20 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
return
false
;
return
false
;
EShMessages
messages
=
EShMsgDefault
;
EShMessages
messages
=
EShMsgDefault
;
if
(
debugOptions
&
EDebugOp
RelaxedErrors
)
if
(
Options
&
EOption
RelaxedErrors
)
messages
=
(
EShMessages
)(
messages
|
EShMsgRelaxedErrors
);
messages
=
(
EShMessages
)(
messages
|
EShMsgRelaxedErrors
);
for
(
int
i
=
0
;
i
<
((
debugOptions
&
EDebugOpMemoryLeakMode
)
?
100
:
1
);
++
i
)
{
if
(
Options
&
EOptionIntermediate
)
for
(
int
j
=
0
;
j
<
((
debugOptions
&
EDebugOpMemoryLeakMode
)
?
100
:
1
);
++
j
)
{
messages
=
(
EShMessages
)(
messages
|
EShMsgAST
);
//ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, resources, debugOptions, 100, false, messages);
for
(
int
i
=
0
;
i
<
((
Options
&
EOptionMemoryLeakMode
)
?
100
:
1
);
++
i
)
{
ret
=
ShCompile
(
compiler
,
shaderStrings
,
NumShaderStrings
,
0
,
EShOptNone
,
resources
,
debugOptions
,
100
,
false
,
messages
);
for
(
int
j
=
0
;
j
<
((
Options
&
EOptionMemoryLeakMode
)
?
100
:
1
);
++
j
)
{
//ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, resources, Options, 100, false, messages);
ret
=
ShCompile
(
compiler
,
shaderStrings
,
NumShaderStrings
,
0
,
EShOptNone
,
resources
,
Options
,
100
,
false
,
messages
);
//const char* multi[4] = { "# ve", "rsion", " 300 e", "s" };
//const char* multi[4] = { "# ve", "rsion", " 300 e", "s" };
//const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
//const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
//ret = ShCompile(compiler, multi, 4, 0, EShOptNone, resources,
debug
Options, 100, false, messages);
//ret = ShCompile(compiler, multi, 4, 0, EShOptNone, resources, Options, 100, false, messages);
}
}
if
(
debugOptions
&
EDebugOp
MemoryLeakMode
)
if
(
Options
&
EOption
MemoryLeakMode
)
glslang
::
OS_DumpMemoryCounters
();
glslang
::
OS_DumpMemoryCounters
();
}
}
...
@@ -319,7 +333,8 @@ void usage()
...
@@ -319,7 +333,8 @@ void usage()
"To get other information, use one of the following options:
\n
"
"To get other information, use one of the following options:
\n
"
"-i: intermediate tree (glslang AST) is printed out
\n
"
"-i: intermediate tree (glslang AST) is printed out
\n
"
"-d: delay exit
\n
"
"-d: delay exit
\n
"
"-l: memory leak mode
\n
"
"-l: link validation of all input files
\n
"
"-m: memory leak mode
\n
"
"-s: silent mode
\n
"
"-s: silent mode
\n
"
"-r: relaxed semantic error-checking mode
\n
"
);
"-r: relaxed semantic error-checking mode
\n
"
);
}
}
...
...
Todo.txt
View file @
94a81fbd
Current functionality level: ESSL 3.0
Current functionality level: ESSL 3.0
Error checking
- compile-time check for static recursion
- location layout range/overlap semantics
Performance
Performance
Testing
Testing
...
@@ -27,6 +23,7 @@ Link Validation
...
@@ -27,6 +23,7 @@ Link Validation
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks
- location/component/binding/index/offset match check
- location/component/binding/index/offset match check
- location/component aliasing (except desktop vertex shader inputs)
- location/component aliasing (except desktop vertex shader inputs)
- location layout range/overlap semantics
- geometry shader input array sizes and input layout qualifier declaration
- geometry shader input array sizes and input layout qualifier declaration
- compute shader layout(local_size_*) matching
- compute shader layout(local_size_*) matching
- mixed es/non-es profiles
- mixed es/non-es profiles
...
...
glslang/Include/intermediate.h
View file @
94a81fbd
...
@@ -572,7 +572,7 @@ protected:
...
@@ -572,7 +572,7 @@ protected:
bool
userDefined
;
// used for user defined function names
bool
userDefined
;
// used for user defined function names
bool
optimize
;
bool
optimize
;
bool
debug
;
bool
debug
;
TPragmaTable
*
pragmaTable
;
TPragmaTable
*
pragmaTable
;
};
};
//
//
...
@@ -634,6 +634,7 @@ public:
...
@@ -634,6 +634,7 @@ public:
visitAggregate
(
0
),
visitAggregate
(
0
),
visitLoop
(
0
),
visitLoop
(
0
),
visitBranch
(
0
),
visitBranch
(
0
),
visitSwitch
(
0
),
depth
(
0
),
depth
(
0
),
preVisit
(
true
),
preVisit
(
true
),
postVisit
(
false
),
postVisit
(
false
),
...
...
glslang/MachineIndependent/Constant.cpp
View file @
94a81fbd
...
@@ -198,6 +198,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
...
@@ -198,6 +198,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray
=
new
TConstUnion
[
objectSize
];
newConstArray
=
new
TConstUnion
[
objectSize
];
for
(
int
i
=
0
;
i
<
objectSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
objectSize
;
i
++
)
{
switch
(
getType
().
getBasicType
())
{
switch
(
getType
().
getBasicType
())
{
case
EbtDouble
:
case
EbtFloat
:
case
EbtFloat
:
newConstArray
[
i
].
setDConst
(
unionArray
[
i
].
getDConst
()
/
rightUnionArray
[
i
].
getDConst
());
newConstArray
[
i
].
setDConst
(
unionArray
[
i
].
getDConst
()
/
rightUnionArray
[
i
].
getDConst
());
break
;
break
;
...
@@ -438,6 +439,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
...
@@ -438,6 +439,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
switch
(
op
)
{
switch
(
op
)
{
case
EOpNegative
:
case
EOpNegative
:
switch
(
getType
().
getBasicType
())
{
switch
(
getType
().
getBasicType
())
{
case
EbtDouble
:
case
EbtFloat
:
newConstArray
[
i
].
setDConst
(
-
unionArray
[
i
].
getDConst
());
break
;
case
EbtFloat
:
newConstArray
[
i
].
setDConst
(
-
unionArray
[
i
].
getDConst
());
break
;
case
EbtInt
:
newConstArray
[
i
].
setIConst
(
-
unionArray
[
i
].
getIConst
());
break
;
case
EbtInt
:
newConstArray
[
i
].
setIConst
(
-
unionArray
[
i
].
getIConst
());
break
;
case
EbtUint
:
newConstArray
[
i
].
setUConst
(
static_cast
<
unsigned
int
>
(
-
static_cast
<
int
>
(
unionArray
[
i
].
getUConst
())));
break
;
case
EbtUint
:
newConstArray
[
i
].
setUConst
(
static_cast
<
unsigned
int
>
(
-
static_cast
<
int
>
(
unionArray
[
i
].
getUConst
())));
break
;
...
...
glslang/MachineIndependent/RemoveTree.cpp
View file @
94a81fbd
...
@@ -88,6 +88,20 @@ void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)
...
@@ -88,6 +88,20 @@ void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)
delete
node
;
delete
node
;
}
}
bool
RemoveLoop
(
bool
/*preVisit*/
,
TIntermLoop
*
node
,
TIntermTraverser
*
)
{
delete
node
;
return
true
;
}
bool
RemoveBranch
(
bool
/*preVisit*/
,
TIntermBranch
*
node
,
TIntermTraverser
*
)
{
delete
node
;
return
true
;
}
//
//
// Entry point.
// Entry point.
//
//
...
@@ -95,12 +109,14 @@ void RemoveAllTreeNodes(TIntermNode* root)
...
@@ -95,12 +109,14 @@ void RemoveAllTreeNodes(TIntermNode* root)
{
{
TIntermTraverser
it
;
TIntermTraverser
it
;
it
.
visitAggregate
=
RemoveAggregate
;
it
.
visitBinary
=
RemoveBinary
;
it
.
visitConstantUnion
=
RemoveConstantUnion
;
it
.
visitSelection
=
RemoveSelection
;
it
.
visitSymbol
=
RemoveSymbol
;
it
.
visitSymbol
=
RemoveSymbol
;
it
.
visitConstantUnion
=
RemoveConstantUnion
;
it
.
visitBinary
=
RemoveBinary
;
it
.
visitUnary
=
RemoveUnary
;
it
.
visitUnary
=
RemoveUnary
;
it
.
visitAggregate
=
RemoveAggregate
;
it
.
visitSelection
=
RemoveSelection
;
it
.
visitLoop
=
RemoveLoop
;
it
.
visitBranch
=
RemoveBranch
;
it
.
visitSwitch
=
RemoveSwitch
;
it
.
visitSwitch
=
RemoveSwitch
;
it
.
preVisit
=
false
;
it
.
preVisit
=
false
;
...
...
glslang/MachineIndependent/ShaderLang.cpp
View file @
94a81fbd
...
@@ -413,10 +413,10 @@ int ShCompile(
...
@@ -413,10 +413,10 @@ int ShCompile(
const
int
*
inputLengths
,
const
int
*
inputLengths
,
const
EShOptimizationLevel
optLevel
,
const
EShOptimizationLevel
optLevel
,
const
TBuiltInResource
*
resources
,
const
TBuiltInResource
*
resources
,
int
debugOptions
,
int
debugOptions
,
// currently unused
int
defaultVersion
,
// use 100 for ES environment, 110 for desktop
int
defaultVersion
,
// use 100 for ES environment, 110 for desktop
bool
forwardCompatible
,
// give errors for use of deprecated features
bool
forwardCompatible
,
// give errors for use of deprecated features
EShMessages
messages
// warnings/errors
EShMessages
messages
// warnings/errors
/AST; things to print out
)
)
{
{
if
(
!
InitThread
())
if
(
!
InitThread
())
...
@@ -513,6 +513,10 @@ int ShCompile(
...
@@ -513,6 +513,10 @@ int ShCompile(
success
=
false
;
success
=
false
;
intermediate
.
addSymbolLinkageNodes
(
parseContext
.
treeRoot
,
parseContext
.
linkage
,
parseContext
.
language
,
symbolTable
);
intermediate
.
addSymbolLinkageNodes
(
parseContext
.
treeRoot
,
parseContext
.
linkage
,
parseContext
.
language
,
symbolTable
);
// Clean up the symbol table before deallocating the pool memory it used.
// The AST is self-sufficient now, so it can be done before the rest of compilation/linking.
delete
symbolTableMemory
;
if
(
success
&&
parseContext
.
treeRoot
)
{
if
(
success
&&
parseContext
.
treeRoot
)
{
if
(
optLevel
==
EShOptNoGeneration
)
if
(
optLevel
==
EShOptNoGeneration
)
parseContext
.
infoSink
.
info
.
message
(
EPrefixNone
,
"No errors. No code generation or linking was requested."
);
parseContext
.
infoSink
.
info
.
message
(
EPrefixNone
,
"No errors. No code generation or linking was requested."
);
...
@@ -520,7 +524,7 @@ int ShCompile(
...
@@ -520,7 +524,7 @@ int ShCompile(
success
=
intermediate
.
postProcess
(
parseContext
.
treeRoot
,
parseContext
.
language
);
success
=
intermediate
.
postProcess
(
parseContext
.
treeRoot
,
parseContext
.
language
);
if
(
success
)
{
if
(
success
)
{
if
(
debugOptions
&
EDebugOpIntermediate
)
if
(
messages
&
EShMsgAST
)
intermediate
.
outputTree
(
parseContext
.
treeRoot
);
intermediate
.
outputTree
(
parseContext
.
treeRoot
);
//
//
...
@@ -534,15 +538,11 @@ int ShCompile(
...
@@ -534,15 +538,11 @@ int ShCompile(
parseContext
.
infoSink
.
info
.
prefix
(
EPrefixError
);
parseContext
.
infoSink
.
info
.
prefix
(
EPrefixError
);
parseContext
.
infoSink
.
info
<<
parseContext
.
numErrors
<<
" compilation errors. No code generated.
\n\n
"
;
parseContext
.
infoSink
.
info
<<
parseContext
.
numErrors
<<
" compilation errors. No code generated.
\n\n
"
;
success
=
false
;
success
=
false
;
if
(
debugOptions
&
EDebugOpIntermediate
)
if
(
messages
&
EShMsgAST
)
intermediate
.
outputTree
(
parseContext
.
treeRoot
);
intermediate
.
outputTree
(
parseContext
.
treeRoot
);
}
}
intermediate
.
remove
(
parseContext
.
treeRoot
);
intermediate
.
remove
(
parseContext
.
treeRoot
);
// Clean up the symbol table before deallocating the pool memory it used.
delete
symbolTableMemory
;
//
//
// Throw away all the temporary memory used by the compilation process.
// Throw away all the temporary memory used by the compilation process.
//
//
...
...
glslang/Public/ShaderLang.h
View file @
94a81fbd
...
@@ -120,7 +120,8 @@ typedef enum {
...
@@ -120,7 +120,8 @@ typedef enum {
enum
EShMessages
{
enum
EShMessages
{
EShMsgDefault
=
0
,
// default is to give all required errors and extra warnings
EShMsgDefault
=
0
,
// default is to give all required errors and extra warnings
EShMsgRelaxedErrors
=
(
1
<<
0
),
// be liberal in accepting input
EShMsgRelaxedErrors
=
(
1
<<
0
),
// be liberal in accepting input
EShMsgSuppressWarnings
=
(
1
<<
1
)
// suppress all warnings, except those required by the specification
EShMsgSuppressWarnings
=
(
1
<<
1
),
// suppress all warnings, except those required by the specification
EShMsgAST
=
(
1
<<
2
),
// print the AST intermediate representation
};
};
//
//
...
@@ -177,18 +178,6 @@ SH_IMPORT_EXPORT int ShCompile(
...
@@ -177,18 +178,6 @@ SH_IMPORT_EXPORT int ShCompile(
EShMessages
messages
=
EShMsgDefault
// warnings and errors
EShMessages
messages
=
EShMsgDefault
// warnings and errors
);
);
//
// Similar to ShCompile, but accepts an opaque handle to an
// intermediate language structure.
//
SH_IMPORT_EXPORT
int
ShCompileIntermediate
(
ShHandle
compiler
,
ShHandle
intermediate
,
const
EShOptimizationLevel
,
int
debuggable
// boolean
);
SH_IMPORT_EXPORT
int
ShLink
(
SH_IMPORT_EXPORT
int
ShLink
(
const
ShHandle
,
// linker object
const
ShHandle
,
// linker object
const
ShHandle
h
[],
// compiler objects to link together
const
ShHandle
h
[],
// compiler objects to link together
...
@@ -228,20 +217,8 @@ SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int co
...
@@ -228,20 +217,8 @@ SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int co
//
//
SH_IMPORT_EXPORT
int
ShGetUniformLocation
(
const
ShHandle
uniformMap
,
const
char
*
name
);
SH_IMPORT_EXPORT
int
ShGetUniformLocation
(
const
ShHandle
uniformMap
,
const
char
*
name
);
enum
TDebugOptions
{
EDebugOpNone
=
0x000
,
EDebugOpIntermediate
=
0x001
,
EDebugOpAssembly
=
0x002
,
EDebugOpObjectCode
=
0x004
,
EDebugOpLinkMaps
=
0x008
,
EDebugOpSuppressInfolog
=
0x010
,
EDebugOpMemoryLeakMode
=
0x020
,
EDebugOpTexturePrototypes
=
0x040
,
EDebugOpRelaxedErrors
=
0x080
,
EDebugOpGiveWarnings
=
0x100
,
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
// end extern "C"
#endif
#endif
#endif // _COMPILER_INTERFACE_INCLUDED_
#endif // _COMPILER_INTERFACE_INCLUDED_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment