1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief GLES3 Scissor tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fScissorTests.hpp"
25
26 #include "glsScissorTests.hpp"
27
28 #include "sglrGLContext.hpp"
29 #include "sglrReferenceContext.hpp"
30 #include "sglrContextUtil.hpp"
31
32 #include "tcuVector.hpp"
33 #include "tcuRenderTarget.hpp"
34 #include "tcuImageCompare.hpp"
35
36 #include "gluStrUtil.hpp"
37 #include "gluDrawUtil.hpp"
38
39 #include "glwEnums.hpp"
40 #include "deDefs.hpp"
41
42 namespace deqp
43 {
44 namespace gles3
45 {
46 namespace Functional
47 {
48
ScissorTests(Context & context)49 ScissorTests::ScissorTests(Context &context) : TestCaseGroup(context, "scissor", "Scissor Tests")
50 {
51 }
52
~ScissorTests(void)53 ScissorTests::~ScissorTests(void)
54 {
55 }
56
init(void)57 void ScissorTests::init(void)
58 {
59 using tcu::Vec4;
60 using namespace gls::Functional::ScissorTestInternal;
61
62 tcu::TestContext &tc = m_context.getTestContext();
63 glu::RenderContext &rc = m_context.getRenderContext();
64
65 const struct
66 {
67 const char *name;
68 const char *desc;
69 const tcu::Vec4 scissor;
70 const tcu::Vec4 render;
71 const PrimitiveType type;
72 const int primitives;
73 } cases[] = {{"contained_quads", "Triangles fully inside scissor area (single call)", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
74 Vec4(0.2f, 0.2f, 0.6f, 0.6f), TRIANGLE, 30},
75 {"partial_quads", "Triangles partially inside scissor area (single call)",
76 Vec4(0.3f, 0.3f, 0.4f, 0.4f), Vec4(0.2f, 0.2f, 0.6f, 0.6f), TRIANGLE, 30},
77 {"contained_tri", "Triangle fully inside scissor area", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
78 Vec4(0.2f, 0.2f, 0.6f, 0.6f), TRIANGLE, 1},
79 {"enclosing_tri", "Triangle fully covering scissor area", Vec4(0.4f, 0.4f, 0.2f, 0.2f),
80 Vec4(0.2f, 0.2f, 0.6f, 0.6f), TRIANGLE, 1},
81 {"partial_tri", "Triangle partially inside scissor area", Vec4(0.4f, 0.4f, 0.6f, 0.6f),
82 Vec4(0.0f, 0.0f, 1.0f, 1.0f), TRIANGLE, 1},
83 {"outside_render_tri", "Triangle with scissor area outside render target",
84 Vec4(1.4f, 1.4f, 0.6f, 0.6f), Vec4(0.0f, 0.0f, 0.6f, 0.6f), TRIANGLE, 1},
85 {"partial_lines", "Linse partially inside scissor area", Vec4(0.4f, 0.4f, 0.6f, 0.6f),
86 Vec4(0.0f, 0.0f, 1.0f, 1.0f), LINE, 30},
87 {"contained_line", "Line fully inside scissor area", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
88 Vec4(0.2f, 0.2f, 0.6f, 0.6f), LINE, 1},
89 {"partial_line", "Line partially inside scissor area", Vec4(0.4f, 0.4f, 0.6f, 0.6f),
90 Vec4(0.0f, 0.0f, 1.0f, 1.0f), LINE, 1},
91 {"outside_render_line", "Line with scissor area outside render target", Vec4(1.4f, 1.4f, 0.6f, 0.6f),
92 Vec4(0.0f, 0.0f, 0.6f, 0.6f), LINE, 1},
93 {"contained_point", "Point fully inside scissor area", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
94 Vec4(0.5f, 0.5f, 0.0f, 0.0f), POINT, 1},
95 {"partial_points", "Points partially inside scissor area", Vec4(0.4f, 0.4f, 0.6f, 0.6f),
96 Vec4(0.0f, 0.0f, 1.0f, 1.0f), POINT, 30},
97 {"outside_point", "Point fully outside scissor area", Vec4(0.4f, 0.4f, 0.6f, 0.6f),
98 Vec4(0.0f, 0.0f, 0.0f, 0.0f), POINT, 1},
99 {"outside_render_point", "Point with scissor area outside render target", Vec4(1.4f, 1.4f, 0.6f, 0.6f),
100 Vec4(0.5f, 0.5f, 0.0f, 0.0f), POINT, 1}};
101
102 for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
103 {
104 addChild(createPrimitiveTest(tc, rc, cases[caseNdx].name, cases[caseNdx].desc, cases[caseNdx].scissor,
105 cases[caseNdx].render, cases[caseNdx].type, cases[caseNdx].primitives));
106 }
107
108 addChild(createClearTest(tc, rc, "clear_depth", "Depth buffer clear", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
109 GL_DEPTH_BUFFER_BIT));
110 addChild(createClearTest(tc, rc, "clear_stencil", "Stencil buffer clear", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
111 GL_STENCIL_BUFFER_BIT));
112 addChild(createClearTest(tc, rc, "clear_color", "Color buffer clear", Vec4(0.1f, 0.1f, 0.8f, 0.8f),
113 GL_COLOR_BUFFER_BIT));
114
115 addChild(createFramebufferClearTest(tc, rc, "clear_fixed_buffer", "Fixed point color clear", CLEAR_COLOR_FIXED));
116 addChild(createFramebufferClearTest(tc, rc, "clear_int_buffer", "Integer color clear", CLEAR_COLOR_INT));
117 addChild(
118 createFramebufferClearTest(tc, rc, "clear_uint_buffer", "Unsigned integer buffer clear", CLEAR_COLOR_UINT));
119 addChild(createFramebufferClearTest(tc, rc, "clear_depth_buffer", "Depth buffer clear", CLEAR_DEPTH));
120 addChild(createFramebufferClearTest(tc, rc, "clear_stencil_buffer", "Stencil buffer clear", CLEAR_STENCIL));
121 addChild(createFramebufferClearTest(tc, rc, "clear_depth_stencil_buffer", "Fixed point color buffer clear",
122 CLEAR_DEPTH_STENCIL));
123
124 addChild(createFramebufferBlitTest(tc, rc, "framebuffer_blit_center",
125 "Blit to default framebuffer, scissor away edges",
126 Vec4(0.1f, 0.1f, 0.8f, 0.8f)));
127 addChild(createFramebufferBlitTest(tc, rc, "framebuffer_blit_corner",
128 "Blit to default framebuffer, scissor all but a corner",
129 Vec4(0.6f, 0.6f, 0.5f, 0.5f)));
130 addChild(createFramebufferBlitTest(tc, rc, "framebuffer_blit_none",
131 "Blit to default framebuffer, scissor area outside screen",
132 Vec4(1.6f, 0.6f, 0.5f, 0.5f)));
133 }
134
135 } // namespace Functional
136 } // namespace gles3
137 } // namespace deqp
138