Ich kann die Übergabe des Kinderwagens an VkSwapchainCreateInfoKHR nicht korrigierenC++

Programme in C++. Entwicklerforum
Anonymous
 Ich kann die Übergabe des Kinderwagens an VkSwapchainCreateInfoKHR nicht korrigieren

Post by Anonymous »

Meine GPU ist RX580 8G, Treiber und VulkanSDK sind aktuell, Windows 10-Version ist 19045.5965

Code: Select all

Present Mode: Immediate
Present Mode: Fifo
Present Mode: FifoRelaxed
Did not find preferred swap chain present mode, using first available present mode.
Format:B8G8R8A8Srgb,ColorSpace:SrgbNonLinear
Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] | MessageID = 0xc036022f
vkCreateSwapchainKHR(): pCreateInfo->imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL does not support usage that includes VK_IMAGE_USAGE_STORAGE_BIT.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.321.1/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] | MessageID = 0xc036022f
vkCreateSwapchainKHR(): pCreateInfo vkGetPhysicalDeviceImageFormatProperties() unexpectedly failed, with following VkImageCreateInfo
format (VK_FORMAT_B8G8R8A8_SRGB)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_OPTIMAL)
usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_STORAGE_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
flags (VkImageCreateFlags(0))
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.321.1/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] | MessageID = 0xc036022f
vkCreateSwapchainKHR(): pCreateInfo->imageArrayLayers 1, but Maximum value returned by vkGetPhysicalDeviceImageFormatProperties() is 0 for imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.321.1/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] | MessageID = 0xc036022f
vkCreateSwapchainKHR(): pCreateInfo->imageExtent (width = 800, height = 600), which is bigger than max extent (width = 0, height = 0, depth = 0) returned by vkGetPhysicalDeviceImageFormatProperties() for imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.321.1/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)
hier ist mein Code

Code: Select all

void CreateSwapChain()
{
VkResult result;
result = instanceApi.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(this.physicalDevice, this.windowsurface, out var surfaceCapabilities);
if (result != VkResult.Success)
{
throw new Exception("Failed to get surface capabilities");
}
result = instanceApi.vkGetPhysicalDeviceSurfaceFormatsKHR(this.physicalDevice, this.windowsurface, out uint formatCount);
if (formatCount == 0 || result != VkResult.Success)
{
throw new Exception("Failed to get surface format count");
}
var swapChainFormats = new VkSurfaceFormatKHR[formatCount];
instanceApi.vkGetPhysicalDeviceSurfaceFormatsKHR(this.physicalDevice, this.windowsurface, swapChainFormats);
if (formatCount == 0 || result != VkResult.Success)
{
throw new Exception("Failed to get surface format count");
}

foreach (var format in swapChainFormats)
{
Console.WriteLine($"Surface Format: {format.format}, ColorSpace:  {format.colorSpace}");
}

result = instanceApi.vkGetPhysicalDeviceSurfacePresentModesKHR(this.physicalDevice, this.windowsurface, out uint presentModeCount);
if (presentModeCount == 0 || result != VkResult.Success)
{
throw new Exception("Failed to get present mode count");
}
var swapChainPresentModes = new VkPresentModeKHR[presentModeCount];
instanceApi.vkGetPhysicalDeviceSurfacePresentModesKHR(this.physicalDevice, this.windowsurface, swapChainPresentModes);

foreach (var presentMode in swapChainPresentModes)
{
Console.WriteLine($"Present Mode: {presentMode}");
}
var swapChainFormatwithcheck = ChooseSwapSurfaceFormat(swapChainFormats);
if (swapChainFormatwithcheck.findformat != true)
{
Console.WriteLine("Did not find preferred swap chain format, using first available format.");
}
this.swapChainFormat = swapChainFormatwithcheck.Item1;
var swapChainPresentModewithcheck = ChooseSwapPresentMode(swapChainPresentModes);
if (swapChainPresentModewithcheck.findpresent != true)
{
Console.WriteLine("Did not find preferred swap chain present mode, using first available present mode.");
}
this.swapChainPresentMode = swapChainPresentModewithcheck.Item1;
var swapChainExtentwithcheck = ChooseSwapExtent(surfaceCapabilities);
if (swapChainExtentwithcheck.success != true)
{
Console.WriteLine("Swap chain extent is not current, using window size.");
}
this.swapChainExtent = swapChainExtentwithcheck.Item1;
var minImageCount = Math.Max(3u, surfaceCapabilities.minImageCount);
minImageCount = (surfaceCapabilities.maxImageCount > 0 && minImageCount > surfaceCapabilities.maxImageCount) ? surfaceCapabilities.maxImageCount : minImageCount;
uint imageCount = surfaceCapabilities.minImageCount + 1;
if (surfaceCapabilities.maxImageCount > 0 && imageCount > surfaceCapabilities.maxImageCount)
{
imageCount = surfaceCapabilities.maxImageCount;
}

Console.WriteLine($"Format:{swapChainFormat.format},ColorSpace:{swapChainFormat.colorSpace}");

VkSwapchainCreateInfoKHR swapchainCreateInfoKHR = new()
{
sType = VkStructureType.SwapchainCreateInfoKHR,
surface = this.windowsurface,
minImageCount = minImageCount,
imageFormat = this.swapChainFormat.format,
imageColorSpace = this.swapChainFormat.colorSpace,
imageExtent = this.swapChainExtent,
imageArrayLayers = 1,
imageUsage = VkImageUsageFlags.ColorAttachment,
imageSharingMode = VkSharingMode.Exclusive,
preTransform = surfaceCapabilities.currentTransform,
compositeAlpha = VkCompositeAlphaFlagsKHR.Opaque,
presentMode = this.swapChainPresentMode,
clipped = VkBool32.True,
oldSwapchain = VkSwapchainKHR.Null
};
// item1 is graphicsIndex,item2 is presentIndex,item3 is a bool,it return (graphicsIndex == presentIndex)
var swapChainCreateInfo = FindQueueFamilies(this.physicalDevice);

Span queueFamilyIndices = new[] { swapChainCreateInfo.graphicsIndex, swapChainCreateInfo.presentIndex };
fixed (uint* pQueueFamilyIndices = queueFamilyIndices)
{
if (swapChainCreateInfo.graphicsIndex != swapChainCreateInfo.presentIndex)
{
swapchainCreateInfoKHR.imageSharingMode = VkSharingMode.Concurrent;
swapchainCreateInfoKHR.queueFamilyIndexCount = (uint)queueFamilyIndices.Length;

swapchainCreateInfoKHR.pQueueFamilyIndices = pQueueFamilyIndices;
}
else
{
swapchainCreateInfoKHR.imageSharingMode = VkSharingMode.Exclusive;
swapchainCreateInfoKHR.queueFamilyIndexCount = 0; // Optional
swapchainCreateInfoKHR.pQueueFamilyIndices = null;  // Optional
}
result = deviceApi.vkCreateSwapchainKHR(this.device, &swapchainCreateInfoKHR, null, out this.swapchain);
if (result != VkResult.Success)
{
throw new Exception("Failed to create swap chain");
}
result = deviceApi.vkGetSwapchainImagesKHR(this.device, this.swapchain, out uint swapchainImageCount);
if (result != VkResult.Success || swapchainImageCount == 0)
{
throw new Exception("Failed to get swap chain image count");
}
this.swapChainImages = new VkImage[swapchainImageCount];
}
Span swapchainImages = swapChainImages;
result = deviceApi.vkGetSwapchainImagesKHR(this.device, this.swapchain, swapchainImages);
if (result != VkResult.Success)
{
throw new Exception("Failed to get swap chain images");
}
}
Wie Sie sehen können, bin ich nicht reingekommen

Code: Select all

VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_STORAGE_BIT
Ich wechsle zu Linux, es ist wieder normal.
Ich versuche auch, C API in C++ zu verwenden, aber es kommt zum gleichen Ergebnis
vkcube funktioniert
ich habe verwiesen https://docs.vulkan.org/tutorial/latest ... swap_chain

Kann mir jemand sagen, wie ich damit richtig umgehen soll?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post