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
e2a728aa
Commit
e2a728aa
authored
Jul 12, 2017
by
Commit Bot
Committed by
Gerrit Code Review
Jul 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Validate uniforms and attributes name conflicts when linking"
parents
d5fbb8b0
caa5cda0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
0 deletions
+58
-0
Program.cpp
src/libANGLE/Program.cpp
+35
-0
Program.h
src/libANGLE/Program.h
+1
-0
WebGLCompatibilityTest.cpp
src/tests/gl_tests/WebGLCompatibilityTest.cpp
+22
-0
No files found.
src/libANGLE/Program.cpp
View file @
e2a728aa
...
@@ -727,6 +727,11 @@ Error Program::link(const gl::Context *context)
...
@@ -727,6 +727,11 @@ Error Program::link(const gl::Context *context)
return
NoError
();
return
NoError
();
}
}
if
(
!
linkValidateGlobalNames
(
context
,
mInfoLog
))
{
return
NoError
();
}
const
auto
&
mergedVaryings
=
getMergedVaryings
(
context
);
const
auto
&
mergedVaryings
=
getMergedVaryings
(
context
);
if
(
!
linkValidateTransformFeedback
(
context
,
mInfoLog
,
mergedVaryings
,
caps
))
if
(
!
linkValidateTransformFeedback
(
context
,
mInfoLog
,
mergedVaryings
,
caps
))
...
@@ -2386,6 +2391,36 @@ bool Program::linkValidateTransformFeedback(const gl::Context *context,
...
@@ -2386,6 +2391,36 @@ bool Program::linkValidateTransformFeedback(const gl::Context *context,
return
true
;
return
true
;
}
}
bool
Program
::
linkValidateGlobalNames
(
const
Context
*
context
,
InfoLog
&
infoLog
)
const
{
const
std
::
vector
<
sh
::
Uniform
>
&
vertexUniforms
=
mState
.
mAttachedVertexShader
->
getUniforms
(
context
);
const
std
::
vector
<
sh
::
Uniform
>
&
fragmentUniforms
=
mState
.
mAttachedFragmentShader
->
getUniforms
(
context
);
const
std
::
vector
<
sh
::
Attribute
>
&
attributes
=
mState
.
mAttachedVertexShader
->
getActiveAttributes
(
context
);
for
(
const
auto
&
attrib
:
attributes
)
{
for
(
const
auto
&
uniform
:
vertexUniforms
)
{
if
(
uniform
.
name
==
attrib
.
name
)
{
infoLog
<<
"Name conflicts between a uniform and an attribute: "
<<
attrib
.
name
;
return
false
;
}
}
for
(
const
auto
&
uniform
:
fragmentUniforms
)
{
if
(
uniform
.
name
==
attrib
.
name
)
{
infoLog
<<
"Name conflicts between a uniform and an attribute: "
<<
attrib
.
name
;
return
false
;
}
}
}
return
true
;
}
void
Program
::
gatherTransformFeedbackVaryings
(
const
Program
::
MergedVaryings
&
varyings
)
void
Program
::
gatherTransformFeedbackVaryings
(
const
Program
::
MergedVaryings
&
varyings
)
{
{
// Gather the linked varyings that are used for transform feedback, they should all exist.
// Gather the linked varyings that are used for transform feedback, they should all exist.
...
...
src/libANGLE/Program.h
View file @
e2a728aa
...
@@ -566,6 +566,7 @@ class Program final : angle::NonCopyable, public LabeledObject
...
@@ -566,6 +566,7 @@ class Program final : angle::NonCopyable, public LabeledObject
InfoLog
&
infoLog
,
InfoLog
&
infoLog
,
const
MergedVaryings
&
linkedVaryings
,
const
MergedVaryings
&
linkedVaryings
,
const
Caps
&
caps
)
const
;
const
Caps
&
caps
)
const
;
bool
linkValidateGlobalNames
(
const
Context
*
context
,
InfoLog
&
infoLog
)
const
;
void
gatherTransformFeedbackVaryings
(
const
MergedVaryings
&
varyings
);
void
gatherTransformFeedbackVaryings
(
const
MergedVaryings
&
varyings
);
...
...
src/tests/gl_tests/WebGLCompatibilityTest.cpp
View file @
e2a728aa
...
@@ -1511,6 +1511,28 @@ TEST_P(WebGLCompatibilityTest, BuiltInInvariant)
...
@@ -1511,6 +1511,28 @@ TEST_P(WebGLCompatibilityTest, BuiltInInvariant)
EXPECT_EQ
(
0u
,
program
);
EXPECT_EQ
(
0u
,
program
);
}
}
// Tests global namespace conflicts between uniforms and attributes.
// Based on WebGL test conformance/glsl/misc/shaders-with-name-conflicts.html.
TEST_P
(
WebGLCompatibilityTest
,
GlobalNamesConflict
)
{
const
std
::
string
vertexShader
=
"attribute vec4 foo;
\n
"
"void main()
\n
"
"{
\n
"
" gl_Position = foo;
\n
"
"}"
;
const
std
::
string
fragmentShader
=
"precision mediump float;
\n
"
"uniform vec4 foo;
\n
"
"void main()
\n
"
"{
\n
"
" gl_FragColor = foo;
\n
"
"}"
;
GLuint
program
=
CompileProgram
(
vertexShader
,
fragmentShader
);
EXPECT_EQ
(
0u
,
program
);
}
// Test dimension and image size validation of compressed textures
// Test dimension and image size validation of compressed textures
TEST_P
(
WebGLCompatibilityTest
,
CompressedTextureS3TC
)
TEST_P
(
WebGLCompatibilityTest
,
CompressedTextureS3TC
)
{
{
...
...
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