Files
Seele/src/Engine/Graphics/Metal/Descriptor.h
T

79 lines
2.6 KiB
C++
Raw Normal View History

2024-04-10 12:53:55 +02:00
#pragma once
2024-05-17 18:08:11 +02:00
#include "Buffer.h"
2024-04-10 12:53:55 +02:00
#include "Graphics/Descriptor.h"
2024-04-10 15:50:20 +02:00
#include "Graphics/Initializer.h"
2024-05-17 18:08:11 +02:00
#include "Graphics/Metal/Resources.h"
2024-04-10 15:50:20 +02:00
#include "MinimalEngine.h"
2024-04-10 12:53:55 +02:00
namespace Seele {
namespace Metal {
DECLARE_REF(Graphics)
2024-04-12 09:27:30 +02:00
class DescriptorLayout : public Gfx::DescriptorLayout {
2024-06-09 12:20:04 +02:00
public:
DescriptorLayout(PGraphics graphics, const std::string& name);
virtual ~DescriptorLayout();
virtual void create() override;
2024-04-13 23:51:38 +02:00
2024-06-09 12:20:04 +02:00
private:
PGraphics graphics;
2024-04-10 12:53:55 +02:00
};
2024-04-13 23:51:38 +02:00
DEFINE_REF(DescriptorLayout)
DECLARE_REF(DescriptorSet)
class DescriptorPool : public Gfx::DescriptorPool {
2024-06-09 12:20:04 +02:00
public:
DescriptorPool(PGraphics graphics, PDescriptorLayout layout);
virtual ~DescriptorPool();
virtual Gfx::PDescriptorSet allocateDescriptorSet() override;
virtual void reset() override;
constexpr PDescriptorLayout getLayout() const { return layout; }
2024-04-12 09:27:30 +02:00
2024-06-09 12:20:04 +02:00
private:
PGraphics graphics;
PDescriptorLayout layout;
Array<ODescriptorSet> allocatedSets;
2024-04-10 15:50:20 +02:00
};
2024-04-13 23:51:38 +02:00
DEFINE_REF(DescriptorPool)
2024-04-10 12:53:55 +02:00
2024-05-17 18:08:11 +02:00
class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
2024-06-09 12:20:04 +02:00
public:
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
virtual ~DescriptorSet();
virtual void writeChanges() override;
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) override;
virtual void updateBuffer(uint32_t binding, Gfx::PShaderBuffer uniformBuffer) override;
virtual void updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer uniformBuffer) override;
virtual void updateSampler(uint32_t binding, Gfx::PSampler samplerState) override;
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler sampler = nullptr) override;
virtual void updateTextureArray(uint32_t binding, Array<Gfx::PTexture> texture) override;
2024-04-12 09:27:30 +02:00
2024-06-09 12:20:04 +02:00
constexpr bool isCurrentlyInUse() const { return currentlyInUse; }
constexpr void allocate() { currentlyInUse = true; }
constexpr void free() { currentlyInUse = false; }
2024-04-13 23:51:38 +02:00
2024-06-09 12:20:04 +02:00
constexpr MTL::Buffer* getBuffer() const { return buffer; }
constexpr const Array<MTL::Resource*>& getBoundResources() const { return boundResources; }
2024-04-14 11:35:37 +02:00
2024-06-09 12:20:04 +02:00
private:
PGraphics graphics;
PDescriptorPool owner;
MTL::Buffer* buffer = nullptr;
uint64* argumentBuffer = nullptr;
Array<MTL::Resource*> boundResources;
bool currentlyInUse;
2024-04-10 15:50:20 +02:00
};
DEFINE_REF(DescriptorSet)
2024-04-13 23:51:38 +02:00
class PipelineLayout : public Gfx::PipelineLayout {
2024-06-09 12:20:04 +02:00
public:
PipelineLayout(PGraphics graphics, const std::string& name, Gfx::PPipelineLayout baseLayout);
virtual ~PipelineLayout();
virtual void create() override;
2024-05-17 18:08:11 +02:00
2024-06-09 12:20:04 +02:00
private:
PGraphics graphics;
2024-04-10 12:53:55 +02:00
};
2024-04-13 23:51:38 +02:00
DEFINE_REF(PipelineLayout)
2024-04-12 09:27:30 +02:00
} // namespace Metal
2024-04-19 18:23:36 +02:00
} // namespace Seele