Hi, I’m starting to build my project using Vulkan.
The code below is referenced from “C:\VulkanSDK\1.2.182.0\Demos\cube.cpp”, but I just replaced the struct “Demo” with “Vulkan”, in order to simplify the engine I’m creating, because the simpler it is, the faster to raise.
The error is indicated in a comment in the code below, I spent whole day to try to fix it but it’s too difficult. But I’m sure there will be no error if I 100% copy the project from Vulkan’s “cube.cpp”. But the problem is that project is using Win32, I want to use a cross platform project using SDL2, so I’m stuck on this problem.
If this problem is still not solved, then I try to give more detailed but extremely complex details, but here is the simplest question if someone can solve it. Thanks.
People from Google tell that you must use vulkan.hpp but I already use it.
#define VULKAN_HPP_NO_EXCEPTIONS
#define VULKAN_HPP_TYPESAFE_CONVERSION
#include <vulkan/vulkan.hpp>
#include <vulkan/vk_sdk_platform.h>
#include "external/linmath.h"
...
void Vulkan::build_image_ownership_cmd(uint32_t const &i) {
auto const cmd_buf_info = vk::CommandBufferBeginInfo().setFlags(vk::CommandBufferUsageFlagBits::eSimultaneousUse);
auto result = swapchain_image_resources[i].graphics_to_present_cmd.begin(&cmd_buf_info);
VERIFY(result == vk::Result::eSuccess);
auto const image_ownership_barrier =
vk::ImageMemoryBarrier()
.setSrcAccessMask(vk::AccessFlags())
.setDstAccessMask(vk::AccessFlags())
.setOldLayout(vk::ImageLayout::ePresentSrcKHR)
.setNewLayout(vk::ImageLayout::ePresentSrcKHR)
.setSrcQueueFamilyIndex(graphics_queue_family_index)
.setDstQueueFamilyIndex(present_queue_family_index)
.setImage(swapchain_image_resources[i].image)
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
swapchain_image_resources[i].graphics_to_present_cmd.pipelineBarrier(
vk::PipelineStageFlagBits::eBottomOfPipe, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlagBits(), 0, nullptr, 0,
nullptr, 1, &image_ownership_barrier);
// Error C2440: '=': cannot convert from 'vk::ResultValueType<void>::type' to 'vk::Result'
result = swapchain_image_resources[i].graphics_to_present_cmd.end();
VERIFY(result == vk::Result::eSuccess);
}