-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
hioOiio: remove use of deprecated API to support OpenImageIO v3.0.0.3 #3418
base: dev
Are you sure you want to change the base?
hioOiio: remove use of deprecated API to support OpenImageIO v3.0.0.3 #3418
Conversation
ImageIOParameter has been a simple alias for ParamValue since at least OpenImageIO 2.0.
@@ -713,13 +713,27 @@ HioOIIO_Image::ReadCropped(int const cropTop, | |||
// If needed, convert double precision images to float | |||
bool res = false; | |||
if (imageInput->spec().format == TypeDesc::DOUBLE) { | |||
res = imageInput->read_image(TypeDesc::FLOAT, | |||
res = imageInput->read_image( | |||
#if OIIO_VERSION >= 30000 |
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.
We could probably push this farther back in OIIO versions if we wanted to, as the overload that was being used was implemented this way fairly early in the 2.x series as far as I can tell. For now I opted to restrict it to just handling the build breakage, but let me know if I should try to trace back to an earlier version.
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.
@mattyjams in https://github.com/PixarAnimationStudios/OpenUSD/pull/3365/files @jessey-git has the same-ish changes. I notice you have got imageInput->current*, and @jessey-git has _subimage
, and _miplevel
instead. @jessey-git hasn't ifdef'd this block. so I'm wondering if we can reconcile these two PRs
- should it be
imageInput->
or_whatever
? - can we still support 2.x and remove the ifdef's?
thanks!
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.
Ahh, sorry for the duplicate PR @meshula! This is indeed very similar to #3365.
In my case here, I followed the implementation of the read_image()
overload we had been using as of the most recent 2.x release (now 2.5.17.0) to try to ensure that we were passing through exactly the same code as before, so that's where I got the current_subimage()
and current_miplevel()
calls from:
https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/v2.5.17.0/src/libOpenImageIO/imageinput.cpp#L894
It may not make a practical difference, but current_subimage()
and current_miplevel()
are both virtual
in ImageInput
, so it seems possible that in some exotic case they could be more than just simple accessors?:
https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/v3.0.0.3/src/include/OpenImageIO/imageio.h#L1153
And doing a bit of version spelunking, I think we should be safe to remove the preprocessor stuff if we're committing to only supporting 2.x+. The versioning in OpenImageIO gets a little tricky to follow going back this far, but I think the Release-2.0.0-beta1
tag would be closest to the earliest 2.x version? If that's correct, then the overload of read_image()
we'd use with this change is available there such that we don't need to guard this:
https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/Release-2.0.0-beta1/src/include/OpenImageIO/imageio.h#L948
The other nice thing is that the format
member of ImageSpec
is still a TypeDesc
there, so I was also able to collapse the conditional down to just determining the format.
Let me know what you think now! Thanks!
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.
Heya, the reason I decided to use _subimage, _miplevel
is that we already use those when making the seek_subimage
check on line 691 of the same file. Whichever way we go, can we make both call sites match (I think they should match)?
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.
Actually, this way is probably fine really. You can disregard my post above :)
@@ -289,7 +289,7 @@ _FindAttribute(ImageSpec const & spec, std::string const & metadataKey) | |||
bool convertMatrixTypes = false; | |||
std::string key = _TranslateMetadataKey(metadataKey, &convertMatrixTypes); | |||
|
|||
ImageIOParameter const * param = spec.find_attribute(key); | |||
ParamValue const * param = spec.find_attribute(key); |
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.
I did not add any preprocessor checking here, since it looks like the ImageIOParameter
alias was in place (and already deprecated) at least as far back as OpenImageIO 2.0:
https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/88df1f55795f79db0c702892fcb311a16509dc04/src/include/OpenImageIO/imageio.h#L106
I'm not sure if anyone is still building against a 1.x version of OpenImageIO, but I can try to distill an OIIO_VERSION
to use as a guard here if that's needed.
These look great, Matt. I think it's fairly unlikely anyone is still using OIIO 1.x while also using a recent version of USD. Larry deprecated 1.x in 2018, https://lists.aswf.io/g/oiio-dev/topic/openimageio_2_0_has_arrived/99728437 So while I defer to Pixar's judgement, I think it would be fine to assume 2.x as the baseline. |
Filed as internal issue #USD-10426 |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
As of OpenImageIO v3.0.0.3, a set of deprecated overloads of ImageInput::read_image() were removed. This change unrolls the overload that was being used into its equivalent in the current API, which was also available in OpenImageIO 2.x.
4b919c6
to
e3b7185
Compare
@mattyjams @jessey-git Are you two both fine with resolving a single changelist here? You'll both be listed as authors in the final commit. |
That seems fine with me. Is there anything you need me to do? |
Yes, when you are both happy with the PR here, please leave a comment to that effect :) |
Sounds good to me, thanks @meshula! This PR is ready to go from my end. |
I left a comment above in the thread about my choice of |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
I am also ok with this PR. I took another look and this all seems fine. |
Ahh, sorry I missed that @jessey-git! At that point, Apologies for my ignorance with OpenImageIO, but are there cases where Otherwise, are you saying that you'd prefer we use |
@mattyjams Your understanding is correct and this PR is fine I think. I don't believe, and wouldn't expect, there to be any dissonance between the values passed into |
This fixes up a few usages of long-deprecated OpenImageIO API to allow building against OpenImageIO v3.0.0.3, where those bits of API were finally removed.
This OpenImageIO commit in particular is where the deprecated API was removed:
AcademySoftwareFoundation/OpenImageIO@a4a759f
Checklist
[x] I have created this PR based on the dev branch
[x] I have followed the coding conventions
[ ] I have added unit tests that exercise this functionality (Reference:
testing guidelines)
[x] I have verified that all unit tests pass with the proposed changes
[x] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)