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(
texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1;
......
......@@ -111,13 +111,12 @@ class SharedImageRepresentationDawnIOSurface
}
WGPUTexture BeginAccess(WGPUTextureUsage usage) final {
WGPUTextureDescriptor texture_descriptor;
WGPUTextureDescriptor texture_descriptor = {};
texture_descriptor.nextInChain = nullptr;
texture_descriptor.format = wgpu_format_;
texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1;
......
......@@ -79,13 +79,12 @@ WGPUTexture SharedImageRepresentationDawnD3D::BeginAccess(
return nullptr;
}
WGPUTextureDescriptor texture_descriptor;
WGPUTextureDescriptor texture_descriptor = {};
texture_descriptor.nextInChain = nullptr;
texture_descriptor.format = wgpu_format;
texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {size().width(), size().height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1;
......
......@@ -64,7 +64,6 @@ WGPUTexture SharedImageRepresentationDawnOzone::BeginAccess(
texture_descriptor.usage = usage;
texture_descriptor.dimension = WGPUTextureDimension_2D;
texture_descriptor.size = {pixmap_size.width(), pixmap_size.height(), 1};
texture_descriptor.arrayLayerCount = 1;
texture_descriptor.mipLevelCount = 1;
texture_descriptor.sampleCount = 1;
......
......@@ -20,24 +20,15 @@
namespace gpu {
namespace {
class MockBufferMapReadCallback {
class MockBufferMapCallback {
public:
MOCK_METHOD4(Call,
void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr,
uint64_t data_length,
void* userdata));
MOCK_METHOD(void, Call, (WGPUBufferMapAsyncStatus status, void* userdata));
};
std::unique_ptr<testing::StrictMock<MockBufferMapCallback>>
mock_buffer_map_callback;
std::unique_ptr<testing::StrictMock<MockBufferMapReadCallback>>
mock_buffer_map_read_callback;
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);
void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) {
mock_buffer_map_callback->Call(status, userdata);
}
} // namespace
......@@ -66,14 +57,14 @@ class SharedImageGLBackingProduceDawnTest : public WebGPUTest {
gpu::kNullSurfaceHandle, attributes, option.shared_memory_limits,
nullptr, nullptr, base::ThreadTaskRunnerHandle::Get());
ASSERT_EQ(result, ContextResult::kSuccess);
mock_buffer_map_read_callback =
std::make_unique<testing::StrictMock<MockBufferMapReadCallback>>();
mock_buffer_map_callback =
std::make_unique<testing::StrictMock<MockBufferMapCallback>>();
}
void TearDown() override {
WebGPUTest::TearDown();
gl_context_.reset();
mock_buffer_map_read_callback = nullptr;
mock_buffer_map_callback = nullptr;
}
bool ShouldSkipTest() {
......@@ -164,9 +155,9 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) {
wgpu::BufferCopyView copy_dst = {};
copy_dst.buffer = readback_buffer;
copy_dst.offset = 0;
copy_dst.bytesPerRow = 256;
copy_dst.rowsPerImage = 0;
copy_dst.layout.offset = 0;
copy_dst.layout.bytesPerRow = 256;
copy_dst.layout.rowsPerImage = 0;
wgpu::Extent3D copy_size = {1, 1, 1};
......@@ -181,15 +172,16 @@ TEST_F(SharedImageGLBackingProduceDawnTest, Basic) {
reservation.generation);
// Map the buffer and assert the pixel is the correct value.
readback_buffer.MapReadAsync(ToMockBufferMapReadCallback, this);
uint32_t buffer_contents = 0xFF00FF00;
EXPECT_CALL(*mock_buffer_map_read_callback,
Call(WGPUBufferMapAsyncStatus_Success,
testing::Pointee(testing::Eq(buffer_contents)),
sizeof(uint32_t), this))
readback_buffer.MapAsync(wgpu::MapMode::Read, 0, 4, ToMockBufferMapCallback,
nullptr);
EXPECT_CALL(*mock_buffer_map_callback,
Call(WGPUBufferMapAsyncStatus_Success, nullptr))
.Times(1);
WaitForCompletion(device);
const void* data = readback_buffer.GetConstMappedRange(0, 4);
EXPECT_EQ(0xFF00FF00, *static_cast<const uint32_t*>(data));
}
}
......
......@@ -14,24 +14,15 @@
namespace gpu {
namespace {
class MockBufferMapReadCallback {
class MockBufferMapCallback {
public:
MOCK_METHOD4(Call,
void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr,
uint64_t data_length,
void* userdata));
MOCK_METHOD(void, Call, (WGPUBufferMapAsyncStatus status, void* userdata));
};
std::unique_ptr<testing::StrictMock<MockBufferMapCallback>>
mock_buffer_map_callback;
std::unique_ptr<testing::StrictMock<MockBufferMapReadCallback>>
mock_buffer_map_read_callback;
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);
void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) {
mock_buffer_map_callback->Call(status, userdata);
}
class MockUncapturedErrorCallback {
......@@ -55,14 +46,14 @@ class WebGPUMailboxTest : public WebGPUTest {
void SetUp() override {
WebGPUTest::SetUp();
Initialize(WebGPUTest::Options());
mock_buffer_map_read_callback =
std::make_unique<testing::StrictMock<MockBufferMapReadCallback>>();
mock_buffer_map_callback =
std::make_unique<testing::StrictMock<MockBufferMapCallback>>();
mock_device_error_callback =
std::make_unique<testing::StrictMock<MockUncapturedErrorCallback>>();
}
void TearDown() override {
mock_buffer_map_read_callback = nullptr;
mock_buffer_map_callback = nullptr;
mock_device_error_callback = nullptr;
WebGPUTest::TearDown();
}
......@@ -153,9 +144,9 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) {
wgpu::BufferCopyView copy_dst = {};
copy_dst.buffer = readback_buffer;
copy_dst.offset = 0;
copy_dst.bytesPerRow = 256;
copy_dst.rowsPerImage = 0;
copy_dst.layout.offset = 0;
copy_dst.layout.bytesPerRow = 256;
copy_dst.layout.rowsPerImage = 0;
wgpu::Extent3D copy_size = {1, 1, 1};
......@@ -170,15 +161,16 @@ TEST_F(WebGPUMailboxTest, WriteToMailboxThenReadFromIt) {
reservation.generation);
// Map the buffer and assert the pixel is the correct value.
readback_buffer.MapReadAsync(ToMockBufferMapReadCallback, 0);
uint32_t buffer_contents = 0xFF00FF00;
EXPECT_CALL(*mock_buffer_map_read_callback,
Call(WGPUBufferMapAsyncStatus_Success,
testing::Pointee(testing::Eq(buffer_contents)),
sizeof(uint32_t), 0))
readback_buffer.MapAsync(wgpu::MapMode::Read, 0, 4, ToMockBufferMapCallback,
nullptr);
EXPECT_CALL(*mock_buffer_map_callback,
Call(WGPUBufferMapAsyncStatus_Success, nullptr))
.Times(1);
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