2020-02-25 00:44:40 +01:00
|
|
|
#pragma once
|
2020-03-08 13:38:40 +01:00
|
|
|
#include "GraphicsEnums.h"
|
|
|
|
|
#include "Containers/Array.h"
|
2020-03-13 12:44:33 +01:00
|
|
|
#include "Math/MemCRC.h"
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#define ENABLE_VALIDATION
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-25 00:44:40 +01:00
|
|
|
namespace Seele
|
|
|
|
|
{
|
|
|
|
|
struct GraphicsInitializer
|
|
|
|
|
{
|
|
|
|
|
const char* windowLayoutFile;
|
2020-03-13 12:44:33 +01:00
|
|
|
const char* applicationName;
|
|
|
|
|
const char* engineName;
|
2020-03-15 15:58:01 +01:00
|
|
|
void* windowHandle;
|
2020-03-13 12:44:33 +01:00
|
|
|
/**
|
|
|
|
|
* layers defines the enabled Vulkan layers used in the instance,
|
|
|
|
|
* if ENABLE_VALIDATION is defined, standard validation is already enabled
|
|
|
|
|
* not yet implemented
|
|
|
|
|
*/
|
|
|
|
|
Array<const char*> layers;
|
|
|
|
|
Array<const char*> instanceExtensions;
|
|
|
|
|
Array<const char*> deviceExtensions;
|
|
|
|
|
GraphicsInitializer()
|
|
|
|
|
: applicationName("SeeleEngine")
|
|
|
|
|
, engineName("SeeleEngine")
|
|
|
|
|
, layers{ "VK_LAYER_LUNARG_standard_validation" }
|
|
|
|
|
, instanceExtensions{}
|
|
|
|
|
, deviceExtensions{ "VK_KHR_swapchain" }
|
2020-03-15 15:58:01 +01:00
|
|
|
, windowHandle(nullptr)
|
2020-03-13 12:44:33 +01:00
|
|
|
{}
|
|
|
|
|
GraphicsInitializer(const GraphicsInitializer& other)
|
|
|
|
|
: applicationName(other.applicationName)
|
|
|
|
|
, engineName(other.engineName)
|
|
|
|
|
, layers(other.layers)
|
|
|
|
|
, instanceExtensions(other.instanceExtensions)
|
|
|
|
|
, deviceExtensions(other.deviceExtensions)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-02-25 00:44:40 +01:00
|
|
|
};
|
2020-03-02 19:07:49 +01:00
|
|
|
struct WindowCreateInfo
|
|
|
|
|
{
|
|
|
|
|
int32 width;
|
|
|
|
|
int32 height;
|
|
|
|
|
const char* title;
|
|
|
|
|
bool bFullscreen;
|
|
|
|
|
};
|
2020-03-20 01:27:40 +01:00
|
|
|
namespace Gfx
|
2020-03-06 11:32:01 +01:00
|
|
|
{
|
2020-03-20 01:27:40 +01:00
|
|
|
struct SePushConstantRange {
|
|
|
|
|
SeShaderStageFlags stageFlags;
|
|
|
|
|
uint32_t offset;
|
|
|
|
|
uint32_t size;
|
|
|
|
|
};
|
|
|
|
|
class RenderCommandBase
|
2020-03-13 12:44:33 +01:00
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(RenderCommandBase);
|
|
|
|
|
|
|
|
|
|
class SamplerState
|
2020-03-06 11:32:01 +01:00
|
|
|
{
|
2020-03-20 01:27:40 +01:00
|
|
|
public:
|
|
|
|
|
virtual ~SamplerState()
|
|
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(SamplerState);
|
|
|
|
|
class DescriptorBinding
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
2020-03-20 01:27:40 +01:00
|
|
|
public:
|
|
|
|
|
DescriptorBinding()
|
|
|
|
|
: binding(0)
|
|
|
|
|
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM)
|
|
|
|
|
, descriptorCount(-1)
|
|
|
|
|
, shaderStages(SE_SHADER_STAGE_ALL)
|
|
|
|
|
{}
|
|
|
|
|
DescriptorBinding(const DescriptorBinding& other)
|
|
|
|
|
: binding(other.binding)
|
|
|
|
|
, descriptorType(other.descriptorType)
|
|
|
|
|
, descriptorCount(other.descriptorCount)
|
|
|
|
|
, shaderStages(other.shaderStages)
|
|
|
|
|
{}
|
|
|
|
|
void operator=(const DescriptorBinding& other)
|
|
|
|
|
{
|
|
|
|
|
binding = other.binding;
|
|
|
|
|
descriptorType = other.descriptorType;
|
|
|
|
|
descriptorCount = other.descriptorCount;
|
|
|
|
|
shaderStages = other.shaderStages;
|
|
|
|
|
}
|
|
|
|
|
uint32_t binding;
|
|
|
|
|
SeDescriptorType descriptorType;
|
|
|
|
|
uint32_t descriptorCount;
|
|
|
|
|
SeShaderStageFlags shaderStages;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(DescriptorBinding);
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
DECLARE_REF(DescriptorSet);
|
|
|
|
|
class DescriptorAllocator
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DescriptorAllocator() {}
|
|
|
|
|
~DescriptorAllocator() {}
|
|
|
|
|
virtual void allocateDescriptorSet(PDescriptorSet& descriptorSet) = 0;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(DescriptorAllocator);
|
|
|
|
|
DECLARE_REF(UniformBuffer);
|
|
|
|
|
DECLARE_REF(StructuredBuffer);
|
|
|
|
|
DECLARE_REF(Texture);
|
|
|
|
|
class DescriptorSet
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~DescriptorSet() {}
|
|
|
|
|
virtual void writeChanges() = 0;
|
|
|
|
|
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
|
|
|
|
virtual void updateBuffer(uint32 binding, PStructuredBuffer structuredBuffer) = 0;
|
|
|
|
|
virtual void updateSampler(uint32 binding, PSamplerState samplerState) = 0;
|
|
|
|
|
virtual void updateTexture(uint32 binding, PTexture texture, PSamplerState samplerState = nullptr) = 0;
|
|
|
|
|
virtual bool operator<(PDescriptorSet other) = 0;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(DescriptorSet);
|
|
|
|
|
|
|
|
|
|
class DescriptorLayout
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DescriptorLayout() {}
|
|
|
|
|
virtual ~DescriptorLayout() {}
|
|
|
|
|
void operator=(const DescriptorLayout& other)
|
|
|
|
|
{
|
|
|
|
|
descriptorBindings.resize(other.descriptorBindings.size());
|
|
|
|
|
std::memcpy(descriptorBindings.data(), other.descriptorBindings.data(), sizeof(DescriptorLayout) * descriptorBindings.size());
|
|
|
|
|
}
|
|
|
|
|
virtual void create() = 0;
|
|
|
|
|
virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1);
|
|
|
|
|
virtual PDescriptorSet allocatedDescriptorSet();
|
|
|
|
|
const Array<DescriptorBinding>& getBindings() const { return descriptorBindings; }
|
|
|
|
|
protected:
|
|
|
|
|
Array<DescriptorBinding> descriptorBindings;
|
|
|
|
|
PDescriptorAllocator allocator;
|
|
|
|
|
friend class PipelineLayout;
|
|
|
|
|
friend class DescriptorAllocator;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(DescriptorLayout);
|
|
|
|
|
class PipelineLayout
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PipelineLayout() {}
|
|
|
|
|
virtual ~PipelineLayout() {}
|
|
|
|
|
virtual void create() = 0;
|
|
|
|
|
void addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout);
|
|
|
|
|
void addPushConstants(const SePushConstantRange& pushConstants);
|
|
|
|
|
virtual uint32 getHash() const = 0;
|
|
|
|
|
protected:
|
|
|
|
|
Array<PDescriptorLayout> descriptorSetLayouts;
|
|
|
|
|
Array<SePushConstantRange> pushConstants;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(PipelineLayout);
|
|
|
|
|
class VertexDeclaration
|
2020-03-13 12:44:33 +01:00
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(VertexDeclaration);
|
|
|
|
|
class GraphicsPipeline
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~GraphicsPipeline()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(GraphicsPipeline);
|
|
|
|
|
class UniformBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~UniformBuffer()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(UniformBuffer);
|
|
|
|
|
class Viewport
|
2020-03-13 12:44:33 +01:00
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(Viewport);
|
|
|
|
|
class VertexBuffer
|
2020-03-13 12:44:33 +01:00
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(VertexBuffer);
|
|
|
|
|
class IndexBuffer
|
|
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(IndexBuffer);
|
|
|
|
|
class StructuredBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~StructuredBuffer()
|
|
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(StructuredBuffer);
|
|
|
|
|
class Texture
|
|
|
|
|
{
|
2020-03-06 11:32:01 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(Texture);
|
|
|
|
|
class Texture2D : public Texture
|
|
|
|
|
{
|
2020-04-01 02:17:49 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~Texture2D()
|
|
|
|
|
{
|
2020-03-20 01:27:40 +01:00
|
|
|
|
2020-04-01 02:17:49 +02:00
|
|
|
}
|
2020-03-20 01:27:40 +01:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(Texture2D);
|
2020-04-01 02:17:49 +02:00
|
|
|
|
|
|
|
|
class RenderTargetLayout
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RenderTargetLayout();
|
|
|
|
|
RenderTargetLayout(PTexture2D depthAttachment);
|
|
|
|
|
RenderTargetLayout(PTexture2D colorAttachment, PTexture2D depthAttachment);
|
|
|
|
|
RenderTargetLayout(Array<PTexture2D> colorAttachments, PTexture2D depthAttachmet);
|
|
|
|
|
RenderTargetLayout(Array<PTexture2D> inputAttachments, Array<PTexture2D> colorAttachments, PTexture2D depthAttachment);
|
|
|
|
|
Array<PTexture2D> inputAttachments;
|
|
|
|
|
Array<PTexture2D> colorAttachments;
|
|
|
|
|
PTexture2D depthAttachment;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(RenderTargetLayout);
|
|
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
class RenderPass
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(RenderPass);
|
|
|
|
|
}
|
2020-02-25 00:44:40 +01:00
|
|
|
}
|