diff options
author | Jonathan Marek <[email protected]> | 2020-07-07 18:27:32 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-07-08 20:46:08 +0000 |
commit | 979e7e3680792dc23d434295edd10b161af8aee3 (patch) | |
tree | 3a04deaed74d2a95215e05c8c8ccb00884e05f1b /src/freedreno/fdl/freedreno_layout.h | |
parent | 4b290b759a8c85c7d493f1ddd7d38b322bbe1276 (diff) |
freedreno/layout: layout simplifications and pitch from level 0 pitch
This updates a3xx/a4xx/a5xx to fix the fetchsize to "PITCHALIGN" (called
"MINLINEOFFSET" by the a3xx docs), and some simplifications to make things
more like a6xx. Also similar simplifications for a2xx layout code.
The pitch can always be determined using a simple calculation from the base
level pitch, so don't pre-calculate a pitch for each mipmap level.
Signed-off-by: Jonathan Marek <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5796>
Diffstat (limited to 'src/freedreno/fdl/freedreno_layout.h')
-rw-r--r-- | src/freedreno/fdl/freedreno_layout.h | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h index 3b2cb67c493..bae4be585b0 100644 --- a/src/freedreno/fdl/freedreno_layout.h +++ b/src/freedreno/fdl/freedreno_layout.h @@ -79,10 +79,15 @@ struct fdl_slice { uint32_t offset; /* offset of first layer in slice */ - uint32_t pitch; /* pitch in bytes between rows. */ uint32_t size0; /* size of first layer in slice */ }; +/* parameters for explicit (imported) layout */ +struct fdl_explicit_layout { + uint32_t offset; + uint32_t pitch; +}; + /** * Encapsulates the layout of a resource, including position of given 2d * surface (layer, level) within. Or rather all the information needed @@ -91,6 +96,8 @@ struct fdl_slice { struct fdl_layout { struct fdl_slice slices[FDL_MAX_MIP_LEVELS]; struct fdl_slice ubwc_slices[FDL_MAX_MIP_LEVELS]; + uint32_t pitch0; + uint32_t ubwc_width0; uint32_t layer_size; uint32_t ubwc_layer_size; /* in bytes */ bool ubwc : 1; @@ -121,7 +128,7 @@ struct fdl_layout { uint32_t size; /* Size of the whole image, in bytes. */ uint32_t base_align; /* Alignment of the base address, in bytes. */ - uint8_t pitchalign; /* log2(pitchalign / 64) */ + uint8_t pitchalign; /* log2(pitchalign) */ }; static inline uint32_t @@ -132,6 +139,24 @@ fdl_cpp_shift(const struct fdl_layout *layout) } static inline uint32_t +fdl_pitch(const struct fdl_layout *layout, unsigned level) +{ + return align(u_minify(layout->pitch0, level), 1 << layout->pitchalign); +} + +#define RGB_TILE_WIDTH_ALIGNMENT 64 +#define RGB_TILE_HEIGHT_ALIGNMENT 16 +#define UBWC_PLANE_SIZE_ALIGNMENT 4096 + +static inline uint32_t +fdl_ubwc_pitch(const struct fdl_layout *layout, unsigned level) +{ + if (!layout->ubwc) + return 0; + return align(u_minify(layout->ubwc_width0, level), RGB_TILE_WIDTH_ALIGNMENT); +} + +static inline uint32_t fdl_layer_stride(const struct fdl_layout *layout, unsigned level) { if (layout->layer_first) @@ -140,6 +165,22 @@ fdl_layer_stride(const struct fdl_layout *layout, unsigned level) return layout->slices[level].size0; } +/* a2xx is special and needs PoT alignment for mipmaps: */ +static inline uint32_t +fdl2_pitch(const struct fdl_layout *layout, unsigned level) +{ + uint32_t pitch = fdl_pitch(layout, level); + if (level) + pitch = util_next_power_of_two(pitch); + return pitch; +} + +static inline uint32_t +fdl2_pitch_pixels(const struct fdl_layout *layout, unsigned level) +{ + return fdl2_pitch(layout, level) >> fdl_cpp_shift(layout); +} + static inline uint32_t fdl_surface_offset(const struct fdl_layout *layout, unsigned level, unsigned layer) { @@ -196,7 +237,15 @@ fdl6_layout(struct fdl_layout *layout, enum pipe_format format, uint32_t nr_samples, uint32_t width0, uint32_t height0, uint32_t depth0, uint32_t mip_levels, uint32_t array_size, bool is_3d, - struct fdl_slice *plane_layout); + struct fdl_explicit_layout *plane_layout); + +static inline void +fdl_set_pitchalign(struct fdl_layout *layout, unsigned pitchalign) +{ + uint32_t nblocksx = util_format_get_nblocksx(layout->format, layout->width0); + layout->pitchalign = pitchalign; + layout->pitch0 = align(nblocksx * layout->cpp, 1 << pitchalign); +} void fdl_dump_layout(struct fdl_layout *layout); |