Commit 859f50d8 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Initial texture swizzling code

parent e622bd5b
......@@ -13,6 +13,7 @@
*/
#include "trans-builder.h"
#include "/home/guest/swizzle-fun/limare-swizzle.c"
#ifdef HAVE_DRI3
#define UNUSED
......@@ -868,7 +869,13 @@ trans_emit_for_draw(struct panfrost_context *ctx)
struct pipe_resource *tex_rsrc = ctx->sampler_views[t][i]->base.texture;
struct panfrost_resource *rsrc = (struct panfrost_resource *) tex_rsrc;
mali_ptr bitmap = panfrost_upload(&ctx->cmdstream, (uint8_t *) rsrc->cpu, rsrc->len, false);
int bpp = 4; /* XXX: Not just RGBA32 */
int stride = rsrc->base.width0 * bpp; /* TODO: Alignment? */
uint8_t *swizzled = malloc(rsrc->len);
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);
/* Inject the address in. XXX: Should be its own dirty flag or something... */
ctx->sampler_views[t][i]->hw.swizzled_bitmap_0 = bitmap;
......@@ -1563,6 +1570,7 @@ panfrost_resource_create_front(struct pipe_screen *screen,
sz *= width;
/* TODO: Allocate straight on the cmdstream for zero-copy operation */
/* TODO: Find optimal time to swizzle */
so->cpu = malloc(sz);
so->len = sz;
......@@ -1687,7 +1695,7 @@ trans_setup_hardware(struct panfrost_context *ctx)
{
ctx->fd = pandev_open();
trans_allocate_slab(ctx, &ctx->cmdstream, 8*64, true, true, 0, 0, 0);
trans_allocate_slab(ctx, &ctx->cmdstream, 8*64*64, true, true, 0, 0, 0);
trans_allocate_slab(ctx, &ctx->scratchpad, 16, true, true, 0, 0, 0);
trans_allocate_slab(ctx, &ctx->varying_mem, 32, false, true, MALI_MEM_COHERENT_LOCAL, 0, 0);
trans_allocate_slab(ctx, &ctx->shaders, 4096, true, false, MALI_MEM_PROT_GPU_EX, 1, 0);
......@@ -1695,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, 1366, 768);
trans_setup_framebuffer(ctx, NULL, 1920, 1080);
#endif
}
......@@ -1752,5 +1760,7 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
trans_invalidate_frame(ctx);
trans_default_shader_backend(ctx);
generate_space_filler_indices();
return gallium;
}
......@@ -21,15 +21,15 @@ int main(int argc, const char **argv)
gallium->bind_vs_state(gallium, gallium->create_vs_state(gallium, &vs_cso));
float attributes_data_1_0[] = {
-0.50000f, 0.500000f, 0.000000f, 1.0f,
0.500000f, 0.500000f, 0.000000f, 1.0f,
-0.50000f, -0.500000f, 0.000000f, 1.0f,
0.500000f, -0.500000f, 0.000000f, 1.0f,
-0.95000f, 0.950000f, 0.000000f, 0.0f,
0.950000f, 0.950000f, 0.000000f, 1.0f,
-0.95000f, -0.950000f, 1.000000f, 1.0f,
0.950000f, -0.950000f, 1.000000f, 0.0f,
-0.50000f, -0.500000f, 0.000000f, 1.0f,
-0.50000f, 0.500000f, 0.000000f, 0.0f,
0.500000f, 0.500000f, 0.000000f, 1.0f,
-0.50000f, -0.500000f, 0.000000f, 1.0f,
0.500000f, -0.500000f, 0.000000f, 1.0f,
-0.50000f, -0.500000f, 1.000000f, 1.0f,
0.500000f, -0.500000f, 1.000000f, 0.0f,
};
......@@ -109,9 +109,9 @@ int main(int argc, const char **argv)
gallium->create_rasterizer_state(gallium, &state));
struct pipe_sampler_state sampler_state = {
.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE,
.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE,
.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE,
.wrap_s = PIPE_TEX_WRAP_REPEAT,
.wrap_t = PIPE_TEX_WRAP_REPEAT,
.wrap_r = PIPE_TEX_WRAP_REPEAT,
.compare_func = PIPE_FUNC_LEQUAL,
.min_img_filter = PIPE_TEX_FILTER_LINEAR,
.mag_img_filter = PIPE_TEX_FILTER_LINEAR,
......@@ -126,16 +126,13 @@ int main(int argc, const char **argv)
.swizzle_a = PIPE_SWIZZLE_W,
};
uint32_t bitmap_data[32 * 32] = { 0 };
uint8_t bitmap_data[568 * 770 * 4];
for (int i = 0; i < 32; ++i) {
for (int j = 0; j < 32; ++j) {
bitmap_data[i*32 + j] = (i * 8) + ((j * 8) << 8);
}
}
FILE *fp = fopen("/home/guest/img.bin", "rb");
fread(bitmap_data, 1, sizeof(bitmap_data), fp);
templ.width0 = 32;
templ.height0 = 32;
templ.width0 = 568;
templ.height0 = 770;
templ.depth0 = 1;
struct pipe_transfer *transfer4;
......@@ -168,7 +165,7 @@ int main(int argc, const char **argv)
gallium->bind_rasterizer_state(gallium,
gallium->create_rasterizer_state(gallium, &stat));
attributes_data_1_0[0] = 0.01f * ((float) i);
attributes_data_1_0[0] = sin(((float) i ) * 0.03f);
memcpy(attrib_trans,
attributes_data_1_0,
......@@ -195,6 +192,7 @@ int main(int argc, const char **argv)
sizeof(attributes_data_1_0));
*/
#if 0
const struct pipe_rasterizer_state staate = {
.line_width = 1.0f,
.front_ccw = false,
......@@ -209,6 +207,8 @@ int main(int argc, const char **argv)
gallium->draw_vbo(gallium, &info);
#endif
gallium->flush(gallium, NULL, PIPE_FLUSH_END_OF_FRAME);
}
......
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