Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/frontends/dri/dri_screen.c
4566 views
1
/**************************************************************************
2
*
3
* Copyright 2009, VMware, Inc.
4
* All Rights Reserved.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the
8
* "Software"), to deal in the Software without restriction, including
9
* without limitation the rights to use, copy, modify, merge, publish,
10
* distribute, sub license, and/or sell copies of the Software, and to
11
* permit persons to whom the Software is furnished to do so, subject to
12
* the following conditions:
13
*
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
16
* of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
*
26
**************************************************************************/
27
/*
28
* Author: Keith Whitwell <[email protected]>
29
* Author: Jakob Bornecrantz <[email protected]>
30
*/
31
32
#include "utils.h"
33
34
#include "dri_screen.h"
35
#include "dri_context.h"
36
#include "dri_helpers.h"
37
38
#include "util/u_inlines.h"
39
#include "pipe/p_screen.h"
40
#include "pipe/p_format.h"
41
#include "pipe-loader/pipe_loader.h"
42
#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
43
#include "frontend/drm_driver.h"
44
45
#include "util/u_debug.h"
46
#include "util/format/u_format_s3tc.h"
47
48
#define MSAA_VISUAL_MAX_SAMPLES 32
49
50
#undef false
51
52
const __DRIconfigOptionsExtension gallium_config_options = {
53
.base = { __DRI_CONFIG_OPTIONS, 2 },
54
.getXml = pipe_loader_get_driinfo_xml
55
};
56
57
#define false 0
58
59
static void
60
dri_fill_st_options(struct dri_screen *screen)
61
{
62
struct st_config_options *options = &screen->options;
63
const struct driOptionCache *optionCache = &screen->dev->option_cache;
64
65
options->disable_blend_func_extended =
66
driQueryOptionb(optionCache, "disable_blend_func_extended");
67
options->disable_arb_gpu_shader5 =
68
driQueryOptionb(optionCache, "disable_arb_gpu_shader5");
69
options->disable_glsl_line_continuations =
70
driQueryOptionb(optionCache, "disable_glsl_line_continuations");
71
options->force_glsl_extensions_warn =
72
driQueryOptionb(optionCache, "force_glsl_extensions_warn");
73
options->force_glsl_version =
74
driQueryOptioni(optionCache, "force_glsl_version");
75
options->allow_extra_pp_tokens =
76
driQueryOptionb(optionCache, "allow_extra_pp_tokens");
77
options->allow_glsl_extension_directive_midshader =
78
driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
79
options->allow_glsl_120_subset_in_110 =
80
driQueryOptionb(optionCache, "allow_glsl_120_subset_in_110");
81
options->allow_glsl_builtin_const_expression =
82
driQueryOptionb(optionCache, "allow_glsl_builtin_const_expression");
83
options->allow_glsl_relaxed_es =
84
driQueryOptionb(optionCache, "allow_glsl_relaxed_es");
85
options->allow_glsl_builtin_variable_redeclaration =
86
driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration");
87
options->allow_higher_compat_version =
88
driQueryOptionb(optionCache, "allow_higher_compat_version");
89
options->glsl_ignore_write_to_readonly_var =
90
driQueryOptionb(optionCache, "glsl_ignore_write_to_readonly_var");
91
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
92
options->force_integer_tex_nearest =
93
driQueryOptionb(optionCache, "force_integer_tex_nearest");
94
options->vs_position_always_invariant =
95
driQueryOptionb(optionCache, "vs_position_always_invariant");
96
options->force_glsl_abs_sqrt =
97
driQueryOptionb(optionCache, "force_glsl_abs_sqrt");
98
options->allow_glsl_cross_stage_interpolation_mismatch =
99
driQueryOptionb(optionCache, "allow_glsl_cross_stage_interpolation_mismatch");
100
options->allow_draw_out_of_order =
101
driQueryOptionb(optionCache, "allow_draw_out_of_order");
102
options->allow_incorrect_primitive_id =
103
driQueryOptionb(optionCache, "allow_incorrect_primitive_id");
104
options->ignore_map_unsynchronized =
105
driQueryOptionb(optionCache, "ignore_map_unsynchronized");
106
options->force_gl_names_reuse =
107
driQueryOptionb(optionCache, "force_gl_names_reuse");
108
options->transcode_etc =
109
driQueryOptionb(optionCache, "transcode_etc");
110
options->transcode_astc =
111
driQueryOptionb(optionCache, "transcode_astc");
112
113
char *vendor_str = driQueryOptionstr(optionCache, "force_gl_vendor");
114
/* not an empty string */
115
if (*vendor_str)
116
options->force_gl_vendor = strdup(vendor_str);
117
118
driComputeOptionsSha1(optionCache, options->config_options_sha1);
119
}
120
121
static unsigned
122
dri_loader_get_cap(struct dri_screen *screen, enum dri_loader_cap cap)
123
{
124
const __DRIdri2LoaderExtension *dri2_loader = screen->sPriv->dri2.loader;
125
const __DRIimageLoaderExtension *image_loader = screen->sPriv->image.loader;
126
127
if (dri2_loader && dri2_loader->base.version >= 4 &&
128
dri2_loader->getCapability)
129
return dri2_loader->getCapability(screen->sPriv->loaderPrivate, cap);
130
131
if (image_loader && image_loader->base.version >= 2 &&
132
image_loader->getCapability)
133
return image_loader->getCapability(screen->sPriv->loaderPrivate, cap);
134
135
return 0;
136
}
137
138
static const __DRIconfig **
139
dri_fill_in_modes(struct dri_screen *screen)
140
{
141
static const mesa_format mesa_formats[] = {
142
MESA_FORMAT_B10G10R10A2_UNORM,
143
MESA_FORMAT_B10G10R10X2_UNORM,
144
MESA_FORMAT_R10G10B10A2_UNORM,
145
MESA_FORMAT_R10G10B10X2_UNORM,
146
MESA_FORMAT_B8G8R8A8_UNORM,
147
MESA_FORMAT_B8G8R8X8_UNORM,
148
MESA_FORMAT_B8G8R8A8_SRGB,
149
MESA_FORMAT_B8G8R8X8_SRGB,
150
MESA_FORMAT_B5G6R5_UNORM,
151
MESA_FORMAT_RGBA_FLOAT16,
152
MESA_FORMAT_RGBX_FLOAT16,
153
154
/* The 32-bit RGBA format must not precede the 32-bit BGRA format.
155
* Likewise for RGBX and BGRX. Otherwise, the GLX client and the GLX
156
* server may disagree on which format the GLXFBConfig represents,
157
* resulting in swapped color channels.
158
*
159
* The problem, as of 2017-05-30:
160
* When matching a GLXFBConfig to a __DRIconfig, GLX ignores the channel
161
* order and chooses the first __DRIconfig with the expected channel
162
* sizes. Specifically, GLX compares the GLXFBConfig's and __DRIconfig's
163
* __DRI_ATTRIB_{CHANNEL}_SIZE but ignores __DRI_ATTRIB_{CHANNEL}_MASK.
164
*
165
* EGL does not suffer from this problem. It correctly compares the
166
* channel masks when matching EGLConfig to __DRIconfig.
167
*/
168
169
/* Required by Android, for HAL_PIXEL_FORMAT_RGBA_8888. */
170
MESA_FORMAT_R8G8B8A8_UNORM,
171
172
/* Required by Android, for HAL_PIXEL_FORMAT_RGBX_8888. */
173
MESA_FORMAT_R8G8B8X8_UNORM,
174
175
/* Required by Android, for HAL_PIXEL_FORMAT_RGBA_8888. */
176
MESA_FORMAT_R8G8B8A8_SRGB,
177
178
/* Required by Android, for HAL_PIXEL_FORMAT_RGBX_8888. */
179
MESA_FORMAT_R8G8B8X8_SRGB,
180
};
181
static const enum pipe_format pipe_formats[] = {
182
PIPE_FORMAT_B10G10R10A2_UNORM,
183
PIPE_FORMAT_B10G10R10X2_UNORM,
184
PIPE_FORMAT_R10G10B10A2_UNORM,
185
PIPE_FORMAT_R10G10B10X2_UNORM,
186
PIPE_FORMAT_BGRA8888_UNORM,
187
PIPE_FORMAT_BGRX8888_UNORM,
188
PIPE_FORMAT_BGRA8888_SRGB,
189
PIPE_FORMAT_BGRX8888_SRGB,
190
PIPE_FORMAT_B5G6R5_UNORM,
191
PIPE_FORMAT_R16G16B16A16_FLOAT,
192
PIPE_FORMAT_R16G16B16X16_FLOAT,
193
PIPE_FORMAT_RGBA8888_UNORM,
194
PIPE_FORMAT_RGBX8888_UNORM,
195
PIPE_FORMAT_RGBA8888_SRGB,
196
PIPE_FORMAT_RGBX8888_SRGB,
197
};
198
mesa_format format;
199
__DRIconfig **configs = NULL;
200
uint8_t depth_bits_array[5];
201
uint8_t stencil_bits_array[5];
202
unsigned depth_buffer_factor;
203
unsigned msaa_samples_max;
204
unsigned i;
205
struct pipe_screen *p_screen = screen->base.screen;
206
bool pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
207
bool mixed_color_depth;
208
bool allow_rgba_ordering;
209
bool allow_rgb10;
210
bool allow_fp16;
211
212
static const GLenum back_buffer_modes[] = {
213
__DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED,
214
__DRI_ATTRIB_SWAP_COPY
215
};
216
217
if (driQueryOptionb(&screen->dev->option_cache, "always_have_depth_buffer")) {
218
/* all visuals will have a depth buffer */
219
depth_buffer_factor = 0;
220
}
221
else {
222
depth_bits_array[0] = 0;
223
stencil_bits_array[0] = 0;
224
depth_buffer_factor = 1;
225
}
226
227
allow_rgba_ordering = dri_loader_get_cap(screen, DRI_LOADER_CAP_RGBA_ORDERING);
228
allow_rgb10 = driQueryOptionb(&screen->dev->option_cache, "allow_rgb10_configs");
229
allow_fp16 = driQueryOptionb(&screen->dev->option_cache, "allow_fp16_configs");
230
allow_fp16 &= dri_loader_get_cap(screen, DRI_LOADER_CAP_FP16);
231
232
msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS_MASK)
233
? MSAA_VISUAL_MAX_SAMPLES : 1;
234
235
pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
236
PIPE_TEXTURE_2D, 0, 0,
237
PIPE_BIND_DEPTH_STENCIL);
238
pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
239
PIPE_TEXTURE_2D, 0, 0,
240
PIPE_BIND_DEPTH_STENCIL);
241
pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_UINT,
242
PIPE_TEXTURE_2D, 0, 0,
243
PIPE_BIND_DEPTH_STENCIL);
244
pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_UINT_Z24_UNORM,
245
PIPE_TEXTURE_2D, 0, 0,
246
PIPE_BIND_DEPTH_STENCIL);
247
pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
248
PIPE_TEXTURE_2D, 0, 0,
249
PIPE_BIND_DEPTH_STENCIL);
250
pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
251
PIPE_TEXTURE_2D, 0, 0,
252
PIPE_BIND_DEPTH_STENCIL);
253
254
if (pf_z16) {
255
depth_bits_array[depth_buffer_factor] = 16;
256
stencil_bits_array[depth_buffer_factor++] = 0;
257
}
258
if (pf_x8z24 || pf_z24x8) {
259
depth_bits_array[depth_buffer_factor] = 24;
260
stencil_bits_array[depth_buffer_factor++] = 0;
261
screen->d_depth_bits_last = pf_x8z24;
262
}
263
if (pf_s8z24 || pf_z24s8) {
264
depth_bits_array[depth_buffer_factor] = 24;
265
stencil_bits_array[depth_buffer_factor++] = 8;
266
screen->sd_depth_bits_last = pf_s8z24;
267
}
268
if (pf_z32) {
269
depth_bits_array[depth_buffer_factor] = 32;
270
stencil_bits_array[depth_buffer_factor++] = 0;
271
}
272
273
mixed_color_depth =
274
p_screen->get_param(p_screen, PIPE_CAP_MIXED_COLOR_DEPTH_BITS);
275
276
assert(ARRAY_SIZE(mesa_formats) == ARRAY_SIZE(pipe_formats));
277
278
/* Add configs. */
279
for (format = 0; format < ARRAY_SIZE(mesa_formats); format++) {
280
__DRIconfig **new_configs = NULL;
281
unsigned num_msaa_modes = 0; /* includes a single-sample mode */
282
uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES];
283
284
/* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */
285
if (!allow_rgba_ordering &&
286
(mesa_formats[format] == MESA_FORMAT_R8G8B8A8_UNORM ||
287
mesa_formats[format] == MESA_FORMAT_R8G8B8X8_UNORM ||
288
mesa_formats[format] == MESA_FORMAT_R8G8B8A8_SRGB ||
289
mesa_formats[format] == MESA_FORMAT_R8G8B8X8_SRGB))
290
continue;
291
292
if (!allow_rgb10 &&
293
(mesa_formats[format] == MESA_FORMAT_B10G10R10A2_UNORM ||
294
mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM ||
295
mesa_formats[format] == MESA_FORMAT_R10G10B10A2_UNORM ||
296
mesa_formats[format] == MESA_FORMAT_R10G10B10X2_UNORM))
297
continue;
298
299
if (!allow_fp16 &&
300
(mesa_formats[format] == MESA_FORMAT_RGBA_FLOAT16 ||
301
mesa_formats[format] == MESA_FORMAT_RGBX_FLOAT16))
302
continue;
303
304
if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
305
PIPE_TEXTURE_2D, 0, 0,
306
PIPE_BIND_RENDER_TARGET |
307
PIPE_BIND_DISPLAY_TARGET))
308
continue;
309
310
for (i = 1; i <= msaa_samples_max; i++) {
311
int samples = i > 1 ? i : 0;
312
313
if (p_screen->is_format_supported(p_screen, pipe_formats[format],
314
PIPE_TEXTURE_2D, samples, samples,
315
PIPE_BIND_RENDER_TARGET)) {
316
msaa_modes[num_msaa_modes++] = samples;
317
}
318
}
319
320
if (num_msaa_modes) {
321
/* Single-sample configs with an accumulation buffer. */
322
new_configs = driCreateConfigs(mesa_formats[format],
323
depth_bits_array, stencil_bits_array,
324
depth_buffer_factor, back_buffer_modes,
325
ARRAY_SIZE(back_buffer_modes),
326
msaa_modes, 1,
327
GL_TRUE, !mixed_color_depth);
328
configs = driConcatConfigs(configs, new_configs);
329
330
/* Multi-sample configs without an accumulation buffer. */
331
if (num_msaa_modes > 1) {
332
new_configs = driCreateConfigs(mesa_formats[format],
333
depth_bits_array, stencil_bits_array,
334
depth_buffer_factor, back_buffer_modes,
335
ARRAY_SIZE(back_buffer_modes),
336
msaa_modes+1, num_msaa_modes-1,
337
GL_FALSE, !mixed_color_depth);
338
configs = driConcatConfigs(configs, new_configs);
339
}
340
}
341
}
342
343
if (configs == NULL) {
344
debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
345
return NULL;
346
}
347
348
return (const __DRIconfig **)configs;
349
}
350
351
/**
352
* Roughly the converse of dri_fill_in_modes.
353
*/
354
void
355
dri_fill_st_visual(struct st_visual *stvis,
356
const struct dri_screen *screen,
357
const struct gl_config *mode)
358
{
359
memset(stvis, 0, sizeof(*stvis));
360
361
if (!mode)
362
return;
363
364
/* Deduce the color format. */
365
switch (mode->redMask) {
366
case 0:
367
/* Formats > 32 bpp */
368
assert(mode->floatMode);
369
if (mode->alphaShift > -1) {
370
assert(mode->alphaShift == 48);
371
stvis->color_format = PIPE_FORMAT_R16G16B16A16_FLOAT;
372
} else {
373
stvis->color_format = PIPE_FORMAT_R16G16B16X16_FLOAT;
374
}
375
break;
376
377
case 0x3FF00000:
378
if (mode->alphaMask) {
379
assert(mode->alphaMask == 0xC0000000);
380
stvis->color_format = PIPE_FORMAT_B10G10R10A2_UNORM;
381
} else {
382
stvis->color_format = PIPE_FORMAT_B10G10R10X2_UNORM;
383
}
384
break;
385
386
case 0x000003FF:
387
if (mode->alphaMask) {
388
assert(mode->alphaMask == 0xC0000000);
389
stvis->color_format = PIPE_FORMAT_R10G10B10A2_UNORM;
390
} else {
391
stvis->color_format = PIPE_FORMAT_R10G10B10X2_UNORM;
392
}
393
break;
394
395
case 0x00FF0000:
396
if (mode->alphaMask) {
397
assert(mode->alphaMask == 0xFF000000);
398
stvis->color_format = mode->sRGBCapable ?
399
PIPE_FORMAT_BGRA8888_SRGB :
400
PIPE_FORMAT_BGRA8888_UNORM;
401
} else {
402
stvis->color_format = mode->sRGBCapable ?
403
PIPE_FORMAT_BGRX8888_SRGB :
404
PIPE_FORMAT_BGRX8888_UNORM;
405
}
406
break;
407
408
case 0x000000FF:
409
if (mode->alphaMask) {
410
assert(mode->alphaMask == 0xFF000000);
411
stvis->color_format = mode->sRGBCapable ?
412
PIPE_FORMAT_RGBA8888_SRGB :
413
PIPE_FORMAT_RGBA8888_UNORM;
414
} else {
415
stvis->color_format = mode->sRGBCapable ?
416
PIPE_FORMAT_RGBX8888_SRGB :
417
PIPE_FORMAT_RGBX8888_UNORM;
418
}
419
break;
420
421
case 0x0000F800:
422
stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM;
423
break;
424
425
default:
426
assert(!"unsupported visual: invalid red mask");
427
return;
428
}
429
430
if (mode->samples > 0) {
431
stvis->samples = mode->samples;
432
}
433
434
switch (mode->depthBits) {
435
default:
436
case 0:
437
stvis->depth_stencil_format = PIPE_FORMAT_NONE;
438
break;
439
case 16:
440
stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
441
break;
442
case 24:
443
if (mode->stencilBits == 0) {
444
stvis->depth_stencil_format = (screen->d_depth_bits_last) ?
445
PIPE_FORMAT_Z24X8_UNORM:
446
PIPE_FORMAT_X8Z24_UNORM;
447
} else {
448
stvis->depth_stencil_format = (screen->sd_depth_bits_last) ?
449
PIPE_FORMAT_Z24_UNORM_S8_UINT:
450
PIPE_FORMAT_S8_UINT_Z24_UNORM;
451
}
452
break;
453
case 32:
454
stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
455
break;
456
}
457
458
stvis->accum_format = (mode->accumRedBits > 0) ?
459
PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE;
460
461
stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
462
if (mode->doubleBufferMode) {
463
stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
464
}
465
if (mode->stereoMode) {
466
stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
467
if (mode->doubleBufferMode)
468
stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
469
}
470
471
if (mode->depthBits > 0 || mode->stencilBits > 0)
472
stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK;
473
/* let the gallium frontend allocate the accum buffer */
474
}
475
476
static bool
477
dri_get_egl_image(struct st_manager *smapi,
478
void *egl_image,
479
struct st_egl_image *stimg)
480
{
481
struct dri_screen *screen = (struct dri_screen *)smapi;
482
__DRIimage *img = NULL;
483
const struct dri2_format_mapping *map;
484
485
if (screen->lookup_egl_image) {
486
img = screen->lookup_egl_image(screen, egl_image);
487
}
488
489
if (!img)
490
return FALSE;
491
492
stimg->texture = NULL;
493
pipe_resource_reference(&stimg->texture, img->texture);
494
map = dri2_get_mapping_by_fourcc(img->dri_fourcc);
495
stimg->format = map ? map->pipe_format : img->texture->format;
496
stimg->level = img->level;
497
stimg->layer = img->layer;
498
499
if (img->imported_dmabuf && map) {
500
/* Guess sized internal format for dma-bufs. Could be used
501
* by EXT_EGL_image_storage.
502
*/
503
mesa_format mesa_format = driImageFormatToGLFormat(map->dri_format);
504
stimg->internalformat = driGLFormatToSizedInternalGLFormat(mesa_format);
505
}
506
507
return TRUE;
508
}
509
510
static int
511
dri_get_param(struct st_manager *smapi,
512
enum st_manager_param param)
513
{
514
struct dri_screen *screen = (struct dri_screen *)smapi;
515
516
switch(param) {
517
case ST_MANAGER_BROKEN_INVALIDATE:
518
return screen->broken_invalidate;
519
default:
520
return 0;
521
}
522
}
523
524
void
525
dri_destroy_screen_helper(struct dri_screen * screen)
526
{
527
if (screen->base.destroy)
528
screen->base.destroy(&screen->base);
529
530
if (screen->st_api && screen->st_api->destroy)
531
screen->st_api->destroy(screen->st_api);
532
533
if (screen->base.screen)
534
screen->base.screen->destroy(screen->base.screen);
535
536
mtx_destroy(&screen->opencl_func_mutex);
537
}
538
539
void
540
dri_destroy_screen(__DRIscreen * sPriv)
541
{
542
struct dri_screen *screen = dri_screen(sPriv);
543
544
dri_destroy_screen_helper(screen);
545
546
pipe_loader_release(&screen->dev, 1);
547
548
free(screen->options.force_gl_vendor);
549
550
/* The caller in dri_util preserves the fd ownership */
551
free(screen);
552
sPriv->driverPrivate = NULL;
553
sPriv->extensions = NULL;
554
}
555
556
static void
557
dri_postprocessing_init(struct dri_screen *screen)
558
{
559
unsigned i;
560
561
for (i = 0; i < PP_FILTERS; i++) {
562
screen->pp_enabled[i] = driQueryOptioni(&screen->dev->option_cache,
563
pp_filters[i].name);
564
}
565
}
566
567
static void
568
dri_set_background_context(struct st_context_iface *st,
569
struct util_queue_monitoring *queue_info)
570
{
571
struct dri_context *ctx = (struct dri_context *)st->st_manager_private;
572
const __DRIbackgroundCallableExtension *backgroundCallable =
573
ctx->sPriv->dri2.backgroundCallable;
574
575
/* Note: Mesa will only call this function if GL multithreading is enabled
576
* We only do that if the loader exposed the __DRI_BACKGROUND_CALLABLE
577
* extension. So we know that backgroundCallable is not NULL.
578
*/
579
assert(backgroundCallable);
580
backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
581
582
if (ctx->hud)
583
hud_add_queue_for_monitoring(ctx->hud, queue_info);
584
}
585
586
void
587
dri_init_options(struct dri_screen *screen)
588
{
589
pipe_loader_load_options(screen->dev);
590
591
dri_fill_st_options(screen);
592
}
593
594
const __DRIconfig **
595
dri_init_screen_helper(struct dri_screen *screen,
596
struct pipe_screen *pscreen)
597
{
598
screen->base.screen = pscreen;
599
screen->base.get_egl_image = dri_get_egl_image;
600
screen->base.get_param = dri_get_param;
601
screen->base.set_background_context = dri_set_background_context;
602
603
screen->st_api = st_gl_api_create();
604
if (!screen->st_api)
605
return NULL;
606
607
if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
608
screen->target = PIPE_TEXTURE_2D;
609
else
610
screen->target = PIPE_TEXTURE_RECT;
611
612
dri_postprocessing_init(screen);
613
614
screen->st_api->query_versions(screen->st_api, &screen->base,
615
&screen->options,
616
&screen->sPriv->max_gl_core_version,
617
&screen->sPriv->max_gl_compat_version,
618
&screen->sPriv->max_gl_es1_version,
619
&screen->sPriv->max_gl_es2_version);
620
621
return dri_fill_in_modes(screen);
622
}
623
624
/* vim: set sw=3 ts=8 sts=3 expandtab: */
625
626