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
75c5603a
Commit
75c5603a
authored
Jan 14, 2019
by
Rex Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix xfb_stride incorrectness(#1654)
Add int64 support in XFB. Change containsDouble to contains64BitType. Make it more general.
parent
28982233
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
34 deletions
+34
-34
440.vert.out
Test/baseResults/440.vert.out
+1
-1
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+4
-4
linkValidate.cpp
glslang/MachineIndependent/linkValidate.cpp
+22
-22
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+3
-3
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+4
-4
No files found.
Test/baseResults/440.vert.out
View file @
75c5603a
...
@@ -166,7 +166,7 @@ Linked vertex stage:
...
@@ -166,7 +166,7 @@ Linked vertex stage:
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
ERROR: Linking vertex stage: xfb_stride is too small to hold all buffer entries:
ERROR: Linking vertex stage: xfb_stride is too small to hold all buffer entries:
ERROR: xfb_buffer 0, xfb_stride 92, minimum stride needed: 96
ERROR: xfb_buffer 0, xfb_stride 92, minimum stride needed: 96
ERROR: Linking vertex stage: xfb_stride must be multiple of 8 for buffer holding a double:
ERROR: Linking vertex stage: xfb_stride must be multiple of 8 for buffer holding a double
or 64-bit integer
:
ERROR: xfb_buffer 0, xfb_stride 92
ERROR: xfb_buffer 0, xfb_stride 92
ERROR: Linking vertex stage: xfb_stride must be multiple of 4:
ERROR: Linking vertex stage: xfb_stride must be multiple of 4:
ERROR: xfb_buffer 5, xfb_stride 6
ERROR: xfb_buffer 5, xfb_stride 6
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
75c5603a
...
@@ -7270,12 +7270,12 @@ void TParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
...
@@ -7270,12 +7270,12 @@ void TParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
int
nextOffset
=
qualifier
.
layoutXfbOffset
;
int
nextOffset
=
qualifier
.
layoutXfbOffset
;
for
(
unsigned
int
member
=
0
;
member
<
typeList
.
size
();
++
member
)
{
for
(
unsigned
int
member
=
0
;
member
<
typeList
.
size
();
++
member
)
{
TQualifier
&
memberQualifier
=
typeList
[
member
].
type
->
getQualifier
();
TQualifier
&
memberQualifier
=
typeList
[
member
].
type
->
getQualifier
();
bool
contains
Doubl
e
=
false
;
bool
contains
64BitTyp
e
=
false
;
int
memberSize
=
intermediate
.
computeTypeXfbSize
(
*
typeList
[
member
].
type
,
contains
Doubl
e
);
int
memberSize
=
intermediate
.
computeTypeXfbSize
(
*
typeList
[
member
].
type
,
contains
64BitTyp
e
);
// see if we need to auto-assign an offset to this member
// see if we need to auto-assign an offset to this member
if
(
!
memberQualifier
.
hasXfbOffset
())
{
if
(
!
memberQualifier
.
hasXfbOffset
())
{
// "if applied to an aggregate containing a double, the offset must also be a multiple of 8"
// "if applied to an aggregate containing a double
or 64-bit integer
, the offset must also be a multiple of 8"
if
(
contains
Doubl
e
)
if
(
contains
64BitTyp
e
)
RoundToPow2
(
nextOffset
,
8
);
RoundToPow2
(
nextOffset
,
8
);
memberQualifier
.
layoutXfbOffset
=
nextOffset
;
memberQualifier
.
layoutXfbOffset
=
nextOffset
;
}
else
}
else
...
...
glslang/MachineIndependent/linkValidate.cpp
View file @
75c5603a
...
@@ -222,8 +222,8 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
...
@@ -222,8 +222,8 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
else
if
(
xfbBuffers
[
b
].
stride
!=
unit
.
xfbBuffers
[
b
].
stride
)
else
if
(
xfbBuffers
[
b
].
stride
!=
unit
.
xfbBuffers
[
b
].
stride
)
error
(
infoSink
,
"Contradictory xfb_stride"
);
error
(
infoSink
,
"Contradictory xfb_stride"
);
xfbBuffers
[
b
].
implicitStride
=
std
::
max
(
xfbBuffers
[
b
].
implicitStride
,
unit
.
xfbBuffers
[
b
].
implicitStride
);
xfbBuffers
[
b
].
implicitStride
=
std
::
max
(
xfbBuffers
[
b
].
implicitStride
,
unit
.
xfbBuffers
[
b
].
implicitStride
);
if
(
unit
.
xfbBuffers
[
b
].
contains
Doubl
e
)
if
(
unit
.
xfbBuffers
[
b
].
contains
64BitTyp
e
)
xfbBuffers
[
b
].
contains
Doubl
e
=
true
;
xfbBuffers
[
b
].
contains
64BitTyp
e
=
true
;
// TODO: 4.4 link: enhanced layouts: compare ranges
// TODO: 4.4 link: enhanced layouts: compare ranges
}
}
...
@@ -634,7 +634,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
...
@@ -634,7 +634,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
error
(
infoSink
,
"Cannot use both gl_FragColor and gl_FragData"
);
error
(
infoSink
,
"Cannot use both gl_FragColor and gl_FragData"
);
for
(
size_t
b
=
0
;
b
<
xfbBuffers
.
size
();
++
b
)
{
for
(
size_t
b
=
0
;
b
<
xfbBuffers
.
size
();
++
b
)
{
if
(
xfbBuffers
[
b
].
contains
Doubl
e
)
if
(
xfbBuffers
[
b
].
contains
64BitTyp
e
)
RoundToPow2
(
xfbBuffers
[
b
].
implicitStride
,
8
);
RoundToPow2
(
xfbBuffers
[
b
].
implicitStride
,
8
);
// "It is a compile-time or link-time error to have
// "It is a compile-time or link-time error to have
...
@@ -650,10 +650,10 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
...
@@ -650,10 +650,10 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
xfbBuffers
[
b
].
stride
=
xfbBuffers
[
b
].
implicitStride
;
xfbBuffers
[
b
].
stride
=
xfbBuffers
[
b
].
implicitStride
;
// "If the buffer is capturing any
// "If the buffer is capturing any
// outputs with double-precision components, the stride must be a multiple of 8, otherwise it must be a
// outputs with double-precision
or 64-bit integer
components, the stride must be a multiple of 8, otherwise it must be a
// multiple of 4, or a compile-time or link-time error results."
// multiple of 4, or a compile-time or link-time error results."
if
(
xfbBuffers
[
b
].
contains
Doubl
e
&&
!
IsMultipleOfPow2
(
xfbBuffers
[
b
].
stride
,
8
))
{
if
(
xfbBuffers
[
b
].
contains
64BitTyp
e
&&
!
IsMultipleOfPow2
(
xfbBuffers
[
b
].
stride
,
8
))
{
error
(
infoSink
,
"xfb_stride must be multiple of 8 for buffer holding a double:"
);
error
(
infoSink
,
"xfb_stride must be multiple of 8 for buffer holding a double
or 64-bit integer
:"
);
infoSink
.
info
.
prefix
(
EPrefixError
);
infoSink
.
info
.
prefix
(
EPrefixError
);
infoSink
.
info
<<
" xfb_buffer "
<<
(
unsigned
int
)
b
<<
", xfb_stride "
<<
xfbBuffers
[
b
].
stride
<<
"
\n
"
;
infoSink
.
info
<<
" xfb_buffer "
<<
(
unsigned
int
)
b
<<
", xfb_stride "
<<
xfbBuffers
[
b
].
stride
<<
"
\n
"
;
}
else
if
(
!
IsMultipleOfPow2
(
xfbBuffers
[
b
].
stride
,
4
))
{
}
else
if
(
!
IsMultipleOfPow2
(
xfbBuffers
[
b
].
stride
,
4
))
{
...
@@ -1260,7 +1260,7 @@ int TIntermediate::addXfbBufferOffset(const TType& type)
...
@@ -1260,7 +1260,7 @@ int TIntermediate::addXfbBufferOffset(const TType& type)
TXfbBuffer
&
buffer
=
xfbBuffers
[
qualifier
.
layoutXfbBuffer
];
TXfbBuffer
&
buffer
=
xfbBuffers
[
qualifier
.
layoutXfbBuffer
];
// compute the range
// compute the range
unsigned
int
size
=
computeTypeXfbSize
(
type
,
buffer
.
contains
Doubl
e
);
unsigned
int
size
=
computeTypeXfbSize
(
type
,
buffer
.
contains
64BitTyp
e
);
buffer
.
implicitStride
=
std
::
max
(
buffer
.
implicitStride
,
qualifier
.
layoutXfbOffset
+
size
);
buffer
.
implicitStride
=
std
::
max
(
buffer
.
implicitStride
,
qualifier
.
layoutXfbOffset
+
size
);
TRange
range
(
qualifier
.
layoutXfbOffset
,
qualifier
.
layoutXfbOffset
+
size
-
1
);
TRange
range
(
qualifier
.
layoutXfbOffset
,
qualifier
.
layoutXfbOffset
+
size
-
1
);
...
@@ -1279,11 +1279,11 @@ int TIntermediate::addXfbBufferOffset(const TType& type)
...
@@ -1279,11 +1279,11 @@ int TIntermediate::addXfbBufferOffset(const TType& type)
// Recursively figure out how many bytes of xfb buffer are used by the given type.
// Recursively figure out how many bytes of xfb buffer are used by the given type.
// Return the size of type, in bytes.
// Return the size of type, in bytes.
// Sets contains
Doubl
e to true if the type contains a double.
// Sets contains
64BitTyp
e to true if the type contains a double.
// N.B. Caller must set contains
Doubl
e to false before calling.
// N.B. Caller must set contains
64BitTyp
e to false before calling.
unsigned
int
TIntermediate
::
computeTypeXfbSize
(
const
TType
&
type
,
bool
&
contains
Doubl
e
)
const
unsigned
int
TIntermediate
::
computeTypeXfbSize
(
const
TType
&
type
,
bool
&
contains
64BitTyp
e
)
const
{
{
// "...if applied to an aggregate containing a double, the offset must also be a multiple of 8,
// "...if applied to an aggregate containing a double
or 64-bit integer
, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8.
// and the space taken in the buffer will be a multiple of 8.
// ...within the qualified entity, subsequent components are each
// ...within the qualified entity, subsequent components are each
// assigned, in order, to the next available offset aligned to a multiple of
// assigned, in order, to the next available offset aligned to a multiple of
...
@@ -1294,28 +1294,28 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
...
@@ -1294,28 +1294,28 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
assert
(
type
.
isSizedArray
());
assert
(
type
.
isSizedArray
());
TType
elementType
(
type
,
0
);
TType
elementType
(
type
,
0
);
return
type
.
getOuterArraySize
()
*
computeTypeXfbSize
(
elementType
,
contains
Doubl
e
);
return
type
.
getOuterArraySize
()
*
computeTypeXfbSize
(
elementType
,
contains
64BitTyp
e
);
}
}
if
(
type
.
isStruct
())
{
if
(
type
.
isStruct
())
{
unsigned
int
size
=
0
;
unsigned
int
size
=
0
;
bool
structContains
Doubl
e
=
false
;
bool
structContains
64BitTyp
e
=
false
;
for
(
int
member
=
0
;
member
<
(
int
)
type
.
getStruct
()
->
size
();
++
member
)
{
for
(
int
member
=
0
;
member
<
(
int
)
type
.
getStruct
()
->
size
();
++
member
)
{
TType
memberType
(
type
,
member
);
TType
memberType
(
type
,
member
);
// "... if applied to
// "... if applied to
// an aggregate containing a double, the offset must also be a multiple of 8,
// an aggregate containing a double
or 64-bit integer
, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8."
// and the space taken in the buffer will be a multiple of 8."
bool
memberContains
Doubl
e
=
false
;
bool
memberContains
64BitTyp
e
=
false
;
int
memberSize
=
computeTypeXfbSize
(
memberType
,
memberContains
Doubl
e
);
int
memberSize
=
computeTypeXfbSize
(
memberType
,
memberContains
64BitTyp
e
);
if
(
memberContains
Doubl
e
)
{
if
(
memberContains
64BitTyp
e
)
{
structContains
Doubl
e
=
true
;
structContains
64BitTyp
e
=
true
;
RoundToPow2
(
size
,
8
);
RoundToPow2
(
size
,
8
);
}
}
size
+=
memberSize
;
size
+=
memberSize
;
}
}
if
(
structContains
Doubl
e
)
{
if
(
structContains
64BitTyp
e
)
{
contains
Doubl
e
=
true
;
contains
64BitTyp
e
=
true
;
RoundToPow2
(
size
,
8
);
RoundToPow2
(
size
,
8
);
}
}
return
size
;
return
size
;
...
@@ -1333,8 +1333,8 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
...
@@ -1333,8 +1333,8 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
numComponents
=
1
;
numComponents
=
1
;
}
}
if
(
type
.
getBasicType
()
==
EbtDouble
)
{
if
(
type
.
getBasicType
()
==
EbtDouble
||
type
.
getBasicType
()
==
EbtInt64
||
type
.
getBasicType
()
==
EbtUint64
)
{
contains
Doubl
e
=
true
;
contains
64BitTyp
e
=
true
;
return
8
*
numComponents
;
return
8
*
numComponents
;
}
else
}
else
return
4
*
numComponents
;
return
4
*
numComponents
;
...
...
glslang/MachineIndependent/localintermediate.h
View file @
75c5603a
...
@@ -149,11 +149,11 @@ struct TOffsetRange {
...
@@ -149,11 +149,11 @@ struct TOffsetRange {
// Things that need to be tracked per xfb buffer.
// Things that need to be tracked per xfb buffer.
struct
TXfbBuffer
{
struct
TXfbBuffer
{
TXfbBuffer
()
:
stride
(
TQualifier
::
layoutXfbStrideEnd
),
implicitStride
(
0
),
contains
Doubl
e
(
false
)
{
}
TXfbBuffer
()
:
stride
(
TQualifier
::
layoutXfbStrideEnd
),
implicitStride
(
0
),
contains
64BitTyp
e
(
false
)
{
}
std
::
vector
<
TRange
>
ranges
;
// byte offsets that have already been assigned
std
::
vector
<
TRange
>
ranges
;
// byte offsets that have already been assigned
unsigned
int
stride
;
unsigned
int
stride
;
unsigned
int
implicitStride
;
unsigned
int
implicitStride
;
bool
contains
Doubl
e
;
bool
contains
64BitTyp
e
;
};
};
// Track a set of strings describing how the module was processed.
// Track a set of strings describing how the module was processed.
...
@@ -640,7 +640,7 @@ public:
...
@@ -640,7 +640,7 @@ public:
}
}
unsigned
getXfbStride
(
int
buffer
)
const
{
return
xfbBuffers
[
buffer
].
stride
;
}
unsigned
getXfbStride
(
int
buffer
)
const
{
return
xfbBuffers
[
buffer
].
stride
;
}
int
addXfbBufferOffset
(
const
TType
&
);
int
addXfbBufferOffset
(
const
TType
&
);
unsigned
int
computeTypeXfbSize
(
const
TType
&
,
bool
&
contains
Doubl
e
)
const
;
unsigned
int
computeTypeXfbSize
(
const
TType
&
,
bool
&
contains
64BitTyp
e
)
const
;
static
int
getBaseAlignmentScalar
(
const
TType
&
,
int
&
size
);
static
int
getBaseAlignmentScalar
(
const
TType
&
,
int
&
size
);
static
int
getBaseAlignment
(
const
TType
&
,
int
&
size
,
int
&
stride
,
TLayoutPacking
layoutPacking
,
bool
rowMajor
);
static
int
getBaseAlignment
(
const
TType
&
,
int
&
size
,
int
&
stride
,
TLayoutPacking
layoutPacking
,
bool
rowMajor
);
static
int
getScalarAlignment
(
const
TType
&
,
int
&
size
,
int
&
stride
,
bool
rowMajor
);
static
int
getScalarAlignment
(
const
TType
&
,
int
&
size
,
int
&
stride
,
bool
rowMajor
);
...
...
hlsl/hlslParseHelper.cpp
View file @
75c5603a
...
@@ -8697,12 +8697,12 @@ void HlslParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
...
@@ -8697,12 +8697,12 @@ void HlslParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
int
nextOffset
=
qualifier
.
layoutXfbOffset
;
int
nextOffset
=
qualifier
.
layoutXfbOffset
;
for
(
unsigned
int
member
=
0
;
member
<
typeList
.
size
();
++
member
)
{
for
(
unsigned
int
member
=
0
;
member
<
typeList
.
size
();
++
member
)
{
TQualifier
&
memberQualifier
=
typeList
[
member
].
type
->
getQualifier
();
TQualifier
&
memberQualifier
=
typeList
[
member
].
type
->
getQualifier
();
bool
contains
Doubl
e
=
false
;
bool
contains
64BitTyp
e
=
false
;
int
memberSize
=
intermediate
.
computeTypeXfbSize
(
*
typeList
[
member
].
type
,
contains
Doubl
e
);
int
memberSize
=
intermediate
.
computeTypeXfbSize
(
*
typeList
[
member
].
type
,
contains
64BitTyp
e
);
// see if we need to auto-assign an offset to this member
// see if we need to auto-assign an offset to this member
if
(
!
memberQualifier
.
hasXfbOffset
())
{
if
(
!
memberQualifier
.
hasXfbOffset
())
{
// "if applied to an aggregate containing a double, the offset must also be a multiple of 8"
// "if applied to an aggregate containing a double
or 64-bit integer
, the offset must also be a multiple of 8"
if
(
contains
Doubl
e
)
if
(
contains
64BitTyp
e
)
RoundToPow2
(
nextOffset
,
8
);
RoundToPow2
(
nextOffset
,
8
);
memberQualifier
.
layoutXfbOffset
=
nextOffset
;
memberQualifier
.
layoutXfbOffset
=
nextOffset
;
}
else
}
else
...
...
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