blob: 6cbb9d09798ac5ed109ef998639db5015f174a2f [file] [log] [blame]
Chia-I Wu214dac62014-08-05 11:07:40 +08001/*
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 Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu214dac62014-08-05 11:07:40 +080026 */
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 Wud8965932014-10-13 13:32:37 +080035#include "kmd/winsys.h"
Chia-I Wuec841722014-08-25 22:36:01 +080036#include "queue.h"
Chia-I Wu214dac62014-08-05 11:07:40 +080037#include "gpu.h"
Chia-I Wu1db76e02014-09-15 14:21:14 +080038#include "wsi_x11.h"
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070039#include "xglIcd.h"
Chia-I Wu1db76e02014-09-15 14:21:14 +080040
41static struct intel_gpu *intel_gpus;
42
Chia-I Wu1076a872015-01-18 16:02:55 +080043static const char * const intel_gpu_exts[INTEL_EXT_COUNT] = {
Chia-I Wu1db76e02014-09-15 14:21:14 +080044#ifdef ENABLE_WSI_X11
45 [INTEL_EXT_WSI_X11] = "XGL_WSI_X11",
46#endif
47};
Chia-I Wu214dac62014-08-05 11:07:40 +080048
Chia-I Wuf07865e2014-09-15 13:52:21 +080049static int gpu_open_primary_node(struct intel_gpu *gpu)
50{
51 /* cannot not open gpu->primary_node directly */
52 return gpu->primary_fd_internal;
53}
54
55static void gpu_close_primary_node(struct intel_gpu *gpu)
56{
Chia-I Wu1db76e02014-09-15 14:21:14 +080057 if (gpu->primary_fd_internal >= 0)
Chia-I Wuf07865e2014-09-15 13:52:21 +080058 gpu->primary_fd_internal = -1;
Chia-I Wuf07865e2014-09-15 13:52:21 +080059}
60
61static int gpu_open_render_node(struct intel_gpu *gpu)
62{
63 if (gpu->render_fd_internal < 0 && gpu->render_node) {
64 gpu->render_fd_internal = open(gpu->render_node, O_RDWR);
65 if (gpu->render_fd_internal < 0) {
66 icd_log(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0,
67 0, "failed to open %s", gpu->render_node);
68 }
69 }
70
71 return gpu->render_fd_internal;
72}
73
74static void gpu_close_render_node(struct intel_gpu *gpu)
75{
76 if (gpu->render_fd_internal >= 0) {
77 close(gpu->render_fd_internal);
78 gpu->render_fd_internal = -1;
79 }
80}
81
Chia-I Wu214dac62014-08-05 11:07:40 +080082static const char *gpu_get_name(const struct intel_gpu *gpu)
83{
84 const char *name = NULL;
85
86 if (gen_is_hsw(gpu->devid)) {
87 if (gen_is_desktop(gpu->devid))
88 name = "Intel(R) Haswell Desktop";
89 else if (gen_is_mobile(gpu->devid))
90 name = "Intel(R) Haswell Mobile";
91 else if (gen_is_server(gpu->devid))
92 name = "Intel(R) Haswell Server";
93 }
94 else if (gen_is_ivb(gpu->devid)) {
95 if (gen_is_desktop(gpu->devid))
96 name = "Intel(R) Ivybridge Desktop";
97 else if (gen_is_mobile(gpu->devid))
98 name = "Intel(R) Ivybridge Mobile";
99 else if (gen_is_server(gpu->devid))
100 name = "Intel(R) Ivybridge Server";
101 }
102 else if (gen_is_snb(gpu->devid)) {
103 if (gen_is_desktop(gpu->devid))
104 name = "Intel(R) Sandybridge Desktop";
105 else if (gen_is_mobile(gpu->devid))
106 name = "Intel(R) Sandybridge Mobile";
107 else if (gen_is_server(gpu->devid))
108 name = "Intel(R) Sandybridge Server";
109 }
110
111 if (!name)
112 name = "Unknown Intel Chipset";
113
114 return name;
115}
116
Chia-I Wuf07865e2014-09-15 13:52:21 +0800117static struct intel_gpu *gpu_create(int gen, int devid,
118 const char *primary_node,
119 const char *render_node)
Chia-I Wu214dac62014-08-05 11:07:40 +0800120{
121 struct intel_gpu *gpu;
Chia-I Wuf07865e2014-09-15 13:52:21 +0800122 size_t primary_len, render_len;
Chia-I Wu214dac62014-08-05 11:07:40 +0800123
124 gpu = icd_alloc(sizeof(*gpu), 0, XGL_SYSTEM_ALLOC_API_OBJECT);
125 if (!gpu)
126 return NULL;
127
128 memset(gpu, 0, sizeof(*gpu));
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -0700129 set_loader_magic_value(gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800130
Chia-I Wu214dac62014-08-05 11:07:40 +0800131 gpu->devid = devid;
132
Chia-I Wuf07865e2014-09-15 13:52:21 +0800133 primary_len = strlen(primary_node);
134 render_len = (render_node) ? strlen(render_node) : 0;
135
136 gpu->primary_node = icd_alloc(primary_len + 1 +
137 ((render_len) ? (render_len + 1) : 0), 0, XGL_SYSTEM_ALLOC_INTERNAL);
138 if (!gpu->primary_node) {
Chia-I Wu214dac62014-08-05 11:07:40 +0800139 icd_free(gpu);
140 return NULL;
141 }
Chia-I Wuf07865e2014-09-15 13:52:21 +0800142
143 memcpy(gpu->primary_node, primary_node, primary_len + 1);
144
145 if (render_node) {
146 gpu->render_node = gpu->primary_node + primary_len + 1;
147 memcpy(gpu->render_node, render_node, render_len + 1);
148 }
Chia-I Wu214dac62014-08-05 11:07:40 +0800149
150 gpu->gen_opaque = gen;
151
Chia-I Wu960f1952014-08-28 23:27:10 +0800152 switch (intel_gpu_gen(gpu)) {
153 case INTEL_GEN(7.5):
154 gpu->gt = gen_get_hsw_gt(devid);
155 break;
156 case INTEL_GEN(7):
157 gpu->gt = gen_get_ivb_gt(devid);
158 break;
159 case INTEL_GEN(6):
160 gpu->gt = gen_get_snb_gt(devid);
161 break;
162 }
163
Mike Stroyan9fca7122015-02-09 13:08:26 -0700164 /* 150K dwords */
165 gpu->max_batch_buffer_size = sizeof(uint32_t) * 150*1024;
Chia-I Wud6109bb2014-08-21 09:12:19 +0800166
167 /* the winsys is prepared for one reloc every two dwords, then minus 2 */
168 gpu->batch_buffer_reloc_count =
169 gpu->max_batch_buffer_size / sizeof(uint32_t) / 2 - 2;
Chia-I Wu214dac62014-08-05 11:07:40 +0800170
Chia-I Wuf07865e2014-09-15 13:52:21 +0800171 gpu->primary_fd_internal = -1;
172 gpu->render_fd_internal = -1;
173
Chia-I Wu214dac62014-08-05 11:07:40 +0800174 return gpu;
175}
176
177static void gpu_destroy(struct intel_gpu *gpu)
178{
Chia-I Wuf07865e2014-09-15 13:52:21 +0800179 intel_gpu_close(gpu);
Chia-I Wu1db76e02014-09-15 14:21:14 +0800180
181#ifdef ENABLE_WSI_X11
182 if (gpu->x11)
183 intel_wsi_x11_destroy(gpu->x11);
184#endif
185
Chia-I Wuf07865e2014-09-15 13:52:21 +0800186 icd_free(gpu->primary_node);
Chia-I Wu214dac62014-08-05 11:07:40 +0800187 icd_free(gpu);
188}
189
Chia-I Wu214dac62014-08-05 11:07:40 +0800190/**
191 * Return true if \p gpu is a valid intel_gpu.
192 */
193bool intel_gpu_is_valid(const struct intel_gpu *gpu)
194{
195 const struct intel_gpu *iter = intel_gpus;
196
197 while (iter) {
198 if (iter == gpu)
199 return true;
200 iter = iter->next;
201 }
202
203 return false;
204}
205
206static int devid_to_gen(int devid)
207{
208 int gen;
209
210 if (gen_is_hsw(devid))
211 gen = INTEL_GEN(7.5);
212 else if (gen_is_ivb(devid))
213 gen = INTEL_GEN(7);
214 else if (gen_is_snb(devid))
215 gen = INTEL_GEN(6);
216 else
217 gen = -1;
218
Chia-I Wubfce58e2014-08-28 23:23:33 +0800219#ifdef INTEL_GEN_SPECIALIZED
220 if (gen != INTEL_GEN(INTEL_GEN_SPECIALIZED))
221 gen = -1;
222#endif
223
Chia-I Wu214dac62014-08-05 11:07:40 +0800224 return gen;
225}
226
Chia-I Wuf07865e2014-09-15 13:52:21 +0800227XGL_RESULT intel_gpu_add(int devid, const char *primary_node,
228 const char *render_node, struct intel_gpu **gpu_ret)
Chia-I Wu214dac62014-08-05 11:07:40 +0800229{
230 const int gen = devid_to_gen(devid);
231 struct intel_gpu *gpu;
232
233 if (gen < 0) {
234 icd_log(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, XGL_NULL_HANDLE,
235 0, 0, "unsupported device id 0x%04x", devid);
236 return XGL_ERROR_INITIALIZATION_FAILED;
237 }
238
Chia-I Wuf07865e2014-09-15 13:52:21 +0800239 gpu = gpu_create(gen, devid, primary_node, render_node);
Chia-I Wu214dac62014-08-05 11:07:40 +0800240 if (!gpu)
241 return XGL_ERROR_OUT_OF_MEMORY;
242
243 gpu->next = intel_gpus;
244 intel_gpus = gpu;
245
246 *gpu_ret = gpu;
247
248 return XGL_SUCCESS;
249}
250
251void intel_gpu_remove_all(void)
252{
253 struct intel_gpu *gpu = intel_gpus;
254
255 while (gpu) {
256 struct intel_gpu *next = gpu->next;
257
258 gpu_destroy(gpu);
259 gpu = next;
260 }
261
262 intel_gpus = NULL;
263}
264
265struct intel_gpu *intel_gpu_get_list(void)
266{
267 return intel_gpus;
268}
269
270void intel_gpu_get_props(const struct intel_gpu *gpu,
271 XGL_PHYSICAL_GPU_PROPERTIES *props)
272{
273 const char *name;
274 size_t name_len;
275
Chia-I Wu214dac62014-08-05 11:07:40 +0800276 props->apiVersion = INTEL_API_VERSION;
277 props->driverVersion = INTEL_DRIVER_VERSION;
278
279 props->vendorId = 0x8086;
280 props->deviceId = gpu->devid;
281
282 props->gpuType = XGL_GPU_TYPE_INTEGRATED;
283
284 /* copy GPU name */
285 name = gpu_get_name(gpu);
286 name_len = strlen(name);
287 if (name_len > sizeof(props->gpuName) - 1)
288 name_len = sizeof(props->gpuName) - 1;
289 memcpy(props->gpuName, name, name_len);
290 props->gpuName[name_len] = '\0';
291
Chia-I Wud6109bb2014-08-21 09:12:19 +0800292 props->maxMemRefsPerSubmission = gpu->batch_buffer_reloc_count;
Chia-I Wu214dac62014-08-05 11:07:40 +0800293
Chia-I Wu214dac62014-08-05 11:07:40 +0800294 /* no size limit, but no bounded buffer could exceed 2GB */
295 props->maxInlineMemoryUpdateSize = 2u << 30;
296
297 props->maxBoundDescriptorSets = 1;
298 props->maxThreadGroupSize = 512;
299
300 /* incremented every 80ns */
301 props->timestampFrequency = 1000 * 1000 * 1000 / 80;
302
303 props->multiColorAttachmentClears = false;
304}
305
306void intel_gpu_get_perf(const struct intel_gpu *gpu,
307 XGL_PHYSICAL_GPU_PERFORMANCE *perf)
308{
309 /* TODO */
310 perf->maxGpuClock = 1.0f;
311 perf->aluPerClock = 1.0f;
312 perf->texPerClock = 1.0f;
313 perf->primsPerClock = 1.0f;
314 perf->pixelsPerClock = 1.0f;
315}
316
317void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
318 enum intel_gpu_engine_type engine,
319 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *props)
320{
Chia-I Wu214dac62014-08-05 11:07:40 +0800321 switch (engine) {
322 case INTEL_GPU_ENGINE_3D:
323 props->queueFlags = XGL_QUEUE_GRAPHICS_BIT | XGL_QUEUE_COMPUTE_BIT;
324 props->queueCount = 1;
Chia-I Wuec841722014-08-25 22:36:01 +0800325 props->maxAtomicCounters = INTEL_QUEUE_ATOMIC_COUNTER_COUNT;
Chia-I Wu214dac62014-08-05 11:07:40 +0800326 props->supportsTimestamps = true;
327 break;
328 default:
329 assert(!"unknown engine type");
330 return;
331 }
332}
333
334void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
335 XGL_PHYSICAL_GPU_MEMORY_PROPERTIES *props)
336{
Chia-I Wu214dac62014-08-05 11:07:40 +0800337 props->supportsMigration = false;
338
Chia-I Wu54c0c4b2014-08-06 13:48:25 +0800339 /* no winsys support for DRM_I915_GEM_USERPTR yet */
340 props->supportsPinning = false;
Chia-I Wu214dac62014-08-05 11:07:40 +0800341}
342
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800343int intel_gpu_get_max_threads(const struct intel_gpu *gpu,
344 XGL_PIPELINE_SHADER_STAGE stage)
345{
346 switch (intel_gpu_gen(gpu)) {
347 case INTEL_GEN(7.5):
348 switch (stage) {
349 case XGL_SHADER_STAGE_VERTEX:
350 return (gpu->gt >= 2) ? 280 : 70;
351 case XGL_SHADER_STAGE_FRAGMENT:
352 return (gpu->gt == 3) ? 408 :
353 (gpu->gt == 2) ? 204 : 102;
354 default:
355 break;
356 }
357 break;
358 case INTEL_GEN(7):
359 switch (stage) {
360 case XGL_SHADER_STAGE_VERTEX:
361 return (gpu->gt == 2) ? 128 : 36;
362 case XGL_SHADER_STAGE_FRAGMENT:
363 return (gpu->gt == 2) ? 172 : 48;
364 default:
365 break;
366 }
367 break;
368 case INTEL_GEN(6):
369 switch (stage) {
370 case XGL_SHADER_STAGE_VERTEX:
371 return (gpu->gt == 2) ? 60 : 24;
372 case XGL_SHADER_STAGE_FRAGMENT:
373 return (gpu->gt == 2) ? 80 : 40;
374 default:
375 break;
376 }
377 break;
378 default:
379 break;
380 }
381
382 icd_log(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, XGL_NULL_HANDLE,
383 0, 0, "unknown Gen or shader stage");
384
385 switch (stage) {
386 case XGL_SHADER_STAGE_VERTEX:
387 return 1;
388 case XGL_SHADER_STAGE_FRAGMENT:
389 return 4;
390 default:
391 return 1;
392 }
393}
394
Chia-I Wu1db76e02014-09-15 14:21:14 +0800395void intel_gpu_associate_x11(struct intel_gpu *gpu,
396 struct intel_wsi_x11 *x11,
397 int fd)
398{
399#ifdef ENABLE_WSI_X11
400 gpu->x11 = x11;
401 gpu->primary_fd_internal = fd;
402#endif
403}
404
Chia-I Wu214dac62014-08-05 11:07:40 +0800405XGL_RESULT intel_gpu_open(struct intel_gpu *gpu)
406{
Chia-I Wud8965932014-10-13 13:32:37 +0800407 int fd;
Chia-I Wu214dac62014-08-05 11:07:40 +0800408
Chia-I Wud8965932014-10-13 13:32:37 +0800409 assert(!gpu->winsys);
410
411 fd = gpu_open_primary_node(gpu);
412 if (fd < 0)
413 fd = gpu_open_render_node(gpu);
414 if (fd < 0)
415 return XGL_ERROR_UNKNOWN;
416
417 gpu->winsys = intel_winsys_create_for_fd(fd);
418 if (!gpu->winsys) {
419 icd_log(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, XGL_NULL_HANDLE,
420 0, 0, "failed to create GPU winsys");
421 intel_gpu_close(gpu);
422 return XGL_ERROR_UNKNOWN;
423 }
424
425 return XGL_SUCCESS;
Chia-I Wu214dac62014-08-05 11:07:40 +0800426}
427
428void intel_gpu_close(struct intel_gpu *gpu)
429{
Chia-I Wud8965932014-10-13 13:32:37 +0800430 if (gpu->winsys) {
431 intel_winsys_destroy(gpu->winsys);
432 gpu->winsys = NULL;
433 }
434
Chia-I Wuf07865e2014-09-15 13:52:21 +0800435 gpu_close_primary_node(gpu);
436 gpu_close_render_node(gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800437}
438
Chia-I Wu1db76e02014-09-15 14:21:14 +0800439enum intel_ext_type intel_gpu_lookup_extension(const struct intel_gpu *gpu,
440 const char *ext)
Chia-I Wu214dac62014-08-05 11:07:40 +0800441{
Chia-I Wu1db76e02014-09-15 14:21:14 +0800442 enum intel_ext_type type;
443
444 for (type = 0; type < ARRAY_SIZE(intel_gpu_exts); type++) {
445 if (intel_gpu_exts[type] && strcmp(intel_gpu_exts[type], ext) == 0)
446 break;
447 }
448
449 assert(type < INTEL_EXT_COUNT || type == INTEL_EXT_INVALID);
450
451 return type;
Chia-I Wu214dac62014-08-05 11:07:40 +0800452}
Chia-I Wubec90a02014-08-06 12:33:03 +0800453
Chia-I Wu96177272015-01-03 15:27:41 +0800454ICD_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(
Chia-I Wubec90a02014-08-06 12:33:03 +0800455 XGL_PHYSICAL_GPU gpu_,
456 XGL_PHYSICAL_GPU_INFO_TYPE infoType,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600457 size_t* pDataSize,
458 void* pData)
Chia-I Wubec90a02014-08-06 12:33:03 +0800459{
460 const struct intel_gpu *gpu = intel_gpu(gpu_);
461 XGL_RESULT ret = XGL_SUCCESS;
462
463 switch (infoType) {
464 case XGL_INFO_TYPE_PHYSICAL_GPU_PROPERTIES:
Chia-I Wubec90a02014-08-06 12:33:03 +0800465 *pDataSize = sizeof(XGL_PHYSICAL_GPU_PROPERTIES);
Jon Ashburn408daec2014-12-05 09:23:52 -0700466 if (pData == NULL) {
467 return ret;
468 }
Chia-I Wubec90a02014-08-06 12:33:03 +0800469 intel_gpu_get_props(gpu, pData);
470 break;
471
472 case XGL_INFO_TYPE_PHYSICAL_GPU_PERFORMANCE:
Chia-I Wubec90a02014-08-06 12:33:03 +0800473 *pDataSize = sizeof(XGL_PHYSICAL_GPU_PERFORMANCE);
Jon Ashburn408daec2014-12-05 09:23:52 -0700474 if (pData == NULL) {
475 return ret;
476 }
Chia-I Wubec90a02014-08-06 12:33:03 +0800477 intel_gpu_get_perf(gpu, pData);
478 break;
479
480 case XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES:
481 /*
482 * XGL Programmers guide, page 33:
483 * to determine the data size an application calls
484 * xglGetGpuInfo() with a NULL data pointer. The
485 * expected data size for all queue property structures
486 * is returned in pDataSize
487 */
488 *pDataSize = sizeof(XGL_PHYSICAL_GPU_QUEUE_PROPERTIES) *
489 INTEL_GPU_ENGINE_COUNT;
490 if (pData != NULL) {
491 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *dst = pData;
492 int engine;
493
494 for (engine = 0; engine < INTEL_GPU_ENGINE_COUNT; engine++) {
495 intel_gpu_get_queue_props(gpu, engine, dst);
496 dst++;
497 }
498 }
499 break;
500
501 case XGL_INFO_TYPE_PHYSICAL_GPU_MEMORY_PROPERTIES:
Chia-I Wubec90a02014-08-06 12:33:03 +0800502 *pDataSize = sizeof(XGL_PHYSICAL_GPU_MEMORY_PROPERTIES);
Jon Ashburn408daec2014-12-05 09:23:52 -0700503 if (pData == NULL) {
504 return ret;
505 }
Chia-I Wubec90a02014-08-06 12:33:03 +0800506 intel_gpu_get_memory_props(gpu, pData);
507 break;
508
509 default:
510 ret = XGL_ERROR_INVALID_VALUE;
511 }
512
513 return ret;
514}
515
Chia-I Wu96177272015-01-03 15:27:41 +0800516ICD_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(
Chia-I Wubec90a02014-08-06 12:33:03 +0800517 XGL_PHYSICAL_GPU gpu_,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600518 const char* pExtName)
Chia-I Wubec90a02014-08-06 12:33:03 +0800519{
520 struct intel_gpu *gpu = intel_gpu(gpu_);
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800521 const enum intel_ext_type ext = intel_gpu_lookup_extension(gpu, pExtName);
Chia-I Wubec90a02014-08-06 12:33:03 +0800522
Chia-I Wu1db76e02014-09-15 14:21:14 +0800523 return (ext != INTEL_EXT_INVALID) ?
Chia-I Wubec90a02014-08-06 12:33:03 +0800524 XGL_SUCCESS : XGL_ERROR_INVALID_EXTENSION;
525}
Chia-I Wu251e7d92014-08-19 13:35:42 +0800526
Chia-I Wu96177272015-01-03 15:27:41 +0800527ICD_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(
Chia-I Wu452f5e82014-08-31 12:39:05 +0800528 XGL_PHYSICAL_GPU gpu0_,
529 XGL_PHYSICAL_GPU gpu1_,
Chia-I Wu251e7d92014-08-19 13:35:42 +0800530 XGL_GPU_COMPATIBILITY_INFO* pInfo)
531{
Chia-I Wu452f5e82014-08-31 12:39:05 +0800532 const struct intel_gpu *gpu0 = intel_gpu(gpu0_);
533 const struct intel_gpu *gpu1 = intel_gpu(gpu1_);
534 XGL_FLAGS compat = XGL_GPU_COMPAT_IQ_MATCH_BIT |
535 XGL_GPU_COMPAT_PEER_TRANSFER_BIT |
536 XGL_GPU_COMPAT_SHARED_MEMORY_BIT |
537 XGL_GPU_COMPAT_SHARED_GPU0_DISPLAY_BIT |
538 XGL_GPU_COMPAT_SHARED_GPU1_DISPLAY_BIT;
539
540 if (intel_gpu_gen(gpu0) == intel_gpu_gen(gpu1))
541 compat |= XGL_GPU_COMPAT_ASIC_FEATURES_BIT;
542
543 pInfo->compatibilityFlags = compat;
544
545 return XGL_SUCCESS;
Chia-I Wu251e7d92014-08-19 13:35:42 +0800546}