aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/vk')
-rw-r--r--src/gpu/vk/GrVkBackendContext.cpp252
-rw-r--r--src/gpu/vk/GrVkExtensions.cpp138
-rw-r--r--src/gpu/vk/GrVkExtensions.h1
-rw-r--r--src/gpu/vk/GrVkGpu.cpp314
-rw-r--r--src/gpu/vk/GrVkGpu.h41
-rw-r--r--src/gpu/vk/GrVkInterface.cpp255
-rw-r--r--src/gpu/vk/GrVkUniformHandler.h6
7 files changed, 587 insertions, 420 deletions
diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp
new file mode 100644
index 0000000000..c169c620a1
--- /dev/null
+++ b/src/gpu/vk/GrVkBackendContext.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "vk/GrVkBackendContext.h"
+#include "vk/GrVkInterface.h"
+#include "vk/GrVkUtil.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper code to set up Vulkan context objects
+
+#ifdef ENABLE_VK_LAYERS
+const char* kEnabledLayerNames[] = {
+ // elements of VK_LAYER_LUNARG_standard_validation
+ "VK_LAYER_LUNARG_threading",
+ "VK_LAYER_LUNARG_param_checker",
+ "VK_LAYER_LUNARG_device_limits",
+ "VK_LAYER_LUNARG_object_tracker",
+ "VK_LAYER_LUNARG_image",
+ "VK_LAYER_LUNARG_mem_tracker",
+ "VK_LAYER_LUNARG_draw_state",
+ "VK_LAYER_LUNARG_swapchain",
+ "VK_LAYER_GOOGLE_unique_objects",
+ // not included in standard_validation
+ //"VK_LAYER_LUNARG_api_dump",
+};
+const char* kEnabledInstanceExtensionNames[] = {
+ VK_EXT_DEBUG_REPORT_EXTENSION_NAME
+};
+
+bool verify_instance_layers() {
+ // make sure we can actually use the extensions and layers above
+ uint32_t extensionCount;
+ VkResult res = vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount];
+ res = vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ int instanceExtensionsFound = 0;
+ for (uint32_t j = 0; j < ARRAYSIZE(kEnabledInstanceExtensionNames); ++j) {
+ for (uint32_t i = 0; i < extensionCount; ++i) {
+ if (!strncmp(extensions[i].extensionName, kEnabledInstanceExtensionNames[j],
+ strlen(kEnabledInstanceExtensionNames[j]))) {
+ ++instanceExtensionsFound;
+ break;
+ }
+ }
+ }
+ delete[] extensions;
+
+ uint32_t layerCount;
+ res = vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkLayerProperties* layers = new VkLayerProperties[layerCount];
+ res = vkEnumerateInstanceLayerProperties(&layerCount, layers);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ int instanceLayersFound = 0;
+ for (uint32_t j = 0; j < ARRAYSIZE(kEnabledLayerNames); ++j) {
+ for (uint32_t i = 0; i < layerCount; ++i) {
+ if (!strncmp(layers[i].layerName, kEnabledLayerNames[j],
+ strlen(kEnabledLayerNames[j]))) {
+ ++instanceLayersFound;
+ break;
+ }
+ }
+ }
+ delete[] layers;
+
+ return instanceExtensionsFound == ARRAYSIZE(kEnabledInstanceExtensionNames) &&
+ instanceLayersFound == ARRAYSIZE(kEnabledLayerNames);
+}
+
+bool verify_device_layers(VkPhysicalDevice physDev) {
+ uint32_t layerCount;
+ VkResult res = vkEnumerateDeviceLayerProperties(physDev, &layerCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkLayerProperties* layers = new VkLayerProperties[layerCount];
+ res = vkEnumerateDeviceLayerProperties(physDev, &layerCount, layers);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ int deviceLayersFound = 0;
+ for (uint32_t j = 0; j < ARRAYSIZE(kEnabledLayerNames); ++j) {
+ for (uint32_t i = 0; i < layerCount; ++i) {
+ if (!strncmp(layers[i].layerName, kEnabledLayerNames[j],
+ strlen(kEnabledLayerNames[j]))) {
+ ++deviceLayersFound;
+ break;
+ }
+ }
+ }
+ delete[] layers;
+
+ return deviceLayersFound == ARRAYSIZE(kEnabledLayerNames);
+}
+#endif
+
+// Create the base Vulkan objects needed by the GrVkGpu object
+const GrVkBackendContext* GrVkBackendContext::Create() {
+ VkPhysicalDevice physDev;
+ VkDevice device;
+ VkInstance inst;
+ VkResult err;
+
+ const VkApplicationInfo app_info = {
+ VK_STRUCTURE_TYPE_APPLICATION_INFO, // sType
+ nullptr, // pNext
+ "vktest", // pApplicationName
+ 0, // applicationVersion
+ "vktest", // pEngineName
+ 0, // engineVerison
+ kGrVkMinimumVersion, // apiVersion
+ };
+
+ const char** enabledLayerNames = nullptr;
+ int enabledLayerCount = 0;
+ const char** enabledInstanceExtensionNames = nullptr;
+ int enabledInstanceExtensionCount = 0;
+#ifdef ENABLE_VK_LAYERS
+ if (verify_instance_layers()) {
+ enabledLayerNames = kEnabledLayerNames;
+ enabledLayerCount = ARRAYSIZE(kEnabledLayerNames);
+ enabledInstanceExtensionNames = kEnabledInstanceExtensionNames;
+ enabledInstanceExtensionCount = ARRAYSIZE(kEnabledInstanceExtensionNames);
+ }
+#endif
+
+ const VkInstanceCreateInfo instance_create = {
+ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
+ nullptr, // pNext
+ 0, // flags
+ &app_info, // pApplicationInfo
+ enabledLayerCount, // enabledLayerNameCount
+ enabledLayerNames, // ppEnabledLayerNames
+ enabledInstanceExtensionCount, // enabledExtensionNameCount
+ enabledInstanceExtensionNames, // ppEnabledExtensionNames
+ };
+
+ err = vkCreateInstance(&instance_create, nullptr, &inst);
+ if (err < 0) {
+ SkDebugf("vkCreateInstance failed: %d\n", err);
+ SkFAIL("failing");
+ }
+
+ uint32_t gpuCount;
+ err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr);
+ if (err) {
+ SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err);
+ SkFAIL("failing");
+ }
+ SkASSERT(gpuCount > 0);
+ // Just returning the first physical device instead of getting the whole array.
+ // TODO: find best match for our needs
+ gpuCount = 1;
+ err = vkEnumeratePhysicalDevices(inst, &gpuCount, &physDev);
+ if (err) {
+ SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err);
+ SkFAIL("failing");
+ }
+
+ // query to get the initial queue props size
+ uint32_t queueCount;
+ vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr);
+ SkASSERT(queueCount >= 1);
+
+ SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties));
+ // now get the actual queue props
+ VkQueueFamilyProperties* queueProps = (VkQueueFamilyProperties*)queuePropsAlloc.get();
+
+ vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, queueProps);
+
+ // iterate to find the graphics queue
+ uint32_t graphicsQueueIndex = -1;
+ for (uint32_t i = 0; i < queueCount; i++) {
+ if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
+ graphicsQueueIndex = i;
+ break;
+ }
+ }
+ SkASSERT(graphicsQueueIndex < queueCount);
+
+#ifdef ENABLE_VK_LAYERS
+ // unlikely that the device will have different layers than the instance, but good to check
+ if (!verify_device_layers(physDev)) {
+ enabledLayerNames = nullptr;
+ enabledLayerCount = 0;
+ }
+#endif
+
+ float queuePriorities[1] = { 0.0 };
+ // Here we assume no need for swapchain queue
+ // If one is needed, the client will need its own setup code
+ const VkDeviceQueueCreateInfo queueInfo = {
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
+ nullptr, // pNext
+ 0, // VkDeviceQueueCreateFlags
+ graphicsQueueIndex, // queueFamilyIndex
+ 1, // queueCount
+ queuePriorities, // pQueuePriorities
+ };
+ const VkDeviceCreateInfo deviceInfo = {
+ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
+ nullptr, // pNext
+ 0, // VkDeviceCreateFlags
+ 1, // queueCreateInfoCount
+ &queueInfo, // pQueueCreateInfos
+ enabledLayerCount, // layerCount
+ enabledLayerNames, // ppEnabledLayerNames
+ 0, // extensionCount
+ nullptr, // ppEnabledExtensionNames
+ nullptr // ppEnabledFeatures
+ };
+
+ err = vkCreateDevice(physDev, &deviceInfo, nullptr, &device);
+ if (err) {
+ SkDebugf("CreateDevice failed: %d\n", err);
+ return nullptr;
+ }
+
+ VkQueue queue;
+ vkGetDeviceQueue(device, graphicsQueueIndex, 0, &queue);
+
+ GrVkBackendContext* ctx = new GrVkBackendContext();
+ ctx->fInstance = inst;
+ ctx->fPhysicalDevice = physDev;
+ ctx->fDevice = device;
+ ctx->fQueue = queue;
+ ctx->fQueueFamilyIndex = graphicsQueueIndex;
+ ctx->fInterface.reset(GrVkCreateInterface(inst, physDev, device));
+
+ return ctx;
+}
+
+GrVkBackendContext::~GrVkBackendContext() {
+ vkDestroyDevice(fDevice, nullptr);
+ fDevice = VK_NULL_HANDLE;
+ vkDestroyInstance(fInstance, nullptr);
+ fInstance = VK_NULL_HANDLE;
+}
diff --git a/src/gpu/vk/GrVkExtensions.cpp b/src/gpu/vk/GrVkExtensions.cpp
index 8fa99cf9fc..c84dda359f 100644
--- a/src/gpu/vk/GrVkExtensions.cpp
+++ b/src/gpu/vk/GrVkExtensions.cpp
@@ -50,12 +50,14 @@ GrVkExtensions& GrVkExtensions::operator=(const GrVkExtensions& that) {
bool GrVkExtensions::init(
uint32_t specVersion,
+ VkPhysicalDevice physDev,
PFN_vkEnumerateInstanceExtensionProperties enumerateInstanceExtensionProperties,
PFN_vkEnumerateDeviceExtensionProperties enumerateDeviceExtensionProperties,
PFN_vkEnumerateInstanceLayerProperties enumerateInstanceLayerProperties,
PFN_vkEnumerateDeviceLayerProperties enumerateDeviceLayerProperties) {
fInitialized = false;
this->reset();
+ SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
if (!enumerateInstanceExtensionProperties ||
!enumerateDeviceExtensionProperties ||
@@ -64,25 +66,147 @@ bool GrVkExtensions::init(
return false;
}
+ // instance layers
+ uint32_t layerCount = 0;
+ VkResult res = enumerateInstanceLayerProperties(&layerCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkLayerProperties* layers = new VkLayerProperties[layerCount];
+ res = enumerateInstanceLayerProperties(&layerCount, layers);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ for (uint32_t i = 0; i < layerCount; ++i) {
+ if (specVersion >= layers[i].specVersion) {
+ fInstanceLayerStrings->push_back() = layers[i].layerName;
+ }
+ }
+ delete[] layers;
+ if (!fInstanceLayerStrings->empty()) {
+ SkTQSort(&fInstanceLayerStrings->front(), &fInstanceLayerStrings->back(), cmp);
+ }
+
// instance extensions
+ // via Vulkan implementation and implicitly enabled layers
uint32_t extensionCount = 0;
- VkResult res = enumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
-
+ res = enumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount];
res = enumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions);
-
- fInstanceExtensionStrings->push_back_n(extensionCount);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
for (uint32_t i = 0; i < extensionCount; ++i) {
if (specVersion >= extensions[i].specVersion) {
- (*fInstanceExtensionStrings)[i] = extensions[i].extensionName;
+ fInstanceExtensionStrings->push_back() = extensions[i].extensionName;
}
}
delete [] extensions;
-
+ // sort so we can search
if (!fInstanceExtensionStrings->empty()) {
- SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings->back(), cmp);
}
+ // via explicitly enabled layers
+ layerCount = fInstanceLayerStrings->count();
+ for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) {
+ uint32_t extensionCount = 0;
+ res = enumerateInstanceExtensionProperties((*fInstanceLayerStrings)[layerIndex].c_str(),
+ &extensionCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount];
+ res = enumerateInstanceExtensionProperties((*fInstanceLayerStrings)[layerIndex].c_str(),
+ &extensionCount, extensions);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ for (uint32_t i = 0; i < extensionCount; ++i) {
+ // if not already in the list, add it
+ if (specVersion >= extensions[i].specVersion &&
+ find_string(*fInstanceExtensionStrings, extensions[i].extensionName) < 0) {
+ fInstanceExtensionStrings->push_back() = extensions[i].extensionName;
+ SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings->back(),
+ cmp);
+ }
+ }
+ delete[] extensions;
+ }
+
+ // device layers
+ layerCount = 0;
+ res = enumerateDeviceLayerProperties(physDev, &layerCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ layers = new VkLayerProperties[layerCount];
+ res = enumerateDeviceLayerProperties(physDev, &layerCount, layers);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ for (uint32_t i = 0; i < layerCount; ++i) {
+ if (specVersion >= layers[i].specVersion) {
+ fDeviceLayerStrings->push_back() = layers[i].layerName;
+ }
+ }
+ delete[] layers;
+ if (!fDeviceLayerStrings->empty()) {
+ SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
+ SkTQSort(&fDeviceLayerStrings->front(), &fDeviceLayerStrings->back(), cmp);
+ }
+
+ // device extensions
+ // via Vulkan implementation and implicitly enabled layers
+ extensionCount = 0;
+ res = enumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ extensions = new VkExtensionProperties[extensionCount];
+ res = enumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount, extensions);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ for (uint32_t i = 0; i < extensionCount; ++i) {
+ if (specVersion >= extensions[i].specVersion) {
+ fDeviceExtensionStrings->push_back() = extensions[i].extensionName;
+ }
+ }
+ delete[] extensions;
+ if (!fDeviceExtensionStrings->empty()) {
+ SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
+ SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStrings->back(), cmp);
+ }
+ // via explicitly enabled layers
+ layerCount = fDeviceLayerStrings->count();
+ for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) {
+ uint32_t extensionCount = 0;
+ res = enumerateDeviceExtensionProperties(physDev,
+ (*fDeviceLayerStrings)[layerIndex].c_str(),
+ &extensionCount, nullptr);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount];
+ res = enumerateDeviceExtensionProperties(physDev,
+ (*fDeviceLayerStrings)[layerIndex].c_str(),
+ &extensionCount, extensions);
+ if (VK_SUCCESS != res) {
+ return false;
+ }
+ for (uint32_t i = 0; i < extensionCount; ++i) {
+ // if not already in the list, add it
+ if (specVersion >= extensions[i].specVersion &&
+ find_string(*fDeviceExtensionStrings, extensions[i].extensionName) < 0) {
+ fDeviceExtensionStrings->push_back() = extensions[i].extensionName;
+ SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStrings->back(), cmp);
+ }
+ }
+ delete[] extensions;
+ }
fInitialized = true;
return true;
diff --git a/src/gpu/vk/GrVkExtensions.h b/src/gpu/vk/GrVkExtensions.h
index d1d57e424a..a165730444 100644
--- a/src/gpu/vk/GrVkExtensions.h
+++ b/src/gpu/vk/GrVkExtensions.h
@@ -41,6 +41,7 @@ public:
* We sometimes need to use this class without having yet created a GrVkInterface.
*/
bool init(uint32_t specVersion,
+ VkPhysicalDevice physDev,
PFN_vkEnumerateInstanceExtensionProperties enumerateInstanceExtensionProperties,
PFN_vkEnumerateDeviceExtensionProperties enumerateDeviceExtensionProperties,
PFN_vkEnumerateInstanceLayerProperties enumerateInstanceLayerProperties,
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 926e423b6e..f01c2e45e5 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -40,10 +40,6 @@
#define VK_CALL_RET(RET, X) GR_VK_CALL_RET(this->vkInterface(), RET, X)
#define VK_CALL_ERRCHECK(X) GR_VK_CALL_ERRCHECK(this->vkInterface(), X)
-////////////////////////////////////////////////////////////////////////////////
-// Stuff used to set up a GrVkGpu secrectly for now.
-
-
#ifdef ENABLE_VK_LAYERS
VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
VkDebugReportFlagsEXT flags,
@@ -65,272 +61,37 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
}
return VK_FALSE;
}
-
-const char* kEnabledLayerNames[] = {
- // elements of VK_LAYER_LUNARG_standard_validation
- "VK_LAYER_LUNARG_threading",
- "VK_LAYER_LUNARG_param_checker",
- "VK_LAYER_LUNARG_device_limits",
- "VK_LAYER_LUNARG_object_tracker",
- "VK_LAYER_LUNARG_image",
- "VK_LAYER_LUNARG_mem_tracker",
- "VK_LAYER_LUNARG_draw_state",
- "VK_LAYER_LUNARG_swapchain",
- "VK_LAYER_GOOGLE_unique_objects",
- // not included in standard_validation
- //"VK_LAYER_LUNARG_api_dump",
-};
-const char* kEnabledInstanceExtensionNames[] = {
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME
-};
-
-bool verify_instance_layers() {
- // make sure we can actually use the extensions and layers above
- uint32_t extensionCount;
- VkResult res = vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
- if (VK_SUCCESS != res) {
- return false;
- }
- VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount];
- res = vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions);
- if (VK_SUCCESS != res) {
- return false;
- }
- int instanceExtensionsFound = 0;
- for (uint32_t j = 0; j < ARRAYSIZE(kEnabledInstanceExtensionNames); ++j) {
- for (uint32_t i = 0; i < extensionCount; ++i) {
- if (!strncmp(extensions[i].extensionName, kEnabledInstanceExtensionNames[j],
- strlen(kEnabledInstanceExtensionNames[j]))) {
- ++instanceExtensionsFound;
- break;
- }
- }
- }
- delete[] extensions;
-
- uint32_t layerCount;
- res = vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
- if (VK_SUCCESS != res) {
- return false;
- }
- VkLayerProperties* layers = new VkLayerProperties[layerCount];
- res = vkEnumerateInstanceLayerProperties(&layerCount, layers);
- if (VK_SUCCESS != res) {
- return false;
- }
- int instanceLayersFound = 0;
- for (uint32_t j = 0; j < ARRAYSIZE(kEnabledLayerNames); ++j) {
- for (uint32_t i = 0; i < layerCount; ++i) {
- if (!strncmp(layers[i].layerName, kEnabledLayerNames[j],
- strlen(kEnabledLayerNames[j]))) {
- ++instanceLayersFound;
- break;
- }
- }
- }
- delete[] layers;
-
- return instanceExtensionsFound == ARRAYSIZE(kEnabledInstanceExtensionNames) &&
- instanceLayersFound == ARRAYSIZE(kEnabledLayerNames);
-}
-
-bool verify_device_layers(VkPhysicalDevice physDev) {
- uint32_t layerCount;
- VkResult res = vkEnumerateDeviceLayerProperties(physDev, &layerCount, nullptr);
- if (VK_SUCCESS != res) {
- return false;
- }
- VkLayerProperties* layers = new VkLayerProperties[layerCount];
- res = vkEnumerateDeviceLayerProperties(physDev, &layerCount, layers);
- if (VK_SUCCESS != res) {
- return false;
- }
- int deviceLayersFound = 0;
- for (uint32_t j = 0; j < ARRAYSIZE(kEnabledLayerNames); ++j) {
- for (uint32_t i = 0; i < layerCount; ++i) {
- if (!strncmp(layers[i].layerName, kEnabledLayerNames[j],
- strlen(kEnabledLayerNames[j]))) {
- ++deviceLayersFound;
- break;
- }
- }
- }
- delete[] layers;
-
- return deviceLayersFound == ARRAYSIZE(kEnabledLayerNames);
-}
#endif
-// For now the VkGpuCreate is using the same signature as GL. This is mostly for ease of
-// hiding this code from offical skia. In the end the VkGpuCreate will not take a GrBackendContext
-// and mostly likely would take an optional device and queues to use.
-GrGpu* vk_gpu_create(GrBackendContext backendContext, const GrContextOptions& options,
- GrContext* context) {
- // Below is Vulkan setup code that normal would be done by a client, but will do here for now
- // for testing purposes.
- VkPhysicalDevice physDev;
- VkDevice device;
- VkInstance inst;
- VkResult err;
-
- const VkApplicationInfo app_info = {
- VK_STRUCTURE_TYPE_APPLICATION_INFO, // sType
- nullptr, // pNext
- "vktest", // pApplicationName
- 0, // applicationVersion
- "vktest", // pEngineName
- 0, // engineVerison
- kGrVkMinimumVersion, // apiVersion
- };
-
- const char** enabledLayerNames = nullptr;
- int enabledLayerCount = 0;
- const char** enabledInstanceExtensionNames = nullptr;
- int enabledInstanceExtensionCount = 0;
-#ifdef ENABLE_VK_LAYERS
- if (verify_instance_layers()) {
- enabledLayerNames = kEnabledLayerNames;
- enabledLayerCount = ARRAYSIZE(kEnabledLayerNames);
- enabledInstanceExtensionNames = kEnabledInstanceExtensionNames;
- enabledInstanceExtensionCount = ARRAYSIZE(kEnabledInstanceExtensionNames);
- }
-#endif
-
- const VkInstanceCreateInfo instance_create = {
- VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
- nullptr, // pNext
- 0, // flags
- &app_info, // pApplicationInfo
- enabledLayerCount, // enabledLayerNameCount
- enabledLayerNames, // ppEnabledLayerNames
- enabledInstanceExtensionCount, // enabledExtensionNameCount
- enabledInstanceExtensionNames, // ppEnabledExtensionNames
- };
-
- err = vkCreateInstance(&instance_create, nullptr, &inst);
- if (err < 0) {
- SkDebugf("vkCreateInstanced failed: %d\n", err);
- SkFAIL("failing");
- }
-
- uint32_t gpuCount;
- err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr);
- if (err) {
- SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err);
- SkFAIL("failing");
- }
- SkASSERT(gpuCount > 0);
- // Just returning the first physical device instead of getting the whole array.
- gpuCount = 1;
- err = vkEnumeratePhysicalDevices(inst, &gpuCount, &physDev);
- if (err) {
- SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err);
- SkFAIL("failing");
- }
-
- // query to get the initial queue props size
- uint32_t queueCount;
- vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr);
- SkASSERT(queueCount >= 1);
-
- SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties));
- // now get the actual queue props
- VkQueueFamilyProperties* queueProps = (VkQueueFamilyProperties*)queuePropsAlloc.get();
-
- vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, queueProps);
-
- // iterate to find the graphics queue
- uint32_t graphicsQueueIndex = -1;
- for (uint32_t i = 0; i < queueCount; i++) {
- if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
- graphicsQueueIndex = i;
- break;
+GrGpu* GrVkGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context) {
+ SkAutoTUnref<const GrVkBackendContext> vkBackendContext(
+ reinterpret_cast<const GrVkBackendContext*>(backendContext));
+ if (!vkBackendContext) {
+ vkBackendContext.reset(GrVkBackendContext::Create());
+ if (!vkBackendContext) {
+ return nullptr;
}
- }
- SkASSERT(graphicsQueueIndex < queueCount);
-
-#ifdef ENABLE_VK_LAYERS
- // unlikely that the device will have different layers than the instance, but good to check
- if (!verify_device_layers(physDev)) {
- enabledLayerNames = nullptr;
- enabledLayerCount = 0;
- }
-#endif
-
- float queuePriorities[1] = { 0.0 };
- const VkDeviceQueueCreateInfo queueInfo = {
- VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
- nullptr, // pNext
- 0, // VkDeviceQueueCreateFlags
- 0, // queueFamilyIndex
- 1, // queueCount
- queuePriorities, // pQueuePriorities
- };
- const VkDeviceCreateInfo deviceInfo = {
- VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
- nullptr, // pNext
- 0, // VkDeviceCreateFlags
- 1, // queueCreateInfoCount
- &queueInfo, // pQueueCreateInfos
- enabledLayerCount, // layerCount
- enabledLayerNames, // ppEnabledLayerNames
- 0, // extensionCount
- nullptr, // ppEnabledExtensionNames
- nullptr // ppEnabledFeatures
- };
-
- err = vkCreateDevice(physDev, &deviceInfo, nullptr, &device);
- if (err) {
- SkDebugf("CreateDevice failed: %d\n", err);
- SkFAIL("failing");
- }
-
- VkQueue queue;
- vkGetDeviceQueue(device, graphicsQueueIndex, 0, &queue);
-
- const VkCommandPoolCreateInfo cmdPoolInfo = {
- VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
- nullptr, // pNext
- 0, // CmdPoolCreateFlags
- graphicsQueueIndex, // queueFamilyIndex
- };
-
- VkCommandPool cmdPool;
- err = vkCreateCommandPool(device, &cmdPoolInfo, nullptr, &cmdPool);
- if (err) {
- SkDebugf("CreateCommandPool failed: %d\n", err);
- SkFAIL("failing");
+ } else {
+ vkBackendContext->ref();
}
- return new GrVkGpu(context, options, physDev, device, queue, cmdPool, inst);
+ return new GrVkGpu(context, options, vkBackendContext);
}
////////////////////////////////////////////////////////////////////////////////
-GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
- VkPhysicalDevice physDev, VkDevice device, VkQueue queue, VkCommandPool cmdPool,
- VkInstance inst)
+GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
+ const GrVkBackendContext* backendCtx)
: INHERITED(context)
- , fDevice(device)
- , fQueue(queue)
- , fCmdPool(cmdPool)
- , fResourceProvider(this)
- , fVkInstance(inst) {
- fInterface.reset(GrVkCreateInterface(fVkInstance));
- fCompiler = shaderc_compiler_initialize();
-
- fVkCaps.reset(new GrVkCaps(options, fInterface, physDev));
- fCaps.reset(SkRef(fVkCaps.get()));
-
- fResourceProvider.init();
-
- fCurrentCmdBuffer = fResourceProvider.createCommandBuffer();
- SkASSERT(fCurrentCmdBuffer);
- fCurrentCmdBuffer->begin(this);
- VK_CALL(GetPhysicalDeviceMemoryProperties(physDev, &fPhysDevMemProps));
+ , fVkInstance(backendCtx->fInstance)
+ , fDevice(backendCtx->fDevice)
+ , fQueue(backendCtx->fQueue)
+ , fResourceProvider(this) {
+ fBackendContext.reset(backendCtx);
#ifdef ENABLE_VK_LAYERS
- if (fInterface->hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) {
+ if (this->vkInterface()->hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) {
/* Setup callback creation information */
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -344,14 +105,35 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
callbackCreateInfo.pUserData = nullptr;
/* Register the callback */
- GR_VK_CALL_ERRCHECK(fInterface, CreateDebugReportCallbackEXT(inst, &callbackCreateInfo,
- nullptr, &fCallback));
+ GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(fVkInstance,
+ &callbackCreateInfo, nullptr, &fCallback));
}
#endif
+
+ fCompiler = shaderc_compiler_initialize();
+
+ fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysicalDevice));
+ fCaps.reset(SkRef(fVkCaps.get()));
+
+ VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhysDevMemProps));
+
+ const VkCommandPoolCreateInfo cmdPoolInfo = {
+ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
+ nullptr, // pNext
+ VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // CmdPoolCreateFlags
+ backendCtx->fQueueFamilyIndex, // queueFamilyIndex
+ };
+ GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPoolInfo, nullptr,
+ &fCmdPool));
+
+ // must call this after creating the CommandPool
+ fResourceProvider.init();
+ fCurrentCmdBuffer = fResourceProvider.createCommandBuffer();
+ SkASSERT(fCurrentCmdBuffer);
+ fCurrentCmdBuffer->begin(this);
}
GrVkGpu::~GrVkGpu() {
- shaderc_compiler_release(fCompiler);
fCurrentCmdBuffer->end(this);
fCurrentCmdBuffer->unref(this);
@@ -364,13 +146,13 @@ GrVkGpu::~GrVkGpu() {
// must call this just before we destroy the VkDevice
fResourceProvider.destroyResources();
-#ifdef SK_DEBUG
+ VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr));
+
+ shaderc_compiler_release(fCompiler);
+
+#ifdef ENABLE_VK_LAYERS
VK_CALL(DestroyDebugReportCallbackEXT(fVkInstance, fCallback, nullptr));
#endif
-
- VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr));
- VK_CALL(DestroyDevice(fDevice, nullptr));
- VK_CALL(DestroyInstance(fVkInstance, nullptr));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index a686c721fd..b9f9027945 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -10,6 +10,7 @@
#include "GrGpu.h"
#include "GrGpuFactory.h"
+#include "vk/GrVkBackendContext.h"
#include "GrVkCaps.h"
#include "GrVkIndexBuffer.h"
#include "GrVkProgram.h"
@@ -36,14 +37,12 @@ struct GrVkInterface;
class GrVkGpu : public GrGpu {
public:
- // Currently passing in the inst so that we can properly delete it when we are done.
- // Normally this would be done by the client.
- GrVkGpu(GrContext* context, const GrContextOptions& options,
- VkPhysicalDevice physDev, VkDevice device, VkQueue queue, VkCommandPool cmdPool,
- VkInstance inst);
+ static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context);
+
~GrVkGpu() override;
- const GrVkInterface* vkInterface() const { return fInterface.get(); }
+ const GrVkInterface* vkInterface() const { return fBackendContext->fInterface; }
const GrVkCaps& vkCaps() const { return *fVkCaps; }
VkDevice device() const { return fDevice; }
@@ -124,6 +123,9 @@ public:
void finishDrawTarget() override;
private:
+ GrVkGpu(GrContext* context, const GrContextOptions& options,
+ const GrVkBackendContext* backendContext);
+
void onResetContext(uint32_t resetBits) override {}
GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCycle,
@@ -211,27 +213,30 @@ private:
const void* data,
size_t rowBytes);
- SkAutoTUnref<const GrVkInterface> fInterface;
- SkAutoTUnref<GrVkCaps> fVkCaps;
- VkPhysicalDeviceMemoryProperties fPhysDevMemProps;
- VkDevice fDevice;
- VkQueue fQueue; // for now, one queue
- VkCommandPool fCmdPool;
- GrVkCommandBuffer* fCurrentCmdBuffer;
- GrVkResourceProvider fResourceProvider;
+ SkAutoTUnref<const GrVkBackendContext> fBackendContext;
+ SkAutoTUnref<GrVkCaps> fVkCaps;
+
+ // These Vulkan objects are provided by the client, and also stored in fBackendContext.
+ // They're copied here for convenient access.
+ VkInstance fVkInstance;
+ VkDevice fDevice;
+ VkQueue fQueue; // Must be Graphics queue
+
+ // Created by GrVkGpu
+ GrVkResourceProvider fResourceProvider;
+ VkCommandPool fCmdPool;
+ GrVkCommandBuffer* fCurrentCmdBuffer;
+ VkPhysicalDeviceMemoryProperties fPhysDevMemProps;
#ifdef ENABLE_VK_LAYERS
// For reporting validation layer errors
- VkDebugReportCallbackEXT fCallback;
+ VkDebugReportCallbackEXT fCallback;
#endif
// Shaderc compiler used for compiling glsl in spirv. We only want to create the compiler once
// since there is significant overhead to the first compile of any compiler.
shaderc_compiler_t fCompiler;
- // This is only for our current testing and building. The client should be holding on to the
- // VkInstance.
- VkInstance fVkInstance;
typedef GrGpu INHERITED;
};
diff --git a/src/gpu/vk/GrVkInterface.cpp b/src/gpu/vk/GrVkInterface.cpp
index 4b12e13f0c..4d445a4989 100644
--- a/src/gpu/vk/GrVkInterface.cpp
+++ b/src/gpu/vk/GrVkInterface.cpp
@@ -13,8 +13,10 @@ GrVkInterface::GrVkInterface() {
#define GET_PROC(F) functions->f ## F = (PFN_vk ## F) vkGetInstanceProcAddr(instance, "vk" #F)
#define GET_PROC_LOCAL(inst, F) PFN_vk ## F F = (PFN_vk ## F) vkGetInstanceProcAddr(inst, "vk" #F)
+#define GET_DEV_PROC(F) functions->f ## F = (PFN_vk ## F) vkGetDeviceProcAddr(device, "vk" #F)
-const GrVkInterface* GrVkCreateInterface(VkInstance instance) {
+const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkPhysicalDevice physDev,
+ VkDevice device) {
GET_PROC_LOCAL(nullptr, EnumerateInstanceExtensionProperties);
GET_PROC_LOCAL(instance, EnumerateDeviceExtensionProperties);
@@ -23,6 +25,7 @@ const GrVkInterface* GrVkCreateInterface(VkInstance instance) {
GrVkExtensions extensions;
if (!extensions.init(kGrVkMinimumVersion,
+ physDev,
EnumerateInstanceExtensionProperties,
EnumerateDeviceExtensionProperties,
EnumerateInstanceLayerProperties,
@@ -48,137 +51,137 @@ const GrVkInterface* GrVkCreateInterface(VkInstance instance) {
GET_PROC(EnumerateDeviceExtensionProperties);
GET_PROC(EnumerateInstanceLayerProperties);
GET_PROC(EnumerateDeviceLayerProperties);
- GET_PROC(GetDeviceQueue);
- GET_PROC(QueueSubmit);
- GET_PROC(QueueWaitIdle);
- GET_PROC(DeviceWaitIdle);
- GET_PROC(AllocateMemory);
- GET_PROC(FreeMemory);
- GET_PROC(MapMemory);
- GET_PROC(UnmapMemory);
- GET_PROC(FlushMappedMemoryRanges);
- GET_PROC(InvalidateMappedMemoryRanges);
- GET_PROC(GetDeviceMemoryCommitment);
- GET_PROC(BindBufferMemory);
- GET_PROC(BindImageMemory);
- GET_PROC(GetBufferMemoryRequirements);
- GET_PROC(GetImageMemoryRequirements);
- GET_PROC(GetImageSparseMemoryRequirements);
+ GET_DEV_PROC(GetDeviceQueue);
+ GET_DEV_PROC(QueueSubmit);
+ GET_DEV_PROC(QueueWaitIdle);
+ GET_DEV_PROC(DeviceWaitIdle);
+ GET_DEV_PROC(AllocateMemory);
+ GET_DEV_PROC(FreeMemory);
+ GET_DEV_PROC(MapMemory);
+ GET_DEV_PROC(UnmapMemory);
+ GET_DEV_PROC(FlushMappedMemoryRanges);
+ GET_DEV_PROC(InvalidateMappedMemoryRanges);
+ GET_DEV_PROC(GetDeviceMemoryCommitment);
+ GET_DEV_PROC(BindBufferMemory);
+ GET_DEV_PROC(BindImageMemory);
+ GET_DEV_PROC(GetBufferMemoryRequirements);
+ GET_DEV_PROC(GetImageMemoryRequirements);
+ GET_DEV_PROC(GetImageSparseMemoryRequirements);
GET_PROC(GetPhysicalDeviceSparseImageFormatProperties);
- GET_PROC(QueueBindSparse);
- GET_PROC(CreateFence);
- GET_PROC(DestroyFence);
- GET_PROC(ResetFences);
- GET_PROC(GetFenceStatus);
- GET_PROC(WaitForFences);
- GET_PROC(CreateSemaphore);
- GET_PROC(DestroySemaphore);
- GET_PROC(CreateEvent);
- GET_PROC(DestroyEvent);
- GET_PROC(GetEventStatus);
- GET_PROC(SetEvent);
- GET_PROC(ResetEvent);
- GET_PROC(CreateQueryPool);
- GET_PROC(DestroyQueryPool);
- GET_PROC(GetQueryPoolResults);
- GET_PROC(CreateBuffer);
- GET_PROC(DestroyBuffer);
- GET_PROC(CreateBufferView);
- GET_PROC(DestroyBufferView);
- GET_PROC(CreateImage);
- GET_PROC(DestroyImage);
- GET_PROC(GetImageSubresourceLayout);
- GET_PROC(CreateImageView);
- GET_PROC(DestroyImageView);
- GET_PROC(CreateShaderModule);
- GET_PROC(DestroyShaderModule);
- GET_PROC(CreatePipelineCache);
- GET_PROC(DestroyPipelineCache);
- GET_PROC(GetPipelineCacheData);
- GET_PROC(MergePipelineCaches);
- GET_PROC(CreateGraphicsPipelines);
- GET_PROC(CreateComputePipelines);
- GET_PROC(DestroyPipeline);
- GET_PROC(CreatePipelineLayout);
- GET_PROC(DestroyPipelineLayout);
- GET_PROC(CreateSampler);
- GET_PROC(DestroySampler);
- GET_PROC(CreateDescriptorSetLayout);
- GET_PROC(DestroyDescriptorSetLayout);
- GET_PROC(CreateDescriptorPool);
- GET_PROC(DestroyDescriptorPool);
- GET_PROC(ResetDescriptorPool);
- GET_PROC(AllocateDescriptorSets);
- GET_PROC(FreeDescriptorSets);
- GET_PROC(UpdateDescriptorSets);
- GET_PROC(CreateFramebuffer);
- GET_PROC(DestroyFramebuffer);
- GET_PROC(CreateRenderPass);
- GET_PROC(DestroyRenderPass);
- GET_PROC(GetRenderAreaGranularity);
- GET_PROC(CreateCommandPool);
- GET_PROC(DestroyCommandPool);
- GET_PROC(ResetCommandPool);
- GET_PROC(AllocateCommandBuffers);
- GET_PROC(FreeCommandBuffers);
- GET_PROC(BeginCommandBuffer);
- GET_PROC(EndCommandBuffer);
- GET_PROC(ResetCommandBuffer);
- GET_PROC(CmdBindPipeline);
- GET_PROC(CmdSetViewport);
- GET_PROC(CmdSetScissor);
- GET_PROC(CmdSetLineWidth);
- GET_PROC(CmdSetDepthBias);
- GET_PROC(CmdSetBlendConstants);
- GET_PROC(CmdSetDepthBounds);
- GET_PROC(CmdSetStencilCompareMask);
- GET_PROC(CmdSetStencilWriteMask);
- GET_PROC(CmdSetStencilReference);
- GET_PROC(CmdBindDescriptorSets);
- GET_PROC(CmdBindIndexBuffer);
- GET_PROC(CmdBindVertexBuffers);
- GET_PROC(CmdDraw);
- GET_PROC(CmdDrawIndexed);
- GET_PROC(CmdDrawIndirect);
- GET_PROC(CmdDrawIndexedIndirect);
- GET_PROC(CmdDispatch);
- GET_PROC(CmdDispatchIndirect);
- GET_PROC(CmdCopyBuffer);
- GET_PROC(CmdCopyImage);
- GET_PROC(CmdBlitImage);
- GET_PROC(CmdCopyBufferToImage);
- GET_PROC(CmdCopyImageToBuffer);
- GET_PROC(CmdUpdateBuffer);
- GET_PROC(CmdFillBuffer);
- GET_PROC(CmdClearColorImage);
- GET_PROC(CmdClearDepthStencilImage);
- GET_PROC(CmdClearAttachments);
- GET_PROC(CmdResolveImage);
- GET_PROC(CmdSetEvent);
- GET_PROC(CmdResetEvent);
- GET_PROC(CmdWaitEvents);
- GET_PROC(CmdPipelineBarrier);
- GET_PROC(CmdBeginQuery);
- GET_PROC(CmdEndQuery);
- GET_PROC(CmdResetQueryPool);
- GET_PROC(CmdWriteTimestamp);
- GET_PROC(CmdCopyQueryPoolResults);
- GET_PROC(CmdPushConstants);
- GET_PROC(CmdBeginRenderPass);
- GET_PROC(CmdNextSubpass);
- GET_PROC(CmdEndRenderPass);
- GET_PROC(CmdExecuteCommands);
+ GET_DEV_PROC(QueueBindSparse);
+ GET_DEV_PROC(CreateFence);
+ GET_DEV_PROC(DestroyFence);
+ GET_DEV_PROC(ResetFences);
+ GET_DEV_PROC(GetFenceStatus);
+ GET_DEV_PROC(WaitForFences);
+ GET_DEV_PROC(CreateSemaphore);
+ GET_DEV_PROC(DestroySemaphore);
+ GET_DEV_PROC(CreateEvent);
+ GET_DEV_PROC(DestroyEvent);
+ GET_DEV_PROC(GetEventStatus);
+ GET_DEV_PROC(SetEvent);
+ GET_DEV_PROC(ResetEvent);
+ GET_DEV_PROC(CreateQueryPool);
+ GET_DEV_PROC(DestroyQueryPool);
+ GET_DEV_PROC(GetQueryPoolResults);
+ GET_DEV_PROC(CreateBuffer);
+ GET_DEV_PROC(DestroyBuffer);
+ GET_DEV_PROC(CreateBufferView);
+ GET_DEV_PROC(DestroyBufferView);
+ GET_DEV_PROC(CreateImage);
+ GET_DEV_PROC(DestroyImage);
+ GET_DEV_PROC(GetImageSubresourceLayout);
+ GET_DEV_PROC(CreateImageView);
+ GET_DEV_PROC(DestroyImageView);
+ GET_DEV_PROC(CreateShaderModule);
+ GET_DEV_PROC(DestroyShaderModule);
+ GET_DEV_PROC(CreatePipelineCache);
+ GET_DEV_PROC(DestroyPipelineCache);
+ GET_DEV_PROC(GetPipelineCacheData);
+ GET_DEV_PROC(MergePipelineCaches);
+ GET_DEV_PROC(CreateGraphicsPipelines);
+ GET_DEV_PROC(CreateComputePipelines);
+ GET_DEV_PROC(DestroyPipeline);
+ GET_DEV_PROC(CreatePipelineLayout);
+ GET_DEV_PROC(DestroyPipelineLayout);
+ GET_DEV_PROC(CreateSampler);
+ GET_DEV_PROC(DestroySampler);
+ GET_DEV_PROC(CreateDescriptorSetLayout);
+ GET_DEV_PROC(DestroyDescriptorSetLayout);
+ GET_DEV_PROC(CreateDescriptorPool);
+ GET_DEV_PROC(DestroyDescriptorPool);
+ GET_DEV_PROC(ResetDescriptorPool);
+ GET_DEV_PROC(AllocateDescriptorSets);
+ GET_DEV_PROC(FreeDescriptorSets);
+ GET_DEV_PROC(UpdateDescriptorSets);
+ GET_DEV_PROC(CreateFramebuffer);
+ GET_DEV_PROC(DestroyFramebuffer);
+ GET_DEV_PROC(CreateRenderPass);
+ GET_DEV_PROC(DestroyRenderPass);
+ GET_DEV_PROC(GetRenderAreaGranularity);
+ GET_DEV_PROC(CreateCommandPool);
+ GET_DEV_PROC(DestroyCommandPool);
+ GET_DEV_PROC(ResetCommandPool);
+ GET_DEV_PROC(AllocateCommandBuffers);
+ GET_DEV_PROC(FreeCommandBuffers);
+ GET_DEV_PROC(BeginCommandBuffer);
+ GET_DEV_PROC(EndCommandBuffer);
+ GET_DEV_PROC(ResetCommandBuffer);
+ GET_DEV_PROC(CmdBindPipeline);
+ GET_DEV_PROC(CmdSetViewport);
+ GET_DEV_PROC(CmdSetScissor);
+ GET_DEV_PROC(CmdSetLineWidth);
+ GET_DEV_PROC(CmdSetDepthBias);
+ GET_DEV_PROC(CmdSetBlendConstants);
+ GET_DEV_PROC(CmdSetDepthBounds);
+ GET_DEV_PROC(CmdSetStencilCompareMask);
+ GET_DEV_PROC(CmdSetStencilWriteMask);
+ GET_DEV_PROC(CmdSetStencilReference);
+ GET_DEV_PROC(CmdBindDescriptorSets);
+ GET_DEV_PROC(CmdBindIndexBuffer);
+ GET_DEV_PROC(CmdBindVertexBuffers);
+ GET_DEV_PROC(CmdDraw);
+ GET_DEV_PROC(CmdDrawIndexed);
+ GET_DEV_PROC(CmdDrawIndirect);
+ GET_DEV_PROC(CmdDrawIndexedIndirect);
+ GET_DEV_PROC(CmdDispatch);
+ GET_DEV_PROC(CmdDispatchIndirect);
+ GET_DEV_PROC(CmdCopyBuffer);
+ GET_DEV_PROC(CmdCopyImage);
+ GET_DEV_PROC(CmdBlitImage);
+ GET_DEV_PROC(CmdCopyBufferToImage);
+ GET_DEV_PROC(CmdCopyImageToBuffer);
+ GET_DEV_PROC(CmdUpdateBuffer);
+ GET_DEV_PROC(CmdFillBuffer);
+ GET_DEV_PROC(CmdClearColorImage);
+ GET_DEV_PROC(CmdClearDepthStencilImage);
+ GET_DEV_PROC(CmdClearAttachments);
+ GET_DEV_PROC(CmdResolveImage);
+ GET_DEV_PROC(CmdSetEvent);
+ GET_DEV_PROC(CmdResetEvent);
+ GET_DEV_PROC(CmdWaitEvents);
+ GET_DEV_PROC(CmdPipelineBarrier);
+ GET_DEV_PROC(CmdBeginQuery);
+ GET_DEV_PROC(CmdEndQuery);
+ GET_DEV_PROC(CmdResetQueryPool);
+ GET_DEV_PROC(CmdWriteTimestamp);
+ GET_DEV_PROC(CmdCopyQueryPoolResults);
+ GET_DEV_PROC(CmdPushConstants);
+ GET_DEV_PROC(CmdBeginRenderPass);
+ 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_PROC(CreateSwapchainKHR);
- GET_PROC(DestroySwapchainKHR);
- GET_PROC(GetSwapchainImagesKHR);
- GET_PROC(AcquireNextImageKHR);
- GET_PROC(QueuePresentKHR);
+ 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);
@@ -186,7 +189,7 @@ const GrVkInterface* GrVkCreateInterface(VkInstance instance) {
GET_PROC(CreateDisplayModeKHR);
GET_PROC(GetDisplayPlaneCapabilitiesKHR);
GET_PROC(CreateDisplayPlaneSurfaceKHR);
- GET_PROC(CreateSharedSwapchainsKHR);
+ GET_DEV_PROC(CreateSharedSwapchainsKHR);
if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) {
GET_PROC(CreateDebugReportCallbackEXT);
diff --git a/src/gpu/vk/GrVkUniformHandler.h b/src/gpu/vk/GrVkUniformHandler.h
index f84bcff0a2..37bde339c4 100644
--- a/src/gpu/vk/GrVkUniformHandler.h
+++ b/src/gpu/vk/GrVkUniformHandler.h
@@ -13,10 +13,10 @@
#include "GrAllocator.h"
#include "glsl/GrGLSLShaderVar.h"
-static const int kUniformsPerBlock = 8;
-
class GrVkUniformHandler : public GrGLSLUniformHandler {
public:
+ static const int kUniformsPerBlock = 8;
+
enum {
kSamplerDescSet = 0,
kUniformBufferDescSet = 1,
@@ -82,4 +82,4 @@ private:
typedef GrGLSLUniformHandler INHERITED;
};
-#endif \ No newline at end of file
+#endif