Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a6xx/fd6_screen.c
4574 views
1
/*
2
* Copyright (C) 2016 Rob Clark <[email protected]>
3
* Copyright © 2018 Google, Inc.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice (including the next
13
* paragraph) shall be included in all copies or substantial portions of the
14
* Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*
24
* Authors:
25
* Rob Clark <[email protected]>
26
*/
27
28
#include "drm-uapi/drm_fourcc.h"
29
#include "pipe/p_screen.h"
30
#include "util/format/u_format.h"
31
32
#include "fd6_blitter.h"
33
#include "fd6_context.h"
34
#include "fd6_emit.h"
35
#include "fd6_format.h"
36
#include "fd6_resource.h"
37
#include "fd6_screen.h"
38
39
#include "ir3/ir3_compiler.h"
40
41
static bool
42
valid_sample_count(unsigned sample_count)
43
{
44
switch (sample_count) {
45
case 0:
46
case 1:
47
case 2:
48
case 4:
49
// TODO seems 8x works, but increases lrz width or height.. but the
50
// blob I have doesn't seem to expose any egl configs w/ 8x, so
51
// just hide it for now and revisit later.
52
// case 8:
53
return true;
54
default:
55
return false;
56
}
57
}
58
59
static bool
60
fd6_screen_is_format_supported(struct pipe_screen *pscreen,
61
enum pipe_format format,
62
enum pipe_texture_target target,
63
unsigned sample_count,
64
unsigned storage_sample_count, unsigned usage)
65
{
66
unsigned retval = 0;
67
68
if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
69
!valid_sample_count(sample_count)) {
70
DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
71
util_format_name(format), target, sample_count, usage);
72
return false;
73
}
74
75
if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
76
return false;
77
78
if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
79
(fd6_pipe2vtx(format) != FMT6_NONE)) {
80
retval |= PIPE_BIND_VERTEX_BUFFER;
81
}
82
83
if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
84
(fd6_pipe2tex(format) != FMT6_NONE) &&
85
(target == PIPE_BUFFER || util_format_get_blocksize(format) != 12)) {
86
retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
87
}
88
89
if ((usage &
90
(PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |
91
PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_COMPUTE_RESOURCE)) &&
92
(fd6_pipe2color(format) != FMT6_NONE) &&
93
(fd6_pipe2tex(format) != FMT6_NONE)) {
94
retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |
95
PIPE_BIND_SCANOUT | PIPE_BIND_SHARED |
96
PIPE_BIND_COMPUTE_RESOURCE);
97
}
98
99
/* For ARB_framebuffer_no_attachments: */
100
if ((usage & PIPE_BIND_RENDER_TARGET) && (format == PIPE_FORMAT_NONE)) {
101
retval |= usage & PIPE_BIND_RENDER_TARGET;
102
}
103
104
if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
105
(fd6_pipe2depth(format) != (enum a6xx_depth_format) ~0) &&
106
(fd6_pipe2tex(format) != FMT6_NONE)) {
107
retval |= PIPE_BIND_DEPTH_STENCIL;
108
}
109
110
if ((usage & PIPE_BIND_INDEX_BUFFER) &&
111
(fd_pipe2index(format) != (enum pc_di_index_size) ~0)) {
112
retval |= PIPE_BIND_INDEX_BUFFER;
113
}
114
115
if (retval != usage) {
116
DBG("not supported: format=%s, target=%d, sample_count=%d, "
117
"usage=%x, retval=%x",
118
util_format_name(format), target, sample_count, usage, retval);
119
}
120
121
return retval == usage;
122
}
123
124
void
125
fd6_screen_init(struct pipe_screen *pscreen)
126
{
127
struct fd_screen *screen = fd_screen(pscreen);
128
129
screen->max_rts = A6XX_MAX_RENDER_TARGETS;
130
131
/* Currently only FB_READ forces GMEM path, mostly because we'd have to
132
* deal with cmdstream patching otherwise..
133
*/
134
screen->gmem_reason_mask = FD_GMEM_CLEARS_DEPTH_STENCIL |
135
FD_GMEM_DEPTH_ENABLED | FD_GMEM_STENCIL_ENABLED |
136
FD_GMEM_BLEND_ENABLED | FD_GMEM_LOGICOP_ENABLED;
137
138
pscreen->context_create = fd6_context_create;
139
pscreen->is_format_supported = fd6_screen_is_format_supported;
140
141
screen->tile_mode = fd6_tile_mode;
142
143
fd6_resource_screen_init(pscreen);
144
fd6_emit_init_screen(pscreen);
145
ir3_screen_init(pscreen);
146
}
147
148