Commit 8c8b2a55 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Generalise bpp for textures

parent ba4ac375
......@@ -1673,15 +1673,13 @@ panfrost_resource_create_front(struct pipe_screen *screen,
so->dt = winsys->displaytarget_create(winsys, template->bind, template->format, template->width0, template->height0, 64, map_front_private, &stride);
}
#endif
/* TODO: Textures n stuff */
int width = 1; /* RGBA XXX */
size_t sz = template->width0;
so->bytes_per_pixel = 1;
size_t sz = so->bytes_per_pixel * template->width0;
if (template->height0) sz *= template->height0;
if (template->depth0) sz *= template->depth0;
sz *= width;
/* TODO: Allocate straight on the cmdstream for zero-copy operation */
for (int l = 0; l < (template->last_level + 1); ++l) {
......@@ -2012,15 +2010,14 @@ panfrost_destroy(struct pipe_context *pipe)
static void
panfrost_tile_texture(struct panfrost_context *ctx, struct panfrost_resource *rsrc, int level)
{
int bpp = 1; /* XXX: Not just RGBA32 */
int width = rsrc->base.width0 >> level;
int height = rsrc->base.height0 >> level;
int stride = width * bpp; /* TODO: Alignment? */
int stride = width * rsrc->bytes_per_pixel; /* TODO: Alignment? */
/* Estimate swizzled bitmap size. Slight overestimates are fine.
* Underestimates will result in memory corruption or worse. */
int swizzled_sz = trans_swizzled_size(width, height, bpp);
int swizzled_sz = trans_swizzled_size(width, height, rsrc->bytes_per_pixel);
/* Allocate the transfer given that known size but do not copy */
......@@ -2029,7 +2026,7 @@ panfrost_tile_texture(struct panfrost_context *ctx, struct panfrost_resource *rs
/* Run actual texture swizzle, writing directly to the mapped GPU chunk
* we allocated */
trans_texture_swizzle(width, height, bpp, stride, rsrc->cpu[level], swizzled);
trans_texture_swizzle(width, height, rsrc->bytes_per_pixel, stride, rsrc->cpu[level], swizzled);
}
static void
......
......@@ -211,6 +211,9 @@ struct panfrost_resource {
/* Is something other than level 0 ever written? */
bool is_mipmap;
/* Only valid for textures */
int bytes_per_pixel;
struct sw_displaytarget *dt;
};
......
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