Skip to content

Modernize MaterialX version checks for easy reading and streamlined logic #3653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

scotbrew
Copy link

Description of Change(s)

Use the new MATERIALX_VERSION_INDEX and MATERIALX_GENERATE_INDEX added in MaterialX 1.39.2. This makes the version check code easier to read and streamlines the logic to avoids potential version check errors when using MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, and MATERIALX_BUILD_VERSION comparisons directly.

Sample usage:
#if MATERIALX_VERSION_INDEX < MATERIALX_GENERATE_INDEX(1, 39, 0)

Note: MATERIALX_VERSION_INDEX and MATERIALX_GENERATE_INDEX were added as of MaterialX 1.39.2 and then revised in 1.39.4. Defining these macros if MaterialX version < 1.39.4.

Fixes Issue(s)

#3651

Testing

Manually tested compilation with MaterialX 1.39.3 and 1.38.10.

Checklist

Use new MATERIALX_VERSION_INDEX and MATERIALX_GENERATE_INDEX added in MaterialX 1.39.2.  This makes the version check code easier to read and avoids potential version check errors when using MATERIALX_MAJOR_VERSION,
MATERIALX_MINOR_VERSION, and MATERIALX_BUILD_VERSION comparisons directly.

Sample usage:
#if MATERIALX_VERSION_INDEX < MATERIALX_GENERATE_INDEX(1, 39, 0)

MATERIALX_VERSION_INDEX and MATERIALX_GENERATE_INDEX were added as of MaterialX 1.39.2 and then revised in 1.39.4.  Will define these macros if version < 1.39.4.

Tested compilation with MaterialX 1.39.3 and 1.38.10.
@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-11055

(This is an automated message. See here for more information.)

Moving MATERIALX_GENERATE_INDEX and MATERIALX_VERSION_INDEX above the MaterialX ShaderGenerator includes as there will likely be another include conditionally added for WGSL based on the MaterialX version.  Putting the code in the same place so it does not have to be moved later and create merging confusion.

Tested with MaterialX 1.39.3 and 1.38.10 versions on MacOS.
@@ -8,11 +8,22 @@
#define PXR_IMAGING_HD_ST_MATERIALX_SHADER_GEN_H

#include "pxr/pxr.h"
#include <MaterialXCore/Library.h>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this #include <MaterialXCore/Library.h> (which declares the MaterialX version defines) and moved the defines above the other MaterialX includes as there are plans in the future for conditionally importing MaterialXGenMsl/WgslShaderGenerator.h based on the MaterialX version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants