File: render_virgl.h

package info (click to toggle)
virglrenderer 0.10.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,744 kB
  • sloc: ansic: 118,882; sh: 1,259; python: 962; makefile: 40
file content (70 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: MIT
 */

#ifndef RENDER_VIRGL_H
#define RENDER_VIRGL_H

#include "render_common.h"

#ifdef ENABLE_RENDER_SERVER_WORKER_THREAD
#include "c11/threads.h"
#endif

/* Workers call into virglrenderer.  When they are processes, not much care is
 * required.  We just want to be careful that the server process might have
 * initialized viglrenderer before workers are forked.
 *
 * But when workers are threads, we need to grab a lock to protect
 * virglrenderer.
 *
 * TODO skip virglrenderer.h and go straight to vkr_renderer.h.  That allows
 * us to remove this file.
 */
struct render_virgl {
#ifdef ENABLE_RENDER_SERVER_WORKER_THREAD
   /* this protects the struct */
   mtx_t struct_mutex;
   /* this protects virglrenderer */
   mtx_t dispatch_mutex;
#endif

   /* for nested initialization */
   int init_count;
   uint32_t init_flags;

   struct list_head contexts;
};

extern struct render_virgl render_virgl_internal;

bool
render_virgl_init(uint32_t init_flags);

void
render_virgl_fini(void);

void
render_virgl_add_context(struct render_context *ctx);

void
render_virgl_remove_context(struct render_context *ctx);

static inline void
render_virgl_lock_dispatch(void)
{
#ifdef ENABLE_RENDER_SERVER_WORKER_THREAD
   mtx_lock(&render_virgl_internal.dispatch_mutex);
#endif
}

static inline void
render_virgl_unlock_dispatch(void)
{
#ifdef ENABLE_RENDER_SERVER_WORKER_THREAD
   mtx_unlock(&render_virgl_internal.dispatch_mutex);
#endif
}

#endif /* RENDER_VIRGL_H */