Dawn: fix memory corruption in DawnTestContext.
Move the dawn_native::Instance ownership from DawnTestContextImpl to DawnTestContext (its parent class), which owns the wgpu::Device. dawn_native::Instance must outlive any wgpu::Devices created from it. Bug: skia: 10311 Change-Id: Iedc4ed94f03b61d5e43cd5c93eb68e24bc4474e1 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293852 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
625dc60e8b
commit
64c8b811b5
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "tools/gpu/dawn/DawnTestContext.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_UNIX
|
||||
@ -150,15 +149,13 @@ protected:
|
||||
private:
|
||||
DawnTestContextImpl(std::unique_ptr<dawn_native::Instance> instance,
|
||||
const wgpu::Device& device)
|
||||
: DawnTestContext(device)
|
||||
, fInstance(std::move(instance)) {
|
||||
: DawnTestContext(std::move(instance), device) {
|
||||
fFenceSupport = true;
|
||||
}
|
||||
|
||||
void onPlatformMakeNotCurrent() const override {}
|
||||
void onPlatformMakeCurrent() const override {}
|
||||
std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
|
||||
std::unique_ptr<dawn_native::Instance> fInstance;
|
||||
|
||||
typedef sk_gpu_test::DawnTestContext INHERITED;
|
||||
};
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define DawnTestContext_DEFINED
|
||||
|
||||
#include "tools/gpu/TestContext.h"
|
||||
#include <dawn_native/DawnNative.h>
|
||||
|
||||
#ifdef SK_DAWN
|
||||
|
||||
@ -22,8 +23,10 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
DawnTestContext(const wgpu::Device& device) : fDevice(device) {}
|
||||
DawnTestContext(std::unique_ptr<dawn_native::Instance> instance, const wgpu::Device& device)
|
||||
: fInstance(std::move(instance)), fDevice(device) {}
|
||||
|
||||
std::unique_ptr<dawn_native::Instance> fInstance;
|
||||
wgpu::Device fDevice;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user