Descriptor sets and refactoring
This commit is contained in:
@@ -8,64 +8,75 @@
|
||||
namespace Seele {
|
||||
namespace Metal {
|
||||
DECLARE_REF(Graphics)
|
||||
DECLARE_REF(DescriptorPool)
|
||||
class DescriptorLayout : public Gfx::DescriptorLayout {
|
||||
public:
|
||||
DescriptorLayout(PGraphics graphics, const std::string &name);
|
||||
DescriptorLayout(PGraphics graphics, const std::string& name);
|
||||
virtual ~DescriptorLayout();
|
||||
virtual void create() override;
|
||||
NS::Array* getArguments() const
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
|
||||
NS::Array* getArguments() const { return arguments; }
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
NS::Array* arguments;
|
||||
};
|
||||
class PipelineLayout : public Gfx::PipelineLayout {
|
||||
DEFINE_REF(DescriptorLayout)
|
||||
|
||||
DECLARE_REF(DescriptorSet)
|
||||
class DescriptorPool : public Gfx::DescriptorPool {
|
||||
public:
|
||||
PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout)
|
||||
: Gfx::PipelineLayout(baseLayout), graphics(graphics) {}
|
||||
DescriptorPool(PGraphics graphics, PDescriptorLayout layout);
|
||||
virtual ~DescriptorPool();
|
||||
virtual Gfx::PDescriptorSet allocateDescriptorSet() override;
|
||||
virtual void reset() override;
|
||||
constexpr NS::Array* getArguments() const { return layout->getArguments(); }
|
||||
constexpr PDescriptorLayout getLayout() const { return layout; }
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
PDescriptorLayout layout;
|
||||
Array<ODescriptorSet> allocatedSets;
|
||||
};
|
||||
DEFINE_REF(PipelineLayout)
|
||||
DEFINE_REF(DescriptorPool)
|
||||
|
||||
class DescriptorSet : public Gfx::DescriptorSet {
|
||||
public:
|
||||
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
|
||||
virtual ~DescriptorSet();
|
||||
virtual void writeChanges();
|
||||
virtual void updateBuffer(uint32_t binding,
|
||||
Gfx::PUniformBuffer uniformBuffer);
|
||||
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
|
||||
virtual void updateBuffer(uint32_t binding, Gfx::PShaderBuffer uniformBuffer);
|
||||
virtual void updateSampler(uint32_t binding, Gfx::PSampler samplerState);
|
||||
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture,
|
||||
Gfx::PSampler sampler = nullptr);
|
||||
virtual void updateTextureArray(uint32_t binding,
|
||||
Array<Gfx::PTexture> texture);
|
||||
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler sampler = nullptr);
|
||||
virtual void updateTextureArray(uint32_t binding, Array<Gfx::PTexture> texture);
|
||||
virtual bool operator<(Gfx::PDescriptorSet other);
|
||||
|
||||
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; }
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
PDescriptorPool owner;
|
||||
MTL::Buffer* buffer;
|
||||
MTL::ArgumentEncoder* encoder;
|
||||
uint32 bindCount;
|
||||
bool currentlyInUse;
|
||||
};
|
||||
DEFINE_REF(DescriptorSet)
|
||||
|
||||
class DescriptorPool : public Gfx::DescriptorPool {
|
||||
class PipelineLayout : public Gfx::PipelineLayout {
|
||||
public:
|
||||
DescriptorPool(PGraphics graphics, DescriptorLayout& layout);
|
||||
virtual ~DescriptorPool();
|
||||
NS::Array* getArguments() const
|
||||
{
|
||||
return layout.getArguments();
|
||||
}
|
||||
PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout);
|
||||
virtual ~PipelineLayout();
|
||||
virtual void create() override;
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
DescriptorLayout& layout;
|
||||
};
|
||||
DEFINE_REF(PipelineLayout)
|
||||
} // namespace Metal
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user