• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define LAYOUT_CONVERT_THRESHOLD 8
33 
34 struct lima_screen;
35 struct panfrost_minmax_cache;
36 
37 struct lima_resource_level {
38    uint32_t width;
39    uint32_t stride;
40    uint32_t offset;
41    uint32_t layer_stride;
42 };
43 
44 struct lima_damage_region {
45    struct pipe_scissor_state *region;
46    struct pipe_scissor_state bound;
47    unsigned num_region;
48    bool aligned;
49 };
50 
51 struct lima_resource {
52    struct pipe_resource base;
53 
54    struct lima_damage_region damage;
55    struct renderonly_scanout *scanout;
56    struct lima_bo *bo;
57    struct panfrost_minmax_cache *index_cache;
58    bool tiled;
59    bool modifier_constant;
60    unsigned full_updates;
61 
62    struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS];
63 };
64 
65 struct lima_surface {
66    struct pipe_surface base;
67    int tiled_w, tiled_h;
68    unsigned reload;
69 };
70 
71 struct lima_transfer {
72    struct pipe_transfer base;
73    void *staging;
74 };
75 
76 static inline struct lima_resource *
lima_resource(struct pipe_resource * res)77 lima_resource(struct pipe_resource *res)
78 {
79    return (struct lima_resource *)res;
80 }
81 
82 static inline struct lima_surface *
lima_surface(struct pipe_surface * surf)83 lima_surface(struct pipe_surface *surf)
84 {
85    return (struct lima_surface *)surf;
86 }
87 
88 static inline struct lima_transfer *
lima_transfer(struct pipe_transfer * trans)89 lima_transfer(struct pipe_transfer *trans)
90 {
91    return (struct lima_transfer *)trans;
92 }
93 
94 void
95 lima_resource_screen_init(struct lima_screen *screen);
96 
97 void
98 lima_resource_context_init(struct lima_context *ctx);
99 
100 #endif
101