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;
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
application.SendNotification();
application.Render(0); // Ensure animation starts
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "uColor", Vector4( 0.5f, 0.5f, 0.5f, 0.75f ) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>( "mixColor", testColor ), true, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
glEnableStack.Reset();
// GL_BLEND should not be changed: Keep enabled
// TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
// DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
TestMixColor( visual, Visual::Property::MIX_COLOR, TARGET_MIX_COLOR );
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str()) );
{
tet_infoline( "Test that the opacity can be increased to full via animation, and that the blend mode is set appropriately at the start and end of the animation." );
// TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
// DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
}
DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
DALI_TEST_EQUALS( color.a, 0.55f, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
glEnableStack.Reset();
DALI_TEST_EQUALS( color.a, 0.1f, TEST_LOCATION );
// GL_BLEND should not be changed: Keep enabled
- // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
-// DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+// @todo
+// TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
+// DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
}
END_TEST;
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
application.SendNotification();
application.Render(0); // Ensure animation starts
application.Render(2000u); // Halfway point through animation
application.SendNotification(); // Handle any signals
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
Vector4 color;
DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
DALI_TEST_EQUALS( color.a, 1.0f, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
END_TEST;
}
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ blendStr << std::hex << GL_BLEND;
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
END_TEST;
}
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
Renderer renderer = actor.GetRendererAt(0);
Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 0.0f, 0.001f, TEST_LOCATION );
// The Renderer is transparent. So rendering is skipped. The state should not be changed.
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
anim.Play();
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 0.5f, 0.001f, TEST_LOCATION );
// Should not be changed
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
glEnableStack.Reset();
DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector3 >( mixColorIndex ), Vector3(Color::MAGENTA), TEST_LOCATION );
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 1.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
END_TEST;
}
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
application.SendNotification();
application.Render(0);
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 1.0f, 0.001f, TEST_LOCATION );
// Default state is disabled. So test if "Enabled" is not called.
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
anim.Play();
DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector3 >( mixColorIndex ), Vector3(Color::MAGENTA), TEST_LOCATION);
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 0.5f, 0.001f, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
glEnableStack.Reset();
DALI_TEST_EQUALS( renderer.GetCurrentProperty< float >( DevelRenderer::Property::OPACITY ), 0.0f, 0.001f, TEST_LOCATION );
// GL_BLEND should not be changed: Keep enabled
- DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( !glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
END_TEST;
}
glAbstraction.EnableEnableDisableCallTrace( true );
TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ blendStr << std::hex << GL_BLEND;
application.SendNotification();
application.Render(0);
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, halfwayColor.a )), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(halfwayColor) ), true, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
glEnableStack.Reset();
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4( 1.0f, 1.0f, 1.0f, TARGET_MIX_COLOR.a ) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION );
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str().c_str() ) );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
actor.Unparent();
}