Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
4574 views
1
/*
2
* Copyright (C) 2013 Rob Clark <[email protected]>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
* SOFTWARE.
22
*
23
* Authors:
24
* Rob Clark <[email protected]>
25
*/
26
27
#include "pipe/p_screen.h"
28
#include "util/format/u_format.h"
29
30
#include "fd3_context.h"
31
#include "fd3_emit.h"
32
#include "fd3_format.h"
33
#include "fd3_resource.h"
34
#include "fd3_screen.h"
35
36
#include "ir3/ir3_compiler.h"
37
38
static bool
39
fd3_screen_is_format_supported(struct pipe_screen *pscreen,
40
enum pipe_format format,
41
enum pipe_texture_target target,
42
unsigned sample_count,
43
unsigned storage_sample_count, unsigned usage)
44
{
45
unsigned retval = 0;
46
47
if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
48
(sample_count > 1)) { /* TODO add MSAA */
49
DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
50
util_format_name(format), target, sample_count, usage);
51
return false;
52
}
53
54
if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
55
return false;
56
57
if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
58
(fd3_pipe2vtx(format) != VFMT_NONE)) {
59
retval |= PIPE_BIND_VERTEX_BUFFER;
60
}
61
62
if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
63
(fd3_pipe2tex(format) != TFMT_NONE)) {
64
retval |= PIPE_BIND_SAMPLER_VIEW;
65
}
66
67
if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |
68
PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_BLENDABLE)) &&
69
(fd3_pipe2color(format) != RB_NONE) &&
70
(fd3_pipe2tex(format) != TFMT_NONE)) {
71
retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |
72
PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
73
if (!util_format_is_pure_integer(format))
74
retval |= usage & PIPE_BIND_BLENDABLE;
75
}
76
77
if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
78
(fd_pipe2depth(format) != (enum adreno_rb_depth_format) ~0) &&
79
(fd3_pipe2tex(format) != TFMT_NONE)) {
80
retval |= PIPE_BIND_DEPTH_STENCIL;
81
}
82
83
if ((usage & PIPE_BIND_INDEX_BUFFER) &&
84
(fd_pipe2index(format) != (enum pc_di_index_size) ~0)) {
85
retval |= PIPE_BIND_INDEX_BUFFER;
86
}
87
88
if (retval != usage) {
89
DBG("not supported: format=%s, target=%d, sample_count=%d, "
90
"usage=%x, retval=%x",
91
util_format_name(format), target, sample_count, usage, retval);
92
}
93
94
return retval == usage;
95
}
96
97
void
98
fd3_screen_init(struct pipe_screen *pscreen)
99
{
100
struct fd_screen *screen = fd_screen(pscreen);
101
screen->max_rts = A3XX_MAX_RENDER_TARGETS;
102
pscreen->context_create = fd3_context_create;
103
pscreen->is_format_supported = fd3_screen_is_format_supported;
104
fd3_emit_init_screen(pscreen);
105
ir3_screen_init(pscreen);
106
107
screen->setup_slices = fd3_setup_slices;
108
if (FD_DBG(TTILE))
109
screen->tile_mode = fd3_tile_mode;
110
}
111
112