-
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] Add GGUI set_image support for non-Vector fields and numpy ndarrays. #5654
Conversation
fixing copy range typo in copy_image_u8_to_rgba8; adding numpy ndarray src support
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
for more information, see https://pre-commit.ci
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.
Really good job! Thanks a lot for your contribution, I still have some doubts here if we can improve it.
Sorry, there have been some confilcts with others whose commitment include adding support for image texture type, I fix some confilcts, may you help to check it? |
add test for flat fields
for more information, see https://pre-commit.ci
Sure, I rewrite some lines to improve the readability. Additionally, I created a test for flat fields in
However, in case I actually use a numpy ndarray as input, it just worked fine, I'm really confused. My numpy test code was like: @pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available")
@test_utils.test(arch=supported_archs)
def test_set_image_flat_field():
window = ti.ui.Window('test', (640, 480), show_window=False)
canvas = window.get_canvas()
img = ti.field(ti.f32, (512, 512, 4))
@ti.kernel
def init_img():
for i, j in ti.ndrange(img.shape[0], img.shape[1]):
img[i, j, 0] = i / 512
img[i, j, 1] = j / 512
img[i, j, 2] = 0
img[i, j, 3] = 1.0
init_img()
def render():
canvas.set_image(img.to_numpy())
for _ in range(RENDER_REPEAT):
render()
write_temp_image(window)
render()
verify_image(window, 'test_set_image')
window.destroy() I'm not quite familiar with taichi kernel code, wondering if u could help me solve it. |
The problem is due to this line Here is a simple test: import taichi as ti
ti.init(arch=ti.vulkan)
@ti.kernel
def test_loop_under_vulkan(test_arr : ti.types.ndarray()):
for i, j in ti.ndrange(test_arr.shape[0], test_arr.shape[1]):
pass
ti_arr = ti.ndarray(ti.f32, (3,3,3))
test_loop_under_vulkan(ti_arr) |
for more information, see https://pre-commit.ci
Thx for reviewing, I've applied all your suggestion. |
So that's strange, cause I success with |
Related issue = close #5633
Fixing the issue and adding additional support for flat fields like (400, 400, 3). Also, I implemented support for numpy.ndarray following the document.