Home | History | Annotate | Download | only in texture_cube_map_array
      1 #ifndef _ESEXTCTEXTURECUBEMAPARRAYSTENCILATTACHMENTS_HPP
      2 #define _ESEXTCTEXTURECUBEMAPARRAYSTENCILATTACHMENTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2014-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 /*!
     27  * \file  esextcTextureCubeMapArrayStencilAttachments.hpp
     28  * \brief Texture Cube Map Array Stencil Attachments (Test 3)
     29  */ /*-------------------------------------------------------------------*/
     30 
     31 #include "../esextcTestCaseBase.hpp"
     32 
     33 namespace glcts
     34 {
     35 
     36 /** Class used to store configuration and data for different texture cube map array textures
     37  */
     38 class CubeMapArrayDataStorage
     39 {
     40 public:
     41 	/* Public functions */
     42 	CubeMapArrayDataStorage();
     43 	~CubeMapArrayDataStorage();
     44 
     45 	void deinit(void);
     46 	void init(const glw::GLuint width, const glw::GLuint height, const glw::GLuint depth,
     47 			  glw::GLubyte initial_value = 0);
     48 
     49 	inline glw::GLuint getDepth() const
     50 	{
     51 		return m_depth;
     52 	}
     53 	inline glw::GLuint getHeight() const
     54 	{
     55 		return m_height;
     56 	}
     57 	inline glw::GLuint getWidth() const
     58 	{
     59 		return m_width;
     60 	}
     61 
     62 	glw::GLuint   getArraySize() const;
     63 	glw::GLubyte* getDataArray() const;
     64 
     65 protected:
     66 	/* Protected variables */
     67 	glw::GLubyte* m_data_array;
     68 	glw::GLuint   m_depth;
     69 	glw::GLuint   m_height;
     70 	glw::GLuint   m_width;
     71 };
     72 
     73 /**  Implementation of Test 3 from CTS_EXT_texture_cube_map_array.
     74  *   Test description follows:
     75  *
     76  *   Make sure cube-map texture layers can be used as stencil attachments.
     77  *
     78  *   Category: Functionality tests,
     79  *             Optional dependency on EXT_geometry_shader;
     80  *   Priority: Must-have.
     81  *
     82  *   Verify that a cube-map array texture layers carrying stencil data
     83  *   can be used as a stencil attachment for a framebuffer object.
     84  *
     85  *   Clear the color buffer with (1, 0, 0, 1) color. Fill the upper half of
     86  *   the stencil buffer with 1 and the bottom half of the stencil buffer with 0.
     87  *
     88  *   Configure the stencil test so that it the test passes only if the stencil
     89  *   buffer data for each fragment is larger than 0.
     90  *   The fragment shader should set the only output variable to (0, 1, 1, 0).
     91  *
     92  *   The test should render a full-screen quad and then check the outcome of
     93  *   the operation. The test passes if top half is filled with (0, 1, 1, 0)
     94  *   and bottom half is set to (1, 0, 0, 1).
     95  *
     96  *   Rendering to both layered (if supported) and non-layered framebuffer
     97  *   objects should be verified.
     98  *
     99  *   Test four different cube-map array texture resolutions, as described
    100  *   in test 1. Both immutable and mutable textures should be checked.
    101  */
    102 class TextureCubeMapArrayStencilAttachments : public TestCaseBase
    103 {
    104 public:
    105 	/* Public functions */
    106 	TextureCubeMapArrayStencilAttachments(Context& context, const ExtParameters& extParams, const char* name,
    107 										  const char* description, glw::GLboolean immutable_storage,
    108 										  glw::GLboolean fbo_layered);
    109 
    110 	virtual ~TextureCubeMapArrayStencilAttachments()
    111 	{
    112 	}
    113 
    114 	virtual IterateResult iterate(void);
    115 	virtual void		  deinit(void);
    116 
    117 	/* Public variables */
    118 	static const glw::GLuint m_n_components;
    119 	static const glw::GLuint m_n_cube_map_array_configurations;
    120 	static const glw::GLuint m_n_vertices_gs;
    121 
    122 private:
    123 	/* Private variables */
    124 	static const char* m_fragment_shader_code;
    125 	static const char* m_vertex_shader_code;
    126 
    127 	glw::GLboolean m_fbo_layered;
    128 	glw::GLboolean m_immutable_storage;
    129 
    130 	glw::GLuint m_fbo_draw_id;
    131 	glw::GLuint m_fbo_read_id;
    132 	glw::GLuint m_fragment_shader_id;
    133 	glw::GLuint m_geometry_shader_id;
    134 	glw::GLuint m_program_id;
    135 	glw::GLuint m_texture_cube_array_stencil_id;
    136 	glw::GLuint m_texture_cube_array_color_id;
    137 	glw::GLuint m_vao_id;
    138 	glw::GLuint m_vbo_id;
    139 	glw::GLuint m_vertex_shader_id;
    140 
    141 	CubeMapArrayDataStorage* m_cube_map_array_data;
    142 	glw::GLubyte*			 m_result_data;
    143 
    144 	/* Private functions */
    145 	void buildAndUseProgram(glw::GLuint test_index);
    146 	void checkFramebufferStatus(glw::GLenum framebuffer_status);
    147 	void cleanAfterTest(void);
    148 	void createImmutableCubeArrayColor(glw::GLuint test_index);
    149 	void createImmutableCubeArrayStencil(glw::GLuint test_index);
    150 	void createMutableCubeArrayColor(glw::GLuint test_index);
    151 	void createMutableCubeArrayStencil(glw::GLuint test_index);
    152 	void fillStencilData(glw::GLuint test_index);
    153 	std::string getGeometryShaderCode(const std::string& max_vertices, const std::string& n_layers);
    154 	void initTest(void);
    155 	void initTestIteration(glw::GLuint test_index);
    156 	bool readPixelsAndCompareWithExpectedResult(glw::GLuint test_index);
    157 	void setupLayeredFramebuffer(void);
    158 	void setupNonLayeredFramebuffer(void);
    159 };
    160 
    161 } // namespace glcts
    162 
    163 #endif // _ESEXTCTEXTURECUBEMAPARRAYSTENCILATTACHMENTS_HPP
    164