1e5c31af7Sopenharmony_ci#ifndef _ESEXTCTESSELLATIONSHADERBARRIER_HPP 2e5c31af7Sopenharmony_ci#define _ESEXTCTESSELLATIONSHADERBARRIER_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite 5e5c31af7Sopenharmony_ci * ----------------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright (c) 2014-2016 The Khronos Group Inc. 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci * limitations under the License. 20e5c31af7Sopenharmony_ci * 21e5c31af7Sopenharmony_ci */ /*! 22e5c31af7Sopenharmony_ci * \file 23e5c31af7Sopenharmony_ci * \brief 24e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "gluShaderUtil.hpp" 27e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci#include "../esextcTestCaseBase.hpp" 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_cinamespace glcts 32e5c31af7Sopenharmony_ci{ 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ci/* Groups all barrier tests */ 35e5c31af7Sopenharmony_ciclass TessellationShaderBarrierTests : public TestCaseGroupBase 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_cipublic: 38e5c31af7Sopenharmony_ci /* Public methods */ 39e5c31af7Sopenharmony_ci TessellationShaderBarrierTests(Context& context, const ExtParameters& extParams); 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ci virtual void init(void); 42e5c31af7Sopenharmony_ci}; 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_ci/** Base class for all tests that check the memory barrier functionality. 45e5c31af7Sopenharmony_ci **/ 46e5c31af7Sopenharmony_ciclass TessellationShaderBarrierTestCase : public TestCaseBase 47e5c31af7Sopenharmony_ci{ 48e5c31af7Sopenharmony_cipublic: 49e5c31af7Sopenharmony_ci /* Public methods */ 50e5c31af7Sopenharmony_ci TessellationShaderBarrierTestCase(Context& context, const ExtParameters& extParams, const char* name, 51e5c31af7Sopenharmony_ci const char* description); 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci virtual ~TessellationShaderBarrierTestCase(void) 54e5c31af7Sopenharmony_ci { 55e5c31af7Sopenharmony_ci } 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_ci virtual void deinit(); 58e5c31af7Sopenharmony_ci virtual void initTest(void); 59e5c31af7Sopenharmony_ci virtual IterateResult iterate(void); 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ciprotected: 62e5c31af7Sopenharmony_ci /* Protected methods */ 63e5c31af7Sopenharmony_ci virtual void getDrawCallArgs(glw::GLenum* out_mode, glw::GLint* out_count, glw::GLenum* out_tf_mode, 64e5c31af7Sopenharmony_ci glw::GLint* out_n_patch_vertices, glw::GLint* out_n_instances) = 0; 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_ci virtual const char* getTCSCode() = 0; 67e5c31af7Sopenharmony_ci virtual const char* getTESCode() = 0; 68e5c31af7Sopenharmony_ci virtual const char* getVSCode() = 0; 69e5c31af7Sopenharmony_ci virtual int getXFBBufferSize() = 0; 70e5c31af7Sopenharmony_ci virtual void getXFBProperties(int* out_n_names, const char*** out_names) = 0; 71e5c31af7Sopenharmony_ci virtual bool verifyXFBBuffer(const void* data) = 0; 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_ci /* Protected variables */ 74e5c31af7Sopenharmony_ci glw::GLuint m_bo_id; 75e5c31af7Sopenharmony_ci glw::GLuint m_fs_id; 76e5c31af7Sopenharmony_ci glw::GLuint m_po_id; 77e5c31af7Sopenharmony_ci glw::GLuint m_tcs_id; 78e5c31af7Sopenharmony_ci glw::GLuint m_tes_id; 79e5c31af7Sopenharmony_ci glw::GLuint m_vao_id; 80e5c31af7Sopenharmony_ci glw::GLuint m_vs_id; 81e5c31af7Sopenharmony_ci}; 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci/** Implementation of Test Case 22.1 84e5c31af7Sopenharmony_ci * 85e5c31af7Sopenharmony_ci * Make sure that a barrier used in a tessellation control shader synchronizes 86e5c31af7Sopenharmony_ci * all instances working on the same patch. Tests the following scenario: 87e5c31af7Sopenharmony_ci * 88e5c31af7Sopenharmony_ci * * invocation A can correctly read a per-vertex & per-patch attribute 89e5c31af7Sopenharmony_ci * modified by invocation B after a barrier() call; 90e5c31af7Sopenharmony_ci **/ 91e5c31af7Sopenharmony_ciclass TessellationShaderBarrier1 : public TessellationShaderBarrierTestCase 92e5c31af7Sopenharmony_ci{ 93e5c31af7Sopenharmony_cipublic: 94e5c31af7Sopenharmony_ci /* Public methods */ 95e5c31af7Sopenharmony_ci TessellationShaderBarrier1(Context& context, const ExtParameters& extParams); 96e5c31af7Sopenharmony_ci 97e5c31af7Sopenharmony_ci virtual ~TessellationShaderBarrier1(void) 98e5c31af7Sopenharmony_ci { 99e5c31af7Sopenharmony_ci } 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ciprotected: 102e5c31af7Sopenharmony_ci /* Protected methods */ 103e5c31af7Sopenharmony_ci void getDrawCallArgs(glw::GLenum* out_mode, glw::GLint* out_count, glw::GLenum* out_tf_mode, 104e5c31af7Sopenharmony_ci glw::GLint* out_n_patch_vertices, glw::GLint* out_n_instances); 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci const char* getTCSCode(); 107e5c31af7Sopenharmony_ci const char* getTESCode(); 108e5c31af7Sopenharmony_ci const char* getVSCode(); 109e5c31af7Sopenharmony_ci int getXFBBufferSize(); 110e5c31af7Sopenharmony_ci void getXFBProperties(int* out_n_names, const char*** out_names); 111e5c31af7Sopenharmony_ci bool verifyXFBBuffer(const void* data); 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ciprivate: 114e5c31af7Sopenharmony_ci /* Private fields */ 115e5c31af7Sopenharmony_ci unsigned int m_n_input_vertices; 116e5c31af7Sopenharmony_ci const unsigned int m_n_result_vertices; 117e5c31af7Sopenharmony_ci}; 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_ci/** Implementation of Test Case 22.2 120e5c31af7Sopenharmony_ci * 121e5c31af7Sopenharmony_ci * Make sure that a barrier used in a tessellation control shader synchronizes 122e5c31af7Sopenharmony_ci * all instances working on the same patch. Tests the following scenario: 123e5c31af7Sopenharmony_ci * 124e5c31af7Sopenharmony_ci * * invocation A writes to a per-patch output. A barrier is then issued, 125e5c31af7Sopenharmony_ci * after which invocation B overwrites the same per-patch output. One more 126e5c31af7Sopenharmony_ci * barrier is issued, after which invocation A should be able to read this 127e5c31af7Sopenharmony_ci * output correctly. 128e5c31af7Sopenharmony_ci **/ 129e5c31af7Sopenharmony_ciclass TessellationShaderBarrier2 : public TessellationShaderBarrierTestCase 130e5c31af7Sopenharmony_ci{ 131e5c31af7Sopenharmony_cipublic: 132e5c31af7Sopenharmony_ci /* Public methods */ 133e5c31af7Sopenharmony_ci TessellationShaderBarrier2(Context& context, const ExtParameters& extParams); 134e5c31af7Sopenharmony_ci 135e5c31af7Sopenharmony_ci virtual ~TessellationShaderBarrier2(void) 136e5c31af7Sopenharmony_ci { 137e5c31af7Sopenharmony_ci } 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_ciprotected: 140e5c31af7Sopenharmony_ci /* Protected methods */ 141e5c31af7Sopenharmony_ci void getDrawCallArgs(glw::GLenum* out_mode, glw::GLint* out_count, glw::GLenum* out_tf_mode, 142e5c31af7Sopenharmony_ci glw::GLint* out_n_patch_vertices, glw::GLint* out_n_instances); 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci const char* getTCSCode(); 145e5c31af7Sopenharmony_ci const char* getTESCode(); 146e5c31af7Sopenharmony_ci const char* getVSCode(); 147e5c31af7Sopenharmony_ci int getXFBBufferSize(); 148e5c31af7Sopenharmony_ci void getXFBProperties(int* out_n_names, const char*** out_names); 149e5c31af7Sopenharmony_ci bool verifyXFBBuffer(const void* data); 150e5c31af7Sopenharmony_ci 151e5c31af7Sopenharmony_ciprivate: 152e5c31af7Sopenharmony_ci /* Private fields */ 153e5c31af7Sopenharmony_ci unsigned int m_n_input_vertices; 154e5c31af7Sopenharmony_ci const unsigned int m_n_result_vertices; 155e5c31af7Sopenharmony_ci}; 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ci/** Implementation of Test Case 22.3 158e5c31af7Sopenharmony_ci * 159e5c31af7Sopenharmony_ci * Make sure that a barrier used in a tessellation control shader synchronizes 160e5c31af7Sopenharmony_ci * all instances working on the same patch. Tests the following scenario: 161e5c31af7Sopenharmony_ci * 162e5c31af7Sopenharmony_ci * * even invocations should write their gl_InvocationID value to their 163e5c31af7Sopenharmony_ci * per-vertex output. A barrier is then issued, after which each odd invocation 164e5c31af7Sopenharmony_ci * should read values stored by preceding even invocation, add current 165e5c31af7Sopenharmony_ci * invocation's ID to that value and then write it to its per-vertex output. 166e5c31af7Sopenharmony_ci * One more barrier should be issued. Then, every fourth invocation should 167e5c31af7Sopenharmony_ci * read & sum up per-vertex outputs for four invocations following it 168e5c31af7Sopenharmony_ci * (including the one discussed), and store it in a per-patch variable. (n+1)-th, 169e5c31af7Sopenharmony_ci * (n+2)-th and (n+3)-th invocations should store zero in dedicated per-patch 170e5c31af7Sopenharmony_ci * variables. 16 invocations should be considered, with 10 instances used for the 171e5c31af7Sopenharmony_ci * draw call, each patch should consist of 8 vertices. 172e5c31af7Sopenharmony_ci **/ 173e5c31af7Sopenharmony_ciclass TessellationShaderBarrier3 : public TessellationShaderBarrierTestCase 174e5c31af7Sopenharmony_ci{ 175e5c31af7Sopenharmony_cipublic: 176e5c31af7Sopenharmony_ci /* Public methods */ 177e5c31af7Sopenharmony_ci TessellationShaderBarrier3(Context& context, const ExtParameters& extParams); 178e5c31af7Sopenharmony_ci 179e5c31af7Sopenharmony_ci virtual ~TessellationShaderBarrier3(void) 180e5c31af7Sopenharmony_ci { 181e5c31af7Sopenharmony_ci } 182e5c31af7Sopenharmony_ci 183e5c31af7Sopenharmony_ciprotected: 184e5c31af7Sopenharmony_ci /* Protected methods */ 185e5c31af7Sopenharmony_ci void getDrawCallArgs(glw::GLenum* out_mode, glw::GLint* out_count, glw::GLenum* out_tf_mode, 186e5c31af7Sopenharmony_ci glw::GLint* out_n_patch_vertices, glw::GLint* out_n_instances); 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci const char* getTCSCode(); 189e5c31af7Sopenharmony_ci const char* getTESCode(); 190e5c31af7Sopenharmony_ci const char* getVSCode(); 191e5c31af7Sopenharmony_ci int getXFBBufferSize(); 192e5c31af7Sopenharmony_ci void getXFBProperties(int* out_n_names, const char*** out_names); 193e5c31af7Sopenharmony_ci bool verifyXFBBuffer(const void* data); 194e5c31af7Sopenharmony_ci 195e5c31af7Sopenharmony_ciprivate: 196e5c31af7Sopenharmony_ci /* Private fields */ 197e5c31af7Sopenharmony_ci unsigned int m_n_input_vertices; 198e5c31af7Sopenharmony_ci const unsigned int m_n_instances; 199e5c31af7Sopenharmony_ci const unsigned int m_n_invocations; 200e5c31af7Sopenharmony_ci const unsigned int m_n_patch_vertices; 201e5c31af7Sopenharmony_ci const unsigned int m_n_patches_per_invocation; 202e5c31af7Sopenharmony_ci const unsigned int m_n_result_vertices; 203e5c31af7Sopenharmony_ci}; 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ci} // namespace glcts 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_ci#endif // _ESEXTCTESSELLATIONSHADERBARRIER_HPP 208