Skip to content

Commit 6d1cd88

Browse files
authored
Add test for surface configuration with view formats
Added a test for configuring a surface with view formats and presenting a texture.
1 parent 27a6a74 commit 6d1cd88

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/dawn/tests/end2end/SurfaceTests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,24 @@ TEST_P(SurfaceTests, Storage) {
719719
ASSERT_EQ(wgpu::Status::Success, surface.Present());
720720
}
721721

722+
// Test acquiring a texture from a surface configured with viewFormats.
723+
TEST_P(SurfaceTests, ConfigureWithViewFormats) {
724+
wgpu::Surface surface = CreateTestSurface();
725+
wgpu::SurfaceConfiguration config = GetPreferredConfiguration(surface);
726+
727+
// Reinterpretation between a format and its srgb counterpart is always
728+
// allowed; pick the counterpart of whatever the surface prefers.
729+
wgpu::TextureFormat viewFormat = utils::ToSrgbFormat(config.format);
730+
config.viewFormatCount = 1;
731+
config.viewFormats = &viewFormat;
732+
surface.Configure(&config);
733+
734+
wgpu::SurfaceTexture surfaceTexture;
735+
surface.GetCurrentTexture(&surfaceTexture); // aborts on Vulkan before the fix
736+
ClearTexture(surfaceTexture.texture, {1.0, 0.0, 0.0, 1.0});
737+
surface.Present();
738+
}
739+
722740
// TODO(crbug.com/465183957): Implement swap chain for WebGPUBackend.
723741
DAWN_INSTANTIATE_TEST(SurfaceTests,
724742
D3D11Backend(),

0 commit comments

Comments
 (0)