[PR #4220] [MERGED] OpenGL 4.2: Enable indirect execution and simulated multi-draw batching #5495

Closed
opened 2026-11-03 05:12:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4220
Author: @elythepreciouscat
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: perf/opengl-indirect-multidraw


📝 Commits (2)

  • 5a2bfc3 OpenGL 4.2: Enable indirect execution and simulated multi-draw batching
  • 41da822 fix(gl): restore clippy allow on UniformLocation and clarify multi-draw requirements

📊 Changes

5 files changed (+50 additions, -37 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+2 -1)
📝 third_party/wgpu-hal/src/gles/adapter.rs (+3 -3)
📝 third_party/wgpu-hal/src/gles/command.rs (+29 -29)
📝 third_party/wgpu-hal/src/gles/mod.rs (+2 -0)
📝 third_party/wgpu-hal/src/gles/queue.rs (+14 -4)

📄 Description

🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally.

Summary

Enables indirect drawing and simulated multi-draw batching on OpenGL 4.0+ / OpenGL 4.2 hardware (the GLES wgpu backend). Fixes #4210.

Problem

  1. In third_party/wgpu-hal/src/gles/adapter.rs, wgt::DownlevelFlags::INDIRECT_EXECUTION was gated behind compute shaders:
    let indirect_execution = supported((3, 1), (4, 3))
        || (extensions.contains("GL_ARB_draw_indirect") && supports_compute);
    
    On OpenGL 4.2 systems (such as Intel HD Graphics 4000 IVB GT2), basic indirect drawing (glDrawArraysIndirect, glDrawElementsIndirect) is fully standard, but compute shaders may be unsupported. Because INDIRECT_EXECUTION was unset, self.multi_draw in horizon-client-render evaluated to false.
  2. When multi_draw is disabled, the renderer is forced to issue hundreds or thousands of individual pass.draw_indexed() calls on the CPU every frame instead of issuing batched indirect section draws.
  3. In third_party/wgpu-hal/src/gles/command.rs, draw_indexed_indirect pushed draw_count separate Command::DrawIndexedIndirect enum variants into the command buffer vector, and in queue.rs, every single draw rebound GL_DRAW_INDIRECT_BUFFER and updated the first_instance uniform in a redundant loop.

Fix

  • In third_party/wgpu-hal/src/gles/adapter.rs:
    • Decouple INDIRECT_EXECUTION from compute shaders: enable it whenever supported((3, 1), (4, 0)) || extensions.contains("GL_ARB_draw_indirect").
  • In third_party/wgpu-hal/src/gles/mod.rs & command.rs:
    • Add draw_count: u32 to Command::DrawIndirect and Command::DrawIndexedIndirect.
    • Push a single command into the command buffer rather than looping and pushing draw_count separate commands.
  • In third_party/wgpu-hal/src/gles/queue.rs:
    • Bind glow::DRAW_INDIRECT_BUFFER and set the uniform once, then loop gl.draw_*_indirect_offset over 0..draw_count with advancing stride. This simulates multi-draw in OpenGL 4.2 without command buffer allocation churn and without buffer rebinding overhead.
  • In crates/horizon-client-render/src/gfx.rs:
    • Update the indirect draw comment to reflect that OpenGL 4.0+ supports indirect execution.

Checks

pr_ready (tools/pr_ready.py --quick on omarchy, against origin/main at 68f036059, 8 min 0 s)

Check Result
Scope ✅ 5 files, +41 −37
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 14 s)
rustfmt ✅ (21 s)
clippy ✅ (5 min 23 s)
tests: horizon-client-render ✅ 571 passed (24 s)
doc tests ✅ 0 passed (35 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Google Antigravity


🔄 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/horizon-rust/horizon/pull/4220 **Author:** [@elythepreciouscat](https://github.com/elythepreciouscat) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/opengl-indirect-multidraw` --- ### 📝 Commits (2) - [`5a2bfc3`](https://github.com/horizon-rust/horizon/commit/5a2bfc3d24f76d48f8340a2a6a0f85ad38a7c4a8) OpenGL 4.2: Enable indirect execution and simulated multi-draw batching - [`41da822`](https://github.com/horizon-rust/horizon/commit/41da822ff8cf5644ba708bf57850772d0ec73e3a) fix(gl): restore clippy allow on UniformLocation and clarify multi-draw requirements ### 📊 Changes **5 files changed** (+50 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+2 -1) 📝 `third_party/wgpu-hal/src/gles/adapter.rs` (+3 -3) 📝 `third_party/wgpu-hal/src/gles/command.rs` (+29 -29) 📝 `third_party/wgpu-hal/src/gles/mod.rs` (+2 -0) 📝 `third_party/wgpu-hal/src/gles/queue.rs` (+14 -4) </details> ### 📄 Description > 🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally. ### Summary Enables indirect drawing and simulated multi-draw batching on OpenGL 4.0+ / OpenGL 4.2 hardware (the GLES wgpu backend). Fixes #4210. ### Problem 1. In `third_party/wgpu-hal/src/gles/adapter.rs`, `wgt::DownlevelFlags::INDIRECT_EXECUTION` was gated behind compute shaders: ```rust let indirect_execution = supported((3, 1), (4, 3)) || (extensions.contains("GL_ARB_draw_indirect") && supports_compute); ``` On OpenGL 4.2 systems (such as Intel HD Graphics 4000 IVB GT2), basic indirect drawing (`glDrawArraysIndirect`, `glDrawElementsIndirect`) is fully standard, but compute shaders may be unsupported. Because `INDIRECT_EXECUTION` was unset, `self.multi_draw` in `horizon-client-render` evaluated to `false`. 2. When `multi_draw` is disabled, the renderer is forced to issue hundreds or thousands of individual `pass.draw_indexed()` calls on the CPU every frame instead of issuing batched indirect section draws. 3. In `third_party/wgpu-hal/src/gles/command.rs`, `draw_indexed_indirect` pushed `draw_count` separate `Command::DrawIndexedIndirect` enum variants into the command buffer vector, and in `queue.rs`, every single draw rebound `GL_DRAW_INDIRECT_BUFFER` and updated the `first_instance` uniform in a redundant loop. ### Fix - In `third_party/wgpu-hal/src/gles/adapter.rs`: - Decouple `INDIRECT_EXECUTION` from compute shaders: enable it whenever `supported((3, 1), (4, 0)) || extensions.contains("GL_ARB_draw_indirect")`. - In `third_party/wgpu-hal/src/gles/mod.rs` & `command.rs`: - Add `draw_count: u32` to `Command::DrawIndirect` and `Command::DrawIndexedIndirect`. - Push a single command into the command buffer rather than looping and pushing `draw_count` separate commands. - In `third_party/wgpu-hal/src/gles/queue.rs`: - Bind `glow::DRAW_INDIRECT_BUFFER` and set the uniform once, then loop `gl.draw_*_indirect_offset` over `0..draw_count` with advancing stride. This simulates multi-draw in OpenGL 4.2 without command buffer allocation churn and without buffer rebinding overhead. - In `crates/horizon-client-render/src/gfx.rs`: - Update the indirect draw comment to reflect that OpenGL 4.0+ supports indirect execution. ### Checks **pr_ready** (`tools/pr_ready.py --quick` on omarchy, against origin/main at 68f036059, 8 min 0 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +41 −37 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 14 s) | | rustfmt | ✅ (21 s) | | clippy | ✅ (5 min 23 s) | | tests: horizon-client-render | ✅ 571 passed (24 s) | | doc tests | ✅ 0 passed (35 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with Google Antigravity --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:59 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#5495
No description provided.