-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[GUI] [linux] Support "ti.GUI(fast_gui=True)" for zero-copy while gui.set_image(img) #1922
Conversation
tremendous progress!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do a merge master
first? That should shrink the size of the PR
python/taichi/lang/meta.py
Outdated
u, v, w = min(255, max(0, int(img[i, img.shape[1] - 1 - j] * 255))) | ||
# We use i32 for |out| since OpenGL and Metal doesn't support u8 types | ||
# TODO: treat Cocoa and Big-endian machines, with XOR logic | ||
out[j * 1920 + i] = w + (v << 8) + (u << 16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
img.shape[1]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
img.shape[0]
actually.
Btw, I saw you use RGB order in cocoa.cpp, and BGR order in x11.cpp and win32.cpp. I want to know if mac actually use big-endian? If so, no changes need to be done here. Otherwise ti.static(ti.get_os_name() == 'osx')
would be used.
@@ -21,6 +21,16 @@ def cook_image_type(x): | |||
return x | |||
|
|||
|
|||
@ti.kernel | |||
def vector_to_fast_image(img: ti.template(), out: ti.ext_arr()): | |||
# FIXME: Why is ``for i, j in img:`` slower than: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know how much it was slower?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you reproduce it? I'm building right now. Will tell you asap. This is likely an issue of row-major / col-major, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. I was just curious if the slowness was just some noise or not. It does sound like row-major vs column-major could be a factor. Thanks for confirming!
Did you reproduce it?
I tried running the example, but all i got was a black screen.. (Tried both RGB and BGR). Given that the original image was of type ti.f32
, maybe that could be the reason? (Or do i actually need to pass fast_buf
somewhere for Cocoa?)
91507a9
to
9a8a53e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM + nits!
@@ -21,6 +21,16 @@ def cook_image_type(x): | |||
return x | |||
|
|||
|
|||
@ti.kernel | |||
def vector_to_fast_image(img: ti.template(), out: ti.ext_arr()): | |||
# FIXME: Why is ``for i, j in img:`` slower than: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. I was just curious if the slowness was just some noise or not. It does sound like row-major vs column-major could be a factor. Thanks for confirming!
Did you reproduce it?
I tried running the example, but all i got was a black screen.. (Tried both RGB and BGR). Given that the original image was of type ti.f32
, maybe that could be the reason? (Or do i actually need to pass fast_buf
somewhere for Cocoa?)
Yes, you need. This PR is only for x11. |
Co-authored-by: Ye Kuang <[email protected]>
Merging! FF2 do the Cocoa and Win32 part iapr :) |
Related issue = depends #1921
[Click here for the format server]
We can now obtain 60fps even with 1920x1080!
This would allow me to implement a real-time soft renderer in Taichi THREE!