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
0dd1285c
Commit
0dd1285c
authored
Sep 02, 2017
by
Sven-Hendrik Haase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --stdin
parent
3a21c880
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
2 deletions
+52
-2
StandAlone.cpp
StandAlone/StandAlone.cpp
+52
-2
No files found.
StandAlone/StandAlone.cpp
View file @
0dd1285c
...
...
@@ -94,6 +94,7 @@ enum TOptions {
EOptionHlslIoMapping
=
(
1
<<
24
),
EOptionAutoMapLocations
=
(
1
<<
25
),
EOptionDebug
=
(
1
<<
26
),
EOptionStdin
=
(
1
<<
27
),
};
//
...
...
@@ -469,6 +470,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
sourceEntryPointName
=
argv
[
1
];
bumpArg
();
break
;
}
else
if
(
lowerword
==
"stdin"
)
{
Options
|=
EOptionStdin
;
shaderStageName
=
argv
[
1
];
}
else
if
(
lowerword
==
"suppress-warnings"
)
{
Options
|=
EOptionSuppressWarnings
;
}
else
if
(
lowerword
==
"target-env"
)
{
...
...
@@ -606,6 +610,10 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
}
}
// Make sure that -S is always specified if --stdin is specified
if
((
Options
&
EOptionStdin
)
&&
shaderStageName
==
nullptr
)
Error
(
"must provide -S when --stdin is given"
);
// Make sure that -E is not specified alongside linking (which includes SPV generation)
if
((
Options
&
EOptionOutputPreprocessed
)
&&
(
Options
&
EOptionLinkProgram
))
Error
(
"can't use -E when linking is selected"
);
...
...
@@ -654,6 +662,19 @@ void SetMessageOptions(EShMessages& messages)
void
CompileShaders
(
glslang
::
TWorklist
&
worklist
)
{
glslang
::
TWorkItem
*
workItem
;
if
(
Options
&
EOptionStdin
)
{
worklist
.
remove
(
workItem
);
ShHandle
compiler
=
ShConstructCompiler
(
FindLanguage
(
"stdin"
),
Options
);
if
(
compiler
==
0
)
return
;
CompileFile
(
"stdin"
,
compiler
);
if
(
!
(
Options
&
EOptionSuppressInfolog
))
workItem
->
results
=
ShGetInfoLog
(
compiler
);
ShDestruct
(
compiler
);
}
else
{
while
(
worklist
.
remove
(
workItem
))
{
ShHandle
compiler
=
ShConstructCompiler
(
FindLanguage
(
workItem
->
name
),
Options
);
if
(
compiler
==
0
)
...
...
@@ -666,6 +687,7 @@ void CompileShaders(glslang::TWorklist& worklist)
ShDestruct
(
compiler
);
}
}
}
// Outputs the given string, but only if it is non-null and non-empty.
...
...
@@ -908,6 +930,18 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
{
std
::
vector
<
ShaderCompUnit
>
compUnits
;
// If this is using stdin, we can't really detect multiple different file
// units by input type. We need to assume that we're just being given one
// file of a certain type.
if
((
Options
&
EOptionStdin
)
!=
0
)
{
ShaderCompUnit
compUnit
(
FindLanguage
(
"stdin"
));
std
::
istreambuf_iterator
<
char
>
begin
(
std
::
cin
),
end
;
std
::
string
tempString
(
begin
,
end
);
char
*
fileText
=
strdup
(
tempString
.
c_str
());
std
::
string
fileName
=
"stdin"
;
compUnit
.
addString
(
fileName
,
fileText
);
compUnits
.
push_back
(
compUnit
);
}
else
{
// Transfer all the work items from to a simple list of
// of compilation units. (We don't care about the thread
// work-item distribution properties in this path, which
...
...
@@ -922,6 +956,7 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
compUnit
.
addString
(
workItem
->
name
,
fileText
);
compUnits
.
push_back
(
compUnit
);
}
}
// Actual call to programmatic processing of compile and link,
// in a loop for testing memory and performance. This part contains
...
...
@@ -973,10 +1008,15 @@ int C_DECL main(int argc, char* argv[])
return
ESuccess
;
}
if
(
workList
.
empty
())
{
if
(
workList
.
empty
()
&&
((
Options
&
EOptionStdin
)
==
0
)
)
{
usage
();
}
if
(
Options
&
EOptionStdin
)
{
workItems
.
push_back
(
std
::
unique_ptr
<
glslang
::
TWorkItem
>
{
new
glslang
::
TWorkItem
(
"stdin"
)});
workList
.
add
(
workItems
.
back
().
get
());
}
ProcessConfigFile
();
//
...
...
@@ -1087,7 +1127,14 @@ EShLanguage FindLanguage(const std::string& name, bool parseSuffix)
void
CompileFile
(
const
char
*
fileName
,
ShHandle
compiler
)
{
int
ret
=
0
;
char
*
shaderString
=
ReadFileData
(
fileName
);
char
*
shaderString
;
if
((
Options
&
EOptionStdin
)
!=
0
)
{
std
::
istreambuf_iterator
<
char
>
begin
(
std
::
cin
),
end
;
std
::
string
tempString
(
begin
,
end
);
shaderString
=
strdup
(
tempString
.
c_str
());
}
else
{
shaderString
=
ReadFileData
(
fileName
);
}
// move to length-based strings, rather than null-terminated strings
int
*
lengths
=
new
int
[
1
];
...
...
@@ -1220,6 +1267,9 @@ void usage()
" --source-entrypoint name the given shader source function is
\n
"
" renamed to be the entry point given in -e
\n
"
" --sep synonym for --source-entrypoint
\n
"
" --stdin Read from stdin instead of from a file.
\n
"
" You'll have to provide the shader stage
\n
"
" using -S.
\n
"
" --suppress-warnings suppress GLSL warnings
\n
"
" (except as required by #extension : warn)
\n
"
" --target-env {vulkan1.0|opengl} set the execution environment code will
\n
"
...
...
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