Attempted to use the vulkan.hpp but it's too much C++ for this. It took 5 hours to just get this one file converted.
This commit is contained in:
parent
a996440c61
commit
24ae3705c9
1 changed files with 77 additions and 96 deletions
|
|
@ -1,93 +1,76 @@
|
|||
#include <vk_initializers.h>
|
||||
|
||||
// #if !defined( VULKAN_HPP_NO_CONSTRUCTORS ) && !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
|
||||
//
|
||||
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS 1
|
||||
#define VULKAN_HPP_NO_CONSTRUCTORS 1
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
VkCommandPoolCreateInfo vkinit::command_pool_create_info(uint32_t queueFamilyIndex,
|
||||
VkCommandPoolCreateFlags flags /*= 0*/)
|
||||
{
|
||||
VkCommandPoolCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.queueFamilyIndex = queueFamilyIndex;
|
||||
info.flags = flags;
|
||||
return info;
|
||||
return vk::CommandPoolCreateInfo{
|
||||
.flags=vk::CommandPoolCreateFlags(flags),
|
||||
.queueFamilyIndex=queueFamilyIndex
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
VkCommandBufferAllocateInfo vkinit::command_buffer_allocate_info(
|
||||
VkCommandPool pool, uint32_t count /*= 1*/)
|
||||
{
|
||||
VkCommandBufferAllocateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
|
||||
info.commandPool = pool;
|
||||
info.commandBufferCount = count;
|
||||
info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
return info;
|
||||
return vk::CommandBufferAllocateInfo{
|
||||
.commandPool=pool,
|
||||
.level=vk::CommandBufferLevel::ePrimary,
|
||||
.commandBufferCount=count
|
||||
};
|
||||
}
|
||||
|
||||
VkFenceCreateInfo vkinit::fence_create_info(VkFenceCreateFlags flags /*=0*/)
|
||||
{
|
||||
VkFenceCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.flags = flags;
|
||||
return info;
|
||||
return vk::FenceCreateInfo{
|
||||
.flags=vk::FenceCreateFlags(flags)
|
||||
};
|
||||
}
|
||||
|
||||
VkSemaphoreCreateInfo vkinit::semaphore_create_info(VkSemaphoreCreateFlags flags/*=0*/)
|
||||
{
|
||||
VkSemaphoreCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.flags = flags;
|
||||
return info;
|
||||
return vk::SemaphoreCreateInfo{
|
||||
.flags=vk::SemaphoreCreateFlags(flags)
|
||||
};
|
||||
}
|
||||
|
||||
VkCommandBufferBeginInfo vkinit::command_buffer_begin_info(VkCommandBufferUsageFlags flags /*= 0*/)
|
||||
{
|
||||
VkCommandBufferBeginInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||
info.pNext = nullptr;
|
||||
|
||||
info.pInheritanceInfo = nullptr;
|
||||
info.flags = flags;
|
||||
return info;
|
||||
return vk::CommandBufferBeginInfo{
|
||||
.flags=vk::CommandBufferUsageFlags(flags)
|
||||
};
|
||||
}
|
||||
|
||||
VkImageSubresourceRange vkinit::image_subresource_range(VkImageAspectFlags aspectMask)
|
||||
{
|
||||
VkImageSubresourceRange subImage {};
|
||||
subImage.aspectMask = aspectMask;
|
||||
subImage.baseMipLevel = 0;
|
||||
subImage.levelCount = VK_REMAINING_MIP_LEVELS;
|
||||
subImage.baseArrayLayer = 0;
|
||||
subImage.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
||||
|
||||
return subImage;
|
||||
return vk::ImageSubresourceRange{
|
||||
vk::ImageAspectFlags(aspectMask),
|
||||
0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_ARRAY_LAYERS
|
||||
};
|
||||
}
|
||||
|
||||
VkSemaphoreSubmitInfo vkinit::semaphore_submit_info(VkPipelineStageFlags2 stageMask, VkSemaphore semaphore)
|
||||
{
|
||||
VkSemaphoreSubmitInfo submitInfo{};
|
||||
submitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO;
|
||||
submitInfo.pNext = nullptr;
|
||||
submitInfo.semaphore = semaphore;
|
||||
submitInfo.stageMask = stageMask;
|
||||
submitInfo.deviceIndex = 0;
|
||||
submitInfo.value = 1;
|
||||
|
||||
return submitInfo;
|
||||
return vk::SemaphoreSubmitInfo{
|
||||
.semaphore=vk::Semaphore{semaphore},
|
||||
.value=1,
|
||||
.stageMask=vk::PipelineStageFlags2{stageMask},
|
||||
.deviceIndex=0,
|
||||
};
|
||||
}
|
||||
|
||||
VkCommandBufferSubmitInfo vkinit::command_buffer_submit_info(VkCommandBuffer cmd)
|
||||
{
|
||||
VkCommandBufferSubmitInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.commandBuffer = cmd;
|
||||
info.deviceMask = 0;
|
||||
|
||||
return info;
|
||||
return vk::CommandBufferSubmitInfo{
|
||||
.commandBuffer=cmd, // commandBuffer
|
||||
.deviceMask=0, // deviceMask
|
||||
};
|
||||
}
|
||||
|
||||
VkSubmitInfo2 vkinit::submit_info(VkCommandBufferSubmitInfo* cmd, VkSemaphoreSubmitInfo* signalSemaphoreInfo,
|
||||
|
|
@ -111,58 +94,56 @@ VkSubmitInfo2 vkinit::submit_info(VkCommandBufferSubmitInfo* cmd, VkSemaphoreSub
|
|||
|
||||
VkImageCreateInfo vkinit::image_create_info(VkFormat format, VkImageUsageFlags usageFlags, VkExtent3D extent)
|
||||
{
|
||||
VkImageCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
|
||||
info.imageType = VK_IMAGE_TYPE_2D;
|
||||
|
||||
info.format = format;
|
||||
info.extent = extent;
|
||||
|
||||
info.mipLevels = 1;
|
||||
info.arrayLayers = 1;
|
||||
|
||||
info.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
info.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
info.usage = usageFlags;
|
||||
|
||||
return info;
|
||||
return vk::ImageCreateInfo{
|
||||
.flags=vk::ImageCreateFlags(0),
|
||||
.imageType=vk::ImageType::e2D,
|
||||
.format=vk::Format{format},
|
||||
.extent=vk::Extent3D{extent.width, extent.height, extent.depth},
|
||||
.mipLevels=1,
|
||||
.arrayLayers=1,
|
||||
.samples=vk::SampleCountFlagBits::e1,
|
||||
.tiling=vk::ImageTiling::eOptimal,
|
||||
.usage=vk::ImageUsageFlags{usageFlags},
|
||||
};
|
||||
}
|
||||
|
||||
VkImageViewCreateInfo vkinit::imageview_create_info(VkFormat format, VkImage image, VkImageAspectFlags aspectFlags)
|
||||
{
|
||||
VkImageViewCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
|
||||
info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
info.image = image;
|
||||
info.format = format;
|
||||
info.subresourceRange.baseMipLevel = 0;
|
||||
info.subresourceRange.levelCount = 1;
|
||||
info.subresourceRange.baseArrayLayer = 0;
|
||||
info.subresourceRange.layerCount = 1;
|
||||
info.subresourceRange.aspectMask = aspectFlags;
|
||||
|
||||
return info;
|
||||
return vk::ImageViewCreateInfo{
|
||||
.image=image,
|
||||
.viewType=vk::ImageViewType::e2D,
|
||||
.format=vk::Format{format},
|
||||
.subresourceRange{
|
||||
.aspectMask=vk::ImageAspectFlags{aspectFlags},
|
||||
.baseMipLevel=0,
|
||||
.levelCount=1,
|
||||
.baseArrayLayer=0,
|
||||
.layerCount=1,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
VkRenderingAttachmentInfo vkinit::attachment_info(
|
||||
VkImageView view, VkClearValue* clear ,VkImageLayout layout /*= VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL*/)
|
||||
{
|
||||
VkRenderingAttachmentInfo colorAttachment {};
|
||||
colorAttachment.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
|
||||
colorAttachment.pNext = nullptr;
|
||||
|
||||
colorAttachment.imageView = view;
|
||||
colorAttachment.imageLayout = layout;
|
||||
colorAttachment.loadOp = clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
vk::RenderingAttachmentInfo colorAttachment{
|
||||
.imageView=view,
|
||||
.imageLayout=vk::ImageLayout(layout),
|
||||
.loadOp=vk::AttachmentLoadOp(clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD),
|
||||
.storeOp=vk::AttachmentStoreOp(VK_ATTACHMENT_STORE_OP_STORE),
|
||||
};
|
||||
|
||||
if (clear) {
|
||||
colorAttachment.clearValue = *clear;
|
||||
vk::ArrayWrapper1D<float, 4> thefuckingcolor{{
|
||||
clear->color.float32[0],
|
||||
clear->color.float32[1],
|
||||
clear->color.float32[2],
|
||||
clear->color.float32[3],
|
||||
}};
|
||||
|
||||
colorAttachment.clearValue = vk::ClearValue{
|
||||
.color = thefuckingcolor
|
||||
};
|
||||
}
|
||||
|
||||
return colorAttachment;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue