assets: the shader asset type exists for an app with no render plugins

Every end-to-end asset-pipeline test — the M2, WMO, BLP and ADT loaders, the minimap's
`load_with_settings` path and the Ironforge group grid — panicked with "Cannot allocate an
Asset Handle of type 'bevy_shader::shader::Shader' because the asset type has not been
initialized". `register_shaders`'s `load_shader_library!` calls allocate a `Handle<Shader>`,
and on Bevy 0.18 it is the render plugins that initialise that type; a headless app has
none, so all six went red at once on the upgrade.

They are the only tests that exercise the loaders every zone load depends on, and the gate
could not see it: each one is data-gated, so it skips without the install, and the
no-install gate is the one that runs everywhere. Found by running the workspace suite with
the install mounted — 44 red there against 0 on the gate.

Initialised here when nothing else has, and **guarded**: `init_asset` *inserts*
`Assets<Shader>`, so calling it unconditionally in the real app would drop every shader the
render plugins had already loaded.

benilla-assets: 109 passed, 0 failed (was 103 and 6). Full chain green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
This commit is contained in:
2026-11-01 14:01:02 -07:00
co-authored by Claude Opus 5
parent e646b5a678
commit 2a65266837
+12 -1
View File
@@ -15,12 +15,23 @@ use bevy::render::render_resource::{
AsBindGroup, BlendComponent, BlendFactor, BlendOperation, BlendState, Buffer, ColorWrites,
CompareFunction, RenderPipelineDescriptor, SpecializedMeshPipelineError,
};
use bevy::shader::{load_shader_library, ShaderRef};
use bevy::shader::{load_shader_library, Shader, ShaderRef};
/// Compile the WGSL files into the binary and register them under
/// `embedded://benilla_assets/shaders/…`. Call **after** Bevy's `AssetPlugin` (it fills the
/// registry that plugin creates); [`crate::register_asset_loaders`] already does.
pub fn register_shaders(app: &mut App) {
// The `load_shader_library!` calls below allocate a `Handle<Shader>`, which bevy refuses
// ("the asset type has not been initialized") unless something has initialised the type. The
// render plugins do; an app that wants only the loaders has none, and on 0.18 that turned the
// six end-to-end pipeline tests red at once — a dependency's doing, invisible to the
// no-install gate because all six are data-gated and skip there.
//
// Guarded, because `init_asset` *inserts* `Assets<Shader>`: calling it where the render
// plugins already ran would drop every shader they had loaded.
if !app.world().contains_resource::<Assets<Shader>>() {
app.init_asset::<Shader>();
}
bevy::asset::embedded_asset!(app, "shaders/terrain.wgsl");
bevy::asset::embedded_asset!(app, "shaders/wow_model.wgsl");
bevy::asset::embedded_asset!(app, "shaders/wdl.wgsl");