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

68 lines
1.9 KiB
C++
Raw Normal View History

2023-10-26 18:37:29 +02:00
#pragma once
#include "Containers/Array.h"
2024-06-09 12:20:04 +02:00
#include "Enums.h"
#include "Math/Math.h"
2023-10-26 18:37:29 +02:00
#ifndef ENABLE_VALIDATION
2023-12-28 21:42:18 +01:00
#define ENABLE_VALIDATION 1
2023-10-26 18:37:29 +02:00
#endif
2024-06-09 12:20:04 +02:00
namespace Seele {
2023-10-26 18:37:29 +02:00
DECLARE_REF(Material)
2024-06-09 12:20:04 +02:00
namespace Gfx {
2023-10-26 18:37:29 +02:00
DECLARE_REF(DescriptorSet)
DECLARE_REF(Graphics)
DECLARE_REF(VertexBuffer)
DECLARE_REF(IndexBuffer)
2023-11-15 00:06:00 +01:00
DECLARE_REF(GraphicsPipeline)
DECLARE_REF(ComputePipeline)
2024-06-09 12:20:04 +02:00
class Sampler {
public:
virtual ~Sampler() {}
2023-10-26 18:37:29 +02:00
};
2023-11-15 00:06:00 +01:00
DEFINE_REF(Sampler)
2023-10-26 18:37:29 +02:00
2024-06-09 12:20:04 +02:00
struct QueueFamilyMapping {
2023-10-26 18:37:29 +02:00
uint32 graphicsFamily;
uint32 computeFamily;
uint32 transferFamily;
2024-06-09 12:20:04 +02:00
uint32 getQueueTypeFamilyIndex(Gfx::QueueType type) const {
switch (type) {
2023-10-26 18:37:29 +02:00
case Gfx::QueueType::GRAPHICS:
return graphicsFamily;
case Gfx::QueueType::COMPUTE:
return computeFamily;
case Gfx::QueueType::TRANSFER:
return transferFamily;
default:
return 0x7fff;
}
}
2024-06-09 12:20:04 +02:00
bool needsTransfer(Gfx::QueueType src, Gfx::QueueType dst) const {
2023-10-26 18:37:29 +02:00
uint32 srcIndex = getQueueTypeFamilyIndex(src);
uint32 dstIndex = getQueueTypeFamilyIndex(dst);
return srcIndex != dstIndex;
}
};
2024-06-09 12:20:04 +02:00
class QueueOwnedResource {
public:
2023-10-26 18:37:29 +02:00
QueueOwnedResource(QueueFamilyMapping mapping, QueueType startQueueType);
virtual ~QueueOwnedResource();
2024-06-09 12:20:04 +02:00
// Preliminary checks to see if the barrier should be executed at all
2023-10-26 18:37:29 +02:00
void transferOwnership(QueueType newOwner);
void pipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage, SeAccessFlags dstAccess, SePipelineStageFlags dstStage);
2024-06-09 12:20:04 +02:00
protected:
2023-10-26 18:37:29 +02:00
virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
2024-06-09 12:20:04 +02:00
virtual void executePipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage, SeAccessFlags dstAccess,
SePipelineStageFlags dstStage) = 0;
2023-10-26 18:37:29 +02:00
Gfx::QueueType currentOwner;
QueueFamilyMapping mapping;
};
DEFINE_REF(QueueOwnedResource)
} // namespace Gfx
} // namespace Seele