1 /*
2 * Copyright (c) 2017-2019 Lima Project
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, sub license,
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
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the 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 NON-INFRINGEMENT. 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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef H_LIMA_RESOURCE
26 #define H_LIMA_RESOURCE
27
28 #include "pipe/p_state.h"
29
30 /* max texture size is 4096x4096 */
31 #define LIMA_MAX_MIP_LEVELS 13
32
33 struct lima_screen;
34 struct panfrost_minmax_cache;
35
36 struct lima_resource_level {
37 uint32_t width;
38 uint32_t stride;
39 uint32_t offset;
40 uint32_t layer_stride;
41 };
42
43 struct lima_damage_region {
44 struct pipe_scissor_state *region;
45 struct pipe_scissor_state bound;
46 unsigned num_region;
47 bool aligned;
48 };
49
50 struct lima_resource {
51 struct pipe_resource base;
52
53 struct lima_damage_region damage;
54 struct renderonly_scanout *scanout;
55 struct lima_bo *bo;
56 struct panfrost_minmax_cache *index_cache;
57 bool tiled;
58
59 struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS];
60 };
61
62 struct lima_surface {
63 struct pipe_surface base;
64 int tiled_w, tiled_h;
65 unsigned reload;
66 };
67
68 struct lima_transfer {
69 struct pipe_transfer base;
70 void *staging;
71 };
72
73 static inline struct lima_resource *
lima_resource(struct pipe_resource * res)74 lima_resource(struct pipe_resource *res)
75 {
76 return (struct lima_resource *)res;
77 }
78
79 static inline struct lima_surface *
lima_surface(struct pipe_surface * surf)80 lima_surface(struct pipe_surface *surf)
81 {
82 return (struct lima_surface *)surf;
83 }
84
85 static inline struct lima_transfer *
lima_transfer(struct pipe_transfer * trans)86 lima_transfer(struct pipe_transfer *trans)
87 {
88 return (struct lima_transfer *)trans;
89 }
90
91 void
92 lima_resource_screen_init(struct lima_screen *screen);
93
94 void
95 lima_resource_context_init(struct lima_context *ctx);
96
97 #endif
98