2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Rob Clark <robclark@freedesktop.org>
28 #include "drm-uapi/drm_fourcc.h"
29 #include "pipe/p_screen.h"
30 #include "util/format/u_format.h"
32 #include "fd6_screen.h"
33 #include "fd6_blitter.h"
34 #include "fd6_context.h"
36 #include "fd6_format.h"
37 #include "fd6_resource.h"
39 #include "ir3/ir3_compiler.h"
42 valid_sample_count(unsigned sample_count
)
44 switch (sample_count
) {
49 // TODO seems 8x works, but increases lrz width or height.. but the
50 // blob I have doesn't seem to expose any egl configs w/ 8x, so
51 // just hide it for now and revisit later.
60 fd6_screen_is_format_supported(struct pipe_screen
*pscreen
,
61 enum pipe_format format
,
62 enum pipe_texture_target target
,
63 unsigned sample_count
,
64 unsigned storage_sample_count
,
69 if ((target
>= PIPE_MAX_TEXTURE_TYPES
) ||
70 !valid_sample_count(sample_count
)) {
71 DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
72 util_format_name(format
), target
, sample_count
, usage
);
76 if (MAX2(1, sample_count
) != MAX2(1, storage_sample_count
))
79 if ((usage
& PIPE_BIND_VERTEX_BUFFER
) &&
80 (fd6_pipe2vtx(format
) != (enum a6xx_vtx_fmt
)~0)) {
81 retval
|= PIPE_BIND_VERTEX_BUFFER
;
84 if ((usage
& (PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_SHADER_IMAGE
)) &&
85 (target
== PIPE_BUFFER
||
86 util_format_get_blocksize(format
) != 12) &&
87 (fd6_pipe2tex(format
) != (enum a6xx_tex_fmt
)~0)) {
88 retval
|= usage
& (PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_SHADER_IMAGE
);
91 if ((usage
& (PIPE_BIND_RENDER_TARGET
|
92 PIPE_BIND_DISPLAY_TARGET
|
95 PIPE_BIND_COMPUTE_RESOURCE
)) &&
96 (fd6_pipe2color(format
) != (enum a6xx_color_fmt
)~0) &&
97 (fd6_pipe2tex(format
) != (enum a6xx_tex_fmt
)~0)) {
98 retval
|= usage
& (PIPE_BIND_RENDER_TARGET
|
99 PIPE_BIND_DISPLAY_TARGET
|
102 PIPE_BIND_COMPUTE_RESOURCE
);
105 /* For ARB_framebuffer_no_attachments: */
106 if ((usage
& PIPE_BIND_RENDER_TARGET
) && (format
== PIPE_FORMAT_NONE
)) {
107 retval
|= usage
& PIPE_BIND_RENDER_TARGET
;
110 if ((usage
& PIPE_BIND_DEPTH_STENCIL
) &&
111 (fd6_pipe2depth(format
) != (enum a6xx_depth_format
)~0) &&
112 (fd6_pipe2tex(format
) != (enum a6xx_tex_fmt
)~0)) {
113 retval
|= PIPE_BIND_DEPTH_STENCIL
;
116 if ((usage
& PIPE_BIND_INDEX_BUFFER
) &&
117 (fd_pipe2index(format
) != (enum pc_di_index_size
)~0)) {
118 retval
|= PIPE_BIND_INDEX_BUFFER
;
121 if (retval
!= usage
) {
122 DBG("not supported: format=%s, target=%d, sample_count=%d, "
123 "usage=%x, retval=%x", util_format_name(format
),
124 target
, sample_count
, usage
, retval
);
127 return retval
== usage
;
131 fd6_screen_init(struct pipe_screen
*pscreen
)
133 struct fd_screen
*screen
= fd_screen(pscreen
);
134 screen
->max_rts
= A6XX_MAX_RENDER_TARGETS
;
135 screen
->compiler
= ir3_compiler_create(screen
->dev
, screen
->gpu_id
);
136 pscreen
->context_create
= fd6_context_create
;
137 pscreen
->is_format_supported
= fd6_screen_is_format_supported
;
139 screen
->setup_slices
= fd6_setup_slices
;
140 screen
->tile_mode
= fd6_tile_mode
;
141 screen
->fill_ubwc_buffer_sizes
= fd6_fill_ubwc_buffer_sizes
;
143 static const uint64_t supported_modifiers
[] = {
144 DRM_FORMAT_MOD_LINEAR
,
145 DRM_FORMAT_MOD_QCOM_COMPRESSED
,
148 screen
->supported_modifiers
= supported_modifiers
;
149 screen
->num_supported_modifiers
= ARRAY_SIZE(supported_modifiers
);
151 fd6_emit_init_screen(pscreen
);