Jump to content
  • Advertisement
ravarcade

Vulkan Crash in amdvlk64.dll (div by zero) when R8G8B8_UNORM or R16G16B16_UNORM is used as vertex attrib format.

Recommended Posts

I get very strange error in my small vulkan project. I get div by zero error deep inside amdvlk64.dll (ver. 25.20.15031.1000) after call to vkCreateGraphicsPipelines.

In short, when i try to pass as attrib data in VkFormat = VK_FORMAT_R8G8B8_UNORM or VK_FORMAT_R16G16B16_UNORM app crash without any usefull info.

Solution: In every VkPipelineVertexInputStateCreateInfo struct passed to vkCreateGraphicsPipelines,  replace VK_FORMAT_R8G8B8_UNORM with VK_FORMAT_R8G8B8A8_UNORM (or VK_FORMAT_R16G16B16_UNORM  with VK_FORMAT_R16G16B16A16_UNORM)

 

To make things clear:

- there is no problem with nvidia gfx cards

- vertex data stride is 16 bytes (for vertex: 3x4 bytes, offset = 0, for color 3x1 bytes, offset=12, 1 byte wasted at end)

- when i changed R8G8B8_UNORM to R8G8B8A8_UNORM as param for vkCreateGraphicsPipelines all start working (no change in shader programs or datas) 

- when i changed R8G8B8_UNORM to R8G8_UNORM or R8_UNORM also program was working (with missing blue or green color on screen as expected)

- same crash when i use R16G16B16_UNORM (with vertex data stride = 20 byes and 2 bytes wasted)

- Vulkan vaidation layer was enabled.

 

I put this here, because i wasted 2 day to find source of problem and it may save time for somebody else.

I know, that it is not a big problem. Attrib input R8G8B8 gives no benefits and can be safely replaced with R8G8B8A8.

 

Questions:

1. Is  VK_FORMAT_R8G8B8_UNORM or VK_FORMAT_R16G16B16_UNORM forbiden as attrib for vertex data only on AMD gfx cards? Drivers bug?

2. Is there way in Vulkan API to query what attrib formats are supported by drivers?

Share this post


Link to post
Share on other sites
Advertisement

Do you have simple project with source code and solution for visual studio? could you share it, it can help to understand what is problem.

Share this post


Link to post
Share on other sites

@Andrey OGL_D3D: simple vulkan project? HA HA :)

Ok.

Here is SaschaWillems simple triangle project.

https://github.com/SaschaWillems/Vulkan/blob/master/examples/triangle/triangle.cpp

 

Only 3 modifications are needed:

1. Line 42: change type from float[3] to uint32_t 

uint32_t color; // float color[3];

2. Lines 370-375: store color as uint32_t not as float[3]

std::vector<Vertex> vertexBuffer = 
{
	{ {  1.0f,  1.0f, 0.0f }, 0x000000ff /*{ 1.0f, 0.0f, 0.0f }*/ },
	{ { -1.0f,  1.0f, 0.0f }, 0x0000ff00 /*{ 0.0f, 1.0f, 0.0f }*/ },
	{ {  0.0f, -1.0f, 0.0f }, 0x00ff0000 /*{ 0.0f, 0.0f, 1.0f }*/ }
};

3. Line 946

vertexInputAttributs[1].format = VK_FORMAT_R8G8B8_UNORM; // VK_FORMAT_R32G32B32_SFLOAT;

In line 996 you have call to vkCreateGraphicsPipelines

It will crash inside amdvlk64.dll with "div by zero" if you are using latest amd drivers.

If change in line 946 format from VK_FORMAT_R8G8B8_UNORM to VK_FORMAT_R8G8B8A8_UNORM... all will work.

If you change to VK_FORMAT_R8G8_UNORM or VK_FORMAT_R8_UNORM It will work too, but you will lost blue and green color on triangle.

 

Same problem exist for VK_FORMAT_R16G16B16_UNORM, VK_FORMAT_R16G16B16_SNORM, VK_FORMAT_R8G8B8_SNORM.

So all formats with 3 rgb values. There is no problem for R, RG or RGBA.

I did not tested 16-bit float formats. 32-bit RGB (VK_FORMAT_R32G32B32_SFLOAT) works.

Share this post


Link to post
Share on other sites

@Andrey OGL_D3D: You have right. VK_FORMAT_R8G8B8_UNORM is not supported. For this forma vkGetPhysicalDeviceFormatProperties return all bits in VkFormatProperties struct =0.

Now i know how to check it. Thanks for help.

Share this post


Link to post
Share on other sites

I double checked ... and validation layer was not working. Not reporting any errors, even added deliberately, like missing vkDestroyBuffer befor vkFreeMemory.

I tested it on my app and in SaschaWillems simple triangle (after changing in line 32 to #define ENABLE_VALIDATION true).

Also, i'm sure, that validation layer was working in my app some time ago. I have no idea why it stops  working.

Maybe after i updated VulkanSDK from 1.0.54.0 to 1.1.82.1.

Anyway, today i updated SDK to 1.1.101.0 and validation layer works again.

So, now i have nice error raport when i use unsupported VkFormat.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!