use egui_wgpu::wgpu::naga;
fn validate_wgsl(name: &str, source: &str) {
let module = naga::front::wgsl::parse_str(source)
.unwrap_or_else(|e| panic!("{name}: WGSL parse failed:\n{}", e.emit_to_string(source)));
let mut validator = naga::valid::Validator::new(
naga::valid::ValidationFlags::all(),
naga::valid::Capabilities::all(),
);
validator.validate(&module).unwrap_or_else(|e| {
panic!(
"{name}: WGSL validation failed:\n{}",
e.emit_to_string(source)
)
});
}
#[test]
fn clear_wgsl_is_valid() {
validate_wgsl("clear.wgsl", include_str!("shaders/clear.wgsl"));
}
#[test]
fn curve_wgsl_is_valid() {
validate_wgsl("curve.wgsl", include_str!("shaders/curve.wgsl"));
}
#[test]
fn errorbars_wgsl_is_valid() {
validate_wgsl("errorbars.wgsl", include_str!("shaders/errorbars.wgsl"));
}
#[test]
fn fill_wgsl_is_valid() {
validate_wgsl("fill.wgsl", include_str!("shaders/fill.wgsl"));
}
#[test]
fn image_wgsl_is_valid() {
validate_wgsl("image.wgsl", include_str!("shaders/image.wgsl"));
}
#[test]
fn image_rgba_wgsl_is_valid() {
validate_wgsl("image_rgba.wgsl", include_str!("shaders/image_rgba.wgsl"));
}
#[test]
fn markers_wgsl_is_valid() {
validate_wgsl("markers.wgsl", include_str!("shaders/markers.wgsl"));
}
#[test]
fn scene3d_wgsl_is_valid() {
validate_wgsl("scene3d.wgsl", include_str!("shaders/scene3d.wgsl"));
}
#[test]
fn scene3d_blit_wgsl_is_valid() {
validate_wgsl(
"scene3d_blit.wgsl",
include_str!("shaders/scene3d_blit.wgsl"),
);
}
#[test]
fn scene3d_points_wgsl_is_valid() {
validate_wgsl(
"scene3d_points.wgsl",
include_str!("shaders/scene3d_points.wgsl"),
);
}
#[test]
fn scene3d_mesh_wgsl_is_valid() {
validate_wgsl(
"scene3d_mesh.wgsl",
include_str!("shaders/scene3d_mesh.wgsl"),
);
}
#[test]
fn scene3d_image_wgsl_is_valid() {
validate_wgsl(
"scene3d_image.wgsl",
include_str!("shaders/scene3d_image.wgsl"),
);
}