aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpu.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-06-28 16:47:48 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-28 17:20:27 +0000
commit0db3a8846a4d05d55c36b7fa95fa6fbc1a6639cd (patch)
tree1bf5b267f22fcc844b9a6e246921e2e217195e44 /src/gpu/vk/GrVkGpu.cpp
parent8849c95710227b6442a3d4ce5c48f6f4e4127e93 (diff)
Reland "Make GrVkBackendContext no longer derive from SkRefCnt."
This reverts commit 059a9ab4bcd07a4bfdbfef333c27ef3d277e0e46. Reason for revert: Fix landed in Fuchsia Original change's description: > Revert "Make GrVkBackendContext no longer derive from SkRefCnt." > > This reverts commit 93ae2337732bf206e6ef4faecc6b30c3881e8359. > > Reason for revert: <INSERT REASONING HERE> > > Original change's description: > > Make GrVkBackendContext no longer derive from SkRefCnt. > > > > Also moves the helper Create functions to VkTestUtils since no clients > > are using them anymore. > > > > Bug: skia: > > Change-Id: I7e8e4912e7ef6fb00a7e2a00407aed5e83211799 > > Reviewed-on: https://skia-review.googlesource.com/135323 > > Reviewed-by: Jim Van Verth <jvanverth@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: skia: > Change-Id: If7201917631dc22753ea3fa6e9d2984463e38e4c > Reviewed-on: https://skia-review.googlesource.com/137903 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia: Change-Id: Ia4b7c0bb2c7b5dba809d85c69f0b41b473140526 Reviewed-on: https://skia-review.googlesource.com/138181 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkGpu.cpp')
-rw-r--r--src/gpu/vk/GrVkGpu.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index ba1f7caf2d..0b160a6ade 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -73,33 +73,38 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
}
#endif
-sk_sp<GrGpu> GrVkGpu::Make(sk_sp<const GrVkBackendContext> backendContext,
+sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext,
const GrContextOptions& options, GrContext* context) {
- if (!backendContext) {
+ if (backendContext.fInstance == VK_NULL_HANDLE ||
+ backendContext.fPhysicalDevice == VK_NULL_HANDLE ||
+ backendContext.fDevice == VK_NULL_HANDLE ||
+ backendContext.fQueue == VK_NULL_HANDLE) {
return nullptr;
}
-
- if (!backendContext->fInterface->validate(backendContext->fExtensions)) {
+ if (!backendContext.fInterface ||
+ !backendContext.fInterface->validate(backendContext.fExtensions)) {
return nullptr;
}
- return sk_sp<GrGpu>(new GrVkGpu(context, options, std::move(backendContext)));
+ return sk_sp<GrGpu>(new GrVkGpu(context, options, backendContext));
}
////////////////////////////////////////////////////////////////////////////////
GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
- sk_sp<const GrVkBackendContext> backendCtx)
+ const GrVkBackendContext& backendContext)
: INHERITED(context)
- , fBackendContext(std::move(backendCtx))
- , fMemoryAllocator(fBackendContext->fMemoryAllocator)
- , fDevice(fBackendContext->fDevice)
- , fQueue(fBackendContext->fQueue)
+ , fInterface(std::move(backendContext.fInterface))
+ , fMemoryAllocator(backendContext.fMemoryAllocator)
+ , fInstance(backendContext.fInstance)
+ , fDevice(backendContext.fDevice)
+ , fQueue(backendContext.fQueue)
, fResourceProvider(this)
, fDisconnected(false) {
+ SkASSERT(!backendContext.fOwnsInstanceAndDevice);
#ifdef SK_ENABLE_VK_LAYERS
fCallback = VK_NULL_HANDLE;
- if (fBackendContext->fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
+ if (backendContext.fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
// Setup callback creation information
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -114,32 +119,32 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
// Register the callback
GR_VK_CALL_ERRCHECK(this->vkInterface(),
- CreateDebugReportCallbackEXT(fBackendContext->fInstance,
+ CreateDebugReportCallbackEXT(backendContext.fInstance,
&callbackCreateInfo, nullptr, &fCallback));
}
#endif
if (!fMemoryAllocator) {
// We were not given a memory allocator at creation
- fMemoryAllocator.reset(new GrVkAMDMemoryAllocator(fBackendContext->fPhysicalDevice,
- fDevice, fBackendContext->fInterface));
+ fMemoryAllocator.reset(new GrVkAMDMemoryAllocator(backendContext.fPhysicalDevice,
+ fDevice, backendContext.fInterface));
}
fCompiler = new SkSL::Compiler();
- fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), fBackendContext->fPhysicalDevice,
- fBackendContext->fFeatures, fBackendContext->fExtensions));
+ fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendContext.fPhysicalDevice,
+ backendContext.fFeatures, backendContext.fExtensions));
fCaps.reset(SkRef(fVkCaps.get()));
- VK_CALL(GetPhysicalDeviceProperties(fBackendContext->fPhysicalDevice, &fPhysDevProps));
- VK_CALL(GetPhysicalDeviceMemoryProperties(fBackendContext->fPhysicalDevice, &fPhysDevMemProps));
+ VK_CALL(GetPhysicalDeviceProperties(backendContext.fPhysicalDevice, &fPhysDevProps));
+ VK_CALL(GetPhysicalDeviceMemoryProperties(backendContext.fPhysicalDevice, &fPhysDevMemProps));
const VkCommandPoolCreateInfo cmdPoolInfo = {
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
nullptr, // pNext
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // CmdPoolCreateFlags
- fBackendContext->fGraphicsQueueIndex, // queueFamilyIndex
+ backendContext.fGraphicsQueueIndex, // queueFamilyIndex
};
GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPoolInfo, nullptr,
&fCmdPool));
@@ -201,10 +206,15 @@ void GrVkGpu::destroyResources() {
#ifdef SK_ENABLE_VK_LAYERS
if (fCallback) {
- VK_CALL(DestroyDebugReportCallbackEXT(fBackendContext->fInstance, fCallback, nullptr));
+ VK_CALL(DestroyDebugReportCallbackEXT(fInstance, fCallback, nullptr));
}
#endif
+ fMemoryAllocator.reset();
+
+ fQueue = VK_NULL_HANDLE;
+ fDevice = VK_NULL_HANDLE;
+ fInstance = VK_NULL_HANDLE;
}
GrVkGpu::~GrVkGpu() {