diff options
Diffstat (limited to 'src/gpu/GrDirectContext.cpp')
-rw-r--r-- | src/gpu/GrDirectContext.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index 7a054e72a4..d0406dd6f6 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -156,7 +156,43 @@ sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext, const GrContextOptions& options) { sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend)); - context->fGpu = GrVkGpu::Make(backendContext, options, context.get()); + sk_sp<GrVkBackendContext> backendContextRef(new GrVkBackendContext()); + backendContextRef->fInstance = backendContext.fInstance; + backendContextRef->fPhysicalDevice = backendContext.fPhysicalDevice; + backendContextRef->fDevice = backendContext.fDevice; + backendContextRef->fQueue = backendContext.fQueue; + backendContextRef->fGraphicsQueueIndex = backendContext.fGraphicsQueueIndex; + backendContextRef->fMinAPIVersion = backendContext.fMinAPIVersion; + backendContextRef->fExtensions = backendContext.fExtensions; + backendContextRef->fFeatures = backendContext.fFeatures; + backendContextRef->fInterface = backendContext.fInterface; + backendContextRef->fMemoryAllocator = backendContext.fMemoryAllocator; + + SkASSERT(!backendContext.fOwnsInstanceAndDevice); + backendContextRef->fOwnsInstanceAndDevice = false; + + context->fGpu = GrVkGpu::Make(std::move(backendContextRef), options, context.get()); + if (!context->fGpu) { + return nullptr; + } + + context->fCaps = context->fGpu->refCaps(); + if (!context->init(options)) { + return nullptr; + } + return context; +} + +sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext) { + GrContextOptions defaultOptions; + return MakeVulkan(std::move(backendContext), defaultOptions); +} + +sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext, + const GrContextOptions& options) { + sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend)); + + context->fGpu = GrVkGpu::Make(std::move(backendContext), options, context.get()); if (!context->fGpu) { return nullptr; } |