From 104ccace5e54d81ebdcba9cea4aae2c55e0b4074 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 29 Oct 2024 15:42:01 +0000 Subject: [PATCH 1/2] ShadingEngine : Support 64 bit ints in `RendererServices::get_userdata()` This requires https://github.com/ImageEngine/cortex/pull/1439 to work. --- Changes.md | 1 + python/GafferOSLTest/ShadingEngineTest.py | 27 ++++++++++++ src/GafferOSL/ShadingEngine.cpp | 50 +++++++++++++++-------- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Changes.md b/Changes.md index ae92c966a41..10cc16669d5 100644 --- a/Changes.md +++ b/Changes.md @@ -43,6 +43,7 @@ Fixes - `gaffer view` : Fixed default OpenColorIO display transform. - AnimationEditor : Fixed changing of the current frame by dragging the frame indicator or clicking on the time axis. - ImageWriter : Matched view metadata to Nuke when using the Nuke options for `layout`. This should address an issue where EXRs written from Gaffer using Nuke layouts sometimes did not load correctly in Nuke (#6120). In the unlikely situation that you were relying on the old behaviour, you can set the env var `GAFFERIMAGE_IMAGEWRITER_OMIT_DEFAULT_NUKE_VIEW = 1` in order to keep the old behaviour. +- OSLObject : Fixed `getattribute()` to support 64 bit integer data, such as an `instanceId` primitive variable loaded from USD. Since OSL doesn't provide a 64 bit integer type, values are truncated to 32 bits. API --- diff --git a/python/GafferOSLTest/ShadingEngineTest.py b/python/GafferOSLTest/ShadingEngineTest.py index 230e92a03dc..702a9cafa51 100644 --- a/python/GafferOSLTest/ShadingEngineTest.py +++ b/python/GafferOSLTest/ShadingEngineTest.py @@ -160,6 +160,33 @@ def testDoubleAsIntViaGetAttribute( self ) : for i, c in enumerate( p["Ci"] ) : self.assertEqual( c[0], float(i) ) + def testInt64GetAttribute( self ) : + + shader = self.compileShader( pathlib.Path( __file__ ).parent / "shaders" / "intAttribute.osl" ) + + for dataType in ( IECore.Int64VectorData, IECore.UInt64VectorData ) : + + with self.subTest( dataType = dataType ) : + + points = IECore.CompoundData( { + "P" : IECore.V3fVectorData( [ imath.V3f( i ) for i in range( 0, 10 ) ] ), + "int64Data" : dataType( range( 0, 10 ) ) + } ) + + engine = GafferOSL.ShadingEngine( IECoreScene.ShaderNetwork( + shaders = { + "output" : IECoreScene.Shader( shader, "osl:surface", { "name" : "int64Data" } ), + }, + output = "output" + ) ) + + self.assertTrue( engine.needsAttribute( "int64Data" ) ) + + points = engine.shade( points ) + + for i, c in enumerate( points["Ci"] ) : + self.assertEqual( c[0], float( i ) ) + def testUserDataViaGetAttribute( self ) : shader = self.compileShader( pathlib.Path( __file__ ).parent / "shaders" / "attribute.osl" ) diff --git a/src/GafferOSL/ShadingEngine.cpp b/src/GafferOSL/ShadingEngine.cpp index 0c40546c00b..b8c8dbeda77 100644 --- a/src/GafferOSL/ShadingEngine.cpp +++ b/src/GafferOSL/ShadingEngine.cpp @@ -215,6 +215,29 @@ DataPtr dataFromTypeDesc( TypeDesc type, void *&basePointer ) return nullptr; } +template +bool convertScalar( void *dst, TypeDesc dstType, const void *src ) +{ + const SourceType *typedSrc = reinterpret_cast( src ); + if( dstType == TypeDesc::FLOAT ) + { + if( typedSrc && dst ) + { + *((float*)dst) = static_cast( *typedSrc ); + } + return true; + } + else if( dstType == TypeDesc::INT ) + { + if( typedSrc && dst ) + { + *((int*)dst) = static_cast( *typedSrc ); + } + return true; + } + return false; +} + // Equivalent to `OSL::ShadingSystem:convert_value()`, but with support for // additional conversions. bool convertValue( void *dst, TypeDesc dstType, const void *src, TypeDesc srcType ) @@ -254,24 +277,15 @@ bool convertValue( void *dst, TypeDesc dstType, const void *src, TypeDesc srcTyp } else if( srcType.basetype == TypeDesc::DOUBLE && srcType.aggregate == TypeDesc::SCALAR ) { - const double *doubleCast = reinterpret_cast( src ); - if( dstType == TypeDesc::FLOAT ) - { - if( doubleCast && dst ) - { - *((float*)dst) = static_cast( *doubleCast ); - } - return true; - } - else if( dstType == TypeDesc::INT ) - { - if( doubleCast && dst ) - { - *((int*)dst) = static_cast( *doubleCast ); - } - return true; - } - return false; + return convertScalar( dst, dstType, src ); + } + else if( srcType.basetype == TypeDesc::INT64 && srcType.aggregate == TypeDesc::SCALAR ) + { + return convertScalar( dst, dstType, src ); + } + else if( srcType.basetype == TypeDesc::UINT64 && srcType.aggregate == TypeDesc::SCALAR ) + { + return convertScalar( dst, dstType, src ); } return false; From ed0cc2321ab7a959e2bef8ec679b5111f0047e3c Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 20 Nov 2024 22:29:10 +0000 Subject: [PATCH 2/2] CI : Update to GafferHQ/dependencies 9.1.0 --- .github/workflows/main/installDependencies.py | 2 +- Changes.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main/installDependencies.py b/.github/workflows/main/installDependencies.py index 7d22f2327e8..f2d1f7c6f28 100755 --- a/.github/workflows/main/installDependencies.py +++ b/.github/workflows/main/installDependencies.py @@ -49,7 +49,7 @@ # Determine default archive URL. -defaultURL = "https://github.com/GafferHQ/dependencies/releases/download/9.0.0/gafferDependencies-9.0.0-{platform}{buildEnvironment}.{extension}" +defaultURL = "https://github.com/GafferHQ/dependencies/releases/download/9.1.0/gafferDependencies-9.1.0-{platform}{buildEnvironment}.{extension}" # Parse command line arguments. diff --git a/Changes.md b/Changes.md index 10cc16669d5..5f54ad7ae84 100644 --- a/Changes.md +++ b/Changes.md @@ -44,6 +44,7 @@ Fixes - AnimationEditor : Fixed changing of the current frame by dragging the frame indicator or clicking on the time axis. - ImageWriter : Matched view metadata to Nuke when using the Nuke options for `layout`. This should address an issue where EXRs written from Gaffer using Nuke layouts sometimes did not load correctly in Nuke (#6120). In the unlikely situation that you were relying on the old behaviour, you can set the env var `GAFFERIMAGE_IMAGEWRITER_OMIT_DEFAULT_NUKE_VIEW = 1` in order to keep the old behaviour. - OSLObject : Fixed `getattribute()` to support 64 bit integer data, such as an `instanceId` primitive variable loaded from USD. Since OSL doesn't provide a 64 bit integer type, values are truncated to 32 bits. +- MeshSplit : Vertex order is now preserved. API --- @@ -55,6 +56,11 @@ API - SceneEditor : Added `editScope()` method. - Image : Added optional `image` argument to `createSwatch()` static method. +Build +----- + +- Cortex : Updated to version 10.5.11.0. + 1.5.0.1 (relative to 1.5.0.0) =======