lima: add layer_stride field to lima_resource struct
[mesa.git] / src / gallium / drivers / lima / lima_resource.h
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
35 struct lima_resource_level {
36 uint32_t width;
37 uint32_t stride;
38 uint32_t offset;
39 uint32_t layer_stride;
40 };
41
42 struct lima_damage_region {
43 struct pipe_scissor_state *region;
44 struct pipe_scissor_state bound;
45 unsigned num_region;
46 bool aligned;
47 };
48
49 struct lima_resource {
50 struct pipe_resource base;
51
52 struct lima_damage_region damage;
53 struct renderonly_scanout *scanout;
54 struct lima_bo *bo;
55 bool tiled;
56
57 struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS];
58 };
59
60 struct lima_surface {
61 struct pipe_surface base;
62 int tiled_w, tiled_h;
63 bool reload;
64 };
65
66 struct lima_transfer {
67 struct pipe_transfer base;
68 void *staging;
69 };
70
71 static inline struct lima_resource *
72 lima_resource(struct pipe_resource *res)
73 {
74 return (struct lima_resource *)res;
75 }
76
77 static inline struct lima_surface *
78 lima_surface(struct pipe_surface *surf)
79 {
80 return (struct lima_surface *)surf;
81 }
82
83 static inline struct lima_transfer *
84 lima_transfer(struct pipe_transfer *trans)
85 {
86 return (struct lima_transfer *)trans;
87 }
88
89 void
90 lima_resource_screen_init(struct lima_screen *screen);
91
92 void
93 lima_resource_context_init(struct lima_context *ctx);
94
95 #endif