Revert "Special-case GetDefaultQueue in the wire"

This reverts commit f93791ab62965964f413744bb73884dd6b9abc42.

Reason for revert: breaks gl_tests on roll.

Original change's description:
> Special-case GetDefaultQueue in the wire
> 
> This makes it so calling GetDefaultQueue always returns the same
> object. It required updating various WireTests to account for the
> additional wire calls.
> 
> Bug: dawn:22
> 
> Change-Id: I8c74374b7c732b8bb7d0490bbc740dee0d2dface
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19726
> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=cwallez@chromium.org,kainino@chromium.org,enga@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: dawn:22
Change-Id: Id2f051b1d4be64a6e16ee8bbe998d72028660334
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-20 15:33:20 +00:00 committed by Commit Bot service account
parent 98334dfdf7
commit 5e088591ca
11 changed files with 31 additions and 79 deletions

View File

@ -101,7 +101,6 @@
"BufferUnmap",
"DeviceCreateBuffer",
"DeviceCreateBufferMapped",
"DeviceGetDefaultQueue",
"DevicePushErrorScope",
"QueueCreateFence",
"QueueSignal"

View File

@ -370,11 +370,6 @@ namespace dawn_wire { namespace client {
void ClientDeviceRelease(WGPUDevice) {
}
WGPUQueue ClientHandwrittenDeviceGetDefaultQueue(WGPUDevice cSelf) {
Device* device = reinterpret_cast<Device*>(cSelf);
return device->GetDefaultQueue();
}
void ClientHandwrittenDeviceSetUncapturedErrorCallback(WGPUDevice cSelf,
WGPUErrorCallback callback,
void* userdata) {

View File

@ -21,6 +21,7 @@ namespace dawn_wire { namespace client {
Client::Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService)
: ClientBase(),
mDevice(DeviceAllocator().New(this)->object.get()),
mSerializer(serializer),
mMemoryTransferService(memoryTransferService) {
if (mMemoryTransferService == nullptr) {
@ -28,8 +29,6 @@ namespace dawn_wire { namespace client {
mOwnedMemoryTransferService = CreateInlineMemoryTransferService();
mMemoryTransferService = mOwnedMemoryTransferService.get();
}
mDevice = DeviceAllocator().New(this)->object.get();
}
Client::~Client() {

View File

@ -16,46 +16,20 @@
#include "common/Assert.h"
#include "dawn_wire/WireCmd_autogen.h"
#include "dawn_wire/client/ApiObjects_autogen.h"
#include "dawn_wire/client/Client.h"
#include "dawn_wire/client/ObjectAllocator.h"
namespace dawn_wire { namespace client {
Device::Device(Client* client, uint32_t initialRefcount, uint32_t initialId)
: ObjectBase(this, initialRefcount, initialId), mClient(client) {
this->device = this;
// Get the default queue for this device.
ObjectAllocator<Queue>::ObjectAndSerial* allocation = mClient->QueueAllocator().New(this);
mDefaultQueue = allocation->object.get();
DeviceGetDefaultQueueCmd cmd;
cmd.self = reinterpret_cast<WGPUDevice>(this);
cmd.result = ObjectHandle{allocation->object->id, allocation->generation};
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(mClient->GetCmdSpace(requiredSize));
cmd.Serialize(allocatedBuffer, *mClient);
}
Device::~Device() {
// Fire pending error scopes
auto errorScopes = std::move(mErrorScopes);
for (const auto& it : errorScopes) {
it.second.callback(WGPUErrorType_Unknown, "Device destroyed", it.second.userdata);
}
// Destroy the default queue
DestroyObjectCmd cmd;
cmd.objectType = ObjectType::Queue;
cmd.objectId = mDefaultQueue->id;
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(mClient->GetCmdSpace(requiredSize));
cmd.Serialize(allocatedBuffer);
mClient->QueueAllocator().Free(mDefaultQueue);
}
Client* Device::GetClient() {
@ -145,9 +119,4 @@ namespace dawn_wire { namespace client {
return true;
}
WGPUQueue Device::GetDefaultQueue() {
mDefaultQueue->refcount++;
return reinterpret_cast<WGPUQueue>(mDefaultQueue);
}
}} // namespace dawn_wire::client

View File

@ -24,7 +24,6 @@
namespace dawn_wire { namespace client {
class Client;
struct Queue;
class Device : public ObjectBase {
public:
@ -41,8 +40,6 @@ namespace dawn_wire { namespace client {
bool RequestPopErrorScope(WGPUErrorCallback callback, void* userdata);
bool PopErrorScope(uint64_t requestSerial, WGPUErrorType type, const char* message);
WGPUQueue GetDefaultQueue();
private:
struct ErrorScopeData {
WGPUErrorCallback callback = nullptr;
@ -56,10 +53,8 @@ namespace dawn_wire { namespace client {
WGPUErrorCallback mErrorCallback = nullptr;
WGPUDeviceLostCallback mDeviceLostCallback = nullptr;
bool mDidRunLostCallback = false;
void* mErrorUserdata = nullptr;
void* mDeviceLostUserdata = nullptr;
Queue* mDefaultQueue = nullptr;
void* mErrorUserdata;
void* mDeviceLostUserdata;
};
}} // namespace dawn_wire::client

View File

@ -25,7 +25,7 @@ class QueueTests : public DawnTest {};
TEST_P(QueueTests, GetDefaultQueueSameObject) {
wgpu::Queue q1 = device.GetDefaultQueue();
wgpu::Queue q2 = device.GetDefaultQueue();
EXPECT_EQ(q1.Get(), q2.Get());
EXPECT_EQ(q1.Get() == q2.Get(), !UsesWire());
}
DAWN_INSTANTIATE_TEST(QueueTests,

View File

@ -232,6 +232,11 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
.WillOnce(Return(apiCmdBufs[i]));
}
// Create queue
WGPUQueue queue = wgpuDeviceGetDefaultQueue(device);
WGPUQueue apiQueue = api.GetNewQueue();
EXPECT_CALL(api, DeviceGetDefaultQueue(apiDevice)).WillOnce(Return(apiQueue));
// Submit command buffer and check we got a call with both API-side command buffers
wgpuQueueSubmit(queue, 2, cmdBufs);

View File

@ -43,6 +43,12 @@ class WireFenceTests : public WireTest {
mockFenceOnCompletionCallback =
std::make_unique<StrictMock<MockFenceOnCompletionCallback>>();
{
queue = wgpuDeviceGetDefaultQueue(device);
apiQueue = api.GetNewQueue();
EXPECT_CALL(api, DeviceGetDefaultQueue(apiDevice)).WillOnce(Return(apiQueue));
FlushClient();
}
{
WGPUFenceDescriptor descriptor = {};
descriptor.initialValue = 1;
@ -83,6 +89,9 @@ class WireFenceTests : public WireTest {
// A successfully created fence
WGPUFence fence;
WGPUFence apiFence;
WGPUQueue queue;
WGPUQueue apiQueue;
};
// Check that signaling a fence succeeds
@ -218,8 +227,7 @@ TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
}
// Test that signaling a fence on a wrong queue is invalid
// DISABLED until we have support for multiple queues.
TEST_F(WireFenceTests, DISABLED_SignalWrongQueue) {
TEST_F(WireFenceTests, SignalWrongQueue) {
WGPUQueue queue2 = wgpuDeviceGetDefaultQueue(device);
WGPUQueue apiQueue2 = api.GetNewQueue();
EXPECT_CALL(api, DeviceGetDefaultQueue(apiDevice)).WillOnce(Return(apiQueue2));
@ -232,8 +240,7 @@ TEST_F(WireFenceTests, DISABLED_SignalWrongQueue) {
}
// Test that signaling a fence on a wrong queue does not update fence signaled value
// DISABLED until we have support for multiple queues.
TEST_F(WireFenceTests, DISABLED_SignalWrongQueueDoesNotUpdateValue) {
TEST_F(WireFenceTests, SignalWrongQueueDoesNotUpdateValue) {
WGPUQueue queue2 = wgpuDeviceGetDefaultQueue(device);
WGPUQueue apiQueue2 = api.GetNewQueue();
EXPECT_CALL(api, DeviceGetDefaultQueue(apiDevice)).WillOnce(Return(apiQueue2));

View File

@ -69,12 +69,6 @@ class WireMultipleDeviceTests : public testing::Test {
mS2cBuf->SetHandler(mWireClient.get());
mClientDevice = mWireClient->GetDevice();
// The GetDefaultQueue is done on WireClient startup so we expect it now.
mClientQueue = wgpuDeviceGetDefaultQueue(mClientDevice);
mServerQueue = mApi.GetNewQueue();
EXPECT_CALL(mApi, DeviceGetDefaultQueue(mServerDevice)).WillOnce(Return(mServerQueue));
FlushClient();
}
~WireHolder() {
@ -103,14 +97,6 @@ class WireMultipleDeviceTests : public testing::Test {
return mServerDevice;
}
WGPUQueue ClientQueue() {
return mClientQueue;
}
WGPUQueue ServerQueue() {
return mServerQueue;
}
private:
testing::StrictMock<MockProcTable> mApi;
std::unique_ptr<dawn_wire::WireServer> mWireServer;
@ -119,8 +105,6 @@ class WireMultipleDeviceTests : public testing::Test {
std::unique_ptr<utils::TerribleCommandBuffer> mC2sBuf;
WGPUDevice mServerDevice;
WGPUDevice mClientDevice;
WGPUQueue mServerQueue;
WGPUQueue mClientQueue;
};
void ExpectInjectedError(WireHolder* wire) {
@ -150,12 +134,20 @@ TEST_F(WireMultipleDeviceTests, ValidatesSameDevice) {
WireHolder wireA;
WireHolder wireB;
// Create the fence
// Create the objects
WGPUQueue queueA = wgpuDeviceGetDefaultQueue(wireA.ClientDevice());
WGPUQueue queueB = wgpuDeviceGetDefaultQueue(wireB.ClientDevice());
WGPUFenceDescriptor desc = {};
WGPUFence fenceA = wgpuQueueCreateFence(wireA.ClientQueue(), &desc);
WGPUFence fenceA = wgpuQueueCreateFence(queueA, &desc);
// Flush on wire B. We should see the queue created.
EXPECT_CALL(*wireB.Api(), DeviceGetDefaultQueue(wireB.ServerDevice()))
.WillOnce(Return(wireB.Api()->GetNewQueue()));
wireB.FlushClient();
// Signal with a fence from a different wire.
wgpuQueueSignal(wireB.ClientQueue(), fenceA, 1u);
wgpuQueueSignal(queueB, fenceA, 1u);
// We should inject an error into the server.
ExpectInjectedError(&wireB);

View File

@ -70,12 +70,6 @@ void WireTest::SetUp() {
dawnProcSetProcs(&clientProcs);
apiDevice = mockDevice;
// The GetDefaultQueue is done on WireClient startup so we expect it now.
queue = wgpuDeviceGetDefaultQueue(device);
apiQueue = api.GetNewQueue();
EXPECT_CALL(api, DeviceGetDefaultQueue(apiDevice)).WillOnce(Return(apiQueue));
FlushClient();
}
void WireTest::TearDown() {
@ -110,7 +104,6 @@ dawn_wire::WireClient* WireTest::GetWireClient() {
}
void WireTest::DeleteServer() {
EXPECT_CALL(api, QueueRelease(apiQueue)).Times(1);
mWireServer = nullptr;
}

View File

@ -123,9 +123,7 @@ class WireTest : public testing::Test {
testing::StrictMock<MockProcTable> api;
WGPUDevice apiDevice;
WGPUQueue apiQueue;
WGPUDevice device;
WGPUQueue queue;
dawn_wire::WireServer* GetWireServer();
dawn_wire::WireClient* GetWireClient();