-
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] Metal GGUI support & run metal ggui tests #8343
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Issue: # <!-- copilot:summary --> This pull request updates the RHI and GGUI modules to support both Vulkan and Metal backends for graphics and user interface functionalities. It adds new examples, shaders, and headers for the RHI module, and replaces the `taichi_ui_vulkan` library with the `taichi_ui_ggui` library. It also fixes some bugs, removes some unused code, and improves the code formatting and compatibility for the RHI and GGUI modules. <!-- copilot:walkthrough --> * Replace `taichi_ui_vulkan` library with `taichi_ui_ggui` library to use the new GGUI library that supports both Vulkan and Metal backends for the Taichi UI module ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-ddbed628f91a9ee8bb2f6af3cb6f4b793746b0cc8182bcd4513b6793e816f347L386-R386)) * Add conditional include of `common_metal.h` or `common_vulkan.h` depending on the CMake system name to use the appropriate header file for the Metal or Vulkan backend for the RHI examples ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-ce18c0b2ae4fee335806357f23ceb248ed7b32ab121fdd4f750e5856bfc65328L5-R9)) * Add a new example `sample_3_textured_triangle` to the CMake file to include the new example in the build process ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-ce18c0b2ae4fee335806357f23ceb248ed7b32ab121fdd4f750e5856bfc65328L28-R39)) * Add new header and source files `common_metal.h` and `common_metal.mm` to define and implement some common types and utilities for the Metal backend for the RHI examples ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c2200488f0fb2fc5f9b2d852cdf9dab73f8a03911dcfa0e854d6f97b43c1cbefR1-R30), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-b8acd5141334e03814080758436245c5f2e18e8c35b507214d37e91d8f50133eR1-R77)) * Modify the include statements in `sample_1_window.cpp` and `sample_2_triangle.cpp` to use the `common_vulkan.h` and `common_metal.h` header files instead of the `common.h` header file, which are more specific to the Vulkan and Metal backends respectively ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-f5e80908e1912664728078f2b0a50511d4c807b2738e12bca6e5a210ce609a2eL1-R2), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-49805b429c6c67e22573214b30ccc9657d8caa0348082e56427a85318d672d1bL1-R2)) * Add new source, header, and shader files `sample_3_textured_triangle.cpp`, `3_triangle.frag`, `3_triangle.frag.spv.h`, `3_triangle.vert`, and `3_triangle.vert.spv.h` to implement a new example that shows how to use textures with the RHI module ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-928a01d05781b44e3a14ade72e1cded1397fcb6296e5b032230f450f04c477dbR1-R277), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-e4ebde697c4962b56a040f309a93e1564b13d3e994895aaf9404811a147d3f41R1-R12), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-bbfd5e1adf18b3fb417282df1b87c5d83a3d750e9b9f0a757e146d2c656e5584R1-R41), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-bb661ff55d0c5f1c2cfe41f62b9d15f75524d01b72dc9e087532d5bc823a3875R1-R19), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-1b18019e7fad40aa42466d3798b8e1d43c6403063bb8a8b893b27412fbc89fe9R1-R63)) * Modify the SPIRV binary data in `2_triangle.frag.spv.h` to update the SPIRV version from 0x000d000a to 0x000d000b, which is required by the Metal backend ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-00e93cf0c366583599b5939d339f4b54098426859fc59ef4d2761cb76cfa4534L2-R2)) * Modify the `ti.init` call in `mass_spring_game_ggui.py` to use the Metal backend instead of the Vulkan backend for the GGUI module ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-e2756c236761fac4f823a8b6c11470369599a6189de1b8d1bb24edee2406b4c5L3-R4)) * Replace the `vulkan` namespace with the `ggui` namespace in the include statements in `export_ggui.cpp` to use the new GGUI library that supports both Vulkan and Metal backends for the Taichi UI module ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-de0a9a1fb6c6210ac5653025b79a982b6721b1c66e17d2dca1db90fa82613bddL16-R20)) * Add code to determine the GGUI backend based on the Taichi backend and to verify that Vulkan is available if the GGUI backend is Vulkan in the `PyWindow` struct in `export_ggui.cpp` ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-de0a9a1fb6c6210ac5653025b79a982b6721b1c66e17d2dca1db90fa82613bddR524-R536)) * Modify the `WindowConfig` constructor call in the `PyWindow` struct in `export_ggui.cpp` to pass the `ggui_arch` variable as an argument and to remove the redundant check for Vulkan availability ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-de0a9a1fb6c6210ac5653025b79a982b6721b1c66e17d2dca1db90fa82613bddL533-R548)) * Add code to expose the native Cocoa window handle in `window_system.h` to enable the Metal backend to access the native window handle for creating a Metal layer ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c0447b54db4ef2688c36b301c669203c6276ae622a4950271188e449b2c1af4bR5-R6)) * Add new Metal types to `metal_device.h` to define some Metal types that are used by the Metal backend for the RHI module ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-5b304e188996abd217fad85fd8b2434e729ad9c089eb9ef48a848c0fcc74d614L38-R64)) * Add a new method declaration to the `MetalCommandList` class in `metal_device.h` to declare a new method that creates a Metal render pass descriptor ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-5b304e188996abd217fad85fd8b2434e729ad9c089eb9ef48a848c0fcc74d614R392)) * Remove some method declarations from the `MetalSurface` and `RHI_DLL_EXPORT` classes in `metal_device.h` and `public_device.h` to remove some methods that are not implemented or needed by the Metal and RHI modules ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-5b304e188996abd217fad85fd8b2434e729ad9c089eb9ef48a848c0fcc74d614L443-L449), [link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-0290f4565dcad1ce884dc8e6377a55a36bdf13bc3914c2e9b9da039cd22dcdf1L889-L892)) * Modify the order of some statements in the `pre_draw_setup` method of the `MetalCommandList` class in `metal_device.mm` to avoid accessing the pixel format of a null texture pointer ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c350a27659df1ebcf2c854e2c21a80f82de87d3b325a80e00f6a6dd6ca53303bL538-R540)) * Split the `pre_draw_setup` method of the `MetalCommandList` class in `metal_device.mm` into two methods to separate the logic of creating a Metal render pass descriptor from the logic of setting up the Metal render command encoder and the render pipeline state ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c350a27659df1ebcf2c854e2c21a80f82de87d3b325a80e00f6a6dd6ca53303bL614-R615)) * Modify the parameter of the `create_render_pass_desc` method of the `MetalCommandList` class in `metal_device.mm` to use the `depth_write` parameter instead of the `raster_params` parameter, which is more specific and consistent with the method name ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c350a27659df1ebcf2c854e2c21a80f82de87d3b325a80e00f6a6dd6ca53303bL630-R630)) * Add code to release the Metal render pass descriptor and to return it from the `create_render_pass_desc` method of the `MetalCommandList` class in `metal_device.mm` to avoid memory leaks and to return the created Metal render pass descriptor to the caller ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c350a27659df1ebcf2c854e2c21a80f82de87d3b325a80e00f6a6dd6ca53303bL639-R651)) * Add code to set the Metal depth stencil state in the `pre_draw_setup` method of the `MetalCommandList` class in `metal_device.mm` to enable depth testing and depth writing for the Metal backend ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-c350a27659df1ebcf2c854e2c21a80f82de87d3b325a80e00f6a6dd6ca53303bR669-R676)) * Remove some method definitions from the `VulkanSurface` class in `vulkan_device.cpp` to remove some methods that are not implemented or needed by the Vulkan backend ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-4479f242ce99cd434c015531997155aa7faa38fb3ead6b0997caf097b05cecb8L2850-L2914)) * Add a newline character in the `MAKE_ENUM_FLAGS` macro in `public_device.h` to improve the code formatting and readability ([link](https://github.com/taichi-dev/taichi/pull/8338/files?diff=unified&w=0#diff-0290f4565dcad1ce884dc8e6377a55a36bdf13bc3914c2e9b9da039cd22dcdf1L58-R60)) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bob Cao <[email protected]>
…into metall-ggui-wip
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
bobcao3
changed the title
[ui] Metal GGUI support & run metal ggui tests
[gui] Metal GGUI support & run metal ggui tests
Aug 31, 2023
for more information, see https://pre-commit.ci
…into metall-ggui-wip
for more information, see https://pre-commit.ci
…into metall-ggui-wip
AntonioFerreras
approved these changes
Sep 3, 2023
AntonioFerreras
added a commit
that referenced
this pull request
Sep 3, 2023
This reverts commit aa0619f.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #
Brief Summary
Implemented by @AntonioFerreras
Walkthrough
🤖 Generated by Copilot at 4d41154