Add WSI functions to GrVkInterface

BUG=skia:5043
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1834903003

Review URL: https://codereview.chromium.org/1834903003
This commit is contained in:
jvanverth 2016-03-28 07:03:06 -07:00 committed by Commit bot
parent 6d37635636
commit e50f3e7539
31 changed files with 157 additions and 83 deletions

View File

@ -427,6 +427,7 @@
],
'skgpu_vk_sources': [
'<(skia_include_path)/gpu/vk/GrVkBackendContext.h',
'<(skia_include_path)/gpu/vk/GrVkDefines.h',
'<(skia_include_path)/gpu/vk/GrVkInterface.h',
'<(skia_include_path)/gpu/vk/GrVkTypes.h',
'<(skia_src_path)/gpu/vk/GrVkBackendContext.cpp',

View File

@ -10,7 +10,7 @@
#include "SkRefCnt.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
#ifdef SK_DEBUG
#define ENABLE_VK_LAYERS
@ -19,8 +19,13 @@
struct GrVkInterface;
enum GrVkExtensionFlags {
kEXT_debug_report_GrVkExtensionFlag = 0x0001,
kNV_glsl_shader_GrVkExtensionFlag = 0x0002,
kEXT_debug_report_GrVkExtensionFlag = 0x0001,
kNV_glsl_shader_GrVkExtensionFlag = 0x0002,
kKHR_surface_GrVkExtensionFlag = 0x0004,
kKHR_swapchain_GrVkExtensionFlag = 0x0008,
kKHR_win32_surface_GrVkExtensionFlag = 0x0010,
kKHR_android_surface_GrVkExtensionFlag = 0x0020,
kKHR_xlib_surface_GrVkExtensionFlag = 0x0040,
};
enum GrVkFeatureFlags {

View File

@ -0,0 +1,22 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrVkDefines_DEFINED
#define GrVkDefines_DEFINED
#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_WIN32)
#define VK_USE_PLATFORM_WIN32_KHR
#elif defined(SK_BUILD_FOR_ANDROID)
#define VK_USE_PLATFORM_ANDROID_KHR
#elif defined(SK_BUILD_FOR_UNIX)
#define VK_USE_PLATFORM_XLIB_KHR
#endif
#include <vulkan/vulkan.h>
#endif

View File

@ -5,17 +5,17 @@
* found in the LICENSE file.
*/
#ifndef GrRadInterface_DEFINED
#define GrRadInterface_DEFINED
#ifndef GrVkInterface_DEFINED
#define GrVkInterface_DEFINED
#include "SkRefCnt.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
////////////////////////////////////////////////////////////////////////////////
/**
* The default interface is returned by GrVkDefaultInterface. This function's
* The default interface is returned by GrVkCreateInterface. This function's
* implementation is platform-specific.
*/
@ -200,6 +200,15 @@ public:
VkPtr<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR> fGetPhysicalDeviceSurfaceCapabilitiesKHR;
VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFormatsKHR;
VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfacePresentModesKHR;
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VkPtr<PFN_vkCreateWin32SurfaceKHR> fCreateWin32SurfaceKHR;
VkPtr<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR> fGetPhysicalDeviceWin32PresentationSupportKHR;
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
VkPtr<PFN_vkCreateAndroidSurfaceKHR> fCreateAndroidSurfaceKHR;
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
VkPtr<PFN_vkCreateXlibSurfaceKHR> fCreateXlibSurfaceKHR;
VkPtr<PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR> fGetPhysicalDeviceXlibPresentationSupportKHR;
#endif
VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR;
VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR;
VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR;

View File

@ -9,7 +9,7 @@
#ifndef GrVkTypes_DEFINED
#define GrVkTypes_DEFINED
#include <vulkan/vulkan.h>
#include "vk/GrVkDefines.h"
/**
* KHR_debug

View File

@ -68,6 +68,30 @@ const GrVkBackendContext* GrVkBackendContext::Create() {
instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
extensionFlags |= kEXT_debug_report_GrVkExtensionFlag;
}
if (extensions.hasInstanceExtension(VK_KHR_SURFACE_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
extensionFlags |= kKHR_surface_GrVkExtensionFlag;
}
if (extensions.hasInstanceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
extensionFlags |= kKHR_swapchain_GrVkExtensionFlag;
}
#ifdef SK_BUILD_FOR_WIN
if (extensions.hasInstanceExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
extensionFlags |= kKHR_win32_surface_GrVkExtensionFlag;
}
#elif SK_BUILD_FOR_ANDROID
if (extensions.hasInstanceExtension(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
extensionFlags |= kKHR_android_surface_GrVkExtensionFlag;
}
#elif SK_BUILD_FOR_UNIX
if (extensions.hasInstanceExtension(VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
extensionFlags |= kKHR_xlib_surface_GrVkExtensionFlag;
}
#endif
#endif
const VkInstanceCreateInfo instance_create = {

View File

@ -8,8 +8,8 @@
#ifndef GrVkBuffer_DEFINED
#define GrVkBuffer_DEFINED
#include "vk/GrVkInterface.h"
#include "GrVkResource.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;
@ -86,7 +86,7 @@ private:
const Resource* fResource;
void* fMapPtr;
typedef SkRefCnt INHERITED;
typedef SkNoncopyable INHERITED;
};
#endif

View File

@ -10,7 +10,7 @@
#include "GrCaps.h"
#include "GrVkStencilAttachment.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
struct GrVkInterface;
class GrGLSLCaps;
@ -75,9 +75,9 @@ private:
uint32_t featureFlags);
void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags);
void initSampleCount(const VkPhysicalDeviceProperties& properties);
void initConfigRenderableTable(const GrVkInterface* interface, VkPhysicalDevice physDev);
void initConfigTexturableTable(const GrVkInterface* interface, VkPhysicalDevice physDev);
void initStencilFormats(const GrVkInterface* interface, VkPhysicalDevice physDev);
void initConfigRenderableTable(const GrVkInterface* iface, VkPhysicalDevice physDev);
void initConfigTexturableTable(const GrVkInterface* iface, VkPhysicalDevice physDev);
void initStencilFormats(const GrVkInterface* iface, VkPhysicalDevice physDev);
bool fConfigTextureSupport[kGrPixelConfigCnt];

View File

@ -11,7 +11,7 @@
#include "GrVkGpu.h"
#include "GrVkResource.h"
#include "GrVkUtil.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkPipeline;
class GrVkRenderPass;

View File

@ -10,7 +10,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;

View File

@ -10,7 +10,7 @@
#include "../private/SkTArray.h"
#include "SkString.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
/**
* This helper queries the Vulkan driver for available extensions and layers, remembers them,

View File

@ -12,7 +12,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;
class GrVkImageView;
@ -42,4 +42,4 @@ private:
typedef GrVkResource INHERITED;
};
#endif
#endif

View File

@ -18,7 +18,7 @@
#include "GrVkUtil.h"
#include "shaderc/shaderc.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrPipeline;
class GrNonInstancedMesh;

View File

@ -11,7 +11,7 @@
#include "GrVkResource.h"
#include "SkTypes.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;

View File

@ -12,7 +12,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkImageView : public GrVkResource {
public:
@ -38,4 +38,4 @@ private:
typedef GrVkResource INHERITED;
};
#endif
#endif

View File

@ -10,7 +10,6 @@
#include "GrBuffer.h"
#include "GrVkBuffer.h"
#include "vk/GrVkInterface.h"
class GrVkGpu;

View File

@ -157,25 +157,45 @@ const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkDevice device,
GET_DEV_PROC(CmdNextSubpass);
GET_DEV_PROC(CmdEndRenderPass);
GET_DEV_PROC(CmdExecuteCommands);
// TODO: break these out with extension checks
GET_PROC(DestroySurfaceKHR);
GET_PROC(GetPhysicalDeviceSurfaceSupportKHR);
GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
GET_PROC(GetPhysicalDeviceSurfaceFormatsKHR);
GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR);
GET_DEV_PROC(CreateSwapchainKHR);
GET_DEV_PROC(DestroySwapchainKHR);
GET_DEV_PROC(GetSwapchainImagesKHR);
GET_DEV_PROC(AcquireNextImageKHR);
GET_DEV_PROC(QueuePresentKHR);
GET_PROC(GetPhysicalDeviceDisplayPropertiesKHR);
GET_PROC(GetPhysicalDeviceDisplayPlanePropertiesKHR);
GET_PROC(GetDisplayPlaneSupportedDisplaysKHR);
GET_PROC(GetDisplayModePropertiesKHR);
GET_PROC(CreateDisplayModeKHR);
GET_PROC(GetDisplayPlaneCapabilitiesKHR);
GET_PROC(CreateDisplayPlaneSurfaceKHR);
GET_DEV_PROC(CreateSharedSwapchainsKHR);
if (extensionFlags & kKHR_surface_GrVkExtensionFlag) {
GET_PROC(DestroySurfaceKHR);
GET_PROC(GetPhysicalDeviceSurfaceSupportKHR);
GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
GET_PROC(GetPhysicalDeviceSurfaceFormatsKHR);
GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR);
}
if (extensionFlags & kKHR_surface_GrVkExtensionFlag) {
GET_DEV_PROC(CreateSwapchainKHR);
GET_DEV_PROC(DestroySwapchainKHR);
GET_DEV_PROC(GetSwapchainImagesKHR);
GET_DEV_PROC(AcquireNextImageKHR);
GET_DEV_PROC(QueuePresentKHR);
}
#if defined(VK_USE_PLATFORM_WIN32_KHR)
if (extensionFlags & kKHR_win32_surface_GrVkExtensionFlag) {
GET_PROC(CreateWin32SurfaceKHR);
GET_PROC(GetPhysicalDeviceWin32PresentationSupportKHR);
}
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
if (extensionFlags & kKHR_android_surface_GrVkExtensionFlag) {
GET_PROC(CreateAndroidSurfaceKHR);
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
if (extensionFlags & kKHR_xlib_surface_GrVkExtensionFlag) {
GET_PROC(CreateXlibSurfaceKHR);
GET_PROC(GetPhysicalDeviceXlibPresentationSupportKHR);
}
#endif
// We probably don't care about these, they're for consoles
//GET_PROC(GetPhysicalDeviceDisplayPropertiesKHR);
//GET_PROC(GetPhysicalDeviceDisplayPlanePropertiesKHR);
//GET_PROC(GetDisplayPlaneSupportedDisplaysKHR);
//GET_PROC(GetDisplayModePropertiesKHR);
//GET_PROC(CreateDisplayModeKHR);
//GET_PROC(GetDisplayPlaneCapabilitiesKHR);
//GET_PROC(CreateDisplayPlaneSurfaceKHR);
//GET_DEV_PROC(CreateSharedSwapchainsKHR);
if (extensionFlags & kEXT_debug_report_GrVkExtensionFlag) {
GET_PROC(CreateDebugReportCallbackEXT);
@ -326,18 +346,17 @@ bool GrVkInterface::validate() const {
NULL == fFunctions.fCmdBeginRenderPass ||
NULL == fFunctions.fCmdNextSubpass ||
NULL == fFunctions.fCmdEndRenderPass ||
NULL == fFunctions.fCmdExecuteCommands
#ifdef VK_CHECK_ALL_FUNCTIONS
// || NULL == fFunctions.fDestroySurfaceKHR ||
//NULL == fFunctions.fGetPhysicalDeviceSurfaceSupportKHR ||
//NULL == fFunctions.fGetPhysicalDeviceSurfaceCapabilitiesKHR ||
//NULL == fFunctions.fGetPhysicalDeviceSurfaceFormatsKHR ||
//NULL == fFunctions.fGetPhysicalDeviceSurfacePresentModesKHR ||
//NULL == fFunctions.fCreateSwapchainKHR ||
//NULL == fFunctions.fDestroySwapchainKHR ||
//NULL == fFunctions.fGetSwapchainImagesKHR ||
//NULL == fFunctions.fAcquireNextImageKHR ||
//NULL == fFunctions.fQueuePresentKHR ||
NULL == fFunctions.fCmdExecuteCommands ||
NULL == fFunctions.fDestroySurfaceKHR ||
NULL == fFunctions.fGetPhysicalDeviceSurfaceSupportKHR ||
NULL == fFunctions.fGetPhysicalDeviceSurfaceCapabilitiesKHR ||
NULL == fFunctions.fGetPhysicalDeviceSurfaceFormatsKHR ||
NULL == fFunctions.fGetPhysicalDeviceSurfacePresentModesKHR ||
NULL == fFunctions.fCreateSwapchainKHR ||
NULL == fFunctions.fDestroySwapchainKHR ||
NULL == fFunctions.fGetSwapchainImagesKHR ||
NULL == fFunctions.fAcquireNextImageKHR ||
NULL == fFunctions.fQueuePresentKHR ||
//NULL == fFunctions.fGetPhysicalDeviceDisplayPropertiesKHR ||
//NULL == fFunctions.fGetPhysicalDeviceDisplayPlanePropertiesKHR ||
//NULL == fFunctions.fGetDisplayPlaneSupportedDisplaysKHR ||
@ -346,12 +365,10 @@ bool GrVkInterface::validate() const {
//NULL == fFunctions.fGetDisplayPlaneCapabilitiesKHR ||
//NULL == fFunctions.fCreateDisplayPlaneSurfaceKHR ||
//NULL == fFunctions.fCreateSharedSwapchainsKHR ||
//NULL == fFunctions.fCreateDebugReportCallbackEXT ||
//NULL == fFunctions.fDebugReportMessageEXT ||
//NULL == fFunctions.fDestroyDebugReportCallbackEXT) {
#else
) {
#endif
NULL == fFunctions.fCreateDebugReportCallbackEXT ||
NULL == fFunctions.fDebugReportMessageEXT ||
NULL == fFunctions.fDestroyDebugReportCallbackEXT) {
return false;
}
return true;

View File

@ -62,11 +62,11 @@ bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu,
VkBuffer buffer,
const VkMemoryPropertyFlags flags,
VkDeviceMemory* memory) {
const GrVkInterface* interface = gpu->vkInterface();
const GrVkInterface* iface = gpu->vkInterface();
VkDevice device = gpu->device();
VkMemoryRequirements memReqs;
GR_VK_CALL(interface, GetBufferMemoryRequirements(device, buffer, &memReqs));
GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs));
if (!alloc_device_memory(gpu, &memReqs, flags, memory)) {
@ -74,9 +74,9 @@ bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu,
}
// Bind Memory to queue
VkResult err = GR_VK_CALL(interface, BindBufferMemory(device, buffer, *memory, 0));
VkResult err = GR_VK_CALL(iface, BindBufferMemory(device, buffer, *memory, 0));
if (err) {
GR_VK_CALL(interface, FreeMemory(device, *memory, nullptr));
GR_VK_CALL(iface, FreeMemory(device, *memory, nullptr));
return false;
}
return true;
@ -86,20 +86,20 @@ bool GrVkMemory::AllocAndBindImageMemory(const GrVkGpu* gpu,
VkImage image,
const VkMemoryPropertyFlags flags,
VkDeviceMemory* memory) {
const GrVkInterface* interface = gpu->vkInterface();
const GrVkInterface* iface = gpu->vkInterface();
VkDevice device = gpu->device();
VkMemoryRequirements memReqs;
GR_VK_CALL(interface, GetImageMemoryRequirements(device, image, &memReqs));
GR_VK_CALL(iface, GetImageMemoryRequirements(device, image, &memReqs));
if (!alloc_device_memory(gpu, &memReqs, flags, memory)) {
return false;
}
// Bind Memory to queue
VkResult err = GR_VK_CALL(interface, BindImageMemory(device, image, *memory, 0));
VkResult err = GR_VK_CALL(iface, BindImageMemory(device, image, *memory, 0));
if (err) {
GR_VK_CALL(interface, FreeMemory(device, *memory, nullptr));
GR_VK_CALL(iface, FreeMemory(device, *memory, nullptr));
return false;
}
return true;

View File

@ -8,7 +8,7 @@
#ifndef GrVkMemory_DEFINED
#define GrVkMemory_DEFINED
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;
@ -32,4 +32,4 @@ namespace GrVkMemory {
VkAccessFlags LayoutToSrcAccessMask(const VkImageLayout layout);
}
#endif
#endif

View File

@ -12,7 +12,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrNonInstancedVertices;
class GrPipeline;

View File

@ -14,7 +14,7 @@
#include "GrVkPipelineStateDataManager.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrPipeline;
class GrVkCommandBuffer;

View File

@ -16,7 +16,7 @@
#include "GrVkVaryingHandler.h"
#include "shaderc/shaderc.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;
class GrVkRenderPass;

View File

@ -14,7 +14,7 @@
#include "GrTypesPriv.h"
#include "shaderc/shaderc.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkGpu;
class GrVkProgramDescBuilder;

View File

@ -12,7 +12,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrProcessorKeyBuilder;
class GrVkGpu;

View File

@ -16,7 +16,7 @@
#include "SkTArray.h"
#include "SkTDynamicHash.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrPipeline;
class GrPrimitiveProcessor;

View File

@ -10,7 +10,7 @@
#include "GrVkResource.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrTextureAccess;
class GrTextureParams;

View File

@ -10,7 +10,7 @@
#include "GrStencilAttachment.h"
#include "GrVkImage.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
class GrVkImageView;
class GrVkGpu;

View File

@ -10,7 +10,6 @@
#include "GrBuffer.h"
#include "GrVkBuffer.h"
#include "vk/GrVkInterface.h"
class GrVkGpu;

View File

@ -9,7 +9,6 @@
#define GrVkUniformBuffer_DEFINED
#include "GrVkBuffer.h"
#include "vk/GrVkInterface.h"
class GrVkGpu;

View File

@ -12,7 +12,7 @@
#include "GrTypes.h"
#include "vk/GrVkInterface.h"
#include "vulkan/vulkan.h"
#include "vk/GrVkDefines.h"
// makes a Vk call on the interface
#define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X;

View File

@ -10,7 +10,6 @@
#include "GrBuffer.h"
#include "GrVkBuffer.h"
#include "vk/GrVkInterface.h"
class GrVkGpu;