Remove non-adapter way to create null devices

BUG=dawn:29

Change-Id: I2153aa30afd096a3f27c8b8b2ba23a10c0ade50a
Reviewed-on: https://dawn-review.googlesource.com/c/3841
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2019-01-10 10:07:04 +00:00
committed by Commit Bot service account
parent bd48385d50
commit 0d03b09623
5 changed files with 37 additions and 10 deletions

View File

@@ -164,8 +164,13 @@ dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
]
deps = [
"${dawn_top_level}:dawn_common",
"${dawn_top_level}:libdawn_static",
"${dawn_top_level}:libdawn_native_static",
"${dawn_top_level}:libdawn_wire_static",
]
additional_configs = [
"${dawn_top_level}:dawn_internal",
]
}

View File

@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "common/Assert.h"
#include "dawn/dawncpp.h"
#include "dawn_native/DawnNative.h"
#include "dawn_native/NullBackend.h"
#include "dawn_wire/Wire.h"
#include <vector>
@@ -45,7 +45,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
procs.swapChainBuilderSetImplementation = SkipSwapChainBuilderSetImplementation;
dawnSetProcs(&procs);
dawn::Device nullDevice = dawn::Device::Acquire(dawn_native::null::CreateDevice());
// Create an instance and find the null adapter to create a device with.
std::unique_ptr<dawn_native::Instance> instance = std::make_unique<dawn_native::Instance>();
instance->DiscoverDefaultAdapters();
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
dawn::Device nullDevice;
for (dawn_native::Adapter adapter : adapters) {
if (adapter.GetBackendType() == dawn_native::BackendType::Null) {
nullDevice = dawn::Device::Acquire(adapter.CreateDevice());
break;
}
}
ASSERT(nullDevice.Get() != nullptr);
DevNull devNull;
std::unique_ptr<dawn_wire::CommandHandler> wireServer(
@@ -59,6 +72,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Destroy the server before the device because it needs to free all objects.
wireServer = nullptr;
nullDevice = nullptr;
instance = nullptr;
return 0;
}