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
GafferOSL : ShadingEngine - cast doubles to float or int if required #2547
Conversation
src/GafferOSL/ShadingEngine.cpp
Outdated
@@ -294,6 +294,22 @@ class RenderState | |||
t.arraylen = 2; | |||
return ShadingSystem::convert_value( value, type, src, t ); | |||
} | |||
else if ( it->dataView.type.basetype == TypeDesc::DOUBLE ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would accept a V3d as well as just a double, right? Is that intended? I don't think we support a V3f->float conversion because it's ambiguous, and I would expect the same to apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked we're dealing with a scalar double in ba245a1
src/GafferOSL/ShadingEngine.cpp
Outdated
else if ( it->dataView.type.basetype == TypeDesc::DOUBLE ) | ||
{ | ||
double doubleValue; | ||
ShadingSystem::convert_value( &doubleValue, TypeDesc::DOUBLE, src, TypeDesc::DOUBLE ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fairly performance-critical code, so I think it's probably worthwhile preferring static_cast<const double *>( src )
over convert_value()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
favoured casts over function call in ba245a1
3dd9262
to
ba245a1
Compare
Perhaps we need to rewrite the Cortex -> OSL type conversion to provide a wider range of conversions? I've largely been responsible for adding special cases and perhaps we have enough examples where we can replace all these ad-hoc conversions with something more systematic. |
Thanks!
I think the ideal might be for |
No description provided.