Added ETC2 and ASTC texture variants (Refs #174)

This commit is contained in:
saschawillems 2017-03-15 20:08:03 +01:00
parent 32f4b240fc
commit ecb688e8c7
4 changed files with 26 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View file

@ -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();