Proposal : Deterministic Default Instance Resolution - #3028
Open
kwokcb wants to merge 3 commits into
Open
Conversation
… checking exact or rough matches. Previously it would always return the first found from either exact or rough matches. This is additive and will not affect any existing logic since no library nodes set this attribute for non-versioned nodedefs. Add unit test to new and modifying existing definition behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deterministic Default Instance Resolution
Issue
For node definition categories which have two or more
nodedefvariants with the same output type but different input arguments, if insufficient input arguments are specified the logic to indicate which variant instantiate is undefined.For MaterialX core the variant chosen is the first one found in memory -- thus if the order of loading (placement in the MaterialX document ) differs than the variant chosen may change. Any integration using MaterialX may choose their own logic which can be inconsistent as well.
Proposal
Allow for definitions with the same category to specify
isdefaultversion=trueto indicate which definition variant is being instantiate when ambiguous.The current requirement that only one variant may set
isdefaultversiondoes not change..Changes to existing specification
versionattribute does not need to be specified forisdefaultversionto be specified.Examples
Existing Definitions
randomcolordiffers only ininwhich may be afloatorinteger.normalmapis another example which only differs inscaletypeThere are public example which show this ambiguity. For example "Emerald Peaks Wallpaper" (and many others) from AMD GPUOpen material site uses this declaration:
As
scaleis not specified the instance could beND_normalmap_floatorND_normalmap_vector2Updated Definitions
If
isdefaultvaluewas specified for one of the variants then there would be no ambiguity. For the examples the first variant is tagged as the "default"