• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
dri2_query_renderer_integer(__DRIscreen * _screen,int param,unsigned int * value)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    case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
59       value[0] =
60          screen->base.screen->get_param(screen->base.screen,
61                                         PIPE_CAP_CONTEXT_PRIORITY_MASK);
62       if (!value[0])
63          return -1;
64       return 0;
65    default:
66       return driQueryRendererIntegerCommon(_screen, param, value);
67    }
68 }
69 
70 static int
dri2_query_renderer_string(__DRIscreen * _screen,int param,const char ** value)71 dri2_query_renderer_string(__DRIscreen *_screen, int param,
72                            const char **value)
73 {
74    struct dri_screen *screen = dri_screen(_screen);
75 
76    switch (param) {
77    case __DRI2_RENDERER_VENDOR_ID:
78       value[0] = screen->base.screen->get_vendor(screen->base.screen);
79       return 0;
80    case __DRI2_RENDERER_DEVICE_ID:
81       value[0] = screen->base.screen->get_name(screen->base.screen);
82       return 0;
83    default:
84       return -1;
85    }
86 }
87 
88 const __DRI2rendererQueryExtension dri2RendererQueryExtension = {
89     .base = { __DRI2_RENDERER_QUERY, 1 },
90 
91     .queryInteger         = dri2_query_renderer_integer,
92     .queryString          = dri2_query_renderer_string
93 };
94