Skip to content
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

[BUG] oiiotool tile issue with otex and prman #4562

Closed
MrLixm opened this issue Dec 11, 2024 · 3 comments
Closed

[BUG] oiiotool tile issue with otex and prman #4562

MrLixm opened this issue Dec 11, 2024 · 3 comments

Comments

@MrLixm
Copy link

MrLixm commented Dec 11, 2024

Describe the bug

I have a strange behvior when using oiiotool with the -otex option.

I am trying to export "tex" textures for renderman using oiiotool (and intentionnaly not maketx).
What I found is that I need to manually set the --tile to 32 32 for the texture to be read properly by prman.
However I found that the tile option only works if I force the bitdepth with -d.

OpenImageIO version and dependencies

I tested on 2 oiio version:

  • hoiiotool shipped Houdini 20.5.332 on Windows
OIIO 2.3.14 built for C++17/201703 sse2
  • oiiotool compiled on linux
OIIO 2.5.7.0 built for C++14/201402 sse2,sse3,ssse3,sse41,sse42

To Reproduce

oiiotool texture.exr --planarconfig separate --tile 32 32 -otex:prman_metadata=1:prman_options=1:resize=1 texture.exr

doesn't work the tile size is still 64x64 (inspected with oiiotool -v --info)

oiiotool texture.exr --planarconfig separate --tile 32 32 -d half -otex:prman_metadata=1:prman_options=1:resize=1 texture.exr

now work, the tile size is 32x32

(the same behavior is observed with the -otex:tile=32x32:type=half syntax)

Hints

What I also found is that removing the prman options also seems to fix it, i.e.

oiiotool texture.exr --planarconfig separate --tile 32 32 -otex texture.exr

will work

@jessey-git
Copy link
Contributor

OpenImageIO calculates the prman tile size based on the data format that is used. See here:
https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/main/src/libOpenImageIO/maketexture.cpp#L72

That code would explain why you only get 32x32 when using half etc.

The values used have been untouched for 12 years. I can't quite find any definitive documentation about what tile sizes are acceptable though. Maybe they are out of date?

@pleprince
Copy link

This is not a bug. Prman's texture cache uses fixed-size slots. This is a feature.

@lgritz
Copy link
Collaborator

lgritz commented Jan 3, 2025

That's right, PRMan has only one tile size it will accept for each data type. If you use the "prman" option to maketx, it will know to use the right one and you shouldn't try to override it.

Closing because I don't think this is a bug.

Interesting history: This was a deliberate design decision in PRMan history 35+ years ago to make PRMan's textures always have tile size of exactly 4k. I take it for granted that it was based on empirical tests that showed it was optimal for whatever hardware they were using at the time. Perhaps it exactly corresponded to some virtual memory page size or the transfer or caching unit size for some particular disk or OS flavor? But I don't think we should put much credence into that being the best choice today. Fifteen years ago, my tests indicated that 64x64 tiles were approximately best regardless of the data type or memory page size or compression, so that's what maketx defaults to creating when not using the 'prman' option (the TS will accept any tile size). But I dunno, I can't say confidently that on today's platforms this is the one best choice. OIIO will happily accept any tile size it's presented with, so I encourage people to test using their typical hardware, platform, and networking (and probably also important to investigate its relation to compression method) and determine the best size for them.

@lgritz lgritz closed this as completed Jan 3, 2025
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

No branches or pull requests

4 participants