Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a2xx/fd2_resource.c
4574 views
1
/*
2
* Copyright (C) 2018 Jonathan Marek <[email protected]>
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, 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:
10
*
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
13
* 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 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
21
* SOFTWARE.
22
*
23
* Authors:
24
* Jonathan Marek <[email protected]>
25
*/
26
27
#include "fd2_resource.h"
28
29
uint32_t
30
fd2_setup_slices(struct fd_resource *rsc)
31
{
32
struct pipe_resource *prsc = &rsc->b.b;
33
enum pipe_format format = prsc->format;
34
uint32_t height0 = util_format_get_nblocksy(format, prsc->height0);
35
uint32_t level, size = 0;
36
37
/* 32 pixel alignment */
38
fdl_set_pitchalign(&rsc->layout, fdl_cpp_shift(&rsc->layout) + 5);
39
40
for (level = 0; level <= prsc->last_level; level++) {
41
struct fdl_slice *slice = fd_resource_slice(rsc, level);
42
uint32_t pitch = fdl2_pitch(&rsc->layout, level);
43
uint32_t nblocksy = align(u_minify(height0, level), 32);
44
45
/* mipmaps have power of two sizes in memory */
46
if (level)
47
nblocksy = util_next_power_of_two(nblocksy);
48
49
slice->offset = size;
50
slice->size0 = align(pitch * nblocksy, 4096);
51
52
size += slice->size0 * u_minify(prsc->depth0, level) * prsc->array_size;
53
}
54
55
return size;
56
}
57
58
unsigned
59
fd2_tile_mode(const struct pipe_resource *tmpl)
60
{
61
/* disable tiling for cube maps, freedreno uses a 2D array for the staging
62
* texture, (a2xx supports 2D arrays but it is not implemented)
63
*/
64
if (tmpl->target == PIPE_TEXTURE_CUBE)
65
return 0;
66
/* we can enable tiling for any resource we can render to */
67
return (tmpl->bind & PIPE_BIND_RENDER_TARGET) ? 1 : 0;
68
}
69
70