diff --git a/kraken/KRCamera.cpp b/kraken/KRCamera.cpp index 708ff1d..c0a15c7 100755 --- a/kraken/KRCamera.cpp +++ b/kraken/KRCamera.cpp @@ -229,7 +229,9 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; info.rasterMode = PipelineInfo::RasterMode::kAlphaBlend; - KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(compositeSurface, info, testVertices.getVertexAttributes(), KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP); + info.vertexAttributes = testVertices.getVertexAttributes(); + info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(compositeSurface, info); testPipeline->bind(commandBuffer); testVertices.bind(commandBuffer); vkCmdDraw(commandBuffer, 4, 1, 0, 0); diff --git a/kraken/KRPipeline.h b/kraken/KRPipeline.h index 4747b6b..d3e3dbf 100644 --- a/kraken/KRPipeline.h +++ b/kraken/KRPipeline.h @@ -196,6 +196,8 @@ public: bool bRimColor : 1; RasterMode rasterMode; CullMode cullMode; + uint32_t vertexAttributes; + KRMesh::model_format_t modelFormat; KRNode::RenderPass renderPass; }; diff --git a/kraken/KRPipelineManager.cpp b/kraken/KRPipelineManager.cpp index 46ee70d..2e49a60 100644 --- a/kraken/KRPipelineManager.cpp +++ b/kraken/KRPipelineManager.cpp @@ -63,7 +63,7 @@ KRPipelineManager::~KRPipelineManager() { #endif // ANDROID } -KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo& info, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat) +KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo& info) { std::pair > key; key.first = *info.shader_name; @@ -71,8 +71,8 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf key.second.push_back(surface.m_swapChain->m_imageFormat); key.second.push_back(surface.m_swapChain->m_extent.width); key.second.push_back(surface.m_swapChain->m_extent.height); - key.second.push_back(vertexAttributes); - key.second.push_back(modelFormat); + key.second.push_back(info.vertexAttributes); + key.second.push_back(info.modelFormat); // TODO - Add renderPass unique identifier to key PipelineMap::iterator itr = m_pipelines.find(key); if (itr != m_pipelines.end()) { @@ -82,13 +82,15 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf std::vector shaders; shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".vert", "spv")); shaders.push_back(m_pContext->getShaderManager()->get(*info.shader_name + ".frag", "spv")); - KRPipeline* pipeline = new KRPipeline(*m_pContext, surface, info, info.shader_name->c_str(), shaders, vertexAttributes, modelFormat); + KRPipeline* pipeline = new KRPipeline(*m_pContext, surface, info, info.shader_name->c_str(), shaders, info.vertexAttributes, info.modelFormat); m_pipelines[key] = pipeline; return pipeline; } +/* +// TODO - Vulkan Refactoring, merge with Vulkan version KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo &info) { int iShadowQuality = 0; // FINDME - HACK - Placeholder code, need to iterate through lights and dynamically build shader @@ -129,6 +131,8 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf key.second.push_back(info.pCamera->settings.bEnablePerPixel); key.second.push_back((int)info.rasterMode); key.second.push_back((int)info.cullMode); + key.second.push_back(info.vertexAttributes); + key.second.push_back((int)info.modelFormat); key.second.push_back(info.bAlphaTest); key.second.push_back(info.bDiffuseMap); key.second.push_back(info.bNormalMap); @@ -280,7 +284,7 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf Vector4 fade_color = info.pCamera->getFadeColor(); char szKey[256]; - sprintf(szKey, "%i_%i_%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f", (int)info.rasterMode, (int)info.cullMode, light_directional_count, light_point_count, light_spot_count, info.bone_count, info.pCamera->settings.fog_type, info.pCamera->settings.bEnablePerPixel, info.bAlphaTest, info.bDiffuseMap, info.bNormalMap, info.bSpecMap, info.bReflectionMap, info.bReflectionCubeMap, info.pCamera->settings.bDebugPSSM, iShadowQuality, info.pCamera->settings.bEnableAmbient, info.pCamera->settings.bEnableDiffuse, info.pCamera->settings.bEnableSpecular, info.bLightMap, info.bDiffuseMapScale, info.bSpecMapScale, info.bReflectionMapScale, info.bNormalMapScale, info.bDiffuseMapOffset, info.bSpecMapOffset, info.bReflectionMapOffset, info.bNormalMapOffset, info.pCamera->settings.volumetric_environment_enable && info.pCamera->settings.volumetric_environment_downsample != 0, info.renderPass, info.shader_name->c_str(), info.pCamera->settings.dof_quality, info.pCamera->settings.bEnableFlash, info.pCamera->settings.bEnableVignette, info.pCamera->settings.dof_depth, info.pCamera->settings.dof_falloff, info.pCamera->settings.flash_depth, info.pCamera->settings.flash_falloff, info.pCamera->settings.flash_intensity, info.pCamera->settings.vignette_radius, info.pCamera->settings.vignette_falloff, fade_color.x, fade_color.y, fade_color.z, fade_color.w); + sprintf(szKey, "%i_%i_%i_%i_%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f", (int)info.rasterMode, (int)info.cullMode, (int)info.modelFormat, (int)info.vertexAttributes, light_directional_count, light_point_count, light_spot_count, info.bone_count, info.pCamera->settings.fog_type, info.pCamera->settings.bEnablePerPixel, info.bAlphaTest, info.bDiffuseMap, info.bNormalMap, info.bSpecMap, info.bReflectionMap, info.bReflectionCubeMap, info.pCamera->settings.bDebugPSSM, iShadowQuality, info.pCamera->settings.bEnableAmbient, info.pCamera->settings.bEnableDiffuse, info.pCamera->settings.bEnableSpecular, info.bLightMap, info.bDiffuseMapScale, info.bSpecMapScale, info.bReflectionMapScale, info.bNormalMapScale, info.bDiffuseMapOffset, info.bSpecMapOffset, info.bReflectionMapOffset, info.bNormalMapOffset, info.pCamera->settings.volumetric_environment_enable && info.pCamera->settings.volumetric_environment_downsample != 0, info.renderPass, info.shader_name->c_str(), info.pCamera->settings.dof_quality, info.pCamera->settings.bEnableFlash, info.pCamera->settings.bEnableVignette, info.pCamera->settings.dof_depth, info.pCamera->settings.dof_falloff, info.pCamera->settings.flash_depth, info.pCamera->settings.flash_falloff, info.pCamera->settings.flash_intensity, info.pCamera->settings.vignette_radius, info.pCamera->settings.vignette_falloff, fade_color.x, fade_color.y, fade_color.z, fade_color.w); pPipeline = new KRPipeline(getContext(), szKey, options, vertSource->getData()->getString(), fragSource->getData()->getString()); @@ -288,6 +292,7 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf } return pPipeline; } +*/ bool KRPipelineManager::selectPipeline(KRSurface& surface, const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color) { diff --git a/kraken/KRPipelineManager.h b/kraken/KRPipelineManager.h index fcf3681..2ed5f4d 100644 --- a/kraken/KRPipelineManager.h +++ b/kraken/KRPipelineManager.h @@ -57,7 +57,6 @@ public: virtual ~KRPipelineManager(); KRPipeline* get(const char* szKey); - KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat); KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info); bool selectPipeline(KRSurface& surface, KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector *point_lights, const std::vector *directional_lights, const std::vector *spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color); bool selectPipeline(KRSurface& surface, const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color);