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 #include "etnaviv_screen.h"
29
30 #include "hw/common.xml.h"
31
32 #include "etnaviv_compiler.h"
33 #include "etnaviv_context.h"
34 #include "etnaviv_debug.h"
35 #include "etnaviv_fence.h"
36 #include "etnaviv_format.h"
37 #include "etnaviv_query.h"
38 #include "etnaviv_resource.h"
39 #include "etnaviv_translate.h"
40
41 #include "util/hash_table.h"
42 #include "util/os_time.h"
43 #include "util/u_math.h"
44 #include "util/u_memory.h"
45 #include "util/u_screen.h"
46 #include "util/u_string.h"
47
48 #include "frontend/drm_driver.h"
49
50 #include "drm-uapi/drm_fourcc.h"
51
52 #define ETNA_DRM_VERSION(major, minor) ((major) << 16 | (minor))
53 #define ETNA_DRM_VERSION_FENCE_FD ETNA_DRM_VERSION(1, 1)
54 #define ETNA_DRM_VERSION_PERFMON ETNA_DRM_VERSION(1, 2)
55
56 static const struct debug_named_value debug_options[] = {
57 {"dbg_msgs", ETNA_DBG_MSGS, "Print debug messages"},
58 {"frame_msgs", ETNA_DBG_FRAME_MSGS, "Print frame messages"},
59 {"resource_msgs", ETNA_DBG_RESOURCE_MSGS, "Print resource messages"},
60 {"compiler_msgs", ETNA_DBG_COMPILER_MSGS, "Print compiler messages"},
61 {"linker_msgs", ETNA_DBG_LINKER_MSGS, "Print linker messages"},
62 {"dump_shaders", ETNA_DBG_DUMP_SHADERS, "Dump shaders"},
63 {"no_ts", ETNA_DBG_NO_TS, "Disable TS"},
64 {"no_autodisable", ETNA_DBG_NO_AUTODISABLE, "Disable autodisable"},
65 {"no_supertile", ETNA_DBG_NO_SUPERTILE, "Disable supertiles"},
66 {"no_early_z", ETNA_DBG_NO_EARLY_Z, "Disable early z"},
67 {"cflush_all", ETNA_DBG_CFLUSH_ALL, "Flush every cache before state update"},
68 {"msaa2x", ETNA_DBG_MSAA_2X, "Force 2x msaa"},
69 {"msaa4x", ETNA_DBG_MSAA_4X, "Force 4x msaa"},
70 {"flush_all", ETNA_DBG_FLUSH_ALL, "Flush after every rendered primitive"},
71 {"zero", ETNA_DBG_ZERO, "Zero all resources after allocation"},
72 {"draw_stall", ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered primitive"},
73 {"shaderdb", ETNA_DBG_SHADERDB, "Enable shaderdb output"},
74 {"no_singlebuffer",ETNA_DBG_NO_SINGLEBUF, "Disable single buffer feature"},
75 {"nir", ETNA_DBG_NIR, "use new NIR compiler"},
76 {"deqp", ETNA_DBG_DEQP, "Hacks to run dEQP GLES3 tests"}, /* needs MESA_GLES_VERSION_OVERRIDE=3.0 */
77 {"nocache", ETNA_DBG_NOCACHE, "Disable shader cache"},
78 DEBUG_NAMED_VALUE_END
79 };
80
81 DEBUG_GET_ONCE_FLAGS_OPTION(etna_mesa_debug, "ETNA_MESA_DEBUG", debug_options, 0)
82 int etna_mesa_debug = 0;
83
84 static void
etna_screen_destroy(struct pipe_screen * pscreen)85 etna_screen_destroy(struct pipe_screen *pscreen)
86 {
87 struct etna_screen *screen = etna_screen(pscreen);
88
89 if (screen->perfmon)
90 etna_perfmon_del(screen->perfmon);
91
92 if (screen->compiler)
93 etna_compiler_destroy(screen->compiler);
94
95 if (screen->pipe)
96 etna_pipe_del(screen->pipe);
97
98 if (screen->gpu)
99 etna_gpu_del(screen->gpu);
100
101 if (screen->ro)
102 FREE(screen->ro);
103
104 if (screen->dev)
105 etna_device_del(screen->dev);
106
107 FREE(screen);
108 }
109
110 static const char *
etna_screen_get_name(struct pipe_screen * pscreen)111 etna_screen_get_name(struct pipe_screen *pscreen)
112 {
113 struct etna_screen *priv = etna_screen(pscreen);
114 static char buffer[128];
115
116 snprintf(buffer, sizeof(buffer), "Vivante GC%x rev %04x", priv->model,
117 priv->revision);
118
119 return buffer;
120 }
121
122 static const char *
etna_screen_get_vendor(struct pipe_screen * pscreen)123 etna_screen_get_vendor(struct pipe_screen *pscreen)
124 {
125 return "etnaviv";
126 }
127
128 static const char *
etna_screen_get_device_vendor(struct pipe_screen * pscreen)129 etna_screen_get_device_vendor(struct pipe_screen *pscreen)
130 {
131 return "Vivante";
132 }
133
134 static int
etna_screen_get_param(struct pipe_screen * pscreen,enum pipe_cap param)135 etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
136 {
137 struct etna_screen *screen = etna_screen(pscreen);
138
139 switch (param) {
140 /* Supported features (boolean caps). */
141 case PIPE_CAP_POINT_SPRITE:
142 case PIPE_CAP_BLEND_EQUATION_SEPARATE:
143 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
144 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
145 case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD:
146 case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
147 case PIPE_CAP_VERTEX_SHADER_SATURATE:
148 case PIPE_CAP_TEXTURE_BARRIER:
149 case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
150 case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
151 case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
152 case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
153 case PIPE_CAP_TGSI_TEXCOORD:
154 case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
155 case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
156 case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
157 case PIPE_CAP_STRING_MARKER:
158 case PIPE_CAP_SHAREABLE_SHADERS:
159 return 1;
160 case PIPE_CAP_NATIVE_FENCE_FD:
161 return screen->drm_version >= ETNA_DRM_VERSION_FENCE_FD;
162 case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
163 case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: /* note: not integer */
164 return DBG_ENABLED(ETNA_DBG_NIR);
165 case PIPE_CAP_TGSI_FS_POINT_IS_SYSVAL:
166 return 0;
167
168 /* Memory */
169 case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
170 return 256;
171 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
172 return 4; /* XXX could easily be supported */
173
174 case PIPE_CAP_NPOT_TEXTURES:
175 return true; /* VIV_FEATURE(priv->dev, chipMinorFeatures1,
176 NON_POWER_OF_TWO); */
177
178 case PIPE_CAP_ANISOTROPIC_FILTER:
179 case PIPE_CAP_TEXTURE_SWIZZLE:
180 case PIPE_CAP_PRIMITIVE_RESTART:
181 case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
182 return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
183
184 /* Unsupported features. */
185 case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
186 case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
187 case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
188 return 0;
189
190 /* Stream output. */
191 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
192 return DBG_ENABLED(ETNA_DBG_DEQP) ? 4 : 0;
193 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
194 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
195 return 0;
196
197 case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE:
198 return 128;
199 case PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET:
200 return 255;
201 case PIPE_CAP_MAX_VERTEX_BUFFERS:
202 return screen->specs.stream_count;
203 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
204 return VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
205
206
207 /* Texturing. */
208 case PIPE_CAP_TEXTURE_SHADOW_MAP:
209 return DBG_ENABLED(ETNA_DBG_NIR) && screen->specs.halti >= 2;
210 case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
211 case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: /* TODO: verify */
212 return screen->specs.max_texture_size;
213 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
214 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
215 {
216 int log2_max_tex_size = util_last_bit(screen->specs.max_texture_size);
217 assert(log2_max_tex_size > 0);
218 return log2_max_tex_size;
219 }
220
221 case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
222 case PIPE_CAP_MIN_TEXEL_OFFSET:
223 return -8;
224 case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET:
225 case PIPE_CAP_MAX_TEXEL_OFFSET:
226 return 7;
227 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
228 return screen->specs.seamless_cube_map;
229
230 /* Queries. */
231 case PIPE_CAP_OCCLUSION_QUERY:
232 return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
233
234 /* Preferences */
235 case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
236 return 0;
237 case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET: {
238 /* etnaviv is being run on systems as small as 256MB total RAM so
239 * we need to provide a sane value for such a device. Limit the
240 * memory budget to min(~3% of pyhiscal memory, 64MB).
241 *
242 * a simple divison by 32 provides the numbers we want.
243 * 256MB / 32 = 8MB
244 * 2048MB / 32 = 64MB
245 */
246 uint64_t system_memory;
247
248 if (!os_get_total_physical_memory(&system_memory))
249 system_memory = (uint64_t)4096 << 20;
250
251 return MIN2(system_memory / 32, 64 * 1024 * 1024);
252 }
253
254 case PIPE_CAP_MAX_VARYINGS:
255 return screen->specs.max_varyings;
256
257 case PIPE_CAP_PCI_GROUP:
258 case PIPE_CAP_PCI_BUS:
259 case PIPE_CAP_PCI_DEVICE:
260 case PIPE_CAP_PCI_FUNCTION:
261 return 0;
262 case PIPE_CAP_ACCELERATED:
263 return 1;
264 case PIPE_CAP_VIDEO_MEMORY:
265 return 0;
266 case PIPE_CAP_UMA:
267 return 1;
268 default:
269 return u_pipe_screen_get_param_defaults(pscreen, param);
270 }
271 }
272
273 static float
etna_screen_get_paramf(struct pipe_screen * pscreen,enum pipe_capf param)274 etna_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param)
275 {
276 struct etna_screen *screen = etna_screen(pscreen);
277
278 switch (param) {
279 case PIPE_CAPF_MAX_LINE_WIDTH:
280 case PIPE_CAPF_MAX_LINE_WIDTH_AA:
281 case PIPE_CAPF_MAX_POINT_WIDTH:
282 case PIPE_CAPF_MAX_POINT_WIDTH_AA:
283 return 8192.0f;
284 case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
285 return 16.0f;
286 case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
287 return util_last_bit(screen->specs.max_texture_size);
288 case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE:
289 case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE:
290 case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY:
291 return 0.0f;
292 }
293
294 debug_printf("unknown paramf %d", param);
295 return 0;
296 }
297
298 static int
etna_screen_get_shader_param(struct pipe_screen * pscreen,enum pipe_shader_type shader,enum pipe_shader_cap param)299 etna_screen_get_shader_param(struct pipe_screen *pscreen,
300 enum pipe_shader_type shader,
301 enum pipe_shader_cap param)
302 {
303 struct etna_screen *screen = etna_screen(pscreen);
304 bool ubo_enable = screen->specs.halti >= 2 && DBG_ENABLED(ETNA_DBG_NIR);
305
306 if (DBG_ENABLED(ETNA_DBG_DEQP))
307 ubo_enable = true;
308
309 switch (shader) {
310 case PIPE_SHADER_FRAGMENT:
311 case PIPE_SHADER_VERTEX:
312 break;
313 case PIPE_SHADER_COMPUTE:
314 case PIPE_SHADER_GEOMETRY:
315 case PIPE_SHADER_TESS_CTRL:
316 case PIPE_SHADER_TESS_EVAL:
317 return 0;
318 default:
319 DBG("unknown shader type %d", shader);
320 return 0;
321 }
322
323 switch (param) {
324 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
325 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
326 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
327 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
328 return ETNA_MAX_TOKENS;
329 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
330 return ETNA_MAX_DEPTH; /* XXX */
331 case PIPE_SHADER_CAP_MAX_INPUTS:
332 /* Maximum number of inputs for the vertex shader is the number
333 * of vertex elements - each element defines one vertex shader
334 * input register. For the fragment shader, this is the number
335 * of varyings. */
336 return shader == PIPE_SHADER_FRAGMENT ? screen->specs.max_varyings
337 : screen->specs.vertex_max_elements;
338 case PIPE_SHADER_CAP_MAX_OUTPUTS:
339 return 16; /* see VIVS_VS_OUTPUT */
340 case PIPE_SHADER_CAP_MAX_TEMPS:
341 return 64; /* Max native temporaries. */
342 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
343 return ubo_enable ? ETNA_MAX_CONST_BUF : 1;
344 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
345 return 1;
346 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
347 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
348 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
349 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
350 return 1;
351 case PIPE_SHADER_CAP_SUBROUTINES:
352 return 0;
353 case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
354 return VIV_FEATURE(screen, chipMinorFeatures0, HAS_SQRT_TRIG);
355 case PIPE_SHADER_CAP_INT64_ATOMICS:
356 case PIPE_SHADER_CAP_FP16:
357 case PIPE_SHADER_CAP_FP16_DERIVATIVES:
358 case PIPE_SHADER_CAP_INT16:
359 case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS:
360 return 0;
361 case PIPE_SHADER_CAP_INTEGERS:
362 return DBG_ENABLED(ETNA_DBG_NIR) && screen->specs.halti >= 2;
363 case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
364 case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
365 return shader == PIPE_SHADER_FRAGMENT
366 ? screen->specs.fragment_sampler_count
367 : screen->specs.vertex_sampler_count;
368 case PIPE_SHADER_CAP_PREFERRED_IR:
369 return DBG_ENABLED(ETNA_DBG_NIR) ? PIPE_SHADER_IR_NIR : PIPE_SHADER_IR_TGSI;
370 case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
371 if (ubo_enable)
372 return 16384; /* 16384 so state tracker enables UBOs */
373 return shader == PIPE_SHADER_FRAGMENT
374 ? screen->specs.max_ps_uniforms * sizeof(float[4])
375 : screen->specs.max_vs_uniforms * sizeof(float[4]);
376 case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED:
377 case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED:
378 case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED:
379 case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED:
380 case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE:
381 return false;
382 case PIPE_SHADER_CAP_SUPPORTED_IRS:
383 return 0;
384 case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
385 return 32;
386 case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
387 case PIPE_SHADER_CAP_MAX_SHADER_IMAGES:
388 case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:
389 case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS:
390 case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
391 case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
392 return 0;
393 }
394
395 debug_printf("unknown shader param %d", param);
396 return 0;
397 }
398
399 static uint64_t
etna_screen_get_timestamp(struct pipe_screen * pscreen)400 etna_screen_get_timestamp(struct pipe_screen *pscreen)
401 {
402 return os_time_get_nano();
403 }
404
405 static bool
gpu_supports_texture_target(struct etna_screen * screen,enum pipe_texture_target target)406 gpu_supports_texture_target(struct etna_screen *screen,
407 enum pipe_texture_target target)
408 {
409 if (target == PIPE_TEXTURE_CUBE_ARRAY)
410 return false;
411
412 /* pre-halti has no array/3D */
413 if (screen->specs.halti < 0 &&
414 (target == PIPE_TEXTURE_1D_ARRAY ||
415 target == PIPE_TEXTURE_2D_ARRAY ||
416 target == PIPE_TEXTURE_3D))
417 return false;
418
419 return true;
420 }
421
422 static bool
gpu_supports_texture_format(struct etna_screen * screen,uint32_t fmt,enum pipe_format format)423 gpu_supports_texture_format(struct etna_screen *screen, uint32_t fmt,
424 enum pipe_format format)
425 {
426 bool supported = true;
427
428 if (fmt == TEXTURE_FORMAT_ETC1)
429 supported = VIV_FEATURE(screen, chipFeatures, ETC1_TEXTURE_COMPRESSION);
430
431 if (fmt >= TEXTURE_FORMAT_DXT1 && fmt <= TEXTURE_FORMAT_DXT4_DXT5)
432 supported = VIV_FEATURE(screen, chipFeatures, DXT_TEXTURE_COMPRESSION);
433
434 if (util_format_is_srgb(format))
435 supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
436
437 if (fmt & EXT_FORMAT)
438 supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
439
440 if (fmt & ASTC_FORMAT) {
441 supported = screen->specs.tex_astc;
442 }
443
444 if (util_format_is_snorm(format))
445 supported = VIV_FEATURE(screen, chipMinorFeatures2, HALTI1);
446
447 if (format != PIPE_FORMAT_S8_UINT_Z24_UNORM &&
448 (util_format_is_pure_integer(format) || util_format_is_float(format)))
449 supported = VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
450
451
452 if (!supported)
453 return false;
454
455 if (texture_format_needs_swiz(format))
456 return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
457
458 return true;
459 }
460
461 static bool
gpu_supports_render_format(struct etna_screen * screen,enum pipe_format format,unsigned sample_count)462 gpu_supports_render_format(struct etna_screen *screen, enum pipe_format format,
463 unsigned sample_count)
464 {
465 const uint32_t fmt = translate_pe_format(format);
466
467 if (fmt == ETNA_NO_MATCH)
468 return false;
469
470 /* MSAA is broken */
471 if (sample_count > 1)
472 return false;
473
474 if (format == PIPE_FORMAT_R8_UNORM)
475 return VIV_FEATURE(screen, chipMinorFeatures5, HALTI5);
476
477 /* figure out 8bpp RS clear to enable these formats */
478 if (format == PIPE_FORMAT_R8_SINT || format == PIPE_FORMAT_R8_UINT)
479 return VIV_FEATURE(screen, chipMinorFeatures5, HALTI5);
480
481 if (util_format_is_srgb(format))
482 return VIV_FEATURE(screen, chipMinorFeatures5, HALTI3);
483
484 if (util_format_is_pure_integer(format) || util_format_is_float(format))
485 return VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
486
487 if (format == PIPE_FORMAT_R8G8_UNORM)
488 return VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
489
490 /* any other extended format is HALTI0 (only R10G10B10A2?) */
491 if (fmt >= PE_FORMAT_R16F)
492 return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
493
494 return true;
495 }
496
497 static bool
gpu_supports_vertex_format(struct etna_screen * screen,enum pipe_format format)498 gpu_supports_vertex_format(struct etna_screen *screen, enum pipe_format format)
499 {
500 if (translate_vertex_format_type(format) == ETNA_NO_MATCH)
501 return false;
502
503 if (util_format_is_pure_integer(format))
504 return VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
505
506 return true;
507 }
508
509 static bool
etna_screen_is_format_supported(struct pipe_screen * pscreen,enum pipe_format format,enum pipe_texture_target target,unsigned sample_count,unsigned storage_sample_count,unsigned usage)510 etna_screen_is_format_supported(struct pipe_screen *pscreen,
511 enum pipe_format format,
512 enum pipe_texture_target target,
513 unsigned sample_count,
514 unsigned storage_sample_count,
515 unsigned usage)
516 {
517 struct etna_screen *screen = etna_screen(pscreen);
518 unsigned allowed = 0;
519
520 if (!gpu_supports_texture_target(screen, target))
521 return false;
522
523 if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
524 return false;
525
526 if (usage & PIPE_BIND_RENDER_TARGET) {
527 if (gpu_supports_render_format(screen, format, sample_count))
528 allowed |= PIPE_BIND_RENDER_TARGET;
529 }
530
531 if (usage & PIPE_BIND_DEPTH_STENCIL) {
532 if (translate_depth_format(format) != ETNA_NO_MATCH)
533 allowed |= PIPE_BIND_DEPTH_STENCIL;
534 }
535
536 if (usage & PIPE_BIND_SAMPLER_VIEW) {
537 uint32_t fmt = translate_texture_format(format);
538
539 if (!gpu_supports_texture_format(screen, fmt, format))
540 fmt = ETNA_NO_MATCH;
541
542 if (sample_count < 2 && fmt != ETNA_NO_MATCH)
543 allowed |= PIPE_BIND_SAMPLER_VIEW;
544 }
545
546 if (usage & PIPE_BIND_VERTEX_BUFFER) {
547 if (gpu_supports_vertex_format(screen, format))
548 allowed |= PIPE_BIND_VERTEX_BUFFER;
549 }
550
551 if (usage & PIPE_BIND_INDEX_BUFFER) {
552 /* must be supported index format */
553 if (format == PIPE_FORMAT_I8_UINT || format == PIPE_FORMAT_I16_UINT ||
554 (format == PIPE_FORMAT_I32_UINT &&
555 VIV_FEATURE(screen, chipFeatures, 32_BIT_INDICES))) {
556 allowed |= PIPE_BIND_INDEX_BUFFER;
557 }
558 }
559
560 /* Always allowed */
561 allowed |=
562 usage & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
563
564 if (usage != allowed) {
565 DBG("not supported: format=%s, target=%d, sample_count=%d, "
566 "usage=%x, allowed=%x",
567 util_format_name(format), target, sample_count, usage, allowed);
568 }
569
570 return usage == allowed;
571 }
572
573 const uint64_t supported_modifiers[] = {
574 DRM_FORMAT_MOD_LINEAR,
575 DRM_FORMAT_MOD_VIVANTE_TILED,
576 DRM_FORMAT_MOD_VIVANTE_SUPER_TILED,
577 DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED,
578 DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED,
579 };
580
581 static void
etna_screen_query_dmabuf_modifiers(struct pipe_screen * pscreen,enum pipe_format format,int max,uint64_t * modifiers,unsigned int * external_only,int * count)582 etna_screen_query_dmabuf_modifiers(struct pipe_screen *pscreen,
583 enum pipe_format format, int max,
584 uint64_t *modifiers,
585 unsigned int *external_only, int *count)
586 {
587 struct etna_screen *screen = etna_screen(pscreen);
588 int i, num_modifiers = 0;
589
590 if (max > ARRAY_SIZE(supported_modifiers))
591 max = ARRAY_SIZE(supported_modifiers);
592
593 if (!max) {
594 modifiers = NULL;
595 max = ARRAY_SIZE(supported_modifiers);
596 }
597
598 for (i = 0; num_modifiers < max; i++) {
599 /* don't advertise split tiled formats on single pipe/buffer GPUs */
600 if ((screen->specs.pixel_pipes == 1 || screen->specs.single_buffer) &&
601 i >= 3)
602 break;
603
604 if (modifiers)
605 modifiers[num_modifiers] = supported_modifiers[i];
606 if (external_only)
607 external_only[num_modifiers] = util_format_is_yuv(format) ? 1 : 0;
608 num_modifiers++;
609 }
610
611 *count = num_modifiers;
612 }
613
614 static void
etna_determine_uniform_limits(struct etna_screen * screen)615 etna_determine_uniform_limits(struct etna_screen *screen)
616 {
617 /* values for the non unified case are taken from
618 * gcmCONFIGUREUNIFORMS in the Vivante kernel driver file
619 * drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h.
620 */
621 if (screen->model == chipModel_GC2000 &&
622 (screen->revision == 0x5118 || screen->revision == 0x5140)) {
623 screen->specs.max_vs_uniforms = 256;
624 screen->specs.max_ps_uniforms = 64;
625 } else if (screen->specs.num_constants == 320) {
626 screen->specs.max_vs_uniforms = 256;
627 screen->specs.max_ps_uniforms = 64;
628 } else if (screen->specs.num_constants > 256 &&
629 screen->model == chipModel_GC1000) {
630 /* All GC1000 series chips can only support 64 uniforms for ps on non-unified const mode. */
631 screen->specs.max_vs_uniforms = 256;
632 screen->specs.max_ps_uniforms = 64;
633 } else if (screen->specs.num_constants > 256) {
634 screen->specs.max_vs_uniforms = 256;
635 screen->specs.max_ps_uniforms = 256;
636 } else if (screen->specs.num_constants == 256) {
637 screen->specs.max_vs_uniforms = 256;
638 screen->specs.max_ps_uniforms = 256;
639 } else {
640 screen->specs.max_vs_uniforms = 168;
641 screen->specs.max_ps_uniforms = 64;
642 }
643 }
644
645 static bool
etna_get_specs(struct etna_screen * screen)646 etna_get_specs(struct etna_screen *screen)
647 {
648 uint64_t val;
649 uint32_t instruction_count;
650
651 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_INSTRUCTION_COUNT, &val)) {
652 DBG("could not get ETNA_GPU_INSTRUCTION_COUNT");
653 goto fail;
654 }
655 instruction_count = val;
656
657 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_VERTEX_OUTPUT_BUFFER_SIZE,
658 &val)) {
659 DBG("could not get ETNA_GPU_VERTEX_OUTPUT_BUFFER_SIZE");
660 goto fail;
661 }
662 screen->specs.vertex_output_buffer_size = val;
663
664 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_VERTEX_CACHE_SIZE, &val)) {
665 DBG("could not get ETNA_GPU_VERTEX_CACHE_SIZE");
666 goto fail;
667 }
668 screen->specs.vertex_cache_size = val;
669
670 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_SHADER_CORE_COUNT, &val)) {
671 DBG("could not get ETNA_GPU_SHADER_CORE_COUNT");
672 goto fail;
673 }
674 screen->specs.shader_core_count = val;
675
676 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_STREAM_COUNT, &val)) {
677 DBG("could not get ETNA_GPU_STREAM_COUNT");
678 goto fail;
679 }
680 screen->specs.stream_count = val;
681
682 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_REGISTER_MAX, &val)) {
683 DBG("could not get ETNA_GPU_REGISTER_MAX");
684 goto fail;
685 }
686 screen->specs.max_registers = val;
687
688 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_PIXEL_PIPES, &val)) {
689 DBG("could not get ETNA_GPU_PIXEL_PIPES");
690 goto fail;
691 }
692 screen->specs.pixel_pipes = val;
693
694 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_NUM_CONSTANTS, &val)) {
695 DBG("could not get %s", "ETNA_GPU_NUM_CONSTANTS");
696 goto fail;
697 }
698 if (val == 0) {
699 fprintf(stderr, "Warning: zero num constants (update kernel?)\n");
700 val = 168;
701 }
702 screen->specs.num_constants = val;
703
704 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_NUM_VARYINGS, &val)) {
705 DBG("could not get ETNA_GPU_NUM_VARYINGS");
706 goto fail;
707 }
708 screen->specs.max_varyings = MAX2(val, ETNA_NUM_VARYINGS);
709
710 /* Figure out gross GPU architecture. See rnndb/common.xml for a specific
711 * description of the differences. */
712 if (VIV_FEATURE(screen, chipMinorFeatures5, HALTI5))
713 screen->specs.halti = 5; /* New GC7000/GC8x00 */
714 else if (VIV_FEATURE(screen, chipMinorFeatures5, HALTI4))
715 screen->specs.halti = 4; /* Old GC7000/GC7400 */
716 else if (VIV_FEATURE(screen, chipMinorFeatures5, HALTI3))
717 screen->specs.halti = 3; /* None? */
718 else if (VIV_FEATURE(screen, chipMinorFeatures4, HALTI2))
719 screen->specs.halti = 2; /* GC2500/GC3000/GC5000/GC6400 */
720 else if (VIV_FEATURE(screen, chipMinorFeatures2, HALTI1))
721 screen->specs.halti = 1; /* GC900/GC4000/GC7000UL */
722 else if (VIV_FEATURE(screen, chipMinorFeatures1, HALTI0))
723 screen->specs.halti = 0; /* GC880/GC2000/GC7000TM */
724 else
725 screen->specs.halti = -1; /* GC7000nanolite / pre-GC2000 except GC880 */
726 if (screen->specs.halti >= 0)
727 DBG("etnaviv: GPU arch: HALTI%d", screen->specs.halti);
728 else
729 DBG("etnaviv: GPU arch: pre-HALTI");
730
731 screen->specs.can_supertile =
732 VIV_FEATURE(screen, chipMinorFeatures0, SUPER_TILED);
733 screen->specs.bits_per_tile =
734 VIV_FEATURE(screen, chipMinorFeatures0, 2BITPERTILE) ? 2 : 4;
735 screen->specs.ts_clear_value =
736 VIV_FEATURE(screen, chipMinorFeatures5, BLT_ENGINE) ? 0xffffffff :
737 VIV_FEATURE(screen, chipMinorFeatures0, 2BITPERTILE) ? 0x55555555 :
738 0x11111111;
739
740
741 /* vertex and fragment samplers live in one address space */
742 screen->specs.vertex_sampler_offset = 8;
743 screen->specs.fragment_sampler_count = 8;
744 screen->specs.vertex_sampler_count = 4;
745
746 if (screen->model == 0x400)
747 screen->specs.vertex_sampler_count = 0;
748
749 screen->specs.vs_need_z_div =
750 screen->model < 0x1000 && screen->model != 0x880;
751 screen->specs.has_sin_cos_sqrt =
752 VIV_FEATURE(screen, chipMinorFeatures0, HAS_SQRT_TRIG);
753 screen->specs.has_sign_floor_ceil =
754 VIV_FEATURE(screen, chipMinorFeatures0, HAS_SIGN_FLOOR_CEIL);
755 screen->specs.has_shader_range_registers =
756 screen->model >= 0x1000 || screen->model == 0x880;
757 screen->specs.npot_tex_any_wrap =
758 VIV_FEATURE(screen, chipMinorFeatures1, NON_POWER_OF_TWO);
759 screen->specs.has_new_transcendentals =
760 VIV_FEATURE(screen, chipMinorFeatures3, HAS_FAST_TRANSCENDENTALS);
761 screen->specs.has_halti2_instructions =
762 VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
763 screen->specs.v4_compression =
764 VIV_FEATURE(screen, chipMinorFeatures6, V4_COMPRESSION);
765 screen->specs.seamless_cube_map =
766 (screen->model != 0x880) && /* Seamless cubemap is broken on GC880? */
767 VIV_FEATURE(screen, chipMinorFeatures2, SEAMLESS_CUBE_MAP);
768
769 if (screen->specs.halti >= 5) {
770 /* GC7000 - this core must load shaders from memory. */
771 screen->specs.vs_offset = 0;
772 screen->specs.ps_offset = 0;
773 screen->specs.max_instructions = 0; /* Do not program shaders manually */
774 screen->specs.has_icache = true;
775 } else if (VIV_FEATURE(screen, chipMinorFeatures3, INSTRUCTION_CACHE)) {
776 /* GC3000 - this core is capable of loading shaders from
777 * memory. It can also run shaders from registers, as a fallback, but
778 * "max_instructions" does not have the correct value. It has place for
779 * 2*256 instructions just like GC2000, but the offsets are slightly
780 * different.
781 */
782 screen->specs.vs_offset = 0xC000;
783 /* State 08000-0C000 mirrors 0C000-0E000, and the Vivante driver uses
784 * this mirror for writing PS instructions, probably safest to do the
785 * same.
786 */
787 screen->specs.ps_offset = 0x8000 + 0x1000;
788 screen->specs.max_instructions = 256; /* maximum number instructions for non-icache use */
789 screen->specs.has_icache = true;
790 } else {
791 if (instruction_count > 256) { /* unified instruction memory? */
792 screen->specs.vs_offset = 0xC000;
793 screen->specs.ps_offset = 0xD000; /* like vivante driver */
794 screen->specs.max_instructions = 256;
795 } else {
796 screen->specs.vs_offset = 0x4000;
797 screen->specs.ps_offset = 0x6000;
798 screen->specs.max_instructions = instruction_count / 2;
799 }
800 screen->specs.has_icache = false;
801 }
802
803 if (VIV_FEATURE(screen, chipMinorFeatures1, HALTI0)) {
804 screen->specs.vertex_max_elements = 16;
805 } else {
806 /* Etna_viv documentation seems confused over the correct value
807 * here so choose the lower to be safe: HALTI0 says 16 i.s.o.
808 * 10, but VERTEX_ELEMENT_CONFIG register says 16 i.s.o. 12. */
809 screen->specs.vertex_max_elements = 10;
810 }
811
812 etna_determine_uniform_limits(screen);
813
814 if (screen->specs.halti >= 5) {
815 screen->specs.has_unified_uniforms = true;
816 screen->specs.vs_uniforms_offset = VIVS_SH_HALTI5_UNIFORMS_MIRROR(0);
817 screen->specs.ps_uniforms_offset = VIVS_SH_HALTI5_UNIFORMS(screen->specs.max_vs_uniforms*4);
818 } else if (screen->specs.halti >= 1) {
819 /* unified uniform memory on GC3000 - HALTI1 feature bit is just a guess
820 */
821 screen->specs.has_unified_uniforms = true;
822 screen->specs.vs_uniforms_offset = VIVS_SH_UNIFORMS(0);
823 /* hardcode PS uniforms to start after end of VS uniforms -
824 * for more flexibility this offset could be variable based on the
825 * shader.
826 */
827 screen->specs.ps_uniforms_offset = VIVS_SH_UNIFORMS(screen->specs.max_vs_uniforms*4);
828 } else {
829 screen->specs.has_unified_uniforms = false;
830 screen->specs.vs_uniforms_offset = VIVS_VS_UNIFORMS(0);
831 screen->specs.ps_uniforms_offset = VIVS_PS_UNIFORMS(0);
832 }
833
834 screen->specs.max_texture_size =
835 VIV_FEATURE(screen, chipMinorFeatures0, TEXTURE_8K) ? 8192 : 2048;
836 screen->specs.max_rendertarget_size =
837 VIV_FEATURE(screen, chipMinorFeatures0, RENDERTARGET_8K) ? 8192 : 2048;
838
839 screen->specs.single_buffer = VIV_FEATURE(screen, chipMinorFeatures4, SINGLE_BUFFER);
840 if (screen->specs.single_buffer)
841 DBG("etnaviv: Single buffer mode enabled with %d pixel pipes", screen->specs.pixel_pipes);
842
843 screen->specs.tex_astc = VIV_FEATURE(screen, chipMinorFeatures4, TEXTURE_ASTC) &&
844 !VIV_FEATURE(screen, chipMinorFeatures6, NO_ASTC);
845
846 screen->specs.use_blt = VIV_FEATURE(screen, chipMinorFeatures5, BLT_ENGINE);
847
848 return true;
849
850 fail:
851 return false;
852 }
853
854 struct etna_bo *
etna_screen_bo_from_handle(struct pipe_screen * pscreen,struct winsys_handle * whandle)855 etna_screen_bo_from_handle(struct pipe_screen *pscreen,
856 struct winsys_handle *whandle)
857 {
858 struct etna_screen *screen = etna_screen(pscreen);
859 struct etna_bo *bo;
860
861 if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) {
862 bo = etna_bo_from_name(screen->dev, whandle->handle);
863 } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
864 bo = etna_bo_from_dmabuf(screen->dev, whandle->handle);
865 } else {
866 DBG("Attempt to import unsupported handle type %d", whandle->type);
867 return NULL;
868 }
869
870 if (!bo) {
871 DBG("ref name 0x%08x failed", whandle->handle);
872 return NULL;
873 }
874
875 return bo;
876 }
877
878 static const void *
etna_get_compiler_options(struct pipe_screen * pscreen,enum pipe_shader_ir ir,unsigned shader)879 etna_get_compiler_options(struct pipe_screen *pscreen,
880 enum pipe_shader_ir ir, unsigned shader)
881 {
882 return &etna_screen(pscreen)->options;
883 }
884
885 static struct disk_cache *
etna_get_disk_shader_cache(struct pipe_screen * pscreen)886 etna_get_disk_shader_cache(struct pipe_screen *pscreen)
887 {
888 struct etna_screen *screen = etna_screen(pscreen);
889 struct etna_compiler *compiler = screen->compiler;
890
891 return compiler->disk_cache;
892 }
893
894 struct pipe_screen *
etna_screen_create(struct etna_device * dev,struct etna_gpu * gpu,struct renderonly * ro)895 etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
896 struct renderonly *ro)
897 {
898 struct etna_screen *screen = CALLOC_STRUCT(etna_screen);
899 struct pipe_screen *pscreen;
900 drmVersionPtr version;
901 uint64_t val;
902
903 if (!screen)
904 return NULL;
905
906 pscreen = &screen->base;
907 screen->dev = dev;
908 screen->gpu = gpu;
909 screen->ro = renderonly_dup(ro);
910 screen->refcnt = 1;
911
912 if (!screen->ro) {
913 DBG("could not create renderonly object");
914 goto fail;
915 }
916
917 version = drmGetVersion(screen->ro->gpu_fd);
918 screen->drm_version = ETNA_DRM_VERSION(version->version_major,
919 version->version_minor);
920 drmFreeVersion(version);
921
922 etna_mesa_debug = debug_get_option_etna_mesa_debug();
923
924 /* Disable autodisable for correct rendering with TS */
925 etna_mesa_debug |= ETNA_DBG_NO_AUTODISABLE;
926
927 screen->pipe = etna_pipe_new(gpu, ETNA_PIPE_3D);
928 if (!screen->pipe) {
929 DBG("could not create 3d pipe");
930 goto fail;
931 }
932
933 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_MODEL, &val)) {
934 DBG("could not get ETNA_GPU_MODEL");
935 goto fail;
936 }
937 screen->model = val;
938
939 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_REVISION, &val)) {
940 DBG("could not get ETNA_GPU_REVISION");
941 goto fail;
942 }
943 screen->revision = val;
944
945 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_0, &val)) {
946 DBG("could not get ETNA_GPU_FEATURES_0");
947 goto fail;
948 }
949 screen->features[0] = val;
950
951 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_1, &val)) {
952 DBG("could not get ETNA_GPU_FEATURES_1");
953 goto fail;
954 }
955 screen->features[1] = val;
956
957 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_2, &val)) {
958 DBG("could not get ETNA_GPU_FEATURES_2");
959 goto fail;
960 }
961 screen->features[2] = val;
962
963 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_3, &val)) {
964 DBG("could not get ETNA_GPU_FEATURES_3");
965 goto fail;
966 }
967 screen->features[3] = val;
968
969 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_4, &val)) {
970 DBG("could not get ETNA_GPU_FEATURES_4");
971 goto fail;
972 }
973 screen->features[4] = val;
974
975 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_5, &val)) {
976 DBG("could not get ETNA_GPU_FEATURES_5");
977 goto fail;
978 }
979 screen->features[5] = val;
980
981 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_6, &val)) {
982 DBG("could not get ETNA_GPU_FEATURES_6");
983 goto fail;
984 }
985 screen->features[6] = val;
986
987 if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_7, &val)) {
988 DBG("could not get ETNA_GPU_FEATURES_7");
989 goto fail;
990 }
991 screen->features[7] = val;
992
993 if (!etna_get_specs(screen))
994 goto fail;
995
996 if (screen->specs.halti >= 5 && !etnaviv_device_softpin_capable(dev)) {
997 DBG("halti5 requires softpin");
998 goto fail;
999 }
1000
1001 screen->options = (nir_shader_compiler_options) {
1002 .lower_fpow = true,
1003 .lower_sub = true,
1004 .lower_ftrunc = true,
1005 .fuse_ffma16 = true,
1006 .fuse_ffma32 = true,
1007 .fuse_ffma64 = true,
1008 .lower_bitops = true,
1009 .lower_all_io_to_temps = true,
1010 .vertex_id_zero_based = true,
1011 .lower_flrp32 = true,
1012 .lower_fmod = true,
1013 .lower_vector_cmp = true,
1014 .lower_fdph = true,
1015 .lower_fdiv = true, /* !screen->specs.has_new_transcendentals */
1016 .lower_fsign = !screen->specs.has_sign_floor_ceil,
1017 .lower_ffloor = !screen->specs.has_sign_floor_ceil,
1018 .lower_fceil = !screen->specs.has_sign_floor_ceil,
1019 .lower_fsqrt = !screen->specs.has_sin_cos_sqrt,
1020 .lower_sincos = !screen->specs.has_sin_cos_sqrt,
1021 };
1022
1023 /* apply debug options that disable individual features */
1024 if (DBG_ENABLED(ETNA_DBG_NO_EARLY_Z))
1025 screen->features[viv_chipFeatures] |= chipFeatures_NO_EARLY_Z;
1026 if (DBG_ENABLED(ETNA_DBG_NO_TS))
1027 screen->features[viv_chipFeatures] &= ~chipFeatures_FAST_CLEAR;
1028 if (DBG_ENABLED(ETNA_DBG_NO_AUTODISABLE))
1029 screen->features[viv_chipMinorFeatures1] &= ~chipMinorFeatures1_AUTO_DISABLE;
1030 if (DBG_ENABLED(ETNA_DBG_NO_SUPERTILE))
1031 screen->specs.can_supertile = 0;
1032 if (DBG_ENABLED(ETNA_DBG_NO_SINGLEBUF))
1033 screen->specs.single_buffer = 0;
1034
1035 pscreen->destroy = etna_screen_destroy;
1036 pscreen->get_param = etna_screen_get_param;
1037 pscreen->get_paramf = etna_screen_get_paramf;
1038 pscreen->get_shader_param = etna_screen_get_shader_param;
1039 pscreen->get_compiler_options = etna_get_compiler_options;
1040 pscreen->get_disk_shader_cache = etna_get_disk_shader_cache;
1041
1042 pscreen->get_name = etna_screen_get_name;
1043 pscreen->get_vendor = etna_screen_get_vendor;
1044 pscreen->get_device_vendor = etna_screen_get_device_vendor;
1045
1046 pscreen->get_timestamp = etna_screen_get_timestamp;
1047 pscreen->context_create = etna_context_create;
1048 pscreen->is_format_supported = etna_screen_is_format_supported;
1049 pscreen->query_dmabuf_modifiers = etna_screen_query_dmabuf_modifiers;
1050
1051 screen->compiler = etna_compiler_create(etna_screen_get_name(pscreen));
1052 if (!screen->compiler)
1053 goto fail;
1054
1055 etna_fence_screen_init(pscreen);
1056 etna_query_screen_init(pscreen);
1057 etna_resource_screen_init(pscreen);
1058
1059 util_dynarray_init(&screen->supported_pm_queries, NULL);
1060 slab_create_parent(&screen->transfer_pool, sizeof(struct etna_transfer), 16);
1061
1062 if (screen->drm_version >= ETNA_DRM_VERSION_PERFMON)
1063 etna_pm_query_setup(screen);
1064
1065 return pscreen;
1066
1067 fail:
1068 etna_screen_destroy(pscreen);
1069 return NULL;
1070 }
1071