[PR #268] Add closest_hit_on_mesh CUDA op #272

Open
opened 2026-10-26 22:22:20 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/268
Author: @kijai
Created: 10/22/2026
Status: 🔄 Open

Base: main ← Head: ray-cast


📝 Commits (2)

  • 2578373 Add closest_hit_on_mesh CUDA op
  • df85a70 Drop unused ray test variable

📊 Changes

6 files changed (+343 additions, -4 deletions)

View changed files

📝 README.md (+1 -0)
📝 comfy_kitchen/__init__.py (+18 -1)
📝 comfy_kitchen/backends/cuda/__init__.py (+28 -0)
📝 comfy_kitchen/backends/cuda/dlpack_bindings.cpp (+15 -0)
📝 comfy_kitchen/backends/cuda/ops/mesh_bvh.cu (+118 -3)
📝 tests/test_mesh_bvh.py (+163 -0)

📄 Description

Nearest ray hit on a mesh_bvh, used for ray casting. Major speedups for any rendering nodes.

Performance

ComfyUI mesh nodes on an RTX 5090, Pixal3D jester mesh (0.70M triangles), pure-torch BVH vs comfy-kitchen.
End-to-end node timings, the kitchen side also builds its BVH with mesh_bvh.

Node Torch BVH comfy-kitchen Speedup
RenderMesh, 12 views at 1024 7.5 s 0.09 s ~80×
RenderMesh, 6 views at 1024 3.58 s 0.14 s ~25×
Ambient occlusion 2.64 s 0.33 s ~8×
Bake Texture From Views 3.99 s 0.67 s ~6×

The bake gains least because ray casting is only its depth pass. Kernel alone: 8M rays against 0.70M triangles in 4.6 ms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-kitchen/pull/268 **Author:** [@kijai](https://github.com/kijai) **Created:** 10/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ray-cast` --- ### 📝 Commits (2) - [`2578373`](https://github.com/Comfy-Org/comfy-kitchen/commit/257837393b0d00eac7fb86a31c0117f5477bfe6f) Add closest_hit_on_mesh CUDA op - [`df85a70`](https://github.com/Comfy-Org/comfy-kitchen/commit/df85a701ef04f8e014a1a5fb733ef508869dc209) Drop unused ray test variable ### 📊 Changes **6 files changed** (+343 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) 📝 `comfy_kitchen/__init__.py` (+18 -1) 📝 `comfy_kitchen/backends/cuda/__init__.py` (+28 -0) 📝 `comfy_kitchen/backends/cuda/dlpack_bindings.cpp` (+15 -0) 📝 `comfy_kitchen/backends/cuda/ops/mesh_bvh.cu` (+118 -3) 📝 `tests/test_mesh_bvh.py` (+163 -0) </details> ### 📄 Description Nearest ray hit on a mesh_bvh, used for ray casting. Major speedups for any rendering nodes. ### Performance ComfyUI mesh nodes on an RTX 5090, Pixal3D jester mesh (0.70M triangles), pure-torch BVH vs comfy-kitchen. End-to-end node timings, the kitchen side also builds its BVH with `mesh_bvh`. | Node | Torch BVH | comfy-kitchen | Speedup | |---|---:|---:|---:| | RenderMesh, 12 views at 1024 | 7.5 s | 0.09 s | ~80× | | RenderMesh, 6 views at 1024 | 3.58 s | 0.14 s | ~25× | | Ambient occlusion | 2.64 s | 0.33 s | ~8× | | Bake Texture From Views | 3.99 s | 0.67 s | ~6× | The bake gains least because ray casting is only its depth pass. Kernel alone: 8M rays against 0.70M triangles in 4.6 ms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-kitchen#272
No description provided.