AcademySoftwareFoundation / OpenImageIO

Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.

Home Page:https://openimageio.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE REQUEST] OIIO::ImageBufAlgo::make_texture doesn't take an nthreads argument

etheory opened this issue · comments

https://openimageio.readthedocs.io/en/stable/imagebufalgo.html says:
All ImageBufAlgo functions take an optional nthreads parameter that signifies the maximum number of threads to use to parallelize the operation. The default value for nthreads is 0, which signifies that the number of thread should be the OIIO global default set by OIIO::attribute() (see Section [Global Attributes](https://openimageio.readthedocs.io/en/stable/imageioapi.html#sec-globalattribs)), which itself defaults to be the detected level of hardware concurrency (number of cores available).

But this is not true for make_texture. In the renderer my company uses, we do texture conversions automatically on scene load, concurrently with using multiple OpenImageIO clients via the shared TextureSystem. As such, we are beholden to whatever another client may have set nthreads to globally when calling make_texture.

How hard would it be to add an nthreads argument to make_texture, and why doesn't it already have one when the docs say it should do?

Thanks!

Is your feature request related to a problem? Please describe.
Texture conversion thread usage being separable from other client usage of OIIO.

Describe the solution you'd like
An nthreads argument for make_texture.

Describe alternatives you've considered
Running maketx from the command line with an nthreads comment in a sys shell from C++ (urgh, no thanks).

Additional context
I could make a PR, but before I do that, I'm wondering if there was a good reason this wasn't the case already, to prevent me "finding out the hard way".

I think it's just an oversight.

If I had to guess about the origin of this, I'd say that probably some version of make_texture predated IBA, or at least predated the addition of the nthreads parameter nearly universally in IBA functions. At some point, we moved it to imagebufalgo.h and recategorized it conceptually as an IBA function, but failed to make it conform to the usual calling convention for IBA, which is to have the last argument be nthreads.

Please do feel free to fix this in a PR, I think it's obviously the right thing to do.

Thanks @lgritz, I'll give it a crack.