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
17535f7d
Commit
17535f7d
authored
May 04, 2016
by
Lei Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a new logger class for all messages w.r.t. SPIR-V build.
parent
09caf12b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
183 additions
and
60 deletions
+183
-60
CMakeLists.txt
SPIRV/CMakeLists.txt
+2
-0
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+22
-25
GlslangToSpv.h
SPIRV/GlslangToSpv.h
+6
-1
Logger.cpp
SPIRV/Logger.cpp
+68
-0
Logger.h
SPIRV/Logger.h
+73
-0
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+3
-18
SpvBuilder.h
SPIRV/SpvBuilder.h
+3
-8
StandAlone.cpp
StandAlone/StandAlone.cpp
+3
-2
spv.int64.frag.out
Test/baseResults/spv.int64.frag.out
+0
-3
TestFixture.h
gtests/TestFixture.h
+3
-3
No files found.
SPIRV/CMakeLists.txt
View file @
17535f7d
set
(
SOURCES
set
(
SOURCES
GlslangToSpv.cpp
GlslangToSpv.cpp
InReadableOrder.cpp
InReadableOrder.cpp
Logger.cpp
SpvBuilder.cpp
SpvBuilder.cpp
SPVRemapper.cpp
SPVRemapper.cpp
doc.cpp
doc.cpp
...
@@ -10,6 +11,7 @@ set(HEADERS
...
@@ -10,6 +11,7 @@ set(HEADERS
spirv.hpp
spirv.hpp
GLSL.std.450.h
GLSL.std.450.h
GlslangToSpv.h
GlslangToSpv.h
Logger.h
SpvBuilder.h
SpvBuilder.h
SPVRemapper.h
SPVRemapper.h
spvIR.h
spvIR.h
...
...
SPIRV/GlslangToSpv.cpp
View file @
17535f7d
...
@@ -52,12 +52,12 @@ namespace spv {
...
@@ -52,12 +52,12 @@ namespace spv {
#include "../glslang/MachineIndependent/SymbolTable.h"
#include "../glslang/MachineIndependent/SymbolTable.h"
#include "../glslang/Include/Common.h"
#include "../glslang/Include/Common.h"
#include <string>
#include <fstream>
#include <map>
#include <list>
#include <list>
#include <
vector
>
#include <
map
>
#include <stack>
#include <stack>
#include <fstream>
#include <string>
#include <vector>
namespace
{
namespace
{
...
@@ -94,7 +94,7 @@ private:
...
@@ -94,7 +94,7 @@ private:
//
//
class
TGlslangToSpvTraverser
:
public
glslang
::
TIntermTraverser
{
class
TGlslangToSpvTraverser
:
public
glslang
::
TIntermTraverser
{
public
:
public
:
TGlslangToSpvTraverser
(
const
glslang
::
TIntermediate
*
);
TGlslangToSpvTraverser
(
const
glslang
::
TIntermediate
*
,
spv
::
SpvBuildLogger
*
logger
);
virtual
~
TGlslangToSpvTraverser
();
virtual
~
TGlslangToSpvTraverser
();
bool
visitAggregate
(
glslang
::
TVisit
,
glslang
::
TIntermAggregate
*
);
bool
visitAggregate
(
glslang
::
TVisit
,
glslang
::
TIntermAggregate
*
);
...
@@ -109,8 +109,6 @@ public:
...
@@ -109,8 +109,6 @@ public:
void
dumpSpv
(
std
::
vector
<
unsigned
int
>&
out
);
void
dumpSpv
(
std
::
vector
<
unsigned
int
>&
out
);
std
::
string
getWarningsAndErrors
()
const
{
return
warningsErrors
.
str
();
}
protected
:
protected
:
spv
::
Decoration
TranslateInterpolationDecoration
(
const
glslang
::
TQualifier
&
qualifier
);
spv
::
Decoration
TranslateInterpolationDecoration
(
const
glslang
::
TQualifier
&
qualifier
);
spv
::
BuiltIn
TranslateBuiltInDecoration
(
glslang
::
TBuiltInVariable
);
spv
::
BuiltIn
TranslateBuiltInDecoration
(
glslang
::
TBuiltInVariable
);
...
@@ -161,7 +159,7 @@ protected:
...
@@ -161,7 +159,7 @@ protected:
spv
::
Instruction
*
entryPoint
;
spv
::
Instruction
*
entryPoint
;
int
sequenceDepth
;
int
sequenceDepth
;
s
td
::
ostringstream
warningsErrors
;
s
pv
::
SpvBuildLogger
*
logger
;
// There is a 1:1 mapping between a spv builder and a module; this is thread safe
// There is a 1:1 mapping between a spv builder and a module; this is thread safe
spv
::
Builder
builder
;
spv
::
Builder
builder
;
...
@@ -437,7 +435,7 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
...
@@ -437,7 +435,7 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
case
glslang
:
:
EbvBaseInstance
:
case
glslang
:
:
EbvBaseInstance
:
case
glslang
:
:
EbvDrawId
:
case
glslang
:
:
EbvDrawId
:
// TODO: Add SPIR-V builtin ID.
// TODO: Add SPIR-V builtin ID.
spv
::
MissingFunctionality
(
warningsErrors
,
"Draw parameters"
);
logger
->
missingFunctionality
(
"Draw parameters"
);
return
(
spv
::
BuiltIn
)
spv
::
BadValue
;
return
(
spv
::
BuiltIn
)
spv
::
BadValue
;
case
glslang
:
:
EbvPrimitiveId
:
return
spv
::
BuiltInPrimitiveId
;
case
glslang
:
:
EbvPrimitiveId
:
return
spv
::
BuiltInPrimitiveId
;
case
glslang
:
:
EbvInvocationId
:
return
spv
::
BuiltInInvocationId
;
case
glslang
:
:
EbvInvocationId
:
return
spv
::
BuiltInInvocationId
;
...
@@ -610,9 +608,9 @@ bool HasNonLayoutQualifiers(const glslang::TQualifier& qualifier)
...
@@ -610,9 +608,9 @@ bool HasNonLayoutQualifiers(const glslang::TQualifier& qualifier)
// Implement the TGlslangToSpvTraverser class.
// Implement the TGlslangToSpvTraverser class.
//
//
TGlslangToSpvTraverser
::
TGlslangToSpvTraverser
(
const
glslang
::
TIntermediate
*
glslangIntermediate
)
TGlslangToSpvTraverser
::
TGlslangToSpvTraverser
(
const
glslang
::
TIntermediate
*
glslangIntermediate
,
spv
::
SpvBuildLogger
*
buildLogger
)
:
TIntermTraverser
(
true
,
false
,
true
),
shaderEntry
(
0
),
sequenceDepth
(
0
),
:
TIntermTraverser
(
true
,
false
,
true
),
shaderEntry
(
0
),
sequenceDepth
(
0
),
logger
(
buildLogger
),
builder
((
glslang
::
GetKhronosToolId
()
<<
16
)
|
GeneratorVersion
,
warningsErrors
),
builder
((
glslang
::
GetKhronosToolId
()
<<
16
)
|
GeneratorVersion
,
logger
),
inMain
(
false
),
mainTerminated
(
false
),
linkageOnly
(
false
),
inMain
(
false
),
mainTerminated
(
false
),
linkageOnly
(
false
),
glslangIntermediate
(
glslangIntermediate
)
glslangIntermediate
(
glslangIntermediate
)
{
{
...
@@ -988,7 +986,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
...
@@ -988,7 +986,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
builder
.
clearAccessChain
();
builder
.
clearAccessChain
();
if
(
!
result
)
{
if
(
!
result
)
{
spv
::
MissingFunctionality
(
warningsErrors
,
"unknown glslang binary operation"
);
logger
->
missingFunctionality
(
"unknown glslang binary operation"
);
return
true
;
// pick up a child as the place-holder result
return
true
;
// pick up a child as the place-holder result
}
else
{
}
else
{
builder
.
setAccessChainRValue
(
result
);
builder
.
setAccessChainRValue
(
result
);
...
@@ -1113,7 +1111,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
...
@@ -1113,7 +1111,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
return
false
;
return
false
;
default
:
default
:
spv
::
MissingFunctionality
(
warningsErrors
,
"unknown glslang unary"
);
logger
->
missingFunctionality
(
"unknown glslang unary"
);
return
true
;
// pick up operand as placeholder result
return
true
;
// pick up operand as placeholder result
}
}
}
}
...
@@ -1224,7 +1222,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
...
@@ -1224,7 +1222,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
builder
.
clearAccessChain
();
builder
.
clearAccessChain
();
builder
.
setAccessChainRValue
(
result
);
builder
.
setAccessChainRValue
(
result
);
}
else
}
else
spv
::
MissingFunctionality
(
warningsErrors
,
"missing user function; linker needs to catch that"
);
logger
->
missingFunctionality
(
"missing user function; linker needs to catch that"
);
return
false
;
return
false
;
}
}
...
@@ -1472,7 +1470,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
...
@@ -1472,7 +1470,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
return
false
;
return
false
;
if
(
!
result
)
{
if
(
!
result
)
{
spv
::
MissingFunctionality
(
warningsErrors
,
"unknown glslang aggregate"
);
logger
->
missingFunctionality
(
"unknown glslang aggregate"
);
return
true
;
// pick up a child as a placeholder operand
return
true
;
// pick up a child as a placeholder operand
}
else
{
}
else
{
builder
.
clearAccessChain
();
builder
.
clearAccessChain
();
...
@@ -1765,7 +1763,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1765,7 +1763,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType
=
builder
.
makeUintType
(
64
);
spvType
=
builder
.
makeUintType
(
64
);
break
;
break
;
case
glslang
:
:
EbtAtomicUint
:
case
glslang
:
:
EbtAtomicUint
:
spv
::
TbdFunctionality
(
warningsErrors
,
"Is atomic_uint an opaque handle in the uniform storage class, or an addresses in the atomic storage class?"
);
logger
->
tbdFunctionality
(
"Is atomic_uint an opaque handle in the uniform storage class, or an addresses in the atomic storage class?"
);
spvType
=
builder
.
makeUintType
(
32
);
spvType
=
builder
.
makeUintType
(
32
);
break
;
break
;
case
glslang
:
:
EbtSampler
:
case
glslang
:
:
EbtSampler
:
...
@@ -3151,7 +3149,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
...
@@ -3151,7 +3149,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
case
glslang
:
:
EOpUnpackInt2x32
:
case
glslang
:
:
EOpUnpackInt2x32
:
case
glslang
:
:
EOpPackUint2x32
:
case
glslang
:
:
EOpPackUint2x32
:
case
glslang
:
:
EOpUnpackUint2x32
:
case
glslang
:
:
EOpUnpackUint2x32
:
spv
::
MissingFunctionality
(
warningsErrors
,
"shader int64"
);
logger
->
missingFunctionality
(
"shader int64"
);
libCall
=
spv
::
GLSLstd450Bad
;
// TODO: This is a placeholder.
libCall
=
spv
::
GLSLstd450Bad
;
// TODO: This is a placeholder.
break
;
break
;
...
@@ -3782,7 +3780,7 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op)
...
@@ -3782,7 +3780,7 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op)
builder
.
createMemoryBarrier
(
spv
::
ScopeDevice
,
spv
::
MemorySemanticsCrossWorkgroupMemoryMask
);
builder
.
createMemoryBarrier
(
spv
::
ScopeDevice
,
spv
::
MemorySemanticsCrossWorkgroupMemoryMask
);
return
0
;
return
0
;
default
:
default
:
spv
::
MissingFunctionality
(
warningsErrors
,
"unknown operation with no arguments"
);
logger
->
missingFunctionality
(
"unknown operation with no arguments"
);
return
0
;
return
0
;
}
}
}
}
...
@@ -3943,7 +3941,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
...
@@ -3943,7 +3941,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
// Neither a front-end constant node, nor a specialization constant node with constant union array or
// Neither a front-end constant node, nor a specialization constant node with constant union array or
// constant sub tree as initializer.
// constant sub tree as initializer.
spv
::
MissingFunctionality
(
warningsErrors
,
"Neither a front-end constant nor a spec constant."
);
logger
->
missingFunctionality
(
"Neither a front-end constant nor a spec constant."
);
exit
(
1
);
exit
(
1
);
return
spv
::
NoResult
;
return
spv
::
NoResult
;
}
}
...
@@ -4198,10 +4196,11 @@ void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName)
...
@@ -4198,10 +4196,11 @@ void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName)
//
//
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
)
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
)
{
{
GlslangToSpv
(
intermediate
,
spirv
,
nullptr
);
spv
::
SpvBuildLogger
logger
;
GlslangToSpv
(
intermediate
,
spirv
,
&
logger
);
}
}
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
s
td
::
string
*
messages
)
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
s
pv
::
SpvBuildLogger
*
logger
)
{
{
TIntermNode
*
root
=
intermediate
.
getTreeRoot
();
TIntermNode
*
root
=
intermediate
.
getTreeRoot
();
...
@@ -4210,14 +4209,12 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
...
@@ -4210,14 +4209,12 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
glslang
::
GetThreadPoolAllocator
().
push
();
glslang
::
GetThreadPoolAllocator
().
push
();
TGlslangToSpvTraverser
it
(
&
intermediate
);
TGlslangToSpvTraverser
it
(
&
intermediate
,
logger
);
root
->
traverse
(
&
it
);
root
->
traverse
(
&
it
);
it
.
dumpSpv
(
spirv
);
it
.
dumpSpv
(
spirv
);
if
(
messages
!=
nullptr
)
*
messages
=
it
.
getWarningsAndErrors
();
glslang
::
GetThreadPoolAllocator
().
pop
();
glslang
::
GetThreadPoolAllocator
().
pop
();
}
}
...
...
SPIRV/GlslangToSpv.h
View file @
17535f7d
...
@@ -34,11 +34,16 @@
...
@@ -34,11 +34,16 @@
#include "../glslang/Include/intermediate.h"
#include "../glslang/Include/intermediate.h"
#include <string>
#include <vector>
#include "Logger.h"
namespace
glslang
{
namespace
glslang
{
void
GetSpirvVersion
(
std
::
string
&
);
void
GetSpirvVersion
(
std
::
string
&
);
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
);
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
);
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
s
td
::
string
*
messages
);
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
s
pv
::
SpvBuildLogger
*
logger
);
void
OutputSpv
(
const
std
::
vector
<
unsigned
int
>&
spirv
,
const
char
*
baseName
);
void
OutputSpv
(
const
std
::
vector
<
unsigned
int
>&
spirv
,
const
char
*
baseName
);
}
}
SPIRV/Logger.cpp
0 → 100644
View file @
17535f7d
//
// Copyright (C) 2016 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include "Logger.h"
#include <algorithm>
#include <iterator>
#include <sstream>
namespace
spv
{
void
SpvBuildLogger
::
tbdFunctionality
(
const
char
*
f
)
{
if
(
std
::
find
(
std
::
begin
(
tbdFeatures
),
std
::
end
(
tbdFeatures
),
f
)
==
std
::
end
(
tbdFeatures
))
tbdFeatures
.
push_back
(
f
);
}
void
SpvBuildLogger
::
missingFunctionality
(
const
char
*
f
)
{
if
(
std
::
find
(
std
::
begin
(
missingFeatures
),
std
::
end
(
missingFeatures
),
f
)
==
std
::
end
(
missingFeatures
))
missingFeatures
.
push_back
(
f
);
}
std
::
string
SpvBuildLogger
::
getAllMessages
()
const
{
std
::
ostringstream
messages
;
for
(
const
auto
&
f
:
tbdFeatures
)
messages
<<
"TBD functionality: "
<<
f
<<
"
\n
"
;
for
(
const
auto
&
f
:
missingFeatures
)
messages
<<
"Missing functionality: "
<<
f
<<
"
\n
"
;
for
(
const
auto
&
w
:
warnings
)
messages
<<
"warning: "
<<
w
<<
"
\n
"
;
for
(
const
auto
&
e
:
errors
)
messages
<<
"error: "
<<
e
<<
"
\n
"
;
return
messages
.
str
();
}
}
// end spv namespace
SPIRV/Logger.h
0 → 100644
View file @
17535f7d
//
// Copyright (C) 2016 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#ifndef GLSLANG_SPIRV_LOGGER_H
#define GLSLANG_SPIRV_LOGGER_H
#include <string>
#include <vector>
namespace
spv
{
// A class for holding all SPIR-V build status messages, including
// missing/TBD functionalities, warnings, and errors.
class
SpvBuildLogger
{
public
:
SpvBuildLogger
()
=
default
;
SpvBuildLogger
(
const
SpvBuildLogger
&
)
=
delete
;
// Registers a TBD functionality.
void
tbdFunctionality
(
const
char
*
f
);
// Registers a missing functionality.
void
missingFunctionality
(
const
char
*
f
);
// Logs a warning.
void
warning
(
const
std
::
string
&
w
)
{
warnings
.
push_back
(
w
);
}
// Logs an error.
void
error
(
const
std
::
string
&
e
)
{
errors
.
push_back
(
e
);
}
// Returns all messages accumulated in the order of:
// TBD functionalities, missing functionalities, warnings, errors.
std
::
string
getAllMessages
()
const
;
private
:
std
::
vector
<
const
char
*>
tbdFeatures
;
std
::
vector
<
const
char
*>
missingFeatures
;
std
::
vector
<
std
::
string
>
warnings
;
std
::
vector
<
std
::
string
>
errors
;
};
}
// end spv namespace
#endif // GLSLANG_SPIRV_LOGGER_H
SPIRV/SpvBuilder.cpp
View file @
17535f7d
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
namespace
spv
{
namespace
spv
{
Builder
::
Builder
(
unsigned
int
magicNumber
,
std
::
ostringstream
&
warnErro
r
)
:
Builder
::
Builder
(
unsigned
int
magicNumber
,
SpvBuildLogger
*
buildLogge
r
)
:
source
(
SourceLanguageUnknown
),
source
(
SourceLanguageUnknown
),
sourceVersion
(
0
),
sourceVersion
(
0
),
addressModel
(
AddressingModelLogical
),
addressModel
(
AddressingModelLogical
),
...
@@ -66,7 +66,7 @@ Builder::Builder(unsigned int magicNumber, std::ostringstream& warnError) :
...
@@ -66,7 +66,7 @@ Builder::Builder(unsigned int magicNumber, std::ostringstream& warnError) :
uniqueId
(
0
),
uniqueId
(
0
),
mainFunction
(
0
),
mainFunction
(
0
),
generatingOpCodeForSpecConst
(
false
),
generatingOpCodeForSpecConst
(
false
),
warningsErrors
(
warnErro
r
)
logger
(
buildLogge
r
)
{
{
clearAccessChain
();
clearAccessChain
();
}
}
...
@@ -2111,7 +2111,7 @@ void Builder::accessChainStore(Id rvalue)
...
@@ -2111,7 +2111,7 @@ void Builder::accessChainStore(Id rvalue)
Id
base
=
collapseAccessChain
();
Id
base
=
collapseAccessChain
();
if
(
accessChain
.
swizzle
.
size
()
&&
accessChain
.
component
!=
NoResult
)
if
(
accessChain
.
swizzle
.
size
()
&&
accessChain
.
component
!=
NoResult
)
MissingFunctionality
(
warningsErrors
,
"simultaneous l-value swizzle and dynamic component selection"
);
logger
->
missingFunctionality
(
"simultaneous l-value swizzle and dynamic component selection"
);
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
// extract and insert elements to perform writeMask and/or swizzle.
// extract and insert elements to perform writeMask and/or swizzle.
...
@@ -2487,19 +2487,4 @@ void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector
...
@@ -2487,19 +2487,4 @@ void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector
}
}
}
}
void
TbdFunctionality
(
std
::
ostringstream
&
stream
,
const
char
*
tbd
)
{
static
std
::
unordered_set
<
const
char
*>
issued
;
if
(
issued
.
find
(
tbd
)
==
issued
.
end
())
{
stream
<<
"TBD functionality: "
<<
tbd
<<
"
\n
"
;
issued
.
insert
(
tbd
);
}
}
void
MissingFunctionality
(
std
::
ostringstream
&
stream
,
const
char
*
fun
)
{
stream
<<
"Missing functionality: "
<<
fun
<<
"
\n
"
;
}
};
// end spv namespace
};
// end spv namespace
SPIRV/SpvBuilder.h
View file @
17535f7d
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
#ifndef SpvBuilder_H
#ifndef SpvBuilder_H
#define SpvBuilder_H
#define SpvBuilder_H
#include "Logger.h"
#include "spirv.hpp"
#include "spirv.hpp"
#include "spvIR.h"
#include "spvIR.h"
...
@@ -63,7 +64,7 @@ namespace spv {
...
@@ -63,7 +64,7 @@ namespace spv {
class
Builder
{
class
Builder
{
public
:
public
:
Builder
(
unsigned
int
userNumber
,
std
::
ostringstream
&
warnErro
r
);
Builder
(
unsigned
int
userNumber
,
SpvBuildLogger
*
logge
r
);
virtual
~
Builder
();
virtual
~
Builder
();
static
const
int
maxMatrixSize
=
4
;
static
const
int
maxMatrixSize
=
4
;
...
@@ -583,15 +584,9 @@ public:
...
@@ -583,15 +584,9 @@ public:
std
::
stack
<
LoopBlocks
>
loops
;
std
::
stack
<
LoopBlocks
>
loops
;
// The stream for outputing warnings and errors.
// The stream for outputing warnings and errors.
std
::
ostringstream
&
warningsErrors
;
SpvBuildLogger
*
logger
;
};
// end Builder class
};
// end Builder class
// Use for non-fatal notes about what's not complete
void
TbdFunctionality
(
std
::
ostringstream
&
,
const
char
*
);
// Use for fatal missing functionality
void
MissingFunctionality
(
std
::
ostringstream
&
,
const
char
*
);
};
// end spv namespace
};
// end spv namespace
#endif // SpvBuilder_H
#endif // SpvBuilder_H
StandAlone/StandAlone.cpp
View file @
17535f7d
...
@@ -672,12 +672,13 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -672,12 +672,13 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if
(
program
.
getIntermediate
((
EShLanguage
)
stage
))
{
if
(
program
.
getIntermediate
((
EShLanguage
)
stage
))
{
std
::
vector
<
unsigned
int
>
spirv
;
std
::
vector
<
unsigned
int
>
spirv
;
std
::
string
warningsErrors
;
std
::
string
warningsErrors
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
((
EShLanguage
)
stage
),
spirv
,
&
warningsErrors
);
spv
::
SpvBuildLogger
logger
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
((
EShLanguage
)
stage
),
spirv
,
&
logger
);
// Dump the spv to a file or stdout, etc., but only if not doing
// Dump the spv to a file or stdout, etc., but only if not doing
// memory/perf testing, as it's not internal to programmatic use.
// memory/perf testing, as it's not internal to programmatic use.
if
(
!
(
Options
&
EOptionMemoryLeakMode
))
{
if
(
!
(
Options
&
EOptionMemoryLeakMode
))
{
printf
(
"%s"
,
warningsErrors
.
c_str
());
printf
(
"%s"
,
logger
.
getAllMessages
()
.
c_str
());
glslang
::
OutputSpv
(
spirv
,
GetBinaryName
((
EShLanguage
)
stage
));
glslang
::
OutputSpv
(
spirv
,
GetBinaryName
((
EShLanguage
)
stage
));
if
(
Options
&
EOptionHumanReadableSpv
)
{
if
(
Options
&
EOptionHumanReadableSpv
)
{
spv
::
Disassemble
(
std
::
cout
,
spirv
);
spv
::
Disassemble
(
std
::
cout
,
spirv
);
...
...
Test/baseResults/spv.int64.frag.out
View file @
17535f7d
...
@@ -6,9 +6,6 @@ Linked fragment stage:
...
@@ -6,9 +6,6 @@ Linked fragment stage:
Missing functionality: shader int64
Missing functionality: shader int64
Missing functionality: shader int64
Missing functionality: shader int64
Missing functionality: shader int64
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by 455
// Id's are bound by 455
...
...
gtests/TestFixture.h
View file @
17535f7d
...
@@ -188,19 +188,19 @@ public:
...
@@ -188,19 +188,19 @@ public:
program
.
addShader
(
&
shader
);
program
.
addShader
(
&
shader
);
success
&=
program
.
link
(
messages
);
success
&=
program
.
link
(
messages
);
s
td
::
string
spirvWarningsErrors
;
s
pv
::
SpvBuildLogger
logger
;
if
(
success
&&
target
==
Target
::
Spirv
)
{
if
(
success
&&
target
==
Target
::
Spirv
)
{
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
language
),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
language
),
spirv_binary
,
&
spirvWarningsErrors
);
spirv_binary
,
&
logger
);
std
::
ostringstream
disassembly_stream
;
std
::
ostringstream
disassembly_stream
;
spv
::
Parameterize
();
spv
::
Parameterize
();
spv
::
Disassemble
(
disassembly_stream
,
spirv_binary
);
spv
::
Disassemble
(
disassembly_stream
,
spirv_binary
);
return
{
shader
.
getInfoLog
(),
shader
.
getInfoDebugLog
(),
return
{
shader
.
getInfoLog
(),
shader
.
getInfoDebugLog
(),
program
.
getInfoLog
(),
program
.
getInfoDebugLog
(),
program
.
getInfoLog
(),
program
.
getInfoDebugLog
(),
spirvWarningsErrors
,
disassembly_stream
.
str
()};
logger
.
getAllMessages
()
,
disassembly_stream
.
str
()};
}
else
{
}
else
{
return
{
shader
.
getInfoLog
(),
shader
.
getInfoDebugLog
(),
return
{
shader
.
getInfoLog
(),
shader
.
getInfoDebugLog
(),
program
.
getInfoLog
(),
program
.
getInfoDebugLog
(),
program
.
getInfoLog
(),
program
.
getInfoDebugLog
(),
...
...
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