break;
}
#ifdef SK_VULKAN
- case kVulkan_GrBackend:
- if (masterContext) {
- // Shared contexts not supported yet
- return ContextInfo();
- }
+ case kVulkan_GrBackend: {
+ VkTestContext* vkSharedContext = masterContext
+ ? static_cast<VkTestContext*>(masterContext->fTestContext) : nullptr;
SkASSERT(kVulkan_ContextType == type);
if (ContextOverrides::kRequireNVPRSupport & overrides) {
return ContextInfo();
}
- testCtx.reset(CreatePlatformVkTestContext());
+ testCtx.reset(CreatePlatformVkTestContext(vkSharedContext));
if (!testCtx) {
return ContextInfo();
}
}
backendContext = testCtx->backendContext();
break;
+ }
#endif
default:
return ContextInfo();
// TODO: Implement swap buffers and finish
class VkTestContextImpl : public sk_gpu_test::VkTestContext {
public:
- static VkTestContext* Create() {
- sk_sp<const GrVkBackendContext> backendContext(
- GrVkBackendContext::Create(vkGetInstanceProcAddr, vkGetDeviceProcAddr));
+ static VkTestContext* Create(VkTestContext* sharedContext) {
+ sk_sp<const GrVkBackendContext> backendContext;
+ if (sharedContext) {
+ backendContext = sharedContext->getVkBackendContext();
+ } else {
+ backendContext.reset(GrVkBackendContext::Create(vkGetInstanceProcAddr,
+ vkGetDeviceProcAddr));
+ }
if (!backendContext) {
return nullptr;
}
} // anonymous namespace
namespace sk_gpu_test {
-VkTestContext* CreatePlatformVkTestContext() { return VkTestContextImpl::Create(); }
+VkTestContext* CreatePlatformVkTestContext(VkTestContext* sharedContext) {
+ return VkTestContextImpl::Create(sharedContext);
+}
} // namespace sk_gpu_test
#endif
return reinterpret_cast<GrBackendContext>(fVk.get());
}
+ sk_sp<const GrVkBackendContext> getVkBackendContext() {
+ return fVk;
+ }
+
bool isValid() const override { return NULL != this->vk(); }
const GrVkInterface* vk() const { return fVk->fInterface.get(); }
/**
* Creates Vk context object bound to the native Vk library.
*/
-VkTestContext* CreatePlatformVkTestContext();
+VkTestContext* CreatePlatformVkTestContext(VkTestContext*);
} // namespace sk_gpu_test