Fix some issue with deinitializing textures
This commit is contained in:
@@ -14,22 +14,36 @@
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
class Texture;
|
||||
|
||||
struct RenderTexture
|
||||
{
|
||||
Texture* m_texture = nullptr;
|
||||
};
|
||||
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
static Texture PLACEHOLDER;
|
||||
static constexpr inline DescriptorSetLayoutBinding DESCRIPTOR_SET_LAYOUT_BINDING = { 0, DescriptorSetLayoutBinding::Type::TYPE_COMBINED_IMAGE_SAMPLER, 1, ShaderProgramType::ALL_GRAPHICS };
|
||||
|
||||
Texture(bool placeholder = false) { if (placeholder) MakePlaceholder(); }
|
||||
|
||||
ICloseable* renderTexture = nullptr;
|
||||
RenderTexture* renderTexture = nullptr;
|
||||
void* textureBuffer = nullptr;
|
||||
Math::Vector3ui resolution = {0,0,0};
|
||||
size_t size = 0;
|
||||
Math::Vector3ui resolution = {0,0,0};
|
||||
DataFormat format = DataFormat::B8G8R8A8_UNORM;
|
||||
bool updated = true;
|
||||
UpdateFrequency updateFrequency = UpdateFrequency::Never;
|
||||
|
||||
Texture(bool placeholder = false) { if (placeholder) MakePlaceholder(); }
|
||||
|
||||
~Texture()
|
||||
{
|
||||
if (renderTexture)
|
||||
{
|
||||
renderTexture->m_texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MakePlaceholder(uint32_t width = 32, uint32_t height = 32,
|
||||
Math::Vector4uc color1 = {248, 123, 255, 255}, Math::Vector4uc color2 = {250, 19, 255, 255});
|
||||
@@ -43,4 +57,4 @@ namespace OpenVulkano::Scene
|
||||
|
||||
operator bool() const { return setId >= 0 && texture; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
void MetalBackedTexture::Close()
|
||||
{
|
||||
m_vulkanTexture.Close();
|
||||
if (m_vulkanTexture) m_vulkanTexture.Close();
|
||||
if (m_metalTexture)
|
||||
{
|
||||
[m_metalTexture release];
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
namespace OpenVulkano::Vulkan
|
||||
{
|
||||
class VulkanTexture : public IRecordable, public Image
|
||||
class VulkanTexture : public Scene::RenderTexture, public IRecordable, public Image
|
||||
{
|
||||
public:
|
||||
static inline vk::SamplerCreateInfo DEFAULT_SAMPLER_CONFIG {};
|
||||
Scene::Texture* m_texture = nullptr;
|
||||
vk::Sampler m_sampler;
|
||||
vk::DescriptorSet m_descriptorSet;
|
||||
|
||||
@@ -52,7 +51,7 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
virtual ~VulkanTexture() override
|
||||
{
|
||||
if (m_texture) Close();
|
||||
if (m_sampler) Close();
|
||||
}
|
||||
|
||||
void Close() override
|
||||
@@ -138,4 +137,4 @@ namespace OpenVulkano::Vulkan
|
||||
VulkanTexture::Record(context, setId);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user