Skip to content

Commit aa3ca63

Browse files
authored
Merge branch 'main' into functional_nodedefs
2 parents d999875 + fbb6100 commit aa3ca63

File tree

8 files changed

+45
-28
lines changed

8 files changed

+45
-28
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
compiler_version: "16.4"
7979
python: 3.13
8080
test_shaders: ON
81+
test_render: ON
8182

8283
- name: MacOS_Xcode_26_Python313
8384
os: macos-26
@@ -265,25 +266,40 @@ jobs:
265266
fi
266267
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/*
267268
268-
- name: Initialize Virtual Framebuffer
269+
- name: Setup Rendering Environment (Linux)
269270
if: matrix.test_render == 'ON' && runner.os == 'Linux'
270271
run: |
271272
Xvfb :1 -screen 0 1280x960x24 &
272273
echo "DISPLAY=:1" >> $GITHUB_ENV
273274
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
274275
276+
- name: Setup Rendering Environment (MacOS)
277+
if: matrix.test_render == 'ON' && runner.os == 'macOS'
278+
run: |
279+
# macOS can render headless with Metal backend without virtual display
280+
# Force software rendering for Metal backend (more reliable in CI)
281+
echo "MTL_HARDWARE_RENDERING=0" >> $GITHUB_ENV
282+
# Enable Metal debug layer for better debugging in CI
283+
echo "MTL_DEBUG_LAYER=1" >> $GITHUB_ENV
284+
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
285+
275286
- name: Render Script Tests
276287
if: matrix.test_render == 'ON'
277288
run: |
278289
mkdir build/render
279290
python python/Scripts/baketextures.py resources/Materials/Examples/StandardSurface/standard_surface_brass_tiled.mtlx build/render/brass_average_baked.mtlx --average
280291
python python/Scripts/translateshader.py resources/Materials/Examples/StandardSurface/standard_surface_carpaint.mtlx build/render/usd_preview_surface_carpaint.mtlx UsdPreviewSurface --hdr
281292
282-
- name: Render Application Tests
293+
- name: Viewer Tests
283294
if: matrix.test_render == 'ON'
284295
run: |
285296
../installed/bin/MaterialXView --material brass_average_baked.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_BrassAverage.png
286297
../installed/bin/MaterialXView --material usd_preview_surface_carpaint.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_CarpaintTranslated.png
298+
working-directory: build/render
299+
300+
- name: Graph Editor Tests
301+
if: matrix.test_render == 'ON' && runner.os == 'Linux'
302+
run: |
287303
../installed/bin/MaterialXGraphEditor --material ../../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --viewWidth 128 --viewHeight 128 --captureFilename GraphEditor_MarbleSolid.png
288304
working-directory: build/render
289305

source/MaterialXFormat/File.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ FilePathVec FilePath::getFilesInDirectory(const string& extension) const
185185

186186
#if defined(_WIN32)
187187
WIN32_FIND_DATAA fd;
188-
FilePath query = extension.empty() ? *this : (*this / ("*." + extension));
188+
FilePath query = extension.empty() ? (*this / "*") : (*this / ("*." + extension));
189189
HANDLE hFind = FindFirstFileA(query.asString().c_str(), &fd);
190190
if (hFind != INVALID_HANDLE_VALUE)
191191
{

source/MaterialXGenOsl/CMakeLists.txt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
file(GLOB_RECURSE materialx_source
2-
"${CMAKE_CURRENT_SOURCE_DIR}/OslShaderGenerator.cpp"
3-
"${CMAKE_CURRENT_SOURCE_DIR}/OslSyntax.cpp"
4-
"${CMAKE_CURRENT_SOURCE_DIR}/OslNetworkShaderGenerator.cpp"
5-
"${CMAKE_CURRENT_SOURCE_DIR}/OslNetworkSyntax.cpp"
6-
"${CMAKE_CURRENT_SOURCE_DIR}/Nodes/OsoNode.cpp")
7-
8-
file(GLOB_RECURSE materialx_headers
9-
"${CMAKE_CURRENT_SOURCE_DIR}/OslShaderGenerator.h"
10-
"${CMAKE_CURRENT_SOURCE_DIR}/OslSyntax.h"
11-
"${CMAKE_CURRENT_SOURCE_DIR}/OslNetworkShaderGenerator.h"
12-
"${CMAKE_CURRENT_SOURCE_DIR}/OslNetworkSyntax.h"
13-
"${CMAKE_CURRENT_SOURCE_DIR}/Nodes/OsoNode.h"
14-
"${CMAKE_CURRENT_SOURCE_DIR}/Export.h")
1+
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
2+
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
3+
4+
list(REMOVE_ITEM materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/LibsToOso.cpp")
155

166
mx_add_library(MaterialXGenOsl
177
SOURCE_FILES
@@ -25,7 +15,7 @@ mx_add_library(MaterialXGenOsl
2515
MATERIALX_GENOSL_EXPORTS)
2616

2717
# FIXME: LibsToOso has a dependency on the OslRenderer.
28-
if (MATERIALX_BUILD_RENDER)
18+
if (MATERIALX_BUILD_OSOS AND MATERIALX_BUILD_RENDER)
2919
file(GLOB GenNodes_SRC "${CMAKE_CURRENT_SOURCE_DIR}/LibsToOso.cpp")
3020

3121
set(MATERIALX_LIBRARIES

source/MaterialXGenOsl/LibsToOso.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int main(int argc, char* const argv[])
335335
mx::NodeGraphPtr librariesDocGraph = librariesDoc->addNodeGraph("librariesDocGraph");
336336

337337
// Loop over all the `NodeDef` gathered in our documents from the provided libraries.
338-
for (const mx::NodeDefPtr& nodeDef : librariesDoc->getNodeDefs())
338+
for (mx::NodeDefPtr nodeDef : librariesDoc->getNodeDefs())
339339
{
340340
std::string nodeName = nodeDef->getName();
341341

@@ -364,7 +364,7 @@ int main(int argc, char* const argv[])
364364
}
365365

366366
// TODO: Check for the existence/validity of the `Node`?
367-
mx::NodePtr node = librariesDoc->addNodeInstance(nodeDef, nodeName);
367+
mx::NodePtr node = librariesDocGraph->addNodeInstance(nodeDef, nodeName);
368368

369369
std::string oslShaderName = node->getName();
370370
oslShaderGen->getSyntax().makeValidName(oslShaderName);

source/MaterialXGraphEditor/Main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ int main(int argc, char* const argv[])
167167
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
168168
#endif
169169

170+
// When captureFilename is specified, make window invisible
171+
// to avoid issues with headless rendering.
172+
if (!captureFilename.empty())
173+
{
174+
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
175+
}
176+
170177
// Create window with graphics context
171178
GLFWwindow* window = glfwCreateWindow(1280, 960, "MaterialX Graph Editor", NULL, NULL);
172179
if (!window)

source/MaterialXRenderOsl/OslRenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ OslRendererPtr OslRenderer::create(unsigned int width, unsigned int height, Imag
2828
OslRenderer::OslRenderer(unsigned int width, unsigned int height, Image::BaseType baseType) :
2929
ShaderRenderer(width, height, baseType),
3030
_useTestRender(true),
31+
_useOSLCmdStr(false),
3132
_raysPerPixelLit(1),
3233
_raysPerPixelUnlit(1)
3334
{

source/MaterialXTest/MaterialXFormat/File.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,23 @@ TEST_CASE("Get all files in directory", "[file]")
185185
mx::FilePathVec results;
186186

187187
results = lightsDir.getFilesInDirectory("mtlx");
188-
for (const mx::FilePath& filename : results)
188+
REQUIRE(results.size() > 0);
189+
for (const mx::FilePath& filename : mtlxFilenames)
189190
{
190-
REQUIRE(std::find(mtlxFilenames.begin(), mtlxFilenames.end(), filename) != mtlxFilenames.end());
191+
REQUIRE(std::find(results.begin(), results.end(), filename) != results.end());
191192
}
192193

193194
results = lightsDir.getFilesInDirectory("hdr");
194-
for (const mx::FilePath& filename : results)
195+
REQUIRE(results.size() > 0);
196+
for (const mx::FilePath& filename : hdrFilenames)
195197
{
196-
REQUIRE(std::find(hdrFilenames.begin(), hdrFilenames.end(), filename) != hdrFilenames.end());
198+
REQUIRE(std::find(results.begin(), results.end(), filename) != results.end());
197199
}
198200

199201
results = lightsDir.getFilesInDirectory();
200-
for (const mx::FilePath& filename : results)
202+
REQUIRE(results.size() > 0);
203+
for (const mx::FilePath& filename : allFilesnames)
201204
{
202-
REQUIRE(std::find(allFilesnames.begin(), allFilesnames.end(), filename) != allFilesnames.end());
205+
REQUIRE(std::find(results.begin(), results.end(), filename) != results.end());
203206
}
204207
}

source/MaterialXTest/MaterialXRenderMsl/RenderMsl.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ bool runRenderer(const std::string& shaderName,
165165
std::ostream& log,
166166
const GenShaderUtil::TestSuiteOptions& testOptions,
167167
RenderUtil::RenderProfileTimes& profileTimes,
168-
const mx::FileSearchPath& /*imageSearchPath*/,
168+
const mx::FileSearchPath& imageSearchPath,
169169
const std::string& outputPath,
170170
mx::ImageVec* imageVec)
171171
{
@@ -351,7 +351,7 @@ bool runRenderer(const std::string& shaderName,
351351

352352
{
353353
mx::ScopedTimer renderTimer(&profileTimes.languageTimes.renderTime);
354-
_renderer->getImageHandler()->setSearchPath(mx::getDefaultDataSearchPath());
354+
_renderer->getImageHandler()->setSearchPath(imageSearchPath);
355355
unsigned int width = (unsigned int) testOptions.renderSize[0] * supersampleFactor;
356356
unsigned int height = (unsigned int) testOptions.renderSize[1] * supersampleFactor;
357357
_renderer->setSize(width, height);

0 commit comments

Comments
 (0)