2020-05-31 08:53:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vk_objects.h"
|
|
|
|
#include "zstring.h"
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
class ImageBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ImageBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
ImageBuilder& Size(int width, int height, int miplevels = 1, int arrayLayers = 1);
|
|
|
|
ImageBuilder& Samples(VkSampleCountFlagBits samples);
|
|
|
|
ImageBuilder& Format(VkFormat format);
|
|
|
|
ImageBuilder& Usage(VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
|
|
|
ImageBuilder& MemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits = 0);
|
|
|
|
ImageBuilder& LinearTiling();
|
|
|
|
ImageBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
bool IsFormatSupported(VulkanDevice *device, VkFormatFeatureFlags bufferFeatures = 0);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanImage> Create(VulkanDevice *device, VkDeviceSize* allocatedBytes = nullptr);
|
|
|
|
std::unique_ptr<VulkanImage> TryCreate(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkImageCreateInfo imageInfo = {};
|
|
|
|
VmaAllocationCreateInfo allocInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ImageViewBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ImageViewBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
ImageViewBuilder& Type(VkImageViewType type);
|
|
|
|
ImageViewBuilder& Image(VulkanImage *image, VkFormat format, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT);
|
|
|
|
ImageViewBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanImageView> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkImageViewCreateInfo viewInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SamplerBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SamplerBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
SamplerBuilder& AddressMode(VkSamplerAddressMode addressMode);
|
|
|
|
SamplerBuilder& AddressMode(VkSamplerAddressMode u, VkSamplerAddressMode v, VkSamplerAddressMode w);
|
|
|
|
SamplerBuilder& MinFilter(VkFilter minFilter);
|
|
|
|
SamplerBuilder& MagFilter(VkFilter magFilter);
|
|
|
|
SamplerBuilder& MipmapMode(VkSamplerMipmapMode mode);
|
|
|
|
SamplerBuilder& Anisotropy(float maxAnisotropy);
|
|
|
|
SamplerBuilder& MaxLod(float value);
|
|
|
|
SamplerBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanSampler> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkSamplerCreateInfo samplerInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BufferBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BufferBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
BufferBuilder& Size(size_t size);
|
|
|
|
BufferBuilder& Usage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
|
|
|
BufferBuilder& MemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits = 0);
|
|
|
|
BufferBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanBuffer> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkBufferCreateInfo bufferInfo = {};
|
|
|
|
VmaAllocationCreateInfo allocInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
ShaderBuilder& VertexShader(const FString &code);
|
|
|
|
ShaderBuilder& FragmentShader(const FString &code);
|
|
|
|
ShaderBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanShader> Create(const char *shadername, VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
FString code;
|
2022-07-02 08:09:59 +00:00
|
|
|
int stage = 0;
|
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ComputePipelineBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ComputePipelineBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
ComputePipelineBuilder& Layout(VulkanPipelineLayout *layout);
|
|
|
|
ComputePipelineBuilder& ComputeShader(VulkanShader *shader);
|
|
|
|
ComputePipelineBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanPipeline> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkComputePipelineCreateInfo pipelineInfo = {};
|
|
|
|
VkPipelineShaderStageCreateInfo stageInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DescriptorSetLayoutBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DescriptorSetLayoutBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
DescriptorSetLayoutBuilder& AddBinding(int binding, VkDescriptorType type, int arrayCount, VkShaderStageFlags stageFlags);
|
|
|
|
DescriptorSetLayoutBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanDescriptorSetLayout> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkDescriptorSetLayoutCreateInfo layoutInfo = {};
|
2021-01-29 12:20:00 +00:00
|
|
|
TArray<VkDescriptorSetLayoutBinding> bindings;
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DescriptorPoolBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DescriptorPoolBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
DescriptorPoolBuilder& MaxSets(int value);
|
|
|
|
DescriptorPoolBuilder& AddPoolSize(VkDescriptorType type, int count);
|
|
|
|
DescriptorPoolBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanDescriptorPool> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkDescriptorPoolSize> poolSizes;
|
2020-05-31 08:53:11 +00:00
|
|
|
VkDescriptorPoolCreateInfo poolInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class QueryPoolBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QueryPoolBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
QueryPoolBuilder& QueryType(VkQueryType type, int count, VkQueryPipelineStatisticFlags pipelineStatistics = 0);
|
|
|
|
QueryPoolBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanQueryPool> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkQueryPoolCreateInfo poolInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FramebufferBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FramebufferBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
FramebufferBuilder& RenderPass(VulkanRenderPass *renderPass);
|
|
|
|
FramebufferBuilder& AddAttachment(VulkanImageView *view);
|
|
|
|
FramebufferBuilder& AddAttachment(VkImageView view);
|
|
|
|
FramebufferBuilder& Size(int width, int height, int layers = 1);
|
|
|
|
FramebufferBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanFramebuffer> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkFramebufferCreateInfo framebufferInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkImageView> attachments;
|
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union FRenderStyle;
|
|
|
|
|
|
|
|
class GraphicsPipelineBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GraphicsPipelineBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& Subpass(int subpass);
|
|
|
|
GraphicsPipelineBuilder& Layout(VulkanPipelineLayout *layout);
|
|
|
|
GraphicsPipelineBuilder& RenderPass(VulkanRenderPass *renderPass);
|
|
|
|
GraphicsPipelineBuilder& Topology(VkPrimitiveTopology topology);
|
|
|
|
GraphicsPipelineBuilder& Viewport(float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f);
|
|
|
|
GraphicsPipelineBuilder& Scissor(int x, int y, int width, int height);
|
|
|
|
GraphicsPipelineBuilder& RasterizationSamples(VkSampleCountFlagBits samples);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& Cull(VkCullModeFlags cullMode, VkFrontFace frontFace);
|
|
|
|
GraphicsPipelineBuilder& DepthStencilEnable(bool test, bool write, bool stencil);
|
|
|
|
GraphicsPipelineBuilder& DepthFunc(VkCompareOp func);
|
|
|
|
GraphicsPipelineBuilder& DepthClampEnable(bool value);
|
|
|
|
GraphicsPipelineBuilder& DepthBias(bool enable, float biasConstantFactor, float biasClamp, float biasSlopeFactor);
|
|
|
|
GraphicsPipelineBuilder& ColorWriteMask(VkColorComponentFlags mask);
|
|
|
|
GraphicsPipelineBuilder& Stencil(VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp, uint32_t compareMask, uint32_t writeMask, uint32_t reference);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& AdditiveBlendMode();
|
|
|
|
GraphicsPipelineBuilder& AlphaBlendMode();
|
|
|
|
GraphicsPipelineBuilder& BlendMode(const FRenderStyle &style);
|
|
|
|
GraphicsPipelineBuilder& BlendMode(VkBlendOp op, VkBlendFactor src, VkBlendFactor dst);
|
|
|
|
GraphicsPipelineBuilder& SubpassColorAttachmentCount(int count);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& AddVertexShader(VulkanShader *shader);
|
|
|
|
GraphicsPipelineBuilder& AddFragmentShader(VulkanShader *shader);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& AddVertexBufferBinding(int index, size_t stride);
|
|
|
|
GraphicsPipelineBuilder& AddVertexAttribute(int location, int binding, VkFormat format, size_t offset);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& AddDynamicState(VkDynamicState state);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
GraphicsPipelineBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
|
|
|
|
|
|
|
std::unique_ptr<VulkanPipeline> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkGraphicsPipelineCreateInfo pipelineInfo = { };
|
|
|
|
VkPipelineVertexInputStateCreateInfo vertexInputInfo = { };
|
|
|
|
VkPipelineInputAssemblyStateCreateInfo inputAssembly = { };
|
|
|
|
VkViewport viewport = { };
|
|
|
|
VkRect2D scissor = { };
|
|
|
|
VkPipelineViewportStateCreateInfo viewportState = { };
|
|
|
|
VkPipelineRasterizationStateCreateInfo rasterizer = { };
|
|
|
|
VkPipelineMultisampleStateCreateInfo multisampling = { };
|
|
|
|
VkPipelineColorBlendAttachmentState colorBlendAttachment = { };
|
|
|
|
VkPipelineColorBlendStateCreateInfo colorBlending = { };
|
|
|
|
VkPipelineDepthStencilStateCreateInfo depthStencil = { };
|
|
|
|
VkPipelineDynamicStateCreateInfo dynamicState = {};
|
|
|
|
|
|
|
|
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
|
|
|
|
std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachments;
|
|
|
|
std::vector<VkVertexInputBindingDescription> vertexInputBindings;
|
|
|
|
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes;
|
|
|
|
std::vector<VkDynamicState> dynamicStates;
|
2022-07-02 08:09:59 +00:00
|
|
|
|
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PipelineLayoutBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PipelineLayoutBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
PipelineLayoutBuilder& AddSetLayout(VulkanDescriptorSetLayout *setLayout);
|
|
|
|
PipelineLayoutBuilder& AddPushConstantRange(VkShaderStageFlags stageFlags, size_t offset, size_t size);
|
|
|
|
|
|
|
|
PipelineLayoutBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::unique_ptr<VulkanPipelineLayout> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
|
|
|
|
std::vector<VkDescriptorSetLayout> setLayouts;
|
|
|
|
std::vector<VkPushConstantRange> pushConstantRanges;
|
2022-07-02 08:09:59 +00:00
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RenderPassBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RenderPassBuilder();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
RenderPassBuilder& AddAttachment(VkFormat format, VkSampleCountFlagBits samples, VkAttachmentLoadOp load, VkAttachmentStoreOp store, VkImageLayout initialLayout, VkImageLayout finalLayout);
|
|
|
|
RenderPassBuilder& AddDepthStencilAttachment(VkFormat format, VkSampleCountFlagBits samples, VkAttachmentLoadOp load, VkAttachmentStoreOp store, VkAttachmentLoadOp stencilLoad, VkAttachmentStoreOp stencilStore, VkImageLayout initialLayout, VkImageLayout finalLayout);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
RenderPassBuilder& AddExternalSubpassDependency(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
RenderPassBuilder& AddSubpass();
|
|
|
|
RenderPassBuilder& AddSubpassColorAttachmentRef(uint32_t index, VkImageLayout layout);
|
|
|
|
RenderPassBuilder& AddSubpassDepthStencilAttachmentRef(uint32_t index, VkImageLayout layout);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
RenderPassBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
|
|
|
|
|
|
|
std::unique_ptr<VulkanRenderPass> Create(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkRenderPassCreateInfo renderPassInfo = { };
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkAttachmentDescription> attachments;
|
|
|
|
std::vector<VkSubpassDependency> dependencies;
|
|
|
|
std::vector<VkSubpassDescription> subpasses;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
struct SubpassData
|
|
|
|
{
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkAttachmentReference> colorRefs;
|
2020-05-31 08:53:11 +00:00
|
|
|
VkAttachmentReference depthRef = { };
|
|
|
|
};
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<std::unique_ptr<SubpassData>> subpassData;
|
|
|
|
|
|
|
|
const char* debugName = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PipelineBarrier
|
|
|
|
{
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
PipelineBarrier& AddMemory(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
|
|
|
|
PipelineBarrier& AddBuffer(VulkanBuffer *buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
|
|
|
|
PipelineBarrier& AddBuffer(VulkanBuffer *buffer, VkDeviceSize offset, VkDeviceSize size, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
|
|
|
|
PipelineBarrier& AddImage(VulkanImage *image, VkImageLayout oldLayout, VkImageLayout newLayout, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, int baseMipLevel = 0, int levelCount = 1);
|
|
|
|
PipelineBarrier& AddImage(VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, int baseMipLevel = 0, int levelCount = 1);
|
|
|
|
PipelineBarrier& AddQueueTransfer(int srcFamily, int dstFamily, VulkanBuffer *buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
|
|
|
|
PipelineBarrier& AddQueueTransfer(int srcFamily, int dstFamily, VulkanImage *image, VkImageLayout layout, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, int baseMipLevel = 0, int levelCount = 1);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
void Execute(VulkanCommandBuffer *commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags = 0);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkMemoryBarrier> memoryBarriers;
|
|
|
|
std::vector<VkBufferMemoryBarrier> bufferMemoryBarriers;
|
|
|
|
std::vector<VkImageMemoryBarrier> imageMemoryBarriers;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class QueueSubmit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QueueSubmit();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
QueueSubmit& AddCommandBuffer(VulkanCommandBuffer *buffer);
|
|
|
|
QueueSubmit& AddWait(VkPipelineStageFlags waitStageMask, VulkanSemaphore *semaphore);
|
|
|
|
QueueSubmit& AddSignal(VulkanSemaphore *semaphore);
|
|
|
|
void Execute(VulkanDevice *device, VkQueue queue, VulkanFence *fence = nullptr);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VkSubmitInfo submitInfo = {};
|
2022-07-02 08:09:59 +00:00
|
|
|
std::vector<VkSemaphore> waitSemaphores;
|
|
|
|
std::vector<VkPipelineStageFlags> waitStages;
|
|
|
|
std::vector<VkSemaphore> signalSemaphores;
|
|
|
|
std::vector<VkCommandBuffer> commandBuffers;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class WriteDescriptors
|
|
|
|
{
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
WriteDescriptors& AddBuffer(VulkanDescriptorSet *descriptorSet, int binding, VkDescriptorType type, VulkanBuffer *buffer);
|
|
|
|
WriteDescriptors& AddBuffer(VulkanDescriptorSet *descriptorSet, int binding, VkDescriptorType type, VulkanBuffer *buffer, size_t offset, size_t range);
|
|
|
|
WriteDescriptors& AddStorageImage(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VkImageLayout imageLayout);
|
|
|
|
WriteDescriptors& AddCombinedImageSampler(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VulkanSampler *sampler, VkImageLayout imageLayout);
|
|
|
|
WriteDescriptors& AddAccelerationStructure(VulkanDescriptorSet* descriptorSet, int binding, VulkanAccelerationStructure* accelStruct);
|
|
|
|
void Execute(VulkanDevice *device);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct WriteExtra
|
|
|
|
{
|
|
|
|
VkDescriptorImageInfo imageInfo;
|
|
|
|
VkDescriptorBufferInfo bufferInfo;
|
|
|
|
VkBufferView bufferView;
|
2022-07-02 08:09:59 +00:00
|
|
|
VkWriteDescriptorSetAccelerationStructureKHR accelStruct;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<VkWriteDescriptorSet> writes;
|
|
|
|
std::vector<std::unique_ptr<WriteExtra>> writeExtras;
|
|
|
|
};
|