Update how camera data is communicated to shader

This commit is contained in:
2023-08-31 21:16:11 +02:00
parent 93c75763c7
commit df4194be51
21 changed files with 265 additions and 177 deletions

View File

@@ -13,6 +13,7 @@
#include "Scene/VulkanShader.hpp"
#include "Base/UI/IVulkanWindow.hpp"
#include "Host/PlatformProducer.hpp"
#include "Vulkan/Scene/VulkanCamera.hpp"
#include <stdexcept>
namespace openVulkanoCpp::Vulkan
@@ -150,11 +151,15 @@ namespace openVulkanoCpp::Vulkan
Scene::Drawable** drawablePointer;
VulkanDrawContext drawContext { poolId, currentImageId, cmdHelper->cmdBuffer, this };
if (!scene->GetCamera()->renderCamera) resourceManager.PrepareCamera(scene->GetCamera());
while((drawablePointer = jobQueue->Pop()) != nullptr)
{
Scene::Drawable* drawable = *drawablePointer;
drawContext.EncodeShader(drawable->GetShader());
cmdHelper->cmdBuffer.pushConstants(drawContext.GetShader()->pipelineLayout, vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) + 8 * sizeof(float), &scene->GetCamera()->GetViewProjectionMatrix());
static_cast<VulkanCamera*>(scene->GetCamera()->renderCamera)->Record(&drawContext);
//cmdHelper->cmdBuffer.pushConstants(drawContext.GetShader()->pipelineLayout, vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) + 8 * sizeof(float), &scene->GetCamera()->GetViewProjectionMatrix());
drawable->GetEncoder().vulkan(drawable, &drawContext);
}
cmdHelper->cmdBuffer.end();