More Refactoring

This commit is contained in:
Dynamitos
2023-11-15 17:42:57 +01:00
parent f8f48352a3
commit 35966cb5b7
60 changed files with 1217 additions and 2332 deletions
+36 -98
View File
@@ -8,46 +8,46 @@ namespace Seele
namespace Vulkan
{
class TextureHandle
class TextureBase
{
public:
TextureHandle(PGraphics graphics, VkImageViewType viewType,
TextureBase(PGraphics graphics, VkImageViewType viewType,
const TextureCreateInfo& createInfo, Gfx::QueueType& owner, VkImage existingImage = VK_NULL_HANDLE);
virtual ~TextureHandle();
virtual ~TextureBase();
inline VkImage getImage() const
constexpr VkImage getImage() const
{
return image;
}
inline VkImageView getView() const
constexpr VkImageView getView() const
{
return defaultView;
}
inline Gfx::SeImageLayout getLayout() const
constexpr Gfx::SeImageLayout getLayout() const
{
return layout;
}
inline VkImageAspectFlags getAspect() const
constexpr VkImageAspectFlags getAspect() const
{
return aspect;
}
inline VkImageUsageFlags getUsage() const
constexpr VkImageUsageFlags getUsage() const
{
return usage;
}
inline Gfx::SeFormat getFormat() const
constexpr Gfx::SeFormat getFormat() const
{
return format;
}
inline Gfx::SeSampleCountFlags getNumSamples() const
constexpr Gfx::SeSampleCountFlags getNumSamples() const
{
return samples;
}
inline uint32 getMipLevels() const
constexpr uint32 getMipLevels() const
{
return mipLevels;
}
inline bool isDepthStencil() const
constexpr bool isDepthStencil() const
{
return aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
}
@@ -57,14 +57,14 @@ public:
void changeLayout(Gfx::SeImageLayout newLayout);
void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer);
private:
protected:
//Updates via reference
Gfx::QueueType& currentOwner;
PGraphics graphics;
OSubAllocation allocation;
uint32 sizeX;
uint32 sizeY;
uint32 sizeZ;
uint32 width;
uint32 height;
uint32 depth;
uint32 arrayCount;
uint32 layerCount;
uint32 mipLevels;
@@ -75,23 +75,9 @@ private:
VkImageView defaultView;
VkImageAspectFlags aspect;
Gfx::SeImageLayout layout;
friend class TextureBase;
friend class Texture2D;
friend class Texture3D;
friend class TextureCube;
friend class Graphics;
};
class TextureBase
{
public:
static TextureHandle* cast(Gfx::PTexture texture);
protected:
TextureHandle* textureHandle;
friend class Graphics;
};
DECLARE_REF(TextureBase)
class Texture2D : public Gfx::Texture2D, public TextureBase
{
public:
@@ -99,46 +85,31 @@ public:
virtual ~Texture2D();
virtual uint32 getWidth() const override
{
return textureHandle->sizeX;
return width;
}
virtual uint32 getHeight() const override
{
return textureHandle->sizeY;
return height;
}
virtual uint32 getDepth() const override
{
return textureHandle->sizeZ;
return depth;
}
virtual Gfx::SeFormat getFormat() const override
{
return textureHandle->format;
return format;
}
virtual Gfx::SeSampleCountFlags getNumSamples() const override
{
return textureHandle->getNumSamples();
return samples;
}
virtual uint32 getMipLevels() const override
{
return textureHandle->getMipLevels();
return mipLevels;
}
virtual void changeLayout(Gfx::SeImageLayout newLayout) override;
virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override;
virtual void* getNativeHandle() override
{
return textureHandle;
}
inline VkImage getHandle() const
{
return textureHandle->image;
}
inline VkImageView getView() const
{
return textureHandle->defaultView;
}
inline bool isDepthStencil() const
{
return textureHandle->isDepthStencil();
}
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
@@ -155,46 +126,31 @@ public:
virtual ~Texture3D();
virtual uint32 getWidth() const override
{
return textureHandle->sizeX;
return width;
}
virtual uint32 getHeight() const override
{
return textureHandle->sizeY;
return height;
}
virtual uint32 getDepth() const override
{
return textureHandle->sizeZ;
return depth;
}
virtual Gfx::SeFormat getFormat() const override
{
return textureHandle->format;
return format;
}
virtual Gfx::SeSampleCountFlags getNumSamples() const override
{
return textureHandle->getNumSamples();
return samples;
}
virtual uint32 getMipLevels() const override
{
return textureHandle->getMipLevels();
return mipLevels;
}
virtual void changeLayout(Gfx::SeImageLayout newLayout) override;
virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override;
virtual void* getNativeHandle() override
{
return textureHandle;
}
inline VkImage getHandle() const
{
return textureHandle->image;
}
inline VkImageView getView() const
{
return textureHandle->defaultView;
}
inline bool isDepthStencil() const
{
return textureHandle->isDepthStencil();
}
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
@@ -211,54 +167,36 @@ public:
virtual ~TextureCube();
virtual uint32 getWidth() const override
{
return textureHandle->sizeX;
return width;
}
virtual uint32 getHeight() const override
{
return textureHandle->sizeY;
return height;
}
virtual uint32 getDepth() const override
{
return textureHandle->sizeZ;
return depth;
}
virtual Gfx::SeFormat getFormat() const override
{
return textureHandle->format;
return format;
}
virtual Gfx::SeSampleCountFlags getNumSamples() const override
{
return textureHandle->getNumSamples();
return samples;
}
virtual uint32 getMipLevels() const override
{
return textureHandle->getMipLevels();
return mipLevels;
}
virtual void changeLayout(Gfx::SeImageLayout newLayout) override;
virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override;
virtual void* getNativeHandle() override
{
return textureHandle;
}
inline VkImage getHandle() const
{
return textureHandle->image;
}
inline VkImageView getView() const
{
return textureHandle->defaultView;
}
inline bool isDepthStencil() const
{
return textureHandle->isDepthStencil();
}
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
};
DEFINE_REF(TextureCube)
}
}