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

Add Python GPU renderer implementation example #1493

Merged

Conversation

michdolan
Copy link
Collaborator

From discussion in Slack #dev channel about how to implement the OCIO GPU renderer in Python, this is a trimmed down version of an image viewer I wrote while stress testing the OCIO v2 Python bindings last year. It implements the OCIO GPU renderer with dynamic parameters for exposure and gamma adjustment. The goal here is to show just the pieces that need to be implemented for a functional and performant viewer GUI, which is quite a bit of code, but demonstrates the OCIO API in context, along with all the glue code needed to interface with the other Python libraries used here.

As @hodoulp mentioned in Slack, we should reimplement oglapphelpers in Python, which much of the rendering code in this module was adapted from. This module would be greatly reduced with that, leaving mostly Qt GUI code, but in the meantime this can serve as a working example.

Signed-off-by: Michael Dolan michdolan@gmail.com

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 15, 2021

CLA Signed

The committers are authorized under a signed CLA.

Signed-off-by: Michael Dolan <michdolan@gmail.com>
@KelSolaar
Copy link
Contributor

Fantastic, this is extremely useful!

I hope we can also discuss some level of abstraction so that for a end user it can be as simple as calling apply on the GPU processor.

@hodoulp
Copy link
Member

hodoulp commented Sep 16, 2021

[Question] Why not creating an apps (like ociocheck, ociodisplay, etc.) ?
So, the Python app could be improved when oglapphelpers.py library is ready and also installed like any other apps. My concern is that an 'not used' example becomes deprecated at some point like an example in the documentation for example.

@michdolan
Copy link
Collaborator Author

I could rebrand this example as pyociodisplay and move it to the apps folder, refining it over time.

@remia
Copy link
Collaborator

remia commented Sep 16, 2021

Thanks for sharing @michdolan ! I'm working on having it work on macOS, will report when succeeded. Would be great for it to support all 3 major platforms.

Edit: I also removed the imath dependency using numpy instead as I find it more difficult to setup (I had to compile it myself because brew doesn't ship the python bindings).

share/python/examples/gpu_viewer.py Outdated Show resolved Hide resolved
share/python/examples/gpu_viewer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zachlewis zachlewis left a comment

Choose a reason for hiding this comment

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

This is so helpful. Thanks guys. This dovetails really nicely with aspects of @hodoulp's and @michdolan's Siggraph presentations. I'd been struggling a little with figuring out what I needed to figure out vis a vis the bare minimum OpenGL + Qt to realize the python OCIO GPU image viewer of my dreams... and it looks like, in retrospect, I probably would have been better served by just biting the bullet and grokking oglapphelpers and ociodisplay.

It's really great to see how all the pieces fit together -- I have a whole new level of appreciation for the GPU processor design and API. For example, and maybe this is intuitive to those with more experience with OpenGL, but I had no idea the GPU path represented large Lut1Ds as 2D textures. Damn clever, and probably something that would have caused me grief if left to my own devices.

Anyway, thanks! Confirmed working quite well on macOS with Remi's tweaks (and imath bindings).

@hodoulp
Copy link
Member

hodoulp commented Sep 30, 2021

@michdolan This pull request is the next one to be merged. But there is still the question about the location, and a second one (at my point of view) would be to document how to run it (or create a CMakeLists.txt with dependencies).

@michdolan
Copy link
Collaborator Author

@hodoulp I will move this and add a README.

michdolan and others added 2 commits October 17, 2021 23:08
@hodoulp hodoulp merged commit 4a6745a into AcademySoftwareFoundation:master Oct 18, 2021
hodoulp added a commit that referenced this pull request Oct 18, 2021
* Add Python GPU renderer implementation example

Signed-off-by: Michael Dolan <michdolan@gmail.com>

* Move to apps with README

Signed-off-by: Michael Dolan <michdolan@gmail.com>

Co-authored-by: Patrick Hodoul <patrick.hodoul@autodesk.com>
Co-authored-by: Rémi Achard <remiachard@gmail.com>
hodoulp added a commit that referenced this pull request Oct 21, 2021
* Add Python GPU renderer implementation example

Signed-off-by: Michael Dolan <michdolan@gmail.com>

* Move to apps with README

Signed-off-by: Michael Dolan <michdolan@gmail.com>

Co-authored-by: Patrick Hodoul <patrick.hodoul@autodesk.com>
Co-authored-by: Rémi Achard <remiachard@gmail.com>

Co-authored-by: Michael Dolan <michdolan@gmail.com>
Co-authored-by: Rémi Achard <remiachard@gmail.com>
@michdolan michdolan deleted the py_gpu_render_example branch July 26, 2023 22:19
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.

None yet

5 participants