We can just bake the UBWC-goes-first delta into the slices at setup time.
I did have to fix up the resource shadowing swap path to swap the slice
fields, as it was missing and regressed the format reinterpets otherwise.
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
uint32_t width0, height0, depth0;
/* UBWC specific fields: */
- uint32_t offset; /* offset to start of pixel data */
uint32_t ubwc_offset; /* offset to UBWC meta data */
uint32_t ubwc_pitch;
uint32_t ubwc_size;
fdl_surface_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
{
const struct fdl_slice *slice = &layout->slices[level];
- unsigned offset = slice->offset;
- offset += fdl_layer_stride(layout, level) * layer;
- return offset + layout->offset;
+ return slice->offset + fdl_layer_stride(layout, level) * layer;
}
static inline uint32_t
* because it is what the kernel expects for scanout. For non-2D we
* could just use a separate UBWC buffer..
*/
+ for (int level = 0; level <= prsc->last_level; level++) {
+ struct fdl_slice *slice = fd_resource_slice(rsc, level);
+ slice->offset += meta_size;
+ }
+
rsc->layout.ubwc_offset = 0;
- rsc->layout.offset = meta_size;
rsc->layout.ubwc_pitch = meta_stride;
rsc->layout.ubwc_size = meta_size >> 2; /* in dwords??? */
rsc->layout.tile_mode = TILE6_3;
/* TODO valid_buffer_range?? */
swap(rsc->bo, shadow->bo);
swap(rsc->write_batch, shadow->write_batch);
- swap(rsc->layout.offset, shadow->layout.offset);
+ for (int level = 0; level <= prsc->last_level; level++)
+ swap(rsc->layout.slices[level], shadow->layout.slices[level]);
swap(rsc->layout.ubwc_offset, shadow->layout.ubwc_offset);
swap(rsc->layout.ubwc_pitch, shadow->layout.ubwc_pitch);
swap(rsc->layout.ubwc_size, shadow->layout.ubwc_size);