The surface format is B8G8R8A8_UNORM, but does vkCmdClearColorImage accept a float?

I use vkGetPhysicalDeviceSurfaceFormatsKHRto get supported image formats for swapchain and (on Linux + Nvidia, using SDL). I get VK_FORMAT_B8G8R8A8_UNORMas the first option, and I continue and create a swapchain with this format:

VkSwapchainCreateInfoKHR swapchain_info = {
    ...
    .imageFormat = format, /* taken from vkGetPhysicalDeviceSurfaceFormatsKHR */
    ...
};

So far, all this makes sense. The image format used for drawing on the screen is the usual 8-bit BGRA.

As part of my educational process, I have so far come to the creation of a large amount of material, but not yet a graphic pipeline 1 . Therefore, I am trying to use the only command that I can use that does not need a pipeline: vkCmdClearColorImage 2 .

VkClearColorValueused to determine the transparent color may take the color as float, uint32_tor int32_t, depending on the image format. I would suggest that based on the image format given by swapchain, I should give it values uint32_t, but that doesn't seem right. I know, because the color of the screen has not changed. I tried to give it floatand it works.

My question is: why do I need to specify a transparent color in floatwhen the image format VK_FORMAT_B8G8R8A8_UNORM?


1 Actually, I have, but I thought that I would try the simpler case of the lack of a pipeline first. I try to use Vulkan gradually (given its verbosity), especially because I also write tutorials on it when I find out.

2 , , , , . >


:

  • swapchain
  • :
    • VK_IMAGE_LAYOUT_UNDEFINED VK_IMAGE_LAYOUT_GENERAL ( )
    • VK_IMAGE_LAYOUT_GENERAL VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
  • ( swapchain )
+4
1

, , VK_FORMAT_B8G8R8A8_UNORM?

normalized, sRGB- - . - [0, 1] [-1, 1], , 16- . - [0, MAX] [-MIN, MAX]. SRGB - [0, 1], -, , .

. vec4 , .

+3

All Articles