2 * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
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, sublicense,
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:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
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 NONINFRINGEMENT. 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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Rob Clark <robclark@freedesktop.org>
27 #include "pipe/p_screen.h"
28 #include "util/u_format.h"
30 #include "fd3_screen.h"
31 #include "fd3_context.h"
32 #include "fd3_format.h"
34 #include "fd3_resource.h"
36 #include "ir3/ir3_compiler.h"
39 fd3_screen_is_format_supported(struct pipe_screen
*pscreen
,
40 enum pipe_format format
,
41 enum pipe_texture_target target
,
42 unsigned sample_count
,
43 unsigned storage_sample_count
,
48 if ((target
>= PIPE_MAX_TEXTURE_TYPES
) ||
49 (sample_count
> 1)) { /* TODO add MSAA */
50 DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
51 util_format_name(format
), target
, sample_count
, usage
);
55 if (MAX2(1, sample_count
) != MAX2(1, storage_sample_count
))
58 if ((usage
& PIPE_BIND_VERTEX_BUFFER
) &&
59 (fd3_pipe2vtx(format
) != (enum a3xx_vtx_fmt
)~0)) {
60 retval
|= PIPE_BIND_VERTEX_BUFFER
;
63 if ((usage
& PIPE_BIND_SAMPLER_VIEW
) &&
64 (fd3_pipe2tex(format
) != (enum a3xx_tex_fmt
)~0)) {
65 retval
|= PIPE_BIND_SAMPLER_VIEW
;
68 if ((usage
& (PIPE_BIND_RENDER_TARGET
|
69 PIPE_BIND_DISPLAY_TARGET
|
72 PIPE_BIND_BLENDABLE
)) &&
73 (fd3_pipe2color(format
) != (enum a3xx_color_fmt
)~0) &&
74 (fd3_pipe2tex(format
) != (enum a3xx_tex_fmt
)~0)) {
75 retval
|= usage
& (PIPE_BIND_RENDER_TARGET
|
76 PIPE_BIND_DISPLAY_TARGET
|
79 if (!util_format_is_pure_integer(format
))
80 retval
|= usage
& PIPE_BIND_BLENDABLE
;
83 if ((usage
& PIPE_BIND_DEPTH_STENCIL
) &&
84 (fd_pipe2depth(format
) != (enum adreno_rb_depth_format
)~0) &&
85 (fd3_pipe2tex(format
) != (enum a3xx_tex_fmt
)~0)) {
86 retval
|= PIPE_BIND_DEPTH_STENCIL
;
89 if ((usage
& PIPE_BIND_INDEX_BUFFER
) &&
90 (fd_pipe2index(format
) != (enum pc_di_index_size
)~0)) {
91 retval
|= PIPE_BIND_INDEX_BUFFER
;
94 if (retval
!= usage
) {
95 DBG("not supported: format=%s, target=%d, sample_count=%d, "
96 "usage=%x, retval=%x", util_format_name(format
),
97 target
, sample_count
, usage
, retval
);
100 return retval
== usage
;
104 fd3_screen_init(struct pipe_screen
*pscreen
)
106 struct fd_screen
*screen
= fd_screen(pscreen
);
107 screen
->max_rts
= A3XX_MAX_RENDER_TARGETS
;
108 screen
->compiler
= ir3_compiler_create(screen
->dev
, screen
->gpu_id
);
109 pscreen
->context_create
= fd3_context_create
;
110 pscreen
->is_format_supported
= fd3_screen_is_format_supported
;
111 fd3_emit_init_screen(pscreen
);
113 screen
->setup_slices
= fd3_setup_slices
;
114 if (fd_mesa_debug
& FD_DBG_TTILE
)
115 screen
->tile_mode
= fd3_tile_mode
;