diff --git a/src/dawn/native/Adapter.cpp b/src/dawn/native/Adapter.cpp index 376956c7a5..0a6d93eac1 100644 --- a/src/dawn/native/Adapter.cpp +++ b/src/dawn/native/Adapter.cpp @@ -86,7 +86,7 @@ MaybeError AdapterBase::Initialize() { InstanceBase* AdapterBase::APIGetInstance() const { auto instance = GetInstance(); ASSERT(instance != nullptr); - instance->Reference(); + instance->APIReference(); return instance; } diff --git a/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp b/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp index 7f3669a4fe..17c175204b 100644 --- a/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp +++ b/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp @@ -335,4 +335,21 @@ TEST_F(AdapterCreationTest, PreferLowPower) { } } +// Test that GetInstance() returns the correct Instance. +TEST_F(AdapterCreationTest, GetInstance) { + wgpu::RequestAdapterOptions options = {}; + + MockCallback cb; + + WGPUAdapter cAdapter = nullptr; + EXPECT_CALL(cb, Call(WGPURequestAdapterStatus_Success, _, nullptr, this)) + .WillOnce(SaveArg<1>(&cAdapter)); + instance.RequestAdapter(&options, cb.Callback(), cb.MakeUserdata(this)); + + wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); + EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); + + EXPECT_EQ(adapter.GetInstance().Get(), instance.Get()); +} + } // anonymous namespace