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
2f78b9c7
Unverified
Commit
2f78b9c7
authored
Oct 04, 2018
by
John Kessenich
Committed by
GitHub
Oct 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1515 from Igalia/more-location-command-line-options
Enhancement: add extra command line options that modifies aml
parents
ca042a0f
b0f3d794
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
4 deletions
+76
-4
StandAlone.cpp
StandAlone/StandAlone.cpp
+37
-0
ShaderLang.cpp
glslang/MachineIndependent/ShaderLang.cpp
+8
-0
iomapper.cpp
glslang/MachineIndependent/iomapper.cpp
+7
-3
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+22
-1
ShaderLang.h
glslang/Public/ShaderLang.h
+2
-0
No files found.
StandAlone/StandAlone.cpp
View file @
2f78b9c7
...
@@ -173,6 +173,9 @@ std::vector<std::string> Processes; // what should be record
...
@@ -173,6 +173,9 @@ std::vector<std::string> Processes; // what should be record
// Per descriptor-set binding base data
// Per descriptor-set binding base data
typedef
std
::
map
<
unsigned
int
,
unsigned
int
>
TPerSetBaseBinding
;
typedef
std
::
map
<
unsigned
int
,
unsigned
int
>
TPerSetBaseBinding
;
std
::
vector
<
std
::
pair
<
std
::
string
,
int
>>
uniformLocationOverrides
;
int
uniformBase
=
0
;
std
::
array
<
std
::
array
<
unsigned
int
,
EShLangCount
>
,
glslang
::
EResCount
>
baseBinding
;
std
::
array
<
std
::
array
<
unsigned
int
,
EShLangCount
>
,
glslang
::
EResCount
>
baseBinding
;
std
::
array
<
std
::
array
<
TPerSetBaseBinding
,
EShLangCount
>
,
glslang
::
EResCount
>
baseBindingForSet
;
std
::
array
<
std
::
array
<
TPerSetBaseBinding
,
EShLangCount
>
,
glslang
::
EResCount
>
baseBindingForSet
;
std
::
array
<
std
::
vector
<
std
::
string
>
,
EShLangCount
>
baseResourceSetBinding
;
std
::
array
<
std
::
vector
<
std
::
string
>
,
EShLangCount
>
baseResourceSetBinding
;
...
@@ -431,6 +434,22 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -431,6 +434,22 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
Options
&=
~
EOptionVulkanRules
;
Options
&=
~
EOptionVulkanRules
;
};
};
const
auto
getUniformOverride
=
[
getStringOperand
]()
{
const
char
*
arg
=
getStringOperand
(
"-u<name>:<location>"
);
const
char
*
split
=
strchr
(
arg
,
':'
);
if
(
split
==
NULL
)
{
printf
(
"%s: missing location
\n
"
,
arg
);
exit
(
EFailUsage
);
}
errno
=
0
;
int
location
=
::
strtol
(
split
+
1
,
NULL
,
10
);
if
(
errno
)
{
printf
(
"%s: invalid location
\n
"
,
arg
);
exit
(
EFailUsage
);
}
return
std
::
make_pair
(
std
::
string
(
arg
,
split
-
arg
),
location
);
};
for
(
bumpArg
();
argc
>=
1
;
bumpArg
())
{
for
(
bumpArg
();
argc
>=
1
;
bumpArg
())
{
if
(
argv
[
0
][
0
]
==
'-'
)
{
if
(
argv
[
0
][
0
]
==
'-'
)
{
switch
(
argv
[
0
][
1
])
{
switch
(
argv
[
0
][
1
])
{
...
@@ -447,6 +466,12 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -447,6 +466,12 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
}
else
if
(
lowerword
==
"auto-map-locations"
||
// synonyms
}
else
if
(
lowerword
==
"auto-map-locations"
||
// synonyms
lowerword
==
"aml"
)
{
lowerword
==
"aml"
)
{
Options
|=
EOptionAutoMapLocations
;
Options
|=
EOptionAutoMapLocations
;
}
else
if
(
lowerword
==
"uniform-base"
)
{
if
(
argc
<=
1
)
Error
(
"no <base> provided for --uniform-base"
);
uniformBase
=
::
strtol
(
argv
[
1
],
NULL
,
10
);
bumpArg
();
break
;
}
else
if
(
lowerword
==
"client"
)
{
}
else
if
(
lowerword
==
"client"
)
{
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"vulkan100"
)
==
0
)
if
(
strcmp
(
argv
[
1
],
"vulkan100"
)
==
0
)
...
@@ -572,6 +597,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -572,6 +597,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
else
else
UserPreamble
.
addDef
(
getStringOperand
(
"-D<macro> macro name"
));
UserPreamble
.
addDef
(
getStringOperand
(
"-D<macro> macro name"
));
break
;
break
;
case
'u'
:
uniformLocationOverrides
.
push_back
(
getUniformOverride
());
break
;
case
'E'
:
case
'E'
:
Options
|=
EOptionOutputPreprocessed
;
Options
|=
EOptionOutputPreprocessed
;
break
;
break
;
...
@@ -898,6 +926,13 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -898,6 +926,13 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if
(
Options
&
EOptionInvertY
)
if
(
Options
&
EOptionInvertY
)
shader
->
setInvertY
(
true
);
shader
->
setInvertY
(
true
);
for
(
auto
&
uniOverride
:
uniformLocationOverrides
)
{
shader
->
addUniformLocationOverride
(
uniOverride
.
first
.
c_str
(),
uniOverride
.
second
);
}
shader
->
setUniformLocationBase
(
uniformBase
);
// Set up the environment, some subsettings take precedence over earlier
// Set up the environment, some subsettings take precedence over earlier
// ways of setting things.
// ways of setting things.
if
(
Options
&
EOptionSpv
)
{
if
(
Options
&
EOptionSpv
)
{
...
@@ -1417,6 +1452,8 @@ void usage()
...
@@ -1417,6 +1452,8 @@ void usage()
" -w | --suppress-warnings
\n
"
" -w | --suppress-warnings
\n
"
" suppress GLSL warnings, except as required by
\"
#extension : warn
\"\n
"
" suppress GLSL warnings, except as required by
\"
#extension : warn
\"\n
"
" -x save binary output as text-based 32-bit hexadecimal numbers
\n
"
" -x save binary output as text-based 32-bit hexadecimal numbers
\n
"
" -u<name>:<loc> specify a uniform location override for --aml
\n
"
" --uniform-base <base> set a base to use for generated uniform locations
\n
"
" --auto-map-bindings | --amb automatically bind uniform variables
\n
"
" --auto-map-bindings | --amb automatically bind uniform variables
\n
"
" without explicit bindings
\n
"
" without explicit bindings
\n
"
" --auto-map-locations | --aml automatically locate input/output lacking
\n
"
" --auto-map-locations | --aml automatically locate input/output lacking
\n
"
...
...
glslang/MachineIndependent/ShaderLang.cpp
View file @
2f78b9c7
...
@@ -1759,6 +1759,14 @@ void TShader::setAutoMapBindings(bool map) { intermediate->setAutoM
...
@@ -1759,6 +1759,14 @@ void TShader::setAutoMapBindings(bool map) { intermediate->setAutoM
void
TShader
::
setInvertY
(
bool
invert
)
{
intermediate
->
setInvertY
(
invert
);
}
void
TShader
::
setInvertY
(
bool
invert
)
{
intermediate
->
setInvertY
(
invert
);
}
// Fragile: currently within one stage: simple auto-assignment of location
// Fragile: currently within one stage: simple auto-assignment of location
void
TShader
::
setAutoMapLocations
(
bool
map
)
{
intermediate
->
setAutoMapLocations
(
map
);
}
void
TShader
::
setAutoMapLocations
(
bool
map
)
{
intermediate
->
setAutoMapLocations
(
map
);
}
void
TShader
::
addUniformLocationOverride
(
const
char
*
name
,
int
loc
)
{
intermediate
->
addUniformLocationOverride
(
name
,
loc
);
}
void
TShader
::
setUniformLocationBase
(
int
base
)
{
intermediate
->
setUniformLocationBase
(
base
);
}
// See comment above TDefaultHlslIoMapper in iomapper.cpp:
// See comment above TDefaultHlslIoMapper in iomapper.cpp:
void
TShader
::
setHlslIoMapping
(
bool
hlslIoMap
)
{
intermediate
->
setHlslIoMapping
(
hlslIoMap
);
}
void
TShader
::
setHlslIoMapping
(
bool
hlslIoMap
)
{
intermediate
->
setHlslIoMapping
(
hlslIoMap
);
}
void
TShader
::
setFlattenUniformArrays
(
bool
flatten
)
{
intermediate
->
setFlattenUniformArrays
(
flatten
);
}
void
TShader
::
setFlattenUniformArrays
(
bool
flatten
)
{
intermediate
->
setFlattenUniformArrays
(
flatten
);
}
...
...
glslang/MachineIndependent/iomapper.cpp
View file @
2f78b9c7
...
@@ -359,7 +359,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
...
@@ -359,7 +359,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
{
{
TDefaultIoResolverBase
(
const
TIntermediate
&
intermediate
)
:
TDefaultIoResolverBase
(
const
TIntermediate
&
intermediate
)
:
intermediate
(
intermediate
),
intermediate
(
intermediate
),
nextUniformLocation
(
0
),
nextUniformLocation
(
intermediate
.
getUniformLocationBase
()
),
nextInputLocation
(
0
),
nextInputLocation
(
0
),
nextOutputLocation
(
0
)
nextOutputLocation
(
0
)
{
}
{
}
...
@@ -434,7 +434,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
...
@@ -434,7 +434,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
return
0
;
return
0
;
}
}
int
resolveUniformLocation
(
EShLanguage
/*stage*/
,
const
char
*
/*name*/
,
const
glslang
::
TType
&
type
,
bool
/*is_live*/
)
override
int
resolveUniformLocation
(
EShLanguage
/*stage*/
,
const
char
*
name
,
const
glslang
::
TType
&
type
,
bool
/*is_live*/
)
override
{
{
// kick out of not doing this
// kick out of not doing this
if
(
!
doAutoLocationMapping
())
if
(
!
doAutoLocationMapping
())
...
@@ -455,7 +455,11 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
...
@@ -455,7 +455,11 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
return
-
1
;
return
-
1
;
}
}
int
location
=
nextUniformLocation
;
int
location
=
intermediate
.
getUniformLocationOverride
(
name
);
if
(
location
!=
-
1
)
return
location
;
location
=
nextUniformLocation
;
nextUniformLocation
+=
TIntermediate
::
computeTypeUniformLocationSize
(
type
);
nextUniformLocation
+=
TIntermediate
::
computeTypeUniformLocationSize
(
type
);
...
...
glslang/MachineIndependent/localintermediate.h
View file @
2f78b9c7
...
@@ -252,7 +252,8 @@ public:
...
@@ -252,7 +252,8 @@ public:
hlslIoMapping
(
false
),
hlslIoMapping
(
false
),
textureSamplerTransformMode
(
EShTexSampTransKeep
),
textureSamplerTransformMode
(
EShTexSampTransKeep
),
needToLegalize
(
false
),
needToLegalize
(
false
),
binaryDoubleOutput
(
false
)
binaryDoubleOutput
(
false
),
uniformLocationBase
(
0
)
{
{
localSize
[
0
]
=
1
;
localSize
[
0
]
=
1
;
localSize
[
1
]
=
1
;
localSize
[
1
]
=
1
;
...
@@ -671,6 +672,23 @@ public:
...
@@ -671,6 +672,23 @@ public:
void
addProcessArgument
(
const
std
::
string
&
arg
)
{
processes
.
addArgument
(
arg
);
}
void
addProcessArgument
(
const
std
::
string
&
arg
)
{
processes
.
addArgument
(
arg
);
}
const
std
::
vector
<
std
::
string
>&
getProcesses
()
const
{
return
processes
.
getProcesses
();
}
const
std
::
vector
<
std
::
string
>&
getProcesses
()
const
{
return
processes
.
getProcesses
();
}
void
addUniformLocationOverride
(
const
TString
&
name
,
int
location
)
{
uniformLocationOverrides
[
name
]
=
location
;
}
int
getUniformLocationOverride
(
const
TString
&
name
)
const
{
auto
pos
=
uniformLocationOverrides
.
find
(
name
);
if
(
pos
==
uniformLocationOverrides
.
end
())
return
-
1
;
else
return
pos
->
second
;
}
void
setUniformLocationBase
(
int
base
)
{
uniformLocationBase
=
base
;
}
int
getUniformLocationBase
()
const
{
return
uniformLocationBase
;
}
void
setNeedsLegalization
()
{
needToLegalize
=
true
;
}
void
setNeedsLegalization
()
{
needToLegalize
=
true
;
}
bool
needsLegalization
()
const
{
return
needToLegalize
;
}
bool
needsLegalization
()
const
{
return
needToLegalize
;
}
...
@@ -796,6 +814,9 @@ protected:
...
@@ -796,6 +814,9 @@ protected:
bool
needToLegalize
;
bool
needToLegalize
;
bool
binaryDoubleOutput
;
bool
binaryDoubleOutput
;
std
::
unordered_map
<
TString
,
int
>
uniformLocationOverrides
;
int
uniformLocationBase
;
private
:
private
:
void
operator
=
(
TIntermediate
&
);
// prevent assignments
void
operator
=
(
TIntermediate
&
);
// prevent assignments
};
};
...
...
glslang/Public/ShaderLang.h
View file @
2f78b9c7
...
@@ -413,6 +413,8 @@ public:
...
@@ -413,6 +413,8 @@ public:
void
setResourceSetBinding
(
const
std
::
vector
<
std
::
string
>&
base
);
void
setResourceSetBinding
(
const
std
::
vector
<
std
::
string
>&
base
);
void
setAutoMapBindings
(
bool
map
);
void
setAutoMapBindings
(
bool
map
);
void
setAutoMapLocations
(
bool
map
);
void
setAutoMapLocations
(
bool
map
);
void
addUniformLocationOverride
(
const
char
*
name
,
int
loc
);
void
setUniformLocationBase
(
int
base
);
void
setInvertY
(
bool
invert
);
void
setInvertY
(
bool
invert
);
void
setHlslIoMapping
(
bool
hlslIoMap
);
void
setHlslIoMapping
(
bool
hlslIoMap
);
void
setFlattenUniformArrays
(
bool
flatten
);
void
setFlattenUniformArrays
(
bool
flatten
);
...
...
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