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

62 lines
1.4 KiB
C++
Raw Normal View History

2024-04-09 16:41:12 +02:00
#pragma once
2024-08-26 21:49:09 +02:00
#include "Graphics/Initializer.h"
2024-08-28 17:54:14 +02:00
#include "Graphics/Resources.h"
2024-04-13 23:51:38 +02:00
#include "Metal/MTLSampler.hpp"
2024-04-09 16:41:12 +02:00
#include <Foundation/Foundation.hpp>
#include <Metal/Metal.hpp>
#include <QuartzCore/CAMetalLayer.h>
2024-04-10 09:58:39 +02:00
#include <QuartzCore/CAMetalLayer.hpp>
#include <QuartzCore/QuartzCore.hpp>
namespace Seele {
namespace Metal {
DECLARE_REF(Graphics);
2024-06-09 12:20:04 +02:00
class CommandBoundResource {
public:
CommandBoundResource(PGraphics graphics) : graphics(graphics) {}
virtual ~CommandBoundResource() {
2024-05-17 18:08:11 +02:00
if (isCurrentlyBound())
abort();
}
constexpr bool isCurrentlyBound() const { return bindCount > 0; }
constexpr void bind() { bindCount++; }
constexpr void unbind() { bindCount--; }
2024-06-09 12:20:04 +02:00
protected:
2024-05-17 18:08:11 +02:00
PGraphics graphics;
uint64 bindCount = 0;
};
DEFINE_REF(CommandBoundResource)
2024-04-10 09:58:39 +02:00
class Fence {
2024-06-09 12:20:04 +02:00
public:
Fence(PGraphics graphics);
~Fence();
MTL::Fence* getHandle() const { return handle; }
2024-04-10 09:58:39 +02:00
2024-06-09 12:20:04 +02:00
private:
MTL::Fence* handle;
2024-04-10 09:58:39 +02:00
};
DEFINE_REF(Fence);
class Event {
2024-06-09 12:20:04 +02:00
public:
Event(PGraphics graphics);
~Event();
MTL::Event* getHandle() const { return handle; }
2024-04-10 09:58:39 +02:00
2024-06-09 12:20:04 +02:00
private:
MTL::Event* handle;
2024-04-10 09:58:39 +02:00
};
DEFINE_REF(Event)
2024-06-09 12:20:04 +02:00
class Sampler : public Gfx::Sampler {
public:
Sampler(PGraphics graphics, const SamplerCreateInfo& createInfo);
virtual ~Sampler();
MTL::SamplerState* getHandle() const { return sampler; }
private:
MTL::SamplerState* sampler;
2024-04-13 23:51:38 +02:00
};
DEFINE_REF(Sampler)
2024-04-10 09:58:39 +02:00
} // namespace Metal
} // namespace Seele