- /**
- * Set Polygon mode
- */
- switch(mGeometry->GetTopology())
- {
- case Graphics::PrimitiveTopology::TRIANGLE_LIST:
- case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
- case Graphics::PrimitiveTopology::TRIANGLE_FAN:
- rasterizationState.SetPolygonMode(Graphics::PolygonMode::FILL);
- break;
- case Graphics::PrimitiveTopology::LINE_LIST:
- case Graphics::PrimitiveTopology::LINE_LOOP:
- case Graphics::PrimitiveTopology::LINE_STRIP:
- rasterizationState.SetPolygonMode(Graphics::PolygonMode::LINE);
- break;
- case Graphics::PrimitiveTopology::POINT_LIST:
- rasterizationState.SetPolygonMode(Graphics::PolygonMode::POINT);
- break;
- }
-
- // @todo How to signal a blend barrier is needed?
- //if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
- //{
- // context.BlendBarrier();
- //}
-
- Graphics::ColorBlendState colorBlendState{};
- colorBlendState.SetBlendEnable(false);
-
- if(blend)
- {
- colorBlendState.SetBlendEnable(true);
-
- Graphics::BlendOp rgbOp = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
- Graphics::BlendOp alphaOp = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
- if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
- {
- if(rgbOp != alphaOp)
- {
- DALI_LOG_ERROR("Advanced Blend Equation MUST be applied by using BlendEquation.\n");
- alphaOp = rgbOp;
- }
- }
-
- colorBlendState
- .SetSrcColorBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendSrcFactorRgb()))
- .SetSrcAlphaBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendSrcFactorAlpha()))
- .SetDstColorBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendDestFactorRgb()))
- .SetDstAlphaBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendDestFactorAlpha()))
- .SetColorBlendOp(rgbOp)
- .SetAlphaBlendOp(alphaOp);
-
- // Blend color is optional and rarely used
- Vector4* blendColor = const_cast<Vector4*>(mBlendingOptions.GetBlendColor());
- if(blendColor)
- {
- colorBlendState.SetBlendConstants(blendColor->AsFloat());
- }
- }
-
- mUpdated = true;
-
- // Create the pipeline
- Graphics::PipelineCreateInfo createInfo;
- createInfo
- .SetInputAssemblyState(&inputAssemblyState)
- .SetVertexInputState(&vertexInputState)
- .SetRasterizationState(&rasterizationState)
- .SetColorBlendState(&colorBlendState)
- .SetProgramState(&programState)
- .SetNextExtension(&mLegacyProgram);
-
- // Store a pipeline per renderer per render (renderer can be owned by multiple nodes,
- // and re-drawn in multiple instructions).
- // @todo This is only needed because ColorBlend state can change. Fixme!
- // This is ameliorated by the fact that implementation caches pipelines, and we're only storing
- // handles.
- auto hash = HashedPipeline::GetHash(&node, &instruction, blend);
- HashedPipeline* hashedPipeline = nullptr;
- for(auto& element : mGraphicsPipelines)
- {
- if(element.mHash == hash)
- {
- hashedPipeline = &element;
- break;
- }
- }
-
- if(hashedPipeline != nullptr)
- {
- hashedPipeline->mGraphicsPipeline = mGraphicsController->CreatePipeline(
- createInfo,
- std::move(hashedPipeline->mGraphicsPipeline));
- }
- else
- {
- mGraphicsPipelines.emplace_back();
- mGraphicsPipelines.back().mHash = hash;
- mGraphicsPipelines.back().mGraphicsPipeline = mGraphicsController->CreatePipeline(createInfo, nullptr);
- hashedPipeline = &mGraphicsPipelines.back();
- }
- return *hashedPipeline->mGraphicsPipeline.get();