khora_lanes/render_lane/shaders/mod.rs
1// Copyright 2025 eraflo
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Built-in shader sources for the Khora Engine rendering system.
16//!
17//! Rendering lanes consume shaders through the `PipelineSystem` backend
18//! (`khora-infra`, naga_oil composer + validation). This module exposes
19//! the two remaining `include_str!` constants still required by
20//! infra-side consumers (the egui editor overlay and the text renderer)
21//! — they take raw WGSL strings, not pipeline handles.
22//!
23//! New lanes / pipelines should be added to the backend's pipeline
24//! module table and looked up by name; no new `_WGSL` constants should
25//! appear here.
26
27/// Shader for text rendering. Consumed by
28/// `khora_infra::StandardTextRenderer::new` as a raw `String`.
29pub const TEXT_WGSL: &str = include_str!("pipelines/text.wgsl");
30
31/// Shader for the egui editor overlay. Consumed by
32/// `khora_infra::WgpuRenderSystem::create_editor_overlay_and_shell`
33/// as a raw `&str`.
34pub const EGUI_WGSL: &str = include_str!("pipelines/egui.wgsl");
35
36// NOTE — the grid and gizmo shaders are NOT exposed as `_WGSL`
37// constants: grid / gizmo rendering is owned by the engine-side
38// `GridLane` / `GizmoLane`, which resolve `khora::pipelines::grid` /
39// `khora::pipelines::gizmo` through the `PipelineSystem` backend like
40// every other render lane.
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn text_shader_valid() {
48 assert!(TEXT_WGSL.contains("@vertex"));
49 assert!(TEXT_WGSL.contains("@fragment"));
50 }
51
52 #[test]
53 fn egui_shader_valid() {
54 assert!(EGUI_WGSL.contains("@vertex"));
55 assert!(EGUI_WGSL.contains("@fragment"));
56 }
57}