taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.52k stars 2.28k forks source link

Add more IMGUI widgets for GGUI #3013

Open AmesingFlank opened 3 years ago

AmesingFlank commented 3 years ago

Concisely describe the proposed feature Currently, GGUI only supports 5 basic widgets (text,button,check_box,slider_float,color_edit_3). It would be nice to have support for more complicated widgets such as drop-down menus, menu bars, etc.

Describe the solution you'd like (if any) GGUI uses dear imgui internally. It's quite simple to write a wrapper for a widget. Take button for example, here are all the relevant code:

https://github.com/taichi-dev/taichi/blob/2f5c9dfa5c52bc7e69e6c9ce3c8d443e69e769cf/taichi/ui/common/gui_base.h#L22 https://github.com/taichi-dev/taichi/blob/2f5c9dfa5c52bc7e69e6c9ce3c8d443e69e769cf/taichi/ui/backends/vulkan/gui.h#L43 https://github.com/taichi-dev/taichi/blob/2f5c9dfa5c52bc7e69e6c9ce3c8d443e69e769cf/taichi/ui/backends/vulkan/gui.cpp#L159-L164 https://github.com/taichi-dev/taichi/blob/2f5c9dfa5c52bc7e69e6c9ce3c8d443e69e769cf/taichi/python/export_ggui.cpp#L60-L62 https://github.com/taichi-dev/taichi/blob/2f5c9dfa5c52bc7e69e6c9ce3c8d443e69e769cf/python/taichi/ui/gui.py#L68-L74

gaocegege commented 3 years ago

Hi, I am new to Taichi and glad to help improve it.

I will start from an easy widget, maybe colored text. But I do not want to dibs the whole issue. Other people can also work on it since there are so many widgets in dear imgui, if I have understood well.

gaocegege commented 3 years ago

Additional info for the issue:

gaocegege commented 3 years ago

@AmesingFlank Hi, it seems that there is only the Vulkan backend for GGUI, then why do we need to enable CUDA to compile GGUI here? https://github.com/taichi-dev/taichi/blob/master/cmake/TaichiCore.cmake#L36

set(TI_WITH_GGUI OFF)
if(TI_WITH_CUDA AND TI_WITH_VULKAN)
    set(TI_WITH_GGUI ON)
endif()
AmesingFlank commented 3 years ago

@AmesingFlank Hi, it seems that there is only the Vulkan backend for GGUI, then why do we need to enable CUDA to compile GGUI here? https://github.com/taichi-dev/taichi/blob/master/cmake/TaichiCore.cmake#L36

set(TI_WITH_GGUI OFF)
if(TI_WITH_CUDA AND TI_WITH_VULKAN)
    set(TI_WITH_GGUI ON)
endif()

Currently, the Vulkan backend for GGUI is only works with the CUDA/x64 compute backend of taichi. That is, you need ti.init(arch=ti.cuda) or ti.init(arch=ti.x64) for GGUI to work. This will be changed in the near future, as we are planning support for GGUI to work with other compute backends such as Vulkan itself and OpenGL.

gaocegege commented 3 years ago

OK, get it.

Thanks for your reply.

gaocegege commented 3 years ago

Hi @AmesingFlank

Do we have tests for GGUI? I am trying to add some new test cases for the widget, but I did not find any.

AmesingFlank commented 3 years ago

Hi @AmesingFlank

Do we have tests for GGUI? I am trying to add some new test cases for the widget, but I did not find any.

We don't, adding tests for GGUI is on the top of my to-do list right now, but I just haven't found the time to do it :((

gaocegege commented 3 years ago

I am trying to add a colored text widget. You can take it as an example https://github.com/taichi-dev/taichi/pull/3078/files about how to add a new GGUI widget in Taichi. There are so many widgets not supported now. Welcome contributions!

I am unassigning myself since it is an umbrella issue.