khora_lanes/render_lane/shadows_lane/algo/bindings.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//! Bundles the lane's atlas resources into the
16//! [`khora_data::render::ShadowGpuBindings`] type that lit consumer
17//! lanes read from the lane context.
18//!
19//! Living next to the atlases keeps the binding-construction concern
20//! local — lit lanes only ever see the bundle, not the individual
21//! 2D / cube view ids.
22
23use khora_core::renderer::api::resource::SamplerId;
24use khora_data::render::ShadowGpuBindings;
25
26use super::atlas_2d::Atlas2D;
27use super::atlas_cube::AtlasCube;
28
29/// Builds a [`ShadowGpuBindings`] from the lane's atlas resources, if
30/// every required handle is present.
31///
32/// Returns `None` only when the lane hasn't finished initialising yet
33/// (rare — only the very first frame between `on_initialize` and
34/// `execute`).
35pub fn build_bindings(
36 atlas_2d: &Atlas2D,
37 atlas_cube: &AtlasCube,
38 sampler: SamplerId,
39) -> Option<ShadowGpuBindings> {
40 Some(ShadowGpuBindings {
41 atlas_2d: atlas_2d.view_id()?,
42 atlas_cube: atlas_cube.view_id()?,
43 sampler,
44 })
45}