1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2014, 2015 Red Hat.
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub
8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom
9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci#ifndef VIRGL_H
24bf215546Sopenharmony_ci#define VIRGL_H
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "pipe/p_screen.h"
27bf215546Sopenharmony_ci#include "util/slab.h"
28bf215546Sopenharmony_ci#include "util/disk_cache.h"
29bf215546Sopenharmony_ci#include "virgl_winsys.h"
30bf215546Sopenharmony_ci#include "compiler/nir/nir.h"
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_cienum virgl_debug_flags {
33bf215546Sopenharmony_ci   VIRGL_DEBUG_VERBOSE              = 1 << 0,
34bf215546Sopenharmony_ci   VIRGL_DEBUG_TGSI                 = 1 << 1,
35bf215546Sopenharmony_ci   VIRGL_DEBUG_NO_EMULATE_BGRA      = 1 << 2,
36bf215546Sopenharmony_ci   VIRGL_DEBUG_NO_BGRA_DEST_SWIZZLE = 1 << 3,
37bf215546Sopenharmony_ci   VIRGL_DEBUG_SYNC                 = 1 << 4,
38bf215546Sopenharmony_ci   VIRGL_DEBUG_XFER                 = 1 << 5,
39bf215546Sopenharmony_ci   VIRGL_DEBUG_NO_COHERENT          = 1 << 6,
40bf215546Sopenharmony_ci   VIRGL_DEBUG_USE_TGSI             = 1 << 7,
41bf215546Sopenharmony_ci   VIRGL_DEBUG_L8_SRGB_ENABLE_READBACK = 1 << 8,
42bf215546Sopenharmony_ci};
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ciextern int virgl_debug;
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_cistruct virgl_screen {
47bf215546Sopenharmony_ci   struct pipe_screen base;
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_ci   int refcnt;
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci   /* place for winsys to stash it's own stuff: */
52bf215546Sopenharmony_ci   void *winsys_priv;
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ci   struct virgl_winsys *vws;
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci   struct virgl_drm_caps caps;
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci   struct slab_parent_pool transfer_pool;
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci   uint32_t sub_ctx_id;
61bf215546Sopenharmony_ci   bool tweak_gles_emulate_bgra;
62bf215546Sopenharmony_ci   bool tweak_gles_apply_bgra_dest_swizzle;
63bf215546Sopenharmony_ci   bool tweak_l8_srgb_readback;
64bf215546Sopenharmony_ci   bool no_coherent;
65bf215546Sopenharmony_ci   int32_t tweak_gles_tf3_value;
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci   nir_shader_compiler_options compiler_options;
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci   struct disk_cache *disk_cache;
70bf215546Sopenharmony_ci};
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_cistatic inline struct virgl_screen *
74bf215546Sopenharmony_civirgl_screen(struct pipe_screen *pipe)
75bf215546Sopenharmony_ci{
76bf215546Sopenharmony_ci   return (struct virgl_screen *)pipe;
77bf215546Sopenharmony_ci}
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_cibool
80bf215546Sopenharmony_civirgl_has_readback_format(struct pipe_screen *screen, enum virgl_formats fmt,
81bf215546Sopenharmony_ci                          bool allow_tweak);
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_cibool
84bf215546Sopenharmony_civirgl_has_scanout_format(struct virgl_screen *vscreen,
85bf215546Sopenharmony_ci                         enum pipe_format format,
86bf215546Sopenharmony_ci                         bool may_emulate_bgra);
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci/* GL_ARB_map_buffer_alignment requires 64 as the minimum alignment value.  In
89bf215546Sopenharmony_ci * addition to complying with the extension, a high enough alignment value is
90bf215546Sopenharmony_ci * expected by various external GL clients. For example, wined3d doesn't like
91bf215546Sopenharmony_ci * maps that don't have a 16 byte alignment.
92bf215546Sopenharmony_ci */
93bf215546Sopenharmony_ci#define VIRGL_MAP_BUFFER_ALIGNMENT 64
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci#endif
96