| 328 | } |
| 329 | |
| 330 | VulkanLoadTestSample* |
| 331 | VulkanLoadTests::showFile(const std::string& filename) |
| 332 | { |
| 333 | KTX_error_code ktxresult; |
| 334 | ktxTexture* kTexture; |
| 335 | ktxresult = ktxTexture_CreateFromNamedFile(filename.c_str(), |
| 336 | KTX_TEXTURE_CREATE_NO_FLAGS, |
| 337 | &kTexture); |
| 338 | if (KTX_SUCCESS != ktxresult) { |
| 339 | std::stringstream message; |
| 340 | |
| 341 | message << "Creation of ktxTexture from \"" << filename |
| 342 | << "\" failed: " << ktxErrorString(ktxresult); |
| 343 | throw std::runtime_error(message.str()); |
| 344 | } |
| 345 | |
| 346 | VulkanLoadTestSample::PFN_create createViewer; |
| 347 | VulkanLoadTestSample* pViewer; |
| 348 | if (kTexture->numDimensions == 3) |
| 349 | createViewer = Texture3d::create; |
| 350 | else if (kTexture->isArray && kTexture->isCubemap) { |
| 351 | // TODO: Add cubemap array app. |
| 352 | std::stringstream message; |
| 353 | message << "Display of cubemap array textures not yet implemented."; |
| 354 | throw std::runtime_error(message.str()); |
| 355 | } else if (kTexture->isArray) { |
| 356 | createViewer = TextureArray::create; |
| 357 | } else if (kTexture->isCubemap) { |
| 358 | createViewer = TextureCubemap::create; |
| 359 | } else if (kTexture->numLevels > 1) { |
| 360 | createViewer = TextureMipmap::create; |
| 361 | } else { |
| 362 | createViewer = Texture::create; |
| 363 | } |
| 364 | ktxTexture_Destroy(kTexture); |
| 365 | |
| 366 | // Escape any spaces in filename. |
| 367 | std::string args = "--external " + std::regex_replace( filename, std::regex(" "), "\\ " ); |
| 368 | pViewer = createViewer(vkctx, w_width, w_height, args.c_str(), sBasePath); |
| 369 | return pViewer; |
| 370 | } |
| 371 | |
| 372 | /* ------------------------------------------------------------------------ */ |
| 373 |
nothing calls this directly
no test coverage detected