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
fa84001a
Commit
fa84001a
authored
Apr 03, 2017
by
John Kessenich
Committed by
GitHub
Apr 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #814 from steve-lunarg/contains
Refactor TType::contains* methods (nonfunctional)
parents
c7fd73b7
27309f68
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
71 deletions
+26
-71
Types.h
glslang/Include/Types.h
+26
-71
No files found.
glslang/Include/Types.h
View file @
fa84001a
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
#include "../Public/ShaderLang.h"
#include "../Public/ShaderLang.h"
#include "arrays.h"
#include "arrays.h"
#include <algorithm>
namespace
glslang
{
namespace
glslang
{
const
int
GlslangMaxTypeLength
=
200
;
// TODO: need to print block/struct one member per line, so this can stay bounded
const
int
GlslangMaxTypeLength
=
200
;
// TODO: need to print block/struct one member per line, so this can stay bounded
...
@@ -1382,92 +1384,57 @@ public:
...
@@ -1382,92 +1384,57 @@ public:
return
!
isPerVertexAndBuiltIn
(
language
);
return
!
isPerVertexAndBuiltIn
(
language
);
}
}
// Recursively checks if the type contains the given basic type
// return true if this type contains any subtype which satisfies the given predicate.
virtual
bool
containsBasicType
(
TBasicType
checkType
)
const
template
<
typename
P
>
bool
contains
(
P
predicate
)
const
{
{
if
(
basicType
==
checkType
)
if
(
predicate
(
this
))
return
true
;
if
(
!
structure
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsBasicType
(
checkType
))
return
true
;
return
true
;
const
auto
hasa
=
[
predicate
](
const
TTypeLoc
&
tl
)
{
return
tl
.
type
->
contains
(
predicate
);
};
return
structure
&&
std
::
any_of
(
structure
->
begin
(),
structure
->
end
(),
hasa
);
}
}
return
false
;
// Recursively checks if the type contains the given basic type
virtual
bool
containsBasicType
(
TBasicType
checkType
)
const
{
return
contains
([
checkType
](
const
TType
*
t
)
{
return
t
->
basicType
==
checkType
;
}
);
}
}
// Recursively check the structure for any arrays, needed for some error checks
// Recursively check the structure for any arrays, needed for some error checks
virtual
bool
containsArray
()
const
virtual
bool
containsArray
()
const
{
{
if
(
isArray
())
return
contains
([](
const
TType
*
t
)
{
return
t
->
isArray
();
}
);
return
true
;
if
(
structure
==
nullptr
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsArray
())
return
true
;
}
return
false
;
}
}
// Check the structure for any structures, needed for some error checks
// Check the structure for any structures, needed for some error checks
virtual
bool
containsStructure
()
const
virtual
bool
containsStructure
()
const
{
{
if
(
structure
==
nullptr
)
return
contains
([
this
](
const
TType
*
t
)
{
return
t
!=
this
&&
t
->
isStruct
();
}
);
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
structure
)
return
true
;
}
return
false
;
}
}
// Recursively check the structure for any implicitly-sized arrays, needed for triggering a copyUp().
// Recursively check the structure for any implicitly-sized arrays, needed for triggering a copyUp().
virtual
bool
containsImplicitlySizedArray
()
const
virtual
bool
containsImplicitlySizedArray
()
const
{
{
if
(
isImplicitlySizedArray
())
return
contains
([](
const
TType
*
t
)
{
return
t
->
isImplicitlySizedArray
();
}
);
return
true
;
if
(
structure
==
nullptr
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsImplicitlySizedArray
())
return
true
;
}
return
false
;
}
}
virtual
bool
containsOpaque
()
const
virtual
bool
containsOpaque
()
const
{
{
if
(
isOpaque
())
return
contains
([](
const
TType
*
t
)
{
return
t
->
isOpaque
();
}
);
return
true
;
if
(
!
structure
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsOpaque
())
return
true
;
}
return
false
;
}
}
// Recursively checks if the type contains an interstage IO builtin
// Recursively checks if the type contains an interstage IO builtin
virtual
bool
containsBuiltInInterstageIO
(
EShLanguage
language
)
const
virtual
bool
containsBuiltInInterstageIO
(
EShLanguage
language
)
const
{
{
if
(
isBuiltInInterstageIO
(
language
))
return
contains
([
language
](
const
TType
*
t
)
{
return
t
->
isBuiltInInterstageIO
(
language
);
}
);
return
true
;
if
(
!
structure
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsBuiltInInterstageIO
(
language
))
return
true
;
}
return
false
;
}
}
virtual
bool
containsNonOpaque
()
const
virtual
bool
containsNonOpaque
()
const
{
{
// list all non-opaque types
const
auto
nonOpaque
=
[](
const
TType
*
t
)
{
switch
(
basicType
)
{
switch
(
t
->
basicType
)
{
case
EbtVoid
:
case
EbtVoid
:
case
EbtFloat
:
case
EbtFloat
:
case
EbtDouble
:
case
EbtDouble
:
...
@@ -1481,28 +1448,16 @@ public:
...
@@ -1481,28 +1448,16 @@ public:
case
EbtBool
:
case
EbtBool
:
return
true
;
return
true
;
default
:
default
:
break
;
}
if
(
!
structure
)
return
false
;
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsNonOpaque
())
return
true
;
}
}
return
false
;
};
return
contains
(
nonOpaque
);
}
}
virtual
bool
containsSpecializationSize
()
const
virtual
bool
containsSpecializationSize
()
const
{
{
if
(
isArray
()
&&
arraySizes
->
containsNode
())
return
contains
([](
const
TType
*
t
)
{
return
t
->
isArray
()
&&
t
->
arraySizes
->
containsNode
();
}
);
return
true
;
if
(
!
structure
)
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
structure
->
size
();
++
i
)
{
if
((
*
structure
)[
i
].
type
->
containsSpecializationSize
())
return
true
;
}
return
false
;
}
}
// Array editing methods. Array descriptors can be shared across
// Array editing methods. Array descriptors can be shared across
...
...
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