Fixed unit test compile issues, and added a unit test for PSO handling setting.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2021-09-15 13:26:48 -07:00
parent 48e0a9d5ff
commit 346e2d9f66
2 changed files with 49 additions and 6 deletions
@@ -1039,6 +1039,42 @@ namespace UnitTest
drawListTagRegistry->ReleaseTag(tag);
}
TEST_F(LuaMaterialFunctorTests, LuaMaterialFunctor_RuntimeContext_PsoChangesNotAllowed_Error)
{
using namespace AZ::RPI;
const char* functorScript =
R"(
function GetMaterialPropertyDependencies()
return {"general.MyBool"}
end
function GetShaderOptionDependencies()
return {}
end
function Process(context)
local boolValue = context:GetMaterialPropertyValue_bool("general.MyBool")
if(boolValue) then
context:GetShader(0):GetRenderStatesOverride():SetFillMode(FillMode_Wireframe)
else
context:GetShader(0):GetRenderStatesOverride():ClearFillMode()
end
end
)";
TestMaterialData testData;
testData.Setup(MaterialPropertyDataType::Bool, "general.MyBool", functorScript);
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{true});
ErrorMessageFinder errorMessageFinder;
errorMessageFinder.AddExpectedErrorMessage("not be changed at runtime because they impact Pipeline State Objects: general.MyBool");
EXPECT_TRUE(testData.GetMaterial()->Compile());
errorMessageFinder.CheckExpectedErrorsFound();
}
TEST_F(LuaMaterialFunctorTests, LuaMaterialFunctor_RuntimeContext_MultisampleCustomPositionCountIndex_Error)
{
@@ -1067,6 +1103,7 @@ namespace UnitTest
TestMaterialData testData;
testData.Setup(MaterialPropertyDataType::Bool, "general.MyBool", functorScript);
testData.GetMaterial()->SetPsoHandlingOverride(AZ::RPI::MaterialPropertyPsoHandling::Allowed);
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{true});
ErrorMessageFinder errorMessageFinder;
@@ -1107,7 +1144,8 @@ namespace UnitTest
errorMessageFinder.AddExpectedErrorMessage("ClearMultisampleCustomPosition(18,...) index is out of range. Must be less than 16.");
testData.Setup(MaterialPropertyDataType::Bool, "general.MyBool", functorScript);
errorMessageFinder.CheckExpectedErrorsFound();
testData.GetMaterial()->SetPsoHandlingOverride(AZ::RPI::MaterialPropertyPsoHandling::Allowed);
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{true});
errorMessageFinder.AddExpectedErrorMessage("SetMultisampleCustomPosition(17,...) index is out of range. Must be less than 16.");
@@ -1146,7 +1184,8 @@ namespace UnitTest
errorMessageFinder.AddExpectedErrorMessage("ClearBlendEnabled(10,...) index is out of range. Must be less than 8.");
testData.Setup(MaterialPropertyDataType::Bool, "general.MyBool", functorScript);
errorMessageFinder.CheckExpectedErrorsFound();
testData.GetMaterial()->SetPsoHandlingOverride(AZ::RPI::MaterialPropertyPsoHandling::Allowed);
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{true});
errorMessageFinder.AddExpectedErrorMessage("SetBlendEnabled(9,...) index is out of range. Must be less than 8.");
@@ -165,7 +165,8 @@ namespace UnitTest
materialTypeAsset->GetMaterialPropertiesLayout(),
&shaderCollectionCopy,
unusedSrg,
&testFunctorSetOptionA.GetMaterialPropertyDependencies()
&testFunctorSetOptionA.GetMaterialPropertyDependencies(),
AZ::RPI::MaterialPropertyPsoHandling::Allowed
};
testFunctorSetOptionA.Process(runtimeContext);
EXPECT_TRUE(testFunctorSetOptionA.GetProcessResult());
@@ -181,7 +182,8 @@ namespace UnitTest
materialTypeAsset->GetMaterialPropertiesLayout(),
&shaderCollectionCopy,
unusedSrg,
&testFunctorSetOptionB.GetMaterialPropertyDependencies()
&testFunctorSetOptionB.GetMaterialPropertyDependencies(),
AZ::RPI::MaterialPropertyPsoHandling::Allowed
};
testFunctorSetOptionB.Process(runtimeContext);
EXPECT_TRUE(testFunctorSetOptionB.GetProcessResult());
@@ -198,7 +200,8 @@ namespace UnitTest
materialTypeAsset->GetMaterialPropertiesLayout(),
&shaderCollectionCopy,
unusedSrg,
&testFunctorSetOptionC.GetMaterialPropertyDependencies()
&testFunctorSetOptionC.GetMaterialPropertyDependencies(),
AZ::RPI::MaterialPropertyPsoHandling::Allowed
};
testFunctorSetOptionC.Process(runtimeContext);
EXPECT_FALSE(testFunctorSetOptionC.GetProcessResult());
@@ -213,7 +216,8 @@ namespace UnitTest
materialTypeAsset->GetMaterialPropertiesLayout(),
&shaderCollectionCopy,
unusedSrg,
&testFunctorSetOptionInvalid.GetMaterialPropertyDependencies()
&testFunctorSetOptionInvalid.GetMaterialPropertyDependencies(),
AZ::RPI::MaterialPropertyPsoHandling::Allowed
};
testFunctorSetOptionInvalid.Process(runtimeContext);
EXPECT_FALSE(testFunctorSetOptionInvalid.GetProcessResult());