Skip to content

api(deepdata): widen merge_deep_pixels srcpixel to int64_t#5252

Merged
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
luna-y-kim:fix-deepdata-abi-break
Jun 23, 2026
Merged

api(deepdata): widen merge_deep_pixels srcpixel to int64_t#5252
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
luna-y-kim:fix-deepdata-abi-break

Conversation

@luna-y-kim

@luna-y-kim luna-y-kim commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

To avoid breaking ABI, the old int overload is kept, but its declaration is hidden behind #ifdef OIIO_INTERNAL. Downstream code only sees the int64_t version, but old binaries still work. The forwarding wrapper handles it until the next first-digit version changes.

Also, the Python binding is adjusted using a wrapper to resolve the overload ambiguity. While adding the wrapper, I noticed other bindings still took int pixel, so widened them to int64_t for consistency.

Follow-up to #2363
Fixes #5242

Tests

N/A

Checklist:

  • I have read the guidelines on contributions and code review procedures.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • (N/A) I have updated the documentation if my PR adds features or changes
    behavior.
  • (N/A) I am sure that this PR's changes are tested in the testsuite.
  • I have run and passed the testsuite in CI before submitting the
    PR, by pushing the changes to my fork and seeing that the automated CI
    passed there. (Exceptions: If most tests pass and you can't figure out why
    the remaining ones fail, it's ok to submit the PR and ask for help. Or if
    any failures seem entirely unrelated to your change; sometimes things break
    on the GitHub runners.)
  • My code follows the prevailing code style of this project and I
    fixed any problems reported by the clang-format CI test.
  • If I added or modified a public C++ API call, I have also amended the
    corresponding Python bindings. If altering ImageBufAlgo functions, I also
    exposed the new functionality as oiiotool options.

Comment on lines +191 to +192
void merge_deep_pixels(int64_t pixel, const DeepData& src,
int64_t srcpixel);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid the ABI break by just not removing the old one at all? Just add the new one, and change the implementation of the old one to call the new one. Leave a comment on the old one indicating that we intend to deprecate it. So the idiom is like this:

    /// full comments
    void func(int64_t);

    // DEPRECATED(3.2): use the version with int64_t
    void func(int);

does that work? Or do you just get warnings everywhere about ambiguous arguments?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I think this is even better:

    /// full comments
    void func(int64_t);

#ifdef OIIO_INTERNAL
    // DEPRECATED(3.2): use the version with int64_t
    void func(int);
#endif

This hides the declaration from external/downstream clients of OIIO when they recompile. They will only see the int64_t version, which if they pass an int32, will just transparently accept it. So starting from their next recompile, they will start using the new function, without having to do anything.

Meanwhile, internally we still declare and implement the old function. Which means that ABI is preserved, the library exports all the same symbols it used to, and an existing program that calls the old function will continue to link properly against a new copy of libOpenImageIO.

When we eventually have OIIO 4.0, we'll chase down all those "DEPRECATED" comments and finally remove the functions entirely (because we don't guarantee any compatibility at first-digit version changes).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I should point out that it's only because the change is specifically int -> int64_t, which is a widening that is implicitly accepted by the compiler without warning, that we are able to do this trick and something like func(my_int) will just work and know to call func(int64_t). If we were changing int to uint64_t, or doing some other change that wouldn't just implicitly cast, we'd be in a more complex situation.)

@luna-y-kim luna-y-kim Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it silently rebinds downstream code to the new int64_t overload with no changes on their side! (Of course because this is the int -> int64_t case as you mentioned.) Thanks, it's a cool tip!

does that work? Or do you just get warnings everywhere about ambiguous arguments?

It works! No ambiguity at the call sites. The Python binding needed a small change due to the ambiguous overload. I fixed it with a wrapper as the other overloaded functions already do.

@luna-y-kim luna-y-kim marked this pull request as draft June 23, 2026 04:42
@luna-y-kim luna-y-kim changed the title fix!: int pixel to int64_t in deepdata api(deepdata): widen merge_deep_pixels srcpixel to int64_t Jun 23, 2026
@luna-y-kim luna-y-kim force-pushed the fix-deepdata-abi-break branch from 393dad6 to 1317900 Compare June 23, 2026 04:45
@luna-y-kim luna-y-kim marked this pull request as ready for review June 23, 2026 05:33

@lgritz lgritz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like it works great!
LGTM.

To avoid breaking ABI, the old int overload is kept, but its declaration
is hidden behind `#ifdef OIIO_INTERNAL`. Downstream code only sees
the int64_t version, but old binaries still work. The forwarding wrapper
handles it until the next first-digit version changes.

Also, Python binding is adjusted using a wrapper to resolve the
overload ambiguity.

Follow-up to AcademySoftwareFoundation#2363
Fixes AcademySoftwareFoundation#5242

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
@lgritz lgritz force-pushed the fix-deepdata-abi-break branch from 1317900 to 2dad3ce Compare June 23, 2026 20:32
@lgritz

lgritz commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

I'm going to rebase this and watch the CI before I merge, just in case it interferes in any way with the other deep related patch I just merged from you.

@lgritz lgritz merged commit 83fb484 into AcademySoftwareFoundation:main Jun 23, 2026
60 checks passed
@luna-y-kim luna-y-kim deleted the fix-deepdata-abi-break branch June 23, 2026 22:30
luna-y-kim added a commit to luna-y-kim/OpenImageIO that referenced this pull request Jun 29, 2026
…CARD_ERROR

`merge_deep_pixels()` calls `copy_deep_sample()`, which has an error
status return, so change `merge_deep_pixels()`'s return type from void
to bool.

For OIIO_NODISCARD_ERROR, all internal calls that previously ignored
return values are handled:
 - OIIO_CONTRACT_ASSERT where the call can't fail in context, or the
   caller is a void function or a constructor.
 - `return false` where the caller already returns a bool error state.
 - `(void)` cast for the deprecated internal overload.

Follow-up to AcademySoftwareFoundation#5252
Part of AcademySoftwareFoundation#4781

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
lgritz pushed a commit that referenced this pull request Jul 1, 2026
…RD_ERROR (#5253)

`merge_deep_pixels()` calls `copy_deep_sample()`, which has an error
status return, so change `merge_deep_pixels()`'s return type from void
to bool.
    
For OIIO_NODISCARD_ERROR, all internal calls that previously ignored
return values are handled:
- OIIO_CONTRACT_ASSERT where the call can't fail in context, or the
caller is a void function or a constructor.
 - `return false` where the caller already returns a bool error state.
 - `(void)` cast for the deprecated internal overload.
    
Follow-up to #5252
Part of #4781

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jul 1, 2026
…ftwareFoundation#5252)

To avoid breaking ABI, the old int overload is kept, but its declaration
is hidden behind `#ifdef OIIO_INTERNAL`. Downstream code only sees the
int64_t version, but old binaries still work. The forwarding wrapper
handles it until the next first-digit version changes.

Also, the Python binding is adjusted using a wrapper to resolve the
overload ambiguity. While adding the wrapper, I noticed other bindings
still took `int pixel`, so widened them to `int64_t` for consistency.

Follow-up to AcademySoftwareFoundation#2363
Fixes AcademySoftwareFoundation#5242

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jul 1, 2026
…RD_ERROR (AcademySoftwareFoundation#5253)

`merge_deep_pixels()` calls `copy_deep_sample()`, which has an error
status return, so change `merge_deep_pixels()`'s return type from void
to bool.
    
For OIIO_NODISCARD_ERROR, all internal calls that previously ignored
return values are handled:
- OIIO_CONTRACT_ASSERT where the call can't fail in context, or the
caller is a void function or a constructor.
 - `return false` where the caller already returns a bool error state.
 - `(void)` cast for the deprecated internal overload.
    
Follow-up to AcademySoftwareFoundation#5252
Part of AcademySoftwareFoundation#4781

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: srcpixel param of DeepData::merge_deep_pixels should be int64_t (breaks ABI)

2 participants