Debian Codegraph @

src/gallium/drivers/freedreno/a2xx/fd2_resource.c

raw
1 /*
2 * Copyright © 2018 Jonathan Marek <[email protected]>
3 * SPDX-License-Identifier: MIT
4 *
5 * Authors:
6 * Jonathan Marek <[email protected]>
7 */
8
9 #include "fd2_resource.h"
10 #include "freedreno_screen.h"
11
12 uint32_t
13 fd2_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
14 {
15 struct pipe_resource *prsc = &rsc->b.b;
16 enum pipe_format format = prsc->format;
17 uint32_t height0 = util_format_get_nblocksy(format, prsc->height0);
18 uint32_t level, size = 0;
19
20 fd_resource_layout_init(prsc);
21
22 /* 32 pixel alignment */
23 fdl_set_pitchalign(&rsc->layout, fdl_cpp_shift(&rsc->layout) + 5);
24
25 for (level = 0; level <= prsc->last_level; level++) {
26 struct fdl_slice *slice = fd_resource_slice(rsc, level);
27 uint32_t pitch = fdl2_pitch(&rsc->layout, level);
28 uint32_t nblocksy = align(u_minify(height0, level), 32);
29
30 /* mipmaps have power of two sizes in memory */
31 if (level)
32 nblocksy = util_next_power_of_two(nblocksy);
33
34 slice->offset = size;
35 slice->size0 = align(pitch * nblocksy, 4096);
36
37 size += slice->size0 * u_minify(prsc->depth0, level) * prsc->array_size;
38 }
39
40 return size;
41 }
42
43 unsigned
44 fd2_tile_mode(const struct pipe_resource *tmpl)
45 {
46 /* disable tiling for cube maps, freedreno uses a 2D array for the staging
47 * texture, (a2xx supports 2D arrays but it is not implemented)
48 */
49 if (tmpl->target == PIPE_TEXTURE_CUBE)
50 return 0;
51 /* we can enable tiling for any resource we can render to */
52 return (tmpl->bind & PIPE_BIND_RENDER_TARGET) ? 1 : 0;
53 }