inline void CullFace(GLenum mode) override
{
std::stringstream out;
- out << mode;
+ out << std::hex << mode;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] << mode;
+ namedParams["mode"] << std::hex << mode;
mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
}
inline void DepthFunc(GLenum func) override
{
std::stringstream out;
- out << func;
+ out << std::hex << func;
TraceCallStack::NamedParams namedParams;
namedParams["func"] << std::hex << func;
inline void Disable(GLenum cap) override
{
std::stringstream out;
- out << cap;
+ out << std::hex << cap;
TraceCallStack::NamedParams namedParams;
namedParams["cap"] << std::hex << cap;
mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
inline void Enable(GLenum cap) override
{
std::stringstream out;
- out << cap;
+ out << std::hex << cap;
TraceCallStack::NamedParams namedParams;
namedParams["cap"] << std::hex << cap;
mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
inline void FrontFace(GLenum mode) override
{
+ // do nothing
}
inline void GenBuffers(GLsizei n, GLuint* buffers) override
return GL_TRIANGLES;
}
+GLenum GetCullFace(Graphics::CullMode cullMode)
+{
+ switch(cullMode)
+ {
+ case Graphics::CullMode::NONE:
+ return GL_NONE;
+ case Graphics::CullMode::FRONT:
+ return GL_FRONT;
+ case Graphics::CullMode::BACK:
+ return GL_BACK;
+ case Graphics::CullMode::FRONT_AND_BACK:
+ return GL_FRONT_AND_BACK;
+ }
+ return GL_NONE;
+}
+
+GLenum GetFrontFace(Graphics::FrontFace frontFace)
+{
+ if(frontFace == Graphics::FrontFace::CLOCKWISE)
+ {
+ return GL_CW;
+ }
+ return GL_CCW;
+}
+
+GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
+{
+ GLenum glFactor = GL_ZERO;
+
+ switch(blendFactor)
+ {
+ case Graphics::BlendFactor::ZERO:
+ glFactor = GL_ZERO;
+ break;
+ case Graphics::BlendFactor::ONE:
+ glFactor = GL_ONE;
+ break;
+ case Graphics::BlendFactor::SRC_COLOR:
+ glFactor = GL_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
+ glFactor = GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::DST_COLOR:
+ glFactor = GL_DST_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
+ glFactor = GL_ONE_MINUS_DST_COLOR;
+ break;
+ case Graphics::BlendFactor::SRC_ALPHA:
+ glFactor = GL_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
+ glFactor = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::DST_ALPHA:
+ glFactor = GL_DST_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
+ glFactor = GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case Graphics::BlendFactor::CONSTANT_COLOR:
+ glFactor = GL_CONSTANT_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
+ glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
+ break;
+ case Graphics::BlendFactor::CONSTANT_ALPHA:
+ glFactor = GL_CONSTANT_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
+ glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
+ break;
+ case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
+ glFactor = GL_SRC_ALPHA_SATURATE;
+ break;
+ // GLES doesn't appear to have dual source blending.
+ case Graphics::BlendFactor::SRC1_COLOR:
+ glFactor = GL_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
+ glFactor = GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::SRC1_ALPHA:
+ glFactor = GL_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
+ glFactor = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ }
+ return glFactor;
+}
+
+GLenum GetBlendOp(Graphics::BlendOp blendOp)
+{
+ GLenum op = GL_FUNC_ADD;
+ switch(blendOp)
+ {
+ case Graphics::BlendOp::ADD:
+ op = GL_FUNC_ADD;
+ break;
+ case Graphics::BlendOp::SUBTRACT:
+ op = GL_FUNC_SUBTRACT;
+ break;
+ case Graphics::BlendOp::REVERSE_SUBTRACT:
+ op = GL_FUNC_REVERSE_SUBTRACT;
+ break;
+ case Graphics::BlendOp::MIN:
+ op = GL_MIN;
+ break;
+ case Graphics::BlendOp::MAX:
+ op = GL_MAX;
+ break;
+
+ // @todo Add advanced blend equations
+ }
+ return op;
+}
+
void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
{
TraceCallStack::NamedParams namedParams;
reinterpret_cast<void*>(attributeOffset));
}
+ // Cull face setup
+ auto& rasterizationState = commandBuffer->mPipeline->rasterizationState;
+ if(rasterizationState.cullMode == Graphics::CullMode::NONE)
+ {
+ mGl.Disable(GL_CULL_FACE);
+ }
+ else
+ {
+ mGl.Enable(GL_CULL_FACE);
+ mGl.CullFace(GetCullFace(rasterizationState.cullMode));
+ }
+
+ mGl.FrontFace(GetFrontFace(rasterizationState.frontFace));
+ // We don't modify glPolygonMode in our context/abstraction from GL_FILL (the GL default),
+ // so it isn't present in the API (and won't have any tests!)
+
+ // Blending setup
+ auto& colorBlendState = commandBuffer->mPipeline->colorBlendState;
+ if(colorBlendState.blendEnable)
+ {
+ mGl.Enable(GL_BLEND);
+
+ mGl.BlendFuncSeparate(GetBlendFactor(colorBlendState.srcColorBlendFactor),
+ GetBlendFactor(colorBlendState.dstColorBlendFactor),
+ GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
+ GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
+ if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
+ {
+ mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
+ }
+ else
+ {
+ mGl.BlendEquation(GetBlendOp(colorBlendState.colorBlendOp));
+ }
+ mGl.BlendColor(colorBlendState.blendConstants[0],
+ colorBlendState.blendConstants[1],
+ colorBlendState.blendConstants[2],
+ colorBlendState.blendConstants[3]);
+ }
+ else
+ {
+ mGl.Disable(GL_BLEND);
+ }
+
// draw call
auto topology = commandBuffer->mPipeline->inputAssemblyState.topology;
CheckColorMask(glAbstraction, true);
// Check the stencil buffer was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+ std::ostringstream oss;
+ oss << std::hex << GL_STENCIL_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
// Check the stencil buffer was cleared.
DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
CheckColorMask(glAbstraction, true);
// Check the stencil buffer was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+ std::ostringstream oss;
+ oss << std::hex << GL_STENCIL_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
// Check the stencil buffer was cleared.
DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
GenerateTrace(application, enabledDisableTrace, stencilTrace);
// Check the stencil buffer was disabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
+ std::ostringstream stencil;
+ stencil << std::hex << GL_STENCIL_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
// Ensure all values in stencil-mask are set to 1.
startIndex = 0u;
CheckColorMask(glAbstraction, true);
// Check the stencil buffer was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+ std::ostringstream oss;
+ oss << std::hex << GL_STENCIL_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
// Perform the test twice, once for 2D layer, and once for 3D.
for(unsigned int i = 0u; i < 2u; ++i)
Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
*/
- size_t startIndex = 0u;
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
+ size_t startIndex = 0u;
+ std::ostringstream blend;
+ blend << std::hex << GL_BLEND;
+ std::ostringstream stencil;
+ stencil << std::hex << GL_STENCIL_TEST;
+
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
// Swap the clipping actor from top of left branch to top of right branch.
actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
// Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
// This proves the draw order has remained the same.
startIndex = 0u;
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
- DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
+ DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
END_TEST;
}
CheckColorMask(glAbstraction, true);
// Check scissor test was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
std::stringstream compareParametersString;
CheckColorMask(glAbstraction, true);
// Check scissor test was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
std::stringstream compareParametersString;
CheckColorMask(glAbstraction, true);
// Check scissor test was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
const Vector4& expectResults(expect[test]);
CheckColorMask(glAbstraction, true);
// Check scissor test was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
std::string clipA("0, 500, 480, 200");
CheckColorMask(glAbstraction, true);
// Check the stencil buffer was not enabled.
- DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+ std::ostringstream stencil;
+ stencil << std::hex << GL_STENCIL_TEST;
+ DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
// Check stencil functions are not called.
DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
GenerateTrace(application, enabledDisableTrace, scissorTrace);
// Check the stencil buffer was not enabled.
- DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
application.Render();
enabledDisableTrace.Enable(false);
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2929")); // 2929 is GL_DEPTH_TEST
+ std::ostringstream depth;
+ depth << std::hex << GL_DEPTH_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", depth.str()));
END_TEST;
}
application.SendNotification();
application.Render();
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
Vector4 expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
application.SendNotification();
application.Render();
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
Vector4 expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
std::string GetStencilTestString(void)
{
std::stringstream stream;
- stream << GL_STENCIL_TEST;
+ stream << std::hex << GL_STENCIL_TEST;
return stream.str();
}
std::string GetDepthTestString(void)
{
std::stringstream stream;
- stream << GL_DEPTH_TEST;
+ stream << std::hex << GL_DEPTH_TEST;
return stream.str();
}
DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
std::ostringstream cullModeString;
- cullModeString << GL_FRONT_AND_BACK;
+ cullModeString << std::hex << GL_FRONT_AND_BACK;
DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
std::ostringstream cullModeString;
- cullModeString << GL_BACK;
+ cullModeString << std::hex << GL_BACK;
DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
std::ostringstream cullModeString;
- cullModeString << GL_FRONT;
+ cullModeString << std::hex << GL_FRONT;
DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable"));
DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", "GL_BLEND"));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
END_TEST;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
}
END_TEST;
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack::NamedParams params;
+ params["cap"] << std::hex << GL_BLEND;
+ DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
}
END_TEST;
scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
scene.Add(actor);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableDepthFunctionCallTrace(true);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glDepthFunctionStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glDepthFunctionStack.EnableLogging(true);
std::ostringstream depthTestStr;
- depthTestStr << GL_DEPTH_TEST;
+ depthTestStr << std::hex << GL_DEPTH_TEST;
//GL_NEVER
{
DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", depthTestStr.str().c_str()));
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_NEVER;
+ depthFunctionStr << std::hex << GL_NEVER;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_ALWAYS;
+ depthFunctionStr << std::hex << GL_ALWAYS;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_LESS;
+ depthFunctionStr << std::hex << GL_LESS;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_GREATER;
+ depthFunctionStr << std::hex << GL_GREATER;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_EQUAL;
+ depthFunctionStr << std::hex << GL_EQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_NOTEQUAL;
+ depthFunctionStr << std::hex << GL_NOTEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_LEQUAL;
+ depthFunctionStr << std::hex << GL_LEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_GEQUAL;
+ depthFunctionStr << std::hex << GL_GEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
TestApplication application;
tet_infoline("Test setting the DepthTestMode");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
glEnableDisableStack.Reset();
application.SendNotification();
TestApplication application;
tet_infoline("Test the stencil defaults");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glStencilFunctionStack.Enable(true);
+ glStencilFunctionStack.EnableLogging(true);
ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
TestApplication application;
tet_infoline("Test setting the RenderMode to use the stencil buffer");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glStencilFunctionStack.Enable(true);
+ glStencilFunctionStack.EnableLogging(true);
// Set the StencilFunction to something other than the default, to confirm it is set as a property,
// but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
TestApplication application;
tet_infoline("Test setting the StencilFunction");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glStencilFunctionStack.Enable(true);
+ glStencilFunctionStack.EnableLogging(true);
// RenderMode must use the stencil for StencilFunction to operate.
renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
TestApplication application;
tet_infoline("Test setting the StencilOperation");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glStencilFunctionStack.Enable(true);
+ glStencilFunctionStack.EnableLogging(true);
// RenderMode must use the stencil for StencilOperation to operate.
renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
TestApplication application;
tet_infoline("Test setting the StencilMask");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Renderer renderer = RendererTestFixture(application);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glStencilFunctionStack.Enable(true);
+ glStencilFunctionStack.EnableLogging(true);
// RenderMode must use the stencil for StencilMask to operate.
renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
TraceCallStack& drawTrace = gl.GetDrawTrace();
drawTrace.Reset();
drawTrace.Enable(true);
+ drawTrace.EnableLogging(true);
application.SendNotification();
application.Render(0);
application.Render();
// Check scissor test was enabled.
- DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+ std::ostringstream scissor;
+ scissor << std::hex << GL_SCISSOR_TEST;
+ DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
// Check the scissor was set, and the coordinates are correct.
DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", "0, 700, 100, 100"));
#include <dali/internal/render/renderers/render-renderer.h>
// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-types.h>
#include <dali/internal/common/image-sampler.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
return type;
}
+constexpr Graphics::CullMode ConvertCullFace(Dali::FaceCullingMode::Type mode)
+{
+ switch(mode)
+ {
+ case Dali::FaceCullingMode::NONE:
+ {
+ return Graphics::CullMode::NONE;
+ }
+ case Dali::FaceCullingMode::FRONT:
+ {
+ return Graphics::CullMode::FRONT;
+ }
+ case Dali::FaceCullingMode::BACK:
+ {
+ return Graphics::CullMode::BACK;
+ }
+ case Dali::FaceCullingMode::FRONT_AND_BACK:
+ {
+ return Graphics::CullMode::FRONT_AND_BACK;
+ }
+ }
+ return Graphics::CullMode::NONE;
+}
+
+constexpr Graphics::BlendFactor ConvertBlendFactor(BlendFactor::Type blendFactor)
+{
+ switch(blendFactor)
+ {
+ case BlendFactor::ZERO:
+ return Graphics::BlendFactor::ZERO;
+ case BlendFactor::ONE:
+ return Graphics::BlendFactor::ONE;
+ case BlendFactor::SRC_COLOR:
+ return Graphics::BlendFactor::SRC_COLOR;
+ case BlendFactor::ONE_MINUS_SRC_COLOR:
+ return Graphics::BlendFactor::ONE_MINUS_SRC_COLOR;
+ case BlendFactor::SRC_ALPHA:
+ return Graphics::BlendFactor::SRC_ALPHA;
+ case BlendFactor::ONE_MINUS_SRC_ALPHA:
+ return Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA;
+ case BlendFactor::DST_ALPHA:
+ return Graphics::BlendFactor::DST_ALPHA;
+ case BlendFactor::ONE_MINUS_DST_ALPHA:
+ return Graphics::BlendFactor::ONE_MINUS_DST_ALPHA;
+ case BlendFactor::DST_COLOR:
+ return Graphics::BlendFactor::DST_COLOR;
+ case BlendFactor::ONE_MINUS_DST_COLOR:
+ return Graphics::BlendFactor::ONE_MINUS_DST_COLOR;
+ case BlendFactor::SRC_ALPHA_SATURATE:
+ return Graphics::BlendFactor::SRC_ALPHA_SATURATE;
+ case BlendFactor::CONSTANT_COLOR:
+ return Graphics::BlendFactor::CONSTANT_COLOR;
+ case BlendFactor::ONE_MINUS_CONSTANT_COLOR:
+ return Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR;
+ case BlendFactor::CONSTANT_ALPHA:
+ return Graphics::BlendFactor::CONSTANT_ALPHA;
+ case BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
+ return Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA;
+ }
+ return Graphics::BlendFactor{};
+}
+
+constexpr Graphics::BlendOp ConvertBlendEquation(DevelBlendEquation::Type blendEquation)
+{
+ switch(blendEquation)
+ {
+ case DevelBlendEquation::ADD:
+ return Graphics::BlendOp::ADD;
+ case DevelBlendEquation::SUBTRACT:
+ return Graphics::BlendOp::SUBTRACT;
+ case DevelBlendEquation::REVERSE_SUBTRACT:
+ return Graphics::BlendOp::REVERSE_SUBTRACT;
+ case DevelBlendEquation::COLOR:
+ case DevelBlendEquation::COLOR_BURN:
+ case DevelBlendEquation::COLOR_DODGE:
+ case DevelBlendEquation::DARKEN:
+ case DevelBlendEquation::DIFFERENCE:
+ case DevelBlendEquation::EXCLUSION:
+ case DevelBlendEquation::HARD_LIGHT:
+ case DevelBlendEquation::HUE:
+ case DevelBlendEquation::LIGHTEN:
+ case DevelBlendEquation::LUMINOSITY:
+ case DevelBlendEquation::MAX:
+ case DevelBlendEquation::MIN:
+ case DevelBlendEquation::MULTIPLY:
+ case DevelBlendEquation::OVERLAY:
+ case DevelBlendEquation::SATURATION:
+ case DevelBlendEquation::SCREEN:
+ case DevelBlendEquation::SOFT_LIGHT:
+ return Graphics::BlendOp{};
+ }
+ return Graphics::BlendOp{};
+}
+
} // namespace
namespace Render
mDrawCommands.insert(mDrawCommands.end(), pDrawCommands, pDrawCommands + size);
}
-void Renderer::SetBlending(Context& context, bool blend)
-{
- context.SetBlend(blend);
- if(blend)
- {
- // Blend color is optional and rarely used
- const Vector4* blendColor = mBlendingOptions.GetBlendColor();
- if(blendColor)
- {
- context.SetCustomBlendColor(*blendColor);
- }
- else
- {
- context.SetDefaultBlendColor();
- }
-
- // Set blend source & destination factors
- context.BlendFuncSeparate(mBlendingOptions.GetBlendSrcFactorRgb(),
- mBlendingOptions.GetBlendDestFactorRgb(),
- mBlendingOptions.GetBlendSrcFactorAlpha(),
- mBlendingOptions.GetBlendDestFactorAlpha());
-
- // Set blend equations
- Dali::DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
- Dali::DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
-
- if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
- {
- if(rgbEquation != alphaEquation)
- {
- DALI_LOG_ERROR("Advanced Blend Equation have to be appried by using BlendEquation.\n");
- }
- context.BlendEquation(rgbEquation);
- }
- else
- {
- context.BlendEquationSeparate(rgbEquation, alphaEquation);
- }
- }
-
- mUpdated = true;
-}
-
void Renderer::GlContextDestroyed()
{
mGeometry->GlContextDestroyed();
}
}
-bool Renderer::BindTextures(Context& context, Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)
+bool Renderer::BindTextures(Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)
{
uint32_t textureUnit = 0;
bool result = true;
.SetLevel(Graphics::CommandBufferLevel::SECONDARY),
nullptr);
- //Set cull face mode
- const Dali::Internal::SceneGraph::Camera* cam = instruction.GetCamera();
- if(cam->GetReflectionUsed())
- {
- auto adjFaceCullingMode = mFaceCullingMode;
- switch(mFaceCullingMode)
- {
- case FaceCullingMode::Type::FRONT:
- {
- adjFaceCullingMode = FaceCullingMode::Type::BACK;
- break;
- }
- case FaceCullingMode::Type::BACK:
- {
- adjFaceCullingMode = FaceCullingMode::Type::FRONT;
- break;
- }
- default:
- {
- // nothing to do, leave culling as it is
- }
- }
- context.CullFace(adjFaceCullingMode);
- }
- else
+ //Set blending mode
+ if(!mDrawCommands.empty())
{
- context.CullFace(mFaceCullingMode);
+ blend = (commands[0]->queue == DevelRenderer::RENDER_QUEUE_OPAQUE ? false : blend);
}
// Temporarily create a pipeline here - this will be used for transporting
- // topology and vertex format for now.
- Graphics::UniquePtr<Graphics::Pipeline> pipeline = PrepareGraphicsPipeline(*program);
+ // topology, vertex format, attrs, rasterization state
+ Graphics::UniquePtr<Graphics::Pipeline> pipeline = PrepareGraphicsPipeline(*program, instruction, blend);
commandBuffer->BindPipeline(*pipeline.get());
- // Take the program into use so we can send uniforms to it
- program->Use();
-
- if(DALI_LIKELY(BindTextures(context, *program, *commandBuffer.get(), boundTextures)))
+ if(DALI_LIKELY(BindTextures(*program, *commandBuffer.get(), boundTextures)))
{
// Only set up and draw if we have textures and they are all valid
SetUniforms(bufferIndex, node, size, *program);
- if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
- {
- context.BlendBarrier();
- }
-
bool drawn = false; // Draw can fail if there are no vertex buffers or they haven't been uploaded yet
// @todo We should detect this case much earlier to prevent unnecessary work
//@todo manage mDrawCommands in the same way as above command buffer?!
if(mDrawCommands.empty())
{
- SetBlending(context, blend);
-
drawn = mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), mIndexedDrawFirstElement, mIndexedDrawElementsCount);
}
else
{
for(auto& cmd : commands)
{
- if(cmd->queue == queueIndex)
- {
- //Set blending mode
- SetBlending(context, cmd->queue == DevelRenderer::RENDER_QUEUE_OPAQUE ? false : blend);
-
- // @todo This should generate a command buffer per cmd
- // Tests WILL fail.
- mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), cmd->firstIndex, cmd->elementCount);
- }
+ // @todo This should generate a command buffer per cmd
+ // Tests WILL fail. (Temporarily commented out)
+ mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), cmd->firstIndex, cmd->elementCount);
}
}
return false;
}
-Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(Program& program)
+Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(
+ Program& program,
+ const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+ bool blend)
{
Graphics::InputAssemblyState inputAssemblyState{};
Graphics::VertexInputState vertexInputState{};
mUpdateAttributeLocations = true;
}
+ /**
+ * Bind Attributes
+ */
uint32_t base = 0;
for(auto&& vertexBuffer : mGeometry->GetVertexBuffers())
{
// Get the topology
inputAssemblyState.SetTopology(mGeometry->GetTopology());
+ Graphics::RasterizationState rasterizationState{};
+
+ //Set cull face mode
+ const Dali::Internal::SceneGraph::Camera* cam = instruction.GetCamera();
+ if(cam->GetReflectionUsed())
+ {
+ auto adjFaceCullingMode = mFaceCullingMode;
+ switch(mFaceCullingMode)
+ {
+ case FaceCullingMode::Type::FRONT:
+ {
+ adjFaceCullingMode = FaceCullingMode::Type::BACK;
+ break;
+ }
+ case FaceCullingMode::Type::BACK:
+ {
+ adjFaceCullingMode = FaceCullingMode::Type::FRONT;
+ break;
+ }
+ default:
+ {
+ // nothing to do, leave culling as it is
+ }
+ }
+ rasterizationState.SetCullMode(ConvertCullFace(adjFaceCullingMode));
+ }
+ else
+ {
+ rasterizationState.SetCullMode(ConvertCullFace(mFaceCullingMode));
+ }
+
+ rasterizationState.SetFrontFace(Graphics::FrontFace::COUNTER_CLOCKWISE);
+
+ /**
+ * 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());
+ }
+ }
+
+ // Take the program into use so we can send uniforms to it
+ // @todo Remove this call entirely!
+ program.Use();
+
+ mUpdated = true;
+
// Create a new pipeline
return mGraphicsController->CreatePipeline(
Graphics::PipelineCreateInfo()
.SetInputAssemblyState(&inputAssemblyState) // Passed as pointers - shallow copy will break. TOO C LIKE
- .SetVertexInputState(&vertexInputState),
+ .SetVertexInputState(&vertexInputState)
+ .SetRasterizationState(&rasterizationState)
+ .SetColorBlendState(&colorBlendState),
nullptr);
}
* @param[in] boundTextures The textures bound for rendering
* @return False if create or bind failed, true if success.
*/
- bool BindTextures(Context& context, Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures);
+ bool BindTextures(Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures);
/**
* Prepare a pipeline for this renderer
*/
- Graphics::UniquePtr<Graphics::Pipeline> PrepareGraphicsPipeline(Program& program);
+ Graphics::UniquePtr<Graphics::Pipeline> PrepareGraphicsPipeline(
+ Program& program,
+ const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+ bool blend);
private:
Graphics::Controller* mGraphicsController;
{
class ConnectionObserver;
class SceneController;
+
/**
* A holder class for Program; also enables sharing of uniform properties
*/