Skip to content

Commit

Permalink
Fix search paths in MSL render tests (#1481)
Browse files Browse the repository at this point in the history
Previously it was failing to find options.mtlx, and not rendering results.
  • Loading branch information
Morteeza authored Aug 21, 2023
1 parent 2d12c16 commit 6918d5d
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions source/MaterialXTest/MaterialXRenderMsl/RenderMsl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void runBake(mx::DocumentPtr doc, const mx::FileSearchPath& imageSearchPath, con
std::cout << "Validating MSL rendering for: " << doc->getSourceUri() << std::endl;

mx::ScopedTimer totalMSLTime(&profileTimes.languageTimes.totalTime);
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();

const mx::ShaderGenerator& shadergen = context.getShaderGenerator();

Expand Down Expand Up @@ -277,7 +278,7 @@ void runBake(mx::DocumentPtr doc, const mx::FileSearchPath& imageSearchPath, con
{
if (!testOptions.renderGeometry.isAbsolute())
{
geomPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Geometry") / testOptions.renderGeometry;
geomPath = searchPath.find("resources/Geometry") / testOptions.renderGeometry;
}
else
{
Expand All @@ -286,7 +287,7 @@ void runBake(mx::DocumentPtr doc, const mx::FileSearchPath& imageSearchPath, con
}
else
{
geomPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Geometry/sphere.obj");
geomPath = searchPath.find("resources/Geometry/sphere.obj");
}

if (!geomHandler->hasGeometry(geomPath))
Expand Down Expand Up @@ -456,18 +457,10 @@ void runBake(mx::DocumentPtr doc, const mx::FileSearchPath& imageSearchPath, con

TEST_CASE("Render: MSL TestSuite", "[rendermsl]")
{
MslShaderRenderTester renderTester(mx::MslShaderGenerator::create());

const mx::FilePath testRootPath = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/TestSuite");
const mx::FilePath testRootPath2 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/StandardSurface");
const mx::FilePath testRootPath3 = mx::FilePath::getCurrentPath() / mx::FilePath("resources/Materials/Examples/UsdPreviewSurface");
mx::FilePathVec testRootPaths;
testRootPaths.push_back(testRootPath);
testRootPaths.push_back(testRootPath2);
testRootPaths.push_back(testRootPath3);

mx::FilePath optionsFilePath = testRootPath / mx::FilePath("_options.mtlx");
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();
mx::FilePath optionsFilePath = searchPath.find("resources/Materials/TestSuite/_options.mtlx");

MslShaderRenderTester renderTester(mx::MslShaderGenerator::create());
renderTester.validate(optionsFilePath);
}

Expand Down

0 comments on commit 6918d5d

Please sign in to comment.