Commit 351a94a4 authored by Corentin Wallez's avatar Corentin Wallez Committed by Commit Bot

Replace uses of deprecated Dawn APIs.

Bug: dawn:22
Change-Id: I57d322b931290bdb922ba8c4d9a28f52f2ae425f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2330053
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796833}
parent 99597677
...@@ -52,7 +52,6 @@ WGPUTexture ExternalVkImageDawnRepresentation::BeginAccess( ...@@ -52,7 +52,6 @@ WGPUTexture ExternalVkImageDawnRepresentation::BeginAccess(
texture_descriptor.usage = usage; texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D; texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1}; texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1; texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1; texture_descriptor.sampleCount = 1;
......
...@@ -111,13 +111,12 @@ class SharedImageRepresentationDawnIOSurface ...@@ -111,13 +111,12 @@ class SharedImageRepresentationDawnIOSurface
} }
WGPUTexture BeginAccess(WGPUTextureUsage usage) final { WGPUTexture BeginAccess(WGPUTextureUsage usage) final {
WGPUTextureDescriptor texture_descriptor; WGPUTextureDescriptor texture_descriptor = {};
texture_descriptor.nextInChain = nullptr; texture_descriptor.nextInChain = nullptr;
texture_descriptor.format = wgpu_format_; texture_descriptor.format = wgpu_format_;
texture_descriptor.usage = usage; texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D; texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1}; texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1; texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1; texture_descriptor.sampleCount = 1;
......
...@@ -79,13 +79,12 @@ WGPUTexture SharedImageRepresentationDawnD3D::BeginAccess( ...@@ -79,13 +79,12 @@ WGPUTexture SharedImageRepresentationDawnD3D::BeginAccess(
return nullptr; return nullptr;
} }
WGPUTextureDescriptor texture_descriptor; WGPUTextureDescriptor texture_descriptor = {};
texture_descriptor.nextInChain = nullptr; texture_descriptor.nextInChain = nullptr;
texture_descriptor.format = wgpu_format; texture_descriptor.format = wgpu_format;
texture_descriptor.usage = usage; texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D; texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1}; texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1; texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1; texture_descriptor.sampleCount = 1;
......
...@@ -64,7 +64,6 @@ WGPUTexture SharedImageRepresentationDawnOzone::BeginAccess( ...@@ -64,7 +64,6 @@ WGPUTexture SharedImageRepresentationDawnOzone::BeginAccess(
texture_descriptor.usage = usage; texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D; texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {pixmap_size.width(), pixmap_size.height(), 1}; texture_descriptor.size = {pixmap_size.width(), pixmap_size.height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1; texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1; texture_descriptor.sampleCount = 1;
......
...@@ -20,24 +20,15 @@ ...@@ -20,24 +20,15 @@
namespace gpu { namespace gpu {
namespace { namespace {
class MockBufferMapReadCallback { class MockBufferMapCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(void, Call, (WGPUBufferMapAsyncStatus status, void* userdata));
void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr,
uint64_t data_length,
void* userdata));
}; };
std::unique_ptr<testing::StrictMock<MockBufferMapCallback>>
mock_buffer_map_callback;
std::unique_ptr<testing::StrictMock<MockBufferMapReadCallback>> void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) {
mock_buffer_map_read_callback; mock_buffer_map_callback->Call(status, userdata);
void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* ptr,
uint64_t data_length,
void* userdata) {
// Assume the data is uint32_t
mock_buffer_map_read_callback->Call(status, static_cast<const uint32_t*>(ptr),
data_length, userdata);
} }
} // namespace } // namespace
...@@ -66,14 +57,14 @@ class SharedImageGLBackingProduceDawnTest : public WebGPUTest { ...@@ -66,14 +57,14 @@ class SharedImageGLBackingProduceDawnTest : public WebGPUTest {
gpu::kNullSurfaceHandle, attributes, option.shared_memory_limits, gpu::kNullSurfaceHandle, attributes, option.shared_memory_limits,
nullptr, nullptr, base::ThreadTaskRunnerHandle::Get()); nullptr, nullptr, base::ThreadTaskRunnerHandle::Get());
ASSERT_EQ(result, ContextResult::kSuccess); ASSERT_EQ(result, ContextResult::kSuccess);
mock_buffer_map_read_callback = mock_buffer_map_callback =
std::make_unique<testing::StrictMock<MockBufferMapReadCallback>>(); std::make_unique<testing::StrictMock<MockBufferMapCallback>>();
} }
void TearDown() override { void TearDown() override {
WebGPUTest::TearDown(); WebGPUTest::TearDown();
gl_context_.reset(); gl_context_.reset();
mock_buffer_map_read_callback = nullptr; mock_buffer_map_callback = nullptr;
} }
bool ShouldSkipTest() { bool ShouldSkipTest() {
...@@ -164,9 +155,9 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) { ...@@ -164,9 +155,9 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) {
wgpu::BufferCopyView copy_dst = {}; wgpu::BufferCopyView copy_dst = {};
copy_dst.buffer = readback_buffer; copy_dst.buffer = readback_buffer;
copy_dst.offset = 0; copy_dst.layout.offset = 0;
copy_dst.bytesPerRow = 256; copy_dst.layout.bytesPerRow = 256;
copy_dst.rowsPerImage = 0; copy_dst.layout.rowsPerImage = 0;
wgpu::Extent3D copy_size = {1, 1, 1}; wgpu::Extent3D copy_size = {1, 1, 1};
...@@ -181,15 +172,16 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) { ...@@ -181,15 +172,16 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) {
reservation.generation); reservation.generation);
// Map the buffer and assert the pixel is the correct value. // Map the buffer and assert the pixel is the correct value.
readback_buffer.MapReadAsync(ToMockBufferMapReadCallback, this); readback_buffer.MapAsync(wgpu::MapMode::Read, 0, 4, ToMockBufferMapCallback,
uint32_t buffer_contents = 0xFF00FF00; nullptr);
EXPECT_CALL(*mock_buffer_map_read_callback, EXPECT_CALL(*mock_buffer_map_callback,
Call(WGPUBufferMapAsyncStatus_Success, Call(WGPUBufferMapAsyncStatus_Success, nullptr))
testing::Pointee(testing::Eq(buffer_contents)),
sizeof(uint32_t), this))
.Times(1); .Times(1);
WaitForCompletion(device); WaitForCompletion(device);
const void* data = readback_buffer.GetConstMappedRange(0, 4);
EXPECT_EQ(0xFF00FF00, *static_cast<const uint32_t*>(data));
} }
} }
......
...@@ -14,24 +14,15 @@ ...@@ -14,24 +14,15 @@
namespace gpu { namespace gpu {
namespace { namespace {
class MockBufferMapReadCallback { class MockBufferMapCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(void, Call, (WGPUBufferMapAsyncStatus status, void* userdata));
void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr,
uint64_t data_length,
void* userdata));
}; };
std::unique_ptr<testing::StrictMock<MockBufferMapCallback>>
mock_buffer_map_callback;
std::unique_ptr<testing::StrictMock<MockBufferMapReadCallback>> void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) {
mock_buffer_map_read_callback; mock_buffer_map_callback->Call(status, userdata);
void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* ptr,
uint64_t data_length,
void* userdata) {
// Assume the data is uint32_t
mock_buffer_map_read_callback->Call(status, static_cast<const uint32_t*>(ptr),
data_length, userdata);
} }
class MockUncapturedErrorCallback { class MockUncapturedErrorCallback {
...@@ -55,14 +46,14 @@ class WebGPUMailboxTest : public WebGPUTest { ...@@ -55,14 +46,14 @@ class WebGPUMailboxTest : public WebGPUTest {
void SetUp() override { void SetUp() override {
WebGPUTest::SetUp(); WebGPUTest::SetUp();
Initialize(WebGPUTest::Options()); Initialize(WebGPUTest::Options());
mock_buffer_map_read_callback = mock_buffer_map_callback =
std::make_unique<testing::StrictMock<MockBufferMapReadCallback>>(); std::make_unique<testing::StrictMock<MockBufferMapCallback>>();
mock_device_error_callback = mock_device_error_callback =
std::make_unique<testing::StrictMock<MockUncapturedErrorCallback>>(); std::make_unique<testing::StrictMock<MockUncapturedErrorCallback>>();
} }
void TearDown() override { void TearDown() override {
mock_buffer_map_read_callback = nullptr; mock_buffer_map_callback = nullptr;
mock_device_error_callback = nullptr; mock_device_error_callback = nullptr;
WebGPUTest::TearDown(); WebGPUTest::TearDown();
} }
...@@ -153,9 +144,9 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) { ...@@ -153,9 +144,9 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) {
wgpu::BufferCopyView copy_dst = {}; wgpu::BufferCopyView copy_dst = {};
copy_dst.buffer = readback_buffer; copy_dst.buffer = readback_buffer;
copy_dst.offset = 0; copy_dst.layout.offset = 0;
copy_dst.bytesPerRow = 256; copy_dst.layout.bytesPerRow = 256;
copy_dst.rowsPerImage = 0; copy_dst.layout.rowsPerImage = 0;
wgpu::Extent3D copy_size = {1, 1, 1}; wgpu::Extent3D copy_size = {1, 1, 1};
...@@ -170,15 +161,16 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) { ...@@ -170,15 +161,16 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) {
reservation.generation); reservation.generation);
// Map the buffer and assert the pixel is the correct value. // Map the buffer and assert the pixel is the correct value.
readback_buffer.MapReadAsync(ToMockBufferMapReadCallback, 0); readback_buffer.MapAsync(wgpu::MapMode::Read, 0, 4, ToMockBufferMapCallback,
uint32_t buffer_contents = 0xFF00FF00; nullptr);
EXPECT_CALL(*mock_buffer_map_read_callback, EXPECT_CALL(*mock_buffer_map_callback,
Call(WGPUBufferMapAsyncStatus_Success, Call(WGPUBufferMapAsyncStatus_Success, nullptr))
testing::Pointee(testing::Eq(buffer_contents)),
sizeof(uint32_t), 0))
.Times(1); .Times(1);
WaitForCompletion(device); WaitForCompletion(device);
const void* data = readback_buffer.GetConstMappedRange(0, 4);
EXPECT_EQ(0xFF00FF00, *static_cast<const uint32_t*>(data));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment