diff --git a/src/fuzzers/BUILD.gn b/src/fuzzers/BUILD.gn index 2b51d6e7a6..525016d0aa 100644 --- a/src/fuzzers/BUILD.gn +++ b/src/fuzzers/BUILD.gn @@ -170,3 +170,15 @@ dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") { additional_configs = [ "${dawn_root}/src/common:dawn_internal" ] } + +dawn_fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") { + sources = [ + "DawnWireServerAndVulkanBackendFuzzer.cpp", + ] + + deps = [ + ":dawn_wire_server_fuzzer_common", + ] + + additional_configs = [ "${dawn_root}/src/common:dawn_internal" ] +} diff --git a/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp b/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp new file mode 100644 index 0000000000..ce39917862 --- /dev/null +++ b/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp @@ -0,0 +1,38 @@ +// Copyright 2019 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 "DawnWireServerFuzzer.h" + +#include "common/Assert.h" +#include "dawn_native/DawnNative.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + return DawnWireServerFuzzer::Run(data, size, [](dawn_native::Instance* instance) { + instance->DiscoverDefaultAdapters(); + + std::vector adapters = instance->GetAdapters(); + + wgpu::Device device; + for (dawn_native::Adapter adapter : adapters) { + if (adapter.GetBackendType() == dawn_native::BackendType::Vulkan && + adapter.GetDeviceType() == dawn_native::DeviceType::CPU) { + device = wgpu::Device::Acquire(adapter.CreateDevice()); + break; + } + } + + ASSERT(device.Get() != nullptr); + return device; + }); +}