Не могу исправить пропуск в коляске на VkSwapchainCreateInfoKHRC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Не могу исправить пропуск в коляске на VkSwapchainCreateInfoKHR

Сообщение Anonymous »

Мой графический процессор — rx580 8g, драйвер и vulkanSDK — последние, версия Windows 10 — 19045.5965

Код: Выделить всё

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)
вот мой код

Код: Выделить всё

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");
}
}
как видите, я не прошел

Код: Выделить всё

VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_STORAGE_BIT
Я перехожу на Linux, все возвращается в норму.
Также я пытаюсь использовать c api в C++, но результат тот же
vkcube работает
Я сделал ссылку https://docs.vulkan.org/tutorial/latest ... swap_chain

Может ли кто-нибудь сказать мне, как правильно с этим справиться?

Подробнее здесь: https://stackoverflow.com/questions/798 ... ateinfokhr
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»