Support using vulkan 1.1.

Bug: skia:
Change-Id: Ic1fc109557f64c748c9ba5427b400795dbde7250
Reviewed-on: https://skia-review.googlesource.com/137882
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2018-08-02 13:55:49 -04:00 committed by Skia Commit-Bot
parent d938887cfe
commit 92aef4b125
5 changed files with 41 additions and 17 deletions

View File

@ -45,8 +45,9 @@ struct SK_API GrVkBackendContext {
VkDevice fDevice;
VkQueue fQueue;
uint32_t fGraphicsQueueIndex;
uint32_t fMinAPIVersion;
uint32_t fExtensions = 0;
uint32_t fMinAPIVersion; // Deprecated. Set fInstanceVersion instead.
uint32_t fInstanceVersion = 0;
uint32_t fExtensions = 0; // Deprecated. Use fVkExtensions instead.
const GrVkExtensions* fVkExtensions = nullptr;
uint32_t fFeatures = kIgnoreAllFlags_GrVkFeatureFlag;
VkPhysicalDeviceFeatures fDeviceFeatures;

View File

@ -15,7 +15,8 @@
#include "vk/GrVkBackendContext.h"
GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface,
VkPhysicalDevice physDev, const VkPhysicalDeviceFeatures& features)
VkPhysicalDevice physDev, const VkPhysicalDeviceFeatures& features,
uint32_t instanceVersion)
: INHERITED(contextOptions) {
fMustDoCopiesFromOrigin = false;
fMustSubmitCommandsBeforeCopyOp = false;

View File

@ -27,7 +27,8 @@ public:
* be called to fill out the caps.
*/
GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface,
VkPhysicalDevice device, const VkPhysicalDeviceFeatures& features);
VkPhysicalDevice device, const VkPhysicalDeviceFeatures& features,
uint32_t instanceVersion);
bool isConfigTexturable(GrPixelConfig config) const override {
return SkToBool(ConfigInfo::kTextureable_Flag & fConfigTable[config].fOptimalFlags);

View File

@ -114,9 +114,12 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
fCompiler = new SkSL::Compiler();
uint32_t instanceVersion = backendContext.fInstanceVersion ? backendContext.fInstanceVersion
: backendContext.fMinAPIVersion;
if (backendContext.fFeatures & kIgnoreAllFlags_GrVkFeatureFlag) {
fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendContext.fPhysicalDevice,
backendContext.fDeviceFeatures));
backendContext.fDeviceFeatures, instanceVersion));
} else {
VkPhysicalDeviceFeatures features;
if (backendContext.fFeatures & kGeometryShader_GrVkFeatureFlag) {
@ -129,7 +132,7 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
features.sampleRateShading = true;
}
fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendContext.fPhysicalDevice,
features));
features, instanceVersion));
}
fCaps.reset(SkRef(fVkCaps.get()));

View File

@ -75,6 +75,7 @@ static bool should_include_debug_layer(const VkLayerProperties& layerProps) {
}
return false;
}
VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT objectType,
@ -276,12 +277,10 @@ static bool init_device_extensions_and_layers(GrVkGetProc getProc, uint32_t spec
return true;
}
// the minimum version of Vulkan supported
#ifdef SK_BUILD_FOR_ANDROID
const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 3);
#else
const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 8);
#endif
#define ACQUIRE_VK_PROC_NOCHECK(name, instance, device) \
PFN_vk##name grVk##name = \
reinterpret_cast<PFN_vk##name>(getProc("vk" #name, instance, device));
#define ACQUIRE_VK_PROC(name, instance, device) \
PFN_vk##name grVk##name = \
@ -320,10 +319,24 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
VkDebugReportCallbackEXT* debugCallback,
uint32_t* presentQueueIndexPtr,
CanPresentFn canPresent) {
VkResult err;
ACQUIRE_VK_PROC_NOCHECK(EnumerateInstanceVersion, VK_NULL_HANDLE, VK_NULL_HANDLE);
uint32_t instanceVersion = 0;
if (!grVkEnumerateInstanceVersion) {
instanceVersion = VK_MAKE_VERSION(1, 0, 0);
} else {
err = grVkEnumerateInstanceVersion(&instanceVersion);
if (err) {
SkDebugf("failed ot enumerate instance version. Err: %d\n", err);
return false;
}
}
SkASSERT(instanceVersion >= VK_MAKE_VERSION(1, 0, 0));
VkPhysicalDevice physDev;
VkDevice device;
VkInstance inst;
VkResult err;
const VkApplicationInfo app_info = {
VK_STRUCTURE_TYPE_APPLICATION_INFO, // sType
@ -332,13 +345,13 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
0, // applicationVersion
"vktest", // pEngineName
0, // engineVerison
kGrVkMinimumVersion, // apiVersion
instanceVersion, // apiVersion
};
SkTArray<VkLayerProperties> instanceLayers;
SkTArray<VkExtensionProperties> instanceExtensions;
if (!init_instance_extensions_and_layers(getProc, kGrVkMinimumVersion,
if (!init_instance_extensions_and_layers(getProc, instanceVersion,
&instanceExtensions,
&instanceLayers)) {
return false;
@ -402,6 +415,7 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
#endif
ACQUIRE_VK_PROC(EnumeratePhysicalDevices, inst, VK_NULL_HANDLE);
ACQUIRE_VK_PROC(GetPhysicalDeviceProperties, inst, VK_NULL_HANDLE);
ACQUIRE_VK_PROC(GetPhysicalDeviceQueueFamilyProperties, inst, VK_NULL_HANDLE);
ACQUIRE_VK_PROC(GetPhysicalDeviceFeatures, inst, VK_NULL_HANDLE);
ACQUIRE_VK_PROC(CreateDevice, inst, VK_NULL_HANDLE);
@ -432,6 +446,10 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
return false;
}
VkPhysicalDeviceProperties physDeviceProperties;
grVkGetPhysicalDeviceProperties(physDev, &physDeviceProperties);
int physDeviceVersion = physDeviceProperties.apiVersion;
// query to get the initial queue props size
uint32_t queueCount;
grVkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr);
@ -484,7 +502,7 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
SkTArray<VkLayerProperties> deviceLayers;
SkTArray<VkExtensionProperties> deviceExtensions;
if (!init_device_extensions_and_layers(getProc, kGrVkMinimumVersion,
if (!init_device_extensions_and_layers(getProc, physDeviceVersion,
inst, physDev,
&deviceExtensions,
&deviceLayers)) {
@ -571,7 +589,7 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
ctx->fDevice = device;
ctx->fQueue = queue;
ctx->fGraphicsQueueIndex = graphicsQueueIndex;
ctx->fMinAPIVersion = kGrVkMinimumVersion;
ctx->fInstanceVersion = instanceVersion;
ctx->fVkExtensions = extensions;
ctx->fDeviceFeatures = deviceFeatures;
ctx->fGetProc = getProc;