Fix some shader issues
This commit is contained in:
@@ -39,7 +39,7 @@ namespace OpenVulkano::Scene
|
|||||||
const DrawPhase phase = DrawPhase::MAIN)
|
const DrawPhase phase = DrawPhase::MAIN)
|
||||||
: m_encoder(encoder), m_drawPhase(phase) {}
|
: m_encoder(encoder), m_drawPhase(phase) {}
|
||||||
|
|
||||||
~Drawable() override { if (m_scene) Drawable::Close(); }
|
~Drawable() override {/* if (m_scene) Drawable::Close();*/ }
|
||||||
|
|
||||||
void Close() override;
|
void Close() override;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenVulkano::Scene
|
|||||||
|
|
||||||
~SimpleDrawable()
|
~SimpleDrawable()
|
||||||
{
|
{
|
||||||
if (m_mesh) SimpleDrawable::Close();
|
//if (m_mesh) SimpleDrawable::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(Shader* shader, Geometry* mesh, Material* material);
|
void Init(Shader* shader, Geometry* mesh, Material* material);
|
||||||
@@ -45,4 +45,4 @@ namespace OpenVulkano::Scene
|
|||||||
|
|
||||||
[[nodiscard]] Material* GetMaterial() const { return m_material; }
|
[[nodiscard]] Material* GetMaterial() const { return m_material; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ namespace OpenVulkano::Vulkan
|
|||||||
|
|
||||||
void ResourceManager::RemoveShader(VulkanShader* shader)
|
void ResourceManager::RemoveShader(VulkanShader* shader)
|
||||||
{
|
{
|
||||||
|
if (!cmdPools) return;
|
||||||
const std::unique_lock lock(mutex);
|
const std::unique_lock lock(mutex);
|
||||||
std::vector<std::unique_ptr<VulkanShader>>::iterator object =
|
std::vector<std::unique_ptr<VulkanShader>>::iterator object =
|
||||||
find_if(shaders.begin(), shaders.end(),
|
find_if(shaders.begin(), shaders.end(),
|
||||||
|
|||||||
@@ -17,14 +17,7 @@ namespace OpenVulkano::Vulkan
|
|||||||
VulkanShader::~VulkanShader()
|
VulkanShader::~VulkanShader()
|
||||||
{
|
{
|
||||||
if (!shader) return;
|
if (!shader) return;
|
||||||
device.destroyPipeline(pipeline);
|
Close();
|
||||||
for(auto& shaderModule : shaderModules)
|
|
||||||
{
|
|
||||||
device.destroyShaderModule(shaderModule);
|
|
||||||
}
|
|
||||||
device.destroyPipelineLayout(pipelineLayout);
|
|
||||||
for(auto& descriptorSetLayout : descriptorSetLayouts)
|
|
||||||
device.destroyDescriptorSetLayout(descriptorSetLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanShader::Init(Context* context, Scene::Shader* shader, IShaderOwner* owner)
|
void VulkanShader::Init(Context* context, Scene::Shader* shader, IShaderOwner* owner)
|
||||||
@@ -124,7 +117,17 @@ namespace OpenVulkano::Vulkan
|
|||||||
|
|
||||||
void VulkanShader::Close()
|
void VulkanShader::Close()
|
||||||
{
|
{
|
||||||
owner->RemoveShader(this);
|
shader->renderShader = nullptr;
|
||||||
|
device.destroyPipeline(pipeline);
|
||||||
|
for(auto& shaderModule : shaderModules)
|
||||||
|
{
|
||||||
|
device.destroyShaderModule(shaderModule);
|
||||||
|
}
|
||||||
|
device.destroyPipelineLayout(pipelineLayout);
|
||||||
|
for(auto& descriptorSetLayout : descriptorSetLayouts)
|
||||||
|
device.destroyDescriptorSetLayout(descriptorSetLayout);
|
||||||
|
shader = nullptr;
|
||||||
|
if (owner) owner->RemoveShader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanShader::CreatePipelineLayout()
|
void VulkanShader::CreatePipelineLayout()
|
||||||
@@ -150,4 +153,4 @@ namespace OpenVulkano::Vulkan
|
|||||||
vk::PipelineLayoutCreateInfo plci = { {}, static_cast<uint32_t>(descriptorSetLayouts.size()), descriptorSetLayouts.data(), 0, nullptr };
|
vk::PipelineLayoutCreateInfo plci = { {}, static_cast<uint32_t>(descriptorSetLayouts.size()), descriptorSetLayouts.data(), 0, nullptr };
|
||||||
pipelineLayout = this->device.createPipelineLayout(plci);
|
pipelineLayout = this->device.createPipelineLayout(plci);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user