Make CreateRenderPipelineAsync use Descriptor2

Since it isn't used by anyone yet we can make a breaking change to
CreateRenderPipelineAsync to immediately start using
RenderPipelineDescriptor2.

Bug: dawn:1177501
Change-Id: I9f88c6fc1b325b7a9356536e2a071d4f17abd6ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45280
Commit-Queue: Brandon Jones <bajones@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Corentin Wallez 2021-03-21 23:13:04 +00:00 committed by Commit Bot service account
parent 6b80743d3f
commit 8ac6a481a3
10 changed files with 66 additions and 65 deletions

View File

@ -703,7 +703,7 @@
"name": "create render pipeline async", "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 2", "annotation": "const*"},
{"name": "callback", "type": "create render pipeline async callback"}, {"name": "callback", "type": "create render pipeline async callback"},
{"name": "userdata", "type": "void", "annotation": "*"} {"name": "userdata", "type": "void", "annotation": "*"}
] ]

View File

@ -46,7 +46,7 @@
{ "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"},
{ "name": "descriptor", "type": "render pipeline descriptor", "annotation": "const*"} { "name": "descriptor", "type": "render pipeline descriptor 2", "annotation": "const*"}
], ],
"device pop error scope": [ "device pop error scope": [
{ "name": "device id", "type": "ObjectId" }, { "name": "device id", "type": "ObjectId" },

View File

@ -758,7 +758,7 @@ namespace dawn_native {
return result; return result;
} }
void DeviceBase::CreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor, void DeviceBase::CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) { void* userdata) {
RenderPipelineBase* result = nullptr; RenderPipelineBase* result = nullptr;

View File

@ -149,7 +149,7 @@ namespace dawn_native {
void CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, void CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata); void* userdata);
void CreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor, void CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);
RenderBundleEncoder* CreateRenderBundleEncoder( RenderBundleEncoder* CreateRenderBundleEncoder(

View File

@ -277,7 +277,7 @@ namespace dawn_wire { namespace client {
return true; return true;
} }
void Device::CreateRenderPipelineAsync(WGPURenderPipelineDescriptor const* descriptor, void Device::CreateRenderPipelineAsync(WGPURenderPipelineDescriptor2 const* descriptor,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) { void* userdata) {
if (client->IsDisconnected()) { if (client->IsDisconnected()) {

View File

@ -45,7 +45,7 @@ namespace dawn_wire { namespace client {
void CreateComputePipelineAsync(WGPUComputePipelineDescriptor const* descriptor, void CreateComputePipelineAsync(WGPUComputePipelineDescriptor const* descriptor,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata); void* userdata);
void CreateRenderPipelineAsync(WGPURenderPipelineDescriptor const* descriptor, void CreateRenderPipelineAsync(WGPURenderPipelineDescriptor2 const* descriptor,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);

View File

@ -149,10 +149,11 @@ namespace dawn_wire { namespace server {
SerializeCommand(cmd); SerializeCommand(cmd);
} }
bool Server::DoDeviceCreateRenderPipelineAsync(ObjectId deviceId, bool Server::DoDeviceCreateRenderPipelineAsync(
ObjectId deviceId,
uint64_t requestSerial, uint64_t requestSerial,
ObjectHandle pipelineObjectHandle, ObjectHandle pipelineObjectHandle,
const WGPURenderPipelineDescriptor* descriptor) { const WGPURenderPipelineDescriptor2* descriptor) {
auto* device = DeviceObjects().Get(deviceId); auto* device = DeviceObjects().Get(deviceId);
if (device == nullptr) { if (device == nullptr) {
return false; return false;

View File

@ -137,7 +137,7 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) { TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
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>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
@ -148,10 +148,10 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0); o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertexStage.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragmentStage.module = fsModule; renderPipelineDescriptor.cFragment.module = fsModule;
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat; renderPipelineDescriptor.cTargets[0].format = kRenderAttachmentFormat;
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
device.CreateRenderPipelineAsync( device.CreateRenderPipelineAsync(
&renderPipelineDescriptor, &renderPipelineDescriptor,
@ -207,7 +207,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::Depth32Float; constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::Depth32Float;
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
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>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
@ -218,10 +218,10 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0); o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertexStage.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragmentStage.module = fsModule; renderPipelineDescriptor.cFragment.module = fsModule;
renderPipelineDescriptor.cColorStates[0].format = kRenderAttachmentFormat; renderPipelineDescriptor.cTargets[0].format = kRenderAttachmentFormat;
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
device.CreateRenderPipelineAsync( device.CreateRenderPipelineAsync(
&renderPipelineDescriptor, &renderPipelineDescriptor,
@ -271,7 +271,7 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipeli
// 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
// CreateRenderPipelineAsync() is called. // CreateRenderPipelineAsync() is called.
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) { TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
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>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
@ -282,10 +282,10 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelin
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0); o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertexStage.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragmentStage.module = fsModule; renderPipelineDescriptor.cFragment.module = fsModule;
renderPipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; renderPipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
device.CreateRenderPipelineAsync( device.CreateRenderPipelineAsync(
&renderPipelineDescriptor, &renderPipelineDescriptor,

View File

@ -235,21 +235,21 @@ TEST_F(UnsafeAPIValidationTest, CreateComputePipelineAsyncDisallowed) {
// Check that CreateRenderPipelineAsync is disallowed as part of unsafe APIs // Check that CreateRenderPipelineAsync is disallowed as part of unsafe APIs
TEST_F(UnsafeAPIValidationTest, CreateRenderPipelineAsyncDisallowed) { TEST_F(UnsafeAPIValidationTest, CreateRenderPipelineAsyncDisallowed) {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> o_color : vec4<f32>; [[location(0)]] var<out> o_color : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0); o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
desc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; desc.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
// Control case: CreateRenderPipeline is allowed. // Control case: CreateRenderPipeline is allowed.
device.CreateRenderPipeline(&desc); device.CreateRenderPipeline2(&desc);
// TODO(bajones): Enable this when the deprecation warning is re-enabled in Device.cpp. // TODO(bajones): Enable this when the deprecation warning is re-enabled in Device.cpp.
// EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&desc)); // EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&desc));

View File

@ -157,14 +157,14 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncSuccess) {
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
WGPURenderPipelineDescriptor pipelineDescriptor{}; WGPURenderPipelineDescriptor2 pipelineDescriptor{};
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertex.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage = {}; WGPUFragmentState fragment = {};
fragmentStage.module = vsModule; fragment.module = vsModule;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragment = &fragment;
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor, wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
ToMockCreateRenderPipelineAsyncCallback, this); ToMockCreateRenderPipelineAsyncCallback, this);
@ -190,14 +190,14 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncError) {
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
WGPURenderPipelineDescriptor pipelineDescriptor{}; WGPURenderPipelineDescriptor2 pipelineDescriptor{};
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertex.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage = {}; WGPUFragmentState fragment = {};
fragmentStage.module = vsModule; fragment.module = vsModule;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragment = &fragment;
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor, wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
ToMockCreateRenderPipelineAsyncCallback, this); ToMockCreateRenderPipelineAsyncCallback, this);
@ -224,14 +224,14 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncThenDisconnect) {
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
WGPUProgrammableStageDescriptor fragmentStage = {}; WGPUFragmentState fragment = {};
fragmentStage.module = vsModule; fragment.module = vsModule;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
WGPURenderPipelineDescriptor pipelineDescriptor{}; WGPURenderPipelineDescriptor2 pipelineDescriptor{};
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertex.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragment = &fragment;
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor, wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
ToMockCreateRenderPipelineAsyncCallback, this); ToMockCreateRenderPipelineAsyncCallback, this);
@ -285,14 +285,14 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncAfterDisconnect) {
WGPUShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
WGPUProgrammableStageDescriptor fragmentStage = {}; WGPUFragmentState fragment = {};
fragmentStage.module = vsModule; fragment.module = vsModule;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
WGPURenderPipelineDescriptor pipelineDescriptor{}; WGPURenderPipelineDescriptor2 pipelineDescriptor{};
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertex.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragment = &fragment;
FlushClient(); FlushClient();
@ -335,14 +335,14 @@ TEST_F(WireCreatePipelineAsyncTest, DeviceDeletedBeforeCallback) {
WGPUShaderModule apiModule = api.GetNewShaderModule(); WGPUShaderModule apiModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiModule));
WGPURenderPipelineDescriptor pipelineDescriptor{}; WGPURenderPipelineDescriptor2 pipelineDescriptor{};
pipelineDescriptor.vertexStage.module = module; pipelineDescriptor.vertex.module = module;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertex.entryPoint = "main";
WGPUProgrammableStageDescriptor fragmentStage = {}; WGPUFragmentState fragment = {};
fragmentStage.module = module; fragment.module = module;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.fragment = &fragment;
wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor, wgpuDeviceCreateRenderPipelineAsync(device, &pipelineDescriptor,
ToMockCreateRenderPipelineAsyncCallback, this); ToMockCreateRenderPipelineAsyncCallback, this);