xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/etnaviv/etnaviv_screen.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright (c) 2012-2015 Etnaviv 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  * Authors:
24  *    Wladimir J. van der Laan <[email protected]>
25  *    Christian Gmeiner <[email protected]>
26  */
27 
28 #ifndef H_ETNAVIV_SCREEN
29 #define H_ETNAVIV_SCREEN
30 
31 #include "etna_core_info.h"
32 #include "etnaviv_internal.h"
33 #include "etnaviv_perfmon.h"
34 
35 #include "util/u_thread.h"
36 #include "pipe/p_screen.h"
37 #include "renderonly/renderonly.h"
38 #include "util/set.h"
39 #include "util/slab.h"
40 #include "util/u_dynarray.h"
41 #include "util/u_helpers.h"
42 #include "util/u_queue.h"
43 #include "compiler/nir/nir.h"
44 
45 struct etna_bo;
46 
47 struct etna_screen {
48    struct pipe_screen base;
49 
50    struct etna_device *dev;
51    struct etna_gpu *gpu;
52    struct etna_gpu *npu;
53    struct etna_pipe *pipe;
54    struct etna_pipe *pipe_nn;
55    struct etna_perfmon *perfmon;
56    struct renderonly *ro;
57 
58    struct util_dynarray supported_pm_queries;
59    struct slab_parent_pool transfer_pool;
60 
61    struct etna_core_info *info;
62 
63    struct etna_specs specs;
64 
65    uint32_t drm_version;
66 
67    struct etna_compiler *compiler;
68    struct util_queue shader_compiler_queue;
69 
70    /* dummy render target for GPUs that can't fully disable the color pipe */
71    struct etna_reloc dummy_rt_reloc;
72 
73    /* dummy texture descriptor */
74    struct etna_reloc dummy_desc_reloc;
75 };
76 
77 static inline bool
VIV_FEATURE(const struct etna_screen * screen,enum etna_feature feature)78 VIV_FEATURE(const struct etna_screen *screen, enum etna_feature feature)
79 {
80    return etna_core_has_feature(screen->info, feature);
81 }
82 
83 static inline struct etna_screen *
etna_screen(struct pipe_screen * pscreen)84 etna_screen(struct pipe_screen *pscreen)
85 {
86    return (struct etna_screen *)pscreen;
87 }
88 
89 struct etna_bo *
90 etna_screen_bo_from_handle(struct pipe_screen *pscreen,
91                            struct winsys_handle *whandle);
92 
93 struct pipe_screen *
94 etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
95                    struct etna_gpu *npu, struct renderonly *ro);
96 
97 static inline size_t
etna_screen_get_tile_size(struct etna_screen * screen,uint8_t ts_mode,bool is_msaa)98 etna_screen_get_tile_size(struct etna_screen *screen, uint8_t ts_mode,
99                           bool is_msaa)
100 {
101    if (!VIV_FEATURE(screen, ETNA_FEATURE_CACHE128B256BPERLINE)) {
102       if (VIV_FEATURE(screen, ETNA_FEATURE_SMALL_MSAA) && is_msaa)
103          return 256;
104       return 64;
105    }
106 
107    if (ts_mode == TS_MODE_256B)
108       return 256;
109    else
110       return 128;
111 }
112 
113 #endif
114