summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-12-07 05:28:17 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-12-07 05:28:17 +0000
commit2c5fc65a2e17abbaa384df66fa26a1d59e91c2cd (patch)
tree685c0c1e436e74f794fab57b84da6a90d593c1d8
parentAdded Rasterizer state test (diff)
downloadDiligentCore-2c5fc65a2e17abbaa384df66fa26a1d59e91c2cd.tar.gz
DiligentCore-2c5fc65a2e17abbaa384df66fa26a1d59e91c2cd.zip
Added depth-stencil state test
-rw-r--r--Graphics/GraphicsAccessories/interface/GraphicsAccessories.h19
-rw-r--r--Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp61
-rw-r--r--UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp152
-rw-r--r--UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp110
-rw-r--r--UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp2
-rw-r--r--UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp5
-rw-r--r--UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp45
7 files changed, 315 insertions, 79 deletions
diff --git a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h
index a0011231..08c42da1 100644
--- a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h
+++ b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h
@@ -278,6 +278,13 @@ const Char* GetTextureAddressModeLiteralName(TEXTURE_ADDRESS_MODE AddressMode, b
const Char* GetComparisonFunctionLiteralName(COMPARISON_FUNCTION ComparisonFunc, bool bGetFullName);
+/// Returns the literal name of a stencil operation.
+
+/// \param [in] StencilOp - Stencil operation, see Diligent::STENCIL_OP.
+/// \return Literal name of the stencil operation.
+const Char* GetStencilOpLiteralName(STENCIL_OP StencilOp);
+
+
/// Returns the literal name of a blend factor.
/// \param [in] BlendFactor - Blend factor, see Diligent::BLEND_FACTOR.
@@ -292,6 +299,18 @@ const Char* GetBlendFactorLiteralName(BLEND_FACTOR BlendFactor);
const Char* GetBlendOperationLiteralName(BLEND_OPERATION BlendOp);
+/// Returns the literal name of a fill mode.
+
+/// \param [in] FillMode - Fill mode, see Diligent::FILL_MODE.
+/// \return Literal name of the fill mode.
+const Char* GetFillModeLiteralName(FILL_MODE FillMode);
+
+/// Returns the literal name of a cull mode.
+
+/// \param [in] CullMode - Cull mode, see Diligent::CULL_MODE.
+/// \return Literal name of the cull mode.
+const Char* GetCullModeLiteralName(CULL_MODE CullMode);
+
/// Returns the string containing the map type
const Char* GetMapTypeString(MAP_TYPE MapType);
diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
index fe954b81..2047c561 100644
--- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
+++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
@@ -618,6 +618,30 @@ const Char* GetComparisonFunctionLiteralName(COMPARISON_FUNCTION ComparisonFunc,
}
}
+const Char* GetStencilOpLiteralName(STENCIL_OP StencilOp)
+{
+#define STENCIL_OP_TO_STR(Op) \
+ case Op: return #Op
+
+ switch (StencilOp)
+ {
+ STENCIL_OP_TO_STR(STENCIL_OP_UNDEFINED);
+ STENCIL_OP_TO_STR(STENCIL_OP_KEEP);
+ STENCIL_OP_TO_STR(STENCIL_OP_ZERO);
+ STENCIL_OP_TO_STR(STENCIL_OP_REPLACE);
+ STENCIL_OP_TO_STR(STENCIL_OP_INCR_SAT);
+ STENCIL_OP_TO_STR(STENCIL_OP_DECR_SAT);
+ STENCIL_OP_TO_STR(STENCIL_OP_INVERT);
+ STENCIL_OP_TO_STR(STENCIL_OP_INCR_WRAP);
+ STENCIL_OP_TO_STR(STENCIL_OP_DECR_WRAP);
+
+ default:
+ UNEXPECTED("Unexepcted stencil operation (", static_cast<Uint32>(StencilOp), ")");
+ return "UNKNOWN";
+ }
+#undef STENCIL_OP_TO_STR
+}
+
const Char* GetBlendFactorLiteralName(BLEND_FACTOR BlendFactor)
{
#define BLEND_FACTOR_TO_STR(Factor) \
@@ -672,6 +696,43 @@ const Char* GetBlendOperationLiteralName(BLEND_OPERATION BlendOp)
#undef BLEND_OP_TO_STR
}
+const Char* GetFillModeLiteralName(FILL_MODE FillMode)
+{
+#define FILL_MODE_TO_STR(Mode) \
+ case Mode: return #Mode
+
+ switch (FillMode)
+ {
+ FILL_MODE_TO_STR(FILL_MODE_UNDEFINED);
+ FILL_MODE_TO_STR(FILL_MODE_WIREFRAME);
+ FILL_MODE_TO_STR(FILL_MODE_SOLID);
+
+ default:
+ UNEXPECTED("Unexepcted fill mode (", static_cast<int>(FillMode), ")");
+ return "UNKNOWN";
+ }
+#undef FILL_MODE_TO_STR
+}
+
+const Char* GetCullModeLiteralName(CULL_MODE CullMode)
+{
+#define CULL_MODE_TO_STR(Mode) \
+ case Mode: return #Mode
+
+ switch (CullMode)
+ {
+ CULL_MODE_TO_STR(CULL_MODE_UNDEFINED);
+ CULL_MODE_TO_STR(CULL_MODE_NONE);
+ CULL_MODE_TO_STR(CULL_MODE_FRONT);
+ CULL_MODE_TO_STR(CULL_MODE_BACK);
+
+ default:
+ UNEXPECTED("Unexepcted cull mode (", static_cast<int>(CullMode), ")");
+ return "UNKNOWN";
+ }
+#undef CULL_MODE_TO_STR
+}
+
const Char* GetMapTypeString(MAP_TYPE MapType)
{
switch (MapType)
diff --git a/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp
index 2c7c0d4a..b033b136 100644
--- a/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp
+++ b/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp
@@ -109,7 +109,9 @@ protected:
RefCntAutoPtr<IPipelineState> pPSO;
pDevice->CreatePipelineState(PSODesc, &pPSO);
- pDeviceContext->SetPipelineState(pPSO);
+ EXPECT_TRUE(pPSO);
+ if (pPSO)
+ pDeviceContext->SetPipelineState(pPSO);
return pPSO;
}
@@ -182,7 +184,7 @@ TEST_F(BlendStateBasicTest, CreatePSO)
EXPECT_TRUE(CreateTestPSO(PSODesc, true));
}
-class BlendFactorTest : public BlendStateTestBase, public testing::TestWithParam<std::tuple<Uint32, int, bool>>
+class BlendFactorTest : public BlendStateTestBase, public testing::TestWithParam<std::tuple<int, bool>>
{
protected:
static void SetUpTestSuite()
@@ -204,26 +206,29 @@ TEST_P(BlendFactorTest, CreatePSO)
const auto& Param = GetParam();
- auto NumRenderTarges = std::get<0>(Param);
- auto BlendFactor = static_cast<BLEND_FACTOR>(std::get<1>(Param));
- bool TestingAlpha = std::get<2>(Param);
+ const auto BlendFactor = static_cast<BLEND_FACTOR>(std::get<0>(Param));
+ const bool TestingAlpha = std::get<1>(Param);
- const auto& DevCaps = pDevice->GetDeviceCaps();
- if (DevCaps.DevType == DeviceType::OpenGLES && NumRenderTarges > 4)
- {
- GTEST_SKIP();
- }
+ const auto& DevCaps = pDevice->GetDeviceCaps();
+ Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8;
- bool TestSRC1 = DevCaps.DevType != DeviceType::OpenGLES; // || DevCaps.Vendor == GPU_VENDOR::NVIDIA;
- if ((!TestSRC1 || NumRenderTarges > 1) &&
- (BlendFactor == BLEND_FACTOR_SRC1_COLOR ||
- BlendFactor == BLEND_FACTOR_INV_SRC1_COLOR ||
- BlendFactor == BLEND_FACTOR_SRC1_ALPHA ||
- BlendFactor == BLEND_FACTOR_INV_SRC1_ALPHA))
+ const bool TestSRC1 = DevCaps.DevType != DeviceType::OpenGLES; // || DevCaps.Vendor == GPU_VENDOR::NVIDIA;
+ if (BlendFactor == BLEND_FACTOR_SRC1_COLOR ||
+ BlendFactor == BLEND_FACTOR_INV_SRC1_COLOR ||
+ BlendFactor == BLEND_FACTOR_SRC1_ALPHA ||
+ BlendFactor == BLEND_FACTOR_INV_SRC1_ALPHA)
{
- GTEST_SKIP();
+ if (!TestSRC1)
+ {
+ GTEST_SKIP();
+ }
+ else
+ {
+ MaxTestRenderTargets = 1;
+ }
}
+ for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges)
{
auto PSODesc = GetPSODesc(NumRenderTarges);
PSODesc.Name = "SrcBlendFactorTest";
@@ -243,23 +248,24 @@ TEST_P(BlendFactorTest, CreatePSO)
}
auto pPSO = CreateTestPSO(PSODesc, true);
- ASSERT_TRUE(pPSO);
+ ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges;
for (Uint32 i = 0; i < NumRenderTarges; ++i)
{
auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i];
- EXPECT_EQ(RT.BlendEnable, True);
+ EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i;
if (TestingAlpha)
{
- EXPECT_EQ(RT.SrcBlendAlpha, BlendFactor);
+ EXPECT_EQ(RT.SrcBlendAlpha, BlendFactor) << "Render target: " << i;
}
else
{
- EXPECT_EQ(RT.SrcBlend, BlendFactor);
+ EXPECT_EQ(RT.SrcBlend, BlendFactor) << "Render target: " << i;
}
}
}
+ for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges)
{
auto PSODesc = GetPSODesc(NumRenderTarges);
PSODesc.Name = "DstBlendFactorTest";
@@ -279,38 +285,36 @@ TEST_P(BlendFactorTest, CreatePSO)
}
auto pPSO = CreateTestPSO(PSODesc, true);
- ASSERT_TRUE(pPSO);
+ ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges;
for (Uint32 i = 0; i < NumRenderTarges; ++i)
{
auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i];
- EXPECT_EQ(RT.BlendEnable, True);
+ EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i;
if (TestingAlpha)
{
- EXPECT_EQ(RT.DestBlendAlpha, BlendFactor);
+ EXPECT_EQ(RT.DestBlendAlpha, BlendFactor) << "Render target: " << i;
}
else
{
- EXPECT_EQ(RT.DestBlend, BlendFactor);
+ EXPECT_EQ(RT.DestBlend, BlendFactor) << "Render target: " << i;
}
}
}
}
-std::string PrintBlendFactorTestName(const testing::TestParamInfo<std::tuple<Uint32, int, bool>>& info) //
+std::string PrintBlendFactorTestName(const testing::TestParamInfo<std::tuple<int, bool>>& info) //
{
- auto NumRenderTarges = std::get<0>(info.param);
- auto BlendFactor = static_cast<BLEND_FACTOR>(std::get<1>(info.param));
+ auto BlendFactor = static_cast<BLEND_FACTOR>(std::get<0>(info.param));
std::stringstream name_ss;
- name_ss << GetBlendFactorLiteralName(BlendFactor) << "_x_" << NumRenderTarges;
+ name_ss << GetBlendFactorLiteralName(BlendFactor);
return name_ss.str();
}
INSTANTIATE_TEST_SUITE_P(ColorBlendFactors,
BlendFactorTest,
testing::Combine(
- testing::Range<Uint32>(Uint32{1}, Uint32{8}),
testing::Range<int>(BLEND_FACTOR_UNDEFINED + 1, BLEND_FACTOR_NUM_FACTORS),
testing::Values(false)),
PrintBlendFactorTestName);
@@ -319,7 +323,6 @@ INSTANTIATE_TEST_SUITE_P(ColorBlendFactors,
INSTANTIATE_TEST_SUITE_P(AlphaBlendFactors,
BlendFactorTest,
testing::Combine(
- testing::Range<Uint32>(Uint32{1}, Uint32{8}),
testing::Values<int>(BLEND_FACTOR_ZERO,
BLEND_FACTOR_ONE,
BLEND_FACTOR_SRC_ALPHA,
@@ -335,7 +338,7 @@ INSTANTIATE_TEST_SUITE_P(AlphaBlendFactors,
PrintBlendFactorTestName);
-class BlendOperationTest : public BlendStateTestBase, public testing::TestWithParam<std::tuple<Uint32, int, bool>>
+class BlendOperationTest : public BlendStateTestBase, public testing::TestWithParam<std::tuple<int, bool>>
{
protected:
static void SetUpTestSuite()
@@ -358,68 +361,65 @@ TEST_P(BlendOperationTest, CreatePSO)
const auto& Param = GetParam();
- auto NumRenderTarges = std::get<0>(Param);
- auto BlendOp = static_cast<BLEND_OPERATION>(std::get<1>(Param));
- auto TestingAlpha = std::get<2>(Param);
-
- const auto& DevCaps = pDevice->GetDeviceCaps();
- if (DevCaps.DevType == DeviceType::OpenGLES && NumRenderTarges > 4)
- {
- GTEST_SKIP();
- }
-
- auto PSODesc = GetPSODesc(NumRenderTarges);
- PSODesc.Name = "BlendOperationTest";
+ const auto BlendOp = static_cast<BLEND_OPERATION>(std::get<0>(Param));
+ const auto TestingAlpha = std::get<1>(Param);
- BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc;
+ const auto& DevCaps = pDevice->GetDeviceCaps();
+ const Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8;
- BSDesc.IndependentBlendEnable = True;
- for (Uint32 i = 0; i < NumRenderTarges; ++i)
+ for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges)
{
- auto& RT = BSDesc.RenderTargets[i];
- RT.BlendEnable = True;
- RT.SrcBlend = BLEND_FACTOR_SRC_COLOR;
- RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR;
- RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
- RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
- if (TestingAlpha)
- RT.BlendOpAlpha = BlendOp;
- else
- RT.BlendOp = BlendOp;
- }
+ auto PSODesc = GetPSODesc(NumRenderTarges);
+ PSODesc.Name = "BlendOperationTest";
- auto pPSO = CreateTestPSO(PSODesc, true);
- ASSERT_TRUE(pPSO);
- for (Uint32 i = 0; i < NumRenderTarges; ++i)
- {
- auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i];
+ BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc;
- EXPECT_EQ(RT.BlendEnable, True);
- if (TestingAlpha)
+ BSDesc.IndependentBlendEnable = True;
+ for (Uint32 i = 0; i < NumRenderTarges; ++i)
{
- EXPECT_EQ(RT.BlendOpAlpha, BlendOp);
+ auto& RT = BSDesc.RenderTargets[i];
+ RT.BlendEnable = True;
+ RT.SrcBlend = BLEND_FACTOR_SRC_COLOR;
+ RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR;
+ RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
+ RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
+ if (TestingAlpha)
+ RT.BlendOpAlpha = BlendOp;
+ else
+ RT.BlendOp = BlendOp;
}
- else
+
+ auto pPSO = CreateTestPSO(PSODesc, true);
+ ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges;
+ for (Uint32 i = 0; i < NumRenderTarges; ++i)
{
- EXPECT_EQ(RT.BlendOp, BlendOp);
+ auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i];
+
+ EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i;
+ if (TestingAlpha)
+ {
+ EXPECT_EQ(RT.BlendOpAlpha, BlendOp) << "Render target: " << i;
+ }
+ else
+ {
+ EXPECT_EQ(RT.BlendOp, BlendOp) << "Render target: " << i;
+ }
}
}
}
-
-INSTANTIATE_TEST_SUITE_P(ColorBlendOperations,
+INSTANTIATE_TEST_SUITE_P(BlendOperations,
BlendOperationTest,
testing::Combine(
- testing::Range<Uint32>(Uint32{1}, Uint32{8}),
testing::Range<int>(BLEND_OPERATION_UNDEFINED + 1, BLEND_OPERATION_NUM_OPERATIONS),
testing::Values(true, false)),
- [](const testing::TestParamInfo<std::tuple<Uint32, int, bool>>& info) //
+ [](const testing::TestParamInfo<std::tuple<int, bool>>& info) //
{
- auto NumRenderTarges = std::get<0>(info.param);
- auto BlendOp = static_cast<BLEND_OPERATION>(std::get<1>(info.param));
- auto IsTestingAlpha = std::get<2>(info.param);
+ auto BlendOp = static_cast<BLEND_OPERATION>(std::get<0>(info.param));
+ auto IsTestingAlpha = std::get<1>(info.param);
+
std::stringstream name_ss;
- name_ss << (IsTestingAlpha ? "Alpha_" : "Color_") << GetBlendOperationLiteralName(BlendOp) << "_x_" << NumRenderTarges;
+ name_ss << (IsTestingAlpha ? "Alpha_" : "Color_") << GetBlendOperationLiteralName(BlendOp);
return name_ss.str();
} //
);
diff --git a/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp
new file mode 100644
index 00000000..ff8c20cf
--- /dev/null
+++ b/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp
@@ -0,0 +1,110 @@
+/* Copyright 2019 Diligent Graphics LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "TestingEnvironment.h"
+#include "PSOTestBase.h"
+#include "GraphicsAccessories.h"
+
+#include "gtest/gtest.h"
+
+using namespace Diligent;
+
+namespace
+{
+
+class DepthStencilStateTest : public PSOTestBase, public ::testing::Test
+{
+protected:
+ static void SetUpTestSuite()
+ {
+ InitResources();
+ }
+
+ static void TearDownTestSuite()
+ {
+ ReleaseResources();
+ TestingEnvironment::GetInstance()->ReleaseResources();
+ }
+};
+
+TEST_F(DepthStencilStateTest, CreatePSO)
+{
+ auto PSODesc = GetPSODesc();
+
+ DepthStencilStateDesc& DSSDesc = PSODesc.GraphicsPipeline.DepthStencilDesc;
+
+ DSSDesc.DepthEnable = False;
+ DSSDesc.DepthWriteEnable = False;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ DSSDesc.DepthEnable = True;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ DSSDesc.DepthWriteEnable = True;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc)
+ {
+ DSSDesc.DepthFunc = static_cast<COMPARISON_FUNCTION>(CmpFunc);
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Comparison func: " << GetComparisonFunctionLiteralName(DSSDesc.DepthFunc, true);
+ }
+
+ DSSDesc.StencilEnable = True;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ DSSDesc.StencilReadMask = 0xA9;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ DSSDesc.StencilWriteMask = 0xB8;
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true));
+
+ for (int Face = 0; Face < 2; ++Face)
+ {
+ auto& FaceOp = Face == 0 ? DSSDesc.FrontFace : DSSDesc.BackFace;
+ for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp)
+ {
+ FaceOp.StencilFailOp = static_cast<STENCIL_OP>(StOp);
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil fail op: " << GetStencilOpLiteralName(FaceOp.StencilFailOp);
+ }
+
+ for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp)
+ {
+ FaceOp.StencilDepthFailOp = static_cast<STENCIL_OP>(StOp);
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil depth fail op: " << GetStencilOpLiteralName(FaceOp.StencilDepthFailOp);
+ }
+
+ for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp)
+ {
+ FaceOp.StencilPassOp = static_cast<STENCIL_OP>(StOp);
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil pass op: " << GetStencilOpLiteralName(FaceOp.StencilPassOp);
+ }
+
+ for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc)
+ {
+ FaceOp.StencilFunc = static_cast<COMPARISON_FUNCTION>(CmpFunc);
+ ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Comparison func: " << GetComparisonFunctionLiteralName(FaceOp.StencilFunc, true);
+ }
+ }
+}
+
+} // namespace
diff --git a/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp b/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp
index 056fc0d5..91840c80 100644
--- a/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp
+++ b/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp
@@ -84,7 +84,7 @@ RefCntAutoPtr<IPipelineState> PSOTestBase::CreateTestPSO(const PipelineStateDesc
RefCntAutoPtr<IPipelineState> pPSO;
pDevice->CreatePipelineState(PSODesc, &pPSO);
- if (BindPSO)
+ if (BindPSO && pPSO)
{
pContext->SetPipelineState(pPSO);
}
diff --git a/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp
index 0e0249ee..dd064074 100644
--- a/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp
+++ b/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp
@@ -23,6 +23,7 @@
#include "TestingEnvironment.h"
#include "PSOTestBase.h"
+#include "GraphicsAccessories.h"
#include "gtest/gtest.h"
@@ -58,7 +59,7 @@ TEST_F(RasterizerStateTest, CreatePSO)
{
RSDesc.FillMode = static_cast<FILL_MODE>(FillMode);
auto pPSO = CreateTestPSO(PSODesc, true);
- ASSERT_TRUE(pPSO);
+ ASSERT_TRUE(pPSO) << "Fill mode: " << GetFillModeLiteralName(RSDesc.FillMode);
EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.FillMode, RSDesc.FillMode);
}
@@ -66,7 +67,7 @@ TEST_F(RasterizerStateTest, CreatePSO)
{
RSDesc.CullMode = static_cast<CULL_MODE>(CullMode);
auto pPSO = CreateTestPSO(PSODesc, true);
- ASSERT_TRUE(pPSO);
+ ASSERT_TRUE(pPSO) << "Cull mode: " << GetCullModeLiteralName(RSDesc.CullMode);
EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.CullMode, RSDesc.CullMode);
}
diff --git a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp
index ca4a188a..89f23ac0 100644
--- a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp
+++ b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp
@@ -141,6 +141,51 @@ TEST(GraphicsAccessories_GraphicsAccessories, GetBlendOperationLiteralName)
#undef TEST_BLEND_OP_ENUM
}
+TEST(GraphicsAccessories_GraphicsAccessories, GetFillModeLiteralName)
+{
+#define TEST_FILL_MODE_ENUM(ENUM_VAL) \
+ { \
+ EXPECT_STREQ(GetFillModeLiteralName(ENUM_VAL), #ENUM_VAL); \
+ }
+ TEST_FILL_MODE_ENUM(FILL_MODE_UNDEFINED);
+ TEST_FILL_MODE_ENUM(FILL_MODE_WIREFRAME);
+ TEST_FILL_MODE_ENUM(FILL_MODE_SOLID);
+#undef TEST_FILL_MODE_ENUM
+}
+
+TEST(GraphicsAccessories_GraphicsAccessories, GetCullModeLiteralName)
+{
+#define TEST_CULL_MODE_ENUM(ENUM_VAL) \
+ { \
+ EXPECT_STREQ(GetCullModeLiteralName(ENUM_VAL), #ENUM_VAL); \
+ }
+ TEST_CULL_MODE_ENUM(CULL_MODE_UNDEFINED);
+ TEST_CULL_MODE_ENUM(CULL_MODE_NONE);
+ TEST_CULL_MODE_ENUM(CULL_MODE_FRONT);
+ TEST_CULL_MODE_ENUM(CULL_MODE_BACK);
+#undef TEST_CULL_MODE_ENUM
+}
+
+TEST(GraphicsAccessories_GraphicsAccessories, GetStencilOpLiteralName)
+{
+#define TEST_STENCIL_OP_ENUM(ENUM_VAL) \
+ { \
+ EXPECT_STREQ(GetStencilOpLiteralName(ENUM_VAL), #ENUM_VAL); \
+ }
+
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_UNDEFINED);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_KEEP);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_ZERO);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_REPLACE);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_SAT);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_SAT);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_INVERT);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_WRAP);
+ TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_WRAP);
+#undef TEST_STENCIL_OP_ENUM
+}
+
+
TEST(GraphicsAccessories_GraphicsAccessories, GetTextureFormatAttribs)
{