From ec3f48242250668ca510ceef7336cf93ba80faa5 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 2 Mar 2021 00:56:51 +0000 Subject: [PATCH] D3D12: Fix ASSERT for external image tests Replaces use of EXPECT_EQ with ASSERT_EQ and allows ASSERT_EQ to propagate to caller so the test returns early. BUG=dawn:625 Change-Id: I6c12aad201f1821fa8c7c1f9a9b735910049cdcf Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42940 Reviewed-by: Austin Eng Reviewed-by: Rafael Cintron Reviewed-by: Bryan Bernhart Commit-Queue: Bryan Bernhart --- src/tests/end2end/D3D12ResourceWrappingTests.cpp | 5 +++++ src/tests/end2end/D3D12VideoViewsTests.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp index 72de44c07c..b8d3c65dc5 100644 --- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp +++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp @@ -439,6 +439,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D12) { ComPtr dxgiKeyedMutex; WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnSrcTexture, clearColor, &d3d11Texture, &dxgiKeyedMutex); + ASSERT_NE(dawnSrcTexture.Get(), nullptr); // Create a texture on the device and copy the source texture to it. wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&baseDawnDescriptor); @@ -462,6 +463,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11ReadbackInD3D12) { ComPtr dxgiKeyedMutex; WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor, &d3d11Texture, &dxgiKeyedMutex); + ASSERT_NE(dawnTexture.Get(), nullptr); // Readback the destination texture and ensure it contains the colors we used // to clear the source texture on the D3D device. @@ -482,6 +484,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D12ReadbackInD3D11) { ComPtr dxgiKeyedMutex; WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor, &d3d11Texture, &dxgiKeyedMutex); + ASSERT_NE(dawnTexture.Get(), nullptr); const wgpu::Color d3d12ClearColor{0.0f, 0.0f, 1.0f, 1.0f}; ClearImage(dawnTexture, d3d12ClearColor); @@ -507,6 +510,7 @@ TEST_P(D3D12SharedHandleUsageTests, ClearTwiceInD3D12ReadbackInD3D11) { ComPtr dxgiKeyedMutex; WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor, &d3d11Texture, &dxgiKeyedMutex); + ASSERT_NE(dawnTexture.Get(), nullptr); const wgpu::Color d3d12ClearColor1{0.0f, 0.0f, 1.0f, 1.0f}; ClearImage(dawnTexture, d3d12ClearColor1); @@ -534,6 +538,7 @@ TEST_P(D3D12SharedHandleUsageTests, UninitializedTextureIsCleared) { ComPtr dxgiKeyedMutex; WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor, &d3d11Texture, &dxgiKeyedMutex, false); + ASSERT_NE(dawnTexture.Get(), nullptr); // Readback the destination texture and ensure it contains the colors we used // to clear the source texture on the D3D device. diff --git a/src/tests/end2end/D3D12VideoViewsTests.cpp b/src/tests/end2end/D3D12VideoViewsTests.cpp index 6f7938de58..d460433c27 100644 --- a/src/tests/end2end/D3D12VideoViewsTests.cpp +++ b/src/tests/end2end/D3D12VideoViewsTests.cpp @@ -189,13 +189,13 @@ namespace { // texture is left uninitialized. This is required for D3D11 and D3D12 interop. ComPtr dxgiKeyedMutex; hr = d3d11Texture.As(&dxgiKeyedMutex); - EXPECT_EQ(hr, S_OK); + ASSERT_EQ(hr, S_OK); hr = dxgiKeyedMutex->AcquireSync(0, INFINITE); - EXPECT_EQ(hr, S_OK); + ASSERT_EQ(hr, S_OK); hr = dxgiKeyedMutex->ReleaseSync(1); - EXPECT_EQ(hr, S_OK); + ASSERT_EQ(hr, S_OK); // Open the DX11 texture in Dawn from the shared handle and return it as a WebGPU // texture. @@ -266,6 +266,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYtoR) { wgpu::Texture wgpuTexture; CreateVideoTextureForTest(wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::Sampled, /*isCheckerboard*/ false, &wgpuTexture); + ASSERT_NE(wgpuTexture.Get(), nullptr); wgpu::TextureViewDescriptor viewDesc; viewDesc.aspect = wgpu::TextureAspect::Plane0Only; @@ -318,6 +319,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleUVtoRG) { wgpu::Texture wgpuTexture; CreateVideoTextureForTest(wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::Sampled, /*isCheckerboard*/ false, &wgpuTexture); + ASSERT_NE(wgpuTexture.Get(), nullptr); wgpu::TextureViewDescriptor viewDesc; viewDesc.aspect = wgpu::TextureAspect::Plane1Only; @@ -371,6 +373,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYUVtoRGB) { wgpu::Texture wgpuTexture; CreateVideoTextureForTest(wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::Sampled, /*isCheckerboard*/ true, &wgpuTexture); + ASSERT_NE(wgpuTexture.Get(), nullptr); wgpu::TextureViewDescriptor lumaViewDesc; lumaViewDesc.aspect = wgpu::TextureAspect::Plane0Only;