Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/panfrost/pan_resource.h
4570 views
1
/*
2
* © Copyright2018-2019 Alyssa Rosenzweig
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
*/
24
25
26
#ifndef PAN_RESOURCE_H
27
#define PAN_RESOURCE_H
28
29
#include "pan_screen.h"
30
#include "pan_minmax_cache.h"
31
#include "pan_texture.h"
32
#include "drm-uapi/drm.h"
33
#include "util/u_range.h"
34
35
#define LAYOUT_CONVERT_THRESHOLD 8
36
#define PAN_MAX_BATCHES 32
37
38
struct panfrost_resource {
39
struct pipe_resource base;
40
struct {
41
struct pipe_scissor_state extent;
42
struct {
43
bool enable;
44
unsigned stride;
45
unsigned size;
46
BITSET_WORD *data;
47
} tile_map;
48
} damage;
49
50
struct {
51
struct panfrost_batch *writer;
52
BITSET_DECLARE(users, PAN_MAX_BATCHES);
53
} track;
54
55
struct renderonly_scanout *scanout;
56
57
struct panfrost_resource *separate_stencil;
58
59
struct util_range valid_buffer_range;
60
61
/* Description of the resource layout */
62
struct pan_image image;
63
64
struct {
65
/* Is the checksum for this image valid? Implicitly refers to
66
* the first slice; we only checksum non-mipmapped 2D images */
67
bool crc;
68
69
/* Has anything been written to this slice? */
70
BITSET_DECLARE(data, MAX_MIP_LEVELS);
71
} valid;
72
73
/* Whether the modifier can be changed */
74
bool modifier_constant;
75
76
/* Used to decide when to convert to another modifier */
77
uint16_t modifier_updates;
78
79
/* Cached min/max values for index buffers */
80
struct panfrost_minmax_cache *index_cache;
81
};
82
83
static inline struct panfrost_resource *
84
pan_resource(struct pipe_resource *p)
85
{
86
return (struct panfrost_resource *)p;
87
}
88
89
struct panfrost_transfer {
90
struct pipe_transfer base;
91
void *map;
92
struct {
93
struct pipe_resource *rsrc;
94
struct pipe_box box;
95
} staging;
96
};
97
98
static inline struct panfrost_transfer *
99
pan_transfer(struct pipe_transfer *p)
100
{
101
return (struct panfrost_transfer *)p;
102
}
103
104
mali_ptr
105
panfrost_get_texture_address(struct panfrost_resource *rsrc,
106
unsigned level, unsigned layer,
107
unsigned sample);
108
109
void
110
panfrost_get_afbc_pointers(struct panfrost_resource *rsrc,
111
unsigned level, unsigned layer,
112
mali_ptr *header, mali_ptr *body);
113
114
void panfrost_resource_screen_init(struct pipe_screen *screen);
115
116
void panfrost_resource_context_init(struct pipe_context *pctx);
117
118
/* Blitting */
119
120
void
121
panfrost_blit(struct pipe_context *pipe,
122
const struct pipe_blit_info *info);
123
124
void
125
panfrost_resource_set_damage_region(struct pipe_screen *screen,
126
struct pipe_resource *res,
127
unsigned int nrects,
128
const struct pipe_box *rects);
129
130
static inline enum mali_texture_dimension
131
panfrost_translate_texture_dimension(enum pipe_texture_target t) {
132
switch (t)
133
{
134
case PIPE_BUFFER:
135
case PIPE_TEXTURE_1D:
136
case PIPE_TEXTURE_1D_ARRAY:
137
return MALI_TEXTURE_DIMENSION_1D;
138
139
case PIPE_TEXTURE_2D:
140
case PIPE_TEXTURE_2D_ARRAY:
141
case PIPE_TEXTURE_RECT:
142
return MALI_TEXTURE_DIMENSION_2D;
143
144
case PIPE_TEXTURE_3D:
145
return MALI_TEXTURE_DIMENSION_3D;
146
147
case PIPE_TEXTURE_CUBE:
148
case PIPE_TEXTURE_CUBE_ARRAY:
149
return MALI_TEXTURE_DIMENSION_CUBE;
150
151
default:
152
unreachable("Unknown target");
153
}
154
}
155
156
void
157
pan_resource_modifier_convert(struct panfrost_context *ctx,
158
struct panfrost_resource *rsrc,
159
uint64_t modifier);
160
161
#endif /* PAN_RESOURCE_H */
162
163