scena 1.7.0

A Rust-native scene-graph renderer with typed scene state, glTF assets, and explicit prepare/render lifecycles.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
//! Phase 1F step 2 (commit 1 of 4): material array-batching plan
//! computation.
//!
//! Determines whether the prepared material slots can share a single
//! `texture_2d_array<f32>` per role (`Capabilities::texture_arrays`
//! batched path) or must keep the per-material 2D bind-group path.
//! All materials must share `(sampler, format, decoded dimensions)`
//! for every populated role; the first incompatibility blocks the
//! batched path. The plan is exposed through `RendererStats` so test
//! harnesses can verify the renderer detects array-batching
//! opportunities.

use crate::assets::{TextureDesc, TextureSamplerDesc, TextureSourceFormat};

use super::resources::PreparedMaterialSlot;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MaterialTextureRole {
    BaseColor,
    Normal,
    MetallicRoughness,
    Occlusion,
    Emissive,
    Clearcoat,
    ClearcoatRoughness,
    ClearcoatNormal,
    SheenColor,
    SheenRoughness,
    Anisotropy,
    Iridescence,
    IridescenceThickness,
    Transmission,
    Thickness,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(clippy::enum_variant_names)]
pub enum MaterialBatchIncompatibility {
    /// The decoded dimensions of two materials' textures for the same
    /// role differ. A single `texture_2d_array` requires every layer
    /// to share width and height.
    DimensionMismatch,
    /// The samplers differ (wrap mode, filter, mipmap policy).
    /// `texture_2d_array` shares one sampler across all layers, so
    /// per-layer sampler differences cannot be expressed.
    SamplerMismatch,
    /// The source formats differ (e.g. one PNG, one KTX2). Array
    /// layers must share the underlying GPU format.
    FormatMismatch,
    /// Browser WebGPU normal-map array batching is disabled until the
    /// M6 browser proof validates tangent-space normal map sampling
    /// through the texture-array path. The per-material path remains
    /// the correctness fallback.
    NormalMapBatchingDeferred,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MaterialBatchPlan {
    /// True iff every populated role across all materials shares
    /// `(sampler, format, dimensions)`.
    pub batchable: bool,
    /// Number of layers a single `texture_2d_array` per role would
    /// hold. Equals the material slot count when `batchable` is true,
    /// otherwise zero.
    pub layer_count: u32,
    /// First role where compatibility broke down, or `None` when the
    /// plan is batchable. Surfaced through `RendererStats` so a
    /// diagnostic UI can point at the offending texture role.
    pub incompatible_role: Option<MaterialTextureRole>,
    /// First reason an incompatibility kicked in, paired with
    /// `incompatible_role`. Always `None` when the plan is
    /// batchable.
    pub incompatible_reason: Option<MaterialBatchIncompatibility>,
}

impl MaterialBatchPlan {
    pub const fn empty() -> Self {
        Self {
            batchable: true,
            layer_count: 0,
            incompatible_role: None,
            incompatible_reason: None,
        }
    }
}

/// Computes the material array-batching plan for a list of prepared
/// material slots. Walks each role across all materials and records
/// the first incompatibility. Materials with a `None` role slot are
/// considered to share that role's fallback texture and do not break
/// compatibility; only populated roles drive the comparison.
pub(in crate::render) fn compute_material_batch_plan(
    slots: &[PreparedMaterialSlot],
) -> MaterialBatchPlan {
    if slots.is_empty() {
        return MaterialBatchPlan::empty();
    }
    let layer_count = slots.len() as u32;
    for role in [
        MaterialTextureRole::BaseColor,
        MaterialTextureRole::Normal,
        MaterialTextureRole::MetallicRoughness,
        MaterialTextureRole::Occlusion,
        MaterialTextureRole::Emissive,
        MaterialTextureRole::Clearcoat,
        MaterialTextureRole::ClearcoatRoughness,
        MaterialTextureRole::ClearcoatNormal,
        MaterialTextureRole::SheenColor,
        MaterialTextureRole::SheenRoughness,
        MaterialTextureRole::Anisotropy,
        MaterialTextureRole::Iridescence,
        MaterialTextureRole::IridescenceThickness,
        MaterialTextureRole::Transmission,
        MaterialTextureRole::Thickness,
    ] {
        if matches!(
            role,
            MaterialTextureRole::Normal | MaterialTextureRole::ClearcoatNormal
        ) && role_is_populated(role, slots)
        {
            return MaterialBatchPlan {
                batchable: false,
                layer_count: 0,
                incompatible_role: Some(role),
                incompatible_reason: Some(MaterialBatchIncompatibility::NormalMapBatchingDeferred),
            };
        }
        if let Some(reason) = role_compatibility(role, slots) {
            return MaterialBatchPlan {
                batchable: false,
                layer_count: 0,
                incompatible_role: Some(role),
                incompatible_reason: Some(reason),
            };
        }
    }
    MaterialBatchPlan {
        batchable: true,
        layer_count,
        incompatible_role: None,
        incompatible_reason: None,
    }
}

fn role_is_populated(role: MaterialTextureRole, slots: &[PreparedMaterialSlot]) -> bool {
    slots.iter().any(|slot| role_texture(role, slot).is_some())
}

fn role_compatibility(
    role: MaterialTextureRole,
    slots: &[PreparedMaterialSlot],
) -> Option<MaterialBatchIncompatibility> {
    let mut anchor: Option<RoleAnchor> = None;
    for slot in slots {
        let Some(desc) = role_texture(role, slot) else {
            continue;
        };
        let candidate = RoleAnchor::from(desc);
        if let Some(anchor) = anchor.as_ref() {
            if let Some(reason) = anchor.compare(&candidate) {
                return Some(reason);
            }
        } else {
            anchor = Some(candidate);
        }
    }
    None
}

fn role_texture(role: MaterialTextureRole, slot: &PreparedMaterialSlot) -> Option<&TextureDesc> {
    let texture = match role {
        MaterialTextureRole::BaseColor => slot.base_color.as_ref(),
        MaterialTextureRole::Normal => slot.normal.as_ref(),
        MaterialTextureRole::MetallicRoughness => slot.metallic_roughness.as_ref(),
        MaterialTextureRole::Occlusion => slot.occlusion.as_ref(),
        MaterialTextureRole::Emissive => slot.emissive.as_ref(),
        MaterialTextureRole::Clearcoat => slot.clearcoat.as_ref(),
        MaterialTextureRole::ClearcoatRoughness => slot.clearcoat_roughness.as_ref(),
        MaterialTextureRole::ClearcoatNormal => slot.clearcoat_normal.as_ref(),
        MaterialTextureRole::SheenColor => slot.sheen_color.as_ref(),
        MaterialTextureRole::SheenRoughness => slot.sheen_roughness.as_ref(),
        MaterialTextureRole::Anisotropy => slot.anisotropy.as_ref(),
        MaterialTextureRole::Iridescence => slot.iridescence.as_ref(),
        MaterialTextureRole::IridescenceThickness => slot.iridescence_thickness.as_ref(),
        MaterialTextureRole::Transmission => slot.transmission.as_ref(),
        MaterialTextureRole::Thickness => slot.thickness.as_ref(),
    }?;
    Some(&texture.desc)
}

struct RoleAnchor {
    sampler: TextureSamplerDesc,
    format: TextureSourceFormat,
    dimensions: Option<(u32, u32)>,
}

impl RoleAnchor {
    fn from(desc: &TextureDesc) -> Self {
        Self {
            sampler: desc.sampler(),
            format: desc.source_format(),
            dimensions: desc.decoded_dimensions(),
        }
    }

    fn compare(&self, other: &Self) -> Option<MaterialBatchIncompatibility> {
        if self.sampler != other.sampler {
            return Some(MaterialBatchIncompatibility::SamplerMismatch);
        }
        if self.format != other.format {
            return Some(MaterialBatchIncompatibility::FormatMismatch);
        }
        if self.dimensions != other.dimensions {
            return Some(MaterialBatchIncompatibility::DimensionMismatch);
        }
        None
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::assets::{
        Assets, MaterialHandle, TextureDesc, TextureFilter, TextureSamplerDesc,
        TextureSourceFormat, TextureWrap,
    };
    use crate::material::{Color, MaterialDesc, TextureColorSpace};
    use crate::render::prepare::resources::PreparedMaterialTexture;

    // Minimal valid 1x1 red PNG, base64 decoded once at test setup. The
    // `new_with_bytes` constructor decodes this into 1x1 RGBA pixels so
    // dimension comparisons in the batch plan have something concrete to
    // measure.
    fn one_pixel_png() -> Vec<u8> {
        base64::Engine::decode(
            &base64::engine::general_purpose::STANDARD,
            "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==",
        )
        .expect("fixture PNG base64 is valid")
    }

    fn texture_desc(sampler: TextureSamplerDesc) -> TextureDesc {
        TextureDesc::new_with_bytes(
            crate::assets::AssetPath::from("memory://material-batch/test.png"),
            TextureColorSpace::Srgb,
            sampler,
            TextureSourceFormat::Png,
            Some(&one_pixel_png()),
        )
        .expect("test PNG decodes")
    }

    fn texture_desc_jpeg(sampler: TextureSamplerDesc) -> TextureDesc {
        // JPEG path stays descriptor-only because the bundled test
        // fixture set does not ship a 1×1 JPEG. The plan compares
        // source_format directly without requiring decoded pixels for
        // that comparison branch.
        TextureDesc::new_with_bytes(
            crate::assets::AssetPath::from("memory://material-batch/test.jpg"),
            TextureColorSpace::Srgb,
            sampler,
            TextureSourceFormat::Jpeg,
            None,
        )
        .expect("descriptor-only JPEG")
    }

    fn material_slot_with_base_color(
        handle: MaterialHandle,
        base_color: TextureDesc,
    ) -> PreparedMaterialSlot {
        PreparedMaterialSlot {
            handle,
            material: MaterialDesc::unlit(Color::WHITE),
            base_color: Some(PreparedMaterialTexture {
                handle: Default::default(),
                desc: base_color,
                transform: None,
            }),
            normal: None,
            metallic_roughness: None,
            occlusion: None,
            emissive: None,
            clearcoat: None,
            clearcoat_roughness: None,
            clearcoat_normal: None,
            sheen_color: None,
            sheen_roughness: None,
            anisotropy: None,
            iridescence: None,
            iridescence_thickness: None,
            transmission: None,
            thickness: None,
        }
    }

    fn material_slot_with_normal(
        handle: MaterialHandle,
        normal: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.normal = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: normal,
            transform: None,
        });
        slot
    }

    fn material_slot_with_clearcoat_roughness(
        handle: MaterialHandle,
        clearcoat_roughness: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.clearcoat_roughness = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: clearcoat_roughness,
            transform: None,
        });
        slot
    }

    fn material_slot_with_sheen_roughness(
        handle: MaterialHandle,
        sheen_roughness: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.sheen_roughness = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: sheen_roughness,
            transform: None,
        });
        slot
    }

    fn material_slot_with_anisotropy(
        handle: MaterialHandle,
        anisotropy: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.anisotropy = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: anisotropy,
            transform: None,
        });
        slot
    }

    fn material_slot_with_iridescence(
        handle: MaterialHandle,
        iridescence: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.iridescence = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: iridescence,
            transform: None,
        });
        slot
    }

    fn material_slot_with_iridescence_thickness(
        handle: MaterialHandle,
        iridescence_thickness: TextureDesc,
    ) -> PreparedMaterialSlot {
        let mut slot = material_slot_with_base_color(handle, texture_desc(default_sampler()));
        slot.iridescence_thickness = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: iridescence_thickness,
            transform: None,
        });
        slot
    }

    fn assets_handle() -> MaterialHandle {
        let assets = Assets::new();
        assets.create_material(MaterialDesc::unlit(Color::WHITE))
    }

    fn default_sampler() -> TextureSamplerDesc {
        TextureSamplerDesc::default()
    }

    fn nearest_sampler() -> TextureSamplerDesc {
        TextureSamplerDesc::new(
            Some(TextureFilter::Nearest),
            Some(TextureFilter::Nearest),
            TextureWrap::ClampToEdge,
            TextureWrap::ClampToEdge,
        )
    }

    #[test]
    fn empty_slot_list_is_batchable_with_zero_layers() {
        let plan = compute_material_batch_plan(&[]);
        assert!(plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert!(plan.incompatible_role.is_none());
    }

    #[test]
    fn single_material_is_batchable_with_one_layer() {
        let slots = vec![material_slot_with_base_color(
            assets_handle(),
            texture_desc(default_sampler()),
        )];
        let plan = compute_material_batch_plan(&slots);
        assert!(plan.batchable);
        assert_eq!(plan.layer_count, 1);
    }

    #[test]
    fn two_compatible_materials_batch_into_two_layers() {
        let slots = vec![
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(plan.batchable);
        assert_eq!(plan.layer_count, 2);
    }

    #[test]
    fn normal_mapped_materials_do_not_use_array_batching_until_webgpu_path_is_proven() {
        let slots = vec![
            material_slot_with_normal(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_normal(assets_handle(), texture_desc(default_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(plan.incompatible_role, Some(MaterialTextureRole::Normal));
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::NormalMapBatchingDeferred),
        );
    }

    #[test]
    fn sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_base_color(assets_handle(), texture_desc(nearest_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(plan.incompatible_role, Some(MaterialTextureRole::BaseColor));
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn clearcoat_roughness_sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_clearcoat_roughness(
                assets_handle(),
                texture_desc(default_sampler()),
            ),
            material_slot_with_clearcoat_roughness(
                assets_handle(),
                texture_desc(nearest_sampler()),
            ),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::ClearcoatRoughness),
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn sheen_roughness_sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_sheen_roughness(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_sheen_roughness(assets_handle(), texture_desc(nearest_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::SheenRoughness),
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn anisotropy_sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_anisotropy(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_anisotropy(assets_handle(), texture_desc(nearest_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::Anisotropy)
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn iridescence_sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_iridescence(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_iridescence(assets_handle(), texture_desc(nearest_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::Iridescence)
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn iridescence_thickness_sampler_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_iridescence_thickness(
                assets_handle(),
                texture_desc(default_sampler()),
            ),
            material_slot_with_iridescence_thickness(
                assets_handle(),
                texture_desc(nearest_sampler()),
            ),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::IridescenceThickness)
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::SamplerMismatch),
        );
    }

    #[test]
    fn format_mismatch_blocks_batching_with_diagnostic_role() {
        let slots = vec![
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler())),
            material_slot_with_base_color(assets_handle(), texture_desc_jpeg(default_sampler())),
        ];
        let plan = compute_material_batch_plan(&slots);
        assert!(!plan.batchable);
        assert_eq!(plan.incompatible_role, Some(MaterialTextureRole::BaseColor));
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::FormatMismatch),
        );
    }

    #[test]
    fn normal_map_on_any_material_uses_per_material_path() {
        // One material has a normal map, the other does not. Until
        // browser WebGPU proves normal maps through texture arrays,
        // any populated normal slot keeps the per-material bind-group
        // path.
        let mut left =
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler()));
        left.normal = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: texture_desc(default_sampler()),
            transform: None,
        });
        let right = material_slot_with_base_color(assets_handle(), texture_desc(default_sampler()));
        let plan = compute_material_batch_plan(&[left, right]);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(plan.incompatible_role, Some(MaterialTextureRole::Normal));
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::NormalMapBatchingDeferred),
        );
    }

    #[test]
    fn clearcoat_normal_map_uses_per_material_path_until_texture_array_proven() {
        let mut left =
            material_slot_with_base_color(assets_handle(), texture_desc(default_sampler()));
        left.clearcoat_normal = Some(PreparedMaterialTexture {
            handle: Default::default(),
            desc: texture_desc(default_sampler()),
            transform: None,
        });
        let right = material_slot_with_base_color(assets_handle(), texture_desc(default_sampler()));
        let plan = compute_material_batch_plan(&[left, right]);
        assert!(!plan.batchable);
        assert_eq!(plan.layer_count, 0);
        assert_eq!(
            plan.incompatible_role,
            Some(MaterialTextureRole::ClearcoatNormal),
        );
        assert_eq!(
            plan.incompatible_reason,
            Some(MaterialBatchIncompatibility::NormalMapBatchingDeferred),
        );
    }
}