Commit 174fab41 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Fix swizzling artifacts on non-aligned images

parent 8acfddaa
......@@ -87,7 +87,6 @@ trans_texture_swizzle(int width, int height, int bytes_per_pixel, int source_str
{
/* Calculate maximum size, overestimating a bit */
int block_pitch = ALIGN(width, 16) >> 4;
uint32_t sz = bytes_per_pixel * 256 * ((height >> 4) + 1) * block_pitch;
/* Use fast path if available */
if (bytes_per_pixel == 4 /* && (ALIGN(width, 16) == width) */) {
......@@ -117,6 +116,17 @@ trans_texture_swizzle(int width, int height, int bytes_per_pixel, int source_str
}
}
unsigned
trans_swizzled_size(int width, int height, int bytes_per_pixel)
{
/* Calculate maximum size, overestimating a bit */
int block_pitch = ALIGN(width, 16) >> 4;
unsigned sz = bytes_per_pixel * 256 * ((height >> 4) + 1) * block_pitch;
return sz;
}
#if 0
#include <stdio.h>
#include <stdlib.h>
......
......@@ -25,4 +25,7 @@ trans_texture_swizzle(int width, int height, int bytes_per_pixel, int source_str
const uint8_t *pixels,
uint8_t *ldest);
unsigned
trans_swizzled_size(int width, int height, int bytes_per_pixel);
#endif
......@@ -872,10 +872,13 @@ trans_emit_for_draw(struct panfrost_context *ctx)
int bpp = 4; /* XXX: Not just RGBA32 */
int stride = rsrc->base.width0 * bpp; /* TODO: Alignment? */
uint8_t *swizzled = malloc(rsrc->len);
int swizzled_sz = trans_swizzled_size(rsrc->base.width0, rsrc->base.height0, bpp);
uint8_t *swizzled = malloc(swizzled_sz);
trans_texture_swizzle(rsrc->base.width0, rsrc->base.height0, bpp, stride, (uint8_t *) rsrc->cpu, swizzled);
mali_ptr bitmap = panfrost_upload(&ctx->cmdstream, swizzled, rsrc->len, false);
mali_ptr bitmap = panfrost_upload(&ctx->cmdstream, swizzled, swizzled_sz, false);
/* Inject the address in. XXX: Should be its own dirty flag or something... */
ctx->sampler_views[t][i]->hw.swizzled_bitmap_0 = bitmap;
......
......@@ -155,7 +155,7 @@ int main(int argc, const char **argv)
0, 2,
texs);
for (int i = 0; i < 60; ++i) {
for (int i = 0; i < 600; ++i) {
const struct pipe_rasterizer_state stat = {
.line_width = 10.0f,
.front_ccw = false,
......
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