GPU texture system prototype#5228
Conversation
|
|
d2e27d0 to
a4b4e67
Compare
|
Here is the README, btw https://github.com/imageworks/OpenImageIO/blob/gputex/testsuite/texture-device/README.md |
0d84c77 to
00ba9bb
Compare
Implemented as a standalone testsuite prototype, without modifying the core OpenImageIO library, this work demonstrates the proposed data model and runtime design in a working executable that already produces images. The prototype validates the host/device architecture end to end: request-driven texture lookup, residency updates, retry flow, filtering behavior, and output generation. It is intentionally scoped to the testsuite so we can iterate quickly on API shape, data structures, and execution strategy before promoting pieces into library code. More details in README.md, started from SPEC.md. Designed and written by me, assisted by gpt-5.3-codex in copilot. Signed-off-by: Alejandro Conty <aconty@imageworks.com>
lgritz
left a comment
There was a problem hiding this comment.
I see where you're going with this, and LGTM. The threshold is pretty low since this is just a testsuite experiment for now, so by no means does anything need to be perfect or final.
I made a number of comments, but really it's nothing that we can't fix up as we continue to work on it, if you are inclined to address any of it in subsequent PRs rather than now.
I would like to discuss it at the TSC meeting today before we merge it, to make sure nobody has any reservations.
One overarching comment/question -- would it be a big simplification to the scheme (and would it be feasible and performant on today's HW) to use unified/managed memory rather than separate allocations and explicit copies?
| inline uint64_t | ||
| ptrtag(const char* s) | ||
| { | ||
| if (!s || !s[0]) | ||
| return 0; | ||
| return OIIO::Strutil::strhash64(std::strlen(s), s); | ||
| } | ||
|
|
||
| template<size_t N> | ||
| inline constexpr uint64_t | ||
| ptrtag(const char (&s)[N]) | ||
| { | ||
| static_assert(N > 1, "tag literal must be non-empty"); | ||
| return OIIO::Strutil::strhash64(N - 1, s); | ||
| } |
There was a problem hiding this comment.
Does the string_view overload of Strutil::strhash64 subsume both of these?
| template<class T, size_t N> struct vector_lite : public std::array<T, N> { | ||
| using Base = std::array<T, N>; |
There was a problem hiding this comment.
C++26 includes a new inplace_vector<> that I think is the same as this. If so, we should adopt their nomenclature and as much of the semantics as makes sense.
I'm a little suspicious of it being is-a std::array versus has-a. Is it just to save a few lines by not having to repeat operator[] and the like? Are we inadvertently inheriting anything from std::array that we wouldn't want here?
There was a problem hiding this comment.
Will do that change.
|
|
||
| void push_back(const T& value) | ||
| { | ||
| assert(m_size < N); |
There was a problem hiding this comment.
I would prefer OIIO_CONTRACT_ASSERT these days.
| std::vector<std::string> m_texture_paths; | ||
| std::unordered_map<std::string, TextureMetadata> m_metadata_cache; |
There was a problem hiding this comment.
Would these be better as ustring? (asking; I do not yet have a strong opinion)
| return loader_error("unsupported tile size for " + filename + " got " | ||
| + std::to_string(spec.tile_width) + "x" | ||
| + std::to_string(spec.tile_height) + " expected " | ||
| + std::to_string(TileRecord::kTileWidth) + "x" | ||
| + std::to_string(TileRecord::kTileHeight)); |
There was a problem hiding this comment.
Strutil::format is probably more idiomatic for OIIO than string::operator+ (and almost certainly much faster). If we want to be really fancy, we can make loader_error itself format input instead of passing an already formatted string.
|
Needless to say, there are a whole bunch of things here that are idiomatically different from TextureSystem (in implementation as well as in use). I'm noting that here only to say that as we eventually make this all part of TS, we'll probably want to revisit which should become more like the other, or if TS should support multiple usage idioms. For example, should TS, even on the CPU, have a set of texture lookup calls that have a "texture not resident" result rather than being obligated to load it within the texture lookup? And a "here are a set of tiles we need, go get them all as efficiently as possible" function. It would be interesting to know how that approach to texture compares to what we're doing now, maybe we'd find it to be the method of choice no matter which HW you're running on. |
|
Your unified memory support comment got me thinking. I'm going to spin this a bit more because I think I can do that and also simplify. The API design, yes, probably better to discuss that live. |
Description
Implemented as a standalone testsuite prototype, without modifying the core OpenImageIO library, this work demonstrates the proposed data model and runtime design in a working executable that already produces images.
The prototype validates the host/device architecture end to end: request-driven texture lookup, residency updates, retry flow, filtering behavior, and output generation. It is intentionally scoped to the testsuite so we can iterate quickly on API shape, data structures, and execution strategy before promoting pieces into library code.
More details in README.md, started from SPEC.md. Designed and written by me, assisted by gpt-5.3-codex in copilot.
Nobody wanted to jump into this task, including myself. So I wrote a prototype SPEC for AI to do it. Since I didn't like where it was going I took full control. of it and ended up enjoying the job a lot. Came up with a couple of patterns that I like a lot. My aim was simplicity and clarity. Hope you people like it.
Tests
The prototype itself is a test. This doesn't interfere with the rest of the library.
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
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.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.