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
b3e24e43
Commit
b3e24e43
authored
Sep 11, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Fix issue #506: generalize struct deep copy to include arrays.
parent
cd0a78a0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
20 deletions
+40
-20
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+37
-17
spv.multiStruct.comp.out
Test/baseResults/spv.multiStruct.comp.out
+0
-0
spv.multiStruct.comp
Test/spv.multiStruct.comp
+2
-2
revision.h
glslang/Include/revision.h
+1
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
b3e24e43
...
...
@@ -2283,13 +2283,13 @@ void TGlslangToSpvTraverser::accessChainStore(const glslang::TType& type, spv::I
// Implicitly uses the existing builder.accessChain as the storage target.
void
TGlslangToSpvTraverser
::
multiTypeStore
(
const
glslang
::
TType
&
type
,
spv
::
Id
rValue
)
{
// we only do the complex path here if it's a
structur
e
if
(
!
type
.
isStruct
())
{
// we only do the complex path here if it's a
n aggregat
e
if
(
!
type
.
isStruct
()
&&
!
type
.
isArray
()
)
{
accessChainStore
(
type
,
rValue
);
return
;
}
// and, it has to be a case of
structure
type aliasing
// and, it has to be a case of type aliasing
spv
::
Id
rType
=
builder
.
getTypeId
(
rValue
);
spv
::
Id
lValue
=
builder
.
accessChainGetLValue
();
spv
::
Id
lType
=
builder
.
getContainedTypeId
(
builder
.
getTypeId
(
lValue
));
...
...
@@ -2298,26 +2298,46 @@ void TGlslangToSpvTraverser::multiTypeStore(const glslang::TType& type, spv::Id
return
;
}
// Recursively (as needed) copy a
struct type to a different struct
type,
// Recursively (as needed) copy a
n aggregate type to a different aggregate
type,
// where the two types were the same type in GLSL. This requires member
// by member copy, recursively.
// loop over members
const
glslang
::
TTypeList
&
members
=
*
type
.
getStruct
();
for
(
int
m
=
0
;
m
<
(
int
)
members
.
size
();
++
m
)
{
const
glslang
::
TType
&
glslangMemberType
=
*
members
[
m
].
type
;
// If an array, copy element by element.
if
(
type
.
isArray
())
{
glslang
::
TType
glslangElementType
(
type
,
0
);
spv
::
Id
elementRType
=
builder
.
getContainedTypeId
(
rType
);
for
(
int
index
=
0
;
index
<
type
.
getOuterArraySize
();
++
index
)
{
// get the source member
spv
::
Id
elementRValue
=
builder
.
createCompositeExtract
(
rValue
,
elementRType
,
index
);
// get the source member
spv
::
Id
memberRType
=
builder
.
getContainedTypeId
(
rType
,
m
);
spv
::
Id
memberRValue
=
builder
.
createCompositeExtract
(
rValue
,
memberRType
,
m
);
// set up the target storage
builder
.
clearAccessChain
();
builder
.
setAccessChainLValue
(
lValue
);
builder
.
accessChainPush
(
builder
.
makeIntConstant
(
index
));
// set up the target storage
builder
.
clearAccessChain
();
builder
.
setAccessChainLValue
(
lValue
);
builder
.
accessChainPush
(
builder
.
makeIntConstant
(
m
));
// store the member
multiTypeStore
(
glslangElementType
,
elementRValue
);
}
}
else
{
assert
(
type
.
isStruct
());
// store the member
multiTypeStore
(
glslangMemberType
,
memberRValue
);
// loop over structure members
const
glslang
::
TTypeList
&
members
=
*
type
.
getStruct
();
for
(
int
m
=
0
;
m
<
(
int
)
members
.
size
();
++
m
)
{
const
glslang
::
TType
&
glslangMemberType
=
*
members
[
m
].
type
;
// get the source member
spv
::
Id
memberRType
=
builder
.
getContainedTypeId
(
rType
,
m
);
spv
::
Id
memberRValue
=
builder
.
createCompositeExtract
(
rValue
,
memberRType
,
m
);
// set up the target storage
builder
.
clearAccessChain
();
builder
.
setAccessChainLValue
(
lValue
);
builder
.
accessChainPush
(
builder
.
makeIntConstant
(
m
));
// store the member
multiTypeStore
(
glslangMemberType
,
memberRValue
);
}
}
}
...
...
Test/baseResults/spv.multiStruct.comp.out
View file @
b3e24e43
This diff is collapsed.
Click to expand it.
Test/spv.multiStruct.comp
View file @
b3e24e43
...
...
@@ -2,7 +2,7 @@
struct MyStruct
{
vec
4 foo
;
vec
2 foo[2]
;
bool sb;
};
...
...
@@ -23,7 +23,7 @@ layout(binding = 2, std140) uniform UBO
struct Nested {
float f;
MyStruct S;
MyStruct S
[2]
;
};
layout(binding = 2, std140) uniform UBON
...
...
glslang/Include/revision.h
View file @
b3e24e43
...
...
@@ -3,4 +3,4 @@
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1481"
#define GLSLANG_DATE "1
0
-Sep-2016"
#define GLSLANG_DATE "1
1
-Sep-2016"
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