[PR #1920] [MERGED] OpenGL: sprite arrays GL can bind, animated sprites without compute shaders #3865

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1920
Author: @ludovic111
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: fix/opengl-downlevel


📝 Commits (4)

  • b3e400a Renderer: sprite arrays OpenGL can view as arrays
  • 1a16e35 Animated sprites without compute shaders (OpenGL before 4.3)
  • 21203de Animated sprites: the CPU path also when the driver cannot build the compute pipeline
  • f65750b Merge origin/main into fix/opengl-downlevel

📊 Changes

2 files changed (+206 additions, -28 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+27 -3)
📝 crates/horizon-client/src/gfx/animate.rs (+179 -25)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Follow-up to #1917 (OpenGL as the last fallback), for OpenGL drivers older than 4.3 and for the GL texture target heuristic. Nothing changes on Vulkan, Metal or DirectX 12.

What

  • Sprite arrays OpenGL can view as arrays (gfx.rs). wgpu's GL backend picks a texture's GL target from its layer count when it creates it: 1 layer becomes TEXTURE_2D, and a multiple of 6 on a square texture becomes a cube map. Neither can be bound as terrain.wgsl's texture_2d_array, and wgpu logged "heuristics assumed that the view dimension will be equal to D2 rather than D2Array". On GL only (array_layers), the 1-layer stand-in for unused sprite arrays gets 2 layers, and a sprite array of 1 or 6n layers gets one empty layer more.
  • Animated sprites without compute shaders (gfx/animate.rs). The animator was a compute pass only. Without compute or storage it now runs the same jobs on the CPU, using animate.wgsl's integer mix, and copies each changed level into its layer through the upload belt. The compute pipeline is created inside error scopes, and a failure switches to the CPU path with one warning: a driver can list GL_ARB_compute_shader while wgpu writes GLSL of its core version, which has no compute. That happens under MESA_GL_VERSION_OVERRIDE=3.3, where the game used to panic in SpriteAnimator::new.
  • The other compute and storage users can't be reached on GL. flat is Metal only (unless HORIZON_FLAT_DRAWS=1), cull is Vulkan/Metal only, and GpuTimer's compute markers exist only without TIMESTAMP_QUERY_INSIDE_ENCODERS, which GL sets together with TIMESTAMP_QUERY.

Tested

  • Mac mini (Metal): cargo clippy -p horizon-client --lib --tests --bins -- -D warnings clean. gfx:: tests 82 passed, including a new copied_layers_match_the_cpu_chains_every_tick: the CPU path checked against the same reference as the GPU test, every tick. New gl_sprite_arrays_are_neither_2d_textures_nor_cube_maps. Game started on Metal with a carved pumpkin worn: the pumpkin blur draws as before.
  • Desktop, Mesa llvmpipe under Xvfb, HORIZON_GRAPHICS_API=opengl (run by the orchestrator): GL 4.6: the world renders, 0 errors. GL 3.3 (MESA_GL_VERSION_OVERRIDE=3.3 MESA_GLSL_VERSION_OVERRIDE=330): no panic, the CPU animation line is logged, 0 errors. But terrain, clouds and the hand don't draw yet at 3.3. That's the next PR (vertex-stage storage), not this one.

Needs Ludovic

Nothing. Label: none (a fix).

🤖 Generated with Claude Code


🔄 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/1920 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/opengl-downlevel` --- ### 📝 Commits (4) - [`b3e400a`](https://github.com/horizon-rust/horizon/commit/b3e400a52673862fa237ef4341ba21d4440d3c52) Renderer: sprite arrays OpenGL can view as arrays - [`1a16e35`](https://github.com/horizon-rust/horizon/commit/1a16e35aaa45800285fca7d5be2a07e48f0421c0) Animated sprites without compute shaders (OpenGL before 4.3) - [`21203de`](https://github.com/horizon-rust/horizon/commit/21203de7f07aec02ac1bb325462c729d9ae8fc38) Animated sprites: the CPU path also when the driver cannot build the compute pipeline - [`f65750b`](https://github.com/horizon-rust/horizon/commit/f65750baed99d815fc1b6169f0f54693e7397978) Merge origin/main into fix/opengl-downlevel ### 📊 Changes **2 files changed** (+206 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+27 -3) 📝 `crates/horizon-client/src/gfx/animate.rs` (+179 -25) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Follow-up to #1917 (OpenGL as the last fallback), for OpenGL drivers older than 4.3 and for the GL texture target heuristic. Nothing changes on Vulkan, Metal or DirectX 12. ## What - **Sprite arrays OpenGL can view as arrays** (`gfx.rs`). wgpu's GL backend picks a texture's GL target from its layer count when it creates it: 1 layer becomes `TEXTURE_2D`, and a multiple of 6 on a square texture becomes a cube map. Neither can be bound as terrain.wgsl's `texture_2d_array`, and wgpu logged "heuristics assumed that the view dimension will be equal to `D2` rather than `D2Array`". On GL only (`array_layers`), the 1-layer stand-in for unused sprite arrays gets 2 layers, and a sprite array of 1 or 6n layers gets one empty layer more. - **Animated sprites without compute shaders** (`gfx/animate.rs`). The animator was a compute pass only. Without compute or storage it now runs the same jobs on the CPU, using animate.wgsl's integer mix, and copies each changed level into its layer through the upload belt. The compute pipeline is created inside error scopes, and a failure switches to the CPU path with one warning: a driver can list `GL_ARB_compute_shader` while wgpu writes GLSL of its core version, which has no compute. That happens under `MESA_GL_VERSION_OVERRIDE=3.3`, where the game used to panic in `SpriteAnimator::new`. - The other compute and storage users can't be reached on GL. `flat` is Metal only (unless `HORIZON_FLAT_DRAWS=1`), `cull` is Vulkan/Metal only, and GpuTimer's compute markers exist only without `TIMESTAMP_QUERY_INSIDE_ENCODERS`, which GL sets together with `TIMESTAMP_QUERY`. ## Tested - Mac mini (Metal): `cargo clippy -p horizon-client --lib --tests --bins -- -D warnings` clean. `gfx::` tests 82 passed, including a new `copied_layers_match_the_cpu_chains_every_tick`: the CPU path checked against the same reference as the GPU test, every tick. New `gl_sprite_arrays_are_neither_2d_textures_nor_cube_maps`. Game started on Metal with a carved pumpkin worn: the pumpkin blur draws as before. - Desktop, Mesa llvmpipe under Xvfb, `HORIZON_GRAPHICS_API=opengl` (run by the orchestrator): **GL 4.6**: the world renders, 0 errors. **GL 3.3** (`MESA_GL_VERSION_OVERRIDE=3.3 MESA_GLSL_VERSION_OVERRIDE=330`): no panic, the CPU animation line is logged, 0 errors. But terrain, clouds and the hand don't draw yet at 3.3. That's the next PR (vertex-stage storage), not this one. ## Needs Ludovic Nothing. Label: none (a fix). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:53 +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#3865
No description provided.