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

81 lines
2.5 KiB
C++
Raw Normal View History

2024-04-10 12:53:55 +02:00
#pragma once
#include "Graphics/Descriptor.h"
2024-04-10 15:50:20 +02:00
#include "Graphics/Initializer.h"
#include "MinimalEngine.h"
2024-04-14 11:35:37 +02:00
#include "Buffer.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-04-10 12:53:55 +02:00
public:
2024-04-13 23:51:38 +02:00
DescriptorLayout(PGraphics graphics, const std::string& name);
2024-04-10 12:53:55 +02:00
virtual ~DescriptorLayout();
2024-04-10 15:50:20 +02:00
virtual void create() override;
2024-04-13 23:51:38 +02:00
2024-04-10 12:53:55 +02:00
private:
PGraphics graphics;
};
2024-04-13 23:51:38 +02:00
DEFINE_REF(DescriptorLayout)
DECLARE_REF(DescriptorSet)
class DescriptorPool : public Gfx::DescriptorPool {
2024-04-10 12:53:55 +02:00
public:
2024-04-13 23:51:38 +02:00
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-04-10 12:53:55 +02:00
private:
2024-04-10 15:50:20 +02:00
PGraphics graphics;
2024-04-13 23:51:38 +02:00
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-04-12 09:27:30 +02:00
class DescriptorSet : public Gfx::DescriptorSet {
2024-04-10 15:50:20 +02:00
public:
2024-04-12 09:27:30 +02:00
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
2024-04-10 15:50:20 +02:00
virtual ~DescriptorSet();
2024-04-12 09:27:30 +02:00
virtual void writeChanges();
2024-04-13 23:51:38 +02:00
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
2024-04-12 09:27:30 +02:00
virtual void updateBuffer(uint32_t binding, Gfx::PShaderBuffer uniformBuffer);
virtual void updateSampler(uint32_t binding, Gfx::PSampler samplerState);
2024-04-13 23:51:38 +02:00
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler sampler = nullptr);
virtual void updateTextureArray(uint32_t binding, Array<Gfx::PTexture> texture);
2024-04-12 09:27:30 +02:00
2024-04-13 23:51:38 +02:00
constexpr bool isCurrentlyBound() const { return bindCount > 0; }
constexpr bool isCurrentlyInUse() const { return currentlyInUse; }
constexpr void bind() { bindCount++; }
constexpr void unbind() { bindCount--; }
constexpr void allocate() { currentlyInUse = true; }
constexpr void free() { currentlyInUse = false; }
2024-04-14 11:35:37 +02:00
constexpr MTL::Buffer* getBuffer() const { return buffer; }
2024-04-19 18:23:36 +02:00
constexpr const Array<MTL::Resource*>& getBoundResources() const { return boundResources; }
2024-04-14 11:35:37 +02:00
2024-04-10 15:50:20 +02:00
private:
PGraphics graphics;
PDescriptorPool owner;
2024-04-19 22:44:00 +02:00
MTL::Buffer* buffer = nullptr;
2024-04-20 21:35:43 +02:00
uint64* argumentBuffer = nullptr;
2024-04-19 18:23:36 +02:00
Array<MTL::Resource*> boundResources;
2024-04-13 23:51:38 +02:00
uint32 bindCount;
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-04-10 15:50:20 +02:00
public:
2024-04-20 21:35:43 +02:00
PipelineLayout(PGraphics graphics, const std::string& name, Gfx::PPipelineLayout baseLayout);
2024-04-13 23:51:38 +02:00
virtual ~PipelineLayout();
virtual void create() override;
2024-04-10 15:50:20 +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