Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | #include <sys/types.h> |
| 30 | #include <sys/stat.h> |
| 31 | #include <fcntl.h> |
| 32 | #include <unistd.h> |
| 33 | |
| 34 | #include "genhw/genhw.h" |
Chia-I Wu | de2bb86 | 2014-08-19 14:32:47 +0800 | [diff] [blame] | 35 | #include "dispatch.h" |
Chia-I Wu | ec84172 | 2014-08-25 22:36:01 +0800 | [diff] [blame] | 36 | #include "queue.h" |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 37 | #include "gpu.h" |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 38 | #include "wsi_x11.h" |
| 39 | |
| 40 | static struct intel_gpu *intel_gpus; |
| 41 | |
| 42 | static const char *intel_gpu_exts[INTEL_EXT_COUNT] = { |
| 43 | #ifdef ENABLE_WSI_X11 |
| 44 | [INTEL_EXT_WSI_X11] = "XGL_WSI_X11", |
| 45 | #endif |
| 46 | }; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 47 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 48 | static int gpu_open_primary_node(struct intel_gpu *gpu) |
| 49 | { |
| 50 | /* cannot not open gpu->primary_node directly */ |
| 51 | return gpu->primary_fd_internal; |
| 52 | } |
| 53 | |
| 54 | static void gpu_close_primary_node(struct intel_gpu *gpu) |
| 55 | { |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 56 | if (gpu->primary_fd_internal >= 0) |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 57 | gpu->primary_fd_internal = -1; |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static int gpu_open_render_node(struct intel_gpu *gpu) |
| 61 | { |
| 62 | if (gpu->render_fd_internal < 0 && gpu->render_node) { |
| 63 | gpu->render_fd_internal = open(gpu->render_node, O_RDWR); |
| 64 | if (gpu->render_fd_internal < 0) { |
| 65 | icd_log(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, |
| 66 | 0, "failed to open %s", gpu->render_node); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return gpu->render_fd_internal; |
| 71 | } |
| 72 | |
| 73 | static void gpu_close_render_node(struct intel_gpu *gpu) |
| 74 | { |
| 75 | if (gpu->render_fd_internal >= 0) { |
| 76 | close(gpu->render_fd_internal); |
| 77 | gpu->render_fd_internal = -1; |
| 78 | } |
| 79 | } |
| 80 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 81 | static const char *gpu_get_name(const struct intel_gpu *gpu) |
| 82 | { |
| 83 | const char *name = NULL; |
| 84 | |
| 85 | if (gen_is_hsw(gpu->devid)) { |
| 86 | if (gen_is_desktop(gpu->devid)) |
| 87 | name = "Intel(R) Haswell Desktop"; |
| 88 | else if (gen_is_mobile(gpu->devid)) |
| 89 | name = "Intel(R) Haswell Mobile"; |
| 90 | else if (gen_is_server(gpu->devid)) |
| 91 | name = "Intel(R) Haswell Server"; |
| 92 | } |
| 93 | else if (gen_is_ivb(gpu->devid)) { |
| 94 | if (gen_is_desktop(gpu->devid)) |
| 95 | name = "Intel(R) Ivybridge Desktop"; |
| 96 | else if (gen_is_mobile(gpu->devid)) |
| 97 | name = "Intel(R) Ivybridge Mobile"; |
| 98 | else if (gen_is_server(gpu->devid)) |
| 99 | name = "Intel(R) Ivybridge Server"; |
| 100 | } |
| 101 | else if (gen_is_snb(gpu->devid)) { |
| 102 | if (gen_is_desktop(gpu->devid)) |
| 103 | name = "Intel(R) Sandybridge Desktop"; |
| 104 | else if (gen_is_mobile(gpu->devid)) |
| 105 | name = "Intel(R) Sandybridge Mobile"; |
| 106 | else if (gen_is_server(gpu->devid)) |
| 107 | name = "Intel(R) Sandybridge Server"; |
| 108 | } |
| 109 | |
| 110 | if (!name) |
| 111 | name = "Unknown Intel Chipset"; |
| 112 | |
| 113 | return name; |
| 114 | } |
| 115 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 116 | static struct intel_gpu *gpu_create(int gen, int devid, |
| 117 | const char *primary_node, |
| 118 | const char *render_node) |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 119 | { |
| 120 | struct intel_gpu *gpu; |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 121 | size_t primary_len, render_len; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 122 | |
| 123 | gpu = icd_alloc(sizeof(*gpu), 0, XGL_SYSTEM_ALLOC_API_OBJECT); |
| 124 | if (!gpu) |
| 125 | return NULL; |
| 126 | |
| 127 | memset(gpu, 0, sizeof(*gpu)); |
| 128 | |
| 129 | /* debug layer is always enabled for intel_gpu */ |
Chia-I Wu | 6a42c2a | 2014-08-19 14:36:47 +0800 | [diff] [blame] | 130 | gpu->dispatch = intel_dispatch_get(true); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 131 | |
| 132 | gpu->devid = devid; |
| 133 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 134 | primary_len = strlen(primary_node); |
| 135 | render_len = (render_node) ? strlen(render_node) : 0; |
| 136 | |
| 137 | gpu->primary_node = icd_alloc(primary_len + 1 + |
| 138 | ((render_len) ? (render_len + 1) : 0), 0, XGL_SYSTEM_ALLOC_INTERNAL); |
| 139 | if (!gpu->primary_node) { |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 140 | icd_free(gpu); |
| 141 | return NULL; |
| 142 | } |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 143 | |
| 144 | memcpy(gpu->primary_node, primary_node, primary_len + 1); |
| 145 | |
| 146 | if (render_node) { |
| 147 | gpu->render_node = gpu->primary_node + primary_len + 1; |
| 148 | memcpy(gpu->render_node, render_node, render_len + 1); |
| 149 | } |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 150 | |
| 151 | gpu->gen_opaque = gen; |
| 152 | |
Chia-I Wu | 960f195 | 2014-08-28 23:27:10 +0800 | [diff] [blame] | 153 | switch (intel_gpu_gen(gpu)) { |
| 154 | case INTEL_GEN(7.5): |
| 155 | gpu->gt = gen_get_hsw_gt(devid); |
| 156 | break; |
| 157 | case INTEL_GEN(7): |
| 158 | gpu->gt = gen_get_ivb_gt(devid); |
| 159 | break; |
| 160 | case INTEL_GEN(6): |
| 161 | gpu->gt = gen_get_snb_gt(devid); |
| 162 | break; |
| 163 | } |
| 164 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 165 | /* 8192 dwords */ |
Chia-I Wu | d6109bb | 2014-08-21 09:12:19 +0800 | [diff] [blame] | 166 | gpu->max_batch_buffer_size = sizeof(uint32_t) * 8192; |
| 167 | |
| 168 | /* the winsys is prepared for one reloc every two dwords, then minus 2 */ |
| 169 | gpu->batch_buffer_reloc_count = |
| 170 | gpu->max_batch_buffer_size / sizeof(uint32_t) / 2 - 2; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 171 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 172 | gpu->primary_fd_internal = -1; |
| 173 | gpu->render_fd_internal = -1; |
| 174 | |
| 175 | gpu->device_fd = -1; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 176 | |
| 177 | return gpu; |
| 178 | } |
| 179 | |
| 180 | static void gpu_destroy(struct intel_gpu *gpu) |
| 181 | { |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 182 | intel_gpu_close(gpu); |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 183 | |
| 184 | #ifdef ENABLE_WSI_X11 |
| 185 | if (gpu->x11) |
| 186 | intel_wsi_x11_destroy(gpu->x11); |
| 187 | #endif |
| 188 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 189 | icd_free(gpu->primary_node); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 190 | icd_free(gpu); |
| 191 | } |
| 192 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 193 | /** |
| 194 | * Return true if \p gpu is a valid intel_gpu. |
| 195 | */ |
| 196 | bool intel_gpu_is_valid(const struct intel_gpu *gpu) |
| 197 | { |
| 198 | const struct intel_gpu *iter = intel_gpus; |
| 199 | |
| 200 | while (iter) { |
| 201 | if (iter == gpu) |
| 202 | return true; |
| 203 | iter = iter->next; |
| 204 | } |
| 205 | |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | static int devid_to_gen(int devid) |
| 210 | { |
| 211 | int gen; |
| 212 | |
| 213 | if (gen_is_hsw(devid)) |
| 214 | gen = INTEL_GEN(7.5); |
| 215 | else if (gen_is_ivb(devid)) |
| 216 | gen = INTEL_GEN(7); |
| 217 | else if (gen_is_snb(devid)) |
| 218 | gen = INTEL_GEN(6); |
| 219 | else |
| 220 | gen = -1; |
| 221 | |
Chia-I Wu | bfce58e | 2014-08-28 23:23:33 +0800 | [diff] [blame] | 222 | #ifdef INTEL_GEN_SPECIALIZED |
| 223 | if (gen != INTEL_GEN(INTEL_GEN_SPECIALIZED)) |
| 224 | gen = -1; |
| 225 | #endif |
| 226 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 227 | return gen; |
| 228 | } |
| 229 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 230 | XGL_RESULT intel_gpu_add(int devid, const char *primary_node, |
| 231 | const char *render_node, struct intel_gpu **gpu_ret) |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 232 | { |
| 233 | const int gen = devid_to_gen(devid); |
| 234 | struct intel_gpu *gpu; |
| 235 | |
| 236 | if (gen < 0) { |
| 237 | icd_log(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, XGL_NULL_HANDLE, |
| 238 | 0, 0, "unsupported device id 0x%04x", devid); |
| 239 | return XGL_ERROR_INITIALIZATION_FAILED; |
| 240 | } |
| 241 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 242 | gpu = gpu_create(gen, devid, primary_node, render_node); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 243 | if (!gpu) |
| 244 | return XGL_ERROR_OUT_OF_MEMORY; |
| 245 | |
| 246 | gpu->next = intel_gpus; |
| 247 | intel_gpus = gpu; |
| 248 | |
| 249 | *gpu_ret = gpu; |
| 250 | |
| 251 | return XGL_SUCCESS; |
| 252 | } |
| 253 | |
| 254 | void intel_gpu_remove_all(void) |
| 255 | { |
| 256 | struct intel_gpu *gpu = intel_gpus; |
| 257 | |
| 258 | while (gpu) { |
| 259 | struct intel_gpu *next = gpu->next; |
| 260 | |
| 261 | gpu_destroy(gpu); |
| 262 | gpu = next; |
| 263 | } |
| 264 | |
| 265 | intel_gpus = NULL; |
| 266 | } |
| 267 | |
| 268 | struct intel_gpu *intel_gpu_get_list(void) |
| 269 | { |
| 270 | return intel_gpus; |
| 271 | } |
| 272 | |
| 273 | void intel_gpu_get_props(const struct intel_gpu *gpu, |
| 274 | XGL_PHYSICAL_GPU_PROPERTIES *props) |
| 275 | { |
| 276 | const char *name; |
| 277 | size_t name_len; |
| 278 | |
| 279 | props->structSize = sizeof(*props); |
| 280 | |
| 281 | props->apiVersion = INTEL_API_VERSION; |
| 282 | props->driverVersion = INTEL_DRIVER_VERSION; |
| 283 | |
| 284 | props->vendorId = 0x8086; |
| 285 | props->deviceId = gpu->devid; |
| 286 | |
| 287 | props->gpuType = XGL_GPU_TYPE_INTEGRATED; |
| 288 | |
| 289 | /* copy GPU name */ |
| 290 | name = gpu_get_name(gpu); |
| 291 | name_len = strlen(name); |
| 292 | if (name_len > sizeof(props->gpuName) - 1) |
| 293 | name_len = sizeof(props->gpuName) - 1; |
| 294 | memcpy(props->gpuName, name, name_len); |
| 295 | props->gpuName[name_len] = '\0'; |
| 296 | |
Chia-I Wu | d6109bb | 2014-08-21 09:12:19 +0800 | [diff] [blame] | 297 | props->maxMemRefsPerSubmission = gpu->batch_buffer_reloc_count; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 298 | |
| 299 | props->virtualMemPageSize = 4096; |
| 300 | |
| 301 | /* no size limit, but no bounded buffer could exceed 2GB */ |
| 302 | props->maxInlineMemoryUpdateSize = 2u << 30; |
| 303 | |
| 304 | props->maxBoundDescriptorSets = 1; |
| 305 | props->maxThreadGroupSize = 512; |
| 306 | |
| 307 | /* incremented every 80ns */ |
| 308 | props->timestampFrequency = 1000 * 1000 * 1000 / 80; |
| 309 | |
| 310 | props->multiColorAttachmentClears = false; |
| 311 | } |
| 312 | |
| 313 | void intel_gpu_get_perf(const struct intel_gpu *gpu, |
| 314 | XGL_PHYSICAL_GPU_PERFORMANCE *perf) |
| 315 | { |
| 316 | /* TODO */ |
| 317 | perf->maxGpuClock = 1.0f; |
| 318 | perf->aluPerClock = 1.0f; |
| 319 | perf->texPerClock = 1.0f; |
| 320 | perf->primsPerClock = 1.0f; |
| 321 | perf->pixelsPerClock = 1.0f; |
| 322 | } |
| 323 | |
| 324 | void intel_gpu_get_queue_props(const struct intel_gpu *gpu, |
| 325 | enum intel_gpu_engine_type engine, |
| 326 | XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *props) |
| 327 | { |
| 328 | props->structSize = sizeof(*props); |
| 329 | |
| 330 | switch (engine) { |
| 331 | case INTEL_GPU_ENGINE_3D: |
| 332 | props->queueFlags = XGL_QUEUE_GRAPHICS_BIT | XGL_QUEUE_COMPUTE_BIT; |
| 333 | props->queueCount = 1; |
Chia-I Wu | ec84172 | 2014-08-25 22:36:01 +0800 | [diff] [blame] | 334 | props->maxAtomicCounters = INTEL_QUEUE_ATOMIC_COUNTER_COUNT; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 335 | props->supportsTimestamps = true; |
| 336 | break; |
| 337 | default: |
| 338 | assert(!"unknown engine type"); |
| 339 | return; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | void intel_gpu_get_memory_props(const struct intel_gpu *gpu, |
| 344 | XGL_PHYSICAL_GPU_MEMORY_PROPERTIES *props) |
| 345 | { |
| 346 | props->structSize = sizeof(*props); |
| 347 | |
| 348 | props->supportsMigration = false; |
| 349 | |
| 350 | /* no kernel support yet */ |
| 351 | props->supportsVirtualMemoryRemapping = false; |
| 352 | |
Chia-I Wu | 54c0c4b | 2014-08-06 13:48:25 +0800 | [diff] [blame] | 353 | /* no winsys support for DRM_I915_GEM_USERPTR yet */ |
| 354 | props->supportsPinning = false; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 355 | } |
| 356 | |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 357 | void intel_gpu_associate_x11(struct intel_gpu *gpu, |
| 358 | struct intel_wsi_x11 *x11, |
| 359 | int fd) |
| 360 | { |
| 361 | #ifdef ENABLE_WSI_X11 |
| 362 | gpu->x11 = x11; |
| 363 | gpu->primary_fd_internal = fd; |
| 364 | #endif |
| 365 | } |
| 366 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 367 | XGL_RESULT intel_gpu_open(struct intel_gpu *gpu) |
| 368 | { |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 369 | gpu->device_fd = gpu_open_primary_node(gpu); |
| 370 | if (gpu->device_fd < 0) |
| 371 | gpu->device_fd = gpu_open_render_node(gpu); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 372 | |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 373 | return (gpu->device_fd >= 0) ? XGL_SUCCESS : XGL_ERROR_UNKNOWN; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | void intel_gpu_close(struct intel_gpu *gpu) |
| 377 | { |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 378 | gpu_close_primary_node(gpu); |
| 379 | gpu_close_render_node(gpu); |
| 380 | gpu->device_fd = -1; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 381 | } |
| 382 | |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 383 | enum intel_ext_type intel_gpu_lookup_extension(const struct intel_gpu *gpu, |
| 384 | const char *ext) |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 385 | { |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 386 | enum intel_ext_type type; |
| 387 | |
| 388 | for (type = 0; type < ARRAY_SIZE(intel_gpu_exts); type++) { |
| 389 | if (intel_gpu_exts[type] && strcmp(intel_gpu_exts[type], ext) == 0) |
| 390 | break; |
| 391 | } |
| 392 | |
| 393 | assert(type < INTEL_EXT_COUNT || type == INTEL_EXT_INVALID); |
| 394 | |
| 395 | return type; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 396 | } |
Chia-I Wu | bec90a0 | 2014-08-06 12:33:03 +0800 | [diff] [blame] | 397 | |
| 398 | XGL_RESULT XGLAPI intelGetGpuInfo( |
| 399 | XGL_PHYSICAL_GPU gpu_, |
| 400 | XGL_PHYSICAL_GPU_INFO_TYPE infoType, |
| 401 | XGL_SIZE* pDataSize, |
| 402 | XGL_VOID* pData) |
| 403 | { |
| 404 | const struct intel_gpu *gpu = intel_gpu(gpu_); |
| 405 | XGL_RESULT ret = XGL_SUCCESS; |
| 406 | |
| 407 | switch (infoType) { |
| 408 | case XGL_INFO_TYPE_PHYSICAL_GPU_PROPERTIES: |
| 409 | if (pData == NULL) { |
| 410 | return XGL_ERROR_INVALID_POINTER; |
| 411 | } |
| 412 | *pDataSize = sizeof(XGL_PHYSICAL_GPU_PROPERTIES); |
| 413 | intel_gpu_get_props(gpu, pData); |
| 414 | break; |
| 415 | |
| 416 | case XGL_INFO_TYPE_PHYSICAL_GPU_PERFORMANCE: |
| 417 | if (pData == NULL) { |
| 418 | return XGL_ERROR_INVALID_POINTER; |
| 419 | } |
| 420 | *pDataSize = sizeof(XGL_PHYSICAL_GPU_PERFORMANCE); |
| 421 | intel_gpu_get_perf(gpu, pData); |
| 422 | break; |
| 423 | |
| 424 | case XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES: |
| 425 | /* |
| 426 | * XGL Programmers guide, page 33: |
| 427 | * to determine the data size an application calls |
| 428 | * xglGetGpuInfo() with a NULL data pointer. The |
| 429 | * expected data size for all queue property structures |
| 430 | * is returned in pDataSize |
| 431 | */ |
| 432 | *pDataSize = sizeof(XGL_PHYSICAL_GPU_QUEUE_PROPERTIES) * |
| 433 | INTEL_GPU_ENGINE_COUNT; |
| 434 | if (pData != NULL) { |
| 435 | XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *dst = pData; |
| 436 | int engine; |
| 437 | |
| 438 | for (engine = 0; engine < INTEL_GPU_ENGINE_COUNT; engine++) { |
| 439 | intel_gpu_get_queue_props(gpu, engine, dst); |
| 440 | dst++; |
| 441 | } |
| 442 | } |
| 443 | break; |
| 444 | |
| 445 | case XGL_INFO_TYPE_PHYSICAL_GPU_MEMORY_PROPERTIES: |
| 446 | if (pData == NULL) { |
| 447 | return XGL_ERROR_INVALID_POINTER; |
| 448 | } |
| 449 | *pDataSize = sizeof(XGL_PHYSICAL_GPU_MEMORY_PROPERTIES); |
| 450 | intel_gpu_get_memory_props(gpu, pData); |
| 451 | break; |
| 452 | |
| 453 | default: |
| 454 | ret = XGL_ERROR_INVALID_VALUE; |
| 455 | } |
| 456 | |
| 457 | return ret; |
| 458 | } |
| 459 | |
| 460 | XGL_RESULT XGLAPI intelGetExtensionSupport( |
| 461 | XGL_PHYSICAL_GPU gpu_, |
| 462 | const XGL_CHAR* pExtName) |
| 463 | { |
| 464 | struct intel_gpu *gpu = intel_gpu(gpu_); |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 465 | const enum intel_ext_type ext = intel_gpu_lookup_extension(gpu, |
| 466 | (const char *) pExtName); |
Chia-I Wu | bec90a0 | 2014-08-06 12:33:03 +0800 | [diff] [blame] | 467 | |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame^] | 468 | return (ext != INTEL_EXT_INVALID) ? |
Chia-I Wu | bec90a0 | 2014-08-06 12:33:03 +0800 | [diff] [blame] | 469 | XGL_SUCCESS : XGL_ERROR_INVALID_EXTENSION; |
| 470 | } |
Chia-I Wu | 251e7d9 | 2014-08-19 13:35:42 +0800 | [diff] [blame] | 471 | |
| 472 | XGL_RESULT XGLAPI intelGetMultiGpuCompatibility( |
Chia-I Wu | 452f5e8 | 2014-08-31 12:39:05 +0800 | [diff] [blame] | 473 | XGL_PHYSICAL_GPU gpu0_, |
| 474 | XGL_PHYSICAL_GPU gpu1_, |
Chia-I Wu | 251e7d9 | 2014-08-19 13:35:42 +0800 | [diff] [blame] | 475 | XGL_GPU_COMPATIBILITY_INFO* pInfo) |
| 476 | { |
Chia-I Wu | 452f5e8 | 2014-08-31 12:39:05 +0800 | [diff] [blame] | 477 | const struct intel_gpu *gpu0 = intel_gpu(gpu0_); |
| 478 | const struct intel_gpu *gpu1 = intel_gpu(gpu1_); |
| 479 | XGL_FLAGS compat = XGL_GPU_COMPAT_IQ_MATCH_BIT | |
| 480 | XGL_GPU_COMPAT_PEER_TRANSFER_BIT | |
| 481 | XGL_GPU_COMPAT_SHARED_MEMORY_BIT | |
| 482 | XGL_GPU_COMPAT_SHARED_GPU0_DISPLAY_BIT | |
| 483 | XGL_GPU_COMPAT_SHARED_GPU1_DISPLAY_BIT; |
| 484 | |
| 485 | if (intel_gpu_gen(gpu0) == intel_gpu_gen(gpu1)) |
| 486 | compat |= XGL_GPU_COMPAT_ASIC_FEATURES_BIT; |
| 487 | |
| 488 | pInfo->compatibilityFlags = compat; |
| 489 | |
| 490 | return XGL_SUCCESS; |
Chia-I Wu | 251e7d9 | 2014-08-19 13:35:42 +0800 | [diff] [blame] | 491 | } |