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/format/u_format.h"
30 #include "fd2_screen.h"
31 #include "fd2_context.h"
34 #include "fd2_resource.h"
37 fd2_screen_is_format_supported(struct pipe_screen
*pscreen
,
38 enum pipe_format format
,
39 enum pipe_texture_target target
,
40 unsigned sample_count
,
41 unsigned storage_sample_count
,
46 if ((target
>= PIPE_MAX_TEXTURE_TYPES
) ||
47 (sample_count
> 1)) { /* TODO add MSAA */
48 DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
49 util_format_name(format
), target
, sample_count
, usage
);
53 if (MAX2(1, sample_count
) != MAX2(1, storage_sample_count
))
56 if ((usage
& PIPE_BIND_RENDER_TARGET
) &&
57 fd2_pipe2color(format
) != (enum a2xx_colorformatx
)~0) {
58 retval
|= PIPE_BIND_RENDER_TARGET
;
61 if ((usage
& (PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_VERTEX_BUFFER
)) &&
62 !util_format_is_srgb(format
) &&
63 !util_format_is_pure_integer(format
) &&
64 fd2_pipe2surface(format
).format
!= FMT_INVALID
) {
65 retval
|= usage
& PIPE_BIND_VERTEX_BUFFER
;
66 /* the only npot blocksize supported texture format is R32G32B32_FLOAT */
67 if (util_is_power_of_two_or_zero(util_format_get_blocksize(format
)) ||
68 format
== PIPE_FORMAT_R32G32B32_FLOAT
)
69 retval
|= usage
& PIPE_BIND_SAMPLER_VIEW
;
72 if ((usage
& (PIPE_BIND_RENDER_TARGET
|
73 PIPE_BIND_DISPLAY_TARGET
|
76 (fd2_pipe2color(format
) != (enum a2xx_colorformatx
)~0)) {
77 retval
|= usage
& (PIPE_BIND_RENDER_TARGET
|
78 PIPE_BIND_DISPLAY_TARGET
|
83 if ((usage
& PIPE_BIND_DEPTH_STENCIL
) &&
84 (fd_pipe2depth(format
) != (enum adreno_rb_depth_format
)~0)) {
85 retval
|= PIPE_BIND_DEPTH_STENCIL
;
88 if ((usage
& PIPE_BIND_INDEX_BUFFER
) &&
89 (fd_pipe2index(format
) != (enum pc_di_index_size
)~0)) {
90 retval
|= PIPE_BIND_INDEX_BUFFER
;
93 if (retval
!= usage
) {
94 DBG("not supported: format=%s, target=%d, sample_count=%d, "
95 "usage=%x, retval=%x", util_format_name(format
),
96 target
, sample_count
, usage
, retval
);
99 return retval
== usage
;
102 extern const struct fd_perfcntr_group a2xx_perfcntr_groups
[];
103 extern const unsigned a2xx_num_perfcntr_groups
;
106 fd2_screen_init(struct pipe_screen
*pscreen
)
108 struct fd_screen
*screen
= fd_screen(pscreen
);
111 pscreen
->context_create
= fd2_context_create
;
112 pscreen
->is_format_supported
= fd2_screen_is_format_supported
;
114 screen
->setup_slices
= fd2_setup_slices
;
115 if (fd_mesa_debug
& FD_DBG_TTILE
)
116 screen
->tile_mode
= fd2_tile_mode
;
118 if (fd_mesa_debug
& FD_DBG_PERFC
) {
119 screen
->perfcntr_groups
= a2xx_perfcntr_groups
;
120 screen
->num_perfcntr_groups
= a2xx_num_perfcntr_groups
;
123 fd2_emit_init_screen(pscreen
);