GitLab will be down for maintenance this Sunday 13th June, from approx 7-11am UTC. This is for a PostgreSQL migration. See the tracker issue for more informations.

Commit 57d5eaf0 authored by Icecream95's avatar Icecream95
Browse files

Merge branch 'fix-crc' into bar

parents dea3642d 8afc16b1
Pipeline #312380 waiting for manual action with stages
......@@ -53,7 +53,7 @@
#include "panfrost-quirks.h"
static bool
panfrost_should_checksum(const struct panfrost_device *dev, const struct panfrost_resource *pres);
panfrost_should_checksum(const struct panfrost_device *dev, const struct pipe_resource *pres);
static struct pipe_resource *
panfrost_resource_from_handle(struct pipe_screen *pscreen,
......@@ -82,9 +82,10 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
DRM_FORMAT_MOD_LINEAR : whandle->modifier;
enum mali_texture_dimension dim =
panfrost_translate_texture_dimension(templat->target);
/* Guess at CRC, but change it later if needed */
enum pan_image_crc_mode crc_mode =
panfrost_should_checksum(dev, rsc) ?
PAN_IMAGE_CRC_OOB : PAN_IMAGE_CRC_NONE;
panfrost_should_checksum(dev, prsc) ?
PAN_IMAGE_CRC_INBAND : PAN_IMAGE_CRC_NONE;
struct pan_image_explicit_layout explicit_layout = {
.offset = whandle->offset,
.line_stride = whandle->stride,
......@@ -110,8 +111,10 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
ralloc_free(rsc);
return NULL;
}
if (rsc->image.layout.crc_mode == PAN_IMAGE_CRC_OOB)
rsc->image.crc.bo = panfrost_bo_create(dev, rsc->image.layout.crc_size, 0);
/* Was our guess at CRC wrong? */
if (rsc->image.layout.data_size > rsc->image.data.bo->size)
rsc->image.layout.crc_mode = PAN_IMAGE_CRC_NONE;
rsc->modifier_constant = true;
......@@ -297,6 +300,21 @@ panfrost_create_scanout_res(struct pipe_screen *screen,
scanout_templat.height0 = ALIGN_POT(template->height0, 16) + header_rows;
}
// todo: align linear here?
if (panfrost_should_checksum(dev, &scanout_templat)) {
unsigned crc_size = panfrost_compute_checksum_size(
scanout_templat.width0, scanout_templat.height0
).size;
unsigned pitch = ALIGN_POT(template->width0, 16) *
util_format_get_blocksize(template->format);
unsigned crc_rows = DIV_ROUND_UP(crc_size, pitch);
scanout_templat.height0 += crc_rows;
}
scanout = renderonly_scanout_for_resource(&scanout_templat,
dev->ro, &handle);
if (!scanout)
......@@ -318,10 +336,10 @@ panfrost_create_scanout_res(struct pipe_screen *screen,
}
static inline bool
panfrost_is_2d(const struct panfrost_resource *pres)
panfrost_is_2d(const struct pipe_resource *pres)
{
return (pres->base.target == PIPE_TEXTURE_2D)
|| (pres->base.target == PIPE_TEXTURE_RECT);
return (pres->target == PIPE_TEXTURE_2D)
|| (pres->target == PIPE_TEXTURE_RECT);
}
/* Based on the usage, determine if it makes sense to use u-inteleaved tiling.
......@@ -422,7 +440,7 @@ panfrost_should_tile(struct panfrost_device *dev,
bpp == 8 || bpp == 16 || bpp == 24 || bpp == 32 ||
bpp == 64 || bpp == 128;
bool can_tile = panfrost_is_2d(pres)
bool can_tile = panfrost_is_2d(&pres->base)
&& is_sane_bpp
&& ((pres->base.bind & ~valid_binding) == 0);
......@@ -450,7 +468,7 @@ panfrost_best_modifier(struct panfrost_device *dev,
}
static bool
panfrost_should_checksum(const struct panfrost_device *dev, const struct panfrost_resource *pres)
panfrost_should_checksum(const struct panfrost_device *dev, const struct pipe_resource *pres)
{
/* When checksumming is enabled, the tile data must fit in the
* size of the writeback buffer, so don't checksum formats
......@@ -458,10 +476,10 @@ panfrost_should_checksum(const struct panfrost_device *dev, const struct panfros
unsigned bytes_per_pixel_max = (dev->arch == 6) ? 6 : 4;
unsigned bytes_per_pixel = MAX2(pres->base.nr_samples, 1) *
util_format_get_blocksize(pres->base.format);
unsigned bytes_per_pixel = MAX2(pres->nr_samples, 1) *
util_format_get_blocksize(pres->format);
return pres->base.bind & PIPE_BIND_RENDER_TARGET &&
return pres->bind & PIPE_BIND_RENDER_TARGET &&
panfrost_is_2d(pres) &&
bytes_per_pixel <= bytes_per_pixel_max &&
!(dev->debug & PAN_DBG_NO_CRC);
......@@ -475,7 +493,7 @@ panfrost_resource_setup(struct panfrost_device *dev,
uint64_t chosen_mod = modifier != DRM_FORMAT_MOD_INVALID ?
modifier : panfrost_best_modifier(dev, pres, fmt);
enum pan_image_crc_mode crc_mode =
panfrost_should_checksum(dev, pres) ?
panfrost_should_checksum(dev, &pres->base) ?
PAN_IMAGE_CRC_INBAND : PAN_IMAGE_CRC_NONE;
enum mali_texture_dimension dim =
panfrost_translate_texture_dimension(pres->base.target);
......
......@@ -500,11 +500,8 @@ panfrost_new_texture(const struct panfrost_device *dev,
#define CHECKSUM_TILE_HEIGHT 16
#define CHECKSUM_BYTES_PER_TILE 8
unsigned
panfrost_compute_checksum_size(
struct pan_image_slice_layout *slice,
unsigned width,
unsigned height)
struct pan_image_slice_crc
panfrost_compute_checksum_size(unsigned width, unsigned height)
{
unsigned aligned_width = ALIGN_POT(width, CHECKSUM_TILE_WIDTH);
unsigned aligned_height = ALIGN_POT(height, CHECKSUM_TILE_HEIGHT);
......@@ -512,9 +509,11 @@ panfrost_compute_checksum_size(
unsigned tile_count_x = aligned_width / CHECKSUM_TILE_WIDTH;
unsigned tile_count_y = aligned_height / CHECKSUM_TILE_HEIGHT;
slice->crc.stride = tile_count_x * CHECKSUM_BYTES_PER_TILE;
struct pan_image_slice_crc ret = {0};
ret.stride = tile_count_x * CHECKSUM_BYTES_PER_TILE;
ret.size = ret.stride * tile_count_y;
return slice->crc.stride * tile_count_y;
return ret;
}
unsigned
......@@ -554,12 +553,11 @@ pan_image_layout_init(const struct panfrost_device *dev,
const struct pan_image_explicit_layout *explicit_layout)
{
/* Explicit stride only work with non-mipmap, non-array; single-sample
* 2D image, and in-band CRC can't be used.
* 2D image.
*/
if (explicit_layout &&
(depth > 1 || nr_samples > 1 || array_size > 1 ||
dim != MALI_TEXTURE_DIMENSION_2D || nr_slices > 1 ||
crc_mode == PAN_IMAGE_CRC_INBAND))
dim != MALI_TEXTURE_DIMENSION_2D || nr_slices > 1))
return false;
/* Mandate 64 byte alignement */
......@@ -687,8 +685,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
/* Add a checksum region if necessary */
if (crc_mode != PAN_IMAGE_CRC_NONE) {
slice->crc.size =
panfrost_compute_checksum_size(slice, width, height);
slice->crc = panfrost_compute_checksum_size(width, height);
if (crc_mode == PAN_IMAGE_CRC_INBAND) {
slice->crc.offset = offset;
......
......@@ -39,6 +39,12 @@
#define PAN_MODIFIER_COUNT 4
extern uint64_t pan_best_modifiers[PAN_MODIFIER_COUNT];
struct pan_image_slice_crc {
unsigned offset;
unsigned stride;
unsigned size;
};
struct pan_image_slice_layout {
unsigned offset;
unsigned line_stride;
......@@ -66,11 +72,7 @@ struct pan_image_slice_layout {
/* If checksumming is enabled following the slice, what
* is its offset/stride? */
struct {
unsigned offset;
unsigned stride;
unsigned size;
} crc;
struct pan_image_slice_crc crc;
unsigned size;
};
......@@ -140,11 +142,8 @@ struct pan_image_view {
} buf;
};
unsigned
panfrost_compute_checksum_size(
struct pan_image_slice_layout *slice,
unsigned width,
unsigned height);
struct pan_image_slice_crc
panfrost_compute_checksum_size(unsigned width, unsigned height);
/* AFBC */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment