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
af201e8a
Commit
af201e8a
authored
Dec 29, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch GitHub 'master' into GitLab master
parents
4c42a976
c9e0a42b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
133 additions
and
86 deletions
+133
-86
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+46
-26
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+12
-7
SpvBuilder.h
SPIRV/SpvBuilder.h
+1
-1
spv.140.frag.out
Test/baseResults/spv.140.frag.out
+41
-40
spv.layoutNested.vert.out
Test/baseResults/spv.layoutNested.vert.out
+0
-0
Types.h
glslang/Include/Types.h
+4
-0
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+2
-1
linkValidate.cpp
glslang/MachineIndependent/linkValidate.cpp
+22
-8
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+1
-1
reflection.cpp
glslang/MachineIndependent/reflection.cpp
+4
-2
No files found.
SPIRV/GlslangToSpv.cpp
View file @
af201e8a
...
@@ -1651,10 +1651,37 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1651,10 +1651,37 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
}
}
if
(
type
.
isArray
())
{
if
(
type
.
isArray
())
{
int
stride
=
0
;
// keep this 0 unless doing an explicit layout; 0 will mean no decoration, no stride
// Do all but the outer dimension
// Do all but the outer dimension
for
(
int
dim
=
type
.
getArraySizes
()
->
getNumDims
()
-
1
;
dim
>
0
;
--
dim
)
{
if
(
type
.
getArraySizes
()
->
getNumDims
()
>
1
)
{
assert
(
type
.
getArraySizes
()
->
getDimSize
(
dim
)
>
0
);
if
(
explicitLayout
!=
glslang
::
ElpNone
)
{
spvType
=
builder
.
makeArrayType
(
spvType
,
type
.
getArraySizes
()
->
getDimSize
(
dim
));
// Use a dummy glslang type for querying internal strides of
// arrays of arrays, but using just a one-dimensional array.
glslang
::
TType
simpleArrayType
(
type
,
0
);
// deference type of the array
while
(
simpleArrayType
.
getArraySizes
().
getNumDims
()
>
1
)
simpleArrayType
.
getArraySizes
().
dereference
();
// Will compute the higher-order strides here, rather than making a whole
// pile of types and doing repetitive recursion on their contents.
stride
=
getArrayStride
(
simpleArrayType
,
explicitLayout
,
qualifier
.
layoutMatrix
);
}
for
(
int
dim
=
type
.
getArraySizes
()
->
getNumDims
()
-
1
;
dim
>
0
;
--
dim
)
{
int
size
=
type
.
getArraySizes
()
->
getDimSize
(
dim
);
assert
(
size
>
0
);
spvType
=
builder
.
makeArrayType
(
spvType
,
size
,
stride
);
if
(
stride
>
0
)
builder
.
addDecoration
(
spvType
,
spv
::
DecorationArrayStride
,
stride
);
stride
*=
size
;
}
}
else
{
// single-dimensional array, and don't yet have stride
// We need to decorate array strides for types needing explicit layout,
// except for the very top if it is an array of blocks; that array is
// not laid out in memory in a way needing a stride.
if
(
explicitLayout
!=
glslang
::
ElpNone
&&
type
.
getBasicType
()
!=
glslang
::
EbtBlock
)
stride
=
getArrayStride
(
type
,
explicitLayout
,
qualifier
.
layoutMatrix
);
}
}
// Do the outer dimension, which might not be known for a runtime-sized array
// Do the outer dimension, which might not be known for a runtime-sized array
...
@@ -1662,18 +1689,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1662,18 +1689,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType
=
builder
.
makeRuntimeArray
(
spvType
);
spvType
=
builder
.
makeRuntimeArray
(
spvType
);
}
else
{
}
else
{
assert
(
type
.
getOuterArraySize
()
>
0
);
assert
(
type
.
getOuterArraySize
()
>
0
);
spvType
=
builder
.
makeArrayType
(
spvType
,
type
.
getOuterArraySize
());
spvType
=
builder
.
makeArrayType
(
spvType
,
type
.
getOuterArraySize
()
,
stride
);
}
}
if
(
stride
>
0
)
// TODO: explicit layout still needs to be done hierarchically for arrays of arrays, which
builder
.
addDecoration
(
spvType
,
spv
::
DecorationArrayStride
,
stride
);
// may still require additional "link time" support from the front-end
// for arrays of arrays
// We need to decorate array strides for types needing explicit layout,
// except for the very top if it is an array of blocks; that array is
// not laid out in memory in a way needing a stride.
if
(
explicitLayout
&&
type
.
getBasicType
()
!=
glslang
::
EbtBlock
)
builder
.
addDecoration
(
spvType
,
spv
::
DecorationArrayStride
,
getArrayStride
(
type
,
explicitLayout
,
qualifier
.
layoutMatrix
));
}
}
return
spvType
;
return
spvType
;
...
@@ -1707,25 +1726,25 @@ glslang::TLayoutPacking TGlslangToSpvTraverser::getExplicitLayout(const glslang:
...
@@ -1707,25 +1726,25 @@ glslang::TLayoutPacking TGlslangToSpvTraverser::getExplicitLayout(const glslang:
int
TGlslangToSpvTraverser
::
getArrayStride
(
const
glslang
::
TType
&
arrayType
,
glslang
::
TLayoutPacking
explicitLayout
,
glslang
::
TLayoutMatrix
matrixLayout
)
int
TGlslangToSpvTraverser
::
getArrayStride
(
const
glslang
::
TType
&
arrayType
,
glslang
::
TLayoutPacking
explicitLayout
,
glslang
::
TLayoutMatrix
matrixLayout
)
{
{
int
size
;
int
size
;
int
stride
=
glslangIntermediate
->
getBaseAlignment
(
arrayType
,
size
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
int
stride
;
if
(
arrayType
.
isMatrix
())
{
glslangIntermediate
->
getBaseAlignment
(
arrayType
,
size
,
stride
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
// GLSL strides are set to alignments of the matrix flattened to individual rows/cols,
// but SPV needs an array stride for the whole matrix, not the rows/cols
if
(
matrixLayout
==
glslang
::
ElmRowMajor
)
stride
*=
arrayType
.
getMatrixRows
();
else
stride
*=
arrayType
.
getMatrixCols
();
}
return
stride
;
return
stride
;
}
}
// Given a matrix type, returns the integer stride required for that matrix
// Given a matrix type,
or array (of array) of matrixes type,
returns the integer stride required for that matrix
// when used as a member of an interface block
// when used as a member of an interface block
int
TGlslangToSpvTraverser
::
getMatrixStride
(
const
glslang
::
TType
&
matrixType
,
glslang
::
TLayoutPacking
explicitLayout
,
glslang
::
TLayoutMatrix
matrixLayout
)
int
TGlslangToSpvTraverser
::
getMatrixStride
(
const
glslang
::
TType
&
matrixType
,
glslang
::
TLayoutPacking
explicitLayout
,
glslang
::
TLayoutMatrix
matrixLayout
)
{
{
glslang
::
TType
elementType
;
elementType
.
shallowCopy
(
matrixType
);
elementType
.
clearArraySizes
();
int
size
;
int
size
;
return
glslangIntermediate
->
getBaseAlignment
(
matrixType
,
size
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
int
stride
;
glslangIntermediate
->
getBaseAlignment
(
elementType
,
size
,
stride
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
return
stride
;
}
}
// Given a member type of a struct, realign the current offset for it, and compute
// Given a member type of a struct, realign the current offset for it, and compute
...
@@ -1764,7 +1783,8 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
...
@@ -1764,7 +1783,8 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
// but possibly not yet correctly aligned.
// but possibly not yet correctly aligned.
int
memberSize
;
int
memberSize
;
int
memberAlignment
=
glslangIntermediate
->
getBaseAlignment
(
memberType
,
memberSize
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
int
dummyStride
;
int
memberAlignment
=
glslangIntermediate
->
getBaseAlignment
(
memberType
,
memberSize
,
dummyStride
,
explicitLayout
==
glslang
::
ElpStd140
,
matrixLayout
==
glslang
::
ElmRowMajor
);
glslang
::
RoundToPow2
(
currentOffset
,
memberAlignment
);
glslang
::
RoundToPow2
(
currentOffset
,
memberAlignment
);
nextOffset
=
currentOffset
+
memberSize
;
nextOffset
=
currentOffset
+
memberSize
;
}
}
...
...
SPIRV/SpvBuilder.cpp
View file @
af201e8a
...
@@ -281,18 +281,23 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
...
@@ -281,18 +281,23 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
return
type
->
getResultId
();
return
type
->
getResultId
();
}
}
Id
Builder
::
makeArrayType
(
Id
element
,
unsigned
size
)
// TODO: performance: track arrays per stride
// If a stride is supplied (non-zero) make an array.
// If no stride (0), reuse previous array types.
Id
Builder
::
makeArrayType
(
Id
element
,
unsigned
size
,
int
stride
)
{
{
// First, we need a constant instruction for the size
// First, we need a constant instruction for the size
Id
sizeId
=
makeUintConstant
(
size
);
Id
sizeId
=
makeUintConstant
(
size
);
// try to find existing type
Instruction
*
type
;
Instruction
*
type
;
for
(
int
t
=
0
;
t
<
(
int
)
groupedTypes
[
OpTypeArray
].
size
();
++
t
)
{
if
(
stride
==
0
)
{
type
=
groupedTypes
[
OpTypeArray
][
t
];
// try to find existing type
if
(
type
->
getIdOperand
(
0
)
==
element
&&
for
(
int
t
=
0
;
t
<
(
int
)
groupedTypes
[
OpTypeArray
].
size
();
++
t
)
{
type
->
getIdOperand
(
1
)
==
sizeId
)
type
=
groupedTypes
[
OpTypeArray
][
t
];
return
type
->
getResultId
();
if
(
type
->
getIdOperand
(
0
)
==
element
&&
type
->
getIdOperand
(
1
)
==
sizeId
)
return
type
->
getResultId
();
}
}
}
// not found, make it
// not found, make it
...
...
SPIRV/SpvBuilder.h
View file @
af201e8a
...
@@ -102,7 +102,7 @@ public:
...
@@ -102,7 +102,7 @@ public:
Id
makeStructResultType
(
Id
type0
,
Id
type1
);
Id
makeStructResultType
(
Id
type0
,
Id
type1
);
Id
makeVectorType
(
Id
component
,
int
size
);
Id
makeVectorType
(
Id
component
,
int
size
);
Id
makeMatrixType
(
Id
component
,
int
cols
,
int
rows
);
Id
makeMatrixType
(
Id
component
,
int
cols
,
int
rows
);
Id
makeArrayType
(
Id
element
,
unsigned
size
);
Id
makeArrayType
(
Id
element
,
unsigned
size
,
int
stride
);
// 0 means no stride decoration
Id
makeRuntimeArray
(
Id
element
);
Id
makeRuntimeArray
(
Id
element
);
Id
makeFunctionType
(
Id
returnType
,
std
::
vector
<
Id
>&
paramTypes
);
Id
makeFunctionType
(
Id
returnType
,
std
::
vector
<
Id
>&
paramTypes
);
Id
makeImageType
(
Id
sampledType
,
Dim
,
bool
depth
,
bool
arrayed
,
bool
ms
,
unsigned
sampled
,
ImageFormat
format
);
Id
makeImageType
(
Id
sampledType
,
Dim
,
bool
depth
,
bool
arrayed
,
bool
ms
,
unsigned
sampled
,
ImageFormat
format
);
...
...
Test/baseResults/spv.140.frag.out
View file @
af201e8a
...
@@ -5,7 +5,7 @@ Linked fragment stage:
...
@@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by
99
// Id's are bound by
100
Capability Shader
Capability Shader
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
...
@@ -24,39 +24,39 @@ Linked fragment stage:
...
@@ -24,39 +24,39 @@ Linked fragment stage:
Name 55 "sampR"
Name 55 "sampR"
Name 63 "sampB"
Name 63 "sampB"
Name 86 "samp2Da"
Name 86 "samp2Da"
Name 9
0
"bn"
Name 9
1
"bn"
MemberName 9
0
(bn) 0 "matra"
MemberName 9
1
(bn) 0 "matra"
MemberName 9
0
(bn) 1 "matca"
MemberName 9
1
(bn) 1 "matca"
MemberName 9
0
(bn) 2 "matr"
MemberName 9
1
(bn) 2 "matr"
MemberName 9
0
(bn) 3 "matc"
MemberName 9
1
(bn) 3 "matc"
MemberName 9
0
(bn) 4 "matrdef"
MemberName 9
1
(bn) 4 "matrdef"
Name 9
2
""
Name 9
3
""
Name 9
5
"bi"
Name 9
6
"bi"
MemberName 9
5
(bi) 0 "v"
MemberName 9
6
(bi) 0 "v"
Name 9
8
"bname"
Name 9
9
"bname"
Decorate 16(gl_FrontFacing) BuiltIn FrontFacing
Decorate 16(gl_FrontFacing) BuiltIn FrontFacing
Decorate 33(gl_ClipDistance) BuiltIn ClipDistance
Decorate 33(gl_ClipDistance) BuiltIn ClipDistance
Decorate 89 ArrayStride 64
Decorate 89 ArrayStride 64
Decorate
89
ArrayStride 64
Decorate
90
ArrayStride 64
MemberDecorate 9
0
(bn) 0 RowMajor
MemberDecorate 9
1
(bn) 0 RowMajor
MemberDecorate 9
0
(bn) 0 Offset 0
MemberDecorate 9
1
(bn) 0 Offset 0
MemberDecorate 9
0
(bn) 0 MatrixStride 16
MemberDecorate 9
1
(bn) 0 MatrixStride 16
MemberDecorate 9
0
(bn) 1 ColMajor
MemberDecorate 9
1
(bn) 1 ColMajor
MemberDecorate 9
0
(bn) 1 Offset 256
MemberDecorate 9
1
(bn) 1 Offset 256
MemberDecorate 9
0
(bn) 1 MatrixStride 16
MemberDecorate 9
1
(bn) 1 MatrixStride 16
MemberDecorate 9
0
(bn) 2 RowMajor
MemberDecorate 9
1
(bn) 2 RowMajor
MemberDecorate 9
0
(bn) 2 Offset 512
MemberDecorate 9
1
(bn) 2 Offset 512
MemberDecorate 9
0
(bn) 2 MatrixStride 16
MemberDecorate 9
1
(bn) 2 MatrixStride 16
MemberDecorate 9
0
(bn) 3 ColMajor
MemberDecorate 9
1
(bn) 3 ColMajor
MemberDecorate 9
0
(bn) 3 Offset 576
MemberDecorate 9
1
(bn) 3 Offset 576
MemberDecorate 9
0
(bn) 3 MatrixStride 16
MemberDecorate 9
1
(bn) 3 MatrixStride 16
MemberDecorate 9
0
(bn) 4 RowMajor
MemberDecorate 9
1
(bn) 4 RowMajor
MemberDecorate 9
0
(bn) 4 Offset 640
MemberDecorate 9
1
(bn) 4 Offset 640
MemberDecorate 9
0
(bn) 4 MatrixStride 16
MemberDecorate 9
1
(bn) 4 MatrixStride 16
Decorate 9
0
(bn) Block
Decorate 9
1
(bn) Block
Decorate 9
4
ArrayStride 16
Decorate 9
5
ArrayStride 16
MemberDecorate 9
5
(bi) 0 Offset 0
MemberDecorate 9
6
(bi) 0 Offset 0
Decorate 9
5
(bi) Block
Decorate 9
6
(bi) Block
2: TypeVoid
2: TypeVoid
3: TypeFunction 2
3: TypeFunction 2
6: TypeFloat 32
6: TypeFloat 32
...
@@ -108,15 +108,16 @@ Linked fragment stage:
...
@@ -108,15 +108,16 @@ Linked fragment stage:
87: TypeMatrix 26(fvec4) 4
87: TypeMatrix 26(fvec4) 4
88: 29(int) Constant 4
88: 29(int) Constant 4
89: TypeArray 87 88
89: TypeArray 87 88
90(bn): TypeStruct 89 89 87 87 87
90: TypeArray 87 88
91: TypePointer Uniform 90(bn)
91(bn): TypeStruct 89 90 87 87 87
92: 91(ptr) Variable Uniform
92: TypePointer Uniform 91(bn)
93: TypeVector 6(float) 3
93: 92(ptr) Variable Uniform
94: TypeArray 93(fvec3) 50
94: TypeVector 6(float) 3
95(bi): TypeStruct 94
95: TypeArray 94(fvec3) 50
96: TypeArray 95(bi) 88
96(bi): TypeStruct 95
97: TypePointer Uniform 96
97: TypeArray 96(bi) 88
98(bname): 97(ptr) Variable Uniform
98: TypePointer Uniform 97
99(bname): 98(ptr) Variable Uniform
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
13: 12(ptr) Variable Function
13: 12(ptr) Variable Function
...
...
Test/baseResults/spv.layoutNested.vert.out
View file @
af201e8a
This diff is collapsed.
Click to expand it.
glslang/Include/Types.h
View file @
af201e8a
...
@@ -1206,6 +1206,10 @@ public:
...
@@ -1206,6 +1206,10 @@ public:
arraySizes
=
new
TArraySizes
;
arraySizes
=
new
TArraySizes
;
*
arraySizes
=
s
;
*
arraySizes
=
s
;
}
}
void
clearArraySizes
()
{
arraySizes
=
0
;
}
void
addArrayOuterSizes
(
const
TArraySizes
&
s
)
void
addArrayOuterSizes
(
const
TArraySizes
&
s
)
{
{
if
(
arraySizes
==
nullptr
)
if
(
arraySizes
==
nullptr
)
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
af201e8a
...
@@ -5353,7 +5353,8 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ
...
@@ -5353,7 +5353,8 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ
// modify just the children's view of matrix layout, if there is one for this member
// modify just the children's view of matrix layout, if there is one for this member
TLayoutMatrix
subMatrixLayout
=
typeList
[
member
].
type
->
getQualifier
().
layoutMatrix
;
TLayoutMatrix
subMatrixLayout
=
typeList
[
member
].
type
->
getQualifier
().
layoutMatrix
;
int
memberAlignment
=
intermediate
.
getBaseAlignment
(
*
typeList
[
member
].
type
,
memberSize
,
qualifier
.
layoutPacking
==
ElpStd140
,
int
dummyStride
;
int
memberAlignment
=
intermediate
.
getBaseAlignment
(
*
typeList
[
member
].
type
,
memberSize
,
dummyStride
,
qualifier
.
layoutPacking
==
ElpStd140
,
subMatrixLayout
!=
ElmNone
?
subMatrixLayout
==
ElmRowMajor
:
qualifier
.
layoutMatrix
==
ElmRowMajor
);
subMatrixLayout
!=
ElmNone
?
subMatrixLayout
==
ElmRowMajor
:
qualifier
.
layoutMatrix
==
ElmRowMajor
);
if
(
memberQualifier
.
hasOffset
())
{
if
(
memberQualifier
.
hasOffset
())
{
// "The specified offset must be a multiple
// "The specified offset must be a multiple
...
...
glslang/MachineIndependent/linkValidate.cpp
View file @
af201e8a
...
@@ -858,8 +858,14 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
...
@@ -858,8 +858,14 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
// otherwise it does not, yielding std430 rules.
// otherwise it does not, yielding std430 rules.
//
//
// The size is returned in the 'size' parameter
// The size is returned in the 'size' parameter
//
// The stride is only non-0 for arrays or matrices, and is the stride of the
// top-level object nested within the type. E.g., for an array of matrices,
// it is the distances needed between matrices, despite the rules saying the
// stride comes from the flattening down to vectors.
//
// Return value is the alignment of the type.
// Return value is the alignment of the type.
int
TIntermediate
::
getBaseAlignment
(
const
TType
&
type
,
int
&
size
,
bool
std140
,
bool
rowMajor
)
int
TIntermediate
::
getBaseAlignment
(
const
TType
&
type
,
int
&
size
,
int
&
stride
,
bool
std140
,
bool
rowMajor
)
{
{
int
alignment
;
int
alignment
;
...
@@ -916,16 +922,23 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
...
@@ -916,16 +922,23 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
//
//
// 10. If the member is an array of S structures, the S elements of the array are laid
// 10. If the member is an array of S structures, the S elements of the array are laid
// out in order, according to rule (9).
// out in order, according to rule (9).
//
// Assuming, for rule 10: The stride is the same as the size of an element.
stride
=
0
;
int
dummyStride
;
// rules 4, 6,
and 8
// rules 4, 6,
8, and 10
if
(
type
.
isArray
())
{
if
(
type
.
isArray
())
{
// TODO: perf: this might be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
// TODO: perf: this might be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
TType
derefType
(
type
,
0
);
TType
derefType
(
type
,
0
);
alignment
=
getBaseAlignment
(
derefType
,
size
,
std140
,
rowMajor
);
alignment
=
getBaseAlignment
(
derefType
,
size
,
dummyStride
,
std140
,
rowMajor
);
if
(
std140
)
if
(
std140
)
alignment
=
std
::
max
(
baseAlignmentVec4Std140
,
alignment
);
alignment
=
std
::
max
(
baseAlignmentVec4Std140
,
alignment
);
RoundToPow2
(
size
,
alignment
);
RoundToPow2
(
size
,
alignment
);
size
*=
type
.
getOuterArraySize
();
stride
=
size
;
// uses full matrix size for stride of an array of matrices (not quite what rule 6/8, but what's expected)
// uses the assumption for rule 10 in the comment above
size
=
stride
*
type
.
getOuterArraySize
();
return
alignment
;
return
alignment
;
}
}
...
@@ -939,7 +952,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
...
@@ -939,7 +952,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
int
memberSize
;
int
memberSize
;
// modify just the children's view of matrix layout, if there is one for this member
// modify just the children's view of matrix layout, if there is one for this member
TLayoutMatrix
subMatrixLayout
=
memberList
[
m
].
type
->
getQualifier
().
layoutMatrix
;
TLayoutMatrix
subMatrixLayout
=
memberList
[
m
].
type
->
getQualifier
().
layoutMatrix
;
int
memberAlignment
=
getBaseAlignment
(
*
memberList
[
m
].
type
,
memberSize
,
std140
,
int
memberAlignment
=
getBaseAlignment
(
*
memberList
[
m
].
type
,
memberSize
,
dummyStride
,
std140
,
(
subMatrixLayout
!=
ElmNone
)
?
(
subMatrixLayout
==
ElmRowMajor
)
:
rowMajor
);
(
subMatrixLayout
!=
ElmNone
)
?
(
subMatrixLayout
==
ElmRowMajor
)
:
rowMajor
);
maxAlignment
=
std
::
max
(
maxAlignment
,
memberAlignment
);
maxAlignment
=
std
::
max
(
maxAlignment
,
memberAlignment
);
RoundToPow2
(
size
,
memberAlignment
);
RoundToPow2
(
size
,
memberAlignment
);
...
@@ -971,14 +984,15 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
...
@@ -971,14 +984,15 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, b
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows
TType
derefType
(
type
,
0
,
type
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
TType
derefType
(
type
,
0
,
type
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
alignment
=
getBaseAlignment
(
derefType
,
size
,
std140
,
rowMajor
);
alignment
=
getBaseAlignment
(
derefType
,
size
,
dummyStride
,
std140
,
rowMajor
);
if
(
std140
)
if
(
std140
)
alignment
=
std
::
max
(
baseAlignmentVec4Std140
,
alignment
);
alignment
=
std
::
max
(
baseAlignmentVec4Std140
,
alignment
);
RoundToPow2
(
size
,
alignment
);
RoundToPow2
(
size
,
alignment
);
stride
=
size
;
// use intra-matrix stride for stride of a just a matrix
if
(
rowMajor
)
if
(
rowMajor
)
size
*=
type
.
getMatrixRows
();
size
=
stride
*
type
.
getMatrixRows
();
else
else
size
*=
type
.
getMatrixCols
();
size
=
stride
*
type
.
getMatrixCols
();
return
alignment
;
return
alignment
;
}
}
...
...
glslang/MachineIndependent/localintermediate.h
View file @
af201e8a
...
@@ -305,7 +305,7 @@ public:
...
@@ -305,7 +305,7 @@ public:
}
}
int
addXfbBufferOffset
(
const
TType
&
);
int
addXfbBufferOffset
(
const
TType
&
);
unsigned
int
computeTypeXfbSize
(
const
TType
&
,
bool
&
containsDouble
)
const
;
unsigned
int
computeTypeXfbSize
(
const
TType
&
,
bool
&
containsDouble
)
const
;
static
int
getBaseAlignment
(
const
TType
&
,
int
&
size
,
bool
std140
,
bool
rowMajor
);
static
int
getBaseAlignment
(
const
TType
&
,
int
&
size
,
int
&
stride
,
bool
std140
,
bool
rowMajor
);
protected
:
protected
:
void
error
(
TInfoSink
&
infoSink
,
const
char
*
);
void
error
(
TInfoSink
&
infoSink
,
const
char
*
);
...
...
glslang/MachineIndependent/reflection.cpp
View file @
af201e8a
...
@@ -121,11 +121,12 @@ public:
...
@@ -121,11 +121,12 @@ public:
return
memberList
[
index
].
type
->
getQualifier
().
layoutOffset
;
return
memberList
[
index
].
type
->
getQualifier
().
layoutOffset
;
int
memberSize
;
int
memberSize
;
int
dummyStride
;
int
offset
=
0
;
int
offset
=
0
;
for
(
int
m
=
0
;
m
<=
index
;
++
m
)
{
for
(
int
m
=
0
;
m
<=
index
;
++
m
)
{
// modify just the children's view of matrix layout, if there is one for this member
// modify just the children's view of matrix layout, if there is one for this member
TLayoutMatrix
subMatrixLayout
=
memberList
[
m
].
type
->
getQualifier
().
layoutMatrix
;
TLayoutMatrix
subMatrixLayout
=
memberList
[
m
].
type
->
getQualifier
().
layoutMatrix
;
int
memberAlignment
=
intermediate
.
getBaseAlignment
(
*
memberList
[
m
].
type
,
memberSize
,
type
.
getQualifier
().
layoutPacking
==
ElpStd140
,
int
memberAlignment
=
intermediate
.
getBaseAlignment
(
*
memberList
[
m
].
type
,
memberSize
,
dummyStride
,
type
.
getQualifier
().
layoutPacking
==
ElpStd140
,
subMatrixLayout
!=
ElmNone
?
subMatrixLayout
==
ElmRowMajor
:
type
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
subMatrixLayout
!=
ElmNone
?
subMatrixLayout
==
ElmRowMajor
:
type
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
RoundToPow2
(
offset
,
memberAlignment
);
RoundToPow2
(
offset
,
memberAlignment
);
if
(
m
<
index
)
if
(
m
<
index
)
...
@@ -144,7 +145,8 @@ public:
...
@@ -144,7 +145,8 @@ public:
int
lastOffset
=
getOffset
(
blockType
,
lastIndex
);
int
lastOffset
=
getOffset
(
blockType
,
lastIndex
);
int
lastMemberSize
;
int
lastMemberSize
;
intermediate
.
getBaseAlignment
(
*
memberList
[
lastIndex
].
type
,
lastMemberSize
,
blockType
.
getQualifier
().
layoutPacking
==
ElpStd140
,
int
dummyStride
;
intermediate
.
getBaseAlignment
(
*
memberList
[
lastIndex
].
type
,
lastMemberSize
,
dummyStride
,
blockType
.
getQualifier
().
layoutPacking
==
ElpStd140
,
blockType
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
blockType
.
getQualifier
().
layoutMatrix
==
ElmRowMajor
);
return
lastOffset
+
lastMemberSize
;
return
lastOffset
+
lastMemberSize
;
...
...
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