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
d004e5ca
Commit
d004e5ca
authored
Sep 07, 2017
by
John Kessenich
Committed by
GitHub
Sep 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1047 from svenstaro/add-stdin-option
Add stdin option (fixes #598)
parents
8688e3fb
0dd1285c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
19 deletions
+69
-19
StandAlone.cpp
StandAlone/StandAlone.cpp
+69
-19
No files found.
StandAlone/StandAlone.cpp
View file @
d004e5ca
...
@@ -94,6 +94,7 @@ enum TOptions {
...
@@ -94,6 +94,7 @@ enum TOptions {
EOptionHlslIoMapping
=
(
1
<<
24
),
EOptionHlslIoMapping
=
(
1
<<
24
),
EOptionAutoMapLocations
=
(
1
<<
25
),
EOptionAutoMapLocations
=
(
1
<<
25
),
EOptionDebug
=
(
1
<<
26
),
EOptionDebug
=
(
1
<<
26
),
EOptionStdin
=
(
1
<<
27
),
};
};
//
//
...
@@ -469,6 +470,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -469,6 +470,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
sourceEntryPointName
=
argv
[
1
];
sourceEntryPointName
=
argv
[
1
];
bumpArg
();
bumpArg
();
break
;
break
;
}
else
if
(
lowerword
==
"stdin"
)
{
Options
|=
EOptionStdin
;
shaderStageName
=
argv
[
1
];
}
else
if
(
lowerword
==
"suppress-warnings"
)
{
}
else
if
(
lowerword
==
"suppress-warnings"
)
{
Options
|=
EOptionSuppressWarnings
;
Options
|=
EOptionSuppressWarnings
;
}
else
if
(
lowerword
==
"target-env"
)
{
}
else
if
(
lowerword
==
"target-env"
)
{
...
@@ -606,6 +610,10 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -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)
// Make sure that -E is not specified alongside linking (which includes SPV generation)
if
((
Options
&
EOptionOutputPreprocessed
)
&&
(
Options
&
EOptionLinkProgram
))
if
((
Options
&
EOptionOutputPreprocessed
)
&&
(
Options
&
EOptionLinkProgram
))
Error
(
"can't use -E when linking is selected"
);
Error
(
"can't use -E when linking is selected"
);
...
@@ -654,17 +662,31 @@ void SetMessageOptions(EShMessages& messages)
...
@@ -654,17 +662,31 @@ void SetMessageOptions(EShMessages& messages)
void
CompileShaders
(
glslang
::
TWorklist
&
worklist
)
void
CompileShaders
(
glslang
::
TWorklist
&
worklist
)
{
{
glslang
::
TWorkItem
*
workItem
;
glslang
::
TWorkItem
*
workItem
;
while
(
worklist
.
remove
(
workItem
))
{
if
(
Options
&
EOptionStdin
)
{
ShHandle
compiler
=
ShConstructCompiler
(
FindLanguage
(
workItem
->
name
),
Options
);
worklist
.
remove
(
workItem
);
ShHandle
compiler
=
ShConstructCompiler
(
FindLanguage
(
"stdin"
),
Options
);
if
(
compiler
==
0
)
if
(
compiler
==
0
)
return
;
return
;
CompileFile
(
workItem
->
name
.
c_str
()
,
compiler
);
CompileFile
(
"stdin"
,
compiler
);
if
(
!
(
Options
&
EOptionSuppressInfolog
))
if
(
!
(
Options
&
EOptionSuppressInfolog
))
workItem
->
results
=
ShGetInfoLog
(
compiler
);
workItem
->
results
=
ShGetInfoLog
(
compiler
);
ShDestruct
(
compiler
);
ShDestruct
(
compiler
);
}
else
{
while
(
worklist
.
remove
(
workItem
))
{
ShHandle
compiler
=
ShConstructCompiler
(
FindLanguage
(
workItem
->
name
),
Options
);
if
(
compiler
==
0
)
return
;
CompileFile
(
workItem
->
name
.
c_str
(),
compiler
);
if
(
!
(
Options
&
EOptionSuppressInfolog
))
workItem
->
results
=
ShGetInfoLog
(
compiler
);
ShDestruct
(
compiler
);
}
}
}
}
}
...
@@ -908,19 +930,32 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
...
@@ -908,19 +930,32 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
{
{
std
::
vector
<
ShaderCompUnit
>
compUnits
;
std
::
vector
<
ShaderCompUnit
>
compUnits
;
// Transfer all the work items from to a simple list of
// If this is using stdin, we can't really detect multiple different file
// of compilation units. (We don't care about the thread
// units by input type. We need to assume that we're just being given one
// work-item distribution properties in this path, which
// file of a certain type.
// is okay due to the limited number of shaders, know since
if
((
Options
&
EOptionStdin
)
!=
0
)
{
// they are all getting linked together.)
ShaderCompUnit
compUnit
(
FindLanguage
(
"stdin"
));
glslang
::
TWorkItem
*
workItem
;
std
::
istreambuf_iterator
<
char
>
begin
(
std
::
cin
),
end
;
while
(
Worklist
.
remove
(
workItem
))
{
std
::
string
tempString
(
begin
,
end
);
ShaderCompUnit
compUnit
(
FindLanguage
(
workItem
->
name
));
char
*
fileText
=
strdup
(
tempString
.
c_str
());
char
*
fileText
=
ReadFileData
(
workItem
->
name
.
c_str
());
std
::
string
fileName
=
"stdin"
;
if
(
fileText
==
nullptr
)
compUnit
.
addString
(
fileName
,
fileText
);
usage
();
compUnit
.
addString
(
workItem
->
name
,
fileText
);
compUnits
.
push_back
(
compUnit
);
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
// is okay due to the limited number of shaders, know since
// they are all getting linked together.)
glslang
::
TWorkItem
*
workItem
;
while
(
Worklist
.
remove
(
workItem
))
{
ShaderCompUnit
compUnit
(
FindLanguage
(
workItem
->
name
));
char
*
fileText
=
ReadFileData
(
workItem
->
name
.
c_str
());
if
(
fileText
==
nullptr
)
usage
();
compUnit
.
addString
(
workItem
->
name
,
fileText
);
compUnits
.
push_back
(
compUnit
);
}
}
}
// Actual call to programmatic processing of compile and link,
// Actual call to programmatic processing of compile and link,
...
@@ -973,10 +1008,15 @@ int C_DECL main(int argc, char* argv[])
...
@@ -973,10 +1008,15 @@ int C_DECL main(int argc, char* argv[])
return
ESuccess
;
return
ESuccess
;
}
}
if
(
workList
.
empty
())
{
if
(
workList
.
empty
()
&&
((
Options
&
EOptionStdin
)
==
0
)
)
{
usage
();
usage
();
}
}
if
(
Options
&
EOptionStdin
)
{
workItems
.
push_back
(
std
::
unique_ptr
<
glslang
::
TWorkItem
>
{
new
glslang
::
TWorkItem
(
"stdin"
)});
workList
.
add
(
workItems
.
back
().
get
());
}
ProcessConfigFile
();
ProcessConfigFile
();
//
//
...
@@ -1087,7 +1127,14 @@ EShLanguage FindLanguage(const std::string& name, bool parseSuffix)
...
@@ -1087,7 +1127,14 @@ EShLanguage FindLanguage(const std::string& name, bool parseSuffix)
void
CompileFile
(
const
char
*
fileName
,
ShHandle
compiler
)
void
CompileFile
(
const
char
*
fileName
,
ShHandle
compiler
)
{
{
int
ret
=
0
;
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
// move to length-based strings, rather than null-terminated strings
int
*
lengths
=
new
int
[
1
];
int
*
lengths
=
new
int
[
1
];
...
@@ -1220,6 +1267,9 @@ void usage()
...
@@ -1220,6 +1267,9 @@ void usage()
" --source-entrypoint name the given shader source function is
\n
"
" --source-entrypoint name the given shader source function is
\n
"
" renamed to be the entry point given in -e
\n
"
" renamed to be the entry point given in -e
\n
"
" --sep synonym for --source-entrypoint
\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
"
" --suppress-warnings suppress GLSL warnings
\n
"
" (except as required by #extension : warn)
\n
"
" (except as required by #extension : warn)
\n
"
" --target-env {vulkan1.0|opengl} set the execution environment code will
\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