diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index fef55b7..8c3214c 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -110,8 +110,17 @@ const char* KRPipeline::KRENGINE_PUSH_CONSTANT_NAMES[] = { }; KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat) - : KRContextObject(context) + : KRPipeline(context, surface.m_deviceHandle, surface.getForwardOpaquePass(), surface.getDimensions(), surface.getDimensions(), info, szKey, shaders, vertexAttributes, modelFormat) { +// TODO - renderPass needs to be selected dynamically from info.render_pass +} + +KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, KRRenderPass& renderPass, Vector2i viewport_size, Vector2i scissor_size, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat) + : KRContextObject(context) + , m_deviceHandle(deviceHandle) +{ + std::unique_ptr& device = getContext().getDeviceManager()->getDevice(m_deviceHandle); + for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; pushConstants.buffer = nullptr; @@ -127,8 +136,6 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf m_descriptorSets.reserve(KRENGINE_MAX_FRAMES_IN_FLIGHT); // TODO - Handle device removal - m_deviceHandle = surface.m_deviceHandle; - std::unique_ptr& device = surface.getDevice(); strcpy(m_szKey, szKey); @@ -260,15 +267,15 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf VkViewport viewport{}; viewport.x = 0.0f; viewport.y = 0.0f; - viewport.width = static_cast(surface.getWidth()); - viewport.height = static_cast(surface.getHeight()); + viewport.width = static_cast(viewport_size.x); + viewport.height = static_cast(viewport_size.y); viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor{}; scissor.offset = { 0, 0 }; - scissor.extent.width = surface.getWidth(); - scissor.extent.height = surface.getHeight(); + scissor.extent.width = scissor_size.x; + scissor.extent.height = scissor_size.y; VkPipelineViewportStateCreateInfo viewportState{}; viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; @@ -443,8 +450,6 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf depthStencil.front = {}; depthStencil.back = {}; - KRRenderPass& renderPass = surface.getForwardOpaquePass(); // TODO - This needs to be selected dynamically from info.render_pass - VkGraphicsPipelineCreateInfo pipelineInfo{}; pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pipelineInfo.stageCount = stage_count; diff --git a/kraken/KRPipeline.h b/kraken/KRPipeline.h index 3687387..5231bf7 100644 --- a/kraken/KRPipeline.h +++ b/kraken/KRPipeline.h @@ -215,6 +215,7 @@ class KRPipeline : public KRContextObject { public: + KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, KRRenderPass& renderPass, Vector2i viewport_size, Vector2i scissor_size, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat); KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat); virtual ~KRPipeline(); const char* getKey() const; @@ -249,7 +250,6 @@ public: projection_matrix, camerapos_model_space, viewport, - viewport_downsample, diffusetexture, speculartexture, reflectioncubetexture, diff --git a/kraken/KRSurface.cpp b/kraken/KRSurface.cpp index a2bf763..80627a5 100644 --- a/kraken/KRSurface.cpp +++ b/kraken/KRSurface.cpp @@ -232,6 +232,11 @@ uint32_t KRSurface::getHeight() const return m_swapChain->m_extent.height; } +Vector2i KRSurface::getDimensions() const +{ + return Vector2i::Create(static_cast(m_swapChain->m_extent.width), static_cast(m_swapChain->m_extent.height)); +} + VkFormat KRSurface::getDepthFormat() const { return m_swapChain->m_depthFormat; diff --git a/kraken/KRSurface.h b/kraken/KRSurface.h index d8c294c..23c90cc 100644 --- a/kraken/KRSurface.h +++ b/kraken/KRSurface.h @@ -50,6 +50,7 @@ public: void destroy(); uint32_t getWidth() const; uint32_t getHeight() const; + Vector2i getDimensions() const; VkFormat getDepthFormat() const; KRSurface(const KRSurface&) = delete;