Using KRPipelineManager::info struct to reduce number of parameters passed to KRPipelineManager::selectPipeline

This commit is contained in:
2022-04-05 21:58:47 -07:00
parent 9e0136f051
commit 858064fa4b
4 changed files with 25 additions and 35 deletions

View File

@@ -348,7 +348,16 @@ void KRLight::render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vec
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix(); occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
} }
if(getContext().getPipelineManager()->selectPipeline("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) { KRPipelineManager::PipelineInfo info{};
std::string shader_name("occlusion_test");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = renderPass;
if(getContext().getPipelineManager()->selectPipeline(info, viewport, occlusion_test_sphere_matrix, Vector3::Zero(), 0.0f, Vector4::Zero())) {
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery)); GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
#if TARGET_OS_IPHONE || defined(ANDROID) #if TARGET_OS_IPHONE || defined(ANDROID)

View File

@@ -279,36 +279,10 @@ KRPipeline *KRPipelineManager::getPipeline(const PipelineInfo &info) {
return pPipeline; return pPipeline;
} }
bool KRPipelineManager::selectPipeline(const std::string &pipeline_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const Matrix4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color) bool KRPipelineManager::selectPipeline(const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color)
{ {
PipelineInfo info{}; KRPipeline* pPipeline = getPipeline(info);
info.shader_name = &pipeline_name; return selectPipeline(*info.pCamera, pPipeline, viewport, matModel, *info.point_lights, *info.directional_lights, *info.spot_lights, info.bone_count, info.renderPass, rim_color, rim_power, fade_color);
info.pCamera = &camera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.bone_count = bone_count;
info.bDiffuseMap = bDiffuseMap;
info.bNormalMap = bNormalMap;
info.bSpecMap = bSpecMap;
info.bReflectionMap = bReflectionMap;
info.bReflectionCubeMap = bReflectionCubeMap;
info.bLightMap = bLightMap;
info.bDiffuseMapScale = bDiffuseMapScale;
info.bSpecMapScale = bSpecMapScale;
info.bNormalMapScale = bNormalMapScale;
info.bReflectionMapScale = bReflectionMapScale;
info.bDiffuseMapOffset = bDiffuseMapOffset;
info.bSpecMapOffset = bDiffuseMapOffset;
info.bNormalMapOffset = bNormalMapOffset;
info.bReflectionMapOffset = bReflectionMapOffset;
info.bAlphaTest = bAlphaTest;
info.bAlphaBlend = bAlphaBlend;
info.renderPass = renderPass;
info.bRimColor = rim_power != 0.0f;
KRPipeline *pPipeline = getPipeline(info);
return selectPipeline(camera, pPipeline, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power, fade_color);
} }
bool KRPipelineManager::selectPipeline(KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color) bool KRPipelineManager::selectPipeline(KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)

View File

@@ -85,9 +85,8 @@ public:
KRPipeline *getPipeline(KRSurface& surface, KRRenderPass& renderPass, const std::string& shader_name, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat); KRPipeline *getPipeline(KRSurface& surface, KRRenderPass& renderPass, const std::string& shader_name, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat);
KRPipeline* getPipeline(const PipelineInfo& info); KRPipeline* getPipeline(const PipelineInfo& info);
bool selectPipeline(KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color); bool selectPipeline(KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
bool selectPipeline(const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color);
bool selectPipeline(const std::string &pipeline_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const Matrix4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
size_t getPipelineHandlesUsed(); size_t getPipelineHandlesUsed();
KRPipeline *m_active_pipeline; KRPipeline *m_active_pipeline;

View File

@@ -296,8 +296,16 @@ void KRScene::render(VkCommandBuffer& commandBuffer, KROctreeNode *pOctreeNode,
// Disable z-buffer write // Disable z-buffer write
GLDEBUG(glDepthMask(GL_FALSE)); GLDEBUG(glDepthMask(GL_FALSE));
} }
KRPipelineManager::PipelineInfo info{};
if(getContext().getPipelineManager()->selectPipeline("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero())) { std::string shader_name("occlusion_test");
info.shader_name = &shader_name;
info.pCamera = pCamera;
info.point_lights = &point_lights;
info.directional_lights = &directional_lights;
info.spot_lights = &spot_lights;
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
if(getContext().getPipelineManager()->selectPipeline(info, viewport, matModel, Vector3::Zero(), 0.0f, Vector4::Zero())) {
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14)); GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14); m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
} }