Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
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
angle
Commits
bcb6a1e0
Commit
bcb6a1e0
authored
Aug 30, 2013
by
Jamie Madill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the varying priority sorting logic, and add more verbose comments.
TRAC #23746 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods
parent
921968ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
37 deletions
+53
-37
Shader.cpp
src/libGLESv2/Shader.cpp
+53
-37
No files found.
src/libGLESv2/Shader.cpp
View file @
bcb6a1e0
...
@@ -525,54 +525,70 @@ GLenum Shader::parseType(const std::string &type)
...
@@ -525,54 +525,70 @@ GLenum Shader::parseType(const std::string &type)
return
GL_NONE
;
return
GL_NONE
;
}
}
typedef
std
::
map
<
GLenum
,
int
>
VaryingPriorityMap
;
// [OpenGL ES SL 3.00.4] Section 11 p. 120
static
VaryingPriorityMap
varyingPriorities
;
// Vertex Outs/Fragment Ins packing priorities
static
const
GLenum
varyingPriorityList
[]
=
static
void
makeVaryingPriorityMap
()
{
{
// 1. Arrays of mat4 and mat4
varyingPriorities
[
GL_FLOAT_MAT4
]
=
0
;
GL_FLOAT_MAT4
,
varyingPriorities
[
GL_FLOAT_MAT3x4
]
=
10
;
varyingPriorities
[
GL_FLOAT_MAT4x3
]
=
20
;
// Non-square matrices of type matCxR consume the same space as a square
varyingPriorities
[
GL_FLOAT_MAT2x4
]
=
30
;
// matrix of type matN where N is the greater of C and R
varyingPriorities
[
GL_FLOAT_MAT4x2
]
=
40
;
GL_FLOAT_MAT3x4
,
varyingPriorities
[
GL_FLOAT_MAT2
]
=
50
;
GL_FLOAT_MAT4x3
,
varyingPriorities
[
GL_FLOAT_VEC4
]
=
60
;
GL_FLOAT_MAT2x4
,
varyingPriorities
[
GL_INT_VEC4
]
=
61
;
GL_FLOAT_MAT4x2
,
varyingPriorities
[
GL_UNSIGNED_INT_VEC4
]
=
62
;
varyingPriorities
[
GL_FLOAT_MAT3
]
=
70
;
// 2. Arrays of mat2 and mat2 (since they occupy full rows)
varyingPriorities
[
GL_FLOAT_MAT2x3
]
=
80
;
GL_FLOAT_MAT2
,
varyingPriorities
[
GL_FLOAT_MAT3x2
]
=
90
;
varyingPriorities
[
GL_FLOAT_VEC3
]
=
100
;
// 3. Arrays of vec4 and vec4
varyingPriorities
[
GL_INT_VEC3
]
=
101
;
GL_FLOAT_VEC4
,
varyingPriorities
[
GL_UNSIGNED_INT_VEC3
]
=
102
;
GL_INT_VEC4
,
varyingPriorities
[
GL_FLOAT_VEC2
]
=
110
;
GL_UNSIGNED_INT_VEC4
,
varyingPriorities
[
GL_INT_VEC2
]
=
111
;
varyingPriorities
[
GL_UNSIGNED_INT_VEC2
]
=
112
;
// 4. Arrays of mat3 and mat3
varyingPriorities
[
GL_FLOAT
]
=
120
;
GL_FLOAT_MAT3
,
varyingPriorities
[
GL_INT
]
=
125
;
GL_FLOAT_MAT2x3
,
varyingPriorities
[
GL_UNSIGNED_INT
]
=
130
;
GL_FLOAT_MAT3x2
,
}
// 5. Arrays of vec3 and vec3
GL_FLOAT_VEC3
,
GL_INT_VEC3
,
GL_UNSIGNED_INT_VEC3
,
// 6. Arrays of vec2 and vec2
GL_FLOAT_VEC2
,
GL_INT_VEC2
,
GL_UNSIGNED_INT_VEC2
,
// 7. Arrays of float and float
GL_FLOAT
,
GL_INT
,
GL_UNSIGNED_INT
,
};
// true if varying x has a higher priority in packing than y
// true if varying x has a higher priority in packing than y
bool
Shader
::
compareVarying
(
const
Varying
&
x
,
const
Varying
&
y
)
bool
Shader
::
compareVarying
(
const
Varying
&
x
,
const
Varying
&
y
)
{
{
if
(
varyingPriorities
.
empty
()
)
if
(
x
.
type
==
y
.
type
)
{
{
makeVaryingPriorityMap
()
;
return
x
.
size
>
y
.
size
;
}
}
if
(
x
.
type
==
y
.
type
)
unsigned
int
xPriority
=
GL_INVALID_INDEX
;
unsigned
int
yPriority
=
GL_INVALID_INDEX
;
for
(
unsigned
int
priorityIndex
=
0
;
priorityIndex
<
ArraySize
(
varyingPriorityList
);
priorityIndex
++
)
{
{
return
x
.
size
>
y
.
size
;
if
(
varyingPriorityList
[
priorityIndex
]
==
x
.
type
)
xPriority
=
priorityIndex
;
if
(
varyingPriorityList
[
priorityIndex
]
==
y
.
type
)
yPriority
=
priorityIndex
;
if
(
xPriority
!=
GL_INVALID_INDEX
&&
yPriority
!=
GL_INVALID_INDEX
)
break
;
}
}
VaryingPriorityMap
::
iterator
xPriority
=
varyingPriorities
.
find
(
x
.
type
);
ASSERT
(
xPriority
!=
GL_INVALID_INDEX
&&
yPriority
!=
GL_INVALID_INDEX
);
VaryingPriorityMap
::
iterator
yPriority
=
varyingPriorities
.
find
(
y
.
type
);
ASSERT
(
xPriority
!=
varyingPriorities
.
end
());
ASSERT
(
yPriority
!=
varyingPriorities
.
end
());
return
xPriority
->
second
<=
yPriority
->
second
;
return
xPriority
<=
yPriority
;
}
}
int
Shader
::
getShaderVersion
()
const
int
Shader
::
getShaderVersion
()
const
...
...
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