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
4d65ee31
Commit
4d65ee31
authored
Mar 12, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generalize "main" to a settable entry point name.
parent
6cc7674b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
8 deletions
+38
-8
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+5
-3
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+2
-2
SpvBuilder.h
SPIRV/SpvBuilder.h
+2
-2
StandAlone.cpp
StandAlone/StandAlone.cpp
+18
-0
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+1
-1
ShaderLang.cpp
glslang/MachineIndependent/ShaderLang.cpp
+6
-0
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+3
-0
ShaderLang.h
glslang/Public/ShaderLang.h
+1
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
4d65ee31
...
@@ -590,8 +590,8 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
...
@@ -590,8 +590,8 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
builder
.
setSource
(
TranslateSourceLanguage
(
glslangIntermediate
->
getProfile
()),
glslangIntermediate
->
getVersion
());
builder
.
setSource
(
TranslateSourceLanguage
(
glslangIntermediate
->
getProfile
()),
glslangIntermediate
->
getVersion
());
stdBuiltins
=
builder
.
import
(
"GLSL.std.450"
);
stdBuiltins
=
builder
.
import
(
"GLSL.std.450"
);
builder
.
setMemoryModel
(
spv
::
AddressingModelLogical
,
spv
::
MemoryModelGLSL450
);
builder
.
setMemoryModel
(
spv
::
AddressingModelLogical
,
spv
::
MemoryModelGLSL450
);
shaderEntry
=
builder
.
make
Main
(
);
shaderEntry
=
builder
.
make
Entrypoint
(
glslangIntermediate
->
getEntryPoint
().
c_str
()
);
entryPoint
=
builder
.
addEntryPoint
(
executionModel
,
shaderEntry
,
"main"
);
entryPoint
=
builder
.
addEntryPoint
(
executionModel
,
shaderEntry
,
glslangIntermediate
->
getEntryPoint
().
c_str
()
);
// Add the source extensions
// Add the source extensions
const
auto
&
sourceExtensions
=
glslangIntermediate
->
getRequestedExtensions
();
const
auto
&
sourceExtensions
=
glslangIntermediate
->
getRequestedExtensions
();
...
@@ -2082,7 +2082,9 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structTy
...
@@ -2082,7 +2082,9 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structTy
bool
TGlslangToSpvTraverser
::
isShaderEntrypoint
(
const
glslang
::
TIntermAggregate
*
node
)
bool
TGlslangToSpvTraverser
::
isShaderEntrypoint
(
const
glslang
::
TIntermAggregate
*
node
)
{
{
return
node
->
getName
()
==
"main("
;
// have to ignore mangling and just look at the base name
int
firstOpen
=
node
->
getName
().
find
(
'('
);
return
node
->
getName
().
compare
(
0
,
firstOpen
,
glslangIntermediate
->
getEntryPoint
())
==
0
;
}
}
// Make all the functions, skeletally, without actually visiting their bodies.
// Make all the functions, skeletally, without actually visiting their bodies.
...
...
SPIRV/SpvBuilder.cpp
View file @
4d65ee31
...
@@ -893,7 +893,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
...
@@ -893,7 +893,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
}
}
// Comments in header
// Comments in header
Function
*
Builder
::
make
Main
(
)
Function
*
Builder
::
make
Entrypoint
(
const
char
*
entryPoint
)
{
{
assert
(
!
mainFunction
);
assert
(
!
mainFunction
);
...
@@ -901,7 +901,7 @@ Function* Builder::makeMain()
...
@@ -901,7 +901,7 @@ Function* Builder::makeMain()
std
::
vector
<
Id
>
params
;
std
::
vector
<
Id
>
params
;
std
::
vector
<
Decoration
>
precisions
;
std
::
vector
<
Decoration
>
precisions
;
mainFunction
=
makeFunctionEntry
(
NoPrecision
,
makeVoidType
(),
"main"
,
params
,
precisions
,
&
entry
);
mainFunction
=
makeFunctionEntry
(
NoPrecision
,
makeVoidType
(),
entryPoint
,
params
,
precisions
,
&
entry
);
return
mainFunction
;
return
mainFunction
;
}
}
...
...
SPIRV/SpvBuilder.h
View file @
4d65ee31
...
@@ -205,9 +205,9 @@ public:
...
@@ -205,9 +205,9 @@ public:
void
setBuildPoint
(
Block
*
bp
)
{
buildPoint
=
bp
;
}
void
setBuildPoint
(
Block
*
bp
)
{
buildPoint
=
bp
;
}
Block
*
getBuildPoint
()
const
{
return
buildPoint
;
}
Block
*
getBuildPoint
()
const
{
return
buildPoint
;
}
// Make the
main
function. The returned pointer is only valid
// Make the
entry-point
function. The returned pointer is only valid
// for the lifetime of this builder.
// for the lifetime of this builder.
Function
*
make
Main
(
);
Function
*
make
Entrypoint
(
const
char
*
);
// Make a shader-style function, and create its entry block if entry is non-zero.
// Make a shader-style function, and create its entry block if entry is non-zero.
// Return the function, pass back the entry.
// Return the function, pass back the entry.
...
...
StandAlone/StandAlone.cpp
View file @
4d65ee31
...
@@ -449,6 +449,7 @@ int NumWorkItems = 0;
...
@@ -449,6 +449,7 @@ int NumWorkItems = 0;
int
Options
=
0
;
int
Options
=
0
;
const
char
*
ExecutableName
=
nullptr
;
const
char
*
ExecutableName
=
nullptr
;
const
char
*
binaryFileName
=
nullptr
;
const
char
*
binaryFileName
=
nullptr
;
const
char
*
entryPointName
=
nullptr
;
//
//
// Create the default name for saving a binary if -o is not provided.
// Create the default name for saving a binary if -o is not provided.
...
@@ -537,6 +538,16 @@ void ProcessArguments(int argc, char* argv[])
...
@@ -537,6 +538,16 @@ void ProcessArguments(int argc, char* argv[])
case
'd'
:
case
'd'
:
Options
|=
EOptionDefaultDesktop
;
Options
|=
EOptionDefaultDesktop
;
break
;
break
;
case
'e'
:
// HLSL todo: entry point handle needs much more sophistication.
// This is okay for one compilation unit with one entry point.
entryPointName
=
argv
[
1
];
if
(
argc
>
0
)
{
argc
--
;
argv
++
;
}
else
Error
(
"no <entry-point> provided for -e"
);
break
;
case
'h'
:
case
'h'
:
usage
();
usage
();
break
;
break
;
...
@@ -693,6 +704,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -693,6 +704,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
const
auto
&
compUnit
=
*
it
;
const
auto
&
compUnit
=
*
it
;
glslang
::
TShader
*
shader
=
new
glslang
::
TShader
(
compUnit
.
stage
);
glslang
::
TShader
*
shader
=
new
glslang
::
TShader
(
compUnit
.
stage
);
shader
->
setStrings
(
compUnit
.
text
,
1
);
shader
->
setStrings
(
compUnit
.
text
,
1
);
if
(
entryPointName
)
// HLSL todo: this needs to be tracked per compUnits
shader
->
setEntryPoint
(
entryPointName
);
shaders
.
push_back
(
shader
);
shaders
.
push_back
(
shader
);
const
int
defaultVersion
=
Options
&
EOptionDefaultDesktop
?
110
:
100
;
const
int
defaultVersion
=
Options
&
EOptionDefaultDesktop
?
110
:
100
;
...
@@ -726,20 +739,24 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -726,20 +739,24 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
// Program-level processing...
// Program-level processing...
//
//
// Link
if
(
!
(
Options
&
EOptionOutputPreprocessed
)
&&
!
program
.
link
(
messages
))
if
(
!
(
Options
&
EOptionOutputPreprocessed
)
&&
!
program
.
link
(
messages
))
LinkFailed
=
true
;
LinkFailed
=
true
;
// Report
if
(
!
(
Options
&
EOptionSuppressInfolog
)
&&
if
(
!
(
Options
&
EOptionSuppressInfolog
)
&&
!
(
Options
&
EOptionMemoryLeakMode
))
{
!
(
Options
&
EOptionMemoryLeakMode
))
{
PutsIfNonEmpty
(
program
.
getInfoLog
());
PutsIfNonEmpty
(
program
.
getInfoLog
());
PutsIfNonEmpty
(
program
.
getInfoDebugLog
());
PutsIfNonEmpty
(
program
.
getInfoDebugLog
());
}
}
// Reflect
if
(
Options
&
EOptionDumpReflection
)
{
if
(
Options
&
EOptionDumpReflection
)
{
program
.
buildReflection
();
program
.
buildReflection
();
program
.
dumpReflection
();
program
.
dumpReflection
();
}
}
// Dump SPIR-V
if
(
Options
&
EOptionSpv
)
{
if
(
Options
&
EOptionSpv
)
{
if
(
CompileFailed
||
LinkFailed
)
if
(
CompileFailed
||
LinkFailed
)
printf
(
"SPIR-V is not generated for failed compile or link
\n
"
);
printf
(
"SPIR-V is not generated for failed compile or link
\n
"
);
...
@@ -1030,6 +1047,7 @@ void usage()
...
@@ -1030,6 +1047,7 @@ void usage()
" creates the default configuration file (redirect to a .conf file)
\n
"
" creates the default configuration file (redirect to a .conf file)
\n
"
" -d default to desktop (#version 110) when there is no shader #version
\n
"
" -d default to desktop (#version 110) when there is no shader #version
\n
"
" (default is ES version 100)
\n
"
" (default is ES version 100)
\n
"
" -e specify entry-point name
\n
"
" -h print this usage message
\n
"
" -h print this usage message
\n
"
" -i intermediate tree (glslang AST) is printed out
\n
"
" -i intermediate tree (glslang AST) is printed out
\n
"
" -l link all input files together to form a single module
\n
"
" -l link all input files together to form a single module
\n
"
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
4d65ee31
...
@@ -975,7 +975,7 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
...
@@ -975,7 +975,7 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
//
//
// Raise error message if main function takes any parameters or returns anything other than void
// Raise error message if main function takes any parameters or returns anything other than void
//
//
if
(
function
.
getName
()
==
"main"
)
{
if
(
function
.
getName
()
==
intermediate
.
getEntryPoint
()
)
{
if
(
function
.
getParamCount
()
>
0
)
if
(
function
.
getParamCount
()
>
0
)
error
(
loc
,
"function cannot take any parameter(s)"
,
function
.
getName
().
c_str
(),
""
);
error
(
loc
,
"function cannot take any parameter(s)"
,
function
.
getName
().
c_str
(),
""
);
if
(
function
.
getType
().
getBasicType
()
!=
EbtVoid
)
if
(
function
.
getType
().
getBasicType
()
!=
EbtVoid
)
...
...
glslang/MachineIndependent/ShaderLang.cpp
View file @
4d65ee31
...
@@ -588,6 +588,7 @@ bool ProcessDeferred(
...
@@ -588,6 +588,7 @@ bool ProcessDeferred(
// Now we can process the full shader under proper symbols and rules.
// Now we can process the full shader under proper symbols and rules.
//
//
intermediate
.
setEntryPoint
(
"main"
);
TParseContext
parseContext
(
symbolTable
,
intermediate
,
false
,
version
,
profile
,
spv
,
vulkan
,
compiler
->
getLanguage
(),
compiler
->
infoSink
,
forwardCompatible
,
messages
);
TParseContext
parseContext
(
symbolTable
,
intermediate
,
false
,
version
,
profile
,
spv
,
vulkan
,
compiler
->
getLanguage
(),
compiler
->
infoSink
,
forwardCompatible
,
messages
);
glslang
::
TScanContext
scanContext
(
parseContext
);
glslang
::
TScanContext
scanContext
(
parseContext
);
TPpContext
ppContext
(
parseContext
,
includer
);
TPpContext
ppContext
(
parseContext
,
includer
);
...
@@ -1355,6 +1356,11 @@ void TShader::setStringsWithLengthsAndNames(
...
@@ -1355,6 +1356,11 @@ void TShader::setStringsWithLengthsAndNames(
stringNames
=
names
;
stringNames
=
names
;
}
}
void
TShader
::
setEntryPoint
(
const
char
*
entryPoint
)
{
intermediate
->
setEntryPoint
(
entryPoint
);
}
//
//
// Turn the shader strings into a parse tree in the TIntermediate.
// Turn the shader strings into a parse tree in the TIntermediate.
//
//
...
...
glslang/MachineIndependent/localintermediate.h
View file @
4d65ee31
...
@@ -145,6 +145,8 @@ public:
...
@@ -145,6 +145,8 @@ public:
void
output
(
TInfoSink
&
,
bool
tree
);
void
output
(
TInfoSink
&
,
bool
tree
);
void
removeTree
();
void
removeTree
();
void
setEntryPoint
(
const
char
*
ep
)
{
entryPoint
=
ep
;
}
const
TString
&
getEntryPoint
()
const
{
return
entryPoint
;
}
void
setVersion
(
int
v
)
{
version
=
v
;
}
void
setVersion
(
int
v
)
{
version
=
v
;
}
int
getVersion
()
const
{
return
version
;
}
int
getVersion
()
const
{
return
version
;
}
void
setProfile
(
EProfile
p
)
{
profile
=
p
;
}
void
setProfile
(
EProfile
p
)
{
profile
=
p
;
}
...
@@ -338,6 +340,7 @@ protected:
...
@@ -338,6 +340,7 @@ protected:
static
int
getBaseAlignmentScalar
(
const
TType
&
,
int
&
size
);
static
int
getBaseAlignmentScalar
(
const
TType
&
,
int
&
size
);
const
EShLanguage
language
;
const
EShLanguage
language
;
TString
entryPoint
;
TIntermNode
*
treeRoot
;
TIntermNode
*
treeRoot
;
EProfile
profile
;
EProfile
profile
;
int
version
;
int
version
;
...
...
glslang/Public/ShaderLang.h
View file @
4d65ee31
...
@@ -290,6 +290,7 @@ public:
...
@@ -290,6 +290,7 @@ public:
void
setStringsWithLengthsAndNames
(
void
setStringsWithLengthsAndNames
(
const
char
*
const
*
s
,
const
int
*
l
,
const
char
*
const
*
names
,
int
n
);
const
char
*
const
*
s
,
const
int
*
l
,
const
char
*
const
*
names
,
int
n
);
void
setPreamble
(
const
char
*
s
)
{
preamble
=
s
;
}
void
setPreamble
(
const
char
*
s
)
{
preamble
=
s
;
}
void
setEntryPoint
(
const
char
*
entryPoint
);
// Interface to #include handlers.
// Interface to #include handlers.
class
Includer
{
class
Includer
{
...
...
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