• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <laanwj@gmail.com>
25  *    Christian Gmeiner <christian.gmeiner@gmail.com>
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 BO available to user that don't care about the content */
71    struct etna_bo *dummy_bo;
72 
73    /* dummy render target for GPUs that can't fully disable the color pipe */
74    struct etna_reloc dummy_rt_reloc;
75 
76    /* dummy texture descriptor */
77    struct etna_reloc dummy_desc_reloc;
78 };
79 
80 static inline bool
VIV_FEATURE(const struct etna_screen * screen,enum etna_feature feature)81 VIV_FEATURE(const struct etna_screen *screen, enum etna_feature feature)
82 {
83    return etna_core_has_feature(screen->info, feature);
84 }
85 
86 static inline struct etna_screen *
etna_screen(struct pipe_screen * pscreen)87 etna_screen(struct pipe_screen *pscreen)
88 {
89    return (struct etna_screen *)pscreen;
90 }
91 
92 struct etna_bo *
93 etna_screen_bo_from_handle(struct pipe_screen *pscreen,
94                            struct winsys_handle *whandle);
95 
96 struct pipe_screen *
97 etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
98                    struct etna_gpu *npu, struct renderonly *ro);
99 
100 static inline size_t
etna_screen_get_tile_size(struct etna_screen * screen,uint8_t ts_mode,bool is_msaa)101 etna_screen_get_tile_size(struct etna_screen *screen, uint8_t ts_mode,
102                           bool is_msaa)
103 {
104    if (!VIV_FEATURE(screen, ETNA_FEATURE_CACHE128B256BPERLINE)) {
105       if (VIV_FEATURE(screen, ETNA_FEATURE_SMALL_MSAA) && is_msaa)
106          return 256;
107       return 64;
108    }
109 
110    if (ts_mode == TS_MODE_256B)
111       return 256;
112    else
113       return 128;
114 }
115 
116 #endif
117