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
6b1ede41
Unverified
Commit
6b1ede41
authored
Mar 29, 2018
by
John Kessenich
Committed by
GitHub
Mar 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1320 from greg-lunarg/addopt21
Only print legalization warning if optimizer not enabled
parents
7be36647
fb03a55e
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
21 additions
and
21 deletions
+21
-21
CMakeLists.txt
CMakeLists.txt
+2
-1
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+3
-3
StandAlone.cpp
StandAlone/StandAlone.cpp
+3
-1
hlsl.aliasOpaque.frag.out
Test/baseLegalResults/hlsl.aliasOpaque.frag.out
+0
-1
hlsl.flattenOpaque.frag.out
Test/baseLegalResults/hlsl.flattenOpaque.frag.out
+0
-1
hlsl.flattenOpaqueInit.vert.out
Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
+0
-1
hlsl.flattenOpaqueInitMix.vert.out
Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
+0
-1
hlsl.flattenSubset.frag.out
Test/baseLegalResults/hlsl.flattenSubset.frag.out
+0
-1
hlsl.flattenSubset2.frag.out
Test/baseLegalResults/hlsl.flattenSubset2.frag.out
+0
-1
hlsl.partialFlattenLocal.vert.out
Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
+0
-1
hlsl.partialFlattenMixed.vert.out
Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
+0
-1
ShaderLang.h
glslang/Public/ShaderLang.h
+1
-0
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+2
-2
TestFixture.cpp
gtests/TestFixture.cpp
+2
-0
TestFixture.h
gtests/TestFixture.h
+7
-5
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
6b1ede41
...
@@ -94,9 +94,10 @@ endif()
...
@@ -94,9 +94,10 @@ endif()
if
(
ENABLE_OPT
)
if
(
ENABLE_OPT
)
message
(
STATUS
"optimizer enabled"
)
message
(
STATUS
"optimizer enabled"
)
add_definitions
(
-DENABLE_OPT
)
add_definitions
(
-DENABLE_OPT
=1
)
elseif
(
ENABLE_HLSL
)
elseif
(
ENABLE_HLSL
)
message
(
STATUS
"spirv-tools not linked - illegal SPIRV may be generated for HLSL"
)
message
(
STATUS
"spirv-tools not linked - illegal SPIRV may be generated for HLSL"
)
add_definitions
(
-DENABLE_OPT=0
)
endif
()
endif
()
add_subdirectory
(
glslang
)
add_subdirectory
(
glslang
)
...
...
SPIRV/GlslangToSpv.cpp
View file @
6b1ede41
...
@@ -54,12 +54,12 @@ namespace spv {
...
@@ -54,12 +54,12 @@ namespace spv {
#endif
#endif
}
}
#if
def
ENABLE_OPT
#if ENABLE_OPT
#include "spirv-tools/optimizer.hpp"
#include "spirv-tools/optimizer.hpp"
#include "message.h"
#include "message.h"
#endif
#endif
#if
def
ENABLE_OPT
#if ENABLE_OPT
using
namespace
spvtools
;
using
namespace
spvtools
;
#endif
#endif
...
@@ -6757,7 +6757,7 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
...
@@ -6757,7 +6757,7 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
it
.
finishSpv
();
it
.
finishSpv
();
it
.
dumpSpv
(
spirv
);
it
.
dumpSpv
(
spirv
);
#if
def
ENABLE_OPT
#if ENABLE_OPT
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
// eg. forward and remove memory writes of opaque types.
if
((
intermediate
.
getSource
()
==
EShSourceHlsl
||
if
((
intermediate
.
getSource
()
==
EShSourceHlsl
||
...
...
StandAlone/StandAlone.cpp
View file @
6b1ede41
...
@@ -574,7 +574,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -574,7 +574,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
if
(
argv
[
0
][
2
]
==
'd'
)
if
(
argv
[
0
][
2
]
==
'd'
)
Options
|=
EOptionOptimizeDisable
;
Options
|=
EOptionOptimizeDisable
;
else
if
(
argv
[
0
][
2
]
==
's'
)
else
if
(
argv
[
0
][
2
]
==
's'
)
#if
def
ENABLE_OPT
#if ENABLE_OPT
Options
|=
EOptionOptimizeSize
;
Options
|=
EOptionOptimizeSize
;
#else
#else
Error
(
"-Os not available; optimizer not linked"
);
Error
(
"-Os not available; optimizer not linked"
);
...
@@ -720,6 +720,8 @@ void SetMessageOptions(EShMessages& messages)
...
@@ -720,6 +720,8 @@ void SetMessageOptions(EShMessages& messages)
messages
=
(
EShMessages
)(
messages
|
EShMsgDebugInfo
);
messages
=
(
EShMessages
)(
messages
|
EShMsgDebugInfo
);
if
(
HlslEnable16BitTypes
)
if
(
HlslEnable16BitTypes
)
messages
=
(
EShMessages
)(
messages
|
EShMsgHlslEnable16BitTypes
);
messages
=
(
EShMessages
)(
messages
|
EShMsgHlslEnable16BitTypes
);
if
((
Options
&
EOptionOptimizeDisable
)
||
!
ENABLE_OPT
)
messages
=
(
EShMessages
)(
messages
|
EShMsgHlslLegalization
);
}
}
//
//
...
...
Test/baseLegalResults/hlsl.aliasOpaque.frag.out
View file @
6b1ede41
hlsl.aliasOpaque.frag
hlsl.aliasOpaque.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 87
// Id's are bound by 87
...
...
Test/baseLegalResults/hlsl.flattenOpaque.frag.out
View file @
6b1ede41
hlsl.flattenOpaque.frag
hlsl.flattenOpaque.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 185
// Id's are bound by 185
...
...
Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
View file @
6b1ede41
hlsl.flattenOpaqueInit.vert
hlsl.flattenOpaqueInit.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 134
// Id's are bound by 134
...
...
Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
View file @
6b1ede41
hlsl.flattenOpaqueInitMix.vert
hlsl.flattenOpaqueInitMix.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 97
// Id's are bound by 97
...
...
Test/baseLegalResults/hlsl.flattenSubset.frag.out
View file @
6b1ede41
hlsl.flattenSubset.frag
hlsl.flattenSubset.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 66
// Id's are bound by 66
...
...
Test/baseLegalResults/hlsl.flattenSubset2.frag.out
View file @
6b1ede41
hlsl.flattenSubset2.frag
hlsl.flattenSubset2.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 53
// Id's are bound by 53
...
...
Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
View file @
6b1ede41
hlsl.partialFlattenLocal.vert
hlsl.partialFlattenLocal.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 169
// Id's are bound by 169
...
...
Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
View file @
6b1ede41
hlsl.partialFlattenMixed.vert
hlsl.partialFlattenMixed.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80006
// Generated by (magic number): 80006
// Id's are bound by 36
// Id's are bound by 36
...
...
glslang/Public/ShaderLang.h
View file @
6b1ede41
...
@@ -215,6 +215,7 @@ enum EShMessages {
...
@@ -215,6 +215,7 @@ enum EShMessages {
EShMsgHlslOffsets
=
(
1
<<
9
),
// allow block offsets to follow HLSL rules instead of GLSL rules
EShMsgHlslOffsets
=
(
1
<<
9
),
// allow block offsets to follow HLSL rules instead of GLSL rules
EShMsgDebugInfo
=
(
1
<<
10
),
// save debug information
EShMsgDebugInfo
=
(
1
<<
10
),
// save debug information
EShMsgHlslEnable16BitTypes
=
(
1
<<
11
),
// enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslEnable16BitTypes
=
(
1
<<
11
),
// enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization
=
(
1
<<
12
),
// enable HLSL Legalization messages
};
};
//
//
...
...
gtests/Hlsl.FromFile.cpp
View file @
6b1ede41
...
@@ -92,7 +92,7 @@ TEST_P(HlslLegalizeTest, FromFile)
...
@@ -92,7 +92,7 @@ TEST_P(HlslLegalizeTest, FromFile)
loadFileCompileAndCheck
(
GlobalTestSettings
.
testRoot
,
GetParam
().
fileName
,
loadFileCompileAndCheck
(
GlobalTestSettings
.
testRoot
,
GetParam
().
fileName
,
Source
::
HLSL
,
Semantics
::
Vulkan
,
glslang
::
EShTargetVulkan_1_0
,
Source
::
HLSL
,
Semantics
::
Vulkan
,
glslang
::
EShTargetVulkan_1_0
,
Target
::
Spv
,
true
,
GetParam
().
entryPoint
,
Target
::
Spv
,
true
,
GetParam
().
entryPoint
,
"/baseLegalResults/"
,
fals
e
);
"/baseLegalResults/"
,
tru
e
);
}
}
// clang-format off
// clang-format off
...
@@ -410,7 +410,7 @@ INSTANTIATE_TEST_CASE_P(
...
@@ -410,7 +410,7 @@ INSTANTIATE_TEST_CASE_P(
);
);
// clang-format on
// clang-format on
#if
def
ENABLE_OPT
#if ENABLE_OPT
// clang-format off
// clang-format off
INSTANTIATE_TEST_CASE_P
(
INSTANTIATE_TEST_CASE_P
(
ToSpirv
,
HlslLegalizeTest
,
ToSpirv
,
HlslLegalizeTest
,
...
...
gtests/TestFixture.cpp
View file @
6b1ede41
...
@@ -100,6 +100,8 @@ EShMessages DeriveOptions(Source source, Semantics semantics, Target target)
...
@@ -100,6 +100,8 @@ EShMessages DeriveOptions(Source source, Semantics semantics, Target target)
break
;
break
;
}
}
result
=
static_cast
<
EShMessages
>
(
result
|
EShMsgHlslLegalization
);
return
result
;
return
result
;
}
}
...
...
gtests/TestFixture.h
View file @
6b1ede41
...
@@ -200,7 +200,7 @@ public:
...
@@ -200,7 +200,7 @@ public:
glslang
::
EShTargetClientVersion
clientTargetVersion
,
glslang
::
EShTargetClientVersion
clientTargetVersion
,
bool
flattenUniformArrays
=
false
,
bool
flattenUniformArrays
=
false
,
EShTextureSamplerTransformMode
texSampTransMode
=
EShTexSampTransKeep
,
EShTextureSamplerTransformMode
texSampTransMode
=
EShTexSampTransKeep
,
bool
disableOptimizer
=
tru
e
,
bool
enableOptimizer
=
fals
e
,
bool
automap
=
true
)
bool
automap
=
true
)
{
{
const
EShLanguage
stage
=
GetShaderStage
(
GetSuffix
(
shaderName
));
const
EShLanguage
stage
=
GetShaderStage
(
GetSuffix
(
shaderName
));
...
@@ -242,7 +242,7 @@ public:
...
@@ -242,7 +242,7 @@ public:
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
SpvOptions
options
;
glslang
::
SpvOptions
options
;
options
.
disableOptimizer
=
dis
ableOptimizer
;
options
.
disableOptimizer
=
!
en
ableOptimizer
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
spirv_binary
,
&
logger
,
&
options
);
spirv_binary
,
&
logger
,
&
options
);
...
@@ -412,7 +412,7 @@ public:
...
@@ -412,7 +412,7 @@ public:
bool
automap
=
true
,
bool
automap
=
true
,
const
std
::
string
&
entryPointName
=
""
,
const
std
::
string
&
entryPointName
=
""
,
const
std
::
string
&
baseDir
=
"/baseResults/"
,
const
std
::
string
&
baseDir
=
"/baseResults/"
,
const
bool
disableOptimizer
=
tru
e
)
const
bool
enableOptimizer
=
fals
e
)
{
{
const
std
::
string
inputFname
=
testDir
+
"/"
+
testName
;
const
std
::
string
inputFname
=
testDir
+
"/"
+
testName
;
const
std
::
string
expectedOutputFname
=
const
std
::
string
expectedOutputFname
=
...
@@ -422,9 +422,11 @@ public:
...
@@ -422,9 +422,11 @@ public:
tryLoadFile
(
inputFname
,
"input"
,
&
input
);
tryLoadFile
(
inputFname
,
"input"
,
&
input
);
tryLoadFile
(
expectedOutputFname
,
"expected output"
,
&
expectedOutput
);
tryLoadFile
(
expectedOutputFname
,
"expected output"
,
&
expectedOutput
);
const
EShMessages
controls
=
DeriveOptions
(
source
,
semantics
,
target
);
EShMessages
controls
=
DeriveOptions
(
source
,
semantics
,
target
);
if
(
enableOptimizer
)
controls
=
static_cast
<
EShMessages
>
(
controls
&
~
EShMsgHlslLegalization
);
GlslangResult
result
=
compileAndLink
(
testName
,
input
,
entryPointName
,
controls
,
clientTargetVersion
,
false
,
GlslangResult
result
=
compileAndLink
(
testName
,
input
,
entryPointName
,
controls
,
clientTargetVersion
,
false
,
EShTexSampTransKeep
,
dis
ableOptimizer
,
automap
);
EShTexSampTransKeep
,
en
ableOptimizer
,
automap
);
// Generate the hybrid output in the way of glslangValidator.
// Generate the hybrid output in the way of glslangValidator.
std
::
ostringstream
stream
;
std
::
ostringstream
stream
;
...
...
hlsl/hlslParseHelper.cpp
View file @
6b1ede41
...
@@ -9924,7 +9924,7 @@ void HlslParseContext::finish()
...
@@ -9924,7 +9924,7 @@ void HlslParseContext::finish()
// Communicate out (esp. for command line) that we formed AST that will make
// Communicate out (esp. for command line) that we formed AST that will make
// illegal AST SPIR-V and it needs transforms to legalize it.
// illegal AST SPIR-V and it needs transforms to legalize it.
if
(
intermediate
.
needsLegalization
())
if
(
intermediate
.
needsLegalization
()
&&
(
messages
&
EShMsgHlslLegalization
)
)
infoSink
.
info
<<
"WARNING: AST will form illegal SPIR-V; need to transform to legalize"
;
infoSink
.
info
<<
"WARNING: AST will form illegal SPIR-V; need to transform to legalize"
;
TParseContextBase
::
finish
();
TParseContextBase
::
finish
();
...
...
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