PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6k stars 1.18k forks source link

MaterialX shader codegen test baseline is platform depedent #3272

Open DDoS opened 1 week ago

DDoS commented 1 week ago

Some of the MaterialX shader codegen uses unordered data structures, and this reflects in the output shader. This causes problems for tests which are comparing against a static baseline. For example, testHdStMaterialXShaderGen_UsdPStextured has these lines

    "textures": {
        "roughness": {
        },
        "diffuseColor": {
        }
    }, 

which will change order according to the stdlib implementation. On macOS, I observe

    "textures": {
        "diffuseColor": {
        },
        "roughness": {
        }
    }, 

and the test fails.

This is because the lines are printed in the order of _mxHdTextureMap, which is a MaterialX::StringMap aka std::unordered_map<std::string, std::string> (see pxr/imaging/hdSt/materialXShaderGen.cpp).

Either the testing baseline check needs to be smarter to handle undefined ordering where they can occur, or the codegen needs to sort the keys using the string values before printing.

jesschimein commented 1 week ago

Filed as internal issue #USD-10084