aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu/vk/VkTestContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gpu/vk/VkTestContext.cpp')
-rw-r--r--tools/gpu/vk/VkTestContext.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/tools/gpu/vk/VkTestContext.cpp b/tools/gpu/vk/VkTestContext.cpp
index 592fb0f7b0..25069fe521 100644
--- a/tools/gpu/vk/VkTestContext.cpp
+++ b/tools/gpu/vk/VkTestContext.cpp
@@ -110,24 +110,21 @@ GR_STATIC_ASSERT(sizeof(VkFence) <= sizeof(sk_gpu_test::PlatformFence));
class VkTestContextImpl : public sk_gpu_test::VkTestContext {
public:
static VkTestContext* Create(VkTestContext* sharedContext) {
- GrVkBackendContext backendContext;
- bool ownsContext = true;
+ sk_sp<const GrVkBackendContext> backendContext;
if (sharedContext) {
backendContext = sharedContext->getVkBackendContext();
- // We always delete the parent context last so make sure the child does not think they
- // own the vulkan context.
- ownsContext = false;
} else {
PFN_vkGetInstanceProcAddr instProc;
PFN_vkGetDeviceProcAddr devProc;
if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc, &devProc)) {
return nullptr;
}
- if (!sk_gpu_test::CreateVkBackendContext(instProc, devProc, &backendContext)) {
- return nullptr;
- }
+ backendContext.reset(GrVkBackendContext::Create(instProc, devProc));
}
- return new VkTestContextImpl(backendContext, ownsContext);
+ if (!backendContext) {
+ return nullptr;
+ }
+ return new VkTestContextImpl(std::move(backendContext));
}
~VkTestContextImpl() override { this->teardown(); }
@@ -146,19 +143,14 @@ public:
protected:
void teardown() override {
INHERITED::teardown();
- fVk.fMemoryAllocator.reset();
- if (fOwnsContext) {
- GR_VK_CALL(this->vk(), DeviceWaitIdle(fVk.fDevice));
- GR_VK_CALL(this->vk(), DestroyDevice(fVk.fDevice, nullptr));
- GR_VK_CALL(this->vk(), DestroyInstance(fVk.fInstance, nullptr));
- }
+ fVk.reset(nullptr);
}
private:
- VkTestContextImpl(const GrVkBackendContext& backendContext, bool ownsContext)
- : VkTestContext(backendContext, ownsContext) {
- fFenceSync.reset(new VkFenceSync(fVk.fInterface, fVk.fDevice, fVk.fQueue,
- fVk.fGraphicsQueueIndex));
+ VkTestContextImpl(sk_sp<const GrVkBackendContext> backendContext)
+ : VkTestContext(std::move(backendContext)) {
+ fFenceSync.reset(new VkFenceSync(fVk->fInterface, fVk->fDevice, fVk->fQueue,
+ fVk->fGraphicsQueueIndex));
}
void onPlatformMakeCurrent() const override {}