Separating declaration and definition of RefPtr
This commit is contained in:
@@ -17,6 +17,7 @@ namespace Seele
|
|||||||
, arraySize(0)
|
, arraySize(0)
|
||||||
{
|
{
|
||||||
_data = (T*)malloc(DEFAULT_ALLOC_SIZE * sizeof(T));
|
_data = (T*)malloc(DEFAULT_ALLOC_SIZE * sizeof(T));
|
||||||
|
assert(_data != nullptr);
|
||||||
memset(_data, 0, sizeof(T) * DEFAULT_ALLOC_SIZE);
|
memset(_data, 0, sizeof(T) * DEFAULT_ALLOC_SIZE);
|
||||||
refreshIterators();
|
refreshIterators();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ target_sources(SeeleEngine
|
|||||||
WindowManager.cpp
|
WindowManager.cpp
|
||||||
Window.h
|
Window.h
|
||||||
Window.cpp
|
Window.cpp
|
||||||
GraphicsResources.h)
|
GraphicsResources.h
|
||||||
|
GraphicsResources.cpp
|
||||||
|
GraphicsEnums.h)
|
||||||
|
|
||||||
add_subdirectory(Vulkan/)
|
add_subdirectory(Vulkan/)
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
|||||||
|
#include "GraphicsResources.h"
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
|
|
||||||
|
void Seele::DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount)
|
||||||
|
{
|
||||||
|
if (descriptorBindings.size() <= bindingIndex)
|
||||||
|
{
|
||||||
|
descriptorBindings.resize(bindingIndex + 1);
|
||||||
|
}
|
||||||
|
DescriptorBinding binding;
|
||||||
|
binding.binding = bindingIndex;
|
||||||
|
binding.descriptorType = type;
|
||||||
|
binding.descriptorCount = arrayCount;
|
||||||
|
descriptorBindings[bindingIndex] = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDescriptorSet Seele::DescriptorLayout::allocatedDescriptorSet()
|
||||||
|
{
|
||||||
|
PDescriptorSet result;
|
||||||
|
allocator->allocateDescriptorSet(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seele::PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout)
|
||||||
|
{
|
||||||
|
if (descriptorSetLayouts.size() <= setIndex)
|
||||||
|
{
|
||||||
|
descriptorSetLayouts.resize(setIndex + 1);
|
||||||
|
}
|
||||||
|
if (descriptorSetLayouts[setIndex] != nullptr)
|
||||||
|
{
|
||||||
|
auto& thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
|
||||||
|
auto& otherBindings = layout->descriptorBindings;
|
||||||
|
thisBindings.resize(otherBindings.size());
|
||||||
|
for (size_t i = 0; i < otherBindings.size(); ++i)
|
||||||
|
{
|
||||||
|
if (otherBindings[i].descriptorType != SE_DESCRIPTOR_TYPE_MAX_ENUM)
|
||||||
|
{
|
||||||
|
assert(thisBindings[i].descriptorType != SE_DESCRIPTOR_TYPE_MAX_ENUM ? thisBindings[i].descriptorType == otherBindings[i].descriptorType : true);
|
||||||
|
thisBindings[i] = otherBindings[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
descriptorSetLayouts[setIndex] = layout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seele::PipelineLayout::addPushConstants(const SePushConstantRange& pushConstant)
|
||||||
|
{
|
||||||
|
pushConstants.add(pushConstant);
|
||||||
|
}
|
||||||
@@ -1,7 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "GraphicsEnums.h"
|
||||||
|
#include "Containers/Array.h"
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
|
struct SePushConstantRange {
|
||||||
|
SeShaderStageFlags stageFlags;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t size;
|
||||||
|
};
|
||||||
|
|
||||||
struct GraphicsInitializer
|
struct GraphicsInitializer
|
||||||
{
|
{
|
||||||
const char* windowLayoutFile;
|
const char* windowLayoutFile;
|
||||||
@@ -18,16 +26,20 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(RenderCommandBase);
|
DEFINE_REF(RenderCommandBase);
|
||||||
|
class SamplerState
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
DEFINE_REF(SamplerState);
|
||||||
class DescriptorBinding
|
class DescriptorBinding
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DescriptorBinding()
|
DescriptorBinding()
|
||||||
: binding(0)
|
: binding(0)
|
||||||
, descriptorType(VK_DESCRIPTOR_TYPE_MAX_ENUM)
|
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM)
|
||||||
, descriptorCount(-1)
|
, descriptorCount(-1)
|
||||||
, shaderStages(VK_SHADER_STAGE_ALL)
|
, shaderStages(SE_SHADER_STAGE_ALL)
|
||||||
{}
|
{}
|
||||||
DescriptorBinding(const DescriptorBinding& other)
|
DescriptorBinding(const DescriptorBinding& other)
|
||||||
: binding(other.binding)
|
: binding(other.binding)
|
||||||
@@ -43,83 +55,120 @@ namespace Seele
|
|||||||
shaderStages = other.shaderStages;
|
shaderStages = other.shaderStages;
|
||||||
}
|
}
|
||||||
uint32_t binding;
|
uint32_t binding;
|
||||||
//TODO make generic enum
|
SeDescriptorType descriptorType;
|
||||||
VkDescriptorType descriptorType;
|
|
||||||
uint32_t descriptorCount;
|
uint32_t descriptorCount;
|
||||||
VkShaderStageFlags shaderStages;
|
SeShaderStageFlags shaderStages;
|
||||||
};
|
};
|
||||||
DECLARE_REF(DescriptorBinding);
|
DEFINE_REF(DescriptorBinding);
|
||||||
|
|
||||||
|
DECLARE_REF(DescriptorSet);
|
||||||
class DescriptorAllocator
|
class DescriptorAllocator
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
DescriptorAllocator() {}
|
||||||
|
~DescriptorAllocator() {}
|
||||||
|
virtual void allocateDescriptorSet(PDescriptorSet& descriptorSet) = 0;
|
||||||
};
|
};
|
||||||
DECLARE_REF(DescriptorAllocator);
|
DEFINE_REF(DescriptorAllocator);
|
||||||
|
DECLARE_REF(UniformBuffer);
|
||||||
|
DECLARE_REF(StructuredBuffer);
|
||||||
|
DECLARE_REF(Texture);
|
||||||
class DescriptorSet
|
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;
|
||||||
};
|
};
|
||||||
DECLARE_REF(DescriptorSet);
|
DEFINE_REF(DescriptorSet);
|
||||||
|
|
||||||
class DescriptorLayout
|
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;
|
||||||
};
|
};
|
||||||
DECLARE_REF(DescriptorLayout);
|
DEFINE_REF(DescriptorLayout);
|
||||||
class PipelineLayout
|
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;
|
||||||
};
|
};
|
||||||
DECLARE_REF(PipelineLayout);
|
DEFINE_REF(PipelineLayout);
|
||||||
class VertexDeclaration
|
class VertexDeclaration
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(VertexDeclaration);
|
DEFINE_REF(VertexDeclaration);
|
||||||
class GraphicsPipeline
|
class GraphicsPipeline
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(GraphicsPipeline);
|
DEFINE_REF(GraphicsPipeline);
|
||||||
class UniformBuffer
|
class UniformBuffer
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(UniformBuffer);
|
DEFINE_REF(UniformBuffer);
|
||||||
class Viewport
|
class Viewport
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(Viewport);
|
DEFINE_REF(Viewport);
|
||||||
class VertexBuffer
|
class VertexBuffer
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(VertexBuffer);
|
DEFINE_REF(VertexBuffer);
|
||||||
class IndexBuffer
|
class IndexBuffer
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(IndexBuffer);
|
DEFINE_REF(IndexBuffer);
|
||||||
class StructuredBuffer
|
class StructuredBuffer
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(StructuredBuffer);
|
DEFINE_REF(StructuredBuffer);
|
||||||
class Texture
|
class Texture
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(Texture);
|
DEFINE_REF(Texture);
|
||||||
class Texture2D : public Texture
|
class Texture2D : public Texture
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(Texture2D);
|
DEFINE_REF(Texture2D);
|
||||||
class RenderPass
|
class RenderPass
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
DECLARE_REF(RenderPass);
|
DEFINE_REF(RenderPass);
|
||||||
}
|
}
|
||||||
@@ -17,5 +17,5 @@ namespace Seele
|
|||||||
Graphics* graphics;
|
Graphics* graphics;
|
||||||
Rect area;
|
Rect area;
|
||||||
};
|
};
|
||||||
DECLARE_REF(RenderPath);
|
DEFINE_REF(RenderPath);
|
||||||
}
|
}
|
||||||
@@ -17,5 +17,5 @@ namespace Seele
|
|||||||
PRenderPath renderer;
|
PRenderPath renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_REF(View)
|
DEFINE_REF(View)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
||||||
@@ -48,7 +48,7 @@ namespace Seele {
|
|||||||
Rect area;
|
Rect area;
|
||||||
Array<PView> views;
|
Array<PView> views;
|
||||||
};
|
};
|
||||||
DECLARE_REF(Section)
|
DEFINE_REF(Section)
|
||||||
class Graphics;
|
class Graphics;
|
||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
@@ -64,5 +64,5 @@ namespace Seele {
|
|||||||
uint32 height;
|
uint32 height;
|
||||||
Graphics* graphics;
|
Graphics* graphics;
|
||||||
};
|
};
|
||||||
DECLARE_REF(Window)
|
DEFINE_REF(Window)
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,5 @@ namespace Seele
|
|||||||
private:
|
private:
|
||||||
Array<PWindow> windows;
|
Array<PWindow> windows;
|
||||||
};
|
};
|
||||||
DECLARE_REF(WindowManager);
|
DEFINE_REF(WindowManager);
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include "Math/Math.h"
|
#include "Math/Math.h"
|
||||||
|
|
||||||
|
#define DEFINE_REF(x) typedef RefPtr<x> P##x; \
|
||||||
|
typedef UniquePtr<x> UP##x; \
|
||||||
|
typedef WeakPtr<x> W##x;
|
||||||
|
|
||||||
#define DECLARE_REF(x) class x; \
|
#define DECLARE_REF(x) class x; \
|
||||||
typedef RefPtr<x> P##x; \
|
typedef RefPtr<x> P##x; \
|
||||||
typedef UniquePtr<x> UP##x; \
|
typedef UniquePtr<x> UP##x; \
|
||||||
@@ -60,11 +64,20 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
return object == other.object;
|
return object == other.object;
|
||||||
}
|
}
|
||||||
|
bool operator!=(const RefPtr& other) const
|
||||||
|
{
|
||||||
|
return object != other.object;
|
||||||
|
}
|
||||||
T* operator->()
|
T* operator->()
|
||||||
{
|
{
|
||||||
assert(object != nullptr);
|
assert(object != nullptr);
|
||||||
return object->getHandle();
|
return object->getHandle();
|
||||||
}
|
}
|
||||||
|
const T* operator->() const
|
||||||
|
{
|
||||||
|
assert(object != nullptr);
|
||||||
|
return object->getHandle();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class RefObject
|
class RefObject
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ target_sources(Seele_unit_tests
|
|||||||
EngineTest.h
|
EngineTest.h
|
||||||
EngineTest.cpp)
|
EngineTest.cpp)
|
||||||
target_include_directories(Seele_unit_tests PUBLIC ./)
|
target_include_directories(Seele_unit_tests PUBLIC ./)
|
||||||
add_subdirectory(Containers/)
|
add_subdirectory(Containers/)
|
||||||
|
add_subdirectory(Graphics/)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
target_sources(Seele_unit_tests
|
||||||
|
PRIVATE
|
||||||
|
GraphicsResources.cpp)
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include "EngineTest.h"
|
||||||
|
#include "Graphics/GraphicsResources.h"
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE(DescriptorSets)
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(descriptor_set_merge)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
Reference in New Issue
Block a user