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
219ed797
Commit
219ed797
authored
Oct 18, 2013
by
Geoff Lang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added occlusion query tests.
TRAC #23776 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
parent
d191317e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
178 additions
and
0 deletions
+178
-0
OcclusionQueriesTest.cpp
tests/angle_tests/OcclusionQueriesTest.cpp
+178
-0
No files found.
tests/angle_tests/OcclusionQueriesTest.cpp
0 → 100644
View file @
219ed797
#include "ANGLETest.h"
class
OcclusionQueriesTest
:
public
ANGLETest
{
protected
:
OcclusionQueriesTest
()
{
setWindowWidth
(
128
);
setWindowHeight
(
128
);
setRedBits
(
8
);
setGreenBits
(
8
);
setBlueBits
(
8
);
setAlphaBits
(
8
);
setDepthBits
(
24
);
mProgram
=
0
;
}
virtual
void
SetUp
()
{
ANGLETest
::
SetUp
();
const
std
::
string
passthroughVS
=
SHADER_SOURCE
(
attribute
highp
vec4
position
;
void
main
(
void
)
{
gl_Position
=
position
;
}
);
const
std
::
string
passthroughPS
=
SHADER_SOURCE
(
precision
highp
float
;
void
main
(
void
)
{
gl_FragColor
=
vec4
(
1.0
,
1.0
,
1.0
,
1.0
);
}
);
mProgram
=
compileProgram
(
passthroughVS
,
passthroughPS
);
if
(
mProgram
==
0
)
{
FAIL
()
<<
"shader compilation failed."
;
}
}
virtual
void
TearDown
()
{
glDeleteProgram
(
mProgram
);
ANGLETest
::
TearDown
();
}
GLuint
mProgram
;
};
TEST_F
(
OcclusionQueriesTest
,
is_occuluded
)
{
glDepthMask
(
GL_TRUE
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
// draw a quad at depth 0.3
glEnable
(
GL_DEPTH_TEST
);
glUseProgram
(
mProgram
);
drawQuad
(
mProgram
,
"position"
,
0.3
f
);
glUseProgram
(
0
);
EXPECT_GL_NO_ERROR
();
GLuint
query
=
0
;
glGenQueriesEXT
(
1
,
&
query
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
,
query
);
drawQuad
(
mProgram
,
"position"
,
0.8
f
);
// this quad should be occluded by first quad
glEndQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
);
EXPECT_GL_NO_ERROR
();
swapBuffers
();
GLuint
ready
=
GL_FALSE
;
while
(
ready
==
GL_FALSE
)
{
Sleep
(
0
);
glGetQueryObjectuivEXT
(
query
,
GL_QUERY_RESULT_AVAILABLE_EXT
,
&
ready
);
}
GLuint
result
=
GL_TRUE
;
glGetQueryObjectuivEXT
(
query
,
GL_QUERY_RESULT_EXT
,
&
result
);
EXPECT_GL_NO_ERROR
();
glDeleteQueriesEXT
(
1
,
&
query
);
EXPECT_EQ
(
result
,
GL_FALSE
);
}
TEST_F
(
OcclusionQueriesTest
,
is_not_occuluded
)
{
glDepthMask
(
GL_TRUE
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
EXPECT_GL_NO_ERROR
();
GLuint
query
=
0
;
glGenQueriesEXT
(
1
,
&
query
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
,
query
);
drawQuad
(
mProgram
,
"position"
,
0.8
f
);
// this quad should not be occluded
glEndQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
);
EXPECT_GL_NO_ERROR
();
swapBuffers
();
GLuint
result
=
GL_TRUE
;
glGetQueryObjectuivEXT
(
query
,
GL_QUERY_RESULT_EXT
,
&
result
);
// will block waiting for result
EXPECT_GL_NO_ERROR
();
glDeleteQueriesEXT
(
1
,
&
query
);
EXPECT_EQ
(
result
,
GL_TRUE
);
}
TEST_F
(
OcclusionQueriesTest
,
errors
)
{
glDepthMask
(
GL_TRUE
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
EXPECT_GL_NO_ERROR
();
GLuint
query
=
0
;
GLuint
query2
=
0
;
glGenQueriesEXT
(
1
,
&
query
);
EXPECT_EQ
(
glIsQueryEXT
(
query
),
GL_FALSE
);
EXPECT_EQ
(
glIsQueryEXT
(
query2
),
GL_FALSE
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
,
0
);
// can't pass 0 as query id
EXPECT_GL_ERROR
(
GL_INVALID_OPERATION
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
,
query
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
,
query2
);
// can't initiate a query while one's already active
EXPECT_GL_ERROR
(
GL_INVALID_OPERATION
);
EXPECT_EQ
(
glIsQueryEXT
(
query
),
GL_TRUE
);
EXPECT_EQ
(
glIsQueryEXT
(
query2
),
GL_FALSE
);
// have not called begin
drawQuad
(
mProgram
,
"position"
,
0.8
f
);
// this quad should not be occluded
glEndQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
);
// no active query for this target
EXPECT_GL_ERROR
(
GL_INVALID_OPERATION
);
glEndQueryEXT
(
GL_ANY_SAMPLES_PASSED_EXT
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
,
query
);
// can't begin a query as a different type than previously used
EXPECT_GL_ERROR
(
GL_INVALID_OPERATION
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
,
query2
);
// have to call genqueries first
EXPECT_EQ
(
glGetError
(),
GL_INVALID_OPERATION
);
glGenQueriesEXT
(
1
,
&
query2
);
glBeginQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
,
query2
);
// should be ok now
EXPECT_EQ
(
glIsQueryEXT
(
query2
),
GL_TRUE
);
drawQuad
(
mProgram
,
"position"
,
0.3
f
);
// this should draw in front of other quad
glDeleteQueriesEXT
(
1
,
&
query2
);
// should delete when query becomes inactive
glEndQueryEXT
(
GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
);
// should not incur error; should delete query + 1 at end of execution.
EXPECT_GL_NO_ERROR
();
swapBuffers
();
EXPECT_GL_NO_ERROR
();
GLuint
ready
=
GL_FALSE
;
glGetQueryObjectuivEXT
(
query2
,
GL_QUERY_RESULT_AVAILABLE_EXT
,
&
ready
);
// this query is now deleted
EXPECT_GL_ERROR
(
GL_INVALID_OPERATION
);
EXPECT_GL_NO_ERROR
();
}
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