Jump to content
  • Advertisement
Sign in to follow this  
renderkid

Vulkan BC3 format is not loaded correctly

This topic is 825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys,

 

I been working on some vulkan api examples. I tried loading bc3 texture but for some reason it is not loaded correctly.

[attachment=33219:bc3Wrong.png]

 

This is how it looks in AMD compressonator:

[attachment=33220:spec_color.png]

 

Loading all the other texture formats as bc1, bc2, bc5, bc7. Is fine. I'm using GLI( texture loading. The code for loading specific texture format looks like this:

	gli::texture2d tex2D(gli::load(filename.c_str()));
	assert(!tex2D.empty());
	if (tex2D.empty())
	{
		return false;
	}

	//Find correct texture format
	gli::texture::format_type type = tex2D.format();
	switch (type)
	{
	case gli::texture::format_type::FORMAT_RGBA_BP_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC7_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT3_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC2_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RG_ATI2N_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC5_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_R_ATI1N_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC4_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT5_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC3_UNORM_BLOCK;
	case gli::texture::format_type::FORMAT_RGBA_DXT1_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
		break;
	}

You can find texture loading code on: 

https://github.com/TywyllSoftware/TywRenderer/blob/master/Renderer/Vulkan/VulkanTextureLoader.cpp

 

The project is Shadow Mapping.

 

 

Do not really know what it is the problem....

Share this post


Link to post
Share on other sites
Advertisement

	switch (type)
	{
	case gli::texture::format_type::FORMAT_RGBA_BP_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC7_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT3_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC2_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RG_ATI2N_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC5_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_R_ATI1N_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC4_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT5_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC3_UNORM_BLOCK;
// Shouldn't there be a break here?
	case gli::texture::format_type::FORMAT_RGBA_DXT1_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
		break;
	}

From a quick glance you're missing a break in your switch.

Share this post


Link to post
Share on other sites

 


	switch (type)
	{
	case gli::texture::format_type::FORMAT_RGBA_BP_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC7_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT3_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC2_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RG_ATI2N_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC5_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_R_ATI1N_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC4_UNORM_BLOCK;
		break;
	case gli::texture::format_type::FORMAT_RGBA_DXT5_UNORM_BLOCK16:
		format = VkFormat::VK_FORMAT_BC3_UNORM_BLOCK;
// Shouldn't there be a break here?
	case gli::texture::format_type::FORMAT_RGBA_DXT1_UNORM_BLOCK8:
		format = VkFormat::VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
		break;
	}

From a quick glance you're missing a break in your switch.

 

 

Daaaamn. Didn't notice it. But yeaa..... Fixed the problem.... Thanks a lot mate :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!