Change shader handling

This commit is contained in:
2023-08-04 20:20:20 +02:00
parent 4dac821abb
commit 836e9dce42
13 changed files with 71 additions and 23 deletions

View File

@@ -0,0 +1,24 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "VulkanDrawContext.hpp"
#include "Scene/Shader.hpp"
#include "Scene/VulkanShader.hpp"
namespace openVulkanoCpp::Vulkan
{
void VulkanDrawContext::EncodeShader(Scene::Shader* shader)
{
VulkanShader* vkShader = static_cast<VulkanShader*>(shader->renderShader);
if (!vkShader)
{
vkShader = renderer->GetResourceManager().CreateShader(shader);
}
else if (m_lastShader == vkShader) return; // Skip it if shader is already bound
vkShader->Record(commandBuffer, currentImageId);
m_lastShader = vkShader;
}
}