• 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 "etnaviv_internal.h"
32 #include "etnaviv_perfmon.h"
33 
34 #include "util/u_thread.h"
35 #include "pipe/p_screen.h"
36 #include "renderonly/renderonly.h"
37 #include "util/set.h"
38 #include "util/slab.h"
39 #include "util/u_dynarray.h"
40 #include "util/u_helpers.h"
41 #include "util/u_queue.h"
42 #include "compiler/nir/nir.h"
43 
44 struct etna_bo;
45 
46 /* Enum with indices for each of the feature words */
47 enum viv_features_word {
48    viv_chipFeatures = 0,
49    viv_chipMinorFeatures0 = 1,
50    viv_chipMinorFeatures1 = 2,
51    viv_chipMinorFeatures2 = 3,
52    viv_chipMinorFeatures3 = 4,
53    viv_chipMinorFeatures4 = 5,
54    viv_chipMinorFeatures5 = 6,
55    viv_chipMinorFeatures6 = 7,
56    viv_chipMinorFeatures7 = 8,
57    viv_chipMinorFeatures8 = 9,
58    viv_chipMinorFeatures9 = 10,
59    viv_chipMinorFeatures10 = 11,
60    viv_chipMinorFeatures11 = 12,
61    viv_chipMinorFeatures12 = 13,
62    VIV_FEATURES_WORD_COUNT /* Must be last */
63 };
64 
65 /** Convenience macro to probe features from state.xml.h:
66  * VIV_FEATURE(chipFeatures, FAST_CLEAR)
67  * VIV_FEATURE(chipMinorFeatures1, AUTO_DISABLE)
68  */
69 #define VIV_FEATURE(screen, word, feature) \
70    ((screen->features[viv_ ## word] & (word ## _ ## feature)) != 0)
71 
72 struct etna_screen {
73    struct pipe_screen base;
74 
75    struct etna_device *dev;
76    struct etna_gpu *gpu;
77    struct etna_pipe *pipe;
78    struct etna_perfmon *perfmon;
79    struct renderonly *ro;
80 
81    struct util_dynarray supported_pm_queries;
82    struct slab_parent_pool transfer_pool;
83 
84    uint32_t model;
85    uint32_t revision;
86    uint32_t features[VIV_FEATURES_WORD_COUNT];
87 
88    struct etna_specs specs;
89 
90    uint32_t drm_version;
91 
92    struct etna_compiler *compiler;
93    struct util_queue shader_compiler_queue;
94 
95    /* dummy render target for GPUs that can't fully disable the color pipe */
96    struct etna_reloc dummy_rt_reloc;
97 
98    /* dummy texture descriptor */
99    struct etna_reloc dummy_desc_reloc;
100 };
101 
102 static inline struct etna_screen *
etna_screen(struct pipe_screen * pscreen)103 etna_screen(struct pipe_screen *pscreen)
104 {
105    return (struct etna_screen *)pscreen;
106 }
107 
108 struct etna_bo *
109 etna_screen_bo_from_handle(struct pipe_screen *pscreen,
110                            struct winsys_handle *whandle);
111 
112 struct pipe_screen *
113 etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
114                    struct renderonly *ro);
115 
116 static inline size_t
etna_screen_get_tile_size(struct etna_screen * screen,uint8_t ts_mode,bool is_msaa)117 etna_screen_get_tile_size(struct etna_screen *screen, uint8_t ts_mode,
118                           bool is_msaa)
119 {
120    if (!VIV_FEATURE(screen, chipMinorFeatures6, CACHE128B256BPERLINE)) {
121       if (VIV_FEATURE(screen, chipMinorFeatures4, SMALL_MSAA) && is_msaa)
122          return 256;
123       return 64;
124    }
125 
126    if (ts_mode == TS_MODE_256B)
127       return 256;
128    else
129       return 128;
130 }
131 
132 #endif
133