52 lines
939 B
C++
52 lines
939 B
C++
// =============================================
|
|
// Aster: sampler.h
|
|
// Copyright (c) 2020-2025 Anish Bhobe
|
|
// =============================================
|
|
|
|
#pragma once
|
|
|
|
#include "global.h"
|
|
|
|
struct Device;
|
|
|
|
// TODO Refactor the Buffer Hierarchy
|
|
|
|
struct Sampler
|
|
{
|
|
const Device *m_Device = nullptr;
|
|
vk::Sampler m_Sampler = nullptr;
|
|
std::atomic<u32> m_RefCount = 0;
|
|
|
|
void Init(const Device *device, const vk::SamplerCreateInfo &samplerCreateInfo, cstr name);
|
|
void Destroy();
|
|
|
|
void
|
|
AddRef()
|
|
{
|
|
const auto rc = ++m_RefCount;
|
|
assert(rc > 0);
|
|
}
|
|
|
|
void
|
|
Release()
|
|
{
|
|
const auto rc = --m_RefCount;
|
|
assert(rc < MaxValue<u32>);
|
|
if (rc == 0)
|
|
{
|
|
Destroy();
|
|
}
|
|
}
|
|
|
|
[[nodiscard]] bool
|
|
IsReferenced() const
|
|
{
|
|
return m_RefCount;
|
|
}
|
|
|
|
[[nodiscard]] bool
|
|
IsValid() const
|
|
{
|
|
return m_Sampler;
|
|
}
|
|
}; |