test(RHI): add rendering state tests for CommandList
- Add tests for SetPrimitiveTopology - Add tests for SetDepthStencilState - Add tests for SetBlendState - Add tests for SetBlendFactor - OpenGL tests now have 45 test cases
This commit is contained in:
@@ -130,3 +130,63 @@ TEST_F(OpenGLTestFixture, CommandList_EnableDisable_Blending) {
|
|||||||
glGetIntegerv(GL_BLEND, &blend);
|
glGetIntegerv(GL_BLEND, &blend);
|
||||||
EXPECT_EQ(blend, 0);
|
EXPECT_EQ(blend, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(OpenGLTestFixture, CommandList_SetPrimitiveTopology) {
|
||||||
|
OpenGLCommandList cmdList;
|
||||||
|
|
||||||
|
cmdList.SetPrimitiveTopology(PrimitiveTopology::TriangleList);
|
||||||
|
GLenum error = glGetError();
|
||||||
|
EXPECT_EQ(error, GL_NO_ERROR);
|
||||||
|
|
||||||
|
cmdList.SetPrimitiveTopology(PrimitiveTopology::LineList);
|
||||||
|
error = glGetError();
|
||||||
|
EXPECT_EQ(error, GL_NO_ERROR);
|
||||||
|
|
||||||
|
cmdList.SetPrimitiveTopology(PrimitiveTopology::PointList);
|
||||||
|
error = glGetError();
|
||||||
|
EXPECT_EQ(error, GL_NO_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(OpenGLTestFixture, CommandList_SetDepthStencilState) {
|
||||||
|
OpenGLCommandList cmdList;
|
||||||
|
|
||||||
|
DepthStencilState state;
|
||||||
|
state.depthEnable = true;
|
||||||
|
state.depthWriteMask = true;
|
||||||
|
state.depthFunc = ComparisonFunc::Less;
|
||||||
|
|
||||||
|
cmdList.SetDepthStencilState(state);
|
||||||
|
|
||||||
|
GLint depthTest = 0;
|
||||||
|
glGetIntegerv(GL_DEPTH_TEST, &depthTest);
|
||||||
|
EXPECT_EQ(depthTest, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(OpenGLTestFixture, CommandList_SetBlendState) {
|
||||||
|
OpenGLCommandList cmdList;
|
||||||
|
|
||||||
|
BlendState state;
|
||||||
|
state.renderTargets[0].blendEnable = true;
|
||||||
|
state.renderTargets[0].srcBlend = BlendFactor::SrcAlpha;
|
||||||
|
state.renderTargets[0].dstBlend = BlendFactor::InvSrcAlpha;
|
||||||
|
|
||||||
|
cmdList.SetBlendState(state);
|
||||||
|
|
||||||
|
GLint blend = 0;
|
||||||
|
glGetIntegerv(GL_BLEND, &blend);
|
||||||
|
EXPECT_EQ(blend, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(OpenGLTestFixture, CommandList_SetBlendFactor) {
|
||||||
|
OpenGLCommandList cmdList;
|
||||||
|
|
||||||
|
float factor[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||||
|
cmdList.SetBlendFactor(factor);
|
||||||
|
|
||||||
|
GLfloat color[4] = {};
|
||||||
|
glGetFloatv(GL_BLEND_COLOR, color);
|
||||||
|
EXPECT_FLOAT_EQ(color[0], 0.5f);
|
||||||
|
EXPECT_FLOAT_EQ(color[1], 0.5f);
|
||||||
|
EXPECT_FLOAT_EQ(color[2], 0.5f);
|
||||||
|
EXPECT_FLOAT_EQ(color[3], 1.0f);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user