1 #include "dri_query_renderer.h"
2 
3 #include "util/u_inlines.h"
4 #include "state_tracker/drm_driver.h"
5 
6 #include "utils.h"
7 #include "dri_screen.h"
8 #include "dri_query_renderer.h"
9 
10 static int
11 dri2_query_renderer_integer(__DRIscreen *_screen, int param,
12                             unsigned int *value)
13 {
14    struct dri_screen *screen = dri_screen(_screen);
15 
16    switch (param) {
17    case __DRI2_RENDERER_VENDOR_ID:
18       value[0] =
19          (unsigned int)screen->base.screen->get_param(screen->base.screen,
20                                                       PIPE_CAP_VENDOR_ID);
21       return 0;
22    case __DRI2_RENDERER_DEVICE_ID:
23       value[0] =
24          (unsigned int)screen->base.screen->get_param(screen->base.screen,
25                                                       PIPE_CAP_DEVICE_ID);
26       return 0;
27    case __DRI2_RENDERER_ACCELERATED:
28       value[0] =
29          (unsigned int)screen->base.screen->get_param(screen->base.screen,
30                                                       PIPE_CAP_ACCELERATED);
31       return 0;
32 
33    case __DRI2_RENDERER_VIDEO_MEMORY:
34       value[0] =
35          (unsigned int)screen->base.screen->get_param(screen->base.screen,
36                                                       PIPE_CAP_VIDEO_MEMORY);
37       return 0;
38 
39    case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
40       value[0] =
41          (unsigned int)screen->base.screen->get_param(screen->base.screen,
42                                                       PIPE_CAP_UMA);
43       return 0;
44 
45    case __DRI2_RENDERER_HAS_TEXTURE_3D:
46       value[0] =
47          screen->base.screen->get_param(screen->base.screen,
48                                         PIPE_CAP_MAX_TEXTURE_3D_LEVELS) != 0;
49       return 0;
50 
51    case __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB:
52       value[0] =
53          screen->base.screen->is_format_supported(screen->base.screen,
54                                                   PIPE_FORMAT_B8G8R8A8_SRGB,
55                                                   PIPE_TEXTURE_2D, 0,
56                                                   PIPE_BIND_RENDER_TARGET);
57       return 0;
58 
59    default:
60       return driQueryRendererIntegerCommon(_screen, param, value);
61    }
62 }
63 
64 static int
65 dri2_query_renderer_string(__DRIscreen *_screen, int param,
66                            const char **value)
67 {
68    struct dri_screen *screen = dri_screen(_screen);
69 
70    switch (param) {
71    case __DRI2_RENDERER_VENDOR_ID:
72       value[0] = screen->base.screen->get_vendor(screen->base.screen);
73       return 0;
74    case __DRI2_RENDERER_DEVICE_ID:
75       value[0] = screen->base.screen->get_name(screen->base.screen);
76       return 0;
77    default:
78       return -1;
79    }
80 }
81 
82 const __DRI2rendererQueryExtension dri2RendererQueryExtension = {
83     .base = { __DRI2_RENDERER_QUERY, 1 },
84 
85     .queryInteger         = dri2_query_renderer_integer,
86     .queryString          = dri2_query_renderer_string
87 };
88