[GH-ISSUE #4210] OpenGL 4.2: Enable indirect execution and simulated multi-draw batching #1239

Closed
opened 2026-11-02 15:45:19 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @elythepreciouscat on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4210

Originally assigned to: @elythepreciouscat on GitHub.

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

Description

OpenGL 4.0+ and OpenGL ES 3.1+ natively support basic indirect drawing (glDrawArraysIndirect and glDrawElementsIndirect).

Currently, in third_party/wgpu-hal/src/gles/adapter.rs, wgpu-hal gates wgt::DownlevelFlags::INDIRECT_EXECUTION 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 Mesa Intel HD Graphics 4000 IVB GT2), compute shaders may not be supported or enabled, causing DownlevelFlags::INDIRECT_EXECUTION to be unset.

As a result, in crates/horizon-client-render/src/gfx.rs, self.multi_draw evaluates to false:

let multi_draw = device
    .features()
    .contains(wgpu::Features::INDIRECT_FIRST_INSTANCE)
    && adapter
        .get_downlevel_capabilities()
        .flags
        .contains(wgpu::DownlevelFlags::INDIRECT_EXECUTION);

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.

Proposed Fix

  1. In third_party/wgpu-hal/src/gles/adapter.rs:
    • Decouple INDIRECT_EXECUTION from compute shaders for draw commands: allow supported((3, 1), (4, 0)) || extensions.contains("GL_ARB_draw_indirect").
  2. In third_party/wgpu-hal/src/gles/command.rs and queue.rs:
    • Replace pushing draw_count separate C::DrawIndexedIndirect commands with a batched C::DrawIndexedIndirectBatch.
    • In queue.rs, bind glow::DRAW_INDIRECT_BUFFER once and loop glDrawElementsIndirect on the CPU with advancing buffer offsets, simulating multi-draw without memory churn.

🤖 Generated with Google Antigravity

Originally created by @elythepreciouscat on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4210 Originally assigned to: @elythepreciouscat on GitHub. > 🤖 Filed by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally. ### Description OpenGL 4.0+ and OpenGL ES 3.1+ natively support basic indirect drawing (`glDrawArraysIndirect` and `glDrawElementsIndirect`). Currently, in `third_party/wgpu-hal/src/gles/adapter.rs`, `wgpu-hal` gates `wgt::DownlevelFlags::INDIRECT_EXECUTION` 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 Mesa Intel HD Graphics 4000 IVB GT2), compute shaders may not be supported or enabled, causing `DownlevelFlags::INDIRECT_EXECUTION` to be unset. As a result, in `crates/horizon-client-render/src/gfx.rs`, `self.multi_draw` evaluates to `false`: ```rust let multi_draw = device .features() .contains(wgpu::Features::INDIRECT_FIRST_INSTANCE) && adapter .get_downlevel_capabilities() .flags .contains(wgpu::DownlevelFlags::INDIRECT_EXECUTION); ``` 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. ### Proposed Fix 1. In `third_party/wgpu-hal/src/gles/adapter.rs`: - Decouple `INDIRECT_EXECUTION` from compute shaders for draw commands: allow `supported((3, 1), (4, 0)) || extensions.contains("GL_ARB_draw_indirect")`. 2. In `third_party/wgpu-hal/src/gles/command.rs` and `queue.rs`: - Replace pushing `draw_count` separate `C::DrawIndexedIndirect` commands with a batched `C::DrawIndexedIndirectBatch`. - In `queue.rs`, bind `glow::DRAW_INDIRECT_BUFFER` once and loop `glDrawElementsIndirect` on the CPU with advancing buffer offsets, simulating multi-draw without memory churn. 🤖 Generated with Google Antigravity
Author
Owner

@elythepreciouscat commented on GitHub (Oct 30, 2026):

/claim

🤖 Agent: Claiming this issue for elythepreciouscat.

<!-- gh-comment-id:6516535661 --> @elythepreciouscat commented on GitHub (Oct 30, 2026): /claim 🤖 Agent: Claiming this issue for elythepreciouscat.
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#1239
No description provided.