From 18b758e3889bdd6ffa769085de15e2b96a0c1eb5 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 15 May 2024 21:46:52 -0400 Subject: [PATCH] test: ensure render pipelines have at least 1 target --- tests/tests/pipeline.rs | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/tests/pipeline.rs b/tests/tests/pipeline.rs index 0d725b8f4..2591bf5d1 100644 --- a/tests/tests/pipeline.rs +++ b/tests/tests/pipeline.rs @@ -35,3 +35,46 @@ static PIPELINE_DEFAULT_LAYOUT_BAD_MODULE: GpuTestConfiguration = GpuTestConfigu pipeline.get_bind_group_layout(0); }); }); + +const TRIVIAL_VERTEX_SHADER_DESC: wgpu::ShaderModuleDescriptor = wgpu::ShaderModuleDescriptor { + label: Some("trivial vertex shader"), + source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed( + "@vertex fn main() -> @builtin(position) vec4 { return vec4(0); }", + )), +}; + +#[gpu_test] +static NO_TARGETLESS_RENDER: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|ctx| { + fail(&ctx.device, || { + // Testing multisampling is important, because some backends don't behave well if one + // tries to compile code in an unsupported multisample count. Failing to validate here + // has historically resulted in requesting the back end to compile code. + for power_of_two in [1, 2, 4, 8, 16, 32, 64] { + ctx.device + .create_render_pipeline(&wgpu::RenderPipelineDescriptor { + label: None, + layout: None, + vertex: wgpu::VertexState { + module: &ctx.device.create_shader_module(TRIVIAL_VERTEX_SHADER_DESC), + entry_point: "main", + compilation_options: Default::default(), + buffers: &[], + }, + primitive: Default::default(), + depth_stencil: None, + multisample: wgpu::MultisampleState { + count: power_of_two, + ..Default::default() + }, + fragment: None, + multiview: None, + cache: None, + }); + } + }) + // TODO: concrete error message: + // At least one color attachment or depth-stencil attachment was expected, but no + // render target for the pipeline was specified. + });