Repository: godot
Issue: Vulkan: MeshInstance3D nodes with Dynamic Bake mode are very expensive in VoxelGI, regardless of quality settings
Labels: enhancement,topic:rendering,confirmed,topic:3d,performance

### Godot version

4.0.dev (5efe80f30)

### System information

Fedora 34, GeForce GTX 1080 (NVIDIA 470.74)

### Issue description

Even when using primitive BoxMeshes and very simple world geometry, VoxelGI updating takes a lot of time. It typically doubles the frametime required to render a scene, making it difficult to sustain a 60 FPS target on anything but the highest-end GPUs. Dynamic VoxelGI becomes relatively affordable at low VoxelGI quality + half-resolution GI, but this causes overall GI quality to take a noticeable hit.

I remember dynamic VoxelGI being less expensive a while ago (late 2019-early 2020), so a regression may have occurred. If this turns out not to be a regression, we should figure out a way to reduce the cost to make the feature more usable in real world scenarios (such as by revoxelizing less often at the cost of quality).

See the FPS counters in the top-left corner of each screenshot:

#### VoxelGI high quality

| Dynamic and static | Dynamic only | Static only | No static or dynamic |
|-|-|-|-|
| ![2021-11-26_17 04 11](https://user-images.githubusercontent.com/180032/143608357-df5a3a5d-7f37-48d4-a508-b008400f4311.png) | ![2021-11-26_17 04 29](https://user-images.githubusercontent.com/180032/143608361-3a619195-8cfc-4b48-ab99-ed307ccbc3e8.png) | ![2021-11-26_17 04 18](https://user-images.githubusercontent.com/180032/143608358-46dcdc57-57d1-48c5-b663-5dc8b70b5c56.png) | ![2021-11-26_17 04 33](https://user-images.githubusercontent.com/180032/143608363-25b354dc-97eb-43a7-83c0-b0eb23dabb02.png) |

#### VoxelGI low quality

| Dynamic and static | Dynamic only | Static only | No static or dynamic |
|-|-|-|-|
| ![2021-11-26_17 05 18](https://user-images.githubusercontent.com/180032/143608364-66bd1616-1b35-4e6a-abb7-87e42aa35a32.png) | ![2021-11-26_17 05 31](https://user-images.githubusercontent.com/180032/143608369-8df9179d-dcd3-415b-8c4e-c39b8dd6ba34.png) | ![2021-11-26_17 05 27](https://user-images.githubusercontent.com/180032/143608368-054ea319-182e-44e5-98c5-1ab8a86ad6de.png) | ![2021-11-26_17 05 37](https://user-images.githubusercontent.com/180032/143608370-61492166-5c84-44af-b00f-1a8b3ed53a0a.png) |

#### VoxelGI low quality + half-resolution GI

| Dynamic and static | Dynamic only | Static only | No static or dynamic |
|-|-|-|-|
| ![2021-11-26_17 06 03](https://user-images.githubusercontent.com/180032/143608374-66691cb6-ca43-4f26-97bc-3ccf07e46ec2.png) | ![2021-11-26_17 06 14](https://user-images.githubusercontent.com/180032/143608380-c0734a6a-5848-4d20-9bf7-fd5f9238e619.png) | ![2021-11-26_17 06 10](https://user-images.githubusercontent.com/180032/143608378-7f7cfff8-0813-49e4-8c4c-39a976d3009a.png) | ![2021-11-26_17 06 21](https://user-images.githubusercontent.com/180032/143608381-3b4e9fd6-33cd-4803-be83-5140e09931bb.png) |

### Steps to reproduce

- Add a VoxelGI node.
- Add a MeshInstance3D with bake mode set to **Baked**. Assign an emissive material to it.
- Add second MeshInstance3D with bake mode set to **Dynamic**. Assign an emissive material to it.
- Bake the VoxelGI node.
- Notice how performance plummets whenever the dynamic MeshInstance is visible, even when it doesn't move.

### Minimal reproduction project

[test_voxelgi_performance.zip](https://github.com/godotengine/godot/files/12272786/test_voxelgi_performance.zip)
Press <kbd>D</kbd> to toggle dynamic mesh visibility.
Press <kbd>S</kbd> to toggle static mesh visibility.