diff --git a/data/textures/cubemap_yokohama_astc_8x8_unorm.ktx b/data/textures/cubemap_yokohama_astc_8x8_unorm.ktx new file mode 100644 index 00000000..48dbe7e9 Binary files /dev/null and b/data/textures/cubemap_yokohama_astc_8x8_unorm.ktx differ diff --git a/data/textures/cubemap_yokohama.ktx b/data/textures/cubemap_yokohama_bc3_unorm.ktx similarity index 100% rename from data/textures/cubemap_yokohama.ktx rename to data/textures/cubemap_yokohama_bc3_unorm.ktx diff --git a/data/textures/cubemap_yokohama_etc2_unorm.ktx b/data/textures/cubemap_yokohama_etc2_unorm.ktx new file mode 100644 index 00000000..350b3d65 Binary files /dev/null and b/data/textures/cubemap_yokohama_etc2_unorm.ktx differ diff --git a/texturecubemap/texturecubemap.cpp b/texturecubemap/texturecubemap.cpp index 5faeffaa..9d19a458 100644 --- a/texturecubemap/texturecubemap.cpp +++ b/texturecubemap/texturecubemap.cpp @@ -299,6 +299,31 @@ public: vkDestroyBuffer(device, stagingBuffer, nullptr); } + void loadTextures() + { + // Vulkan core supports three different compressed texture formats + // As the support differs between implemementations we need to check device features and select a proper format and file + std::string filename; + VkFormat format; + if (deviceFeatures.textureCompressionBC) { + filename = "cubemap_yokohama_bc3_unorm.ktx"; + format = VK_FORMAT_BC2_UNORM_BLOCK; + } + else if (deviceFeatures.textureCompressionASTC_LDR) { + filename = "cubemap_yokohama_astc_8x8_unorm.ktx"; + format = VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + } + else if (deviceFeatures.textureCompressionETC2) { + filename = "cubemap_yokohama_etc2_unorm.ktx"; + format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + } + else { + vks::tools::exitFatal("Device does not support any compressed texture format!", "Error"); + } + + loadCubemap(getAssetPath() + "textures/" + filename, format, false); + } + void reBuildCommandBuffers() { if (!checkCommandBuffers()) @@ -676,13 +701,10 @@ public: void prepare() { VulkanExampleBase::prepare(); + loadTextures(); loadMeshes(); setupVertexDescriptions(); prepareUniformBuffers(); - loadCubemap( - getAssetPath() + "textures/cubemap_yokohama.ktx", - VK_FORMAT_BC3_UNORM_BLOCK, - false); setupDescriptorSetLayout(); preparePipelines(); setupDescriptorPool();