xref: /aosp_15_r20/external/deqp/external/openglcts/modules/gl/gl4cStencilTexturingTests.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GL4CSTENCILTEXTURINGTESTS_HPP
2 #define _GL4CSTENCILTEXTURINGTESTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2015-2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */ /*!
22  * \file
23  * \brief
24  */ /*-------------------------------------------------------------------*/
25 
26 #include "glcTestCase.hpp"
27 #include "glwDefs.hpp"
28 
29 namespace gl4cts
30 {
31 namespace StencilTexturing
32 {
33 /**
34  * * Create packed GL_DEPTH_STENCIL GL_DEPTH24_STENCIL8 format 2D texture
35  *   with a gradient in both depth and stencil components. Set
36  *   GL_DEPTH_STENCIL_TEXTURE_MODE texture parameter to GL_DEPTH_COMPONENT,
37  *   verify that no error is generated. Create framebuffer and bind it for
38  *   drawing. Use a fragment shader with a sampler2D to copy depth component
39  *   value to the output color. Draw triangle strip and read color pixels.
40  *   Verify that gradient values are copied correctly.
41  *
42  * * Set GL_DEPTH_STENCIL_TEXTURE_MODE texture parameter to GL_STENCIL_INDEX,
43  *   verify that no error is generated. Use a fragment shader with usampler2D
44  *   to copy stencil index value to output color. Draw triangle strip and read
45  *   color pixels. Verify that gradient values are copied correctly.
46  *
47  * * Repeat all the above for GL_DEPTH32F_STENCIL8 format
48  **/
49 class FunctionalTest : public deqp::TestCase
50 {
51 public:
52     FunctionalTest(deqp::Context &context);
53 
~FunctionalTest()54     ~FunctionalTest()
55     {
56     }
57 
58     virtual tcu::TestNode::IterateResult iterate();
59 
60 private:
61     /* Private routines */
62     void dispatch(glw::GLuint program_id, bool is_stencil, glw::GLuint dst_texture_id, glw::GLuint src_texture_id);
63 
64     void draw(glw::GLuint program_id, glw::GLuint dst_texture_id, glw::GLuint src_texture_id);
65 
66     glw::GLuint prepareDestinationTexture(bool is_stencil);
67 
68     glw::GLuint prepareProgram(bool is_draw, bool is_stencil);
69 
70     glw::GLuint prepareSourceTexture(glw::GLenum internal_format, bool is_stencil,
71                                      const std::vector<glw::GLubyte> &texture_data);
72 
73     void prepareSourceTextureData(glw::GLenum internal_format, std::vector<glw::GLubyte> &texture_data);
74 
75     bool verifyTexture(glw::GLuint id, glw::GLenum source_internal_format, bool is_stencil,
76                        const std::vector<glw::GLubyte> &src_texture_data);
77 
78     bool test(glw::GLenum internal_format, bool is_stencil);
79 
80     /* Private constants */
81     static const glw::GLchar *m_compute_shader_code;
82     static const glw::GLchar *m_fragment_shader_code;
83     static const glw::GLchar *m_geometry_shader_code;
84     static const glw::GLchar *m_tesselation_control_shader_code;
85     static const glw::GLchar *m_tesselation_evaluation_shader_code;
86     static const glw::GLchar *m_vertex_shader_code;
87     static const glw::GLchar *m_expected_value_depth;
88     static const glw::GLchar *m_expected_value_stencil;
89     static const glw::GLchar *m_image_definition_depth;
90     static const glw::GLchar *m_image_definition_stencil;
91     static const glw::GLchar *m_output_type_depth;
92     static const glw::GLchar *m_output_type_stencil;
93     static const glw::GLchar *m_sampler_definition_depth;
94     static const glw::GLchar *m_sampler_definition_stencil;
95     static const glw::GLuint m_height;
96     static const glw::GLint m_image_unit;
97     static const glw::GLint m_texture_unit;
98     static const glw::GLuint m_width;
99 };
100 } /* namespace StencilTexturing */
101 
102 class StencilTexturingTests : public deqp::TestCaseGroup
103 {
104 public:
105     StencilTexturingTests(deqp::Context &context);
106     ~StencilTexturingTests(void);
107 
108     virtual void init(void);
109 
110 private:
111     StencilTexturingTests(const StencilTexturingTests &other);
112     StencilTexturingTests &operator=(const StencilTexturingTests &other);
113 };
114 } /* namespace gl4cts */
115 
116 #endif // _GL4CSTENCILTEXTURINGTESTS_HPP
117