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
fad62972
Commit
fad62972
authored
Jul 18, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Non-functional: support lists of decorations per parameter.
parent
37c202aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
10 deletions
+21
-10
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+13
-4
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+7
-5
SpvBuilder.h
SPIRV/SpvBuilder.h
+1
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
fad62972
...
@@ -2914,6 +2914,12 @@ bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate*
...
@@ -2914,6 +2914,12 @@ bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate*
// Make all the functions, skeletally, without actually visiting their bodies.
// Make all the functions, skeletally, without actually visiting their bodies.
void
TGlslangToSpvTraverser
::
makeFunctions
(
const
glslang
::
TIntermSequence
&
glslFunctions
)
void
TGlslangToSpvTraverser
::
makeFunctions
(
const
glslang
::
TIntermSequence
&
glslFunctions
)
{
{
const
auto
getParamDecorations
=
[](
std
::
vector
<
spv
::
Decoration
>&
decorations
,
const
glslang
::
TType
&
type
)
{
spv
::
Decoration
paramPrecision
=
TranslatePrecisionDecoration
(
type
);
if
(
paramPrecision
!=
spv
::
NoPrecision
)
decorations
.
push_back
(
paramPrecision
);
};
for
(
int
f
=
0
;
f
<
(
int
)
glslFunctions
.
size
();
++
f
)
{
for
(
int
f
=
0
;
f
<
(
int
)
glslFunctions
.
size
();
++
f
)
{
glslang
::
TIntermAggregate
*
glslFunction
=
glslFunctions
[
f
]
->
getAsAggregate
();
glslang
::
TIntermAggregate
*
glslFunction
=
glslFunctions
[
f
]
->
getAsAggregate
();
if
(
!
glslFunction
||
glslFunction
->
getOp
()
!=
glslang
::
EOpFunction
||
isShaderEntryPoint
(
glslFunction
))
if
(
!
glslFunction
||
glslFunction
->
getOp
()
!=
glslang
::
EOpFunction
||
isShaderEntryPoint
(
glslFunction
))
...
@@ -2934,11 +2940,13 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
...
@@ -2934,11 +2940,13 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
// GLSL has copy-in/copy-out semantics. They can be handled though with a pointer to a copy.
// GLSL has copy-in/copy-out semantics. They can be handled though with a pointer to a copy.
std
::
vector
<
spv
::
Id
>
paramTypes
;
std
::
vector
<
spv
::
Id
>
paramTypes
;
std
::
vector
<
s
pv
::
Decoration
>
paramPrecisions
;
std
::
vector
<
s
td
::
vector
<
spv
::
Decoration
>>
paramDecorations
;
// list of decorations per parameter
glslang
::
TIntermSequence
&
parameters
=
glslFunction
->
getSequence
()[
0
]
->
getAsAggregate
()
->
getSequence
();
glslang
::
TIntermSequence
&
parameters
=
glslFunction
->
getSequence
()[
0
]
->
getAsAggregate
()
->
getSequence
();
bool
implicitThis
=
(
int
)
parameters
.
size
()
>
0
&&
parameters
[
0
]
->
getAsSymbolNode
()
->
getName
()
==
glslangIntermediate
->
implicitThisName
;
bool
implicitThis
=
(
int
)
parameters
.
size
()
>
0
&&
parameters
[
0
]
->
getAsSymbolNode
()
->
getName
()
==
glslangIntermediate
->
implicitThisName
;
paramDecorations
.
resize
(
parameters
.
size
());
for
(
int
p
=
0
;
p
<
(
int
)
parameters
.
size
();
++
p
)
{
for
(
int
p
=
0
;
p
<
(
int
)
parameters
.
size
();
++
p
)
{
const
glslang
::
TType
&
paramType
=
parameters
[
p
]
->
getAsTyped
()
->
getType
();
const
glslang
::
TType
&
paramType
=
parameters
[
p
]
->
getAsTyped
()
->
getType
();
spv
::
Id
typeId
=
convertGlslangToSpvType
(
paramType
);
spv
::
Id
typeId
=
convertGlslangToSpvType
(
paramType
);
...
@@ -2952,14 +2960,15 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
...
@@ -2952,14 +2960,15 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
typeId
=
builder
.
makePointer
(
spv
::
StorageClassFunction
,
typeId
);
typeId
=
builder
.
makePointer
(
spv
::
StorageClassFunction
,
typeId
);
else
else
rValueParameters
.
insert
(
parameters
[
p
]
->
getAsSymbolNode
()
->
getId
());
rValueParameters
.
insert
(
parameters
[
p
]
->
getAsSymbolNode
()
->
getId
());
paramPrecisions
.
push_back
(
TranslatePrecisionDecoration
(
paramType
)
);
getParamDecorations
(
paramDecorations
[
p
],
paramType
);
paramTypes
.
push_back
(
typeId
);
paramTypes
.
push_back
(
typeId
);
}
}
spv
::
Block
*
functionBlock
;
spv
::
Block
*
functionBlock
;
spv
::
Function
*
function
=
builder
.
makeFunctionEntry
(
TranslatePrecisionDecoration
(
glslFunction
->
getType
()),
spv
::
Function
*
function
=
builder
.
makeFunctionEntry
(
TranslatePrecisionDecoration
(
glslFunction
->
getType
()),
convertGlslangToSpvType
(
glslFunction
->
getType
()),
convertGlslangToSpvType
(
glslFunction
->
getType
()),
glslFunction
->
getName
().
c_str
(),
paramTypes
,
paramPrecisions
,
&
functionBlock
);
glslFunction
->
getName
().
c_str
(),
paramTypes
,
paramDecorations
,
&
functionBlock
);
if
(
implicitThis
)
if
(
implicitThis
)
function
->
setImplicitThis
();
function
->
setImplicitThis
();
...
...
SPIRV/SpvBuilder.cpp
View file @
fad62972
...
@@ -983,16 +983,16 @@ Function* Builder::makeEntryPoint(const char* entryPoint)
...
@@ -983,16 +983,16 @@ Function* Builder::makeEntryPoint(const char* entryPoint)
Block
*
entry
;
Block
*
entry
;
std
::
vector
<
Id
>
params
;
std
::
vector
<
Id
>
params
;
std
::
vector
<
Decoration
>
precis
ions
;
std
::
vector
<
std
::
vector
<
Decoration
>>
decorat
ions
;
entryPointFunction
=
makeFunctionEntry
(
NoPrecision
,
makeVoidType
(),
entryPoint
,
params
,
precis
ions
,
&
entry
);
entryPointFunction
=
makeFunctionEntry
(
NoPrecision
,
makeVoidType
(),
entryPoint
,
params
,
decorat
ions
,
&
entry
);
return
entryPointFunction
;
return
entryPointFunction
;
}
}
// Comments in header
// Comments in header
Function
*
Builder
::
makeFunctionEntry
(
Decoration
precision
,
Id
returnType
,
const
char
*
name
,
Function
*
Builder
::
makeFunctionEntry
(
Decoration
precision
,
Id
returnType
,
const
char
*
name
,
const
std
::
vector
<
Id
>&
paramTypes
,
const
std
::
vector
<
Decoration
>&
precis
ions
,
Block
**
entry
)
const
std
::
vector
<
Id
>&
paramTypes
,
const
std
::
vector
<
std
::
vector
<
Decoration
>>&
decorat
ions
,
Block
**
entry
)
{
{
// Make the function and initial instructions in it
// Make the function and initial instructions in it
Id
typeId
=
makeFunctionType
(
returnType
,
paramTypes
);
Id
typeId
=
makeFunctionType
(
returnType
,
paramTypes
);
...
@@ -1001,8 +1001,10 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
...
@@ -1001,8 +1001,10 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
// Set up the precisions
// Set up the precisions
setPrecision
(
function
->
getId
(),
precision
);
setPrecision
(
function
->
getId
(),
precision
);
for
(
unsigned
p
=
0
;
p
<
(
unsigned
)
precisions
.
size
();
++
p
)
for
(
unsigned
p
=
0
;
p
<
(
unsigned
)
decorations
.
size
();
++
p
)
{
setPrecision
(
firstParamId
+
p
,
precisions
[
p
]);
for
(
int
d
=
0
;
d
<
(
int
)
decorations
[
p
].
size
();
++
d
)
addDecoration
(
firstParamId
+
p
,
decorations
[
p
][
d
]);
}
// CFG
// CFG
if
(
entry
)
{
if
(
entry
)
{
...
...
SPIRV/SpvBuilder.h
View file @
fad62972
...
@@ -247,7 +247,7 @@ public:
...
@@ -247,7 +247,7 @@ public:
// Return the function, pass back the entry.
// Return the function, pass back the entry.
// The returned pointer is only valid for the lifetime of this builder.
// The returned pointer is only valid for the lifetime of this builder.
Function
*
makeFunctionEntry
(
Decoration
precision
,
Id
returnType
,
const
char
*
name
,
const
std
::
vector
<
Id
>&
paramTypes
,
Function
*
makeFunctionEntry
(
Decoration
precision
,
Id
returnType
,
const
char
*
name
,
const
std
::
vector
<
Id
>&
paramTypes
,
const
std
::
vector
<
Decoration
>&
precisions
,
Block
**
entry
=
0
);
const
std
::
vector
<
std
::
vector
<
Decoration
>
>&
precisions
,
Block
**
entry
=
0
);
// Create a return. An 'implicit' return is one not appearing in the source
// Create a return. An 'implicit' return is one not appearing in the source
// code. In the case of an implicit return, no post-return block is inserted.
// code. In the case of an implicit return, no post-return block is inserted.
...
...
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