Rename CreateReady*Pipeline to Create*PipelineAsync
This follows the name change in the upstream WebGPU specification. Bug: dawn:529 Change-Id: I6d940dcc89f6b75136c642b578cb01bb8e40d681 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41720 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
1258e245a9
commit
2d3c2e3553
18
dawn.json
18
dawn.json
|
@ -597,16 +597,16 @@
|
||||||
{"name": "flipY", "type": "bool", "default": "false"}
|
{"name": "flipY", "type": "bool", "default": "false"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"create ready compute pipeline callback": {
|
"create compute pipeline async callback": {
|
||||||
"category": "callback",
|
"category": "callback",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "status", "type": "create ready pipeline status"},
|
{"name": "status", "type": "create pipeline async status"},
|
||||||
{"name": "pipeline", "type": "compute pipeline"},
|
{"name": "pipeline", "type": "compute pipeline"},
|
||||||
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen"},
|
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen"},
|
||||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"create ready pipeline status": {
|
"create pipeline async status": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "success"},
|
{"value": 0, "name": "success"},
|
||||||
|
@ -616,10 +616,10 @@
|
||||||
{"value": 4, "name": "unknown"}
|
{"value": 4, "name": "unknown"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"create ready render pipeline callback": {
|
"create render pipeline async callback": {
|
||||||
"category": "callback",
|
"category": "callback",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "status", "type": "create ready pipeline status"},
|
{"name": "status", "type": "create pipeline async status"},
|
||||||
{"name": "pipeline", "type": "render pipeline"},
|
{"name": "pipeline", "type": "render pipeline"},
|
||||||
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen"},
|
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen"},
|
||||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
|
@ -677,11 +677,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "create ready compute pipeline",
|
"name": "create compute pipeline async",
|
||||||
"returns": "void",
|
"returns": "void",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"},
|
{"name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"},
|
||||||
{"name": "callback", "type": "create ready compute pipeline callback"},
|
{"name": "callback", "type": "create compute pipeline async callback"},
|
||||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -700,11 +700,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "create ready render pipeline",
|
"name": "create render pipeline async",
|
||||||
"returns": "void",
|
"returns": "void",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "descriptor", "type": "render pipeline descriptor", "annotation": "const*"},
|
{"name": "descriptor", "type": "render pipeline descriptor", "annotation": "const*"},
|
||||||
{"name": "callback", "type": "create ready render pipeline callback"},
|
{"name": "callback", "type": "create render pipeline async callback"},
|
||||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,13 +36,13 @@
|
||||||
{ "name": "handle create info length", "type": "uint64_t" },
|
{ "name": "handle create info length", "type": "uint64_t" },
|
||||||
{ "name": "handle create info", "type": "uint8_t", "annotation": "const*", "length": "handle create info length", "skip_serialize": true}
|
{ "name": "handle create info", "type": "uint8_t", "annotation": "const*", "length": "handle create info length", "skip_serialize": true}
|
||||||
],
|
],
|
||||||
"device create ready compute pipeline": [
|
"device create compute pipeline async": [
|
||||||
{ "name": "device id", "type": "ObjectId" },
|
{ "name": "device id", "type": "ObjectId" },
|
||||||
{ "name": "request serial", "type": "uint64_t" },
|
{ "name": "request serial", "type": "uint64_t" },
|
||||||
{ "name": "pipeline object handle", "type": "ObjectHandle", "handle_type": "compute pipeline"},
|
{ "name": "pipeline object handle", "type": "ObjectHandle", "handle_type": "compute pipeline"},
|
||||||
{ "name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"}
|
{ "name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"}
|
||||||
],
|
],
|
||||||
"device create ready render pipeline": [
|
"device create render pipeline async": [
|
||||||
{ "name": "device id", "type": "ObjectId" },
|
{ "name": "device id", "type": "ObjectId" },
|
||||||
{ "name": "request serial", "type": "uint64_t" },
|
{ "name": "request serial", "type": "uint64_t" },
|
||||||
{ "name": "pipeline object handle", "type": "ObjectHandle", "handle_type": "render pipeline"},
|
{ "name": "pipeline object handle", "type": "ObjectHandle", "handle_type": "render pipeline"},
|
||||||
|
@ -85,16 +85,16 @@
|
||||||
{ "name": "read initial data info length", "type": "uint64_t" },
|
{ "name": "read initial data info length", "type": "uint64_t" },
|
||||||
{ "name": "read initial data info", "type": "uint8_t", "annotation": "const*", "length": "read initial data info length", "skip_serialize": true }
|
{ "name": "read initial data info", "type": "uint8_t", "annotation": "const*", "length": "read initial data info length", "skip_serialize": true }
|
||||||
],
|
],
|
||||||
"device create ready compute pipeline callback": [
|
"device create compute pipeline async callback": [
|
||||||
{ "name": "device", "type": "ObjectHandle", "handle_type": "device" },
|
{ "name": "device", "type": "ObjectHandle", "handle_type": "device" },
|
||||||
{ "name": "request serial", "type": "uint64_t" },
|
{ "name": "request serial", "type": "uint64_t" },
|
||||||
{ "name": "status", "type": "create ready pipeline status" },
|
{ "name": "status", "type": "create pipeline async status" },
|
||||||
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
||||||
],
|
],
|
||||||
"device create ready render pipeline callback": [
|
"device create render pipeline async callback": [
|
||||||
{ "name": "device", "type": "ObjectHandle", "handle_type": "device" },
|
{ "name": "device", "type": "ObjectHandle", "handle_type": "device" },
|
||||||
{ "name": "request serial", "type": "uint64_t" },
|
{ "name": "request serial", "type": "uint64_t" },
|
||||||
{ "name": "status", "type": "create ready pipeline status" },
|
{ "name": "status", "type": "create pipeline async status" },
|
||||||
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
||||||
],
|
],
|
||||||
"device uncaptured error callback": [
|
"device uncaptured error callback": [
|
||||||
|
@ -133,8 +133,8 @@
|
||||||
"BufferGetConstMappedRange",
|
"BufferGetConstMappedRange",
|
||||||
"BufferGetMappedRange",
|
"BufferGetMappedRange",
|
||||||
"DeviceCreateBuffer",
|
"DeviceCreateBuffer",
|
||||||
"DeviceCreateReadyComputePipeline",
|
"DeviceCreateComputePipelineAsync",
|
||||||
"DeviceCreateReadyRenderPipeline",
|
"DeviceCreateRenderPipelineAsync",
|
||||||
"DevicePopErrorScope",
|
"DevicePopErrorScope",
|
||||||
"DeviceSetDeviceLostCallback",
|
"DeviceSetDeviceLostCallback",
|
||||||
"DeviceSetUncapturedErrorCallback",
|
"DeviceSetUncapturedErrorCallback",
|
||||||
|
|
|
@ -199,8 +199,8 @@ source_set("dawn_native_sources") {
|
||||||
"ComputePipeline.h",
|
"ComputePipeline.h",
|
||||||
"CopyTextureForBrowserHelper.cpp",
|
"CopyTextureForBrowserHelper.cpp",
|
||||||
"CopyTextureForBrowserHelper.h",
|
"CopyTextureForBrowserHelper.h",
|
||||||
"CreateReadyPipelineTracker.cpp",
|
"CreatePipelineAsyncTracker.cpp",
|
||||||
"CreateReadyPipelineTracker.h",
|
"CreatePipelineAsyncTracker.h",
|
||||||
"Device.cpp",
|
"Device.cpp",
|
||||||
"Device.h",
|
"Device.h",
|
||||||
"DynamicUploader.cpp",
|
"DynamicUploader.cpp",
|
||||||
|
|
|
@ -72,8 +72,8 @@ target_sources(dawn_native PRIVATE
|
||||||
"ComputePipeline.h"
|
"ComputePipeline.h"
|
||||||
"CopyTextureForBrowserHelper.cpp"
|
"CopyTextureForBrowserHelper.cpp"
|
||||||
"CopyTextureForBrowserHelper.h"
|
"CopyTextureForBrowserHelper.h"
|
||||||
"CreateReadyPipelineTracker.cpp"
|
"CreatePipelineAsyncTracker.cpp"
|
||||||
"CreateReadyPipelineTracker.h"
|
"CreatePipelineAsyncTracker.h"
|
||||||
"Device.cpp"
|
"Device.cpp"
|
||||||
"Device.h"
|
"Device.h"
|
||||||
"DynamicUploader.cpp"
|
"DynamicUploader.cpp"
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
// Copyright 2020 The Dawn Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "dawn_native/CreatePipelineAsyncTracker.h"
|
||||||
|
|
||||||
|
#include "dawn_native/ComputePipeline.h"
|
||||||
|
#include "dawn_native/Device.h"
|
||||||
|
#include "dawn_native/RenderPipeline.h"
|
||||||
|
|
||||||
|
namespace dawn_native {
|
||||||
|
|
||||||
|
CreatePipelineAsyncTaskBase::CreatePipelineAsyncTaskBase(void* userdata) : mUserData(userdata) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatePipelineAsyncTaskBase::~CreatePipelineAsyncTaskBase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateComputePipelineAsyncTask::CreateComputePipelineAsyncTask(
|
||||||
|
ComputePipelineBase* pipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata)
|
||||||
|
: CreatePipelineAsyncTaskBase(userdata),
|
||||||
|
mPipeline(pipeline),
|
||||||
|
mCreateComputePipelineAsyncCallback(callback) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateComputePipelineAsyncTask::Finish(WGPUCreatePipelineAsyncStatus status) {
|
||||||
|
ASSERT(mPipeline != nullptr);
|
||||||
|
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
|
if (status != WGPUCreatePipelineAsyncStatus_Success) {
|
||||||
|
// TODO(jiawei.shao@intel.com): support handling device lost
|
||||||
|
ASSERT(status == WGPUCreatePipelineAsyncStatus_DeviceDestroyed);
|
||||||
|
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed,
|
||||||
|
nullptr, "Device destroyed before callback",
|
||||||
|
mUserData);
|
||||||
|
mPipeline->Release();
|
||||||
|
} else {
|
||||||
|
mCreateComputePipelineAsyncCallback(
|
||||||
|
status, reinterpret_cast<WGPUComputePipeline>(mPipeline), "", mUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set mCreateComputePipelineAsyncCallback to nullptr in case it is called more than once.
|
||||||
|
mCreateComputePipelineAsyncCallback = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateRenderPipelineAsyncTask::CreateRenderPipelineAsyncTask(
|
||||||
|
RenderPipelineBase* pipeline,
|
||||||
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
void* userdata)
|
||||||
|
: CreatePipelineAsyncTaskBase(userdata),
|
||||||
|
mPipeline(pipeline),
|
||||||
|
mCreateRenderPipelineAsyncCallback(callback) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRenderPipelineAsyncTask::Finish(WGPUCreatePipelineAsyncStatus status) {
|
||||||
|
ASSERT(mPipeline != nullptr);
|
||||||
|
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
|
if (status != WGPUCreatePipelineAsyncStatus_Success) {
|
||||||
|
// TODO(jiawei.shao@intel.com): support handling device lost
|
||||||
|
ASSERT(status == WGPUCreatePipelineAsyncStatus_DeviceDestroyed);
|
||||||
|
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed,
|
||||||
|
nullptr, "Device destroyed before callback",
|
||||||
|
mUserData);
|
||||||
|
mPipeline->Release();
|
||||||
|
} else {
|
||||||
|
mCreateRenderPipelineAsyncCallback(
|
||||||
|
status, reinterpret_cast<WGPURenderPipeline>(mPipeline), "", mUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set mCreatePipelineAsyncCallback to nullptr in case it is called more than once.
|
||||||
|
mCreateRenderPipelineAsyncCallback = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatePipelineAsyncTracker::CreatePipelineAsyncTracker(DeviceBase* device) : mDevice(device) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatePipelineAsyncTracker::~CreatePipelineAsyncTracker() {
|
||||||
|
ASSERT(mCreatePipelineAsyncTasksInFlight.Empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatePipelineAsyncTracker::TrackTask(std::unique_ptr<CreatePipelineAsyncTaskBase> task,
|
||||||
|
ExecutionSerial serial) {
|
||||||
|
mCreatePipelineAsyncTasksInFlight.Enqueue(std::move(task), serial);
|
||||||
|
mDevice->AddFutureSerial(serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatePipelineAsyncTracker::Tick(ExecutionSerial finishedSerial) {
|
||||||
|
for (auto& task : mCreatePipelineAsyncTasksInFlight.IterateUpTo(finishedSerial)) {
|
||||||
|
task->Finish(WGPUCreatePipelineAsyncStatus_Success);
|
||||||
|
}
|
||||||
|
mCreatePipelineAsyncTasksInFlight.ClearUpTo(finishedSerial);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatePipelineAsyncTracker::ClearForShutDown() {
|
||||||
|
for (auto& task : mCreatePipelineAsyncTasksInFlight.IterateAll()) {
|
||||||
|
task->Finish(WGPUCreatePipelineAsyncStatus_DeviceDestroyed);
|
||||||
|
}
|
||||||
|
mCreatePipelineAsyncTasksInFlight.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dawn_native
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Copyright 2020 The Dawn Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#ifndef DAWNNATIVE_CREATEPIPELINEASYNCTRACKER_H_
|
||||||
|
#define DAWNNATIVE_CREATEPIPELINEASYNCTRACKER_H_
|
||||||
|
|
||||||
|
#include "common/SerialQueue.h"
|
||||||
|
#include "dawn/webgpu.h"
|
||||||
|
#include "dawn_native/IntegerTypes.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace dawn_native {
|
||||||
|
|
||||||
|
class ComputePipelineBase;
|
||||||
|
class DeviceBase;
|
||||||
|
class PipelineBase;
|
||||||
|
class RenderPipelineBase;
|
||||||
|
|
||||||
|
struct CreatePipelineAsyncTaskBase {
|
||||||
|
CreatePipelineAsyncTaskBase(void* userData);
|
||||||
|
virtual ~CreatePipelineAsyncTaskBase();
|
||||||
|
|
||||||
|
virtual void Finish(WGPUCreatePipelineAsyncStatus status) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void* mUserData;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CreateComputePipelineAsyncTask final : public CreatePipelineAsyncTaskBase {
|
||||||
|
CreateComputePipelineAsyncTask(ComputePipelineBase* pipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
|
||||||
|
void Finish(WGPUCreatePipelineAsyncStatus status) final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ComputePipelineBase* mPipeline;
|
||||||
|
WGPUCreateComputePipelineAsyncCallback mCreateComputePipelineAsyncCallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CreateRenderPipelineAsyncTask final : public CreatePipelineAsyncTaskBase {
|
||||||
|
CreateRenderPipelineAsyncTask(RenderPipelineBase* pipeline,
|
||||||
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
|
||||||
|
void Finish(WGPUCreatePipelineAsyncStatus status) final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RenderPipelineBase* mPipeline;
|
||||||
|
WGPUCreateRenderPipelineAsyncCallback mCreateRenderPipelineAsyncCallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CreatePipelineAsyncTracker {
|
||||||
|
public:
|
||||||
|
CreatePipelineAsyncTracker(DeviceBase* device);
|
||||||
|
~CreatePipelineAsyncTracker();
|
||||||
|
|
||||||
|
void TrackTask(std::unique_ptr<CreatePipelineAsyncTaskBase> task, ExecutionSerial serial);
|
||||||
|
void Tick(ExecutionSerial finishedSerial);
|
||||||
|
void ClearForShutDown();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DeviceBase* mDevice;
|
||||||
|
SerialQueue<ExecutionSerial, std::unique_ptr<CreatePipelineAsyncTaskBase>>
|
||||||
|
mCreatePipelineAsyncTasksInFlight;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dawn_native
|
||||||
|
|
||||||
|
#endif // DAWNNATIVE_CREATEPIPELINEASYNCTRACKER_H_
|
|
@ -1,114 +0,0 @@
|
||||||
// Copyright 2020 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "dawn_native/CreateReadyPipelineTracker.h"
|
|
||||||
|
|
||||||
#include "dawn_native/ComputePipeline.h"
|
|
||||||
#include "dawn_native/Device.h"
|
|
||||||
#include "dawn_native/RenderPipeline.h"
|
|
||||||
|
|
||||||
namespace dawn_native {
|
|
||||||
|
|
||||||
CreateReadyPipelineTaskBase::CreateReadyPipelineTaskBase(void* userdata) : mUserData(userdata) {
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateReadyPipelineTaskBase::~CreateReadyPipelineTaskBase() {
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateReadyComputePipelineTask::CreateReadyComputePipelineTask(
|
|
||||||
ComputePipelineBase* pipeline,
|
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
|
||||||
void* userdata)
|
|
||||||
: CreateReadyPipelineTaskBase(userdata),
|
|
||||||
mPipeline(pipeline),
|
|
||||||
mCreateReadyComputePipelineCallback(callback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateReadyComputePipelineTask::Finish(WGPUCreateReadyPipelineStatus status) {
|
|
||||||
ASSERT(mPipeline != nullptr);
|
|
||||||
ASSERT(mCreateReadyComputePipelineCallback != nullptr);
|
|
||||||
|
|
||||||
if (status != WGPUCreateReadyPipelineStatus_Success) {
|
|
||||||
// TODO(jiawei.shao@intel.com): support handling device lost
|
|
||||||
ASSERT(status == WGPUCreateReadyPipelineStatus_DeviceDestroyed);
|
|
||||||
mCreateReadyComputePipelineCallback(WGPUCreateReadyPipelineStatus_DeviceDestroyed,
|
|
||||||
nullptr, "Device destroyed before callback",
|
|
||||||
mUserData);
|
|
||||||
mPipeline->Release();
|
|
||||||
} else {
|
|
||||||
mCreateReadyComputePipelineCallback(
|
|
||||||
status, reinterpret_cast<WGPUComputePipeline>(mPipeline), "", mUserData);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set mCreateReadyComputePipelineCallback to nullptr in case it is called more than once.
|
|
||||||
mCreateReadyComputePipelineCallback = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateReadyRenderPipelineTask::CreateReadyRenderPipelineTask(
|
|
||||||
RenderPipelineBase* pipeline,
|
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
|
||||||
void* userdata)
|
|
||||||
: CreateReadyPipelineTaskBase(userdata),
|
|
||||||
mPipeline(pipeline),
|
|
||||||
mCreateReadyRenderPipelineCallback(callback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateReadyRenderPipelineTask::Finish(WGPUCreateReadyPipelineStatus status) {
|
|
||||||
ASSERT(mPipeline != nullptr);
|
|
||||||
ASSERT(mCreateReadyRenderPipelineCallback != nullptr);
|
|
||||||
|
|
||||||
if (status != WGPUCreateReadyPipelineStatus_Success) {
|
|
||||||
// TODO(jiawei.shao@intel.com): support handling device lost
|
|
||||||
ASSERT(status == WGPUCreateReadyPipelineStatus_DeviceDestroyed);
|
|
||||||
mCreateReadyRenderPipelineCallback(WGPUCreateReadyPipelineStatus_DeviceDestroyed,
|
|
||||||
nullptr, "Device destroyed before callback",
|
|
||||||
mUserData);
|
|
||||||
mPipeline->Release();
|
|
||||||
} else {
|
|
||||||
mCreateReadyRenderPipelineCallback(
|
|
||||||
status, reinterpret_cast<WGPURenderPipeline>(mPipeline), "", mUserData);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set mCreateReadyPipelineCallback to nullptr in case it is called more than once.
|
|
||||||
mCreateReadyRenderPipelineCallback = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateReadyPipelineTracker::CreateReadyPipelineTracker(DeviceBase* device) : mDevice(device) {
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateReadyPipelineTracker::~CreateReadyPipelineTracker() {
|
|
||||||
ASSERT(mCreateReadyPipelineTasksInFlight.Empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateReadyPipelineTracker::TrackTask(std::unique_ptr<CreateReadyPipelineTaskBase> task,
|
|
||||||
ExecutionSerial serial) {
|
|
||||||
mCreateReadyPipelineTasksInFlight.Enqueue(std::move(task), serial);
|
|
||||||
mDevice->AddFutureSerial(serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateReadyPipelineTracker::Tick(ExecutionSerial finishedSerial) {
|
|
||||||
for (auto& task : mCreateReadyPipelineTasksInFlight.IterateUpTo(finishedSerial)) {
|
|
||||||
task->Finish(WGPUCreateReadyPipelineStatus_Success);
|
|
||||||
}
|
|
||||||
mCreateReadyPipelineTasksInFlight.ClearUpTo(finishedSerial);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateReadyPipelineTracker::ClearForShutDown() {
|
|
||||||
for (auto& task : mCreateReadyPipelineTasksInFlight.IterateAll()) {
|
|
||||||
task->Finish(WGPUCreateReadyPipelineStatus_DeviceDestroyed);
|
|
||||||
}
|
|
||||||
mCreateReadyPipelineTasksInFlight.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dawn_native
|
|
|
@ -1,82 +0,0 @@
|
||||||
// Copyright 2020 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef DAWNNATIVE_CREATEREADYPIPELINETRACKER_H_
|
|
||||||
#define DAWNNATIVE_CREATEREADYPIPELINETRACKER_H_
|
|
||||||
|
|
||||||
#include "common/SerialQueue.h"
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
#include "dawn_native/IntegerTypes.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace dawn_native {
|
|
||||||
|
|
||||||
class ComputePipelineBase;
|
|
||||||
class DeviceBase;
|
|
||||||
class PipelineBase;
|
|
||||||
class RenderPipelineBase;
|
|
||||||
|
|
||||||
struct CreateReadyPipelineTaskBase {
|
|
||||||
CreateReadyPipelineTaskBase(void* userData);
|
|
||||||
virtual ~CreateReadyPipelineTaskBase();
|
|
||||||
|
|
||||||
virtual void Finish(WGPUCreateReadyPipelineStatus status) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void* mUserData;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CreateReadyComputePipelineTask final : public CreateReadyPipelineTaskBase {
|
|
||||||
CreateReadyComputePipelineTask(ComputePipelineBase* pipeline,
|
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
|
|
||||||
void Finish(WGPUCreateReadyPipelineStatus status) final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ComputePipelineBase* mPipeline;
|
|
||||||
WGPUCreateReadyComputePipelineCallback mCreateReadyComputePipelineCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CreateReadyRenderPipelineTask final : public CreateReadyPipelineTaskBase {
|
|
||||||
CreateReadyRenderPipelineTask(RenderPipelineBase* pipeline,
|
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
|
|
||||||
void Finish(WGPUCreateReadyPipelineStatus status) final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
RenderPipelineBase* mPipeline;
|
|
||||||
WGPUCreateReadyRenderPipelineCallback mCreateReadyRenderPipelineCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CreateReadyPipelineTracker {
|
|
||||||
public:
|
|
||||||
CreateReadyPipelineTracker(DeviceBase* device);
|
|
||||||
~CreateReadyPipelineTracker();
|
|
||||||
|
|
||||||
void TrackTask(std::unique_ptr<CreateReadyPipelineTaskBase> task, ExecutionSerial serial);
|
|
||||||
void Tick(ExecutionSerial finishedSerial);
|
|
||||||
void ClearForShutDown();
|
|
||||||
|
|
||||||
private:
|
|
||||||
DeviceBase* mDevice;
|
|
||||||
SerialQueue<ExecutionSerial, std::unique_ptr<CreateReadyPipelineTaskBase>>
|
|
||||||
mCreateReadyPipelineTasksInFlight;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dawn_native
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "dawn_native/CommandBuffer.h"
|
#include "dawn_native/CommandBuffer.h"
|
||||||
#include "dawn_native/CommandEncoder.h"
|
#include "dawn_native/CommandEncoder.h"
|
||||||
#include "dawn_native/ComputePipeline.h"
|
#include "dawn_native/ComputePipeline.h"
|
||||||
#include "dawn_native/CreateReadyPipelineTracker.h"
|
#include "dawn_native/CreatePipelineAsyncTracker.h"
|
||||||
#include "dawn_native/DynamicUploader.h"
|
#include "dawn_native/DynamicUploader.h"
|
||||||
#include "dawn_native/ErrorData.h"
|
#include "dawn_native/ErrorData.h"
|
||||||
#include "dawn_native/ErrorScope.h"
|
#include "dawn_native/ErrorScope.h"
|
||||||
|
@ -123,7 +123,7 @@ namespace dawn_native {
|
||||||
mCaches = std::make_unique<DeviceBase::Caches>();
|
mCaches = std::make_unique<DeviceBase::Caches>();
|
||||||
mErrorScopeStack = std::make_unique<ErrorScopeStack>();
|
mErrorScopeStack = std::make_unique<ErrorScopeStack>();
|
||||||
mDynamicUploader = std::make_unique<DynamicUploader>(this);
|
mDynamicUploader = std::make_unique<DynamicUploader>(this);
|
||||||
mCreateReadyPipelineTracker = std::make_unique<CreateReadyPipelineTracker>(this);
|
mCreatePipelineAsyncTracker = std::make_unique<CreatePipelineAsyncTracker>(this);
|
||||||
mDeprecationWarnings = std::make_unique<DeprecationWarnings>();
|
mDeprecationWarnings = std::make_unique<DeprecationWarnings>();
|
||||||
mInternalPipelineStore = std::make_unique<InternalPipelineStore>();
|
mInternalPipelineStore = std::make_unique<InternalPipelineStore>();
|
||||||
mPersistentCache = std::make_unique<PersistentCache>(this);
|
mPersistentCache = std::make_unique<PersistentCache>(this);
|
||||||
|
@ -141,7 +141,7 @@ namespace dawn_native {
|
||||||
// Skip handling device facilities if they haven't even been created (or failed doing so)
|
// Skip handling device facilities if they haven't even been created (or failed doing so)
|
||||||
if (mState != State::BeingCreated) {
|
if (mState != State::BeingCreated) {
|
||||||
// Reject all async pipeline creations.
|
// Reject all async pipeline creations.
|
||||||
mCreateReadyPipelineTracker->ClearForShutDown();
|
mCreatePipelineAsyncTracker->ClearForShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect the device, depending on which state we are currently in.
|
// Disconnect the device, depending on which state we are currently in.
|
||||||
|
@ -186,7 +186,7 @@ namespace dawn_native {
|
||||||
mState = State::Disconnected;
|
mState = State::Disconnected;
|
||||||
|
|
||||||
mDynamicUploader = nullptr;
|
mDynamicUploader = nullptr;
|
||||||
mCreateReadyPipelineTracker = nullptr;
|
mCreatePipelineAsyncTracker = nullptr;
|
||||||
mPersistentCache = nullptr;
|
mPersistentCache = nullptr;
|
||||||
|
|
||||||
mEmptyBindGroupLayout = nullptr;
|
mEmptyBindGroupLayout = nullptr;
|
||||||
|
@ -705,21 +705,21 @@ namespace dawn_native {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void DeviceBase::CreateReadyComputePipeline(const ComputePipelineDescriptor* descriptor,
|
void DeviceBase::CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
ComputePipelineBase* result = nullptr;
|
ComputePipelineBase* result = nullptr;
|
||||||
MaybeError maybeError = CreateComputePipelineInternal(&result, descriptor);
|
MaybeError maybeError = CreateComputePipelineInternal(&result, descriptor);
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
callback(WGPUCreateReadyPipelineStatus_Error, nullptr, error->GetMessage().c_str(),
|
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
||||||
userdata);
|
userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateReadyComputePipelineTask> request =
|
std::unique_ptr<CreateComputePipelineAsyncTask> request =
|
||||||
std::make_unique<CreateReadyComputePipelineTask>(result, callback, userdata);
|
std::make_unique<CreateComputePipelineAsyncTask>(result, callback, userdata);
|
||||||
mCreateReadyPipelineTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
|
PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
|
@ -749,21 +749,21 @@ namespace dawn_native {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void DeviceBase::CreateReadyRenderPipeline(const RenderPipelineDescriptor* descriptor,
|
void DeviceBase::CreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor,
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
RenderPipelineBase* result = nullptr;
|
RenderPipelineBase* result = nullptr;
|
||||||
MaybeError maybeError = CreateRenderPipelineInternal(&result, descriptor);
|
MaybeError maybeError = CreateRenderPipelineInternal(&result, descriptor);
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
callback(WGPUCreateReadyPipelineStatus_Error, nullptr, error->GetMessage().c_str(),
|
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
||||||
userdata);
|
userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateReadyRenderPipelineTask> request =
|
std::unique_ptr<CreateRenderPipelineAsyncTask> request =
|
||||||
std::make_unique<CreateReadyRenderPipelineTask>(result, callback, userdata);
|
std::make_unique<CreateRenderPipelineAsyncTask>(result, callback, userdata);
|
||||||
mCreateReadyPipelineTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
RenderBundleEncoder* DeviceBase::CreateRenderBundleEncoder(
|
RenderBundleEncoder* DeviceBase::CreateRenderBundleEncoder(
|
||||||
const RenderBundleEncoderDescriptor* descriptor) {
|
const RenderBundleEncoderDescriptor* descriptor) {
|
||||||
|
@ -862,7 +862,7 @@ namespace dawn_native {
|
||||||
mDynamicUploader->Deallocate(mCompletedSerial);
|
mDynamicUploader->Deallocate(mCompletedSerial);
|
||||||
GetQueue()->Tick(mCompletedSerial);
|
GetQueue()->Tick(mCompletedSerial);
|
||||||
|
|
||||||
mCreateReadyPipelineTracker->Tick(mCompletedSerial);
|
mCreatePipelineAsyncTracker->Tick(mCompletedSerial);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !IsDeviceIdle();
|
return !IsDeviceIdle();
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native {
|
||||||
class AttachmentState;
|
class AttachmentState;
|
||||||
class AttachmentStateBlueprint;
|
class AttachmentStateBlueprint;
|
||||||
class BindGroupLayoutBase;
|
class BindGroupLayoutBase;
|
||||||
class CreateReadyPipelineTracker;
|
class CreatePipelineAsyncTracker;
|
||||||
class DynamicUploader;
|
class DynamicUploader;
|
||||||
class ErrorScopeStack;
|
class ErrorScopeStack;
|
||||||
class PersistentCache;
|
class PersistentCache;
|
||||||
|
@ -146,11 +146,11 @@ namespace dawn_native {
|
||||||
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
||||||
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
||||||
QuerySetBase* CreateQuerySet(const QuerySetDescriptor* descriptor);
|
QuerySetBase* CreateQuerySet(const QuerySetDescriptor* descriptor);
|
||||||
void CreateReadyComputePipeline(const ComputePipelineDescriptor* descriptor,
|
void CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void CreateReadyRenderPipeline(const RenderPipelineDescriptor* descriptor,
|
void CreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor,
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
RenderBundleEncoder* CreateRenderBundleEncoder(
|
RenderBundleEncoder* CreateRenderBundleEncoder(
|
||||||
const RenderBundleEncoderDescriptor* descriptor);
|
const RenderBundleEncoderDescriptor* descriptor);
|
||||||
|
@ -381,7 +381,7 @@ namespace dawn_native {
|
||||||
Ref<BindGroupLayoutBase> mEmptyBindGroupLayout;
|
Ref<BindGroupLayoutBase> mEmptyBindGroupLayout;
|
||||||
|
|
||||||
std::unique_ptr<DynamicUploader> mDynamicUploader;
|
std::unique_ptr<DynamicUploader> mDynamicUploader;
|
||||||
std::unique_ptr<CreateReadyPipelineTracker> mCreateReadyPipelineTracker;
|
std::unique_ptr<CreatePipelineAsyncTracker> mCreatePipelineAsyncTracker;
|
||||||
Ref<QueueBase> mQueue;
|
Ref<QueueBase> mQueue;
|
||||||
|
|
||||||
struct DeprecationWarnings;
|
struct DeprecationWarnings;
|
||||||
|
|
|
@ -93,26 +93,26 @@ namespace dawn_wire { namespace client {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::DoDeviceCreateReadyComputePipelineCallback(Device* device,
|
bool Client::DoDeviceCreateComputePipelineAsyncCallback(Device* device,
|
||||||
uint64_t requestSerial,
|
uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
// The device might have been deleted or recreated so this isn't an error.
|
// The device might have been deleted or recreated so this isn't an error.
|
||||||
if (device == nullptr) {
|
if (device == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return device->OnCreateReadyComputePipelineCallback(requestSerial, status, message);
|
return device->OnCreateComputePipelineAsyncCallback(requestSerial, status, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::DoDeviceCreateReadyRenderPipelineCallback(Device* device,
|
bool Client::DoDeviceCreateRenderPipelineAsyncCallback(Device* device,
|
||||||
uint64_t requestSerial,
|
uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
// The device might have been deleted or recreated so this isn't an error.
|
// The device might have been deleted or recreated so this isn't an error.
|
||||||
if (device == nullptr) {
|
if (device == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return device->OnCreateReadyRenderPipelineCallback(requestSerial, status, message);
|
return device->OnCreateRenderPipelineAsyncCallback(requestSerial, status, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace dawn_wire::client
|
}} // namespace dawn_wire::client
|
||||||
|
|
|
@ -55,16 +55,16 @@ namespace dawn_wire { namespace client {
|
||||||
it.second.userdata);
|
it.second.userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto createReadyPipelineRequests = std::move(mCreateReadyPipelineRequests);
|
auto createPipelineAsyncRequests = std::move(mCreatePipelineAsyncRequests);
|
||||||
for (const auto& it : createReadyPipelineRequests) {
|
for (const auto& it : createPipelineAsyncRequests) {
|
||||||
if (it.second.createReadyComputePipelineCallback != nullptr) {
|
if (it.second.createComputePipelineAsyncCallback != nullptr) {
|
||||||
it.second.createReadyComputePipelineCallback(
|
it.second.createComputePipelineAsyncCallback(
|
||||||
WGPUCreateReadyPipelineStatus_DeviceDestroyed, nullptr,
|
WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||||
"Device destroyed before callback", it.second.userdata);
|
"Device destroyed before callback", it.second.userdata);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(it.second.createReadyRenderPipelineCallback != nullptr);
|
ASSERT(it.second.createRenderPipelineAsyncCallback != nullptr);
|
||||||
it.second.createReadyRenderPipelineCallback(
|
it.second.createRenderPipelineAsyncCallback(
|
||||||
WGPUCreateReadyPipelineStatus_DeviceDestroyed, nullptr,
|
WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||||
"Device destroyed before callback", it.second.userdata);
|
"Device destroyed before callback", it.second.userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,20 +84,20 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::CancelCallbacksForDisconnect() {
|
void Device::CancelCallbacksForDisconnect() {
|
||||||
for (auto& it : mCreateReadyPipelineRequests) {
|
for (auto& it : mCreatePipelineAsyncRequests) {
|
||||||
ASSERT((it.second.createReadyComputePipelineCallback != nullptr) ^
|
ASSERT((it.second.createComputePipelineAsyncCallback != nullptr) ^
|
||||||
(it.second.createReadyRenderPipelineCallback != nullptr));
|
(it.second.createRenderPipelineAsyncCallback != nullptr));
|
||||||
if (it.second.createReadyRenderPipelineCallback) {
|
if (it.second.createRenderPipelineAsyncCallback) {
|
||||||
it.second.createReadyRenderPipelineCallback(
|
it.second.createRenderPipelineAsyncCallback(
|
||||||
WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, "Device lost",
|
WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr, "Device lost",
|
||||||
it.second.userdata);
|
it.second.userdata);
|
||||||
} else {
|
} else {
|
||||||
it.second.createReadyComputePipelineCallback(
|
it.second.createComputePipelineAsyncCallback(
|
||||||
WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, "Device lost",
|
WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr, "Device lost",
|
||||||
it.second.userdata);
|
it.second.userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCreateReadyPipelineRequests.clear();
|
mCreatePipelineAsyncRequests.clear();
|
||||||
|
|
||||||
for (auto& it : mErrorScopes) {
|
for (auto& it : mErrorScopes) {
|
||||||
it.second.callback(WGPUErrorType_DeviceLost, "Device lost", it.second.userdata);
|
it.second.callback(WGPUErrorType_DeviceLost, "Device lost", it.second.userdata);
|
||||||
|
@ -221,113 +221,113 @@ namespace dawn_wire { namespace client {
|
||||||
return GetQueue();
|
return GetQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::CreateReadyComputePipeline(WGPUComputePipelineDescriptor const* descriptor,
|
void Device::CreateComputePipelineAsync(WGPUComputePipelineDescriptor const* descriptor,
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
if (client->IsDisconnected()) {
|
if (client->IsDisconnected()) {
|
||||||
return callback(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr,
|
return callback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||||
"GPU device disconnected", userdata);
|
"GPU device disconnected", userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceCreateReadyComputePipelineCmd cmd;
|
DeviceCreateComputePipelineAsyncCmd cmd;
|
||||||
cmd.deviceId = this->id;
|
cmd.deviceId = this->id;
|
||||||
cmd.descriptor = descriptor;
|
cmd.descriptor = descriptor;
|
||||||
|
|
||||||
uint64_t serial = mCreateReadyPipelineRequestSerial++;
|
uint64_t serial = mCreatePipelineAsyncRequestSerial++;
|
||||||
ASSERT(mCreateReadyPipelineRequests.find(serial) == mCreateReadyPipelineRequests.end());
|
ASSERT(mCreatePipelineAsyncRequests.find(serial) == mCreatePipelineAsyncRequests.end());
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
|
|
||||||
auto* allocation = client->ComputePipelineAllocator().New(client);
|
auto* allocation = client->ComputePipelineAllocator().New(client);
|
||||||
CreateReadyPipelineRequest request = {};
|
CreatePipelineAsyncRequest request = {};
|
||||||
request.createReadyComputePipelineCallback = callback;
|
request.createComputePipelineAsyncCallback = callback;
|
||||||
request.userdata = userdata;
|
request.userdata = userdata;
|
||||||
request.pipelineObjectID = allocation->object->id;
|
request.pipelineObjectID = allocation->object->id;
|
||||||
|
|
||||||
cmd.pipelineObjectHandle = ObjectHandle{allocation->object->id, allocation->generation};
|
cmd.pipelineObjectHandle = ObjectHandle{allocation->object->id, allocation->generation};
|
||||||
client->SerializeCommand(cmd);
|
client->SerializeCommand(cmd);
|
||||||
|
|
||||||
mCreateReadyPipelineRequests[serial] = std::move(request);
|
mCreatePipelineAsyncRequests[serial] = std::move(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::OnCreateReadyComputePipelineCallback(uint64_t requestSerial,
|
bool Device::OnCreateComputePipelineAsyncCallback(uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
const auto& requestIt = mCreateReadyPipelineRequests.find(requestSerial);
|
const auto& requestIt = mCreatePipelineAsyncRequests.find(requestSerial);
|
||||||
if (requestIt == mCreateReadyPipelineRequests.end()) {
|
if (requestIt == mCreatePipelineAsyncRequests.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateReadyPipelineRequest request = std::move(requestIt->second);
|
CreatePipelineAsyncRequest request = std::move(requestIt->second);
|
||||||
mCreateReadyPipelineRequests.erase(requestIt);
|
mCreatePipelineAsyncRequests.erase(requestIt);
|
||||||
|
|
||||||
auto pipelineAllocation =
|
auto pipelineAllocation =
|
||||||
client->ComputePipelineAllocator().GetObject(request.pipelineObjectID);
|
client->ComputePipelineAllocator().GetObject(request.pipelineObjectID);
|
||||||
|
|
||||||
// If the return status is a failure we should give a null pipeline to the callback and
|
// If the return status is a failure we should give a null pipeline to the callback and
|
||||||
// free the allocation both on the client side and the server side.
|
// free the allocation both on the client side and the server side.
|
||||||
if (status != WGPUCreateReadyPipelineStatus_Success) {
|
if (status != WGPUCreatePipelineAsyncStatus_Success) {
|
||||||
client->ComputePipelineAllocator().Free(pipelineAllocation);
|
client->ComputePipelineAllocator().Free(pipelineAllocation);
|
||||||
request.createReadyComputePipelineCallback(status, nullptr, message, request.userdata);
|
request.createComputePipelineAsyncCallback(status, nullptr, message, request.userdata);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WGPUComputePipeline pipeline = reinterpret_cast<WGPUComputePipeline>(pipelineAllocation);
|
WGPUComputePipeline pipeline = reinterpret_cast<WGPUComputePipeline>(pipelineAllocation);
|
||||||
request.createReadyComputePipelineCallback(status, pipeline, message, request.userdata);
|
request.createComputePipelineAsyncCallback(status, pipeline, message, request.userdata);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::CreateReadyRenderPipeline(WGPURenderPipelineDescriptor const* descriptor,
|
void Device::CreateRenderPipelineAsync(WGPURenderPipelineDescriptor const* descriptor,
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
if (client->IsDisconnected()) {
|
if (client->IsDisconnected()) {
|
||||||
return callback(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr,
|
return callback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||||
"GPU device disconnected", userdata);
|
"GPU device disconnected", userdata);
|
||||||
}
|
}
|
||||||
DeviceCreateReadyRenderPipelineCmd cmd;
|
DeviceCreateRenderPipelineAsyncCmd cmd;
|
||||||
cmd.deviceId = this->id;
|
cmd.deviceId = this->id;
|
||||||
cmd.descriptor = descriptor;
|
cmd.descriptor = descriptor;
|
||||||
|
|
||||||
uint64_t serial = mCreateReadyPipelineRequestSerial++;
|
uint64_t serial = mCreatePipelineAsyncRequestSerial++;
|
||||||
ASSERT(mCreateReadyPipelineRequests.find(serial) == mCreateReadyPipelineRequests.end());
|
ASSERT(mCreatePipelineAsyncRequests.find(serial) == mCreatePipelineAsyncRequests.end());
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
|
|
||||||
auto* allocation = client->RenderPipelineAllocator().New(client);
|
auto* allocation = client->RenderPipelineAllocator().New(client);
|
||||||
CreateReadyPipelineRequest request = {};
|
CreatePipelineAsyncRequest request = {};
|
||||||
request.createReadyRenderPipelineCallback = callback;
|
request.createRenderPipelineAsyncCallback = callback;
|
||||||
request.userdata = userdata;
|
request.userdata = userdata;
|
||||||
request.pipelineObjectID = allocation->object->id;
|
request.pipelineObjectID = allocation->object->id;
|
||||||
|
|
||||||
cmd.pipelineObjectHandle = ObjectHandle(allocation->object->id, allocation->generation);
|
cmd.pipelineObjectHandle = ObjectHandle(allocation->object->id, allocation->generation);
|
||||||
client->SerializeCommand(cmd);
|
client->SerializeCommand(cmd);
|
||||||
|
|
||||||
mCreateReadyPipelineRequests[serial] = std::move(request);
|
mCreatePipelineAsyncRequests[serial] = std::move(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::OnCreateReadyRenderPipelineCallback(uint64_t requestSerial,
|
bool Device::OnCreateRenderPipelineAsyncCallback(uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
const auto& requestIt = mCreateReadyPipelineRequests.find(requestSerial);
|
const auto& requestIt = mCreatePipelineAsyncRequests.find(requestSerial);
|
||||||
if (requestIt == mCreateReadyPipelineRequests.end()) {
|
if (requestIt == mCreatePipelineAsyncRequests.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateReadyPipelineRequest request = std::move(requestIt->second);
|
CreatePipelineAsyncRequest request = std::move(requestIt->second);
|
||||||
mCreateReadyPipelineRequests.erase(requestIt);
|
mCreatePipelineAsyncRequests.erase(requestIt);
|
||||||
|
|
||||||
auto pipelineAllocation =
|
auto pipelineAllocation =
|
||||||
client->RenderPipelineAllocator().GetObject(request.pipelineObjectID);
|
client->RenderPipelineAllocator().GetObject(request.pipelineObjectID);
|
||||||
|
|
||||||
// If the return status is a failure we should give a null pipeline to the callback and
|
// If the return status is a failure we should give a null pipeline to the callback and
|
||||||
// free the allocation both on the client side and the server side.
|
// free the allocation both on the client side and the server side.
|
||||||
if (status != WGPUCreateReadyPipelineStatus_Success) {
|
if (status != WGPUCreatePipelineAsyncStatus_Success) {
|
||||||
client->RenderPipelineAllocator().Free(pipelineAllocation);
|
client->RenderPipelineAllocator().Free(pipelineAllocation);
|
||||||
request.createReadyRenderPipelineCallback(status, nullptr, message, request.userdata);
|
request.createRenderPipelineAsyncCallback(status, nullptr, message, request.userdata);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WGPURenderPipeline pipeline = reinterpret_cast<WGPURenderPipeline>(pipelineAllocation);
|
WGPURenderPipeline pipeline = reinterpret_cast<WGPURenderPipeline>(pipelineAllocation);
|
||||||
request.createReadyRenderPipelineCallback(status, pipeline, message, request.userdata);
|
request.createRenderPipelineAsyncCallback(status, pipeline, message, request.userdata);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ namespace dawn_wire { namespace client {
|
||||||
bool PopErrorScope(WGPUErrorCallback callback, void* userdata);
|
bool PopErrorScope(WGPUErrorCallback callback, void* userdata);
|
||||||
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor* descriptor);
|
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor* descriptor);
|
||||||
WGPUBuffer CreateErrorBuffer();
|
WGPUBuffer CreateErrorBuffer();
|
||||||
void CreateReadyComputePipeline(WGPUComputePipelineDescriptor const* descriptor,
|
void CreateComputePipelineAsync(WGPUComputePipelineDescriptor const* descriptor,
|
||||||
WGPUCreateReadyComputePipelineCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void CreateReadyRenderPipeline(WGPURenderPipelineDescriptor const* descriptor,
|
void CreateRenderPipelineAsync(WGPURenderPipelineDescriptor const* descriptor,
|
||||||
WGPUCreateReadyRenderPipelineCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
|
||||||
void HandleError(WGPUErrorType errorType, const char* message);
|
void HandleError(WGPUErrorType errorType, const char* message);
|
||||||
|
@ -54,11 +54,11 @@ namespace dawn_wire { namespace client {
|
||||||
bool OnPopErrorScopeCallback(uint64_t requestSerial,
|
bool OnPopErrorScopeCallback(uint64_t requestSerial,
|
||||||
WGPUErrorType type,
|
WGPUErrorType type,
|
||||||
const char* message);
|
const char* message);
|
||||||
bool OnCreateReadyComputePipelineCallback(uint64_t requestSerial,
|
bool OnCreateComputePipelineAsyncCallback(uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message);
|
const char* message);
|
||||||
bool OnCreateReadyRenderPipelineCallback(uint64_t requestSerial,
|
bool OnCreateRenderPipelineAsyncCallback(uint64_t requestSerial,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
const char* message);
|
const char* message);
|
||||||
|
|
||||||
// TODO(dawn:22): Remove once the deprecation period is finished.
|
// TODO(dawn:22): Remove once the deprecation period is finished.
|
||||||
|
@ -78,14 +78,14 @@ namespace dawn_wire { namespace client {
|
||||||
uint64_t mErrorScopeRequestSerial = 0;
|
uint64_t mErrorScopeRequestSerial = 0;
|
||||||
uint64_t mErrorScopeStackSize = 0;
|
uint64_t mErrorScopeStackSize = 0;
|
||||||
|
|
||||||
struct CreateReadyPipelineRequest {
|
struct CreatePipelineAsyncRequest {
|
||||||
WGPUCreateReadyComputePipelineCallback createReadyComputePipelineCallback = nullptr;
|
WGPUCreateComputePipelineAsyncCallback createComputePipelineAsyncCallback = nullptr;
|
||||||
WGPUCreateReadyRenderPipelineCallback createReadyRenderPipelineCallback = nullptr;
|
WGPUCreateRenderPipelineAsyncCallback createRenderPipelineAsyncCallback = nullptr;
|
||||||
void* userdata = nullptr;
|
void* userdata = nullptr;
|
||||||
ObjectId pipelineObjectID;
|
ObjectId pipelineObjectID;
|
||||||
};
|
};
|
||||||
std::map<uint64_t, CreateReadyPipelineRequest> mCreateReadyPipelineRequests;
|
std::map<uint64_t, CreatePipelineAsyncRequest> mCreatePipelineAsyncRequests;
|
||||||
uint64_t mCreateReadyPipelineRequestSerial = 0;
|
uint64_t mCreatePipelineAsyncRequestSerial = 0;
|
||||||
|
|
||||||
WGPUErrorCallback mErrorCallback = nullptr;
|
WGPUErrorCallback mErrorCallback = nullptr;
|
||||||
WGPUDeviceLostCallback mDeviceLostCallback = nullptr;
|
WGPUDeviceLostCallback mDeviceLostCallback = nullptr;
|
||||||
|
|
|
@ -141,7 +141,7 @@ namespace dawn_wire { namespace server {
|
||||||
uint64_t requestSerial;
|
uint64_t requestSerial;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CreateReadyPipelineUserData : CallbackUserdata {
|
struct CreatePipelineAsyncUserData : CallbackUserdata {
|
||||||
using CallbackUserdata::CallbackUserdata;
|
using CallbackUserdata::CallbackUserdata;
|
||||||
|
|
||||||
ObjectHandle device;
|
ObjectHandle device;
|
||||||
|
@ -202,14 +202,14 @@ namespace dawn_wire { namespace server {
|
||||||
FenceCompletionUserdata* userdata);
|
FenceCompletionUserdata* userdata);
|
||||||
void OnFenceOnCompletion(WGPUFenceCompletionStatus status,
|
void OnFenceOnCompletion(WGPUFenceCompletionStatus status,
|
||||||
FenceOnCompletionUserdata* userdata);
|
FenceOnCompletionUserdata* userdata);
|
||||||
void OnCreateReadyComputePipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void OnCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPUComputePipeline pipeline,
|
WGPUComputePipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
CreateReadyPipelineUserData* userdata);
|
CreatePipelineAsyncUserData* userdata);
|
||||||
void OnCreateReadyRenderPipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void OnCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPURenderPipeline pipeline,
|
WGPURenderPipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
CreateReadyPipelineUserData* userdata);
|
CreatePipelineAsyncUserData* userdata);
|
||||||
|
|
||||||
#include "dawn_wire/server/ServerPrototypes_autogen.inc"
|
#include "dawn_wire/server/ServerPrototypes_autogen.inc"
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@ namespace dawn_wire { namespace server {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <ObjectType objectType, typename Pipeline>
|
template <ObjectType objectType, typename Pipeline>
|
||||||
void HandleCreateReadyRenderPipelineCallbackResult(KnownObjects<Pipeline>* knownObjects,
|
void HandleCreateRenderPipelineAsyncCallbackResult(KnownObjects<Pipeline>* knownObjects,
|
||||||
WGPUCreateReadyPipelineStatus status,
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
Pipeline pipeline,
|
Pipeline pipeline,
|
||||||
CreateReadyPipelineUserData* data) {
|
CreatePipelineAsyncUserData* data) {
|
||||||
// May be null if the device was destroyed. Device destruction destroys child
|
// May be null if the device was destroyed. Device destruction destroys child
|
||||||
// objects on the wire.
|
// objects on the wire.
|
||||||
auto* pipelineObject =
|
auto* pipelineObject =
|
||||||
|
@ -31,7 +31,7 @@ namespace dawn_wire { namespace server {
|
||||||
// they move from Reserved to Allocated, or if they are destroyed here.
|
// they move from Reserved to Allocated, or if they are destroyed here.
|
||||||
ASSERT(pipelineObject != nullptr);
|
ASSERT(pipelineObject != nullptr);
|
||||||
|
|
||||||
if (status == WGPUCreateReadyPipelineStatus_Success) {
|
if (status == WGPUCreatePipelineAsyncStatus_Success) {
|
||||||
// Assign the handle and allocated status if the pipeline is created successfully.
|
// Assign the handle and allocated status if the pipeline is created successfully.
|
||||||
pipelineObject->state = AllocationState::Allocated;
|
pipelineObject->state = AllocationState::Allocated;
|
||||||
pipelineObject->handle = pipeline;
|
pipelineObject->handle = pipeline;
|
||||||
|
@ -101,7 +101,7 @@ namespace dawn_wire { namespace server {
|
||||||
SerializeCommand(cmd);
|
SerializeCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::DoDeviceCreateReadyComputePipeline(
|
bool Server::DoDeviceCreateComputePipelineAsync(
|
||||||
ObjectId deviceId,
|
ObjectId deviceId,
|
||||||
uint64_t requestSerial,
|
uint64_t requestSerial,
|
||||||
ObjectHandle pipelineObjectHandle,
|
ObjectHandle pipelineObjectHandle,
|
||||||
|
@ -120,27 +120,27 @@ namespace dawn_wire { namespace server {
|
||||||
resultData->generation = pipelineObjectHandle.generation;
|
resultData->generation = pipelineObjectHandle.generation;
|
||||||
resultData->deviceInfo = device->info.get();
|
resultData->deviceInfo = device->info.get();
|
||||||
|
|
||||||
auto userdata = MakeUserdata<CreateReadyPipelineUserData>();
|
auto userdata = MakeUserdata<CreatePipelineAsyncUserData>();
|
||||||
userdata->device = ObjectHandle{deviceId, device->generation};
|
userdata->device = ObjectHandle{deviceId, device->generation};
|
||||||
userdata->requestSerial = requestSerial;
|
userdata->requestSerial = requestSerial;
|
||||||
userdata->pipelineObjectID = pipelineObjectHandle.id;
|
userdata->pipelineObjectID = pipelineObjectHandle.id;
|
||||||
|
|
||||||
mProcs.deviceCreateReadyComputePipeline(
|
mProcs.deviceCreateComputePipelineAsync(
|
||||||
device->handle, descriptor,
|
device->handle, descriptor,
|
||||||
ForwardToServer<decltype(&Server::OnCreateReadyComputePipelineCallback)>::Func<
|
ForwardToServer<decltype(&Server::OnCreateComputePipelineAsyncCallback)>::Func<
|
||||||
&Server::OnCreateReadyComputePipelineCallback>(),
|
&Server::OnCreateComputePipelineAsyncCallback>(),
|
||||||
userdata.release());
|
userdata.release());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnCreateReadyComputePipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void Server::OnCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPUComputePipeline pipeline,
|
WGPUComputePipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
CreateReadyPipelineUserData* data) {
|
CreatePipelineAsyncUserData* data) {
|
||||||
HandleCreateReadyRenderPipelineCallbackResult<ObjectType::ComputePipeline>(
|
HandleCreateRenderPipelineAsyncCallbackResult<ObjectType::ComputePipeline>(
|
||||||
&ComputePipelineObjects(), status, pipeline, data);
|
&ComputePipelineObjects(), status, pipeline, data);
|
||||||
|
|
||||||
ReturnDeviceCreateReadyComputePipelineCallbackCmd cmd;
|
ReturnDeviceCreateComputePipelineAsyncCallbackCmd cmd;
|
||||||
cmd.device = data->device;
|
cmd.device = data->device;
|
||||||
cmd.status = status;
|
cmd.status = status;
|
||||||
cmd.requestSerial = data->requestSerial;
|
cmd.requestSerial = data->requestSerial;
|
||||||
|
@ -149,7 +149,7 @@ namespace dawn_wire { namespace server {
|
||||||
SerializeCommand(cmd);
|
SerializeCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::DoDeviceCreateReadyRenderPipeline(ObjectId deviceId,
|
bool Server::DoDeviceCreateRenderPipelineAsync(ObjectId deviceId,
|
||||||
uint64_t requestSerial,
|
uint64_t requestSerial,
|
||||||
ObjectHandle pipelineObjectHandle,
|
ObjectHandle pipelineObjectHandle,
|
||||||
const WGPURenderPipelineDescriptor* descriptor) {
|
const WGPURenderPipelineDescriptor* descriptor) {
|
||||||
|
@ -167,27 +167,27 @@ namespace dawn_wire { namespace server {
|
||||||
resultData->generation = pipelineObjectHandle.generation;
|
resultData->generation = pipelineObjectHandle.generation;
|
||||||
resultData->deviceInfo = device->info.get();
|
resultData->deviceInfo = device->info.get();
|
||||||
|
|
||||||
auto userdata = MakeUserdata<CreateReadyPipelineUserData>();
|
auto userdata = MakeUserdata<CreatePipelineAsyncUserData>();
|
||||||
userdata->device = ObjectHandle{deviceId, device->generation};
|
userdata->device = ObjectHandle{deviceId, device->generation};
|
||||||
userdata->requestSerial = requestSerial;
|
userdata->requestSerial = requestSerial;
|
||||||
userdata->pipelineObjectID = pipelineObjectHandle.id;
|
userdata->pipelineObjectID = pipelineObjectHandle.id;
|
||||||
|
|
||||||
mProcs.deviceCreateReadyRenderPipeline(
|
mProcs.deviceCreateRenderPipelineAsync(
|
||||||
device->handle, descriptor,
|
device->handle, descriptor,
|
||||||
ForwardToServer<decltype(&Server::OnCreateReadyRenderPipelineCallback)>::Func<
|
ForwardToServer<decltype(&Server::OnCreateRenderPipelineAsyncCallback)>::Func<
|
||||||
&Server::OnCreateReadyRenderPipelineCallback>(),
|
&Server::OnCreateRenderPipelineAsyncCallback>(),
|
||||||
userdata.release());
|
userdata.release());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnCreateReadyRenderPipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void Server::OnCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPURenderPipeline pipeline,
|
WGPURenderPipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
CreateReadyPipelineUserData* data) {
|
CreatePipelineAsyncUserData* data) {
|
||||||
HandleCreateReadyRenderPipelineCallbackResult<ObjectType::RenderPipeline>(
|
HandleCreateRenderPipelineAsyncCallbackResult<ObjectType::RenderPipeline>(
|
||||||
&RenderPipelineObjects(), status, pipeline, data);
|
&RenderPipelineObjects(), status, pipeline, data);
|
||||||
|
|
||||||
ReturnDeviceCreateReadyRenderPipelineCallbackCmd cmd;
|
ReturnDeviceCreateRenderPipelineAsyncCallbackCmd cmd;
|
||||||
cmd.device = data->device;
|
cmd.device = data->device;
|
||||||
cmd.status = status;
|
cmd.status = status;
|
||||||
cmd.requestSerial = data->requestSerial;
|
cmd.requestSerial = data->requestSerial;
|
||||||
|
|
|
@ -221,7 +221,7 @@ test("dawn_unittests") {
|
||||||
"unittests/wire/WireArgumentTests.cpp",
|
"unittests/wire/WireArgumentTests.cpp",
|
||||||
"unittests/wire/WireBasicTests.cpp",
|
"unittests/wire/WireBasicTests.cpp",
|
||||||
"unittests/wire/WireBufferMappingTests.cpp",
|
"unittests/wire/WireBufferMappingTests.cpp",
|
||||||
"unittests/wire/WireCreateReadyPipelineTests.cpp",
|
"unittests/wire/WireCreatePipelineAsyncTests.cpp",
|
||||||
"unittests/wire/WireDestroyObjectTests.cpp",
|
"unittests/wire/WireDestroyObjectTests.cpp",
|
||||||
"unittests/wire/WireDisconnectTests.cpp",
|
"unittests/wire/WireDisconnectTests.cpp",
|
||||||
"unittests/wire/WireErrorCallbackTests.cpp",
|
"unittests/wire/WireErrorCallbackTests.cpp",
|
||||||
|
@ -283,7 +283,7 @@ source_set("dawn_end2end_tests_sources") {
|
||||||
"end2end/ComputeStorageBufferBarrierTests.cpp",
|
"end2end/ComputeStorageBufferBarrierTests.cpp",
|
||||||
"end2end/CopyTests.cpp",
|
"end2end/CopyTests.cpp",
|
||||||
"end2end/CopyTextureForBrowserTests.cpp",
|
"end2end/CopyTextureForBrowserTests.cpp",
|
||||||
"end2end/CreateReadyPipelineTests.cpp",
|
"end2end/CreatePipelineAsyncTests.cpp",
|
||||||
"end2end/CullingTests.cpp",
|
"end2end/CullingTests.cpp",
|
||||||
"end2end/DebugMarkerTests.cpp",
|
"end2end/DebugMarkerTests.cpp",
|
||||||
"end2end/DeprecatedAPITests.cpp",
|
"end2end/DeprecatedAPITests.cpp",
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct CreateReadyPipelineTask {
|
struct CreatePipelineAsyncTask {
|
||||||
wgpu::ComputePipeline computePipeline = nullptr;
|
wgpu::ComputePipeline computePipeline = nullptr;
|
||||||
wgpu::RenderPipeline renderPipeline = nullptr;
|
wgpu::RenderPipeline renderPipeline = nullptr;
|
||||||
bool isCompleted = false;
|
bool isCompleted = false;
|
||||||
|
@ -26,13 +26,13 @@ namespace {
|
||||||
};
|
};
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
class CreateReadyPipelineTest : public DawnTest {
|
class CreatePipelineAsyncTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
CreateReadyPipelineTask task;
|
CreatePipelineAsyncTask task;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Verify the basic use of CreateReadyComputePipeline works on all backends.
|
// Verify the basic use of CreateComputePipelineAsync works on all backends.
|
||||||
TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyComputePipeline) {
|
TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateComputePipelineAsync) {
|
||||||
wgpu::ComputePipelineDescriptor csDesc;
|
wgpu::ComputePipelineDescriptor csDesc;
|
||||||
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[block]] struct SSBO {
|
[[block]] struct SSBO {
|
||||||
|
@ -45,13 +45,13 @@ TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyComputePipeline) {
|
||||||
})");
|
})");
|
||||||
csDesc.computeStage.entryPoint = "main";
|
csDesc.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
device.CreateReadyComputePipeline(
|
device.CreateComputePipelineAsync(
|
||||||
&csDesc,
|
&csDesc,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPUComputePipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_Success, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Success, status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -93,11 +93,11 @@ TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyComputePipeline) {
|
||||||
EXPECT_BUFFER_U32_EQ(kExpected, ssbo, 0);
|
EXPECT_BUFFER_U32_EQ(kExpected, ssbo, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify CreateReadyComputePipeline() works as expected when there is any error that happens during
|
// Verify CreateComputePipelineAsync() works as expected when there is any error that happens during
|
||||||
// the creation of the compute pipeline. The SPEC requires that during the call of
|
// the creation of the compute pipeline. The SPEC requires that during the call of
|
||||||
// CreateReadyComputePipeline() any error won't be forwarded to the error scope / unhandled error
|
// CreateComputePipelineAsync() any error won't be forwarded to the error scope / unhandled error
|
||||||
// callback.
|
// callback.
|
||||||
TEST_P(CreateReadyPipelineTest, CreateComputePipelineFailed) {
|
TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
|
||||||
DAWN_SKIP_TEST_IF(HasToggleEnabled("skip_validation"));
|
DAWN_SKIP_TEST_IF(HasToggleEnabled("skip_validation"));
|
||||||
|
|
||||||
wgpu::ComputePipelineDescriptor csDesc;
|
wgpu::ComputePipelineDescriptor csDesc;
|
||||||
|
@ -112,13 +112,13 @@ TEST_P(CreateReadyPipelineTest, CreateComputePipelineFailed) {
|
||||||
})");
|
})");
|
||||||
csDesc.computeStage.entryPoint = "main0";
|
csDesc.computeStage.entryPoint = "main0";
|
||||||
|
|
||||||
device.CreateReadyComputePipeline(
|
device.CreateComputePipelineAsync(
|
||||||
&csDesc,
|
&csDesc,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPUComputePipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -133,8 +133,8 @@ TEST_P(CreateReadyPipelineTest, CreateComputePipelineFailed) {
|
||||||
ASSERT_EQ(nullptr, task.computePipeline.Get());
|
ASSERT_EQ(nullptr, task.computePipeline.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the basic use of CreateReadyRenderPipeline() works on all backends.
|
// Verify the basic use of CreateRenderPipelineAsync() works on all backends.
|
||||||
TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyRenderPipeline) {
|
TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
|
||||||
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
|
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
|
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
|
||||||
|
@ -153,13 +153,13 @@ TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyRenderPipeline) {
|
||||||
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat;
|
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat;
|
||||||
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
||||||
|
|
||||||
device.CreateReadyRenderPipeline(
|
device.CreateRenderPipelineAsync(
|
||||||
&renderPipelineDescriptor,
|
&renderPipelineDescriptor,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPURenderPipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_Success, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Success, status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -198,11 +198,11 @@ TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyRenderPipeline) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), outputTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), outputTexture, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify CreateReadyRenderPipeline() works as expected when there is any error that happens during
|
// Verify CreateRenderPipelineAsync() works as expected when there is any error that happens during
|
||||||
// the creation of the render pipeline. The SPEC requires that during the call of
|
// the creation of the render pipeline. The SPEC requires that during the call of
|
||||||
// CreateReadyRenderPipeline() any error won't be forwarded to the error scope / unhandled error
|
// CreateRenderPipelineAsync() any error won't be forwarded to the error scope / unhandled error
|
||||||
// callback.
|
// callback.
|
||||||
TEST_P(CreateReadyPipelineTest, CreateRenderPipelineFailed) {
|
TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
|
||||||
DAWN_SKIP_TEST_IF(HasToggleEnabled("skip_validation"));
|
DAWN_SKIP_TEST_IF(HasToggleEnabled("skip_validation"));
|
||||||
|
|
||||||
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::Depth32Float;
|
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::Depth32Float;
|
||||||
|
@ -223,13 +223,13 @@ TEST_P(CreateReadyPipelineTest, CreateRenderPipelineFailed) {
|
||||||
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat;
|
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat;
|
||||||
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
||||||
|
|
||||||
device.CreateReadyRenderPipeline(
|
device.CreateRenderPipelineAsync(
|
||||||
&renderPipelineDescriptor,
|
&renderPipelineDescriptor,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPURenderPipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -245,22 +245,22 @@ TEST_P(CreateReadyPipelineTest, CreateRenderPipelineFailed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify there is no error when the device is released before the callback of
|
// Verify there is no error when the device is released before the callback of
|
||||||
// CreateReadyComputePipeline() is called.
|
// CreateComputePipelineAsync() is called.
|
||||||
TEST_P(CreateReadyPipelineTest, ReleaseDeviceBeforeCallbackOfCreateReadyComputePipeline) {
|
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipelineAsync) {
|
||||||
wgpu::ComputePipelineDescriptor csDesc;
|
wgpu::ComputePipelineDescriptor csDesc;
|
||||||
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[stage(compute)]] fn main() -> void {
|
[[stage(compute)]] fn main() -> void {
|
||||||
})");
|
})");
|
||||||
csDesc.computeStage.entryPoint = "main";
|
csDesc.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
device.CreateReadyComputePipeline(
|
device.CreateComputePipelineAsync(
|
||||||
&csDesc,
|
&csDesc,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPUComputePipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_DeviceDestroyed,
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_DeviceDestroyed,
|
||||||
status);
|
status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -269,8 +269,8 @@ TEST_P(CreateReadyPipelineTest, ReleaseDeviceBeforeCallbackOfCreateReadyComputeP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify there is no error when the device is released before the callback of
|
// Verify there is no error when the device is released before the callback of
|
||||||
// CreateReadyRenderPipeline() is called.
|
// CreateRenderPipelineAsync() is called.
|
||||||
TEST_P(CreateReadyPipelineTest, ReleaseDeviceBeforeCallbackOfCreateReadyRenderPipeline) {
|
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
|
||||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
|
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device);
|
||||||
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
|
@ -287,14 +287,14 @@ TEST_P(CreateReadyPipelineTest, ReleaseDeviceBeforeCallbackOfCreateReadyRenderPi
|
||||||
renderPipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
|
renderPipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
||||||
|
|
||||||
device.CreateReadyRenderPipeline(
|
device.CreateRenderPipelineAsync(
|
||||||
&renderPipelineDescriptor,
|
&renderPipelineDescriptor,
|
||||||
[](WGPUCreateReadyPipelineStatus status, WGPURenderPipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreateReadyPipelineStatus::WGPUCreateReadyPipelineStatus_DeviceDestroyed,
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_DeviceDestroyed,
|
||||||
status);
|
status);
|
||||||
|
|
||||||
CreateReadyPipelineTask* task = static_cast<CreateReadyPipelineTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
||||||
task->isCompleted = true;
|
task->isCompleted = true;
|
||||||
task->message = message;
|
task->message = message;
|
||||||
|
@ -302,7 +302,7 @@ TEST_P(CreateReadyPipelineTest, ReleaseDeviceBeforeCallbackOfCreateReadyRenderPi
|
||||||
&task);
|
&task);
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(CreateReadyPipelineTest,
|
DAWN_INSTANTIATE_TEST(CreatePipelineAsyncTest,
|
||||||
D3D12Backend(),
|
D3D12Backend(),
|
||||||
MetalBackend(),
|
MetalBackend(),
|
||||||
OpenGLBackend(),
|
OpenGLBackend(),
|
|
@ -149,7 +149,7 @@ namespace {
|
||||||
|
|
||||||
class WorkerThreadTest : public testing::Test {};
|
class WorkerThreadTest : public testing::Test {};
|
||||||
|
|
||||||
// Emulate the basic usage of worker thread pool in CreateReady*Pipeline().
|
// Emulate the basic usage of worker thread pool in Create*PipelineAsync().
|
||||||
TEST_F(WorkerThreadTest, Basic) {
|
TEST_F(WorkerThreadTest, Basic) {
|
||||||
dawn_platform::Platform platform;
|
dawn_platform::Platform platform;
|
||||||
std::unique_ptr<dawn_platform::WorkerTaskPool> pool = platform.CreateWorkerTaskPool();
|
std::unique_ptr<dawn_platform::WorkerTaskPool> pool = platform.CreateWorkerTaskPool();
|
||||||
|
|
|
@ -28,9 +28,9 @@ TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
|
||||||
ASSERT_DEVICE_ERROR(device.GetQueue().Submit(1, &commandBuffer));
|
ASSERT_DEVICE_ERROR(device.GetQueue().Submit(1, &commandBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that CreateReadyPipeline fails creation with an Error status if it uses
|
// Test that CreatePipelineAsync fails creation with an Error status if it uses
|
||||||
// objects from a different device.
|
// objects from a different device.
|
||||||
TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreateReadyPipeline) {
|
TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
|
||||||
wgpu::ShaderModuleWGSLDescriptor wgslDesc = {};
|
wgpu::ShaderModuleWGSLDescriptor wgslDesc = {};
|
||||||
wgslDesc.source = R"(
|
wgslDesc.source = R"(
|
||||||
[[stage(compute)]] fn main() -> void {
|
[[stage(compute)]] fn main() -> void {
|
||||||
|
@ -40,7 +40,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreateReadyPipeline) {
|
||||||
wgpu::ShaderModuleDescriptor shaderModuleDesc = {};
|
wgpu::ShaderModuleDescriptor shaderModuleDesc = {};
|
||||||
shaderModuleDesc.nextInChain = &wgslDesc;
|
shaderModuleDesc.nextInChain = &wgslDesc;
|
||||||
|
|
||||||
// Base case: CreateReadyComputePipeline succeeds.
|
// Base case: CreateComputePipelineAsync succeeds.
|
||||||
{
|
{
|
||||||
wgpu::ShaderModule shaderModule = device.CreateShaderModule(&shaderModuleDesc);
|
wgpu::ShaderModule shaderModule = device.CreateShaderModule(&shaderModuleDesc);
|
||||||
|
|
||||||
|
@ -48,18 +48,18 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreateReadyPipeline) {
|
||||||
pipelineDesc.computeStage.module = shaderModule;
|
pipelineDesc.computeStage.module = shaderModule;
|
||||||
pipelineDesc.computeStage.entryPoint = "main";
|
pipelineDesc.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
StrictMock<MockCallback<WGPUCreateReadyComputePipelineCallback>> creationCallback;
|
StrictMock<MockCallback<WGPUCreateComputePipelineAsyncCallback>> creationCallback;
|
||||||
EXPECT_CALL(creationCallback,
|
EXPECT_CALL(creationCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Success, NotNull(), _, this))
|
Call(WGPUCreatePipelineAsyncStatus_Success, NotNull(), _, this))
|
||||||
.WillOnce(WithArg<1>(Invoke(
|
.WillOnce(WithArg<1>(Invoke(
|
||||||
[](WGPUComputePipeline pipeline) { wgpu::ComputePipeline::Acquire(pipeline); })));
|
[](WGPUComputePipeline pipeline) { wgpu::ComputePipeline::Acquire(pipeline); })));
|
||||||
device.CreateReadyComputePipeline(&pipelineDesc, creationCallback.Callback(),
|
device.CreateComputePipelineAsync(&pipelineDesc, creationCallback.Callback(),
|
||||||
creationCallback.MakeUserdata(this));
|
creationCallback.MakeUserdata(this));
|
||||||
|
|
||||||
WaitForAllOperations(device);
|
WaitForAllOperations(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateReadyComputePipeline errors if the shader module is created on a different device.
|
// CreateComputePipelineAsync errors if the shader module is created on a different device.
|
||||||
{
|
{
|
||||||
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
||||||
wgpu::ShaderModule shaderModule = device2.CreateShaderModule(&shaderModuleDesc);
|
wgpu::ShaderModule shaderModule = device2.CreateShaderModule(&shaderModuleDesc);
|
||||||
|
@ -68,11 +68,11 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreateReadyPipeline) {
|
||||||
pipelineDesc.computeStage.module = shaderModule;
|
pipelineDesc.computeStage.module = shaderModule;
|
||||||
pipelineDesc.computeStage.entryPoint = "main";
|
pipelineDesc.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
StrictMock<MockCallback<WGPUCreateReadyComputePipelineCallback>> creationCallback;
|
StrictMock<MockCallback<WGPUCreateComputePipelineAsyncCallback>> creationCallback;
|
||||||
EXPECT_CALL(creationCallback,
|
EXPECT_CALL(creationCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Error, nullptr, _, this + 1))
|
Call(WGPUCreatePipelineAsyncStatus_Error, nullptr, _, this + 1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
device.CreateReadyComputePipeline(&pipelineDesc, creationCallback.Callback(),
|
device.CreateComputePipelineAsync(&pipelineDesc, creationCallback.Callback(),
|
||||||
creationCallback.MakeUserdata(this + 1));
|
creationCallback.MakeUserdata(this + 1));
|
||||||
|
|
||||||
WaitForAllOperations(device);
|
WaitForAllOperations(device);
|
||||||
|
|
|
@ -22,78 +22,78 @@ using namespace dawn_wire;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Mock class to add expectations on the wire calling callbacks
|
// Mock class to add expectations on the wire calling callbacks
|
||||||
class MockCreateReadyComputePipelineCallback {
|
class MockCreateComputePipelineAsyncCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
Call,
|
Call,
|
||||||
(WGPUCreateReadyPipelineStatus status,
|
(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPUComputePipeline pipeline,
|
WGPUComputePipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
void* userdata));
|
void* userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<StrictMock<MockCreateReadyComputePipelineCallback>>
|
std::unique_ptr<StrictMock<MockCreateComputePipelineAsyncCallback>>
|
||||||
mockCreateReadyComputePipelineCallback;
|
mockCreateComputePipelineAsyncCallback;
|
||||||
void ToMockCreateReadyComputePipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void ToMockCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPUComputePipeline pipeline,
|
WGPUComputePipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
mockCreateReadyComputePipelineCallback->Call(status, pipeline, message, userdata);
|
mockCreateComputePipelineAsyncCallback->Call(status, pipeline, message, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockCreateReadyRenderPipelineCallback {
|
class MockCreateRenderPipelineAsyncCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
Call,
|
Call,
|
||||||
(WGPUCreateReadyPipelineStatus status,
|
(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPURenderPipeline pipeline,
|
WGPURenderPipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
void* userdata));
|
void* userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<StrictMock<MockCreateReadyRenderPipelineCallback>>
|
std::unique_ptr<StrictMock<MockCreateRenderPipelineAsyncCallback>>
|
||||||
mockCreateReadyRenderPipelineCallback;
|
mockCreateRenderPipelineAsyncCallback;
|
||||||
void ToMockCreateReadyRenderPipelineCallback(WGPUCreateReadyPipelineStatus status,
|
void ToMockCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||||
WGPURenderPipeline pipeline,
|
WGPURenderPipeline pipeline,
|
||||||
const char* message,
|
const char* message,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
mockCreateReadyRenderPipelineCallback->Call(status, pipeline, message, userdata);
|
mockCreateRenderPipelineAsyncCallback->Call(status, pipeline, message, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
class WireCreateReadyPipelineTest : public WireTest {
|
class WireCreatePipelineAsyncTest : public WireTest {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
WireTest::SetUp();
|
WireTest::SetUp();
|
||||||
|
|
||||||
mockCreateReadyComputePipelineCallback =
|
mockCreateComputePipelineAsyncCallback =
|
||||||
std::make_unique<StrictMock<MockCreateReadyComputePipelineCallback>>();
|
std::make_unique<StrictMock<MockCreateComputePipelineAsyncCallback>>();
|
||||||
mockCreateReadyRenderPipelineCallback =
|
mockCreateRenderPipelineAsyncCallback =
|
||||||
std::make_unique<StrictMock<MockCreateReadyRenderPipelineCallback>>();
|
std::make_unique<StrictMock<MockCreateRenderPipelineAsyncCallback>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
WireTest::TearDown();
|
WireTest::TearDown();
|
||||||
|
|
||||||
// Delete mock so that expectations are checked
|
// Delete mock so that expectations are checked
|
||||||
mockCreateReadyComputePipelineCallback = nullptr;
|
mockCreateComputePipelineAsyncCallback = nullptr;
|
||||||
mockCreateReadyRenderPipelineCallback = nullptr;
|
mockCreateRenderPipelineAsyncCallback = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlushClient() {
|
void FlushClient() {
|
||||||
WireTest::FlushClient();
|
WireTest::FlushClient();
|
||||||
Mock::VerifyAndClearExpectations(&mockCreateReadyComputePipelineCallback);
|
Mock::VerifyAndClearExpectations(&mockCreateComputePipelineAsyncCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlushServer() {
|
void FlushServer() {
|
||||||
WireTest::FlushServer();
|
WireTest::FlushServer();
|
||||||
Mock::VerifyAndClearExpectations(&mockCreateReadyComputePipelineCallback);
|
Mock::VerifyAndClearExpectations(&mockCreateComputePipelineAsyncCallback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test when creating a compute pipeline with CreateReadyComputePipeline() successfully.
|
// Test when creating a compute pipeline with CreateComputePipelineAsync() successfully.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineSuccess) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncSuccess) {
|
||||||
WGPUShaderModuleDescriptor csDescriptor{};
|
WGPUShaderModuleDescriptor csDescriptor{};
|
||||||
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
||||||
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
||||||
|
@ -103,26 +103,26 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineSuccess) {
|
||||||
descriptor.computeStage.module = csModule;
|
descriptor.computeStage.module = csModule;
|
||||||
descriptor.computeStage.entryPoint = "main";
|
descriptor.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
wgpuDeviceCreateComputePipelineAsync(device, &descriptor,
|
||||||
ToMockCreateReadyComputePipelineCallback, this);
|
ToMockCreateComputePipelineAsyncCallback, this);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
api.CallDeviceCreateComputePipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Success, nullptr, "");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyComputePipelineCallback,
|
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Success, _, StrEq(""), this))
|
Call(WGPUCreatePipelineAsyncStatus_Success, _, StrEq(""), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test when creating a compute pipeline with CreateReadyComputePipeline() results in an error.
|
// Test when creating a compute pipeline with CreateComputePipelineAsync() results in an error.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineError) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncError) {
|
||||||
WGPUShaderModuleDescriptor csDescriptor{};
|
WGPUShaderModuleDescriptor csDescriptor{};
|
||||||
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
||||||
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
||||||
|
@ -132,26 +132,26 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineError) {
|
||||||
descriptor.computeStage.module = csModule;
|
descriptor.computeStage.module = csModule;
|
||||||
descriptor.computeStage.entryPoint = "main";
|
descriptor.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
wgpuDeviceCreateComputePipelineAsync(device, &descriptor,
|
||||||
ToMockCreateReadyComputePipelineCallback, this);
|
ToMockCreateComputePipelineAsyncCallback, this);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
api.CallDeviceCreateComputePipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Error, nullptr, "Some error message");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyComputePipelineCallback,
|
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Error, _, StrEq("Some error message"), this))
|
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test when creating a render pipeline with CreateReadyRenderPipeline() successfully.
|
// Test when creating a render pipeline with CreateRenderPipelineAsync() successfully.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineSuccess) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncSuccess) {
|
||||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||||
|
@ -166,25 +166,25 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineSuccess) {
|
||||||
fragmentStage.entryPoint = "main";
|
fragmentStage.entryPoint = "main";
|
||||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||||
|
|
||||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
|
||||||
ToMockCreateReadyRenderPipelineCallback, this);
|
ToMockCreateRenderPipelineAsyncCallback, this);
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Success, nullptr, "");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Success, _, StrEq(""), this))
|
Call(WGPUCreatePipelineAsyncStatus_Success, _, StrEq(""), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test when creating a render pipeline with CreateReadyRenderPipeline() results in an error.
|
// Test when creating a render pipeline with CreateRenderPipelineAsync() results in an error.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineError) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncError) {
|
||||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||||
|
@ -199,18 +199,18 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineError) {
|
||||||
fragmentStage.entryPoint = "main";
|
fragmentStage.entryPoint = "main";
|
||||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||||
|
|
||||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
|
||||||
ToMockCreateReadyRenderPipelineCallback, this);
|
ToMockCreateRenderPipelineAsyncCallback, this);
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Error, nullptr, "Some error message");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_Error, _, StrEq("Some error message"), this))
|
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -218,7 +218,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineError) {
|
||||||
|
|
||||||
// Test that registering a callback then wire disconnect calls the callback with
|
// Test that registering a callback then wire disconnect calls the callback with
|
||||||
// DeviceLost.
|
// DeviceLost.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineThenDisconnect) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncThenDisconnect) {
|
||||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||||
|
@ -233,25 +233,25 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineThenDisconnect) {
|
||||||
pipelineDescriptor.vertexStage.entryPoint = "main";
|
pipelineDescriptor.vertexStage.entryPoint = "main";
|
||||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||||
|
|
||||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
|
||||||
ToMockCreateReadyRenderPipelineCallback, this);
|
ToMockCreateRenderPipelineAsyncCallback, this);
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Success, nullptr, "");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, _, _, this))
|
Call(WGPUCreatePipelineAsyncStatus_DeviceLost, _, _, this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
GetWireClient()->Disconnect();
|
GetWireClient()->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that registering a callback then wire disconnect calls the callback with
|
// Test that registering a callback then wire disconnect calls the callback with
|
||||||
// DeviceLost.
|
// DeviceLost.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineThenDisconnect) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncThenDisconnect) {
|
||||||
WGPUShaderModuleDescriptor csDescriptor{};
|
WGPUShaderModuleDescriptor csDescriptor{};
|
||||||
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
||||||
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
||||||
|
@ -261,25 +261,25 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineThenDisconnect) {
|
||||||
descriptor.computeStage.module = csModule;
|
descriptor.computeStage.module = csModule;
|
||||||
descriptor.computeStage.entryPoint = "main";
|
descriptor.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
wgpuDeviceCreateComputePipelineAsync(device, &descriptor,
|
||||||
ToMockCreateReadyComputePipelineCallback, this);
|
ToMockCreateComputePipelineAsyncCallback, this);
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
api.CallDeviceCreateComputePipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
apiDevice, WGPUCreatePipelineAsyncStatus_Success, nullptr, "");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyComputePipelineCallback,
|
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, _, _, this))
|
Call(WGPUCreatePipelineAsyncStatus_DeviceLost, _, _, this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
GetWireClient()->Disconnect();
|
GetWireClient()->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that registering a callback after wire disconnect calls the callback with
|
// Test that registering a callback after wire disconnect calls the callback with
|
||||||
// DeviceLost.
|
// DeviceLost.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineAfterDisconnect) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncAfterDisconnect) {
|
||||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||||
|
@ -298,16 +298,16 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineAfterDisconnect) {
|
||||||
|
|
||||||
GetWireClient()->Disconnect();
|
GetWireClient()->Disconnect();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, _, this))
|
Call(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr, _, this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
|
||||||
ToMockCreateReadyRenderPipelineCallback, this);
|
ToMockCreateRenderPipelineAsyncCallback, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that registering a callback after wire disconnect calls the callback with
|
// Test that registering a callback after wire disconnect calls the callback with
|
||||||
// DeviceLost.
|
// DeviceLost.
|
||||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineAfterDisconnect) {
|
TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncAfterDisconnect) {
|
||||||
WGPUShaderModuleDescriptor csDescriptor{};
|
WGPUShaderModuleDescriptor csDescriptor{};
|
||||||
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
||||||
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
||||||
|
@ -321,15 +321,15 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineAfterDisconnect) {
|
||||||
|
|
||||||
GetWireClient()->Disconnect();
|
GetWireClient()->Disconnect();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyComputePipelineCallback,
|
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, _, this))
|
Call(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr, _, this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
wgpuDeviceCreateComputePipelineAsync(device, &descriptor,
|
||||||
ToMockCreateReadyComputePipelineCallback, this);
|
ToMockCreateComputePipelineAsyncCallback, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WireCreateReadyPipelineTest, DeviceDeletedBeforeCallback) {
|
TEST_F(WireCreatePipelineAsyncTest, DeviceDeletedBeforeCallback) {
|
||||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||||
WGPUShaderModule module = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
WGPUShaderModule module = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||||
WGPUShaderModule apiModule = api.GetNewShaderModule();
|
WGPUShaderModule apiModule = api.GetNewShaderModule();
|
||||||
|
@ -344,14 +344,14 @@ TEST_F(WireCreateReadyPipelineTest, DeviceDeletedBeforeCallback) {
|
||||||
fragmentStage.entryPoint = "main";
|
fragmentStage.entryPoint = "main";
|
||||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||||
|
|
||||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
|
||||||
ToMockCreateReadyRenderPipelineCallback, this);
|
ToMockCreateRenderPipelineAsyncCallback, this);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _));
|
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _));
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||||
Call(WGPUCreateReadyPipelineStatus_DeviceDestroyed, nullptr, _, this))
|
Call(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr, _, this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
wgpuDeviceRelease(device);
|
wgpuDeviceRelease(device);
|
Loading…
Reference in New Issue