Commit 73d7e00e authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Cleanups relating to texture swizzling

parent cc3eceda
......@@ -26,29 +26,33 @@
#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
/* Spacing out individual bits. */
int space_filler_indices[16];
/* Space a group of 4-bits out. For instance, 0x7 -- that is, 0b111 -- would
* become 0b10101 */
void
trans_generate_space_filler_indices()
static inline int
space_bits_4(int i)
{
for (int i = 0; i < 16; ++i) {
space_filler_indices[i] =
((i & 0x8) << 3) |
((i & 0x4) << 2) |
((i & 0x2) << 1) |
((i & 0x1) << 0);
}
return ((i & 0x8) << 3) |
((i & 0x4) << 2) |
((i & 0x2) << 1) |
((i & 0x1) << 0);
}
/* Indices only use every other bit. So, shifting one index over and OR'ing
* with the other interleaves the indices */
/* Generate lookup table for the space filler curve. Note this is a 1:1
* mapping, just with bits twiddled around. */
static int
space_filler_index(int x, int y)
int space_filler[16][16];
void
trans_generate_space_filler_indices()
{
return space_filler_indices[y ^ x] | (space_filler_indices[y] << 1);
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 16; ++y) {
space_filler[x][y] =
space_bits_4(y ^ x) | (space_bits_4(y) << 1);
}
}
}
void
......@@ -58,19 +62,19 @@ trans_texture_swizzle(int width, int height, int bytes_per_pixel, int source_str
{
int block_pitch = ALIGN(width, 16) >> 4;
for (int y = 0; y < height; y++) {
for (int y = 0; y < height; ++y) {
int block_y = y >> 4;
int rem_y = y & 0x0F;
int block_start_s = block_y * block_pitch * 256;
int source_start = y * source_stride;
for (int x = 0; x < width; x++) {
int block_x = x >> 4;
for (int x = 0; x < width; ++x) {
int block_x_s = (x >> 4) * 256;
int rem_x = x & 0x0F;
int index = space_filler_index(rem_x, rem_y);
const uint8_t *source = &pixels[y * source_stride + bytes_per_pixel * x];
uint8_t *dest = ldest + bytes_per_pixel * ((256 * (block_y * block_pitch + block_x)) + index);
int index = space_filler[rem_x][rem_y];
const uint8_t *source = &pixels[source_start + bytes_per_pixel * x];
uint8_t *dest = ldest + bytes_per_pixel * (block_start_s + block_x_s + index);
for (int b = 0; b < bytes_per_pixel; ++b)
dest[b] = source[b];
......
......@@ -18,7 +18,7 @@
#include <stdint.h>
void
trans_generate_space_filler_indices();
trans_generate_space_filler_indices(void);
void
trans_texture_swizzle(int width, int height, int bytes_per_pixel, int source_stride,
......
......@@ -1703,7 +1703,7 @@ trans_setup_hardware(struct panfrost_context *ctx)
#ifndef HAVE_DRI3
/* Mesa allocates the framebuffer for us, but when standalone we handle it ourselves */
trans_setup_framebuffer(ctx, NULL, 1920, 1080);
trans_setup_framebuffer(ctx, NULL, 1366, 768);
#endif
}
......
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