1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES 3.1 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 Texture buffer tests 22 *//*--------------------------------------------------------------------*/ 23 24 #include "es31fTextureBufferTests.hpp" 25 26 #include "glsTextureBufferCase.hpp" 27 28 #include "glwEnums.hpp" 29 30 #include "deStringUtil.hpp" 31 32 #include <string> 33 34 using std::string; 35 using namespace deqp::gls::TextureBufferCaseUtil; 36 using deqp::gls::TextureBufferCase; 37 38 namespace deqp 39 { 40 namespace gles31 41 { 42 namespace Functional 43 { 44 namespace 45 { 46 47 string toTestName (RenderBits renderBits) 48 { 49 struct 50 { 51 RenderBits bit; 52 const char* str; 53 } bitInfos[] = 54 { 55 { RENDERBITS_AS_VERTEX_ARRAY, "as_vertex_array" }, 56 { RENDERBITS_AS_INDEX_ARRAY, "as_index_array" }, 57 { RENDERBITS_AS_VERTEX_TEXTURE, "as_vertex_texture" }, 58 { RENDERBITS_AS_FRAGMENT_TEXTURE, "as_fragment_texture" } 59 }; 60 61 std::ostringstream stream; 62 bool first = true; 63 64 DE_ASSERT(renderBits != 0); 65 66 for (int infoNdx = 0; infoNdx < DE_LENGTH_OF_ARRAY(bitInfos); infoNdx++) 67 { 68 if (renderBits & bitInfos[infoNdx].bit) 69 { 70 stream << (first ? "" : "_") << bitInfos[infoNdx].str; 71 first = false; 72 } 73 } 74 75 return stream.str(); 76 } 77 78 string toTestName (ModifyBits modifyBits) 79 { 80 struct 81 { 82 ModifyBits bit; 83 const char* str; 84 } bitInfos[] = 85 { 86 { MODIFYBITS_BUFFERDATA, "bufferdata" }, 87 { MODIFYBITS_BUFFERSUBDATA, "buffersubdata" }, 88 { MODIFYBITS_MAPBUFFER_WRITE, "mapbuffer_write" }, 89 { MODIFYBITS_MAPBUFFER_READWRITE, "mapbuffer_readwrite" } 90 }; 91 92 std::ostringstream stream; 93 bool first = true; 94 95 DE_ASSERT(modifyBits != 0); 96 97 for (int infoNdx = 0; infoNdx < DE_LENGTH_OF_ARRAY(bitInfos); infoNdx++) 98 { 99 if (modifyBits & bitInfos[infoNdx].bit) 100 { 101 stream << (first ? "" : "_") << bitInfos[infoNdx].str; 102 first = false; 103 } 104 } 105 106 return stream.str(); 107 } 108 109 RenderBits operator| (RenderBits a, RenderBits b) 110 { 111 return (RenderBits)(deUint32(a) | deUint32(b)); 112 } 113 114 } // anonymous 115 116 TestCaseGroup* createTextureBufferTests (Context& context) 117 { 118 TestCaseGroup* const root = new TestCaseGroup(context, "texture_buffer", "Texture buffer syncronization tests"); 119 120 const size_t bufferSizes[] = 121 { 122 512, 123 513, 124 65536, 125 65537, 126 131071 127 }; 128 129 const size_t rangeSizes[] = 130 { 131 512, 132 513, 133 65537, 134 98304, 135 }; 136 137 const size_t offsets[] = 138 { 139 1, 140 7 141 }; 142 143 const RenderBits renderTypeCombinations[] = 144 { 145 RENDERBITS_AS_VERTEX_ARRAY, 146 RENDERBITS_AS_INDEX_ARRAY, 147 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_INDEX_ARRAY, 148 149 RENDERBITS_AS_VERTEX_TEXTURE, 150 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE, 151 RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE, 152 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE, 153 154 RENDERBITS_AS_FRAGMENT_TEXTURE, 155 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_FRAGMENT_TEXTURE, 156 RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_FRAGMENT_TEXTURE, 157 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_FRAGMENT_TEXTURE, 158 RENDERBITS_AS_VERTEX_TEXTURE | RENDERBITS_AS_FRAGMENT_TEXTURE, 159 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE | RENDERBITS_AS_FRAGMENT_TEXTURE, 160 RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE | RENDERBITS_AS_FRAGMENT_TEXTURE, 161 RENDERBITS_AS_VERTEX_ARRAY | RENDERBITS_AS_INDEX_ARRAY | RENDERBITS_AS_VERTEX_TEXTURE | RENDERBITS_AS_FRAGMENT_TEXTURE 162 }; 163 164 const ModifyBits modifyTypes[] = 165 { 166 MODIFYBITS_BUFFERDATA, 167 MODIFYBITS_BUFFERSUBDATA, 168 MODIFYBITS_MAPBUFFER_WRITE, 169 MODIFYBITS_MAPBUFFER_READWRITE 170 }; 171 172 // Rendering test 173 { 174 TestCaseGroup* const renderGroup = new TestCaseGroup(context, "render", "Setup texture buffer with glBufferData and render data in different ways"); 175 root->addChild(renderGroup); 176 177 for (int renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypeCombinations); renderTypeNdx++) 178 { 179 const RenderBits renderType = renderTypeCombinations[renderTypeNdx]; 180 TestCaseGroup* const renderTypeGroup = new TestCaseGroup(context, toTestName(renderType).c_str(), toTestName(renderType).c_str()); 181 182 renderGroup->addChild(renderTypeGroup); 183 184 for (int sizeNdx = 0; sizeNdx < DE_LENGTH_OF_ARRAY(bufferSizes); sizeNdx++) 185 { 186 const size_t size = bufferSizes[sizeNdx]; 187 const string name ("buffer_size_" + de::toString(size)); 188 189 renderTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, size, 0, 0, RENDERBITS_NONE, MODIFYBITS_NONE, renderType, name.c_str(), name.c_str())); 190 } 191 192 for (int sizeNdx = 0; sizeNdx < DE_LENGTH_OF_ARRAY(rangeSizes); sizeNdx++) 193 { 194 const size_t size = rangeSizes[sizeNdx]; 195 const string name ("range_size_" + de::toString(size)); 196 const size_t bufferSize = 131072; 197 198 renderTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, bufferSize, 0, size, RENDERBITS_NONE, MODIFYBITS_NONE, renderType, name.c_str(), name.c_str())); 199 } 200 201 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 202 { 203 const size_t offset = offsets[offsetNdx]; 204 const size_t bufferSize = 131072; 205 const size_t size = 65537; 206 const string name ("offset_" + de::toString(offset) + "_alignments"); 207 208 renderTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, bufferSize, offset, size, RENDERBITS_NONE, MODIFYBITS_NONE, renderType, name.c_str(), name.c_str())); 209 } 210 } 211 } 212 213 // Modify tests 214 { 215 TestCaseGroup* const modifyGroup = new TestCaseGroup(context, "modify", "Modify texture buffer content in multiple ways"); 216 root->addChild(modifyGroup); 217 218 for (int modifyNdx = 0; modifyNdx < DE_LENGTH_OF_ARRAY(modifyTypes); modifyNdx++) 219 { 220 const ModifyBits modifyType = modifyTypes[modifyNdx]; 221 TestCaseGroup* const modifyTypeGroup = new TestCaseGroup(context, toTestName(modifyType).c_str(), toTestName(modifyType).c_str()); 222 223 modifyGroup->addChild(modifyTypeGroup); 224 225 for (int sizeNdx = 0; sizeNdx < DE_LENGTH_OF_ARRAY(bufferSizes); sizeNdx++) 226 { 227 const size_t size = bufferSizes[sizeNdx]; 228 const string name ("buffer_size_" + de::toString(size)); 229 230 modifyTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, size, 0, 0, RENDERBITS_NONE, modifyType, RENDERBITS_AS_FRAGMENT_TEXTURE, name.c_str(), name.c_str())); 231 } 232 233 for (int sizeNdx = 0; sizeNdx < DE_LENGTH_OF_ARRAY(rangeSizes); sizeNdx++) 234 { 235 const size_t size = rangeSizes[sizeNdx]; 236 const string name ("range_size_" + de::toString(size)); 237 const size_t bufferSize = 131072; 238 239 modifyTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, bufferSize, 0, size, RENDERBITS_NONE, modifyType, RENDERBITS_AS_FRAGMENT_TEXTURE, name.c_str(), name.c_str())); 240 } 241 242 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 243 { 244 const size_t offset = offsets[offsetNdx]; 245 const size_t bufferSize = 131072; 246 const size_t size = 65537; 247 const string name ("offset_" + de::toString(offset) + "_alignments"); 248 249 modifyTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, bufferSize, offset, size, RENDERBITS_NONE, modifyType, RENDERBITS_AS_FRAGMENT_TEXTURE, name.c_str(), name.c_str())); 250 } 251 } 252 } 253 254 // Modify-Render tests 255 { 256 TestCaseGroup* const modifyRenderGroup = new TestCaseGroup(context, "modify_render", "Modify texture buffer content in multiple ways and render in different ways"); 257 root->addChild(modifyRenderGroup); 258 259 for (int modifyNdx = 0; modifyNdx < DE_LENGTH_OF_ARRAY(modifyTypes); modifyNdx++) 260 { 261 const ModifyBits modifyType = modifyTypes[modifyNdx]; 262 TestCaseGroup* const modifyTypeGroup = new TestCaseGroup(context, toTestName(modifyType).c_str(), toTestName(modifyType).c_str()); 263 264 modifyRenderGroup->addChild(modifyTypeGroup); 265 266 for (int renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypeCombinations); renderTypeNdx++) 267 { 268 const RenderBits renderType = renderTypeCombinations[renderTypeNdx]; 269 const size_t size = 16*1024; 270 const string name (toTestName(renderType)); 271 272 modifyTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, size, 0, 0, RENDERBITS_NONE, modifyType, renderType, name.c_str(), name.c_str())); 273 } 274 } 275 } 276 277 // Render-Modify tests 278 { 279 TestCaseGroup* const renderModifyGroup = new TestCaseGroup(context, "render_modify", "Render texture buffer and modify."); 280 root->addChild(renderModifyGroup); 281 282 for (int renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypeCombinations); renderTypeNdx++) 283 { 284 const RenderBits renderType = renderTypeCombinations[renderTypeNdx]; 285 TestCaseGroup* const renderTypeGroup = new TestCaseGroup(context, toTestName(renderType).c_str(), toTestName(renderType).c_str()); 286 287 renderModifyGroup->addChild(renderTypeGroup); 288 289 for (int modifyNdx = 0; modifyNdx < DE_LENGTH_OF_ARRAY(modifyTypes); modifyNdx++) 290 { 291 const ModifyBits modifyType = modifyTypes[modifyNdx]; 292 const size_t size = 16*1024; 293 const string name (toTestName(modifyType)); 294 295 renderTypeGroup->addChild(new TextureBufferCase(context.getTestContext(), context.getRenderContext(), GL_RGBA8, size, 0, 0, renderType, modifyType, RENDERBITS_AS_FRAGMENT_TEXTURE, name.c_str(), name.c_str())); 296 } 297 } 298 } 299 300 return root; 301 } 302 303 } // Functional 304 } // gles31 305 } // deqp 306