Move GrVkInterface out of public API.
Bug: skia: Change-Id: I8b73982e4c9372af1c35bfc5e665c2c146d7d9f5 Reviewed-on: https://skia-review.googlesource.com/141121 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
9b9453e907
commit
d3e65aa758
@ -536,7 +536,6 @@ skia_null_gpu_sources = []
|
||||
skia_vk_sources = [
|
||||
"$_include/gpu/vk/GrVkBackendContext.h",
|
||||
"$_include/gpu/vk/GrVkDefines.h",
|
||||
"$_include/gpu/vk/GrVkInterface.h",
|
||||
"$_include/gpu/vk/GrVkMemoryAllocator.h",
|
||||
"$_include/gpu/vk/GrVkTypes.h",
|
||||
"$_include/private/GrVkTypesPriv.h",
|
||||
@ -576,6 +575,7 @@ skia_vk_sources = [
|
||||
"$_src/gpu/vk/GrVkIndexBuffer.cpp",
|
||||
"$_src/gpu/vk/GrVkIndexBuffer.h",
|
||||
"$_src/gpu/vk/GrVkInterface.cpp",
|
||||
"$_src/gpu/vk/GrVkInterface.h",
|
||||
"$_src/gpu/vk/GrVkMemory.cpp",
|
||||
"$_src/gpu/vk/GrVkMemory.h",
|
||||
"$_src/gpu/vk/GrVkPipeline.cpp",
|
||||
|
@ -8,10 +8,9 @@
|
||||
#ifndef GrVkBackendContext_DEFINED
|
||||
#define GrVkBackendContext_DEFINED
|
||||
|
||||
#include <functional>
|
||||
#include "GrVkTypes.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
#include "vk/GrVkDefines.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "vk/GrVkMemoryAllocator.h"
|
||||
|
||||
enum GrVkExtensionFlags {
|
||||
@ -53,7 +52,6 @@ struct SK_API GrVkBackendContext {
|
||||
uint32_t fMinAPIVersion;
|
||||
uint32_t fExtensions;
|
||||
uint32_t fFeatures;
|
||||
sk_sp<const GrVkInterface> fInterface;
|
||||
sk_sp<GrVkMemoryAllocator> fMemoryAllocator;
|
||||
GrVkGetProc fGetProc = nullptr;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "GrVkAMDMemoryAllocator.h"
|
||||
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "GrVkMemory.h"
|
||||
#include "GrVkUtil.h"
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "GrRenderTargetProxy.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#include "GrShaderCaps.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "GrVkUtil.h"
|
||||
#include "vk/GrVkBackendContext.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
|
||||
GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface,
|
||||
VkPhysicalDevice physDev, uint32_t featureFlags, uint32_t extensionFlags)
|
||||
|
@ -9,9 +9,9 @@
|
||||
#define GrVkExtensions_DEFINED
|
||||
|
||||
#include "../private/SkTArray.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "SkString.h"
|
||||
#include "vk/GrVkDefines.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "vk/GrVkTypes.h"
|
||||
|
||||
/**
|
||||
* This helper queries the Vulkan driver for available extensions and layers, remembers them,
|
||||
@ -19,12 +19,12 @@
|
||||
*/
|
||||
class SK_API GrVkExtensions {
|
||||
public:
|
||||
GrVkExtensions(GrVkInterface::GetProc getProc)
|
||||
: fGetProc(getProc)
|
||||
, fInstanceExtensionStrings(new SkTArray<SkString>)
|
||||
, fDeviceExtensionStrings(new SkTArray<SkString>)
|
||||
, fInstanceLayerStrings(new SkTArray<SkString>)
|
||||
, fDeviceLayerStrings(new SkTArray<SkString>) {}
|
||||
GrVkExtensions(GrVkGetProc getProc)
|
||||
: fGetProc(getProc)
|
||||
, fInstanceExtensionStrings(new SkTArray<SkString>)
|
||||
, fDeviceExtensionStrings(new SkTArray<SkString>)
|
||||
, fInstanceLayerStrings(new SkTArray<SkString>)
|
||||
, fDeviceLayerStrings(new SkTArray<SkString>) {}
|
||||
|
||||
bool initInstance(uint32_t specVersion);
|
||||
bool initDevice(uint32_t specVersion, VkInstance, VkPhysicalDevice);
|
||||
@ -40,7 +40,7 @@ public:
|
||||
void print(const char* sep = "\n") const;
|
||||
|
||||
private:
|
||||
GrVkInterface::GetProc fGetProc;
|
||||
GrVkGetProc fGetProc;
|
||||
std::unique_ptr<SkTArray<SkString>> fInstanceExtensionStrings;
|
||||
std::unique_ptr<SkTArray<SkString>> fDeviceExtensionStrings;
|
||||
std::unique_ptr<SkTArray<SkString>> fInstanceLayerStrings;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "GrVkGpuCommandBuffer.h"
|
||||
#include "GrVkImage.h"
|
||||
#include "GrVkIndexBuffer.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "GrVkMemory.h"
|
||||
#include "GrVkPipeline.h"
|
||||
#include "GrVkPipelineState.h"
|
||||
@ -35,7 +36,6 @@
|
||||
#include "SkMipMap.h"
|
||||
#include "SkSLCompiler.h"
|
||||
#include "SkTo.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "vk/GrVkTypes.h"
|
||||
|
||||
#include <utility>
|
||||
@ -56,19 +56,15 @@ sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext,
|
||||
backendContext.fQueue == VK_NULL_HANDLE) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<const GrVkInterface> interface;
|
||||
if (backendContext.fGetProc) {
|
||||
interface.reset(new GrVkInterface(backendContext.fGetProc,
|
||||
backendContext.fInstance,
|
||||
backendContext.fDevice,
|
||||
backendContext.fExtensions));
|
||||
} else {
|
||||
if (!backendContext.fInterface) {
|
||||
return nullptr;
|
||||
}
|
||||
interface = backendContext.fInterface;
|
||||
if (!backendContext.fGetProc) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT(interface);
|
||||
|
||||
sk_sp<const GrVkInterface> interface(new GrVkInterface(backendContext.fGetProc,
|
||||
backendContext.fInstance,
|
||||
backendContext.fDevice,
|
||||
backendContext.fExtensions));
|
||||
|
||||
if (!interface->validate(backendContext.fExtensions)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -5,34 +5,14 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "vk/GrVkBackendContext.h"
|
||||
#include "vk/GrVkUtil.h"
|
||||
|
||||
#define ACQUIRE_PROC(name, instance, device) fFunctions.f##name = \
|
||||
reinterpret_cast<PFN_vk##name>(getProc("vk"#name, instance, device));
|
||||
|
||||
GrVkInterface::GetProc make_unified_getter(const GrVkInterface::GetInstanceProc& iproc,
|
||||
const GrVkInterface::GetDeviceProc& dproc) {
|
||||
return [&iproc, &dproc](const char* proc_name, VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
return dproc(device, proc_name);
|
||||
}
|
||||
return iproc(instance, proc_name);
|
||||
};
|
||||
}
|
||||
|
||||
GrVkInterface::GrVkInterface(const GetInstanceProc& getInstanceProc,
|
||||
const GetDeviceProc& getDeviceProc,
|
||||
VkInstance instance,
|
||||
VkDevice device,
|
||||
uint32_t extensionFlags)
|
||||
: GrVkInterface(make_unified_getter(getInstanceProc, getDeviceProc),
|
||||
instance,
|
||||
device,
|
||||
extensionFlags) {}
|
||||
|
||||
GrVkInterface::GrVkInterface(GetProc getProc,
|
||||
GrVkInterface::GrVkInterface(GrVkGetProc getProc,
|
||||
VkInstance instance,
|
||||
VkDevice device,
|
||||
uint32_t extensionFlags) {
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
#include "vk/GrVkDefines.h"
|
||||
#include "vk/GrVkBackendContext.h"
|
||||
#include "vk/GrVkTypes.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -35,27 +36,7 @@ private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
|
||||
public:
|
||||
// TODO: This matches the definition of GrVkGetProc in GrVkTypes. Once we switch clients to
|
||||
// using that and make GrVkInterface private, we can remove this GetProc.
|
||||
using GetProc = std::function<PFN_vkVoidFunction(
|
||||
const char*, // function name
|
||||
VkInstance, // instance or VK_NULL_HANDLE
|
||||
VkDevice // device or VK_NULL_HANDLE
|
||||
)>;
|
||||
|
||||
// This is typically vkGetInstanceProcAddr.
|
||||
using GetInstanceProc = std::function<PFN_vkVoidFunction(VkInstance, const char*)>;
|
||||
|
||||
// This is typically vkGetDeviceProcAddr.
|
||||
using GetDeviceProc = std::function<PFN_vkVoidFunction(VkDevice, const char*)>;
|
||||
|
||||
GrVkInterface(GetProc getProc,
|
||||
VkInstance instance,
|
||||
VkDevice device,
|
||||
uint32_t extensionFlags);
|
||||
|
||||
GrVkInterface(const GetInstanceProc&,
|
||||
const GetDeviceProc&,
|
||||
GrVkInterface(GrVkGetProc getProc,
|
||||
VkInstance instance,
|
||||
VkDevice device,
|
||||
uint32_t extensionFlags);
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include "GrColor.h"
|
||||
#include "GrTypes.h"
|
||||
#include "GrVkInterface.h"
|
||||
#include "SkMacros.h"
|
||||
#include "ir/SkSLProgram.h"
|
||||
#include "vk/GrVkDefines.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
|
||||
class GrVkGpu;
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
headerLoc=../third_party/vulkan/vulkan.h
|
||||
outFile=tempVkInterface
|
||||
|
||||
if [ ! -e "$outFile" ] ; then
|
||||
echo 'I AM HERE'
|
||||
touch "$outFile"
|
||||
fi
|
||||
|
||||
chmod 700 $outFile
|
||||
|
||||
echo '// *******************************************' > $outFile
|
||||
echo '// Place these lines into GrVkInterface.cpp::validate' >> $outFile
|
||||
echo '// *******************************************' >> $outFile
|
||||
sed -n 's/^VKAPI_ATTR \(VkResult\|void\) VKAPI_CALL vk\([a-zA-Z]*\).*/NULL == fFunctions.f\2 ||/p' $headerLoc >> $outFile
|
||||
sed -i '1,/NULL/ s/^NULL/if (NULL/' $outFile
|
||||
sed -i '5,$ s/^/ /' $outFile
|
||||
sed -i '$ s/ ||/) {/' $outFile
|
||||
|
||||
echo '' >> $outFile
|
||||
echo '// *******************************************' >> $outFile
|
||||
echo '// Place these lines into GrVkInterface.h' >> $outFile
|
||||
echo '// *******************************************' >> $outFile
|
||||
sed -n 's/^VKAPI_ATTR \(VkResult\|void\) VKAPI_CALL vk\([a-zA-Z]*\).*/VkPtr<PFN_vk\2> f\2;/p' $headerLoc >> $outFile
|
||||
|
||||
echo '' >> $outFile
|
||||
echo '// *******************************************' >> $outFile
|
||||
echo '// Place these lines into GrVkInterface.cpp::GrVKCreateInterface' >> $outFile
|
||||
echo '// *******************************************' >> $outFile
|
||||
sed -n 's/^VKAPI_ATTR \(VkResult\|void\) VKAPI_CALL vk\([a-zA-Z]*\).*/GET_PROC(\2);/p' $headerLoc >> $outFile
|
||||
|
@ -162,7 +162,14 @@ public:
|
||||
if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc, &devProc)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!sk_gpu_test::CreateVkBackendContext(instProc, devProc, &backendContext,
|
||||
auto getProc = [instProc, devProc](const char* proc_name,
|
||||
VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
return devProc(device, proc_name);
|
||||
}
|
||||
return instProc(instance, proc_name);
|
||||
};
|
||||
if (!sk_gpu_test::CreateVkBackendContext(getProc, &backendContext,
|
||||
&debugCallback)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace sk_gpu_test {
|
||||
|
||||
bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc,
|
||||
PFN_vkGetDeviceProcAddr* devProc) {
|
||||
PFN_vkGetDeviceProcAddr* devProc) {
|
||||
#ifdef SK_MOLTENVK
|
||||
// MoltenVK is a statically linked framework, so there is no Vulkan library to load.
|
||||
*instProc = &vkGetInstanceProcAddr;
|
||||
@ -120,7 +120,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
|
||||
return; \
|
||||
}
|
||||
|
||||
static void destroy_instance(GrVkInterface::GetProc getProc, VkInstance inst,
|
||||
static void destroy_instance(GrVkGetProc getProc, VkInstance inst,
|
||||
VkDebugReportCallbackEXT* debugCallback,
|
||||
bool hasDebugExtension) {
|
||||
if (hasDebugExtension && *debugCallback != VK_NULL_HANDLE) {
|
||||
@ -132,20 +132,11 @@ static void destroy_instance(GrVkInterface::GetProc getProc, VkInstance inst,
|
||||
grVkDestroyInstance(inst, nullptr);
|
||||
}
|
||||
|
||||
bool CreateVkBackendContext(const GrVkInterface::GetInstanceProc& getInstanceProc,
|
||||
const GrVkInterface::GetDeviceProc& getDeviceProc,
|
||||
bool CreateVkBackendContext(GrVkGetProc getProc,
|
||||
GrVkBackendContext* ctx,
|
||||
VkDebugReportCallbackEXT* debugCallback,
|
||||
uint32_t* presentQueueIndexPtr,
|
||||
CanPresentFn canPresent) {
|
||||
auto getProc = [getInstanceProc, getDeviceProc](const char* proc_name,
|
||||
VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
return getDeviceProc(device, proc_name);
|
||||
}
|
||||
return getInstanceProc(instance, proc_name);
|
||||
};
|
||||
|
||||
VkPhysicalDevice physDev;
|
||||
VkDevice device;
|
||||
VkInstance inst;
|
||||
@ -417,7 +408,6 @@ bool CreateVkBackendContext(const GrVkInterface::GetInstanceProc& getInstancePro
|
||||
ctx->fMinAPIVersion = kGrVkMinimumVersion;
|
||||
ctx->fExtensions = extensionFlags;
|
||||
ctx->fFeatures = featureFlags;
|
||||
ctx->fInterface = nullptr;
|
||||
ctx->fGetProc = getProc;
|
||||
ctx->fOwnsInstanceAndDevice = false;
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
|
||||
#ifdef SK_VULKAN
|
||||
|
||||
#include "vk/GrVkDefines.h"
|
||||
#include "vk/GrVkInterface.h"
|
||||
#include "vk/GrVkBackendContext.h"
|
||||
#include "vk/GrVkTypes.h"
|
||||
#include <functional>
|
||||
|
||||
struct GrVkBackendContext;
|
||||
|
||||
@ -23,8 +24,7 @@ namespace sk_gpu_test {
|
||||
using CanPresentFn = std::function<bool(VkInstance, VkPhysicalDevice,
|
||||
uint32_t queueFamilyIndex)>;
|
||||
|
||||
bool CreateVkBackendContext(const GrVkInterface::GetInstanceProc& getInstanceProc,
|
||||
const GrVkInterface::GetDeviceProc& getDeviceProc,
|
||||
bool CreateVkBackendContext(GrVkGetProc getProc,
|
||||
GrVkBackendContext* ctx,
|
||||
VkDebugReportCallbackEXT* debugCallback,
|
||||
uint32_t* presentQueueIndexPtr = nullptr,
|
||||
|
@ -49,8 +49,17 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
|
||||
void VulkanWindowContext::initializeContext() {
|
||||
// any config code here (particularly for msaa)?
|
||||
|
||||
PFN_vkGetInstanceProcAddr getInstanceProc = fGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr getDeviceProc = fGetDeviceProcAddr;
|
||||
auto getProc = [getInstanceProc, getDeviceProc](const char* proc_name,
|
||||
VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
return getDeviceProc(device, proc_name);
|
||||
}
|
||||
return getInstanceProc(instance, proc_name);
|
||||
};
|
||||
GrVkBackendContext backendContext;
|
||||
if (!sk_gpu_test::CreateVkBackendContext(fGetInstanceProcAddr, fGetDeviceProcAddr,
|
||||
if (!sk_gpu_test::CreateVkBackendContext(getProc,
|
||||
&backendContext, &fDebugCallback,
|
||||
&fPresentQueueIndex, fCanPresentFn)) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user