• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "dri_query_renderer.h"
2 
3 #include "util/u_inlines.h"
4 #include "frontend/drm_driver.h"
5 
6 #include "utils.h"
7 #include "dri_screen.h"
8 #include "dri_query_renderer.h"
9 #include "pipe-loader/pipe_loader.h"
10 
11 static int
dri2_query_renderer_integer(__DRIscreen * _screen,int param,unsigned int * value)12 dri2_query_renderer_integer(__DRIscreen *_screen, int param,
13                             unsigned int *value)
14 {
15    struct dri_screen *screen = dri_screen(_screen);
16 
17    switch (param) {
18    case __DRI2_RENDERER_VENDOR_ID:
19       value[0] =
20          (unsigned int)screen->base.screen->get_param(screen->base.screen,
21                                                       PIPE_CAP_VENDOR_ID);
22       return 0;
23    case __DRI2_RENDERER_DEVICE_ID:
24       value[0] =
25          (unsigned int)screen->base.screen->get_param(screen->base.screen,
26                                                       PIPE_CAP_DEVICE_ID);
27       return 0;
28    case __DRI2_RENDERER_ACCELERATED:
29       value[0] =
30          (unsigned int)screen->base.screen->get_param(screen->base.screen,
31                                                       PIPE_CAP_ACCELERATED);
32       return 0;
33 
34    case __DRI2_RENDERER_VIDEO_MEMORY: {
35       int ov = driQueryOptioni(&screen->dev->option_cache, "override_vram_size");
36       value[0] =
37          (unsigned int)screen->base.screen->get_param(screen->base.screen,
38                                                       PIPE_CAP_VIDEO_MEMORY);
39       if (ov >= 0)
40          value[0] = MIN2(ov, value[0]);
41       return 0;
42    }
43 
44    case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
45       value[0] =
46          (unsigned int)screen->base.screen->get_param(screen->base.screen,
47                                                       PIPE_CAP_UMA);
48       return 0;
49 
50    case __DRI2_RENDERER_HAS_TEXTURE_3D:
51       value[0] =
52          screen->base.screen->get_param(screen->base.screen,
53                                         PIPE_CAP_MAX_TEXTURE_3D_LEVELS) != 0;
54       return 0;
55 
56    case __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB:
57       value[0] =
58          screen->base.screen->is_format_supported(screen->base.screen,
59                                                   PIPE_FORMAT_B8G8R8A8_SRGB,
60                                                   PIPE_TEXTURE_2D, 0, 0,
61                                                   PIPE_BIND_RENDER_TARGET);
62       return 0;
63    case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
64       value[0] =
65          screen->base.screen->get_param(screen->base.screen,
66                                         PIPE_CAP_CONTEXT_PRIORITY_MASK);
67       if (!value[0])
68          return -1;
69       return 0;
70    case __DRI2_RENDERER_HAS_PROTECTED_CONTENT:
71       value[0] =
72          screen->base.screen->get_param(screen->base.screen,
73                                         PIPE_CAP_DEVICE_PROTECTED_CONTENT);
74       if (!value[0])
75          return -1;
76       return 0;
77    default:
78       return driQueryRendererIntegerCommon(_screen, param, value);
79    }
80 }
81 
82 static int
dri2_query_renderer_string(__DRIscreen * _screen,int param,const char ** value)83 dri2_query_renderer_string(__DRIscreen *_screen, int param,
84                            const char **value)
85 {
86    struct dri_screen *screen = dri_screen(_screen);
87 
88    switch (param) {
89    case __DRI2_RENDERER_VENDOR_ID:
90       value[0] = screen->base.screen->get_vendor(screen->base.screen);
91       return 0;
92    case __DRI2_RENDERER_DEVICE_ID:
93       value[0] = screen->base.screen->get_name(screen->base.screen);
94       return 0;
95    default:
96       return -1;
97    }
98 }
99 
100 const __DRI2rendererQueryExtension dri2RendererQueryExtension = {
101     .base = { __DRI2_RENDERER_QUERY, 1 },
102 
103     .queryInteger         = dri2_query_renderer_integer,
104     .queryString          = dri2_query_renderer_string
105 };
106