Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: src/gpu/vk/GrVkBackendContext.cpp

Issue 1834953003: got Vulkan compiling on Linux again (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed indentation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/vk/GrVkExtensions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "vk/GrVkBackendContext.h" 8 #include "vk/GrVkBackendContext.h"
9 #include "vk/GrVkExtensions.h" 9 #include "vk/GrVkExtensions.h"
10 #include "vk/GrVkInterface.h" 10 #include "vk/GrVkInterface.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 kGrVkMinimumVersion, // apiVersion 52 kGrVkMinimumVersion, // apiVersion
53 }; 53 };
54 54
55 GrVkExtensions extensions; 55 GrVkExtensions extensions;
56 extensions.initInstance(kGrVkMinimumVersion); 56 extensions.initInstance(kGrVkMinimumVersion);
57 57
58 SkTArray<const char*> instanceLayerNames; 58 SkTArray<const char*> instanceLayerNames;
59 SkTArray<const char*> instanceExtensionNames; 59 SkTArray<const char*> instanceExtensionNames;
60 uint32_t extensionFlags = 0; 60 uint32_t extensionFlags = 0;
61 #ifdef ENABLE_VK_LAYERS 61 #ifdef ENABLE_VK_LAYERS
62 for (int i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { 62 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) {
63 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) { 63 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) {
64 instanceLayerNames.push_back(kDebugLayerNames[i]); 64 instanceLayerNames.push_back(kDebugLayerNames[i]);
65 } 65 }
66 } 66 }
67 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { 67 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) {
68 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); 68 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
69 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag; 69 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag;
70 } 70 }
71 #endif 71 #endif
72 72
73 const VkInstanceCreateInfo instance_create = { 73 const VkInstanceCreateInfo instance_create = {
74 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType 74 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
75 nullptr, // pNext 75 nullptr, // pNext
76 0, // flags 76 0, // flags
77 &app_info, // pApplicationInfo 77 &app_info, // pApplicationInfo
78 instanceLayerNames.count(), // enabledLayerNameCount 78 (uint32_t) instanceLayerNames.count(), // enabledLayerNameCount
79 instanceLayerNames.begin(), // ppEnabledLayerNames 79 instanceLayerNames.begin(), // ppEnabledLayerNames
80 instanceExtensionNames.count(), // enabledExtensionNameCount 80 (uint32_t) instanceExtensionNames.count(), // enabledExtensionNameCount
81 instanceExtensionNames.begin(), // ppEnabledExtensionNames 81 instanceExtensionNames.begin(), // ppEnabledExtensionNames
82 }; 82 };
83 83
84 err = vkCreateInstance(&instance_create, nullptr, &inst); 84 err = vkCreateInstance(&instance_create, nullptr, &inst);
85 if (err < 0) { 85 if (err < 0) {
86 SkDebugf("vkCreateInstance failed: %d\n", err); 86 SkDebugf("vkCreateInstance failed: %d\n", err);
87 SkFAIL("failing"); 87 SkFAIL("failing");
88 } 88 }
89 89
90 uint32_t gpuCount; 90 uint32_t gpuCount;
91 err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr); 91 err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr);
(...skipping 30 matching lines...) Expand all
122 break; 122 break;
123 } 123 }
124 } 124 }
125 SkASSERT(graphicsQueueIndex < queueCount); 125 SkASSERT(graphicsQueueIndex < queueCount);
126 126
127 extensions.initDevice(kGrVkMinimumVersion, inst, physDev); 127 extensions.initDevice(kGrVkMinimumVersion, inst, physDev);
128 128
129 SkTArray<const char*> deviceLayerNames; 129 SkTArray<const char*> deviceLayerNames;
130 SkTArray<const char*> deviceExtensionNames; 130 SkTArray<const char*> deviceExtensionNames;
131 #ifdef ENABLE_VK_LAYERS 131 #ifdef ENABLE_VK_LAYERS
132 for (int i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { 132 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) {
133 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) { 133 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) {
134 deviceLayerNames.push_back(kDebugLayerNames[i]); 134 deviceLayerNames.push_back(kDebugLayerNames[i]);
135 } 135 }
136 } 136 }
137 #endif 137 #endif
138 if (extensions.hasDeviceExtension("VK_NV_glsl_shader")) { 138 if (extensions.hasDeviceExtension("VK_NV_glsl_shader")) {
139 deviceExtensionNames.push_back("VK_NV_glsl_shader"); 139 deviceExtensionNames.push_back("VK_NV_glsl_shader");
140 extensionFlags |= kNV_glsl_shader_GrVkExtensionFlag; 140 extensionFlags |= kNV_glsl_shader_GrVkExtensionFlag;
141 } 141 }
142 142
(...skipping 20 matching lines...) Expand all
163 // If one is needed, the client will need its own setup code 163 // If one is needed, the client will need its own setup code
164 const VkDeviceQueueCreateInfo queueInfo = { 164 const VkDeviceQueueCreateInfo queueInfo = {
165 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType 165 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
166 nullptr, // pNext 166 nullptr, // pNext
167 0, // VkDeviceQueueCreateFlags 167 0, // VkDeviceQueueCreateFlags
168 graphicsQueueIndex, // queueFamilyIndex 168 graphicsQueueIndex, // queueFamilyIndex
169 1, // queueCount 169 1, // queueCount
170 queuePriorities, // pQueuePriorities 170 queuePriorities, // pQueuePriorities
171 }; 171 };
172 const VkDeviceCreateInfo deviceInfo = { 172 const VkDeviceCreateInfo deviceInfo = {
173 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType 173 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
174 nullptr, // pNext 174 nullptr, // pNext
175 0, // VkDeviceCreateFlags 175 0, // VkDeviceCreateFlags
176 1, // queueCreateInfoCount 176 1, // queueCreateInfoCount
177 &queueInfo, // pQueueCreateInfos 177 &queueInfo, // pQueueCreateInfos
178 deviceLayerNames.count(), // layerCount 178 (uint32_t) deviceLayerNames.count(), // layerCount
179 deviceLayerNames.begin(), // ppEnabledLayerNames 179 deviceLayerNames.begin(), // ppEnabledLayerNames
180 deviceExtensionNames.count(), // extensionCount 180 (uint32_t) deviceExtensionNames.count(), // extensionCount
181 deviceExtensionNames.begin(), // ppEnabledExtensionNames 181 deviceExtensionNames.begin(), // ppEnabledExtensionNames
182 &deviceFeatures // ppEnabledFeatures 182 &deviceFeatures // ppEnabledFeatures
183 }; 183 };
184 184
185 err = vkCreateDevice(physDev, &deviceInfo, nullptr, &device); 185 err = vkCreateDevice(physDev, &deviceInfo, nullptr, &device);
186 if (err) { 186 if (err) {
187 SkDebugf("CreateDevice failed: %d\n", err); 187 SkDebugf("CreateDevice failed: %d\n", err);
188 return nullptr; 188 return nullptr;
189 } 189 }
190 190
191 VkQueue queue; 191 VkQueue queue;
192 vkGetDeviceQueue(device, graphicsQueueIndex, 0, &queue); 192 vkGetDeviceQueue(device, graphicsQueueIndex, 0, &queue);
(...skipping 11 matching lines...) Expand all
204 204
205 return ctx; 205 return ctx;
206 } 206 }
207 207
208 GrVkBackendContext::~GrVkBackendContext() { 208 GrVkBackendContext::~GrVkBackendContext() {
209 vkDestroyDevice(fDevice, nullptr); 209 vkDestroyDevice(fDevice, nullptr);
210 fDevice = VK_NULL_HANDLE; 210 fDevice = VK_NULL_HANDLE;
211 vkDestroyInstance(fInstance, nullptr); 211 vkDestroyInstance(fInstance, nullptr);
212 fInstance = VK_NULL_HANDLE; 212 fInstance = VK_NULL_HANDLE;
213 } 213 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/vk/GrVkExtensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698