Files
Seele/src/Engine/Graphics/GraphicsResources.h
T

174 lines
3.9 KiB
C++
Raw Normal View History

#pragma once
#include "GraphicsEnums.h"
#include "Containers/Array.h"
#include <vulkan/vulkan.h>
namespace Seele
{
struct SePushConstantRange {
SeShaderStageFlags stageFlags;
uint32_t offset;
uint32_t size;
};
struct GraphicsInitializer
{
const char* windowLayoutFile;
};
2020-03-02 19:07:49 +01:00
struct WindowCreateInfo
{
int32 width;
int32 height;
const char* title;
bool bFullscreen;
};
2020-03-06 11:32:01 +01:00
class RenderCommandBase
{
2020-03-02 19:07:49 +01:00
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(RenderCommandBase);
class SamplerState
{
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(SamplerState);
2020-03-06 11:32:01 +01:00
class DescriptorBinding
{
public:
DescriptorBinding()
: binding(0)
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM)
2020-03-06 11:32:01 +01:00
, descriptorCount(-1)
, shaderStages(SE_SHADER_STAGE_ALL)
2020-03-06 11:32:01 +01:00
{}
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;
2020-03-06 11:32:01 +01:00
uint32_t descriptorCount;
SeShaderStageFlags shaderStages;
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(DescriptorBinding);
2020-03-06 11:32:01 +01:00
DECLARE_REF(DescriptorSet);
2020-03-06 11:32:01 +01:00
class DescriptorAllocator
{
public:
DescriptorAllocator() {}
~DescriptorAllocator() {}
virtual void allocateDescriptorSet(PDescriptorSet& descriptorSet) = 0;
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(DescriptorAllocator);
DECLARE_REF(UniformBuffer);
DECLARE_REF(StructuredBuffer);
DECLARE_REF(Texture);
2020-03-06 11:32:01 +01:00
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;
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(DescriptorSet);
2020-03-06 11:32:01 +01:00
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;
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(DescriptorLayout);
2020-03-06 11:32:01 +01:00
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;
2020-03-06 11:32:01 +01:00
};
DEFINE_REF(PipelineLayout);
2020-03-06 11:32:01 +01:00
class VertexDeclaration
{
};
DEFINE_REF(VertexDeclaration);
2020-03-06 11:32:01 +01:00
class GraphicsPipeline
{
};
DEFINE_REF(GraphicsPipeline);
2020-03-06 11:32:01 +01:00
class UniformBuffer
{
};
DEFINE_REF(UniformBuffer);
2020-03-06 11:32:01 +01:00
class Viewport
{
};
DEFINE_REF(Viewport);
2020-03-06 11:32:01 +01:00
class VertexBuffer
{
};
DEFINE_REF(VertexBuffer);
2020-03-06 11:32:01 +01:00
class IndexBuffer
{
};
DEFINE_REF(IndexBuffer);
2020-03-06 11:32:01 +01:00
class StructuredBuffer
{
};
DEFINE_REF(StructuredBuffer);
2020-03-06 11:32:01 +01:00
class Texture
{
};
DEFINE_REF(Texture);
2020-03-06 11:32:01 +01:00
class Texture2D : public Texture
{
};
DEFINE_REF(Texture2D);
2020-03-06 11:32:01 +01:00
class RenderPass
{
};
DEFINE_REF(RenderPass);
}