From de9f8e8b717aa4b4ab94af73be5aa70088cd6b81 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 2 Jan 2008 18:53:33 -0700 Subject: Cell: basic triangle rendering works. The cell "render_stage" (last in the "draw" pipeline) emits vertices into a buffer which is pulled by the SPUs in response to a "RENDER" command. This is pretty much temporary/scaffold code for now. --- src/mesa/pipe/cell/common.h | 21 ++++++++ src/mesa/pipe/cell/ppu/cell_context.c | 5 +- src/mesa/pipe/cell/ppu/cell_context.h | 3 +- src/mesa/pipe/cell/ppu/cell_flush.c | 3 ++ src/mesa/pipe/cell/ppu/cell_render.c | 73 +++++++++++++++++++++++++++ src/mesa/pipe/cell/ppu/cell_render.h | 3 ++ src/mesa/pipe/cell/ppu/cell_surface.c | 8 ++- src/mesa/pipe/cell/spu/main.c | 95 ++++++++++++++++++++++++++++++++--- src/mesa/pipe/cell/spu/main.h | 13 +++-- src/mesa/pipe/cell/spu/tri.c | 21 ++++++-- src/mesa/pipe/cell/spu/tri.h | 4 ++ src/mesa/pipe/xlib/xm_winsys.c | 9 +++- 12 files changed, 240 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index f7f1e2eb41..0868e8d90f 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -51,6 +51,7 @@ #define CELL_CMD_CLEAR_TILES 3 #define CELL_CMD_TRIANGLE 4 #define CELL_CMD_FINISH 5 +#define CELL_CMD_RENDER 6 /** @@ -80,12 +81,22 @@ struct cell_command_triangle } ALIGN16_ATTRIB; +struct cell_command_render +{ + uint prim_type; + uint num_verts; + float xmin, ymin, xmax, ymax; + void *vertex_data; +} ALIGN16_ATTRIB; + + /** XXX unions don't seem to work */ struct cell_command { struct cell_command_framebuffer fb; struct cell_command_clear_tiles clear; struct cell_command_triangle tri; + struct cell_command_render render; } ALIGN16_ATTRIB; @@ -98,6 +109,16 @@ struct cell_init_info } ALIGN16_ATTRIB; +/** Temporary */ +#define CELL_MAX_VERTS 48 +#define CELL_MAX_ATTRIBS 2 +struct cell_prim_buffer +{ + float vertex[CELL_MAX_VERTS][CELL_MAX_ATTRIBS][4] ALIGN16_ATTRIB; + float xmin, ymin, xmax, ymax; + uint num_verts; +} ALIGN16_ATTRIB; + #endif /* CELL_COMMON_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 82b69ac33e..fb89837a7c 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -161,10 +161,13 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) { struct cell_context *cell; - cell = CALLOC_STRUCT(cell_context); + /* some fields need to be 16-byte aligned, so align the whole object */ + cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16); if (!cell) return NULL; + memset(cell, 0, sizeof(*cell)); + cell->winsys = cws; cell->pipe.winsys = winsys; cell->pipe.destroy = cell_destroy_context; diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index 5f6f987d8f..be985820d1 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -34,6 +34,7 @@ #include "pipe/p_defines.h" #include "pipe/draw/draw_vertex.h" #include "cell_winsys.h" +#include "pipe/cell/common.h" struct cell_vertex_shader_state @@ -90,7 +91,7 @@ struct cell_context uint num_spus; - + struct cell_prim_buffer prim_buffer; }; diff --git a/src/mesa/pipe/cell/ppu/cell_flush.c b/src/mesa/pipe/cell/ppu/cell_flush.c index b1ff0e51cd..47003bef18 100644 --- a/src/mesa/pipe/cell/ppu/cell_flush.c +++ b/src/mesa/pipe/cell/ppu/cell_flush.c @@ -29,6 +29,7 @@ #include "cell_context.h" #include "cell_flush.h" #include "cell_spu.h" +#include "cell_render.h" void @@ -39,6 +40,8 @@ cell_flush(struct pipe_context *pipe, unsigned flags) printf("%s\n", __FUNCTION__); + cell_flush_prim_buffer(cell); + /* Send CMD_FINISH to all SPUs */ for (i = 0; i < cell->num_spus; i++) { send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FINISH); diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c index c7f0cf6be6..672406aa23 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.c +++ b/src/mesa/pipe/cell/ppu/cell_render.c @@ -32,6 +32,7 @@ #include "cell_context.h" #include "cell_render.h" +#include "cell_spu.h" #include "pipe/p_util.h" #include "pipe/draw/draw_private.h" @@ -89,13 +90,85 @@ render_line(struct draw_stage *stage, struct prim_header *prim) } +/** Write a vertex into the prim buffer */ +static void +save_vertex(struct cell_prim_buffer *buf, uint pos, + const struct vertex_header *vert) +{ + uint attr, j; + + for (attr = 0; attr < 2; attr++) { + for (j = 0; j < 4; j++) { + buf->vertex[pos][attr][j] = vert->data[attr][j]; + } + } + + /* update bounding box */ + if (vert->data[0][0] < buf->xmin) + buf->xmin = vert->data[0][0]; + if (vert->data[0][0] > buf->xmax) + buf->xmax = vert->data[0][0]; + if (vert->data[0][1] < buf->ymin) + buf->ymin = vert->data[0][1]; + if (vert->data[0][1] > buf->ymax) + buf->ymax = vert->data[0][1]; +} + + static void render_tri(struct draw_stage *stage, struct prim_header *prim) { + struct render_stage *rs = render_stage(stage); + struct cell_context *cell = rs->cell; + struct cell_prim_buffer *buf = &cell->prim_buffer; + uint i; + printf("Cell render tri\n"); + + if (buf->num_verts + 3 > CELL_MAX_VERTS) { + cell_flush_prim_buffer(cell); + } + + i = buf->num_verts; + assert(i+2 <= CELL_MAX_VERTS); + save_vertex(buf, i+0, prim->v[0]); + save_vertex(buf, i+1, prim->v[1]); + save_vertex(buf, i+2, prim->v[2]); + buf->num_verts += 3; } +/** + * Send the a RENDER command to all SPUs to have them render the prims + * in the current prim_buffer. + */ +void +cell_flush_prim_buffer(struct cell_context *cell) +{ + uint i; + + if (cell->prim_buffer.num_verts == 0) + return; + + printf("*** Flushing prim buffer\n"); + for (i = 0; i < cell->num_spus; i++) { + struct cell_command_render *render = &cell_global.command[i].render; + render->prim_type = PIPE_PRIM_TRIANGLES; + render->num_verts = cell->prim_buffer.num_verts; + render->xmin = cell->prim_buffer.xmin; + render->ymin = cell->prim_buffer.ymin; + render->xmax = cell->prim_buffer.xmax; + render->ymax = cell->prim_buffer.ymax; + render->vertex_data = &cell->prim_buffer.vertex; + ASSERT_ALIGN16(render->vertex_data); + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER); + } + + cell->prim_buffer.num_verts = 0; +} + + + static void render_destroy( struct draw_stage *stage ) { FREE( stage ); diff --git a/src/mesa/pipe/cell/ppu/cell_render.h b/src/mesa/pipe/cell/ppu/cell_render.h index d66e1bdb79..826dcbafeb 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.h +++ b/src/mesa/pipe/cell/ppu/cell_render.h @@ -31,6 +31,9 @@ struct cell_context; struct draw_stage; +extern void +cell_flush_prim_buffer(struct cell_context *cell); + extern struct draw_stage *cell_draw_render_stage( struct cell_context *cell ); #endif /* CELL_RENDER_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 185eeb26e8..c487d0439a 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -51,8 +51,14 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, if (!ps->map) pipe_surface_map(ps); + if (pf_get_size(ps->format) != 4) { + printf("Cell: Skipping non 32bpp clear_surface\n"); + return; + } + for (i = 0; i < cell->num_spus; i++) { struct cell_command_framebuffer *fb = &cell_global.command[i].fb; + printf("%s %u start = 0x%x\n", __FUNCTION__, i, ps->map); fb->start = ps->map; fb->width = ps->width; fb->height = ps->height; @@ -66,7 +72,7 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES); } -#if 1 +#if 0 /* XXX Draw a test triangle over the cleared surface */ for (i = 0; i < cell->num_spus; i++) { /* Same triangle data for all SPUs */ diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index cc5eddb0f5..183397a5ff 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -37,6 +37,7 @@ #include "main.h" #include "tri.h" #include "pipe/cell/common.h" +#include "pipe/p_defines.h" /* helpful headers: @@ -48,6 +49,8 @@ volatile struct cell_init_info init; struct framebuffer fb; +uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; + int DefaultTag; @@ -62,12 +65,12 @@ wait_on_mask(unsigned tag) void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile) +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag) { uint offset = ty * fb->width_tiles + tx; uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; ubyte *src = (ubyte *) fb->start + offset * bytesPerTile; - int tag = DefaultTag; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -85,12 +88,12 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile) } void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile) +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag) { uint offset = ty * fb->width_tiles + tx; uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; ubyte *dst = (ubyte *) fb->start + offset * bytesPerTile; - int tag = DefaultTag; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -100,7 +103,7 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile) tile, (unsigned int) dst, bytesPerTile); */ mfc_put((void *) tile, /* src in local memory */ - (unsigned int) dst, /* dst in main mory */ + (unsigned int) dst, /* dst in main memory */ bytesPerTile, tag, 0, /* tid */ @@ -119,15 +122,19 @@ clear_tiles(const struct cell_command_clear_tiles *clear) for (i = 0; i < TILE_SIZE * TILE_SIZE; i++) tile[i] = clear->value; + /* printf("SPU: %s num=%d w=%d h=%d\n", __FUNCTION__, num_tiles, fb.width_tiles, fb.height_tiles); + */ + for (i = init.id; i < num_tiles; i += init.num_spus) { uint tx = i % fb.width_tiles; uint ty = i / fb.width_tiles; - put_tile(&fb, tx, ty, tile); + put_tile(&fb, tx, ty, tile, DefaultTag); /* XXX we don't want this here, but it fixes bad tile results */ wait_on_mask(1 << DefaultTag); } + } @@ -155,6 +162,76 @@ triangle(const struct cell_command_triangle *tri) +static void +render(const struct cell_command_render *render) +{ + const uint num_tiles = fb.width_tiles * fb.height_tiles; + struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; + int tag = DefaultTag; + uint i, j; + + /* + printf("SPU %u: RENDER buffer dst=%p src=%p size=%d\n", + init.id, + &prim_buffer, render->vertex_data, (int)sizeof(prim_buffer)); + */ + + ASSERT_ALIGN16(render->vertex_data); + ASSERT_ALIGN16(&prim_buffer); + + /* get vertex data from main memory */ + mfc_get(&prim_buffer, /* dest */ + (unsigned int) render->vertex_data, /* src */ + sizeof(prim_buffer), /* bytes */ + tag, + 0, /* tid */ + 0 /* rid */); + wait_on_mask( 1 << tag ); /* XXX temporary */ + + /* loop over tiles */ + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + + get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); + wait_on_mask(1 << DefaultTag); /* XXX temporary */ + + assert(render->prim_type == PIPE_PRIM_TRIANGLES); + + /* loop over tris */ + for (j = 0; j < render->num_verts; j += 3) { + struct prim_header prim; + + /* + printf(" %u: Triangle %g,%g %g,%g %g,%g\n", + init.id, + prim_buffer.vertex[j*3+0][0][0], + prim_buffer.vertex[j*3+0][0][1], + prim_buffer.vertex[j*3+1][0][0], + prim_buffer.vertex[j*3+1][0][1], + prim_buffer.vertex[j*3+2][0][0], + prim_buffer.vertex[j*3+2][0][1]); + */ + + /* pos */ + COPY_4V(prim.v[0].data[0], prim_buffer.vertex[j+0][0]); + COPY_4V(prim.v[1].data[0], prim_buffer.vertex[j+1][0]); + COPY_4V(prim.v[2].data[0], prim_buffer.vertex[j+2][0]); + + /* color */ + COPY_4V(prim.v[0].data[1], prim_buffer.vertex[j+0][1]); + COPY_4V(prim.v[1].data[1], prim_buffer.vertex[j+1][1]); + COPY_4V(prim.v[2].data[1], prim_buffer.vertex[j+2][1]); + + draw_triangle(&prim, tx, ty); + } + + put_tile(&fb, tx, ty, (uint *) tile, DefaultTag); + wait_on_mask(1 << DefaultTag); /* XXX temp */ + } +} + + /** * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. */ @@ -215,6 +292,12 @@ main_loop(void) printf("SPU %u: TRIANGLE\n", init.id); triangle(&cmd.tri); break; + case CELL_CMD_RENDER: + printf("SPU %u: RENDER %u verts, prim %u\n", + init.id, cmd.render.num_verts, cmd.render.prim_type); + render(&cmd.render); + break; + case CELL_CMD_FINISH: printf("SPU %u: FINISH\n", init.id); /* wait for all outstanding DMAs to finish */ diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 8c2796387f..47ce4be4b4 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -37,13 +37,16 @@ extern volatile struct cell_init_info init; struct framebuffer { - void *start; - uint width, height; + void *start; /**< addr of surface in main memory */ + uint width, height; /**< size in pixels */ uint width_tiles, height_tiles; /**< width and height in tiles */ }; +/* XXX Collect these globals in a struct: */ + extern struct framebuffer fb; +extern uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; extern int DefaultTag; @@ -52,10 +55,12 @@ void wait_on_mask(unsigned tag); void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile); +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag); void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile); +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag); #endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index cd648db360..ce759a5647 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -74,8 +74,6 @@ static int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; -static uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; - #endif @@ -879,11 +877,26 @@ draw_triangle(struct prim_header *tri, uint tx, uint ty) cliprect_maxx = (tx + 1) * TILE_SIZE; cliprect_maxy = (ty + 1) * TILE_SIZE; - get_tile(&fb, tx, ty, (uint *) tile); + get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); wait_on_mask(1 << DefaultTag); setup_tri(tri); - put_tile(&fb, tx, ty, (uint *) tile); + put_tile(&fb, tx, ty, (uint *) tile, DefaultTag); wait_on_mask(1 << DefaultTag); } + + +void +tri_draw(struct prim_header *tri, uint tx, uint ty) +{ + /* set clipping bounds to tile bounds */ + cliprect_minx = tx * TILE_SIZE; + cliprect_miny = ty * TILE_SIZE; + cliprect_maxx = (tx + 1) * TILE_SIZE; + cliprect_maxy = (ty + 1) * TILE_SIZE; + + setup_tri(tri); +} + + diff --git a/src/mesa/pipe/cell/spu/tri.h b/src/mesa/pipe/cell/spu/tri.h index dc66ad0f47..576030579f 100644 --- a/src/mesa/pipe/cell/spu/tri.h +++ b/src/mesa/pipe/cell/spu/tri.h @@ -49,4 +49,8 @@ extern void draw_triangle(struct prim_header *tri, uint tx, uint ty); +extern void +tri_draw(struct prim_header *tri, uint tx, uint ty); + + #endif /* TRI_H */ diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index 42c43387af..10dc09b13c 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -45,7 +45,10 @@ #ifdef GALLIUM_CELL #include "pipe/cell/ppu/cell_context.h" #include "pipe/cell/ppu/cell_winsys.h" +#else +#define TILE_SIZE 32 /* avoid compilation errors */ #endif + #include "xm_winsys_aub.h" @@ -214,7 +217,6 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf) { XImage *ximage = b->tempImage; struct xm_buffer *xm_buf = xm_bo(surf->buffer); - const int TILE_SIZE = 32; const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE; uint x, y; @@ -234,6 +236,7 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf) int tx = x / TILE_SIZE; int ty = y / TILE_SIZE; int offset = ty * tilesPerRow + tx; + offset *= 4 * TILE_SIZE * TILE_SIZE; ximage->data = (char *) xm_buf->data + offset; @@ -364,6 +367,10 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys, surf->cpp = pf_get_size(format); surf->pitch = round_up(width, alignment / surf->cpp); +#ifdef GALLIUM_CELL /* XXX a bit of a hack */ + height = round_up(height, TILE_SIZE); +#endif + assert(!surf->buffer); surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0); if(!surf->buffer) -- cgit v1.2.3 From d55c4ec9d2c0a8cd9ba75985962297381e6c0364 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 2 Jan 2008 18:58:44 -0700 Subject: remove previous triangle test code --- src/mesa/pipe/cell/common.h | 9 --------- src/mesa/pipe/cell/ppu/cell_surface.c | 33 --------------------------------- src/mesa/pipe/cell/spu/main.c | 30 +----------------------------- src/mesa/pipe/cell/spu/tri.c | 23 ++++------------------- src/mesa/pipe/cell/spu/tri.h | 4 ---- 5 files changed, 5 insertions(+), 94 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 0868e8d90f..8202bbbe76 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -49,7 +49,6 @@ #define CELL_CMD_EXIT 1 #define CELL_CMD_FRAMEBUFFER 2 #define CELL_CMD_CLEAR_TILES 3 -#define CELL_CMD_TRIANGLE 4 #define CELL_CMD_FINISH 5 #define CELL_CMD_RENDER 6 @@ -74,13 +73,6 @@ struct cell_command_clear_tiles } ALIGN16_ATTRIB; -struct cell_command_triangle -{ - float vert[3][4]; - float color[3][4]; -} ALIGN16_ATTRIB; - - struct cell_command_render { uint prim_type; @@ -95,7 +87,6 @@ struct cell_command { struct cell_command_framebuffer fb; struct cell_command_clear_tiles clear; - struct cell_command_triangle tri; struct cell_command_render render; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index c487d0439a..8b3ed4a23a 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -71,37 +71,4 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, cell_global.command[i].clear.value = clearValue | (i << 21); send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES); } - -#if 0 - /* XXX Draw a test triangle over the cleared surface */ - for (i = 0; i < cell->num_spus; i++) { - /* Same triangle data for all SPUs */ - struct cell_command_triangle *tri = &cell_global.command[i].tri; - tri->vert[0][0] = 20.0; - tri->vert[0][1] = ps->height - 20; - - tri->vert[1][0] = ps->width - 20.0; - tri->vert[1][1] = ps->height - 20; - - tri->vert[2][0] = ps->width / 2; - tri->vert[2][1] = 20.0; - - tri->color[0][0] = 1.0; - tri->color[0][1] = 0.0; - tri->color[0][2] = 0.0; - tri->color[0][3] = 0.0; - - tri->color[1][0] = 0.0; - tri->color[1][1] = 1.0; - tri->color[1][2] = 0.0; - tri->color[1][3] = 0.0; - - tri->color[2][0] = 0.0; - tri->color[2][1] = 0.0; - tri->color[2][2] = 1.0; - tri->color[2][3] = 0.0; - - send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_TRIANGLE); - } -#endif } diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 183397a5ff..94b9eda5c3 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -138,30 +138,6 @@ clear_tiles(const struct cell_command_clear_tiles *clear) } -static void -triangle(const struct cell_command_triangle *tri) -{ - uint num_tiles = fb.width_tiles * fb.height_tiles; - struct prim_header prim; - uint i; - - COPY_4V(prim.v[0].data[0], tri->vert[0]); - COPY_4V(prim.v[1].data[0], tri->vert[1]); - COPY_4V(prim.v[2].data[0], tri->vert[2]); - - COPY_4V(prim.v[0].data[1], tri->color[0]); - COPY_4V(prim.v[1].data[1], tri->color[1]); - COPY_4V(prim.v[2].data[1], tri->color[2]); - - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; - draw_triangle(&prim, tx, ty); - } -} - - - static void render(const struct cell_command_render *render) { @@ -223,7 +199,7 @@ render(const struct cell_command_render *render) COPY_4V(prim.v[1].data[1], prim_buffer.vertex[j+1][1]); COPY_4V(prim.v[2].data[1], prim_buffer.vertex[j+2][1]); - draw_triangle(&prim, tx, ty); + tri_draw(&prim, tx, ty); } put_tile(&fb, tx, ty, (uint *) tile, DefaultTag); @@ -288,10 +264,6 @@ main_loop(void) printf("SPU %u: CLEAR to 0x%08x\n", init.id, cmd.clear.value); clear_tiles(&cmd.clear); break; - case CELL_CMD_TRIANGLE: - printf("SPU %u: TRIANGLE\n", init.id); - triangle(&cmd.tri); - break; case CELL_CMD_RENDER: printf("SPU %u: RENDER %u verts, prim %u\n", init.id, cmd.render.num_verts, cmd.render.prim_type); diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index ce759a5647..4e198e638c 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -868,25 +868,10 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) #endif -void -draw_triangle(struct prim_header *tri, uint tx, uint ty) -{ - /* set clipping bounds to tile bounds */ - cliprect_minx = tx * TILE_SIZE; - cliprect_miny = ty * TILE_SIZE; - cliprect_maxx = (tx + 1) * TILE_SIZE; - cliprect_maxy = (ty + 1) * TILE_SIZE; - - get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); - wait_on_mask(1 << DefaultTag); - - setup_tri(tri); - - put_tile(&fb, tx, ty, (uint *) tile, DefaultTag); - wait_on_mask(1 << DefaultTag); -} - - +/** + * Draw triangle into tile at (tx, ty) (tile coords) + * The tile data should have already been fetched. + */ void tri_draw(struct prim_header *tri, uint tx, uint ty) { diff --git a/src/mesa/pipe/cell/spu/tri.h b/src/mesa/pipe/cell/spu/tri.h index 576030579f..01612a2579 100644 --- a/src/mesa/pipe/cell/spu/tri.h +++ b/src/mesa/pipe/cell/spu/tri.h @@ -45,10 +45,6 @@ struct prim_header { }; -extern void -draw_triangle(struct prim_header *tri, uint tx, uint ty); - - extern void tri_draw(struct prim_header *tri, uint tx, uint ty); -- cgit v1.2.3 From 54090bd841b302c6d48e7f130dbe07c8fd5a0a96 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 2 Jan 2008 19:05:34 -0700 Subject: only fetch as much vertex data as needed --- src/mesa/pipe/cell/common.h | 2 +- src/mesa/pipe/cell/ppu/cell_render.c | 1 + src/mesa/pipe/cell/spu/main.c | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 8202bbbe76..ee20bd150b 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -76,7 +76,7 @@ struct cell_command_clear_tiles struct cell_command_render { uint prim_type; - uint num_verts; + uint num_verts, num_attribs; float xmin, ymin, xmax, ymax; void *vertex_data; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c index 672406aa23..b97f4ff536 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.c +++ b/src/mesa/pipe/cell/ppu/cell_render.c @@ -155,6 +155,7 @@ cell_flush_prim_buffer(struct cell_context *cell) struct cell_command_render *render = &cell_global.command[i].render; render->prim_type = PIPE_PRIM_TRIANGLES; render->num_verts = cell->prim_buffer.num_verts; + render->num_attribs = CELL_MAX_ATTRIBS; render->xmin = cell->prim_buffer.xmin; render->ymin = cell->prim_buffer.ymin; render->xmax = cell->prim_buffer.xmax; diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 94b9eda5c3..5e29d4faaa 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -144,7 +144,7 @@ render(const struct cell_command_render *render) const uint num_tiles = fb.width_tiles * fb.height_tiles; struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; int tag = DefaultTag; - uint i, j; + uint i, j, vertex_bytes; /* printf("SPU %u: RENDER buffer dst=%p src=%p size=%d\n", @@ -155,10 +155,13 @@ render(const struct cell_command_render *render) ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(&prim_buffer); + /* how much vertex data */ + vertex_bytes = render->num_verts * render->num_attribs * 4 * sizeof(float); + /* get vertex data from main memory */ mfc_get(&prim_buffer, /* dest */ (unsigned int) render->vertex_data, /* src */ - sizeof(prim_buffer), /* bytes */ + vertex_bytes, /* size */ tag, 0, /* tid */ 0 /* rid */); @@ -166,8 +169,8 @@ render(const struct cell_command_render *render) /* loop over tiles */ for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; + const uint tx = i % fb.width_tiles; + const uint ty = i / fb.width_tiles; get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); wait_on_mask(1 << DefaultTag); /* XXX temporary */ -- cgit v1.2.3 From f6b7e2d3bf9af34704e9624246614c1583b655da Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 2 Jan 2008 19:31:36 -0700 Subject: make use of prim bounds box info --- src/mesa/pipe/cell/ppu/cell_context.c | 5 +++++ src/mesa/pipe/cell/ppu/cell_render.c | 5 +++++ src/mesa/pipe/cell/spu/main.c | 40 ++++++++++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index fb89837a7c..4fcf804d82 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -241,6 +241,11 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) draw_set_rasterize_stage(cell->draw, cell->render_stage); + cell->prim_buffer.xmin = 1e100; + cell->prim_buffer.ymin = 1e100; + cell->prim_buffer.xmax = -1e100; + cell->prim_buffer.ymax = -1e100; + /* * SPU stuff */ diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c index b97f4ff536..79aa37ea02 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.c +++ b/src/mesa/pipe/cell/ppu/cell_render.c @@ -166,6 +166,11 @@ cell_flush_prim_buffer(struct cell_context *cell) } cell->prim_buffer.num_verts = 0; + + cell->prim_buffer.xmin = 1e100; + cell->prim_buffer.ymin = 1e100; + cell->prim_buffer.xmax = -1e100; + cell->prim_buffer.ymax = -1e100; } diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 5e29d4faaa..94f13029ff 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -87,6 +87,7 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, 0 /* rid */); } + void put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, int tag) @@ -138,6 +139,33 @@ clear_tiles(const struct cell_command_clear_tiles *clear) } +/** + * Given a rendering command's bounding box (in pixels) compute the + * location of the corresponding screen tile bounding box. + */ +static INLINE void +tile_bounding_box(const struct cell_command_render *render, + uint *txmin, uint *tymin, + uint *box_num_tiles, uint *box_width_tiles) +{ + uint txmax, tymax, box_height_tiles; + + *txmin = (uint) render->xmin / TILE_SIZE; + *tymin = (uint) render->ymin / TILE_SIZE; + txmax = (uint) render->xmax / TILE_SIZE; + tymax = (uint) render->ymax / TILE_SIZE; + *box_width_tiles = txmax - *txmin + 1; + box_height_tiles = tymax - *tymin + 1; + *box_num_tiles = *box_width_tiles * box_height_tiles; + /* + printf("Render bounds: %g, %g ... %g, %g\n", + render->xmin, render->ymin, render->xmax, render->ymax); + printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax); + */ +} + + + static void render(const struct cell_command_render *render) { @@ -167,10 +195,16 @@ render(const struct cell_command_render *render) 0 /* rid */); wait_on_mask( 1 << tag ); /* XXX temporary */ + /* find tiles which intersect the prim bounding box */ + uint txmin, tymin, box_width_tiles, box_num_tiles; + tile_bounding_box(render, &txmin, &tymin, + &box_num_tiles, &box_width_tiles); + + /* loop over tiles */ - for (i = init.id; i < num_tiles; i += init.num_spus) { - const uint tx = i % fb.width_tiles; - const uint ty = i / fb.width_tiles; + for (i = init.id; i < box_num_tiles; i += init.num_spus) { + const uint tx = txmin + i % box_width_tiles; + const uint ty = tymin + i / box_width_tiles; get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); wait_on_mask(1 << DefaultTag); /* XXX temporary */ -- cgit v1.2.3 From 7aee3eff18decd6ce46f63a44c9a531414565265 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 07:49:13 -0700 Subject: better debug code --- src/mesa/pipe/cell/ppu/cell_surface.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 8b3ed4a23a..5fa37dd2cd 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -67,8 +67,21 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, } for (i = 0; i < cell->num_spus; i++) { - /* XXX clear color varies per-SPU for debugging */ - cell_global.command[i].clear.value = clearValue | (i << 21); +#if 1 + uint clr = clearValue; + /* XXX debug: clear color varied per-SPU to visualize tiles */ + if ((clr & 0xff) == 0) + clr |= 64 + i * 8; + if ((clr & 0xff00) == 0) + clr |= (64 + i * 8) << 8; + if ((clr & 0xff0000) == 0) + clr |= (64 + i * 8) << 16; + if ((clr & 0xff000000) == 0) + clr |= (64 + i * 8) << 24; + cell_global.command[i].clear.value = clr; +#else + cell_global.command[i].clear.value = clearValue; +#endif send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES); } } -- cgit v1.2.3 From 5cd96f7684adc7ba52a216fb676c7eb88ba3f66a Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 07:49:59 -0700 Subject: pass surface format in cell_command_framebuffer struct --- src/mesa/pipe/cell/common.h | 3 ++- src/mesa/pipe/cell/spu/main.c | 6 ++++-- src/mesa/pipe/cell/spu/main.h | 1 + src/mesa/pipe/cell/spu/tri.c | 3 +-- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index ee20bd150b..983ccd0775 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -35,6 +35,7 @@ #include "pipe/p_compiler.h" #include "pipe/p_util.h" +#include "pipe/p_format.h" /** for sanity checking */ @@ -60,7 +61,7 @@ struct cell_command_framebuffer { void *start; int width, height; - unsigned format; + enum pipe_format format; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 94f13029ff..02b23866a5 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -285,10 +285,12 @@ main_loop(void) exitFlag = 1; break; case CELL_CMD_FRAMEBUFFER: - printf("SPU %u: FRAMEBUFFER: %d x %d at %p\n", init.id, + printf("SPU %u: FRAMEBUFFER: %d x %d at %p, format 0x%x\n", init.id, cmd.fb.width, cmd.fb.height, - cmd.fb.start); + cmd.fb.start, + cmd.fb.format); + fb.format = cmd.fb.format; fb.width = cmd.fb.width; fb.height = cmd.fb.height; fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 47ce4be4b4..3240e01615 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -38,6 +38,7 @@ extern volatile struct cell_init_info init; struct framebuffer { void *start; /**< addr of surface in main memory */ + enum pipe_format format; uint width, height; /**< size in pixels */ uint width_tiles, height_tiles; /**< width and height in tiles */ }; diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 4e198e638c..3707ebea45 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -234,8 +234,7 @@ pack_color(const float color[4]) uint g = (uint) (color[1] * 255.0); uint b = (uint) (color[2] * 255.0); uint a = (uint) (color[3] * 255.0); - const enum pipe_format format = PIPE_FORMAT_A8R8G8B8_UNORM; /* XXX temp */ - switch (format) { + switch (fb.format) { case PIPE_FORMAT_A8R8G8B8_UNORM: return (a << 24) | (r << 16) | (g << 8) | b; case PIPE_FORMAT_B8G8R8A8_UNORM: -- cgit v1.2.3 From bb55835fc07e4d29e94c7db1e3854a5bd37c8aeb Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 08:58:01 -0700 Subject: insert a temporary flush to fix missing triangles artifact --- src/mesa/pipe/cell/ppu/cell_render.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c index 79aa37ea02..f5a91776a5 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.c +++ b/src/mesa/pipe/cell/ppu/cell_render.c @@ -171,6 +171,11 @@ cell_flush_prim_buffer(struct cell_context *cell) cell->prim_buffer.ymin = 1e100; cell->prim_buffer.xmax = -1e100; cell->prim_buffer.ymax = -1e100; + + /* XXX temporary, need to double-buffer the prim buffer until we get + * a real command buffer/list system. + */ + cell_flush(&cell->pipe, 0x0); } -- cgit v1.2.3 From 9b598df95ebe99d9aaf2043ce8786847978de4aa Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 08:58:51 -0700 Subject: asst changes in bbox code, dma tags, etc --- src/mesa/pipe/cell/spu/main.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 02b23866a5..a131bd5198 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -119,6 +119,7 @@ clear_tiles(const struct cell_command_clear_tiles *clear) uint num_tiles = fb.width_tiles * fb.height_tiles; uint i; uint tile[TILE_SIZE * TILE_SIZE] ALIGN16_ATTRIB; + int tag = init.id; for (i = 0; i < TILE_SIZE * TILE_SIZE; i++) tile[i] = clear->value; @@ -131,9 +132,9 @@ clear_tiles(const struct cell_command_clear_tiles *clear) for (i = init.id; i < num_tiles; i += init.num_spus) { uint tx = i % fb.width_tiles; uint ty = i / fb.width_tiles; - put_tile(&fb, tx, ty, tile, DefaultTag); + put_tile(&fb, tx, ty, tile, tag); /* XXX we don't want this here, but it fixes bad tile results */ - wait_on_mask(1 << DefaultTag); + wait_on_mask(1 << tag); } } @@ -148,6 +149,15 @@ tile_bounding_box(const struct cell_command_render *render, uint *txmin, uint *tymin, uint *box_num_tiles, uint *box_width_tiles) { +#if 0 + /* Debug: full-window bounding box */ + uint txmax = fb.width_tiles - 1; + uint tymax = fb.height_tiles - 1; + *txmin = 0; + *tymin = 0; + *box_num_tiles = fb.width_tiles * fb.height_tiles; + *box_width_tiles = fb.width_tiles; +#else uint txmax, tymax, box_height_tiles; *txmin = (uint) render->xmin / TILE_SIZE; @@ -157,11 +167,12 @@ tile_bounding_box(const struct cell_command_render *render, *box_width_tiles = txmax - *txmin + 1; box_height_tiles = tymax - *tymin + 1; *box_num_tiles = *box_width_tiles * box_height_tiles; - /* +#endif +#if 0 printf("Render bounds: %g, %g ... %g, %g\n", render->xmin, render->ymin, render->xmax, render->ymax); printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax); - */ +#endif } @@ -171,7 +182,7 @@ render(const struct cell_command_render *render) { const uint num_tiles = fb.width_tiles * fb.height_tiles; struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; - int tag = DefaultTag; + int tag = init.id /**DefaultTag**/; uint i, j, vertex_bytes; /* @@ -206,8 +217,11 @@ render(const struct cell_command_render *render) const uint tx = txmin + i % box_width_tiles; const uint ty = tymin + i / box_width_tiles; - get_tile(&fb, tx, ty, (uint *) tile, DefaultTag); - wait_on_mask(1 << DefaultTag); /* XXX temporary */ + assert(tx < fb.width_tiles); + assert(ty < fb.height_tiles); + + get_tile(&fb, tx, ty, (uint *) tile, tag); + wait_on_mask(1 << tag); /* XXX temporary */ assert(render->prim_type == PIPE_PRIM_TRIANGLES); @@ -239,8 +253,8 @@ render(const struct cell_command_render *render) tri_draw(&prim, tx, ty); } - put_tile(&fb, tx, ty, (uint *) tile, DefaultTag); - wait_on_mask(1 << DefaultTag); /* XXX temp */ + put_tile(&fb, tx, ty, (uint *) tile, tag); + wait_on_mask(1 << tag); /* XXX temp */ } } -- cgit v1.2.3 From 4ff6367295bc266cf1e3390570c9aee50fe716a0 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 09:40:02 -0700 Subject: Cell: improve surface state code to replace some temporary code. --- src/mesa/pipe/cell/common.h | 4 +- src/mesa/pipe/cell/ppu/cell_spu.c | 15 +++--- src/mesa/pipe/cell/ppu/cell_state_surface.c | 77 +++++++++++++++++++++++++++-- src/mesa/pipe/cell/ppu/cell_surface.c | 7 +-- src/mesa/pipe/cell/spu/main.c | 17 ++++--- src/mesa/pipe/cell/spu/main.h | 6 ++- src/mesa/pipe/cell/spu/tri.c | 2 +- 7 files changed, 103 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 983ccd0775..dff0b1f8ec 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -59,9 +59,9 @@ */ struct cell_command_framebuffer { - void *start; int width, height; - enum pipe_format format; + void *color_start, *depth_start; + enum pipe_format color_format, depth_format; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 55a0d5038b..15b89682fa 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -158,16 +158,19 @@ void test_spus(struct cell_context *cell) { uint i; - struct pipe_surface *surf = cell->framebuffer.cbufs[0]; + struct pipe_surface *csurf = cell->framebuffer.cbufs[0]; + struct pipe_surface *zsurf = cell->framebuffer.zbuf; printf("PPU: sleep(2)\n\n\n"); sleep(2); for (i = 0; i < cell->num_spus; i++) { - cell_global.command[i].fb.start = surf->map; - cell_global.command[i].fb.width = surf->width; - cell_global.command[i].fb.height = surf->height; - cell_global.command[i].fb.format = PIPE_FORMAT_A8R8G8B8_UNORM; + cell_global.command[i].fb.color_start = csurf->map; + cell_global.command[i].fb.depth_start = zsurf ? zsurf->map : NULL; + cell_global.command[i].fb.width = csurf->width; + cell_global.command[i].fb.height = csurf->height; + cell_global.command[i].fb.color_format = PIPE_FORMAT_A8R8G8B8_UNORM; + cell_global.command[i].fb.depth_format = PIPE_FORMAT_Z32_UNORM; send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER); } @@ -179,7 +182,7 @@ test_spus(struct cell_context *cell) finish_all(cell->num_spus); { - uint *b = (uint*) surf->map; + uint *b = (uint*) csurf->map; printf("PPU: Clear results: 0x%x 0x%x 0x%x 0x%x\n", b[0], b[1000], b[2000], b[3000]); } diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c index f7330caf5e..cd8e5def31 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -1,7 +1,36 @@ - - +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_inlines.h" #include "cell_context.h" #include "cell_state.h" +#include "cell_spu.h" + void cell_set_framebuffer_state(struct pipe_context *pipe, @@ -9,9 +38,49 @@ cell_set_framebuffer_state(struct pipe_context *pipe, { struct cell_context *cell = cell_context(pipe); - cell->framebuffer = *fb; + if (memcmp(&cell->framebuffer, fb, sizeof(*fb))) { + struct pipe_surface *csurf = fb->cbufs[0]; + struct pipe_surface *zsurf = fb->zbuf; + uint i; + + /* change in fb state */ + + /* unmap old surfaces */ + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + if (cell->framebuffer.cbufs[i] && + cell->framebuffer.cbufs[i]->map) { + pipe_surface_unmap(cell->framebuffer.cbufs[i]); + } + } - cell->dirty |= CELL_NEW_FRAMEBUFFER; + if (cell->framebuffer.zbuf && + cell->framebuffer.zbuf->map) { + pipe_surface_unmap(cell->framebuffer.zbuf); + } + + /* update my state */ + cell->framebuffer = *fb; + + /* map new surfaces */ + if (csurf && !csurf->map) + pipe_surface_map(csurf); + + if (zsurf && !zsurf->map) + pipe_surface_map(zsurf); + + for (i = 0; i < cell->num_spus; i++) { + struct cell_command_framebuffer *fb = &cell_global.command[i].fb; + fb->color_start = csurf->map; + fb->color_format = csurf->format; + fb->depth_start = zsurf ? zsurf->map : NULL; + fb->depth_format = zsurf ? zsurf->format : PIPE_FORMAT_NONE; + fb->width = csurf->width; + fb->height = csurf->height; + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER); + } + + cell->dirty |= CELL_NEW_FRAMEBUFFER; + } #if 0 struct pipe_surface *ps; diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 5fa37dd2cd..62e0febc0c 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -55,16 +55,17 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, printf("Cell: Skipping non 32bpp clear_surface\n"); return; } - +#if 0 for (i = 0; i < cell->num_spus; i++) { struct cell_command_framebuffer *fb = &cell_global.command[i].fb; printf("%s %u start = 0x%x\n", __FUNCTION__, i, ps->map); - fb->start = ps->map; + fb->color_start = ps->map; fb->width = ps->width; fb->height = ps->height; - fb->format = ps->format; + fb->color_format = ps->format; send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER); } +#endif for (i = 0; i < cell->num_spus; i++) { #if 1 diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index a131bd5198..6292962f44 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -70,7 +70,7 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, { uint offset = ty * fb->width_tiles + tx; uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; - ubyte *src = (ubyte *) fb->start + offset * bytesPerTile; + ubyte *src = (ubyte *) fb->color_start + offset * bytesPerTile; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -94,7 +94,7 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, { uint offset = ty * fb->width_tiles + tx; uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; - ubyte *dst = (ubyte *) fb->start + offset * bytesPerTile; + ubyte *dst = (ubyte *) fb->color_start + offset * bytesPerTile; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -180,7 +180,6 @@ tile_bounding_box(const struct cell_command_render *render, static void render(const struct cell_command_render *render) { - const uint num_tiles = fb.width_tiles * fb.height_tiles; struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; int tag = init.id /**DefaultTag**/; uint i, j, vertex_bytes; @@ -302,16 +301,20 @@ main_loop(void) printf("SPU %u: FRAMEBUFFER: %d x %d at %p, format 0x%x\n", init.id, cmd.fb.width, cmd.fb.height, - cmd.fb.start, - cmd.fb.format); - fb.format = cmd.fb.format; + cmd.fb.color_start, + cmd.fb.color_format); + fb.color_start = cmd.fb.color_start; + fb.depth_start = cmd.fb.depth_start; + fb.color_format = cmd.fb.color_format; + fb.depth_format = cmd.fb.depth_format; fb.width = cmd.fb.width; fb.height = cmd.fb.height; fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; + /* printf("SPU %u: %u x %u tiles\n", init.id, fb.width_tiles, fb.height_tiles); - fb.start = cmd.fb.start; + */ break; case CELL_CMD_CLEAR_TILES: printf("SPU %u: CLEAR to 0x%08x\n", init.id, cmd.clear.value); diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 3240e01615..60a565bfa7 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -37,8 +37,10 @@ extern volatile struct cell_init_info init; struct framebuffer { - void *start; /**< addr of surface in main memory */ - enum pipe_format format; + void *color_start; /**< addr of color surface in main memory */ + void *depth_start; /**< addr of depth surface in main memory */ + enum pipe_format color_format; + enum pipe_format depth_format; uint width, height; /**< size in pixels */ uint width_tiles, height_tiles; /**< width and height in tiles */ }; diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 3707ebea45..f58cc4b024 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -234,7 +234,7 @@ pack_color(const float color[4]) uint g = (uint) (color[1] * 255.0); uint b = (uint) (color[2] * 255.0); uint a = (uint) (color[3] * 255.0); - switch (fb.format) { + switch (fb.color_format) { case PIPE_FORMAT_A8R8G8B8_UNORM: return (a << 24) | (r << 16) | (g << 8) | b; case PIPE_FORMAT_B8G8R8A8_UNORM: -- cgit v1.2.3 From 3ffef8de825f843ed504a8177fd08af9196be696 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 09:40:32 -0700 Subject: disable bbox code until glitches are fixed --- src/mesa/pipe/cell/spu/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 6292962f44..bdb814e5d8 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -149,7 +149,7 @@ tile_bounding_box(const struct cell_command_render *render, uint *txmin, uint *tymin, uint *box_num_tiles, uint *box_width_tiles) { -#if 0 +#if 1 /* Debug: full-window bounding box */ uint txmax = fb.width_tiles - 1; uint tymax = fb.height_tiles - 1; -- cgit v1.2.3 From 5e00ae3fea51afd5de14d559f693645837b3903b Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 09:56:48 -0700 Subject: Cell: initial work for getting/putting Z tiles --- src/mesa/pipe/cell/spu/main.c | 47 ++++++++++++++++++++++++++++--------------- src/mesa/pipe/cell/spu/main.h | 7 ++++--- src/mesa/pipe/cell/spu/tri.c | 8 ++++---- 3 files changed, 39 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index bdb814e5d8..9580281971 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -49,7 +49,8 @@ volatile struct cell_init_info init; struct framebuffer fb; -uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; int DefaultTag; @@ -66,11 +67,13 @@ wait_on_mask(unsigned tag) void get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag) + int tag, int zBuf) { - uint offset = ty * fb->width_tiles + tx; - uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; - ubyte *src = (ubyte *) fb->color_start + offset * bytesPerTile; + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; + const ubyte *src = zBuf ? fb->depth_start : fb->color_start; + + src += offset * bytesPerTile; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -90,11 +93,13 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, void put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag) + int tag, int zBuf) { - uint offset = ty * fb->width_tiles + tx; - uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; - ubyte *dst = (ubyte *) fb->color_start + offset * bytesPerTile; + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; + ubyte *dst = zBuf ? fb->depth_start : fb->color_start; + + dst += offset * bytesPerTile; assert(tx < fb->width_tiles); assert(ty < fb->height_tiles); @@ -117,12 +122,12 @@ static void clear_tiles(const struct cell_command_clear_tiles *clear) { uint num_tiles = fb.width_tiles * fb.height_tiles; - uint i; - uint tile[TILE_SIZE * TILE_SIZE] ALIGN16_ATTRIB; + uint i, j; int tag = init.id; - for (i = 0; i < TILE_SIZE * TILE_SIZE; i++) - tile[i] = clear->value; + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ctile[i][j] = clear->value; /* printf("SPU: %s num=%d w=%d h=%d\n", @@ -132,7 +137,7 @@ clear_tiles(const struct cell_command_clear_tiles *clear) for (i = init.id; i < num_tiles; i += init.num_spus) { uint tx = i % fb.width_tiles; uint ty = i / fb.width_tiles; - put_tile(&fb, tx, ty, tile, tag); + put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); /* XXX we don't want this here, but it fixes bad tile results */ wait_on_mask(1 << tag); } @@ -219,9 +224,14 @@ render(const struct cell_command_render *render) assert(tx < fb.width_tiles); assert(ty < fb.height_tiles); - get_tile(&fb, tx, ty, (uint *) tile, tag); + get_tile(&fb, tx, ty, (uint *) ctile, tag, 0); wait_on_mask(1 << tag); /* XXX temporary */ + if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) { + get_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); + wait_on_mask(1 << (tag+1)); /* XXX temporary */ + } + assert(render->prim_type == PIPE_PRIM_TRIANGLES); /* loop over tris */ @@ -252,8 +262,13 @@ render(const struct cell_command_render *render) tri_draw(&prim, tx, ty); } - put_tile(&fb, tx, ty, (uint *) tile, tag); + put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); wait_on_mask(1 << tag); /* XXX temp */ + + if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) { + put_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); + wait_on_mask(1 << (tag+1)); /* XXX temporary */ + } } } diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 60a565bfa7..c22679c5d9 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -49,7 +49,8 @@ struct framebuffer { extern struct framebuffer fb; -extern uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +extern uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; extern int DefaultTag; @@ -59,11 +60,11 @@ wait_on_mask(unsigned tag); void get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag); + int tag, int zBuf); void put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag); + int tag, int zBuf); #endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index f58cc4b024..36599297b9 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -267,13 +267,13 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) eval_coeff(setup, 1, (float) x, (float) y, colors); if (mask & MASK_TOP_LEFT) - tile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); + ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); if (mask & MASK_TOP_RIGHT) - tile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); + ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); if (mask & MASK_BOTTOM_LEFT) - tile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); + ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); if (mask & MASK_BOTTOM_RIGHT) - tile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); + ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); #endif } -- cgit v1.2.3 From aa7f2333675f3e005f3eb6a40ac55d2fb55ea36e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 15:03:52 -0700 Subject: replace void * with struct draw_vertex_shader opaque type --- src/mesa/pipe/draw/draw_context.h | 10 ++++++---- src/mesa/pipe/draw/draw_vertex_shader.c | 16 ++++++---------- src/mesa/pipe/i915simple/i915_state.c | 6 +++--- src/mesa/pipe/softpipe/sp_state.h | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 6dc6e4ce82..60be3e194d 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -45,6 +45,7 @@ struct vertex_buffer; struct vertex_info; struct draw_context; struct draw_stage; +struct draw_vertex_shader; /** @@ -89,12 +90,13 @@ void draw_set_rasterize_stage( struct draw_context *draw, struct draw_stage *stage ); -void * draw_create_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader); +struct draw_vertex_shader * +draw_create_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader); void draw_bind_vertex_shader(struct draw_context *draw, - void *vcso); + struct draw_vertex_shader *dvs); void draw_delete_vertex_shader(struct draw_context *draw, - void *vcso); + struct draw_vertex_shader *dvs); boolean draw_use_sse(struct draw_context *draw); diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index d34d923018..1fa9af8cec 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -227,7 +227,7 @@ void draw_vertex_shader_queue_flush( struct draw_context *draw ) } -void * +struct draw_vertex_shader * draw_create_vertex_shader(struct draw_context *draw, const struct pipe_shader_state *shader) { @@ -263,10 +263,10 @@ draw_create_vertex_shader(struct draw_context *draw, } void draw_bind_vertex_shader(struct draw_context *draw, - void *vcso) + struct draw_vertex_shader *dvs) { draw_flush(draw); - draw->vertex_shader = (struct draw_vertex_shader*)(vcso); + draw->vertex_shader = dvs; /* specify the fragment program to interpret/execute */ tgsi_exec_machine_init(&draw->machine, @@ -276,15 +276,11 @@ void draw_bind_vertex_shader(struct draw_context *draw, } void draw_delete_vertex_shader(struct draw_context *draw, - void *vcso) + struct draw_vertex_shader *dvs) { - struct draw_vertex_shader *vs; - - vs = (struct draw_vertex_shader *) vcso; - #if defined(__i386__) || defined(__386__) - x86_release_func( (struct x86_function *) &vs->sse2_program ); + x86_release_func( (struct x86_function *) &dvs->sse2_program ); #endif - FREE( vs ); + FREE( dvs ); } diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index f8332aab37..1190e05699 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -438,12 +438,12 @@ i915_create_vs_state(struct pipe_context *pipe, return draw_create_vertex_shader(i915->draw, templ); } -static void i915_bind_vs_state(struct pipe_context *pipe, void *vs) +static void i915_bind_vs_state(struct pipe_context *pipe, void *shader) { struct i915_context *i915 = i915_context(pipe); /* just pass-through to draw module */ - draw_bind_vertex_shader(i915->draw, vs); + draw_bind_vertex_shader(i915->draw, (struct draw_vertex_shader *) shader); } static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) @@ -451,7 +451,7 @@ static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) struct i915_context *i915 = i915_context(pipe); /* just pass-through to draw module */ - draw_delete_vertex_shader(i915->draw, shader); + draw_delete_vertex_shader(i915->draw, (struct draw_vertex_shader *) shader); } static void i915_set_constant_buffer(struct pipe_context *pipe, diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index c1f5555a86..bac7b0876f 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -75,7 +75,7 @@ struct sp_fragment_shader_state { /** Subclass of pipe_shader_state */ struct sp_vertex_shader_state { struct pipe_shader_state shader; - void *draw_data; + struct draw_vertex_shader *draw_data; }; -- cgit v1.2.3 From 2b40838972bb84a0dff8f8a3c933b0d2b8384f10 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 15:05:51 -0700 Subject: rename vars, clean-up formatting --- src/mesa/pipe/softpipe/sp_state_fs.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index f72a91485f..830c873b25 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -38,8 +38,9 @@ #include "pipe/tgsi/exec/tgsi_sse2.h" -void * softpipe_create_fs_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +void * +softpipe_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_fragment_shader_state *state; @@ -78,7 +79,8 @@ void * softpipe_create_fs_state(struct pipe_context *pipe, } -void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) +void +softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -88,10 +90,10 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) } -void softpipe_delete_fs_state(struct pipe_context *pipe, - void *shader) +void +softpipe_delete_fs_state(struct pipe_context *pipe, void *fs) { - struct sp_fragment_shader_state *state = shader; + struct sp_fragment_shader_state *state = fs; #if defined(__i386__) || defined(__386__) x86_release_func( &state->sse2_program ); @@ -101,8 +103,9 @@ void softpipe_delete_fs_state(struct pipe_context *pipe, } -void * softpipe_create_vs_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +void * +softpipe_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_vertex_shader_state *state; @@ -125,7 +128,8 @@ void * softpipe_create_vs_state(struct pipe_context *pipe, } -void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) +void +softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -137,7 +141,8 @@ void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) } -void softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) +void +softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -149,9 +154,11 @@ void softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) } -void softpipe_set_constant_buffer(struct pipe_context *pipe, - uint shader, uint index, - const struct pipe_constant_buffer *buf) + +void +softpipe_set_constant_buffer(struct pipe_context *pipe, + uint shader, uint index, + const struct pipe_constant_buffer *buf) { struct softpipe_context *softpipe = softpipe_context(pipe); struct pipe_winsys *ws = pipe->winsys; -- cgit v1.2.3 From 4e62fbbfc5bcf368c3f11d4384008e64aad06ec8 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 3 Jan 2008 15:09:30 -0700 Subject: clean-ups, silence warnings --- src/mesa/pipe/draw/draw_vertex_shader.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index 1fa9af8cec..240149118f 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -117,7 +117,11 @@ run_vertex_program(struct draw_context *draw, #if defined(__i386__) || defined(__386__) if (draw->use_sse) { /* SSE */ - codegen_function func = (codegen_function) x86_get_func( &draw->vertex_shader->sse2_program ); + /* cast away const */ + struct draw_vertex_shader *shader + = (struct draw_vertex_shader *)draw->vertex_shader; + codegen_function func + = (codegen_function) x86_get_func( &shader->sse2_program ); func( machine->Inputs, machine->Outputs, @@ -193,7 +197,8 @@ run_vertex_program(struct draw_context *draw, * Run the vertex shader on all vertices in the vertex queue. * Called by the draw module when the vertx cache needs to be flushed. */ -void draw_vertex_shader_queue_flush( struct draw_context *draw ) +void +draw_vertex_shader_queue_flush(struct draw_context *draw) { unsigned i, j; @@ -246,7 +251,7 @@ draw_create_vertex_shader(struct draw_context *draw, struct pipe_shader_state *sh = (struct pipe_shader_state *) shader; x86_init_func( &vs->sse2_program ); - tgsi_emit_sse2( sh->tokens, &vs->sse2_program ); + tgsi_emit_sse2( (struct tgsi_token *) sh->tokens, &vs->sse2_program ); } #endif #ifdef MESA_LLVM @@ -255,15 +260,18 @@ draw_create_vertex_shader(struct draw_context *draw, if (!draw->engine) { draw->engine = gallivm_cpu_engine_create(vs->llvm_prog); } - else + else { gallivm_cpu_jit_compile(draw->engine, vs->llvm_prog); + } #endif return vs; } -void draw_bind_vertex_shader(struct draw_context *draw, - struct draw_vertex_shader *dvs) + +void +draw_bind_vertex_shader(struct draw_context *draw, + struct draw_vertex_shader *dvs) { draw_flush(draw); draw->vertex_shader = dvs; @@ -275,8 +283,10 @@ void draw_bind_vertex_shader(struct draw_context *draw, NULL /*samplers*/ ); } -void draw_delete_vertex_shader(struct draw_context *draw, - struct draw_vertex_shader *dvs) + +void +draw_delete_vertex_shader(struct draw_context *draw, + struct draw_vertex_shader *dvs) { #if defined(__i386__) || defined(__386__) x86_release_func( (struct x86_function *) &dvs->sse2_program ); -- cgit v1.2.3 From 25c9728644becd6342d025bdf355f311d00d5cb5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 3 Jan 2008 16:44:56 +0000 Subject: 965: scan fs inputs to work out interpolation in setup program --- src/mesa/pipe/i965simple/brw_sf.c | 102 +++++++++++++++++++++------------ src/mesa/pipe/i965simple/brw_sf_emit.c | 30 +++++++--- 2 files changed, 87 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_sf.c b/src/mesa/pipe/i965simple/brw_sf.c index 7b6fd3fff6..c04234ecf4 100644 --- a/src/mesa/pipe/i965simple/brw_sf.c +++ b/src/mesa/pipe/i965simple/brw_sf.c @@ -119,7 +119,11 @@ static boolean search_cache( struct brw_context *brw, */ static void upload_sf_prog( struct brw_context *brw ) { + const struct brw_fragment_program *fs = brw->attribs.FragmentProgram; struct brw_sf_prog_key key; + struct tgsi_parse_context parse; + int i, done = 0; + memset(&key, 0, sizeof(key)); @@ -149,6 +153,63 @@ static void upload_sf_prog( struct brw_context *brw ) } + + /* Scan fp inputs to figure out what interpolation modes are + * required for each incoming vp output. There is an assumption + * that the state tracker makes sure there is a 1:1 linkage between + * these sets of attributes (XXX: position??) + */ + tgsi_parse_init( &parse, fs->program.tokens ); + while( !done && + !tgsi_parse_end_of_tokens( &parse ) ) + { + tgsi_parse_token( &parse ); + + switch( parse.FullToken.Token.Type ) { + case TGSI_TOKEN_TYPE_DECLARATION: + if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT) + { + int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First; + int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last; + int interp_mode = parse.FullToken.FullDeclaration.Interpolation.Interpolate; + //int semantic = parse.FullToken.FullDeclaration.Semantic.SemanticName; + //int semantic_index = parse.FullToken.FullDeclaration.Semantic.SemanticIndex; + + _mesa_printf("fs input %d..%d interp mode %d\n", first, last, interp_mode); + + switch (interp_mode) { + case TGSI_INTERPOLATE_CONSTANT: + for (i = first; i <= last; i++) + key.const_mask |= (1 << i); + break; + case TGSI_INTERPOLATE_LINEAR: + for (i = first; i <= last; i++) + key.linear_mask |= (1 << i); + break; + case TGSI_INTERPOLATE_PERSPECTIVE: + for (i = first; i <= last; i++) + key.persp_mask |= (1 << i); + break; + default: + break; + } + + /* Also need stuff for flat shading, twosided color. + */ + + } + break; + default: + done = 1; + break; + } + } + + _mesa_printf("key.persp_mask: %x\n", key.persp_mask); + _mesa_printf("key.linear_mask: %x\n", key.linear_mask); + _mesa_printf("key.const_mask: %x\n", key.const_mask); + + // key.do_point_sprite = brw->attribs.Point->PointSprite; // key.SpriteOrigin = brw->attribs.Point->SpriteOrigin; @@ -176,6 +237,8 @@ const struct brw_tracked_state brw_sf_prog = { }; + +#if 0 /* Build a struct like the one we'd like the state tracker to pass to * us. */ @@ -202,43 +265,6 @@ static void update_sf_linkage( struct brw_context *brw ) - /* First scan fp inputs - */ - tgsi_parse_init( &parse, fs->program.tokens ); - while( !done && - !tgsi_parse_end_of_tokens( &parse ) ) - { - tgsi_parse_token( &parse ); - - switch( parse.FullToken.Token.Type ) { - case TGSI_TOKEN_TYPE_DECLARATION: - if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT) - { - int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First; - int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last; - - for (i = first; i < last; i++) { - state.fp_input[i].vp_output = ~0; - state.fp_input[i].bf_vp_output = ~0; - state.fp_input[i].interp_mode = - parse.FullToken.FullDeclaration.Interpolation.Interpolate; - - fp_semantic[i].semantic = - parse.FullToken.FullDeclaration.Semantic.SemanticName; - fp_semantic[i].semantic_index = - parse.FullToken.FullDeclaration.Semantic.SemanticIndex; - - } - - assert(last > state.fp_input_count); - state.fp_input_count = last; - } - break; - default: - done = 1; - break; - } - } assert(state.fp_input_count == fs->program.num_inputs); @@ -313,3 +339,5 @@ const struct brw_tracked_state brw_sf_linkage = { .update = update_sf_linkage }; + +#endif diff --git a/src/mesa/pipe/i965simple/brw_sf_emit.c b/src/mesa/pipe/i965simple/brw_sf_emit.c index 0fa61f14b6..bc3878a93a 100644 --- a/src/mesa/pipe/i965simple/brw_sf_emit.c +++ b/src/mesa/pipe/i965simple/brw_sf_emit.c @@ -134,30 +134,39 @@ static boolean calculate_masks( struct brw_sf_compile *c, ushort *pc_linear) { boolean is_last_attr = (reg == c->nr_setup_regs - 1); + unsigned persp_mask = c->key.persp_mask; + unsigned linear_mask = c->key.linear_mask; + _mesa_printf("persp_mask: %x\n", persp_mask); + _mesa_printf("linear_mask: %x\n", linear_mask); *pc_persp = 0; *pc_linear = 0; *pc = 0xf; -// if (persp_mask & (1 << c->idx_to_attr[reg*2])) -// *pc_persp = 0xf; + if (persp_mask & (1 << (reg*2))) + *pc_persp = 0xf; -// if (linear_mask & (1 << c->idx_to_attr[reg*2])) + if (linear_mask & (1 << (reg*2))) *pc_linear = 0xf; /* Maybe only processs one attribute on the final round: */ - if (1 || reg*2+1 < c->nr_setup_attrs) { + if (reg*2+1 < c->nr_setup_attrs) { *pc |= 0xf0; -// if (persp_mask & (1 << c->idx_to_attr[reg*2+1])) -// *pc_persp |= 0xf0; + if (persp_mask & (1 << (reg*2+1))) + *pc_persp |= 0xf0; -// if (linear_mask & (1 << c->idx_to_attr[reg*2+1])) + if (linear_mask & (1 << (reg*2+1))) *pc_linear |= 0xf0; } + _mesa_printf("pc: %x\n", *pc); + _mesa_printf("pc_persp: %x\n", *pc_persp); + _mesa_printf("pc_linear: %x\n", *pc_linear); + + return is_last_attr; } @@ -168,6 +177,8 @@ void brw_emit_tri_setup( struct brw_sf_compile *c ) struct brw_compile *p = &c->func; unsigned i; + _mesa_printf("%s START ==============\n", __FUNCTION__); + c->nr_verts = 3; alloc_regs(c); invert_det(c); @@ -181,7 +192,7 @@ void brw_emit_tri_setup( struct brw_sf_compile *c ) struct brw_reg a0 = offset(c->vert[0], i); struct brw_reg a1 = offset(c->vert[1], i); struct brw_reg a2 = offset(c->vert[2], i); - ushort pc, pc_persp, pc_linear; + ushort pc = 0, pc_persp = 0, pc_linear = 0; boolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear); if (pc_persp) @@ -238,6 +249,9 @@ void brw_emit_tri_setup( struct brw_sf_compile *c ) BRW_URB_SWIZZLE_TRANSPOSE); /* XXX: Swizzle control "SF to windower" */ } } + + _mesa_printf("%s DONE ==============\n", __FUNCTION__); + } -- cgit v1.2.3 From 65426b144e9c3f6c8c1e6d0c0dce0ae955f7d1c3 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 3 Jan 2008 17:21:22 +0000 Subject: 965: always perform SF parameter setup for position Match behaviour of DRI driver. Fix fragment shader to find the other parameters one slot further on. Will need more work to cope with FP's that actually reference position. --- src/mesa/pipe/i965simple/brw_sf.c | 10 +++++++++- src/mesa/pipe/i965simple/brw_wm_decl.c | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_sf.c b/src/mesa/pipe/i965simple/brw_sf.c index c04234ecf4..362196a0d1 100644 --- a/src/mesa/pipe/i965simple/brw_sf.c +++ b/src/mesa/pipe/i965simple/brw_sf.c @@ -58,7 +58,7 @@ static void compile_sf_prog( struct brw_context *brw, c.nr_attrs = c.key.vp_output_count; c.nr_attr_regs = (c.nr_attrs+1)/2; - c.nr_setup_attrs = c.key.fp_input_count; + c.nr_setup_attrs = c.key.fp_input_count + 1; /* +1 for position */ c.nr_setup_regs = (c.nr_setup_attrs+1)/2; c.prog_data.urb_read_length = c.nr_attr_regs; @@ -205,6 +205,14 @@ static void upload_sf_prog( struct brw_context *brw ) } } + /* Hack: Adjust for position. Optimize away when not required (ie + * for perspective interpolation). + */ + key.persp_mask <<= 1; + key.linear_mask <<= 1; + key.linear_mask |= 1; + key.const_mask <<= 1; + _mesa_printf("key.persp_mask: %x\n", key.persp_mask); _mesa_printf("key.linear_mask: %x\n", key.linear_mask); _mesa_printf("key.const_mask: %x\n", key.const_mask); diff --git a/src/mesa/pipe/i965simple/brw_wm_decl.c b/src/mesa/pipe/i965simple/brw_wm_decl.c index 5b1abb9d48..b45a333a2e 100644 --- a/src/mesa/pipe/i965simple/brw_wm_decl.c +++ b/src/mesa/pipe/i965simple/brw_wm_decl.c @@ -273,6 +273,12 @@ static void prealloc_reg(struct brw_wm_compile *c) c->reg_index += nr_curbe_regs; } + /* Adjust for parameter coefficients for position, which are + * currently always provided. + */ +// c->position_coef[i] = brw_vec8_grf(c->reg_index, 0); + c->reg_index += 2; + /* Next we receive the plane coefficients for parameter * interpolation: */ @@ -282,7 +288,7 @@ static void prealloc_reg(struct brw_wm_compile *c) } c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2; - c->prog_data.urb_read_length = c->fp->program.num_inputs * 2; + c->prog_data.urb_read_length = (c->fp->program.num_inputs + 1) * 2; c->prog_data.curb_read_length = nr_curbe_regs; /* That's the end of the payload, now we can start allocating registers. -- cgit v1.2.3 From f54012650eebd940a6a7006ebcc0b9160c0368cf Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 3 Jan 2008 19:46:16 +0000 Subject: 965: use correct offset for constants vs immediates --- src/mesa/pipe/i965simple/brw_vs_emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_vs_emit.c b/src/mesa/pipe/i965simple/brw_vs_emit.c index 0cc0a437b0..5f212bd055 100644 --- a/src/mesa/pipe/i965simple/brw_vs_emit.c +++ b/src/mesa/pipe/i965simple/brw_vs_emit.c @@ -630,8 +630,8 @@ static struct brw_reg get_reg( struct brw_vs_compile *c, assert(c->regs[file][index].nr != 0); return c->regs[file][index]; case TGSI_FILE_CONSTANT: - assert(c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_consts].nr != 0); - return c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_consts]; + assert(c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_imm].nr != 0); + return c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_imm]; case TGSI_FILE_IMMEDIATE: assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0); return c->regs[TGSI_FILE_CONSTANT][index]; -- cgit v1.2.3 From b1e67c5d840a2c07c4ccf73bf1d3200b8531efa3 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 3 Jan 2008 19:46:59 +0000 Subject: 965: fix various refcount issues --- src/mesa/pipe/xlib/xm_winsys_aub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c index b207638390..2be8f8793d 100644 --- a/src/mesa/pipe/xlib/xm_winsys_aub.c +++ b/src/mesa/pipe/xlib/xm_winsys_aub.c @@ -99,6 +99,8 @@ static void *aub_buffer_map(struct pipe_winsys *winsys, { struct aub_buffer *sbo = aub_bo(buf); + assert(sbo->data); + if (flags & PIPE_BUFFER_FLAG_WRITE) sbo->dump_on_unmap = 1; @@ -116,6 +118,9 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys, if (sbo->map_count == 0 && sbo->dump_on_unmap) { + + sbo->dump_on_unmap = 0; + brw_aub_gtt_data( iws->aubfile, sbo->offset, sbo->data, @@ -132,6 +137,7 @@ aub_buffer_reference(struct pipe_winsys *winsys, struct pipe_buffer_handle *buf) { if (*ptr) { + assert(aub_bo(*ptr)->refcount != 0); if (--(aub_bo(*ptr)->refcount) == 0) free(*ptr); *ptr = NULL; @@ -273,7 +279,9 @@ aub_buffer_create(struct pipe_winsys *winsys, unsigned flags, unsigned hint) { - return pipe_bo(CALLOC_STRUCT(aub_buffer)); + struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); + sbo->refcount = 1; + return pipe_bo(sbo); } @@ -282,6 +290,8 @@ aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); + sbo->refcount = 1; + /* Lets hope this is meant for upload, not as a result! */ aub_buffer_data( winsys, -- cgit v1.2.3 From 3385f3d250df1ad6899c0ac59a8f6b845cc5d504 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 4 Jan 2008 08:32:20 -0500 Subject: llvm: update llvm sources the latest svn --- src/mesa/pipe/llvm/gallivm_builtins.cpp | 342 +++++++----- src/mesa/pipe/llvm/instructions.cpp | 239 ++++---- src/mesa/pipe/llvm/llvm_base_shader.cpp | 960 +++++++++++++++++--------------- 3 files changed, 833 insertions(+), 708 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/llvm/gallivm_builtins.cpp b/src/mesa/pipe/llvm/gallivm_builtins.cpp index 48693ca2ed..1796f0a177 100644 --- a/src/mesa/pipe/llvm/gallivm_builtins.cpp +++ b/src/mesa/pipe/llvm/gallivm_builtins.cpp @@ -8,144 +8,170 @@ mod->setModuleIdentifier("shader"); // Type Definitions ArrayType* ArrayTy_0 = ArrayType::get(IntegerType::get(8), 25); -PointerType* PointerTy_1 = PointerType::get(ArrayTy_0); +PointerType* PointerTy_1 = PointerType::get(ArrayTy_0, 0); std::vectorFuncTy_2_args; FuncTy_2_args.push_back(Type::FloatTy); FuncTy_2_args.push_back(Type::FloatTy); -ParamAttrsList *FuncTy_2_PAL = 0; FunctionType* FuncTy_2 = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/FuncTy_2_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_2_PAL); + /*isVarArg=*/false); -PointerType* PointerTy_3 = PointerType::get(FuncTy_2); +PointerType* PointerTy_3 = PointerType::get(FuncTy_2, 0); VectorType* VectorTy_4 = VectorType::get(Type::FloatTy, 4); std::vectorFuncTy_5_args; FuncTy_5_args.push_back(VectorTy_4); -ParamAttrsList *FuncTy_5_PAL = 0; FunctionType* FuncTy_5 = FunctionType::get( /*Result=*/VectorTy_4, /*Params=*/FuncTy_5_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_5_PAL); + /*isVarArg=*/false); std::vectorFuncTy_6_args; FuncTy_6_args.push_back(VectorTy_4); FuncTy_6_args.push_back(VectorTy_4); FuncTy_6_args.push_back(VectorTy_4); -ParamAttrsList *FuncTy_6_PAL = 0; FunctionType* FuncTy_6 = FunctionType::get( /*Result=*/VectorTy_4, /*Params=*/FuncTy_6_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_6_PAL); + /*isVarArg=*/false); VectorType* VectorTy_7 = VectorType::get(IntegerType::get(32), 4); std::vectorFuncTy_9_args; -ParamAttrsList *FuncTy_9_PAL = 0; FunctionType* FuncTy_9 = FunctionType::get( /*Result=*/IntegerType::get(32), /*Params=*/FuncTy_9_args, - /*isVarArg=*/true, - /*ParamAttrs=*/FuncTy_9_PAL); + /*isVarArg=*/true); -PointerType* PointerTy_8 = PointerType::get(FuncTy_9); +PointerType* PointerTy_8 = PointerType::get(FuncTy_9, 0); -PointerType* PointerTy_10 = PointerType::get(IntegerType::get(8)); +PointerType* PointerTy_10 = PointerType::get(IntegerType::get(8), 0); std::vectorFuncTy_12_args; FuncTy_12_args.push_back(Type::FloatTy); -ParamAttrsList *FuncTy_12_PAL = 0; FunctionType* FuncTy_12 = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/FuncTy_12_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_12_PAL); + /*isVarArg=*/false); -PointerType* PointerTy_11 = PointerType::get(FuncTy_12); +PointerType* PointerTy_11 = PointerType::get(FuncTy_12, 0); std::vectorFuncTy_13_args; FuncTy_13_args.push_back(VectorTy_4); -ParamAttrsList *FuncTy_13_PAL = 0; FunctionType* FuncTy_13 = FunctionType::get( /*Result=*/IntegerType::get(32), /*Params=*/FuncTy_13_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_13_PAL); + /*isVarArg=*/false); // Function Declarations Function* func_approx = new Function( /*Type=*/FuncTy_2, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"approx", mod); func_approx->setCallingConv(CallingConv::C); +const ParamAttrsList *func_approx_PAL = 0; +func_approx->setParamAttrs(func_approx_PAL); Function* func_powf = new Function( /*Type=*/FuncTy_2, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"powf", mod); // (external, no body) func_powf->setCallingConv(CallingConv::C); +const ParamAttrsList *func_powf_PAL = 0; +func_powf->setParamAttrs(func_powf_PAL); Function* func_lit = new Function( /*Type=*/FuncTy_5, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"lit", mod); func_lit->setCallingConv(CallingConv::C); +const ParamAttrsList *func_lit_PAL = 0; +func_lit->setParamAttrs(func_lit_PAL); Function* func_cmp = new Function( /*Type=*/FuncTy_6, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"cmp", mod); func_cmp->setCallingConv(CallingConv::C); +const ParamAttrsList *func_cmp_PAL = 0; +{ + ParamAttrsVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind; + Attrs.push_back(PAWI); + func_cmp_PAL = ParamAttrsList::get(Attrs); + +} +func_cmp->setParamAttrs(func_cmp_PAL); Function* func_vcos = new Function( /*Type=*/FuncTy_5, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"vcos", mod); func_vcos->setCallingConv(CallingConv::C); +const ParamAttrsList *func_vcos_PAL = 0; +func_vcos->setParamAttrs(func_vcos_PAL); Function* func_printf = new Function( /*Type=*/FuncTy_9, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"printf", mod); // (external, no body) func_printf->setCallingConv(CallingConv::C); +const ParamAttrsList *func_printf_PAL = 0; +func_printf->setParamAttrs(func_printf_PAL); Function* func_cosf = new Function( /*Type=*/FuncTy_12, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"cosf", mod); // (external, no body) func_cosf->setCallingConv(CallingConv::C); +const ParamAttrsList *func_cosf_PAL = 0; +func_cosf->setParamAttrs(func_cosf_PAL); Function* func_scs = new Function( /*Type=*/FuncTy_5, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"scs", mod); func_scs->setCallingConv(CallingConv::C); +const ParamAttrsList *func_scs_PAL = 0; +func_scs->setParamAttrs(func_scs_PAL); Function* func_sinf = new Function( /*Type=*/FuncTy_12, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"sinf", mod); // (external, no body) func_sinf->setCallingConv(CallingConv::C); +const ParamAttrsList *func_sinf_PAL = 0; +func_sinf->setParamAttrs(func_sinf_PAL); Function* func_vsin = new Function( /*Type=*/FuncTy_5, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"vsin", mod); func_vsin->setCallingConv(CallingConv::C); +const ParamAttrsList *func_vsin_PAL = 0; +func_vsin->setParamAttrs(func_vsin_PAL); Function* func_kilp = new Function( /*Type=*/FuncTy_13, - /*Linkage=*/GlobalValue::ExternalLinkage, + /*Linkage=*/GlobalValue::WeakLinkage, /*Name=*/"kilp", mod); func_kilp->setCallingConv(CallingConv::C); +const ParamAttrsList *func_kilp_PAL = 0; +{ + ParamAttrsVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind; + Attrs.push_back(PAWI); + func_kilp_PAL = ParamAttrsList::get(Attrs); + +} +func_kilp->setParamAttrs(func_kilp_PAL); // Global Variable Declarations @@ -250,7 +276,9 @@ gvar_array__str1->setInitializer(const_array_15); float_call_params.push_back(float_b_addr_1); CallInst* float_call = new CallInst(func_powf, float_call_params.begin(), float_call_params.end(), "call", label_entry); float_call->setCallingConv(CallingConv::C); - float_call->setTailCall(true); + float_call->setTailCall(true);const ParamAttrsList *float_call_PAL = 0; + float_call->setParamAttrs(float_call_PAL); + new ReturnInst(float_call, label_entry); } @@ -266,28 +294,24 @@ gvar_array__str1->setInitializer(const_array_15); BasicBlock* label_UnifiedReturnBlock = new BasicBlock("UnifiedReturnBlock",func_lit,0); // Block entry (label_entry_38) - ExtractElementInst* float_tmp7 = new ExtractElementInst(packed_tmp, const_int32_19, "tmp7", label_entry_38); - FCmpInst* int1_cmp_39 = new FCmpInst(FCmpInst::FCMP_OGT, float_tmp7, const_float_18, "cmp", label_entry_38); + ExtractElementInst* float_tmp6 = new ExtractElementInst(packed_tmp, const_int32_19, "tmp6", label_entry_38); + FCmpInst* int1_cmp_39 = new FCmpInst(FCmpInst::FCMP_OGT, float_tmp6, const_float_18, "cmp", label_entry_38); new BranchInst(label_ifthen, label_UnifiedReturnBlock, int1_cmp_39, label_entry_38); // Block ifthen (label_ifthen) - InsertElementInst* packed_tmp12 = new InsertElementInst(const_packed_20, float_tmp7, const_int32_23, "tmp12", label_ifthen); - ExtractElementInst* float_tmp14 = new ExtractElementInst(packed_tmp, const_int32_23, "tmp14", label_ifthen); - ExtractElementInst* float_tmp16 = new ExtractElementInst(packed_tmp, const_int32_24, "tmp16", label_ifthen); - FCmpInst* int1_cmp_i = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp16, const_float_16, "cmp.i", label_ifthen); - SelectInst* float_b_addr_0_i = new SelectInst(int1_cmp_i, const_float_16, float_tmp16, "b.addr.0.i", label_ifthen); - FCmpInst* int1_cmp3_i = new FCmpInst(FCmpInst::FCMP_OGT, float_b_addr_0_i, const_float_17, "cmp3.i", label_ifthen); - SelectInst* float_b_addr_1_i = new SelectInst(int1_cmp3_i, const_float_17, float_b_addr_0_i, "b.addr.1.i", label_ifthen); - FCmpInst* int1_cmp7_i = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp14, const_float_18, "cmp7.i", label_ifthen); - SelectInst* float_a_addr_0_i = new SelectInst(int1_cmp7_i, const_float_18, float_tmp14, "a.addr.0.i", label_ifthen); - std::vector float_call_i_params; - float_call_i_params.push_back(float_a_addr_0_i); - float_call_i_params.push_back(float_b_addr_1_i); - CallInst* float_call_i = new CallInst(func_powf, float_call_i_params.begin(), float_call_i_params.end(), "call.i", label_ifthen); - float_call_i->setCallingConv(CallingConv::C); - float_call_i->setTailCall(true); - InsertElementInst* packed_tmp18 = new InsertElementInst(packed_tmp12, float_call_i, const_int32_25, "tmp18", label_ifthen); - new ReturnInst(packed_tmp18, label_ifthen); + InsertElementInst* packed_tmp10 = new InsertElementInst(const_packed_20, float_tmp6, const_int32_23, "tmp10", label_ifthen); + ExtractElementInst* float_tmp12 = new ExtractElementInst(packed_tmp, const_int32_23, "tmp12", label_ifthen); + ExtractElementInst* float_tmp14 = new ExtractElementInst(packed_tmp, const_int32_24, "tmp14", label_ifthen); + std::vector float_call_41_params; + float_call_41_params.push_back(float_tmp12); + float_call_41_params.push_back(float_tmp14); + CallInst* float_call_41 = new CallInst(func_approx, float_call_41_params.begin(), float_call_41_params.end(), "call", label_ifthen); + float_call_41->setCallingConv(CallingConv::C); + float_call_41->setTailCall(true);const ParamAttrsList *float_call_41_PAL = 0; + float_call_41->setParamAttrs(float_call_41_PAL); + + InsertElementInst* packed_tmp16 = new InsertElementInst(packed_tmp10, float_call_41, const_int32_25, "tmp16", label_ifthen); + new ReturnInst(packed_tmp16, label_ifthen); // Block UnifiedReturnBlock (label_UnifiedReturnBlock) new ReturnInst(const_packed_26, label_UnifiedReturnBlock); @@ -304,7 +328,7 @@ gvar_array__str1->setInitializer(const_array_15); Value* packed_tmp2 = args++; packed_tmp2->setName("tmp2"); - BasicBlock* label_entry_43 = new BasicBlock("entry",func_cmp,0); + BasicBlock* label_entry_44 = new BasicBlock("entry",func_cmp,0); BasicBlock* label_cond__14 = new BasicBlock("cond.?14",func_cmp,0); BasicBlock* label_cond_cont20 = new BasicBlock("cond.cont20",func_cmp,0); BasicBlock* label_cond__28 = new BasicBlock("cond.?28",func_cmp,0); @@ -312,15 +336,15 @@ gvar_array__str1->setInitializer(const_array_15); BasicBlock* label_cond__42 = new BasicBlock("cond.?42",func_cmp,0); BasicBlock* label_cond_cont48 = new BasicBlock("cond.cont48",func_cmp,0); - // Block entry (label_entry_43) - ExtractElementInst* float_tmp3 = new ExtractElementInst(packed_tmp0, const_int32_19, "tmp3", label_entry_43); - CastInst* double_conv = new FPExtInst(float_tmp3, Type::DoubleTy, "conv", label_entry_43); - FCmpInst* int1_cmp_44 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv, const_double_27, "cmp", label_entry_43); - ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp0, const_int32_23, "tmp11", label_entry_43); - CastInst* double_conv12 = new FPExtInst(float_tmp11, Type::DoubleTy, "conv12", label_entry_43); - FCmpInst* int1_cmp13 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv12, const_double_27, "cmp13", label_entry_43); - SelectInst* packed_tmp1_tmp2 = new SelectInst(int1_cmp_44, packed_tmp1, packed_tmp2, "tmp1.tmp2", label_entry_43); - new BranchInst(label_cond__14, label_cond_cont20, int1_cmp13, label_entry_43); + // Block entry (label_entry_44) + ExtractElementInst* float_tmp3 = new ExtractElementInst(packed_tmp0, const_int32_19, "tmp3", label_entry_44); + CastInst* double_conv = new FPExtInst(float_tmp3, Type::DoubleTy, "conv", label_entry_44); + FCmpInst* int1_cmp_45 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv, const_double_27, "cmp", label_entry_44); + ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp0, const_int32_23, "tmp11", label_entry_44); + CastInst* double_conv12 = new FPExtInst(float_tmp11, Type::DoubleTy, "conv12", label_entry_44); + FCmpInst* int1_cmp13 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv12, const_double_27, "cmp13", label_entry_44); + SelectInst* packed_tmp1_tmp2 = new SelectInst(int1_cmp_45, packed_tmp1, packed_tmp2, "tmp1.tmp2", label_entry_44); + new BranchInst(label_cond__14, label_cond_cont20, int1_cmp13, label_entry_44); // Block cond.?14 (label_cond__14) ShuffleVectorInst* packed_tmp233 = new ShuffleVectorInst(packed_tmp1_tmp2, packed_tmp1, const_packed_28, "tmp233", label_cond__14); @@ -386,125 +410,155 @@ gvar_array__str1->setInitializer(const_array_15); Value* packed_val = args++; packed_val->setName("val"); - BasicBlock* label_entry_52 = new BasicBlock("entry",func_vcos,0); - - // Block entry (label_entry_52) - ExtractElementInst* float_tmp1 = new ExtractElementInst(packed_val, const_int32_19, "tmp1", label_entry_52); - CastInst* double_conv_53 = new FPExtInst(float_tmp1, Type::DoubleTy, "conv", label_entry_52); - ExtractElementInst* float_tmp3_54 = new ExtractElementInst(packed_val, const_int32_23, "tmp3", label_entry_52); - CastInst* double_conv4 = new FPExtInst(float_tmp3_54, Type::DoubleTy, "conv4", label_entry_52); - ExtractElementInst* float_tmp6 = new ExtractElementInst(packed_val, const_int32_25, "tmp6", label_entry_52); - CastInst* double_conv7 = new FPExtInst(float_tmp6, Type::DoubleTy, "conv7", label_entry_52); - ExtractElementInst* float_tmp9 = new ExtractElementInst(packed_val, const_int32_24, "tmp9", label_entry_52); - CastInst* double_conv10 = new FPExtInst(float_tmp9, Type::DoubleTy, "conv10", label_entry_52); + BasicBlock* label_entry_53 = new BasicBlock("entry",func_vcos,0); + + // Block entry (label_entry_53) + ExtractElementInst* float_tmp1 = new ExtractElementInst(packed_val, const_int32_19, "tmp1", label_entry_53); + CastInst* double_conv_54 = new FPExtInst(float_tmp1, Type::DoubleTy, "conv", label_entry_53); + ExtractElementInst* float_tmp3_55 = new ExtractElementInst(packed_val, const_int32_23, "tmp3", label_entry_53); + CastInst* double_conv4 = new FPExtInst(float_tmp3_55, Type::DoubleTy, "conv4", label_entry_53); + ExtractElementInst* float_tmp6_56 = new ExtractElementInst(packed_val, const_int32_25, "tmp6", label_entry_53); + CastInst* double_conv7 = new FPExtInst(float_tmp6_56, Type::DoubleTy, "conv7", label_entry_53); + ExtractElementInst* float_tmp9 = new ExtractElementInst(packed_val, const_int32_24, "tmp9", label_entry_53); + CastInst* double_conv10 = new FPExtInst(float_tmp9, Type::DoubleTy, "conv10", label_entry_53); std::vector int32_call_params; int32_call_params.push_back(const_ptr_34); - int32_call_params.push_back(double_conv_53); + int32_call_params.push_back(double_conv_54); int32_call_params.push_back(double_conv4); int32_call_params.push_back(double_conv7); int32_call_params.push_back(double_conv10); - CallInst* int32_call = new CallInst(func_printf, int32_call_params.begin(), int32_call_params.end(), "call", label_entry_52); + CallInst* int32_call = new CallInst(func_printf, int32_call_params.begin(), int32_call_params.end(), "call", label_entry_53); int32_call->setCallingConv(CallingConv::C); - int32_call->setTailCall(true); - CallInst* float_call13 = new CallInst(func_cosf, float_tmp1, "call13", label_entry_52); + int32_call->setTailCall(true);const ParamAttrsList *int32_call_PAL = 0; + int32_call->setParamAttrs(int32_call_PAL); + + CallInst* float_call13 = new CallInst(func_cosf, float_tmp1, "call13", label_entry_53); float_call13->setCallingConv(CallingConv::C); - float_call13->setTailCall(true); - InsertElementInst* packed_tmp15 = new InsertElementInst(const_packed_35, float_call13, const_int32_19, "tmp15", label_entry_52); - InsertElementInst* packed_tmp20 = new InsertElementInst(packed_tmp15, float_call13, const_int32_23, "tmp20", label_entry_52); - InsertElementInst* packed_tmp25 = new InsertElementInst(packed_tmp20, float_call13, const_int32_25, "tmp25", label_entry_52); - InsertElementInst* packed_tmp30 = new InsertElementInst(packed_tmp25, float_call13, const_int32_24, "tmp30", label_entry_52); - CastInst* double_conv33 = new FPExtInst(float_call13, Type::DoubleTy, "conv33", label_entry_52); + float_call13->setTailCall(true);const ParamAttrsList *float_call13_PAL = 0; + float_call13->setParamAttrs(float_call13_PAL); + + InsertElementInst* packed_tmp15 = new InsertElementInst(const_packed_35, float_call13, const_int32_19, "tmp15", label_entry_53); + CallInst* float_call18 = new CallInst(func_cosf, float_tmp1, "call18", label_entry_53); + float_call18->setCallingConv(CallingConv::C); + float_call18->setTailCall(true);const ParamAttrsList *float_call18_PAL = 0; + float_call18->setParamAttrs(float_call18_PAL); + + InsertElementInst* packed_tmp20 = new InsertElementInst(packed_tmp15, float_call18, const_int32_23, "tmp20", label_entry_53); + CallInst* float_call23 = new CallInst(func_cosf, float_tmp1, "call23", label_entry_53); + float_call23->setCallingConv(CallingConv::C); + float_call23->setTailCall(true);const ParamAttrsList *float_call23_PAL = 0; + float_call23->setParamAttrs(float_call23_PAL); + + InsertElementInst* packed_tmp25 = new InsertElementInst(packed_tmp20, float_call23, const_int32_25, "tmp25", label_entry_53); + CallInst* float_call28 = new CallInst(func_cosf, float_tmp1, "call28", label_entry_53); + float_call28->setCallingConv(CallingConv::C); + float_call28->setTailCall(true);const ParamAttrsList *float_call28_PAL = 0; + float_call28->setParamAttrs(float_call28_PAL); + + InsertElementInst* packed_tmp30 = new InsertElementInst(packed_tmp25, float_call28, const_int32_24, "tmp30", label_entry_53); + CastInst* double_conv33 = new FPExtInst(float_call13, Type::DoubleTy, "conv33", label_entry_53); + CastInst* double_conv36 = new FPExtInst(float_call18, Type::DoubleTy, "conv36", label_entry_53); + CastInst* double_conv39 = new FPExtInst(float_call23, Type::DoubleTy, "conv39", label_entry_53); + CastInst* double_conv42 = new FPExtInst(float_call28, Type::DoubleTy, "conv42", label_entry_53); std::vector int32_call43_params; int32_call43_params.push_back(const_ptr_36); int32_call43_params.push_back(double_conv33); - int32_call43_params.push_back(double_conv33); - int32_call43_params.push_back(double_conv33); - int32_call43_params.push_back(double_conv33); - CallInst* int32_call43 = new CallInst(func_printf, int32_call43_params.begin(), int32_call43_params.end(), "call43", label_entry_52); + int32_call43_params.push_back(double_conv36); + int32_call43_params.push_back(double_conv39); + int32_call43_params.push_back(double_conv42); + CallInst* int32_call43 = new CallInst(func_printf, int32_call43_params.begin(), int32_call43_params.end(), "call43", label_entry_53); int32_call43->setCallingConv(CallingConv::C); - int32_call43->setTailCall(true); - new ReturnInst(packed_tmp30, label_entry_52); + int32_call43->setTailCall(true);const ParamAttrsList *int32_call43_PAL = 0; + int32_call43->setParamAttrs(int32_call43_PAL); + + new ReturnInst(packed_tmp30, label_entry_53); } // Function: scs (func_scs) { Function::arg_iterator args = func_scs->arg_begin(); - Value* packed_val_56 = args++; - packed_val_56->setName("val"); - - BasicBlock* label_entry_57 = new BasicBlock("entry",func_scs,0); - - // Block entry (label_entry_57) - ExtractElementInst* float_tmp2 = new ExtractElementInst(packed_val_56, const_int32_19, "tmp2", label_entry_57); - CallInst* float_call_58 = new CallInst(func_cosf, float_tmp2, "call", label_entry_57); - float_call_58->setCallingConv(CallingConv::C); - float_call_58->setTailCall(true); - InsertElementInst* packed_tmp5 = new InsertElementInst(const_packed_35, float_call_58, const_int32_19, "tmp5", label_entry_57); - CallInst* float_call7 = new CallInst(func_sinf, float_tmp2, "call7", label_entry_57); + Value* packed_val_58 = args++; + packed_val_58->setName("val"); + + BasicBlock* label_entry_59 = new BasicBlock("entry",func_scs,0); + + // Block entry (label_entry_59) + ExtractElementInst* float_tmp2 = new ExtractElementInst(packed_val_58, const_int32_19, "tmp2", label_entry_59); + CallInst* float_call_60 = new CallInst(func_cosf, float_tmp2, "call", label_entry_59); + float_call_60->setCallingConv(CallingConv::C); + float_call_60->setTailCall(true);const ParamAttrsList *float_call_60_PAL = 0; + float_call_60->setParamAttrs(float_call_60_PAL); + + InsertElementInst* packed_tmp5 = new InsertElementInst(const_packed_35, float_call_60, const_int32_19, "tmp5", label_entry_59); + CallInst* float_call7 = new CallInst(func_sinf, float_tmp2, "call7", label_entry_59); float_call7->setCallingConv(CallingConv::C); - float_call7->setTailCall(true); - InsertElementInst* packed_tmp9 = new InsertElementInst(packed_tmp5, float_call7, const_int32_23, "tmp9", label_entry_57); - new ReturnInst(packed_tmp9, label_entry_57); + float_call7->setTailCall(true);const ParamAttrsList *float_call7_PAL = 0; + float_call7->setParamAttrs(float_call7_PAL); + + InsertElementInst* packed_tmp9 = new InsertElementInst(packed_tmp5, float_call7, const_int32_23, "tmp9", label_entry_59); + new ReturnInst(packed_tmp9, label_entry_59); } // Function: vsin (func_vsin) { Function::arg_iterator args = func_vsin->arg_begin(); - Value* packed_val_60 = args++; - packed_val_60->setName("val"); - - BasicBlock* label_entry_61 = new BasicBlock("entry",func_vsin,0); - - // Block entry (label_entry_61) - ExtractElementInst* float_tmp2_62 = new ExtractElementInst(packed_val_60, const_int32_19, "tmp2", label_entry_61); - CallInst* float_call_63 = new CallInst(func_sinf, float_tmp2_62, "call", label_entry_61); - float_call_63->setCallingConv(CallingConv::C); - float_call_63->setTailCall(true); - InsertElementInst* packed_tmp6 = new InsertElementInst(const_packed_35, float_call_63, const_int32_19, "tmp6", label_entry_61); - InsertElementInst* packed_tmp9_64 = new InsertElementInst(packed_tmp6, float_call_63, const_int32_23, "tmp9", label_entry_61); - InsertElementInst* packed_tmp12_65 = new InsertElementInst(packed_tmp9_64, float_call_63, const_int32_25, "tmp12", label_entry_61); - InsertElementInst* packed_tmp15_66 = new InsertElementInst(packed_tmp12_65, float_call_63, const_int32_24, "tmp15", label_entry_61); - new ReturnInst(packed_tmp15_66, label_entry_61); + Value* packed_val_62 = args++; + packed_val_62->setName("val"); + + BasicBlock* label_entry_63 = new BasicBlock("entry",func_vsin,0); + + // Block entry (label_entry_63) + ExtractElementInst* float_tmp2_64 = new ExtractElementInst(packed_val_62, const_int32_19, "tmp2", label_entry_63); + CallInst* float_call_65 = new CallInst(func_sinf, float_tmp2_64, "call", label_entry_63); + float_call_65->setCallingConv(CallingConv::C); + float_call_65->setTailCall(true);const ParamAttrsList *float_call_65_PAL = 0; + float_call_65->setParamAttrs(float_call_65_PAL); + + InsertElementInst* packed_tmp6 = new InsertElementInst(const_packed_35, float_call_65, const_int32_19, "tmp6", label_entry_63); + InsertElementInst* packed_tmp9_66 = new InsertElementInst(packed_tmp6, float_call_65, const_int32_23, "tmp9", label_entry_63); + InsertElementInst* packed_tmp12 = new InsertElementInst(packed_tmp9_66, float_call_65, const_int32_25, "tmp12", label_entry_63); + InsertElementInst* packed_tmp15_67 = new InsertElementInst(packed_tmp12, float_call_65, const_int32_24, "tmp15", label_entry_63); + new ReturnInst(packed_tmp15_67, label_entry_63); } // Function: kilp (func_kilp) { Function::arg_iterator args = func_kilp->arg_begin(); - Value* packed_val_68 = args++; - packed_val_68->setName("val"); + Value* packed_val_69 = args++; + packed_val_69->setName("val"); - BasicBlock* label_entry_69 = new BasicBlock("entry",func_kilp,0); + BasicBlock* label_entry_70 = new BasicBlock("entry",func_kilp,0); BasicBlock* label_lor_rhs = new BasicBlock("lor_rhs",func_kilp,0); - BasicBlock* label_lor_rhs6 = new BasicBlock("lor_rhs6",func_kilp,0); - BasicBlock* label_lor_rhs13 = new BasicBlock("lor_rhs13",func_kilp,0); - BasicBlock* label_UnifiedReturnBlock_70 = new BasicBlock("UnifiedReturnBlock",func_kilp,0); + BasicBlock* label_lor_rhs5 = new BasicBlock("lor_rhs5",func_kilp,0); + BasicBlock* label_lor_rhs11 = new BasicBlock("lor_rhs11",func_kilp,0); + BasicBlock* label_UnifiedReturnBlock_71 = new BasicBlock("UnifiedReturnBlock",func_kilp,0); - // Block entry (label_entry_69) - ExtractElementInst* float_tmp1_71 = new ExtractElementInst(packed_val_68, const_int32_19, "tmp1", label_entry_69); - FCmpInst* int1_cmp_72 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp1_71, const_float_18, "cmp", label_entry_69); - new BranchInst(label_UnifiedReturnBlock_70, label_lor_rhs, int1_cmp_72, label_entry_69); + // Block entry (label_entry_70) + ExtractElementInst* float_tmp1_72 = new ExtractElementInst(packed_val_69, const_int32_19, "tmp1", label_entry_70); + FCmpInst* int1_cmp_73 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp1_72, const_float_18, "cmp", label_entry_70); + new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs, int1_cmp_73, label_entry_70); // Block lor_rhs (label_lor_rhs) - ExtractElementInst* float_tmp3_74 = new ExtractElementInst(packed_val_68, const_int32_23, "tmp3", label_lor_rhs); - FCmpInst* int1_cmp5 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp3_74, const_float_18, "cmp5", label_lor_rhs); - new BranchInst(label_UnifiedReturnBlock_70, label_lor_rhs6, int1_cmp5, label_lor_rhs); - - // Block lor_rhs6 (label_lor_rhs6) - ExtractElementInst* float_tmp8 = new ExtractElementInst(packed_val_68, const_int32_25, "tmp8", label_lor_rhs6); - FCmpInst* int1_cmp10 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp8, const_float_18, "cmp10", label_lor_rhs6); - new BranchInst(label_UnifiedReturnBlock_70, label_lor_rhs13, int1_cmp10, label_lor_rhs6); - - // Block lor_rhs13 (label_lor_rhs13) - ExtractElementInst* float_tmp15 = new ExtractElementInst(packed_val_68, const_int32_24, "tmp15", label_lor_rhs13); - FCmpInst* int1_cmp17 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp15, const_float_18, "cmp17", label_lor_rhs13); - CastInst* int32_retval = new ZExtInst(int1_cmp17, IntegerType::get(32), "retval", label_lor_rhs13); - new ReturnInst(int32_retval, label_lor_rhs13); - - // Block UnifiedReturnBlock (label_UnifiedReturnBlock_70) - new ReturnInst(const_int32_23, label_UnifiedReturnBlock_70); + ExtractElementInst* float_tmp3_75 = new ExtractElementInst(packed_val_69, const_int32_23, "tmp3", label_lor_rhs); + FCmpInst* int1_cmp4 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp3_75, const_float_18, "cmp4", label_lor_rhs); + new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs5, int1_cmp4, label_lor_rhs); + + // Block lor_rhs5 (label_lor_rhs5) + ExtractElementInst* float_tmp7 = new ExtractElementInst(packed_val_69, const_int32_25, "tmp7", label_lor_rhs5); + FCmpInst* int1_cmp8 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp7, const_float_18, "cmp8", label_lor_rhs5); + new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs11, int1_cmp8, label_lor_rhs5); + + // Block lor_rhs11 (label_lor_rhs11) + ExtractElementInst* float_tmp13 = new ExtractElementInst(packed_val_69, const_int32_24, "tmp13", label_lor_rhs11); + FCmpInst* int1_cmp14 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp13, const_float_18, "cmp14", label_lor_rhs11); + CastInst* int32_retval = new ZExtInst(int1_cmp14, IntegerType::get(32), "retval", label_lor_rhs11); + new ReturnInst(int32_retval, label_lor_rhs11); + + // Block UnifiedReturnBlock (label_UnifiedReturnBlock_71) + new ReturnInst(const_int32_23, label_UnifiedReturnBlock_71); } diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp index c8d1992587..55d39fa5f1 100644 --- a/src/mesa/pipe/llvm/instructions.cpp +++ b/src/mesa/pipe/llvm/instructions.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -103,13 +104,13 @@ const char * Instructions::name(const char *prefix) llvm::Value * Instructions::dp3(llvm::Value *in1, llvm::Value *in2) { Value *mulRes = mul(in1, in2); - ExtractElementInst *x = m_builder.CreateExtractElement(mulRes, + Value *x = m_builder.CreateExtractElement(mulRes, m_storage->constantInt(0), name("extractx")); - ExtractElementInst *y = m_builder.CreateExtractElement(mulRes, + Value *y = m_builder.CreateExtractElement(mulRes, m_storage->constantInt(1), name("extracty")); - ExtractElementInst *z = m_builder.CreateExtractElement(mulRes, + Value *z = m_builder.CreateExtractElement(mulRes, m_storage->constantInt(2), name("extractz")); Value *xy = m_builder.CreateAdd(x, y,name("xy")); @@ -127,13 +128,13 @@ llvm::Value *Instructions::callFSqrt(llvm::Value *val) FunctionType* fsqrtType = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/fsqrtArgs, - /*isVarArg=*/false, - /*ParamAttrs=*/fsqrtPal); + /*isVarArg=*/false); m_llvmFSqrt = new Function( /*Type=*/fsqrtType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.sqrt.f32", m_mod); m_llvmFSqrt->setCallingConv(CallingConv::C); + m_llvmFSqrt->setParamAttrs(fsqrtPal); } CallInst *call = m_builder.CreateCall(m_llvmFSqrt, val, name("sqrt")); @@ -144,9 +145,9 @@ llvm::Value *Instructions::callFSqrt(llvm::Value *val) llvm::Value * Instructions::rsq(llvm::Value *in1) { - ExtractElementInst *x = m_builder.CreateExtractElement(in1, - m_storage->constantInt(0), - name("extractx")); + Value *x = m_builder.CreateExtractElement(in1, + m_storage->constantInt(0), + name("extractx")); Value *abs = callFAbs(x); Value *sqrt = callFSqrt(abs); @@ -161,9 +162,9 @@ llvm::Value * Instructions::vectorFromVals(llvm::Value *x, llvm::Value *y, llvm::Value *z, llvm::Value *w) { Constant *const_vec = Constant::getNullValue(m_floatVecType); - InsertElementInst *res = m_builder.CreateInsertElement(const_vec, x, - m_storage->constantInt(0), - name("vecx")); + Value *res = m_builder.CreateInsertElement(const_vec, x, + m_storage->constantInt(0), + name("vecx")); res = m_builder.CreateInsertElement(res, y, m_storage->constantInt(1), name("vecxy")); res = m_builder.CreateInsertElement(res, z, m_storage->constantInt(2), @@ -184,13 +185,13 @@ llvm::Value *Instructions::callFAbs(llvm::Value *val) FunctionType* fabsType = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/fabsArgs, - /*isVarArg=*/false, - /*ParamAttrs=*/fabsPal); + /*isVarArg=*/false); m_llvmFAbs = new Function( /*Type=*/fabsType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"fabs", m_mod); m_llvmFAbs->setCallingConv(CallingConv::C); + m_llvmFAbs->setParamAttrs(fabsPal); } CallInst *call = m_builder.CreateCall(m_llvmFAbs, val, name("fabs")); @@ -227,13 +228,13 @@ llvm::Value * Instructions::callPow(llvm::Value *val1, llvm::Value *val2) FunctionType* powType = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/powArgs, - /*isVarArg=*/false, - /*ParamAttrs=*/powPal); + /*isVarArg=*/false); m_llvmPow = new Function( /*Type=*/powType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.pow.f32", m_mod); m_llvmPow->setCallingConv(CallingConv::C); + m_llvmPow->setParamAttrs(powPal); } std::vector params; params.push_back(val1); @@ -247,21 +248,21 @@ llvm::Value * Instructions::callPow(llvm::Value *val1, llvm::Value *val2) llvm::Value * Instructions::pow(llvm::Value *in1, llvm::Value *in2) { - ExtractElementInst *x1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(0), - name("x1")); - ExtractElementInst *x2 = m_builder.CreateExtractElement(in2, - m_storage->constantInt(0), - name("x2")); + Value *x1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(0), + name("x1")); + Value *x2 = m_builder.CreateExtractElement(in2, + m_storage->constantInt(0), + name("x2")); llvm::Value *val = callPow(x1, x2); return vectorFromVals(val, val, val, val); } llvm::Value * Instructions::rcp(llvm::Value *in1) { - ExtractElementInst *x1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(0), - name("x1")); + Value *x1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(0), + name("x1")); Value *res = m_builder.CreateFDiv(ConstantFP::get(Type::FloatTy, APFloat(1.f)), x1, name("rcp")); @@ -290,18 +291,18 @@ llvm::Value * Instructions::dph(llvm::Value *in1, llvm::Value *in2) llvm::Value * Instructions::dst(llvm::Value *in1, llvm::Value *in2) { - ExtractElementInst *y1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(1), - name("y1")); - ExtractElementInst *z = m_builder.CreateExtractElement(in1, - m_storage->constantInt(2), - name("z")); - ExtractElementInst *y2 = m_builder.CreateExtractElement(in2, - m_storage->constantInt(1), - name("y2")); - ExtractElementInst *w = m_builder.CreateExtractElement(in2, - m_storage->constantInt(3), - name("w")); + Value *y1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(1), + name("y1")); + Value *z = m_builder.CreateExtractElement(in1, + m_storage->constantInt(2), + name("z")); + Value *y2 = m_builder.CreateExtractElement(in2, + m_storage->constantInt(1), + name("y2")); + Value *w = m_builder.CreateExtractElement(in2, + m_storage->constantInt(3), + name("w")); Value *ry = m_builder.CreateMul(y1, y2, name("tyuy")); return vectorFromVals(ConstantFP::get(Type::FloatTy, APFloat(1.f)), ry, z, w); @@ -326,13 +327,13 @@ llvm::Value * Instructions::callFloor(llvm::Value *val) FunctionType* floorType = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/floorArgs, - /*isVarArg=*/false, - /*ParamAttrs=*/floorPal); + /*isVarArg=*/false); m_llvmFloor = new Function( /*Type=*/floorType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"floorf", m_mod); m_llvmFloor->setCallingConv(CallingConv::C); + m_llvmFloor->setParamAttrs(floorPal); } CallInst *call = m_builder.CreateCall(m_llvmFloor, val, name("floorf")); @@ -369,13 +370,13 @@ llvm::Value * Instructions::callFLog(llvm::Value *val) FunctionType* flogType = FunctionType::get( /*Result=*/Type::FloatTy, /*Params=*/flogArgs, - /*isVarArg=*/false, - /*ParamAttrs=*/flogPal); + /*isVarArg=*/false); m_llvmFlog = new Function( /*Type=*/flogType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"logf", m_mod); m_llvmFlog->setCallingConv(CallingConv::C); + m_llvmFlog->setParamAttrs(flogPal); } CallInst *call = m_builder.CreateCall(m_llvmFlog, val, name("logf")); @@ -399,20 +400,20 @@ llvm::Value * Instructions::min(llvm::Value *in1, llvm::Value *in2) std::vector vec2 = extractVector(in2); Value *xcmp = m_builder.CreateFCmpOLT(vec1[0], vec2[0], name("xcmp")); - SelectInst *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0], - name("selx")); + Value *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0], + name("selx")); Value *ycmp = m_builder.CreateFCmpOLT(vec1[1], vec2[1], name("ycmp")); - SelectInst *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1], - name("sely")); + Value *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1], + name("sely")); Value *zcmp = m_builder.CreateFCmpOLT(vec1[2], vec2[2], name("zcmp")); - SelectInst *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2], - name("selz")); + Value *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2], + name("selz")); Value *wcmp = m_builder.CreateFCmpOLT(vec1[3], vec2[3], name("wcmp")); - SelectInst *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3], - name("selw")); + Value *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3], + name("selw")); return vectorFromVals(selx, sely, selz, selw); } @@ -423,24 +424,24 @@ llvm::Value * Instructions::max(llvm::Value *in1, llvm::Value *in2) std::vector vec2 = extractVector(in2); Value *xcmp = m_builder.CreateFCmpOGT(vec1[0], vec2[0], - name("xcmp")); - SelectInst *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0], - name("selx")); + name("xcmp")); + Value *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0], + name("selx")); Value *ycmp = m_builder.CreateFCmpOGT(vec1[1], vec2[1], - name("ycmp")); - SelectInst *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1], - name("sely")); + name("ycmp")); + Value *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1], + name("sely")); Value *zcmp = m_builder.CreateFCmpOGT(vec1[2], vec2[2], - name("zcmp")); - SelectInst *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2], - name("selz")); + name("zcmp")); + Value *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2], + name("selz")); Value *wcmp = m_builder.CreateFCmpOGT(vec1[3], vec2[3], - name("wcmp")); - SelectInst *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3], - name("selw")); + name("wcmp")); + Value *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3], + name("selw")); return vectorFromVals(selx, sely, selz, selw); } @@ -474,17 +475,17 @@ void Instructions::printVector(llvm::Value *val) func_printf = declarePrintf(); assert(func_printf); std::vector vec = extractVector(val); - CastInst *dx = m_builder.CreateFPExt(vec[0], Type::DoubleTy, name("dx")); - CastInst *dy = m_builder.CreateFPExt(vec[1], Type::DoubleTy, name("dy")); - CastInst *dz = m_builder.CreateFPExt(vec[2], Type::DoubleTy, name("dz")); - CastInst *dw = m_builder.CreateFPExt(vec[3], Type::DoubleTy, name("dw")); + Value *dx = m_builder.CreateFPExt(vec[0], Type::DoubleTy, name("dx")); + Value *dy = m_builder.CreateFPExt(vec[1], Type::DoubleTy, name("dy")); + Value *dz = m_builder.CreateFPExt(vec[2], Type::DoubleTy, name("dz")); + Value *dw = m_builder.CreateFPExt(vec[3], Type::DoubleTy, name("dw")); std::vector params; params.push_back(m_fmtPtr); params.push_back(dx); params.push_back(dy); params.push_back(dz); params.push_back(dw); - CallInst* call = m_builder.CreateCall(func_printf, params.begin(), params.end(), + CallInst *call = m_builder.CreateCall(func_printf, params.begin(), params.end(), name("printf")); call->setCallingConv(CallingConv::C); call->setTailCall(true); @@ -497,13 +498,13 @@ llvm::Function * Instructions::declarePrintf() FunctionType* funcTy = FunctionType::get( /*Result=*/IntegerType::get(32), /*Params=*/args, - /*isVarArg=*/true, - /*ParamAttrs=*/params); + /*isVarArg=*/true); Function* func_printf = new Function( /*Type=*/funcTy, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"printf", m_mod); func_printf->setCallingConv(CallingConv::C); + func_printf->setParamAttrs(params); return func_printf; } @@ -516,16 +517,16 @@ llvm::Value * Instructions::sgt(llvm::Value *in1, llvm::Value *in2) std::vector vec1 = extractVector(in1); std::vector vec2 = extractVector(in2); Value *xcmp = m_builder.CreateFCmpOGT(vec1[0], vec2[0], name("xcmp")); - SelectInst *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); + Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); Value *ycmp = m_builder.CreateFCmpOGT(vec1[1], vec2[1], name("ycmp")); - SelectInst *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); + Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); Value *zcmp = m_builder.CreateFCmpOGT(vec1[2], vec2[2], name("zcmp")); - SelectInst *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); + Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); Value *wcmp = m_builder.CreateFCmpOGT(vec1[3], vec2[3], name("wcmp")); - SelectInst *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); + Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); return vectorFromVals(x, y, z, w); } @@ -538,16 +539,16 @@ llvm::Value * Instructions::sge(llvm::Value *in1, llvm::Value *in2) std::vector vec2 = extractVector(in2); Value *xcmp = m_builder.CreateFCmpOGE(vec1[0], vec2[0], name("xcmp")); - SelectInst *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); + Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); Value *ycmp = m_builder.CreateFCmpOGE(vec1[1], vec2[1], name("ycmp")); - SelectInst *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); + Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); Value *zcmp = m_builder.CreateFCmpOGE(vec1[2], vec2[2], name("zcmp")); - SelectInst *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); + Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); Value *wcmp = m_builder.CreateFCmpOGE(vec1[3], vec2[3], name("wcmp")); - SelectInst *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); + Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); return vectorFromVals(x, y, z, w); } @@ -562,41 +563,41 @@ llvm::Value * Instructions::slt(llvm::Value *in1, llvm::Value *in2) std::vector vec2 = extractVector(in2); Value *xcmp = m_builder.CreateFCmpOLT(vec1[0], vec2[0], name("xcmp")); - SelectInst *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); + Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel")); Value *ycmp = m_builder.CreateFCmpOLT(vec1[1], vec2[1], name("ycmp")); - SelectInst *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); + Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel")); Value *zcmp = m_builder.CreateFCmpOLT(vec1[2], vec2[2], name("zcmp")); - SelectInst *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); + Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel")); Value *wcmp = m_builder.CreateFCmpOLT(vec1[3], vec2[3], name("wcmp")); - SelectInst *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); + Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel")); return vectorFromVals(x, y, z, w); } llvm::Value * Instructions::cross(llvm::Value *in1, llvm::Value *in2) { - ExtractElementInst *x1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(0), - name("x1")); - ExtractElementInst *y1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(1), - name("y1")); - ExtractElementInst *z1 = m_builder.CreateExtractElement(in1, - m_storage->constantInt(2), - name("z1")); - - ExtractElementInst *x2 = m_builder.CreateExtractElement(in2, - m_storage->constantInt(0), - name("x2")); - ExtractElementInst *y2 = m_builder.CreateExtractElement(in2, - m_storage->constantInt(1), - name("y2")); - ExtractElementInst *z2 = m_builder.CreateExtractElement(in2, - m_storage->constantInt(2), - name("z2")); + Value *x1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(0), + name("x1")); + Value *y1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(1), + name("y1")); + Value *z1 = m_builder.CreateExtractElement(in1, + m_storage->constantInt(2), + name("z1")); + + Value *x2 = m_builder.CreateExtractElement(in2, + m_storage->constantInt(0), + name("x2")); + Value *y2 = m_builder.CreateExtractElement(in2, + m_storage->constantInt(1), + name("y2")); + Value *z2 = m_builder.CreateExtractElement(in2, + m_storage->constantInt(2), + name("z2")); Value *y1z2 = mul(y1, z2); Value *z1y2 = mul(z1, y2); @@ -631,8 +632,8 @@ void Instructions::ifop(llvm::Value *in) Constant *float0 = Constant::getNullValue(Type::FloatTy); - ExtractElementInst *x = m_builder.CreateExtractElement(in, m_storage->constantInt(0), - name("extractx")); + Value *x = m_builder.CreateExtractElement(in, m_storage->constantInt(0), + name("extractx")); Value *xcmp = m_builder.CreateFCmpUNE(x, float0, name("xcmp")); m_builder.CreateCondBr(xcmp, ifthen, ifend); //m_builder.SetInsertPoint(yblock); @@ -708,22 +709,22 @@ void Instructions::brk() llvm::Value * Instructions::trunc(llvm::Value *in) { std::vector vec = extractVector(in); - CastInst *icastx = m_builder.CreateFPToSI(vec[0], IntegerType::get(32), - name("ftoix")); - CastInst *icasty = m_builder.CreateFPToSI(vec[1], IntegerType::get(32), - name("ftoiy")); - CastInst *icastz = m_builder.CreateFPToSI(vec[2], IntegerType::get(32), - name("ftoiz")); - CastInst *icastw = m_builder.CreateFPToSI(vec[3], IntegerType::get(32), - name("ftoiw")); - CastInst *fx = m_builder.CreateSIToFP(icastx, Type::FloatTy, - name("fx")); - CastInst *fy = m_builder.CreateSIToFP(icasty, Type::FloatTy, - name("fy")); - CastInst *fz = m_builder.CreateSIToFP(icastz, Type::FloatTy, - name("fz")); - CastInst *fw = m_builder.CreateSIToFP(icastw, Type::FloatTy, - name("fw")); + Value *icastx = m_builder.CreateFPToSI(vec[0], IntegerType::get(32), + name("ftoix")); + Value *icasty = m_builder.CreateFPToSI(vec[1], IntegerType::get(32), + name("ftoiy")); + Value *icastz = m_builder.CreateFPToSI(vec[2], IntegerType::get(32), + name("ftoiz")); + Value *icastw = m_builder.CreateFPToSI(vec[3], IntegerType::get(32), + name("ftoiw")); + Value *fx = m_builder.CreateSIToFP(icastx, Type::FloatTy, + name("fx")); + Value *fy = m_builder.CreateSIToFP(icasty, Type::FloatTy, + name("fy")); + Value *fz = m_builder.CreateSIToFP(icastz, Type::FloatTy, + name("fz")); + Value *fw = m_builder.CreateSIToFP(icastw, Type::FloatTy, + name("fw")); return vectorFromVals(fx, fy, fz, fw); } @@ -743,7 +744,7 @@ void Instructions::cal(int label, llvm::Value *input) llvm::Function * Instructions::declareFunc(int label) { - PointerType *vecPtr = PointerType::get(m_floatVecType); + PointerType *vecPtr = PointerType::getUnqual(m_floatVecType); std::vector args; args.push_back(vecPtr); args.push_back(vecPtr); @@ -753,14 +754,14 @@ llvm::Function * Instructions::declareFunc(int label) FunctionType *funcType = FunctionType::get( /*Result=*/Type::VoidTy, /*Params=*/args, - /*isVarArg=*/false, - /*ParamAttrs=*/params); + /*isVarArg=*/false); std::string name = createFuncName(label); Function *func = new Function( /*Type=*/funcType, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/name.c_str(), m_mod); func->setCallingConv(CallingConv::C); + func->setParamAttrs(params); return func; } diff --git a/src/mesa/pipe/llvm/llvm_base_shader.cpp b/src/mesa/pipe/llvm/llvm_base_shader.cpp index 85fa389d79..951afc390e 100644 --- a/src/mesa/pipe/llvm/llvm_base_shader.cpp +++ b/src/mesa/pipe/llvm/llvm_base_shader.cpp @@ -4,14 +4,14 @@ Module* createBaseShader() { // Module Construction Module* mod = new Module("Shader"); - mod->setDataLayout(""); - mod->setTargetTriple("i686-apple-darwin9"); + mod->setDataLayout("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"); + mod->setTargetTriple("i686-pc-linux-gnu"); // Type Definitions std::vectorStructTy_struct_ShaderInput_fields; VectorType* VectorTy_1 = VectorType::get(Type::FloatTy, 4); - PointerType* PointerTy_0 = PointerType::get(VectorTy_1); + PointerType* PointerTy_0 = PointerType::get(VectorTy_1, 0); StructTy_struct_ShaderInput_fields.push_back(PointerTy_0); StructTy_struct_ShaderInput_fields.push_back(PointerTy_0); @@ -21,9 +21,6 @@ Module* createBaseShader() { StructType* StructTy_struct_ShaderInput = StructType::get(StructTy_struct_ShaderInput_fields, /*isPacked=*/false); mod->addTypeName("struct.ShaderInput", StructTy_struct_ShaderInput); - OpaqueType* OpaqueTy_struct_pipe_mipmap_tree = OpaqueType::get(); - mod->addTypeName("struct.pipe_mipmap_tree", OpaqueTy_struct_pipe_mipmap_tree); - OpaqueType* OpaqueTy_struct_pipe_sampler_state = OpaqueType::get(); mod->addTypeName("struct.pipe_sampler_state", OpaqueTy_struct_pipe_sampler_state); @@ -31,199 +28,217 @@ Module* createBaseShader() { mod->addTypeName("struct.softpipe_tile_cache", OpaqueTy_struct_softpipe_tile_cache); std::vectorStructTy_struct_tgsi_sampler_fields; - PointerType* PointerTy_2 = PointerType::get(OpaqueTy_struct_pipe_sampler_state); + PointerType* PointerTy_2 = PointerType::get(OpaqueTy_struct_pipe_sampler_state, 0); StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_2); - PointerType* PointerTy_3 = PointerType::get(OpaqueTy_struct_pipe_mipmap_tree); - - StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_3); - std::vectorFuncTy_5_args; + std::vectorFuncTy_4_args; PATypeHolder StructTy_struct_tgsi_sampler_fwd = OpaqueType::get(); - PointerType* PointerTy_6 = PointerType::get(StructTy_struct_tgsi_sampler_fwd); + PointerType* PointerTy_5 = PointerType::get(StructTy_struct_tgsi_sampler_fwd, 0); - FuncTy_5_args.push_back(PointerTy_6); - PointerType* PointerTy_7 = PointerType::get(Type::FloatTy); + FuncTy_4_args.push_back(PointerTy_5); + PointerType* PointerTy_6 = PointerType::get(Type::FloatTy, 0); - FuncTy_5_args.push_back(PointerTy_7); - FuncTy_5_args.push_back(PointerTy_7); - FuncTy_5_args.push_back(PointerTy_7); - FuncTy_5_args.push_back(Type::FloatTy); - ArrayType* ArrayTy_9 = ArrayType::get(Type::FloatTy, 4); + FuncTy_4_args.push_back(PointerTy_6); + FuncTy_4_args.push_back(PointerTy_6); + FuncTy_4_args.push_back(PointerTy_6); + FuncTy_4_args.push_back(Type::FloatTy); + ArrayType* ArrayTy_8 = ArrayType::get(Type::FloatTy, 4); - PointerType* PointerTy_8 = PointerType::get(ArrayTy_9); + PointerType* PointerTy_7 = PointerType::get(ArrayTy_8, 0); - FuncTy_5_args.push_back(PointerTy_8); - ParamAttrsList *FuncTy_5_PAL = 0; - FunctionType* FuncTy_5 = FunctionType::get( + FuncTy_4_args.push_back(PointerTy_7); + FunctionType* FuncTy_4 = FunctionType::get( /*Result=*/Type::VoidTy, - /*Params=*/FuncTy_5_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_5_PAL); + /*Params=*/FuncTy_4_args, + /*isVarArg=*/false); - PointerType* PointerTy_4 = PointerType::get(FuncTy_5); + PointerType* PointerTy_3 = PointerType::get(FuncTy_4, 0); - StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_4); - PointerType* PointerTy_10 = PointerType::get(IntegerType::get(8)); + StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_3); + PointerType* PointerTy_9 = PointerType::get(IntegerType::get(8), 0); - StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_10); - PointerType* PointerTy_11 = PointerType::get(OpaqueTy_struct_softpipe_tile_cache); + StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_9); + PointerType* PointerTy_10 = PointerType::get(OpaqueTy_struct_softpipe_tile_cache, 0); - StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_11); + StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_10); StructType* StructTy_struct_tgsi_sampler = StructType::get(StructTy_struct_tgsi_sampler_fields, /*isPacked=*/false); mod->addTypeName("struct.tgsi_sampler", StructTy_struct_tgsi_sampler); cast(StructTy_struct_tgsi_sampler_fwd.get())->refineAbstractTypeTo(StructTy_struct_tgsi_sampler); StructTy_struct_tgsi_sampler = cast(StructTy_struct_tgsi_sampler_fwd.get()); - std::vectorFuncTy_12_args; - ArrayType* ArrayTy_14 = ArrayType::get(VectorTy_1, 16); + std::vectorFuncTy_11_args; + ArrayType* ArrayTy_13 = ArrayType::get(VectorTy_1, 16); - PointerType* PointerTy_13 = PointerType::get(ArrayTy_14); + PointerType* PointerTy_12 = PointerType::get(ArrayTy_13, 0); - FuncTy_12_args.push_back(PointerTy_13); - ArrayType* ArrayTy_16 = ArrayType::get(ArrayTy_9, 16); + FuncTy_11_args.push_back(PointerTy_12); + ArrayType* ArrayTy_15 = ArrayType::get(ArrayTy_8, 16); - PointerType* PointerTy_15 = PointerType::get(ArrayTy_16); + PointerType* PointerTy_14 = PointerType::get(ArrayTy_15, 0); - FuncTy_12_args.push_back(PointerTy_15); - FuncTy_12_args.push_back(IntegerType::get(32)); - FuncTy_12_args.push_back(IntegerType::get(32)); - ParamAttrsList *FuncTy_12_PAL = 0; - FunctionType* FuncTy_12 = FunctionType::get( + FuncTy_11_args.push_back(PointerTy_14); + FuncTy_11_args.push_back(IntegerType::get(32)); + FuncTy_11_args.push_back(IntegerType::get(32)); + FunctionType* FuncTy_11 = FunctionType::get( /*Result=*/Type::VoidTy, - /*Params=*/FuncTy_12_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_12_PAL); + /*Params=*/FuncTy_11_args, + /*isVarArg=*/false); + + std::vectorFuncTy_16_args; + FuncTy_16_args.push_back(PointerTy_0); + FuncTy_16_args.push_back(PointerTy_7); + FuncTy_16_args.push_back(IntegerType::get(32)); + FunctionType* FuncTy_16 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_16_args, + /*isVarArg=*/false); std::vectorFuncTy_17_args; + FuncTy_17_args.push_back(PointerTy_7); FuncTy_17_args.push_back(PointerTy_0); - FuncTy_17_args.push_back(PointerTy_8); FuncTy_17_args.push_back(IntegerType::get(32)); - ParamAttrsList *FuncTy_17_PAL = 0; FunctionType* FuncTy_17 = FunctionType::get( /*Result=*/Type::VoidTy, /*Params=*/FuncTy_17_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_17_PAL); + /*isVarArg=*/false); std::vectorFuncTy_18_args; - FuncTy_18_args.push_back(PointerTy_8); - FuncTy_18_args.push_back(PointerTy_0); + FuncTy_18_args.push_back(PointerTy_12); + FuncTy_18_args.push_back(PointerTy_12); + FuncTy_18_args.push_back(PointerTy_7); + FuncTy_18_args.push_back(IntegerType::get(32)); + FuncTy_18_args.push_back(IntegerType::get(32)); + FuncTy_18_args.push_back(IntegerType::get(32)); FuncTy_18_args.push_back(IntegerType::get(32)); - ParamAttrsList *FuncTy_18_PAL = 0; FunctionType* FuncTy_18 = FunctionType::get( /*Result=*/Type::VoidTy, /*Params=*/FuncTy_18_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_18_PAL); - - std::vectorFuncTy_19_args; - FuncTy_19_args.push_back(PointerTy_13); - FuncTy_19_args.push_back(PointerTy_13); - FuncTy_19_args.push_back(PointerTy_8); - FuncTy_19_args.push_back(IntegerType::get(32)); - FuncTy_19_args.push_back(IntegerType::get(32)); - FuncTy_19_args.push_back(IntegerType::get(32)); - FuncTy_19_args.push_back(IntegerType::get(32)); - ParamAttrsList *FuncTy_19_PAL = 0; - FunctionType* FuncTy_19 = FunctionType::get( - /*Result=*/Type::VoidTy, - /*Params=*/FuncTy_19_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_19_PAL); + /*isVarArg=*/false); - ArrayType* ArrayTy_21 = ArrayType::get(VectorTy_1, 32); + ArrayType* ArrayTy_20 = ArrayType::get(VectorTy_1, 32); - PointerType* PointerTy_20 = PointerType::get(ArrayTy_21); + PointerType* PointerTy_19 = PointerType::get(ArrayTy_20, 0); - ArrayType* ArrayTy_23 = ArrayType::get(VectorTy_1, 128); + ArrayType* ArrayTy_22 = ArrayType::get(VectorTy_1, 128); - PointerType* PointerTy_22 = PointerType::get(ArrayTy_23); + PointerType* PointerTy_21 = PointerType::get(ArrayTy_22, 0); - PointerType* PointerTy_24 = PointerType::get(StructTy_struct_ShaderInput); + PointerType* PointerTy_23 = PointerType::get(StructTy_struct_ShaderInput, 0); - PointerType* PointerTy_25 = PointerType::get(PointerTy_0); + PointerType* PointerTy_24 = PointerType::get(PointerTy_0, 0); + + std::vectorFuncTy_26_args; + FuncTy_26_args.push_back(PointerTy_23); + FunctionType* FuncTy_26 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_26_args, + /*isVarArg=*/false); + + PointerType* PointerTy_25 = PointerType::get(FuncTy_26, 0); std::vectorFuncTy_27_args; - FuncTy_27_args.push_back(PointerTy_24); - ParamAttrsList *FuncTy_27_PAL = 0; + FuncTy_27_args.push_back(Type::FloatTy); + FuncTy_27_args.push_back(Type::FloatTy); + FuncTy_27_args.push_back(PointerTy_12); + FuncTy_27_args.push_back(PointerTy_12); + FuncTy_27_args.push_back(IntegerType::get(32)); + FuncTy_27_args.push_back(PointerTy_7); + FuncTy_27_args.push_back(IntegerType::get(32)); + FuncTy_27_args.push_back(PointerTy_5); FunctionType* FuncTy_27 = FunctionType::get( - /*Result=*/Type::VoidTy, - /*Params=*/FuncTy_27_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_27_PAL); - - PointerType* PointerTy_26 = PointerType::get(FuncTy_27); - - std::vectorFuncTy_28_args; - FuncTy_28_args.push_back(Type::FloatTy); - FuncTy_28_args.push_back(Type::FloatTy); - FuncTy_28_args.push_back(PointerTy_13); - FuncTy_28_args.push_back(PointerTy_13); - FuncTy_28_args.push_back(IntegerType::get(32)); - FuncTy_28_args.push_back(PointerTy_8); - FuncTy_28_args.push_back(IntegerType::get(32)); - FuncTy_28_args.push_back(PointerTy_6); - PointerType* PointerTy_29 = PointerType::get(IntegerType::get(32)); - - FuncTy_28_args.push_back(PointerTy_29); - ParamAttrsList *FuncTy_28_PAL = 0; - FunctionType* FuncTy_28 = FunctionType::get( /*Result=*/IntegerType::get(32), - /*Params=*/FuncTy_28_args, - /*isVarArg=*/false, - /*ParamAttrs=*/FuncTy_28_PAL); + /*Params=*/FuncTy_27_args, + /*isVarArg=*/false); + + PointerType* PointerTy_28 = PointerType::get(IntegerType::get(32), 0); // Function Declarations Function* func_from_array = new Function( - /*Type=*/FuncTy_12, + /*Type=*/FuncTy_11, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"from_array", mod); func_from_array->setCallingConv(CallingConv::C); + const ParamAttrsList *func_from_array_PAL = 0; + { + ParamAttrsVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind; + Attrs.push_back(PAWI); + func_from_array_PAL = ParamAttrsList::get(Attrs); + + } + func_from_array->setParamAttrs(func_from_array_PAL); Function* func_from_consts = new Function( - /*Type=*/FuncTy_17, + /*Type=*/FuncTy_16, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"from_consts", mod); func_from_consts->setCallingConv(CallingConv::C); + const ParamAttrsList *func_from_consts_PAL = 0; + { + ParamAttrsVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind; + Attrs.push_back(PAWI); + func_from_consts_PAL = ParamAttrsList::get(Attrs); + + } + func_from_consts->setParamAttrs(func_from_consts_PAL); Function* func_to_array = new Function( - /*Type=*/FuncTy_18, + /*Type=*/FuncTy_17, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"to_array", mod); func_to_array->setCallingConv(CallingConv::C); + const ParamAttrsList *func_to_array_PAL = 0; + { + ParamAttrsVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind; + Attrs.push_back(PAWI); + func_to_array_PAL = ParamAttrsList::get(Attrs); + + } + func_to_array->setParamAttrs(func_to_array_PAL); Function* func_run_vertex_shader = new Function( - /*Type=*/FuncTy_19, + /*Type=*/FuncTy_18, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"run_vertex_shader", mod); func_run_vertex_shader->setCallingConv(CallingConv::C); + ParamAttrsList *func_run_vertex_shader_PAL = 0; + func_run_vertex_shader->setParamAttrs(func_run_vertex_shader_PAL); Function* func_execute_shader = new Function( - /*Type=*/FuncTy_27, + /*Type=*/FuncTy_26, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"execute_shader", mod); // (external, no body) func_execute_shader->setCallingConv(CallingConv::C); + ParamAttrsList *func_execute_shader_PAL = 0; + func_execute_shader->setParamAttrs(func_execute_shader_PAL); Function* func_run_fragment_shader = new Function( - /*Type=*/FuncTy_28, + /*Type=*/FuncTy_27, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"run_fragment_shader", mod); func_run_fragment_shader->setCallingConv(CallingConv::C); + ParamAttrsList *func_run_fragment_shader_PAL = 0; + func_run_fragment_shader->setParamAttrs(func_run_fragment_shader_PAL); // Global Variable Declarations // Constant Definitions - Constant* const_int32_30 = Constant::getNullValue(IntegerType::get(32)); - UndefValue* const_packed_31 = UndefValue::get(VectorTy_1); - ConstantInt* const_int32_32 = ConstantInt::get(APInt(32, "1", 10)); + Constant* const_int32_29 = Constant::getNullValue(IntegerType::get(32)); + ConstantInt* const_int32_30 = ConstantInt::get(APInt(32, "-1", 10)); + ConstantInt* const_int32_31 = ConstantInt::get(APInt(32, "1", 10)); + UndefValue* const_packed_32 = UndefValue::get(VectorTy_1); ConstantInt* const_int32_33 = ConstantInt::get(APInt(32, "2", 10)); ConstantInt* const_int32_34 = ConstantInt::get(APInt(32, "3", 10)); ConstantInt* const_int32_35 = ConstantInt::get(APInt(32, "4", 10)); - ConstantInt* const_int32_36 = ConstantInt::get(APInt(32, "-1", 10)); // Global Variable Definitions @@ -242,53 +257,68 @@ Module* createBaseShader() { int32_num_attribs->setName("num_attribs"); BasicBlock* label_entry = new BasicBlock("entry",func_from_array,0); + BasicBlock* label_forcond2_preheader_split = new BasicBlock("forcond2.preheader.split",func_from_array,0); + BasicBlock* label_forcond2 = new BasicBlock("forcond2",func_from_array,0); BasicBlock* label_forbody6 = new BasicBlock("forbody6",func_from_array,0); BasicBlock* label_forinc57 = new BasicBlock("forinc57",func_from_array,0); BasicBlock* label_afterfor60 = new BasicBlock("afterfor60",func_from_array,0); // Block entry (label_entry) - ICmpInst* int1_cmp = new ICmpInst(ICmpInst::ICMP_SGT, int32_count, const_int32_30, "cmp", label_entry); - ICmpInst* int1_cmp5 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs, const_int32_30, "cmp5", label_entry); + ICmpInst* int1_cmp = new ICmpInst(ICmpInst::ICMP_SGT, int32_count, const_int32_29, "cmp", label_entry); + ICmpInst* int1_cmp5 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs, const_int32_29, "cmp5", label_entry); BinaryOperator* int1_bothcond = BinaryOperator::create(Instruction::And, int1_cmp, int1_cmp5, "bothcond", label_entry); - new BranchInst(label_forbody6, label_afterfor60, int1_bothcond, label_entry); + new BranchInst(label_forcond2_preheader_split, label_afterfor60, int1_bothcond, label_entry); - // Block forbody6 (label_forbody6) + // Block forcond2.preheader.split (label_forcond2_preheader_split) + BinaryOperator* int32_tmp21 = BinaryOperator::create(Instruction::Add, int32_count, const_int32_30, "tmp21", label_forcond2_preheader_split); + ICmpInst* int1_tmp22 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp21, const_int32_29, "tmp22", label_forcond2_preheader_split); + SelectInst* int32_tmp25 = new SelectInst(int1_tmp22, const_int32_31, int32_count, "tmp25", label_forcond2_preheader_split); + new BranchInst(label_forcond2, label_forcond2_preheader_split); + + // Block forcond2 (label_forcond2) Argument* fwdref_38 = new Argument(IntegerType::get(32)); - Argument* fwdref_39 = new Argument(IntegerType::get(32)); - PHINode* int32_i_0_reg2mem_0 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody6); - int32_i_0_reg2mem_0->reserveOperandSpace(3); - int32_i_0_reg2mem_0->addIncoming(const_int32_30, label_entry); + PHINode* int32_i_0_reg2mem_0 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forcond2); + int32_i_0_reg2mem_0->reserveOperandSpace(2); + int32_i_0_reg2mem_0->addIncoming(const_int32_29, label_forcond2_preheader_split); int32_i_0_reg2mem_0->addIncoming(fwdref_38, label_forinc57); - int32_i_0_reg2mem_0->addIncoming(fwdref_39, label_forbody6); - Argument* fwdref_40 = new Argument(IntegerType::get(32)); + Argument* fwdref_39 = new Argument(VectorTy_1); + PHINode* packed_vec_1_reg2mem_0 = new PHINode(VectorTy_1, "vec.1.reg2mem.0", label_forcond2); + packed_vec_1_reg2mem_0->reserveOperandSpace(2); + packed_vec_1_reg2mem_0->addIncoming(const_packed_32, label_forcond2_preheader_split); + packed_vec_1_reg2mem_0->addIncoming(fwdref_39, label_forinc57); + + BinaryOperator* int32_tmp = BinaryOperator::create(Instruction::Add, int32_num_attribs, const_int32_30, "tmp", label_forcond2); + ICmpInst* int1_tmp18 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp, const_int32_29, "tmp18", label_forcond2); + SelectInst* int32_tmp19 = new SelectInst(int1_tmp18, const_int32_31, int32_num_attribs, "tmp19", label_forcond2); + new BranchInst(label_forbody6, label_forcond2); + + // Block forbody6 (label_forbody6) + Argument* fwdref_41 = new Argument(IntegerType::get(32)); PHINode* int32_j_0_reg2mem_0 = new PHINode(IntegerType::get(32), "j.0.reg2mem.0", label_forbody6); - int32_j_0_reg2mem_0->reserveOperandSpace(3); - int32_j_0_reg2mem_0->addIncoming(fwdref_40, label_forbody6); - int32_j_0_reg2mem_0->addIncoming(const_int32_30, label_forinc57); - int32_j_0_reg2mem_0->addIncoming(const_int32_30, label_entry); + int32_j_0_reg2mem_0->reserveOperandSpace(2); + int32_j_0_reg2mem_0->addIncoming(const_int32_29, label_forcond2); + int32_j_0_reg2mem_0->addIncoming(fwdref_41, label_forbody6); - Argument* fwdref_41 = new Argument(VectorTy_1); PHINode* packed_vec_0_reg2mem_0 = new PHINode(VectorTy_1, "vec.0.reg2mem.0", label_forbody6); - packed_vec_0_reg2mem_0->reserveOperandSpace(3); - packed_vec_0_reg2mem_0->addIncoming(fwdref_41, label_forbody6); - packed_vec_0_reg2mem_0->addIncoming(const_packed_31, label_entry); - packed_vec_0_reg2mem_0->addIncoming(fwdref_41, label_forinc57); + packed_vec_0_reg2mem_0->reserveOperandSpace(2); + packed_vec_0_reg2mem_0->addIncoming(packed_vec_1_reg2mem_0, label_forcond2); + packed_vec_0_reg2mem_0->addIncoming(fwdref_39, label_forbody6); std::vector ptr_arraydecay11_indices; ptr_arraydecay11_indices.push_back(int32_i_0_reg2mem_0); ptr_arraydecay11_indices.push_back(int32_j_0_reg2mem_0); - ptr_arraydecay11_indices.push_back(const_int32_30); + ptr_arraydecay11_indices.push_back(const_int32_29); Instruction* ptr_arraydecay11 = new GetElementPtrInst(ptr_ainputs, ptr_arraydecay11_indices.begin(), ptr_arraydecay11_indices.end(), "arraydecay11", label_forbody6); LoadInst* float_tmp13 = new LoadInst(ptr_arraydecay11, "tmp13", false, label_forbody6); - InsertElementInst* packed_tmp15 = new InsertElementInst(packed_vec_0_reg2mem_0, float_tmp13, const_int32_30, "tmp15", label_forbody6); + InsertElementInst* packed_tmp15 = new InsertElementInst(packed_vec_0_reg2mem_0, float_tmp13, const_int32_29, "tmp15", label_forbody6); std::vector ptr_arrayidx23_indices; ptr_arrayidx23_indices.push_back(int32_i_0_reg2mem_0); ptr_arrayidx23_indices.push_back(int32_j_0_reg2mem_0); - ptr_arrayidx23_indices.push_back(const_int32_32); + ptr_arrayidx23_indices.push_back(const_int32_31); Instruction* ptr_arrayidx23 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx23_indices.begin(), ptr_arrayidx23_indices.end(), "arrayidx23", label_forbody6); LoadInst* float_tmp24 = new LoadInst(ptr_arrayidx23, "tmp24", false, label_forbody6); - InsertElementInst* packed_tmp26 = new InsertElementInst(packed_tmp15, float_tmp24, const_int32_32, "tmp26", label_forbody6); + InsertElementInst* packed_tmp26 = new InsertElementInst(packed_tmp15, float_tmp24, const_int32_31, "tmp26", label_forbody6); std::vector ptr_arrayidx34_indices; ptr_arrayidx34_indices.push_back(int32_i_0_reg2mem_0); ptr_arrayidx34_indices.push_back(int32_j_0_reg2mem_0); @@ -308,23 +338,22 @@ Module* createBaseShader() { ptr_arrayidx54_indices.push_back(int32_j_0_reg2mem_0); Instruction* ptr_arrayidx54 = new GetElementPtrInst(ptr_res, ptr_arrayidx54_indices.begin(), ptr_arrayidx54_indices.end(), "arrayidx54", label_forbody6); StoreInst* void_42 = new StoreInst(packed_tmp48, ptr_arrayidx54, false, label_forbody6); - BinaryOperator* int32_inc = BinaryOperator::create(Instruction::Add, int32_j_0_reg2mem_0, const_int32_32, "inc", label_forbody6); - ICmpInst* int1_cmp59 = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc, int32_num_attribs, "cmp59", label_forbody6); - new BranchInst(label_forbody6, label_forinc57, int1_cmp59, label_forbody6); + BinaryOperator* int32_indvar_next = BinaryOperator::create(Instruction::Add, int32_j_0_reg2mem_0, const_int32_31, "indvar.next", label_forbody6); + ICmpInst* int1_exitcond = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next, int32_tmp19, "exitcond", label_forbody6); + new BranchInst(label_forinc57, label_forbody6, int1_exitcond, label_forbody6); // Block forinc57 (label_forinc57) - BinaryOperator* int32_inc59 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0, const_int32_32, "inc59", label_forinc57); - ICmpInst* int1_cmp17 = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc59, int32_count, "cmp17", label_forinc57); - new BranchInst(label_forbody6, label_afterfor60, int1_cmp17, label_forinc57); + BinaryOperator* int32_indvar_next20 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0, const_int32_31, "indvar.next20", label_forinc57); + ICmpInst* int1_exitcond26 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next20, int32_tmp25, "exitcond26", label_forinc57); + new BranchInst(label_afterfor60, label_forcond2, int1_exitcond26, label_forinc57); // Block afterfor60 (label_afterfor60) new ReturnInst(label_afterfor60); // Resolve Forward References - fwdref_39->replaceAllUsesWith(int32_i_0_reg2mem_0); delete fwdref_39; - fwdref_41->replaceAllUsesWith(packed_tmp48); delete fwdref_41; - fwdref_40->replaceAllUsesWith(int32_inc); delete fwdref_40; - fwdref_38->replaceAllUsesWith(int32_inc59); delete fwdref_38; + fwdref_39->replaceAllUsesWith(packed_tmp48); delete fwdref_39; + fwdref_41->replaceAllUsesWith(int32_indvar_next); delete fwdref_41; + fwdref_38->replaceAllUsesWith(int32_indvar_next20); delete fwdref_38; } @@ -339,62 +368,69 @@ Module* createBaseShader() { int32_count_48->setName("count"); BasicBlock* label_entry_49 = new BasicBlock("entry",func_from_consts,0); + BasicBlock* label_forbody_preheader = new BasicBlock("forbody.preheader",func_from_consts,0); BasicBlock* label_forbody = new BasicBlock("forbody",func_from_consts,0); BasicBlock* label_afterfor = new BasicBlock("afterfor",func_from_consts,0); // Block entry (label_entry_49) - ICmpInst* int1_cmp_50 = new ICmpInst(ICmpInst::ICMP_SGT, int32_count_48, const_int32_30, "cmp", label_entry_49); - new BranchInst(label_forbody, label_afterfor, int1_cmp_50, label_entry_49); + ICmpInst* int1_cmp_50 = new ICmpInst(ICmpInst::ICMP_SGT, int32_count_48, const_int32_29, "cmp", label_entry_49); + new BranchInst(label_forbody_preheader, label_afterfor, int1_cmp_50, label_entry_49); + + // Block forbody.preheader (label_forbody_preheader) + BinaryOperator* int32_tmp_52 = BinaryOperator::create(Instruction::Add, int32_count_48, const_int32_30, "tmp", label_forbody_preheader); + ICmpInst* int1_tmp9 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_52, const_int32_29, "tmp9", label_forbody_preheader); + SelectInst* int32_tmp10 = new SelectInst(int1_tmp9, const_int32_31, int32_count_48, "tmp10", label_forbody_preheader); + new BranchInst(label_forbody, label_forbody_preheader); // Block forbody (label_forbody) - Argument* fwdref_53 = new Argument(IntegerType::get(32)); - PHINode* int32_i_0_reg2mem_0_52 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody); - int32_i_0_reg2mem_0_52->reserveOperandSpace(2); - int32_i_0_reg2mem_0_52->addIncoming(const_int32_30, label_entry_49); - int32_i_0_reg2mem_0_52->addIncoming(fwdref_53, label_forbody); - - Argument* fwdref_55 = new Argument(VectorTy_1); - PHINode* packed_vec_0_reg2mem_0_54 = new PHINode(VectorTy_1, "vec.0.reg2mem.0", label_forbody); - packed_vec_0_reg2mem_0_54->reserveOperandSpace(2); - packed_vec_0_reg2mem_0_54->addIncoming(const_packed_31, label_entry_49); - packed_vec_0_reg2mem_0_54->addIncoming(fwdref_55, label_forbody); + Argument* fwdref_55 = new Argument(IntegerType::get(32)); + PHINode* int32_i_0_reg2mem_0_54 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody); + int32_i_0_reg2mem_0_54->reserveOperandSpace(2); + int32_i_0_reg2mem_0_54->addIncoming(const_int32_29, label_forbody_preheader); + int32_i_0_reg2mem_0_54->addIncoming(fwdref_55, label_forbody); + + Argument* fwdref_57 = new Argument(VectorTy_1); + PHINode* packed_vec_0_reg2mem_0_56 = new PHINode(VectorTy_1, "vec.0.reg2mem.0", label_forbody); + packed_vec_0_reg2mem_0_56->reserveOperandSpace(2); + packed_vec_0_reg2mem_0_56->addIncoming(const_packed_32, label_forbody_preheader); + packed_vec_0_reg2mem_0_56->addIncoming(fwdref_57, label_forbody); std::vector ptr_arraydecay_indices; - ptr_arraydecay_indices.push_back(int32_i_0_reg2mem_0_52); - ptr_arraydecay_indices.push_back(const_int32_30); + ptr_arraydecay_indices.push_back(int32_i_0_reg2mem_0_54); + ptr_arraydecay_indices.push_back(const_int32_29); Instruction* ptr_arraydecay = new GetElementPtrInst(ptr_ainputs_47, ptr_arraydecay_indices.begin(), ptr_arraydecay_indices.end(), "arraydecay", label_forbody); LoadInst* float_tmp5 = new LoadInst(ptr_arraydecay, "tmp5", false, label_forbody); - InsertElementInst* packed_tmp7 = new InsertElementInst(packed_vec_0_reg2mem_0_54, float_tmp5, const_int32_30, "tmp7", label_forbody); + InsertElementInst* packed_tmp7 = new InsertElementInst(packed_vec_0_reg2mem_0_56, float_tmp5, const_int32_29, "tmp7", label_forbody); std::vector ptr_arrayidx12_indices; - ptr_arrayidx12_indices.push_back(int32_i_0_reg2mem_0_52); - ptr_arrayidx12_indices.push_back(const_int32_32); + ptr_arrayidx12_indices.push_back(int32_i_0_reg2mem_0_54); + ptr_arrayidx12_indices.push_back(const_int32_31); Instruction* ptr_arrayidx12 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx12_indices.begin(), ptr_arrayidx12_indices.end(), "arrayidx12", label_forbody); - LoadInst* float_tmp13_56 = new LoadInst(ptr_arrayidx12, "tmp13", false, label_forbody); - InsertElementInst* packed_tmp15_57 = new InsertElementInst(packed_tmp7, float_tmp13_56, const_int32_32, "tmp15", label_forbody); + LoadInst* float_tmp13_58 = new LoadInst(ptr_arrayidx12, "tmp13", false, label_forbody); + InsertElementInst* packed_tmp15_59 = new InsertElementInst(packed_tmp7, float_tmp13_58, const_int32_31, "tmp15", label_forbody); std::vector ptr_arrayidx20_indices; - ptr_arrayidx20_indices.push_back(int32_i_0_reg2mem_0_52); + ptr_arrayidx20_indices.push_back(int32_i_0_reg2mem_0_54); ptr_arrayidx20_indices.push_back(const_int32_33); Instruction* ptr_arrayidx20 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx20_indices.begin(), ptr_arrayidx20_indices.end(), "arrayidx20", label_forbody); LoadInst* float_tmp21 = new LoadInst(ptr_arrayidx20, "tmp21", false, label_forbody); - InsertElementInst* packed_tmp23 = new InsertElementInst(packed_tmp15_57, float_tmp21, const_int32_33, "tmp23", label_forbody); + InsertElementInst* packed_tmp23 = new InsertElementInst(packed_tmp15_59, float_tmp21, const_int32_33, "tmp23", label_forbody); std::vector ptr_arrayidx28_indices; - ptr_arrayidx28_indices.push_back(int32_i_0_reg2mem_0_52); + ptr_arrayidx28_indices.push_back(int32_i_0_reg2mem_0_54); ptr_arrayidx28_indices.push_back(const_int32_34); Instruction* ptr_arrayidx28 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx28_indices.begin(), ptr_arrayidx28_indices.end(), "arrayidx28", label_forbody); LoadInst* float_tmp29 = new LoadInst(ptr_arrayidx28, "tmp29", false, label_forbody); InsertElementInst* packed_tmp31 = new InsertElementInst(packed_tmp23, float_tmp29, const_int32_34, "tmp31", label_forbody); - GetElementPtrInst* ptr_arrayidx34_58 = new GetElementPtrInst(ptr_res_46, int32_i_0_reg2mem_0_52, "arrayidx34", label_forbody); - StoreInst* void_59 = new StoreInst(packed_tmp31, ptr_arrayidx34_58, false, label_forbody); - BinaryOperator* int32_indvar_next = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_52, const_int32_32, "indvar.next", label_forbody); - ICmpInst* int1_exitcond = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next, int32_count_48, "exitcond", label_forbody); - new BranchInst(label_afterfor, label_forbody, int1_exitcond, label_forbody); + GetElementPtrInst* ptr_arrayidx34_60 = new GetElementPtrInst(ptr_res_46, int32_i_0_reg2mem_0_54, "arrayidx34", label_forbody); + StoreInst* void_61 = new StoreInst(packed_tmp31, ptr_arrayidx34_60, false, label_forbody); + BinaryOperator* int32_indvar_next_62 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_54, const_int32_31, "indvar.next", label_forbody); + ICmpInst* int1_exitcond_63 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_62, int32_tmp10, "exitcond", label_forbody); + new BranchInst(label_afterfor, label_forbody, int1_exitcond_63, label_forbody); // Block afterfor (label_afterfor) new ReturnInst(label_afterfor); // Resolve Forward References - fwdref_55->replaceAllUsesWith(packed_tmp31); delete fwdref_55; - fwdref_53->replaceAllUsesWith(int32_indvar_next); delete fwdref_53; + fwdref_57->replaceAllUsesWith(packed_tmp31); delete fwdref_57; + fwdref_55->replaceAllUsesWith(int32_indvar_next_62); delete fwdref_55; } @@ -405,59 +441,66 @@ Module* createBaseShader() { ptr_dests->setName("dests"); Value* ptr_in = args++; ptr_in->setName("in"); - Value* int32_num_attribs_62 = args++; - int32_num_attribs_62->setName("num_attribs"); - - BasicBlock* label_entry_63 = new BasicBlock("entry",func_to_array,0); - BasicBlock* label_forbody_64 = new BasicBlock("forbody",func_to_array,0); - BasicBlock* label_afterfor_65 = new BasicBlock("afterfor",func_to_array,0); - - // Block entry (label_entry_63) - ICmpInst* int1_cmp_66 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs_62, const_int32_30, "cmp", label_entry_63); - new BranchInst(label_forbody_64, label_afterfor_65, int1_cmp_66, label_entry_63); - - // Block forbody (label_forbody_64) - Argument* fwdref_69 = new Argument(IntegerType::get(32)); - PHINode* int32_i_0_reg2mem_0_68 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_64); - int32_i_0_reg2mem_0_68->reserveOperandSpace(2); - int32_i_0_reg2mem_0_68->addIncoming(const_int32_30, label_entry_63); - int32_i_0_reg2mem_0_68->addIncoming(fwdref_69, label_forbody_64); - - std::vector ptr_arraydecay_70_indices; - ptr_arraydecay_70_indices.push_back(int32_i_0_reg2mem_0_68); - ptr_arraydecay_70_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay_70 = new GetElementPtrInst(ptr_dests, ptr_arraydecay_70_indices.begin(), ptr_arraydecay_70_indices.end(), "arraydecay", label_forbody_64); - GetElementPtrInst* ptr_arrayidx6 = new GetElementPtrInst(ptr_in, int32_i_0_reg2mem_0_68, "arrayidx6", label_forbody_64); - LoadInst* packed_tmp7_71 = new LoadInst(ptr_arrayidx6, "tmp7", false, label_forbody_64); - ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp7_71, const_int32_30, "tmp11", label_forbody_64); - StoreInst* void_72 = new StoreInst(float_tmp11, ptr_arraydecay_70, false, label_forbody_64); + Value* int32_num_attribs_66 = args++; + int32_num_attribs_66->setName("num_attribs"); + + BasicBlock* label_entry_67 = new BasicBlock("entry",func_to_array,0); + BasicBlock* label_forbody_preheader_68 = new BasicBlock("forbody.preheader",func_to_array,0); + BasicBlock* label_forbody_69 = new BasicBlock("forbody",func_to_array,0); + BasicBlock* label_afterfor_70 = new BasicBlock("afterfor",func_to_array,0); + + // Block entry (label_entry_67) + ICmpInst* int1_cmp_71 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs_66, const_int32_29, "cmp", label_entry_67); + new BranchInst(label_forbody_preheader_68, label_afterfor_70, int1_cmp_71, label_entry_67); + + // Block forbody.preheader (label_forbody_preheader_68) + BinaryOperator* int32_tmp_73 = BinaryOperator::create(Instruction::Add, int32_num_attribs_66, const_int32_30, "tmp", label_forbody_preheader_68); + ICmpInst* int1_tmp9_74 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_73, const_int32_29, "tmp9", label_forbody_preheader_68); + SelectInst* int32_tmp10_75 = new SelectInst(int1_tmp9_74, const_int32_31, int32_num_attribs_66, "tmp10", label_forbody_preheader_68); + new BranchInst(label_forbody_69, label_forbody_preheader_68); + + // Block forbody (label_forbody_69) + Argument* fwdref_78 = new Argument(IntegerType::get(32)); + PHINode* int32_i_0_reg2mem_0_77 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_69); + int32_i_0_reg2mem_0_77->reserveOperandSpace(2); + int32_i_0_reg2mem_0_77->addIncoming(const_int32_29, label_forbody_preheader_68); + int32_i_0_reg2mem_0_77->addIncoming(fwdref_78, label_forbody_69); + + std::vector ptr_arraydecay_79_indices; + ptr_arraydecay_79_indices.push_back(int32_i_0_reg2mem_0_77); + ptr_arraydecay_79_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay_79 = new GetElementPtrInst(ptr_dests, ptr_arraydecay_79_indices.begin(), ptr_arraydecay_79_indices.end(), "arraydecay", label_forbody_69); + GetElementPtrInst* ptr_arrayidx6 = new GetElementPtrInst(ptr_in, int32_i_0_reg2mem_0_77, "arrayidx6", label_forbody_69); + LoadInst* packed_tmp7_80 = new LoadInst(ptr_arrayidx6, "tmp7", false, label_forbody_69); + ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp7_80, const_int32_29, "tmp11", label_forbody_69); + StoreInst* void_81 = new StoreInst(float_tmp11, ptr_arraydecay_79, false, label_forbody_69); std::vector ptr_arrayidx13_indices; - ptr_arrayidx13_indices.push_back(int32_i_0_reg2mem_0_68); - ptr_arrayidx13_indices.push_back(const_int32_32); - Instruction* ptr_arrayidx13 = new GetElementPtrInst(ptr_dests, ptr_arrayidx13_indices.begin(), ptr_arrayidx13_indices.end(), "arrayidx13", label_forbody_64); - ExtractElementInst* float_tmp15 = new ExtractElementInst(packed_tmp7_71, const_int32_32, "tmp15", label_forbody_64); - StoreInst* void_73 = new StoreInst(float_tmp15, ptr_arrayidx13, false, label_forbody_64); + ptr_arrayidx13_indices.push_back(int32_i_0_reg2mem_0_77); + ptr_arrayidx13_indices.push_back(const_int32_31); + Instruction* ptr_arrayidx13 = new GetElementPtrInst(ptr_dests, ptr_arrayidx13_indices.begin(), ptr_arrayidx13_indices.end(), "arrayidx13", label_forbody_69); + ExtractElementInst* float_tmp15 = new ExtractElementInst(packed_tmp7_80, const_int32_31, "tmp15", label_forbody_69); + StoreInst* void_82 = new StoreInst(float_tmp15, ptr_arrayidx13, false, label_forbody_69); std::vector ptr_arrayidx17_indices; - ptr_arrayidx17_indices.push_back(int32_i_0_reg2mem_0_68); + ptr_arrayidx17_indices.push_back(int32_i_0_reg2mem_0_77); ptr_arrayidx17_indices.push_back(const_int32_33); - Instruction* ptr_arrayidx17 = new GetElementPtrInst(ptr_dests, ptr_arrayidx17_indices.begin(), ptr_arrayidx17_indices.end(), "arrayidx17", label_forbody_64); - ExtractElementInst* float_tmp19 = new ExtractElementInst(packed_tmp7_71, const_int32_33, "tmp19", label_forbody_64); - StoreInst* void_74 = new StoreInst(float_tmp19, ptr_arrayidx17, false, label_forbody_64); + Instruction* ptr_arrayidx17 = new GetElementPtrInst(ptr_dests, ptr_arrayidx17_indices.begin(), ptr_arrayidx17_indices.end(), "arrayidx17", label_forbody_69); + ExtractElementInst* float_tmp19 = new ExtractElementInst(packed_tmp7_80, const_int32_33, "tmp19", label_forbody_69); + StoreInst* void_83 = new StoreInst(float_tmp19, ptr_arrayidx17, false, label_forbody_69); std::vector ptr_arrayidx21_indices; - ptr_arrayidx21_indices.push_back(int32_i_0_reg2mem_0_68); + ptr_arrayidx21_indices.push_back(int32_i_0_reg2mem_0_77); ptr_arrayidx21_indices.push_back(const_int32_34); - Instruction* ptr_arrayidx21 = new GetElementPtrInst(ptr_dests, ptr_arrayidx21_indices.begin(), ptr_arrayidx21_indices.end(), "arrayidx21", label_forbody_64); - ExtractElementInst* float_tmp23 = new ExtractElementInst(packed_tmp7_71, const_int32_34, "tmp23", label_forbody_64); - StoreInst* void_75 = new StoreInst(float_tmp23, ptr_arrayidx21, false, label_forbody_64); - BinaryOperator* int32_indvar_next_76 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_68, const_int32_32, "indvar.next", label_forbody_64); - ICmpInst* int1_exitcond_77 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_76, int32_num_attribs_62, "exitcond", label_forbody_64); - new BranchInst(label_afterfor_65, label_forbody_64, int1_exitcond_77, label_forbody_64); + Instruction* ptr_arrayidx21 = new GetElementPtrInst(ptr_dests, ptr_arrayidx21_indices.begin(), ptr_arrayidx21_indices.end(), "arrayidx21", label_forbody_69); + ExtractElementInst* float_tmp23 = new ExtractElementInst(packed_tmp7_80, const_int32_34, "tmp23", label_forbody_69); + StoreInst* void_84 = new StoreInst(float_tmp23, ptr_arrayidx21, false, label_forbody_69); + BinaryOperator* int32_indvar_next_85 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_77, const_int32_31, "indvar.next", label_forbody_69); + ICmpInst* int1_exitcond_86 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_85, int32_tmp10_75, "exitcond", label_forbody_69); + new BranchInst(label_afterfor_70, label_forbody_69, int1_exitcond_86, label_forbody_69); - // Block afterfor (label_afterfor_65) - new ReturnInst(label_afterfor_65); + // Block afterfor (label_afterfor_70) + new ReturnInst(label_afterfor_70); // Resolve Forward References - fwdref_69->replaceAllUsesWith(int32_indvar_next_76); delete fwdref_69; + fwdref_78->replaceAllUsesWith(int32_indvar_next_85); delete fwdref_78; } @@ -474,50 +517,57 @@ Module* createBaseShader() { int32_num_vertices->setName("num_vertices"); Value* int32_num_inputs = args++; int32_num_inputs->setName("num_inputs"); - Value* int32_num_attribs_80 = args++; - int32_num_attribs_80->setName("num_attribs"); + Value* int32_num_attribs_89 = args++; + int32_num_attribs_89->setName("num_attribs"); Value* int32_num_consts = args++; int32_num_consts->setName("num_consts"); - BasicBlock* label_entry_81 = new BasicBlock("entry",func_run_vertex_shader,0); + BasicBlock* label_entry_90 = new BasicBlock("entry",func_run_vertex_shader,0); + BasicBlock* label_forbody_preheader_i = new BasicBlock("forbody.preheader.i",func_run_vertex_shader,0); BasicBlock* label_forbody_i = new BasicBlock("forbody.i",func_run_vertex_shader,0); BasicBlock* label_from_consts_exit = new BasicBlock("from_consts.exit",func_run_vertex_shader,0); - BasicBlock* label_forbody_preheader = new BasicBlock("forbody.preheader",func_run_vertex_shader,0); - BasicBlock* label_forbody_82 = new BasicBlock("forbody",func_run_vertex_shader,0); - BasicBlock* label_afterfor_83 = new BasicBlock("afterfor",func_run_vertex_shader,0); - - // Block entry (label_entry_81) - AllocaInst* ptr_consts = new AllocaInst(ArrayTy_21, "consts", label_entry_81); - AllocaInst* ptr_temps = new AllocaInst(ArrayTy_23, "temps", label_entry_81); - AllocaInst* ptr_args = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_81); - ICmpInst* int1_cmp_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts, const_int32_30, "cmp.i", label_entry_81); - new BranchInst(label_forbody_i, label_from_consts_exit, int1_cmp_i, label_entry_81); + BasicBlock* label_forbody_preheader_91 = new BasicBlock("forbody.preheader",func_run_vertex_shader,0); + BasicBlock* label_forbody_92 = new BasicBlock("forbody",func_run_vertex_shader,0); + BasicBlock* label_afterfor_93 = new BasicBlock("afterfor",func_run_vertex_shader,0); + + // Block entry (label_entry_90) + AllocaInst* ptr_consts = new AllocaInst(ArrayTy_20, "consts", label_entry_90); + AllocaInst* ptr_temps = new AllocaInst(ArrayTy_22, "temps", label_entry_90); + AllocaInst* ptr_args = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_90); + ICmpInst* int1_cmp_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts, const_int32_29, "cmp.i", label_entry_90); + new BranchInst(label_forbody_preheader_i, label_from_consts_exit, int1_cmp_i, label_entry_90); + + // Block forbody.preheader.i (label_forbody_preheader_i) + BinaryOperator* int32_tmp_i = BinaryOperator::create(Instruction::Add, int32_num_consts, const_int32_30, "tmp.i", label_forbody_preheader_i); + ICmpInst* int1_tmp9_i = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i, const_int32_29, "tmp9.i", label_forbody_preheader_i); + SelectInst* int32_tmp10_i = new SelectInst(int1_tmp9_i, const_int32_31, int32_num_consts, "tmp10.i", label_forbody_preheader_i); + new BranchInst(label_forbody_i, label_forbody_preheader_i); // Block forbody.i (label_forbody_i) - Argument* fwdref_85 = new Argument(IntegerType::get(32)); + Argument* fwdref_96 = new Argument(IntegerType::get(32)); PHINode* int32_i_0_reg2mem_0_i = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i); int32_i_0_reg2mem_0_i->reserveOperandSpace(2); - int32_i_0_reg2mem_0_i->addIncoming(const_int32_30, label_entry_81); - int32_i_0_reg2mem_0_i->addIncoming(fwdref_85, label_forbody_i); + int32_i_0_reg2mem_0_i->addIncoming(const_int32_29, label_forbody_preheader_i); + int32_i_0_reg2mem_0_i->addIncoming(fwdref_96, label_forbody_i); - Argument* fwdref_86 = new Argument(VectorTy_1); + Argument* fwdref_97 = new Argument(VectorTy_1); PHINode* packed_vec_0_reg2mem_0_i = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i); packed_vec_0_reg2mem_0_i->reserveOperandSpace(2); - packed_vec_0_reg2mem_0_i->addIncoming(const_packed_31, label_entry_81); - packed_vec_0_reg2mem_0_i->addIncoming(fwdref_86, label_forbody_i); + packed_vec_0_reg2mem_0_i->addIncoming(const_packed_32, label_forbody_preheader_i); + packed_vec_0_reg2mem_0_i->addIncoming(fwdref_97, label_forbody_i); std::vector ptr_arraydecay_i_indices; ptr_arraydecay_i_indices.push_back(int32_i_0_reg2mem_0_i); - ptr_arraydecay_i_indices.push_back(const_int32_30); + ptr_arraydecay_i_indices.push_back(const_int32_29); Instruction* ptr_arraydecay_i = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i_indices.begin(), ptr_arraydecay_i_indices.end(), "arraydecay.i", label_forbody_i); LoadInst* float_tmp5_i = new LoadInst(ptr_arraydecay_i, "tmp5.i", false, label_forbody_i); - InsertElementInst* packed_tmp7_i = new InsertElementInst(packed_vec_0_reg2mem_0_i, float_tmp5_i, const_int32_30, "tmp7.i", label_forbody_i); + InsertElementInst* packed_tmp7_i = new InsertElementInst(packed_vec_0_reg2mem_0_i, float_tmp5_i, const_int32_29, "tmp7.i", label_forbody_i); std::vector ptr_arrayidx12_i_indices; ptr_arrayidx12_i_indices.push_back(int32_i_0_reg2mem_0_i); - ptr_arrayidx12_i_indices.push_back(const_int32_32); + ptr_arrayidx12_i_indices.push_back(const_int32_31); Instruction* ptr_arrayidx12_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_indices.begin(), ptr_arrayidx12_i_indices.end(), "arrayidx12.i", label_forbody_i); LoadInst* float_tmp13_i = new LoadInst(ptr_arrayidx12_i, "tmp13.i", false, label_forbody_i); - InsertElementInst* packed_tmp15_i = new InsertElementInst(packed_tmp7_i, float_tmp13_i, const_int32_32, "tmp15.i", label_forbody_i); + InsertElementInst* packed_tmp15_i = new InsertElementInst(packed_tmp7_i, float_tmp13_i, const_int32_31, "tmp15.i", label_forbody_i); std::vector ptr_arrayidx20_i_indices; ptr_arrayidx20_i_indices.push_back(int32_i_0_reg2mem_0_i); ptr_arrayidx20_i_indices.push_back(const_int32_33); @@ -531,78 +581,83 @@ Module* createBaseShader() { LoadInst* float_tmp29_i = new LoadInst(ptr_arrayidx28_i, "tmp29.i", false, label_forbody_i); InsertElementInst* packed_tmp31_i = new InsertElementInst(packed_tmp23_i, float_tmp29_i, const_int32_34, "tmp31.i", label_forbody_i); std::vector ptr_arrayidx34_i_indices; - ptr_arrayidx34_i_indices.push_back(const_int32_30); + ptr_arrayidx34_i_indices.push_back(const_int32_29); ptr_arrayidx34_i_indices.push_back(int32_i_0_reg2mem_0_i); Instruction* ptr_arrayidx34_i = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i_indices.begin(), ptr_arrayidx34_i_indices.end(), "arrayidx34.i", label_forbody_i); - StoreInst* void_87 = new StoreInst(packed_tmp31_i, ptr_arrayidx34_i, false, label_forbody_i); - BinaryOperator* int32_indvar_next6 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i, const_int32_32, "indvar.next6", label_forbody_i); - ICmpInst* int1_exitcond7 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next6, int32_num_consts, "exitcond7", label_forbody_i); - new BranchInst(label_from_consts_exit, label_forbody_i, int1_exitcond7, label_forbody_i); + StoreInst* void_98 = new StoreInst(packed_tmp31_i, ptr_arrayidx34_i, false, label_forbody_i); + BinaryOperator* int32_indvar_next8 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i, const_int32_31, "indvar.next8", label_forbody_i); + ICmpInst* int1_exitcond9 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next8, int32_tmp10_i, "exitcond9", label_forbody_i); + new BranchInst(label_from_consts_exit, label_forbody_i, int1_exitcond9, label_forbody_i); // Block from_consts.exit (label_from_consts_exit) std::vector ptr_tmp2_indices; - ptr_tmp2_indices.push_back(const_int32_30); + ptr_tmp2_indices.push_back(const_int32_29); ptr_tmp2_indices.push_back(const_int32_34); Instruction* ptr_tmp2 = new GetElementPtrInst(ptr_args, ptr_tmp2_indices.begin(), ptr_tmp2_indices.end(), "tmp2", label_from_consts_exit); std::vector ptr_arraydecay3_indices; - ptr_arraydecay3_indices.push_back(const_int32_30); - ptr_arraydecay3_indices.push_back(const_int32_30); + ptr_arraydecay3_indices.push_back(const_int32_29); + ptr_arraydecay3_indices.push_back(const_int32_29); Instruction* ptr_arraydecay3 = new GetElementPtrInst(ptr_consts, ptr_arraydecay3_indices.begin(), ptr_arraydecay3_indices.end(), "arraydecay3", label_from_consts_exit); - StoreInst* void_89 = new StoreInst(ptr_arraydecay3, ptr_tmp2, false, label_from_consts_exit); + StoreInst* void_100 = new StoreInst(ptr_arraydecay3, ptr_tmp2, false, label_from_consts_exit); std::vector ptr_tmp4_indices; - ptr_tmp4_indices.push_back(const_int32_30); + ptr_tmp4_indices.push_back(const_int32_29); ptr_tmp4_indices.push_back(const_int32_33); Instruction* ptr_tmp4 = new GetElementPtrInst(ptr_args, ptr_tmp4_indices.begin(), ptr_tmp4_indices.end(), "tmp4", label_from_consts_exit); std::vector ptr_arraydecay5_indices; - ptr_arraydecay5_indices.push_back(const_int32_30); - ptr_arraydecay5_indices.push_back(const_int32_30); + ptr_arraydecay5_indices.push_back(const_int32_29); + ptr_arraydecay5_indices.push_back(const_int32_29); Instruction* ptr_arraydecay5 = new GetElementPtrInst(ptr_temps, ptr_arraydecay5_indices.begin(), ptr_arraydecay5_indices.end(), "arraydecay5", label_from_consts_exit); - StoreInst* void_90 = new StoreInst(ptr_arraydecay5, ptr_tmp4, false, label_from_consts_exit); - ICmpInst* int1_cmp_91 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_vertices, const_int32_30, "cmp", label_from_consts_exit); - new BranchInst(label_forbody_preheader, label_afterfor_83, int1_cmp_91, label_from_consts_exit); + StoreInst* void_101 = new StoreInst(ptr_arraydecay5, ptr_tmp4, false, label_from_consts_exit); + ICmpInst* int1_cmp_102 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_vertices, const_int32_29, "cmp", label_from_consts_exit); + new BranchInst(label_forbody_preheader_91, label_afterfor_93, int1_cmp_102, label_from_consts_exit); - // Block forbody.preheader (label_forbody_preheader) + // Block forbody.preheader (label_forbody_preheader_91) std::vector ptr_tmp8_indices; - ptr_tmp8_indices.push_back(const_int32_30); - ptr_tmp8_indices.push_back(const_int32_30); - Instruction* ptr_tmp8 = new GetElementPtrInst(ptr_args, ptr_tmp8_indices.begin(), ptr_tmp8_indices.end(), "tmp8", label_forbody_preheader); + ptr_tmp8_indices.push_back(const_int32_29); + ptr_tmp8_indices.push_back(const_int32_29); + Instruction* ptr_tmp8 = new GetElementPtrInst(ptr_args, ptr_tmp8_indices.begin(), ptr_tmp8_indices.end(), "tmp8", label_forbody_preheader_91); std::vector ptr_tmp12_indices; - ptr_tmp12_indices.push_back(const_int32_30); - ptr_tmp12_indices.push_back(const_int32_32); - Instruction* ptr_tmp12 = new GetElementPtrInst(ptr_args, ptr_tmp12_indices.begin(), ptr_tmp12_indices.end(), "tmp12", label_forbody_preheader); - new BranchInst(label_forbody_82, label_forbody_preheader); - - // Block forbody (label_forbody_82) - Argument* fwdref_95 = new Argument(IntegerType::get(32)); - PHINode* int32_i_0_reg2mem_0_94 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_82); - int32_i_0_reg2mem_0_94->reserveOperandSpace(2); - int32_i_0_reg2mem_0_94->addIncoming(const_int32_30, label_forbody_preheader); - int32_i_0_reg2mem_0_94->addIncoming(fwdref_95, label_forbody_82); - - std::vector ptr_arraydecay11_96_indices; - ptr_arraydecay11_96_indices.push_back(int32_i_0_reg2mem_0_94); - ptr_arraydecay11_96_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay11_96 = new GetElementPtrInst(ptr_results, ptr_arraydecay11_96_indices.begin(), ptr_arraydecay11_96_indices.end(), "arraydecay11", label_forbody_82); - StoreInst* void_97 = new StoreInst(ptr_arraydecay11_96, ptr_tmp8, false, label_forbody_82); + ptr_tmp12_indices.push_back(const_int32_29); + ptr_tmp12_indices.push_back(const_int32_31); + Instruction* ptr_tmp12 = new GetElementPtrInst(ptr_args, ptr_tmp12_indices.begin(), ptr_tmp12_indices.end(), "tmp12", label_forbody_preheader_91); + BinaryOperator* int32_tmp_104 = BinaryOperator::create(Instruction::Add, int32_num_vertices, const_int32_30, "tmp", label_forbody_preheader_91); + ICmpInst* int1_tmp6 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_104, const_int32_29, "tmp6", label_forbody_preheader_91); + SelectInst* int32_tmp7 = new SelectInst(int1_tmp6, const_int32_31, int32_num_vertices, "tmp7", label_forbody_preheader_91); + new BranchInst(label_forbody_92, label_forbody_preheader_91); + + // Block forbody (label_forbody_92) + Argument* fwdref_107 = new Argument(IntegerType::get(32)); + PHINode* int32_i_0_reg2mem_0_106 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_92); + int32_i_0_reg2mem_0_106->reserveOperandSpace(2); + int32_i_0_reg2mem_0_106->addIncoming(const_int32_29, label_forbody_preheader_91); + int32_i_0_reg2mem_0_106->addIncoming(fwdref_107, label_forbody_92); + + std::vector ptr_arraydecay11_108_indices; + ptr_arraydecay11_108_indices.push_back(int32_i_0_reg2mem_0_106); + ptr_arraydecay11_108_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay11_108 = new GetElementPtrInst(ptr_results, ptr_arraydecay11_108_indices.begin(), ptr_arraydecay11_108_indices.end(), "arraydecay11", label_forbody_92); + StoreInst* void_109 = new StoreInst(ptr_arraydecay11_108, ptr_tmp8, false, label_forbody_92); std::vector ptr_arraydecay16_indices; - ptr_arraydecay16_indices.push_back(int32_i_0_reg2mem_0_94); - ptr_arraydecay16_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay16 = new GetElementPtrInst(ptr_inputs, ptr_arraydecay16_indices.begin(), ptr_arraydecay16_indices.end(), "arraydecay16", label_forbody_82); - StoreInst* void_98 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_forbody_82); - CallInst* void_99 = new CallInst(func_execute_shader, ptr_args, "", label_forbody_82); - void_99->setCallingConv(CallingConv::C); - void_99->setTailCall(false); - BinaryOperator* int32_indvar_next_100 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_94, const_int32_32, "indvar.next", label_forbody_82); - ICmpInst* int1_exitcond_101 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_100, int32_num_vertices, "exitcond", label_forbody_82); - new BranchInst(label_afterfor_83, label_forbody_82, int1_exitcond_101, label_forbody_82); - - // Block afterfor (label_afterfor_83) - new ReturnInst(label_afterfor_83); + ptr_arraydecay16_indices.push_back(int32_i_0_reg2mem_0_106); + ptr_arraydecay16_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay16 = new GetElementPtrInst(ptr_inputs, ptr_arraydecay16_indices.begin(), ptr_arraydecay16_indices.end(), "arraydecay16", label_forbody_92); + StoreInst* void_110 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_forbody_92); + CallInst* void_111 = new CallInst(func_execute_shader, ptr_args, "", label_forbody_92); + void_111->setCallingConv(CallingConv::C); + void_111->setTailCall(false);ParamAttrsList *void_111_PAL = 0; + void_111->setParamAttrs(void_111_PAL); + + BinaryOperator* int32_indvar_next_112 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_106, const_int32_31, "indvar.next", label_forbody_92); + ICmpInst* int1_exitcond_113 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_112, int32_tmp7, "exitcond", label_forbody_92); + new BranchInst(label_afterfor_93, label_forbody_92, int1_exitcond_113, label_forbody_92); + + // Block afterfor (label_afterfor_93) + new ReturnInst(label_afterfor_93); // Resolve Forward References - fwdref_86->replaceAllUsesWith(packed_tmp31_i); delete fwdref_86; - fwdref_85->replaceAllUsesWith(int32_indvar_next6); delete fwdref_85; - fwdref_95->replaceAllUsesWith(int32_indvar_next_100); delete fwdref_95; + fwdref_107->replaceAllUsesWith(int32_indvar_next_112); delete fwdref_107; + fwdref_97->replaceAllUsesWith(packed_tmp31_i); delete fwdref_97; + fwdref_96->replaceAllUsesWith(int32_indvar_next8); delete fwdref_96; } @@ -613,180 +668,195 @@ Module* createBaseShader() { float_x->setName("x"); Value* float_y = args++; float_y->setName("y"); - Value* ptr_results_104 = args++; - ptr_results_104->setName("results"); - Value* ptr_inputs_105 = args++; - ptr_inputs_105->setName("inputs"); - Value* int32_num_inputs_106 = args++; - int32_num_inputs_106->setName("num_inputs"); - Value* ptr_aconsts_107 = args++; - ptr_aconsts_107->setName("aconsts"); - Value* int32_num_consts_108 = args++; - int32_num_consts_108->setName("num_consts"); + Value* ptr_results_116 = args++; + ptr_results_116->setName("results"); + Value* ptr_inputs_117 = args++; + ptr_inputs_117->setName("inputs"); + Value* int32_num_inputs_118 = args++; + int32_num_inputs_118->setName("num_inputs"); + Value* ptr_aconsts_119 = args++; + ptr_aconsts_119->setName("aconsts"); + Value* int32_num_consts_120 = args++; + int32_num_consts_120->setName("num_consts"); Value* ptr_samplers = args++; ptr_samplers->setName("samplers"); - BasicBlock* label_entry_109 = new BasicBlock("entry",func_run_fragment_shader,0); - BasicBlock* label_forbody_i_110 = new BasicBlock("forbody.i",func_run_fragment_shader,0); - BasicBlock* label_from_consts_exit_111 = new BasicBlock("from_consts.exit",func_run_fragment_shader,0); + BasicBlock* label_entry_121 = new BasicBlock("entry",func_run_fragment_shader,0); + BasicBlock* label_forbody_preheader_i_122 = new BasicBlock("forbody.preheader.i",func_run_fragment_shader,0); + BasicBlock* label_forbody_i_123 = new BasicBlock("forbody.i",func_run_fragment_shader,0); + BasicBlock* label_from_consts_exit_124 = new BasicBlock("from_consts.exit",func_run_fragment_shader,0); - // Block entry (label_entry_109) - AllocaInst* ptr_consts_112 = new AllocaInst(ArrayTy_21, "consts", label_entry_109); - AllocaInst* ptr_temps_113 = new AllocaInst(ArrayTy_23, "temps", label_entry_109); - AllocaInst* ptr_args_114 = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_109); + // Block entry (label_entry_121) + AllocaInst* ptr_consts_125 = new AllocaInst(ArrayTy_20, "consts", label_entry_121); + AllocaInst* ptr_temps_126 = new AllocaInst(ArrayTy_22, "temps", label_entry_121); + AllocaInst* ptr_args_127 = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_121); std::vector ptr_tmp_indices; - ptr_tmp_indices.push_back(const_int32_30); + ptr_tmp_indices.push_back(const_int32_29); ptr_tmp_indices.push_back(const_int32_35); - Instruction* ptr_tmp = new GetElementPtrInst(ptr_args_114, ptr_tmp_indices.begin(), ptr_tmp_indices.end(), "tmp", label_entry_109); - StoreInst* void_115 = new StoreInst(const_int32_30, ptr_tmp, false, label_entry_109); - ICmpInst* int1_cmp_i_116 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts_108, const_int32_30, "cmp.i", label_entry_109); - new BranchInst(label_forbody_i_110, label_from_consts_exit_111, int1_cmp_i_116, label_entry_109); - - // Block forbody.i (label_forbody_i_110) - Argument* fwdref_119 = new Argument(IntegerType::get(32)); - PHINode* int32_i_0_reg2mem_0_i_118 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i_110); - int32_i_0_reg2mem_0_i_118->reserveOperandSpace(2); - int32_i_0_reg2mem_0_i_118->addIncoming(const_int32_30, label_entry_109); - int32_i_0_reg2mem_0_i_118->addIncoming(fwdref_119, label_forbody_i_110); - - Argument* fwdref_121 = new Argument(VectorTy_1); - PHINode* packed_vec_0_reg2mem_0_i_120 = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i_110); - packed_vec_0_reg2mem_0_i_120->reserveOperandSpace(2); - packed_vec_0_reg2mem_0_i_120->addIncoming(const_packed_31, label_entry_109); - packed_vec_0_reg2mem_0_i_120->addIncoming(fwdref_121, label_forbody_i_110); - - std::vector ptr_arraydecay_i_122_indices; - ptr_arraydecay_i_122_indices.push_back(int32_i_0_reg2mem_0_i_118); - ptr_arraydecay_i_122_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay_i_122 = new GetElementPtrInst(ptr_aconsts_107, ptr_arraydecay_i_122_indices.begin(), ptr_arraydecay_i_122_indices.end(), "arraydecay.i", label_forbody_i_110); - LoadInst* float_tmp5_i_123 = new LoadInst(ptr_arraydecay_i_122, "tmp5.i", false, label_forbody_i_110); - InsertElementInst* packed_tmp7_i_124 = new InsertElementInst(packed_vec_0_reg2mem_0_i_120, float_tmp5_i_123, const_int32_30, "tmp7.i", label_forbody_i_110); - std::vector ptr_arrayidx12_i_125_indices; - ptr_arrayidx12_i_125_indices.push_back(int32_i_0_reg2mem_0_i_118); - ptr_arrayidx12_i_125_indices.push_back(const_int32_32); - Instruction* ptr_arrayidx12_i_125 = new GetElementPtrInst(ptr_aconsts_107, ptr_arrayidx12_i_125_indices.begin(), ptr_arrayidx12_i_125_indices.end(), "arrayidx12.i", label_forbody_i_110); - LoadInst* float_tmp13_i_126 = new LoadInst(ptr_arrayidx12_i_125, "tmp13.i", false, label_forbody_i_110); - InsertElementInst* packed_tmp15_i_127 = new InsertElementInst(packed_tmp7_i_124, float_tmp13_i_126, const_int32_32, "tmp15.i", label_forbody_i_110); - std::vector ptr_arrayidx20_i_128_indices; - ptr_arrayidx20_i_128_indices.push_back(int32_i_0_reg2mem_0_i_118); - ptr_arrayidx20_i_128_indices.push_back(const_int32_33); - Instruction* ptr_arrayidx20_i_128 = new GetElementPtrInst(ptr_aconsts_107, ptr_arrayidx20_i_128_indices.begin(), ptr_arrayidx20_i_128_indices.end(), "arrayidx20.i", label_forbody_i_110); - LoadInst* float_tmp21_i_129 = new LoadInst(ptr_arrayidx20_i_128, "tmp21.i", false, label_forbody_i_110); - InsertElementInst* packed_tmp23_i_130 = new InsertElementInst(packed_tmp15_i_127, float_tmp21_i_129, const_int32_33, "tmp23.i", label_forbody_i_110); - std::vector ptr_arrayidx28_i_131_indices; - ptr_arrayidx28_i_131_indices.push_back(int32_i_0_reg2mem_0_i_118); - ptr_arrayidx28_i_131_indices.push_back(const_int32_34); - Instruction* ptr_arrayidx28_i_131 = new GetElementPtrInst(ptr_aconsts_107, ptr_arrayidx28_i_131_indices.begin(), ptr_arrayidx28_i_131_indices.end(), "arrayidx28.i", label_forbody_i_110); - LoadInst* float_tmp29_i_132 = new LoadInst(ptr_arrayidx28_i_131, "tmp29.i", false, label_forbody_i_110); - InsertElementInst* packed_tmp31_i_133 = new InsertElementInst(packed_tmp23_i_130, float_tmp29_i_132, const_int32_34, "tmp31.i", label_forbody_i_110); - std::vector ptr_arrayidx34_i_134_indices; - ptr_arrayidx34_i_134_indices.push_back(const_int32_30); - ptr_arrayidx34_i_134_indices.push_back(int32_i_0_reg2mem_0_i_118); - Instruction* ptr_arrayidx34_i_134 = new GetElementPtrInst(ptr_consts_112, ptr_arrayidx34_i_134_indices.begin(), ptr_arrayidx34_i_134_indices.end(), "arrayidx34.i", label_forbody_i_110); - StoreInst* void_135 = new StoreInst(packed_tmp31_i_133, ptr_arrayidx34_i_134, false, label_forbody_i_110); - BinaryOperator* int32_indvar_next7 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i_118, const_int32_32, "indvar.next7", label_forbody_i_110); - ICmpInst* int1_exitcond8 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next7, int32_num_consts_108, "exitcond8", label_forbody_i_110); - new BranchInst(label_from_consts_exit_111, label_forbody_i_110, int1_exitcond8, label_forbody_i_110); - - // Block from_consts.exit (label_from_consts_exit_111) + Instruction* ptr_tmp = new GetElementPtrInst(ptr_args_127, ptr_tmp_indices.begin(), ptr_tmp_indices.end(), "tmp", label_entry_121); + StoreInst* void_128 = new StoreInst(const_int32_29, ptr_tmp, false, label_entry_121); + ICmpInst* int1_cmp_i_129 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts_120, const_int32_29, "cmp.i", label_entry_121); + new BranchInst(label_forbody_preheader_i_122, label_from_consts_exit_124, int1_cmp_i_129, label_entry_121); + + // Block forbody.preheader.i (label_forbody_preheader_i_122) + BinaryOperator* int32_tmp_i_131 = BinaryOperator::create(Instruction::Add, int32_num_consts_120, const_int32_30, "tmp.i", label_forbody_preheader_i_122); + ICmpInst* int1_tmp9_i_132 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i_131, const_int32_29, "tmp9.i", label_forbody_preheader_i_122); + SelectInst* int32_tmp10_i_133 = new SelectInst(int1_tmp9_i_132, const_int32_31, int32_num_consts_120, "tmp10.i", label_forbody_preheader_i_122); + new BranchInst(label_forbody_i_123, label_forbody_preheader_i_122); + + // Block forbody.i (label_forbody_i_123) + Argument* fwdref_136 = new Argument(IntegerType::get(32)); + PHINode* int32_i_0_reg2mem_0_i_135 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i_123); + int32_i_0_reg2mem_0_i_135->reserveOperandSpace(2); + int32_i_0_reg2mem_0_i_135->addIncoming(const_int32_29, label_forbody_preheader_i_122); + int32_i_0_reg2mem_0_i_135->addIncoming(fwdref_136, label_forbody_i_123); + + Argument* fwdref_138 = new Argument(VectorTy_1); + PHINode* packed_vec_0_reg2mem_0_i_137 = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i_123); + packed_vec_0_reg2mem_0_i_137->reserveOperandSpace(2); + packed_vec_0_reg2mem_0_i_137->addIncoming(const_packed_32, label_forbody_preheader_i_122); + packed_vec_0_reg2mem_0_i_137->addIncoming(fwdref_138, label_forbody_i_123); + + std::vector ptr_arraydecay_i_139_indices; + ptr_arraydecay_i_139_indices.push_back(int32_i_0_reg2mem_0_i_135); + ptr_arraydecay_i_139_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay_i_139 = new GetElementPtrInst(ptr_aconsts_119, ptr_arraydecay_i_139_indices.begin(), ptr_arraydecay_i_139_indices.end(), "arraydecay.i", label_forbody_i_123); + LoadInst* float_tmp5_i_140 = new LoadInst(ptr_arraydecay_i_139, "tmp5.i", false, label_forbody_i_123); + InsertElementInst* packed_tmp7_i_141 = new InsertElementInst(packed_vec_0_reg2mem_0_i_137, float_tmp5_i_140, const_int32_29, "tmp7.i", label_forbody_i_123); + std::vector ptr_arrayidx12_i_142_indices; + ptr_arrayidx12_i_142_indices.push_back(int32_i_0_reg2mem_0_i_135); + ptr_arrayidx12_i_142_indices.push_back(const_int32_31); + Instruction* ptr_arrayidx12_i_142 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx12_i_142_indices.begin(), ptr_arrayidx12_i_142_indices.end(), "arrayidx12.i", label_forbody_i_123); + LoadInst* float_tmp13_i_143 = new LoadInst(ptr_arrayidx12_i_142, "tmp13.i", false, label_forbody_i_123); + InsertElementInst* packed_tmp15_i_144 = new InsertElementInst(packed_tmp7_i_141, float_tmp13_i_143, const_int32_31, "tmp15.i", label_forbody_i_123); + std::vector ptr_arrayidx20_i_145_indices; + ptr_arrayidx20_i_145_indices.push_back(int32_i_0_reg2mem_0_i_135); + ptr_arrayidx20_i_145_indices.push_back(const_int32_33); + Instruction* ptr_arrayidx20_i_145 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx20_i_145_indices.begin(), ptr_arrayidx20_i_145_indices.end(), "arrayidx20.i", label_forbody_i_123); + LoadInst* float_tmp21_i_146 = new LoadInst(ptr_arrayidx20_i_145, "tmp21.i", false, label_forbody_i_123); + InsertElementInst* packed_tmp23_i_147 = new InsertElementInst(packed_tmp15_i_144, float_tmp21_i_146, const_int32_33, "tmp23.i", label_forbody_i_123); + std::vector ptr_arrayidx28_i_148_indices; + ptr_arrayidx28_i_148_indices.push_back(int32_i_0_reg2mem_0_i_135); + ptr_arrayidx28_i_148_indices.push_back(const_int32_34); + Instruction* ptr_arrayidx28_i_148 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx28_i_148_indices.begin(), ptr_arrayidx28_i_148_indices.end(), "arrayidx28.i", label_forbody_i_123); + LoadInst* float_tmp29_i_149 = new LoadInst(ptr_arrayidx28_i_148, "tmp29.i", false, label_forbody_i_123); + InsertElementInst* packed_tmp31_i_150 = new InsertElementInst(packed_tmp23_i_147, float_tmp29_i_149, const_int32_34, "tmp31.i", label_forbody_i_123); + std::vector ptr_arrayidx34_i_151_indices; + ptr_arrayidx34_i_151_indices.push_back(const_int32_29); + ptr_arrayidx34_i_151_indices.push_back(int32_i_0_reg2mem_0_i_135); + Instruction* ptr_arrayidx34_i_151 = new GetElementPtrInst(ptr_consts_125, ptr_arrayidx34_i_151_indices.begin(), ptr_arrayidx34_i_151_indices.end(), "arrayidx34.i", label_forbody_i_123); + StoreInst* void_152 = new StoreInst(packed_tmp31_i_150, ptr_arrayidx34_i_151, false, label_forbody_i_123); + BinaryOperator* int32_indvar_next7 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i_135, const_int32_31, "indvar.next7", label_forbody_i_123); + ICmpInst* int1_exitcond8 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next7, int32_tmp10_i_133, "exitcond8", label_forbody_i_123); + new BranchInst(label_from_consts_exit_124, label_forbody_i_123, int1_exitcond8, label_forbody_i_123); + + // Block from_consts.exit (label_from_consts_exit_124) std::vector ptr_tmp3_indices; - ptr_tmp3_indices.push_back(const_int32_30); + ptr_tmp3_indices.push_back(const_int32_29); ptr_tmp3_indices.push_back(const_int32_34); - Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_args_114, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_from_consts_exit_111); + Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_args_127, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_from_consts_exit_124); std::vector ptr_arraydecay4_indices; - ptr_arraydecay4_indices.push_back(const_int32_30); - ptr_arraydecay4_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay4 = new GetElementPtrInst(ptr_consts_112, ptr_arraydecay4_indices.begin(), ptr_arraydecay4_indices.end(), "arraydecay4", label_from_consts_exit_111); - StoreInst* void_137 = new StoreInst(ptr_arraydecay4, ptr_tmp3, false, label_from_consts_exit_111); + ptr_arraydecay4_indices.push_back(const_int32_29); + ptr_arraydecay4_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay4 = new GetElementPtrInst(ptr_consts_125, ptr_arraydecay4_indices.begin(), ptr_arraydecay4_indices.end(), "arraydecay4", label_from_consts_exit_124); + StoreInst* void_154 = new StoreInst(ptr_arraydecay4, ptr_tmp3, false, label_from_consts_exit_124); std::vector ptr_tmp5_indices; - ptr_tmp5_indices.push_back(const_int32_30); + ptr_tmp5_indices.push_back(const_int32_29); ptr_tmp5_indices.push_back(const_int32_33); - Instruction* ptr_tmp5 = new GetElementPtrInst(ptr_args_114, ptr_tmp5_indices.begin(), ptr_tmp5_indices.end(), "tmp5", label_from_consts_exit_111); + Instruction* ptr_tmp5 = new GetElementPtrInst(ptr_args_127, ptr_tmp5_indices.begin(), ptr_tmp5_indices.end(), "tmp5", label_from_consts_exit_124); std::vector ptr_arraydecay6_indices; - ptr_arraydecay6_indices.push_back(const_int32_30); - ptr_arraydecay6_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay6 = new GetElementPtrInst(ptr_temps_113, ptr_arraydecay6_indices.begin(), ptr_arraydecay6_indices.end(), "arraydecay6", label_from_consts_exit_111); - StoreInst* void_138 = new StoreInst(ptr_arraydecay6, ptr_tmp5, false, label_from_consts_exit_111); - std::vector ptr_tmp8_139_indices; - ptr_tmp8_139_indices.push_back(const_int32_30); - ptr_tmp8_139_indices.push_back(const_int32_32); - Instruction* ptr_tmp8_139 = new GetElementPtrInst(ptr_args_114, ptr_tmp8_139_indices.begin(), ptr_tmp8_139_indices.end(), "tmp8", label_from_consts_exit_111); - std::vector ptr_tmp12_140_indices; - ptr_tmp12_140_indices.push_back(const_int32_30); - ptr_tmp12_140_indices.push_back(const_int32_30); - Instruction* ptr_tmp12_140 = new GetElementPtrInst(ptr_args_114, ptr_tmp12_140_indices.begin(), ptr_tmp12_140_indices.end(), "tmp12", label_from_consts_exit_111); - std::vector ptr_arraydecay11_141_indices; - ptr_arraydecay11_141_indices.push_back(const_int32_30); - ptr_arraydecay11_141_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay11_141 = new GetElementPtrInst(ptr_inputs_105, ptr_arraydecay11_141_indices.begin(), ptr_arraydecay11_141_indices.end(), "arraydecay11", label_from_consts_exit_111); - StoreInst* void_142 = new StoreInst(ptr_arraydecay11_141, ptr_tmp8_139, false, label_from_consts_exit_111); - std::vector ptr_arraydecay16_143_indices; - ptr_arraydecay16_143_indices.push_back(const_int32_30); - ptr_arraydecay16_143_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay16_143 = new GetElementPtrInst(ptr_results_104, ptr_arraydecay16_143_indices.begin(), ptr_arraydecay16_143_indices.end(), "arraydecay16", label_from_consts_exit_111); - StoreInst* void_144 = new StoreInst(ptr_arraydecay16_143, ptr_tmp12_140, false, label_from_consts_exit_111); - StoreInst* void_145 = new StoreInst(const_int32_30, ptr_tmp, false, label_from_consts_exit_111); - CallInst* void_146 = new CallInst(func_execute_shader, ptr_args_114, "", label_from_consts_exit_111); - void_146->setCallingConv(CallingConv::C); - void_146->setTailCall(false); - LoadInst* int32_tmp23 = new LoadInst(ptr_tmp, "tmp23", false, label_from_consts_exit_111); + ptr_arraydecay6_indices.push_back(const_int32_29); + ptr_arraydecay6_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay6 = new GetElementPtrInst(ptr_temps_126, ptr_arraydecay6_indices.begin(), ptr_arraydecay6_indices.end(), "arraydecay6", label_from_consts_exit_124); + StoreInst* void_155 = new StoreInst(ptr_arraydecay6, ptr_tmp5, false, label_from_consts_exit_124); + std::vector ptr_tmp8_156_indices; + ptr_tmp8_156_indices.push_back(const_int32_29); + ptr_tmp8_156_indices.push_back(const_int32_31); + Instruction* ptr_tmp8_156 = new GetElementPtrInst(ptr_args_127, ptr_tmp8_156_indices.begin(), ptr_tmp8_156_indices.end(), "tmp8", label_from_consts_exit_124); + std::vector ptr_tmp12_157_indices; + ptr_tmp12_157_indices.push_back(const_int32_29); + ptr_tmp12_157_indices.push_back(const_int32_29); + Instruction* ptr_tmp12_157 = new GetElementPtrInst(ptr_args_127, ptr_tmp12_157_indices.begin(), ptr_tmp12_157_indices.end(), "tmp12", label_from_consts_exit_124); + std::vector ptr_arraydecay11_158_indices; + ptr_arraydecay11_158_indices.push_back(const_int32_29); + ptr_arraydecay11_158_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay11_158 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_158_indices.begin(), ptr_arraydecay11_158_indices.end(), "arraydecay11", label_from_consts_exit_124); + StoreInst* void_159 = new StoreInst(ptr_arraydecay11_158, ptr_tmp8_156, false, label_from_consts_exit_124); + std::vector ptr_arraydecay16_160_indices; + ptr_arraydecay16_160_indices.push_back(const_int32_29); + ptr_arraydecay16_160_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay16_160 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_160_indices.begin(), ptr_arraydecay16_160_indices.end(), "arraydecay16", label_from_consts_exit_124); + StoreInst* void_161 = new StoreInst(ptr_arraydecay16_160, ptr_tmp12_157, false, label_from_consts_exit_124); + StoreInst* void_162 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); + CallInst* void_163 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); + void_163->setCallingConv(CallingConv::C); + void_163->setTailCall(false);ParamAttrsList *void_163_PAL = 0; + void_163->setParamAttrs(void_163_PAL); + + LoadInst* int32_tmp23 = new LoadInst(ptr_tmp, "tmp23", false, label_from_consts_exit_124); std::vector ptr_arraydecay11_1_indices; - ptr_arraydecay11_1_indices.push_back(const_int32_32); - ptr_arraydecay11_1_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay11_1 = new GetElementPtrInst(ptr_inputs_105, ptr_arraydecay11_1_indices.begin(), ptr_arraydecay11_1_indices.end(), "arraydecay11.1", label_from_consts_exit_111); - StoreInst* void_147 = new StoreInst(ptr_arraydecay11_1, ptr_tmp8_139, false, label_from_consts_exit_111); + ptr_arraydecay11_1_indices.push_back(const_int32_31); + ptr_arraydecay11_1_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay11_1 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_1_indices.begin(), ptr_arraydecay11_1_indices.end(), "arraydecay11.1", label_from_consts_exit_124); + StoreInst* void_164 = new StoreInst(ptr_arraydecay11_1, ptr_tmp8_156, false, label_from_consts_exit_124); std::vector ptr_arraydecay16_1_indices; - ptr_arraydecay16_1_indices.push_back(const_int32_32); - ptr_arraydecay16_1_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay16_1 = new GetElementPtrInst(ptr_results_104, ptr_arraydecay16_1_indices.begin(), ptr_arraydecay16_1_indices.end(), "arraydecay16.1", label_from_consts_exit_111); - StoreInst* void_148 = new StoreInst(ptr_arraydecay16_1, ptr_tmp12_140, false, label_from_consts_exit_111); - StoreInst* void_149 = new StoreInst(const_int32_30, ptr_tmp, false, label_from_consts_exit_111); - CallInst* void_150 = new CallInst(func_execute_shader, ptr_args_114, "", label_from_consts_exit_111); - void_150->setCallingConv(CallingConv::C); - void_150->setTailCall(false); - LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp, "tmp23.1", false, label_from_consts_exit_111); - BinaryOperator* int32_shl_1 = BinaryOperator::create(Instruction::Shl, int32_tmp23_1, const_int32_32, "shl.1", label_from_consts_exit_111); - BinaryOperator* int32_or_1 = BinaryOperator::create(Instruction::Or, int32_shl_1, int32_tmp23, "or.1", label_from_consts_exit_111); + ptr_arraydecay16_1_indices.push_back(const_int32_31); + ptr_arraydecay16_1_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay16_1 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_1_indices.begin(), ptr_arraydecay16_1_indices.end(), "arraydecay16.1", label_from_consts_exit_124); + StoreInst* void_165 = new StoreInst(ptr_arraydecay16_1, ptr_tmp12_157, false, label_from_consts_exit_124); + StoreInst* void_166 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); + CallInst* void_167 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); + void_167->setCallingConv(CallingConv::C); + void_167->setTailCall(false);ParamAttrsList *void_167_PAL = 0; + void_167->setParamAttrs(void_167_PAL); + + LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp, "tmp23.1", false, label_from_consts_exit_124); + BinaryOperator* int32_shl_1 = BinaryOperator::create(Instruction::Shl, int32_tmp23_1, const_int32_31, "shl.1", label_from_consts_exit_124); + BinaryOperator* int32_or_1 = BinaryOperator::create(Instruction::Or, int32_shl_1, int32_tmp23, "or.1", label_from_consts_exit_124); std::vector ptr_arraydecay11_2_indices; ptr_arraydecay11_2_indices.push_back(const_int32_33); - ptr_arraydecay11_2_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay11_2 = new GetElementPtrInst(ptr_inputs_105, ptr_arraydecay11_2_indices.begin(), ptr_arraydecay11_2_indices.end(), "arraydecay11.2", label_from_consts_exit_111); - StoreInst* void_151 = new StoreInst(ptr_arraydecay11_2, ptr_tmp8_139, false, label_from_consts_exit_111); + ptr_arraydecay11_2_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay11_2 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_2_indices.begin(), ptr_arraydecay11_2_indices.end(), "arraydecay11.2", label_from_consts_exit_124); + StoreInst* void_168 = new StoreInst(ptr_arraydecay11_2, ptr_tmp8_156, false, label_from_consts_exit_124); std::vector ptr_arraydecay16_2_indices; ptr_arraydecay16_2_indices.push_back(const_int32_33); - ptr_arraydecay16_2_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay16_2 = new GetElementPtrInst(ptr_results_104, ptr_arraydecay16_2_indices.begin(), ptr_arraydecay16_2_indices.end(), "arraydecay16.2", label_from_consts_exit_111); - StoreInst* void_152 = new StoreInst(ptr_arraydecay16_2, ptr_tmp12_140, false, label_from_consts_exit_111); - StoreInst* void_153 = new StoreInst(const_int32_30, ptr_tmp, false, label_from_consts_exit_111); - CallInst* void_154 = new CallInst(func_execute_shader, ptr_args_114, "", label_from_consts_exit_111); - void_154->setCallingConv(CallingConv::C); - void_154->setTailCall(false); - LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp, "tmp23.2", false, label_from_consts_exit_111); - BinaryOperator* int32_shl_2 = BinaryOperator::create(Instruction::Shl, int32_tmp23_2, const_int32_33, "shl.2", label_from_consts_exit_111); - BinaryOperator* int32_or_2 = BinaryOperator::create(Instruction::Or, int32_shl_2, int32_or_1, "or.2", label_from_consts_exit_111); + ptr_arraydecay16_2_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay16_2 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_2_indices.begin(), ptr_arraydecay16_2_indices.end(), "arraydecay16.2", label_from_consts_exit_124); + StoreInst* void_169 = new StoreInst(ptr_arraydecay16_2, ptr_tmp12_157, false, label_from_consts_exit_124); + StoreInst* void_170 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); + CallInst* void_171 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); + void_171->setCallingConv(CallingConv::C); + void_171->setTailCall(false);ParamAttrsList *void_171_PAL = 0; + void_171->setParamAttrs(void_171_PAL); + + LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp, "tmp23.2", false, label_from_consts_exit_124); + BinaryOperator* int32_shl_2 = BinaryOperator::create(Instruction::Shl, int32_tmp23_2, const_int32_33, "shl.2", label_from_consts_exit_124); + BinaryOperator* int32_or_2 = BinaryOperator::create(Instruction::Or, int32_shl_2, int32_or_1, "or.2", label_from_consts_exit_124); std::vector ptr_arraydecay11_3_indices; ptr_arraydecay11_3_indices.push_back(const_int32_34); - ptr_arraydecay11_3_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay11_3 = new GetElementPtrInst(ptr_inputs_105, ptr_arraydecay11_3_indices.begin(), ptr_arraydecay11_3_indices.end(), "arraydecay11.3", label_from_consts_exit_111); - StoreInst* void_155 = new StoreInst(ptr_arraydecay11_3, ptr_tmp8_139, false, label_from_consts_exit_111); + ptr_arraydecay11_3_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay11_3 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_3_indices.begin(), ptr_arraydecay11_3_indices.end(), "arraydecay11.3", label_from_consts_exit_124); + StoreInst* void_172 = new StoreInst(ptr_arraydecay11_3, ptr_tmp8_156, false, label_from_consts_exit_124); std::vector ptr_arraydecay16_3_indices; ptr_arraydecay16_3_indices.push_back(const_int32_34); - ptr_arraydecay16_3_indices.push_back(const_int32_30); - Instruction* ptr_arraydecay16_3 = new GetElementPtrInst(ptr_results_104, ptr_arraydecay16_3_indices.begin(), ptr_arraydecay16_3_indices.end(), "arraydecay16.3", label_from_consts_exit_111); - StoreInst* void_156 = new StoreInst(ptr_arraydecay16_3, ptr_tmp12_140, false, label_from_consts_exit_111); - StoreInst* void_157 = new StoreInst(const_int32_30, ptr_tmp, false, label_from_consts_exit_111); - CallInst* void_158 = new CallInst(func_execute_shader, ptr_args_114, "", label_from_consts_exit_111); - void_158->setCallingConv(CallingConv::C); - void_158->setTailCall(false); - LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp, "tmp23.3", false, label_from_consts_exit_111); - BinaryOperator* int32_shl_3 = BinaryOperator::create(Instruction::Shl, int32_tmp23_3, const_int32_34, "shl.3", label_from_consts_exit_111); - BinaryOperator* int32_or_3 = BinaryOperator::create(Instruction::Or, int32_shl_3, int32_or_2, "or.3", label_from_consts_exit_111); - BinaryOperator* int32_neg = BinaryOperator::create(Instruction::Xor, int32_or_3, const_int32_36, "neg", label_from_consts_exit_111); - new ReturnInst(int32_neg, label_from_consts_exit_111); + ptr_arraydecay16_3_indices.push_back(const_int32_29); + Instruction* ptr_arraydecay16_3 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_3_indices.begin(), ptr_arraydecay16_3_indices.end(), "arraydecay16.3", label_from_consts_exit_124); + StoreInst* void_173 = new StoreInst(ptr_arraydecay16_3, ptr_tmp12_157, false, label_from_consts_exit_124); + StoreInst* void_174 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); + CallInst* void_175 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); + void_175->setCallingConv(CallingConv::C); + void_175->setTailCall(false);ParamAttrsList *void_175_PAL = 0; + void_175->setParamAttrs(void_175_PAL); + + LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp, "tmp23.3", false, label_from_consts_exit_124); + BinaryOperator* int32_shl_3 = BinaryOperator::create(Instruction::Shl, int32_tmp23_3, const_int32_34, "shl.3", label_from_consts_exit_124); + BinaryOperator* int32_or_3 = BinaryOperator::create(Instruction::Or, int32_shl_3, int32_or_2, "or.3", label_from_consts_exit_124); + BinaryOperator* int32_neg = BinaryOperator::create(Instruction::Xor, int32_or_3, const_int32_30, "neg", label_from_consts_exit_124); + new ReturnInst(int32_neg, label_from_consts_exit_124); // Resolve Forward References - fwdref_121->replaceAllUsesWith(packed_tmp31_i_133); delete fwdref_121; - fwdref_119->replaceAllUsesWith(int32_indvar_next7); delete fwdref_119; + fwdref_138->replaceAllUsesWith(packed_tmp31_i_150); delete fwdref_138; + fwdref_136->replaceAllUsesWith(int32_indvar_next7); delete fwdref_136; } -- cgit v1.2.3 From 9789c301b476b1127f847144fd5c8313e6ba8be8 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 4 Jan 2008 09:27:42 -0500 Subject: llvm: we need custom rules so had to redo the build a little bit also don't use sse when llvm is enabled --- configs/linux-llvm | 8 ++-- src/mesa/Makefile | 11 +++-- src/mesa/pipe/Makefile | 6 ++- src/mesa/pipe/Makefile.template | 10 +++-- src/mesa/pipe/llvm/Makefile | 80 +++++++++++++++++++++++++++++++++ src/mesa/pipe/llvm/llvm_base_shader.cpp | 16 +++---- src/mesa/pipe/softpipe/sp_state_fs.c | 12 +++-- src/mesa/sources | 11 +---- 8 files changed, 117 insertions(+), 37 deletions(-) create mode 100644 src/mesa/pipe/llvm/Makefile (limited to 'src') diff --git a/configs/linux-llvm b/configs/linux-llvm index 6d1f31daa2..915189f462 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -1,3 +1,4 @@ +# -*-makefile-*- # Configuration for Linux and LLVM with debugging info include $(TOP)/configs/linux @@ -5,7 +6,7 @@ include $(TOP)/configs/linux CONFIG_NAME = linux-llvm OPT_FLAGS = -g -ansi -pedantic -DEFINES += -DDEBUG -DDEBUG_MATH +DEFINES += -DDEBUG -DDEBUG_MATH -DMESA_LLVM=1 LLVM_VERSION := $(shell llvm-config --version) @@ -18,9 +19,8 @@ else endif ifeq ($(MESA_LLVM),1) -# LLVM_CFLAGS=`llvm-config --cflags` -DMESA_LLVM=1 - LLVM_CFLAGS=-DMESA_LLVM=1 - LLVM_CXXFLAGS=`llvm-config --cxxflags` -DMESA_LLVM=1 -Wno-long-long +# LLVM_CFLAGS=`llvm-config --cflags` + LLVM_CXXFLAGS=`llvm-config --cxxflags` -Wno-long-long LLVM_LDFLAGS=`llvm-config --ldflags` LLVM_LIBS=`llvm-config --libs` MKLIB_OPTIONS=-cplusplus diff --git a/src/mesa/Makefile b/src/mesa/Makefile index dd8e2c3762..681c566140 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -20,14 +20,17 @@ CELL_LIB = $(TOP)/src/mesa/pipe/cell/ppu/libcell.a CELL_LIB_SPU = $(TOP)/src/mesa/pipe/cell/spu/g3d_spu.a endif +ifeq ($(CONFIG_NAME), linux-llvm) +LLVM_LIB = $(TOP)/src/mesa/pipe/llvm/libgallivm.a +endif .SUFFIXES : .cpp .c.o: - $(CC) -c $(LLVM_CFLAGS) $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ .cpp.o: - $(CXX) -c $(LLVM_CXXFLAGS) $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ + $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ .S.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ @@ -120,12 +123,12 @@ stand-alone: depend subdirs $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$ osmesa-only: depend subdirs $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) # Make the GL library -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS) $(PIPE_LIB) $(CELL_LIB) $(CELL_LIB_SPU) +$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS) $(PIPE_LIB) $(CELL_LIB) $(CELL_LIB_SPU) $(LLVM_LIB) @ $(TOP)/bin/mklib -o $(GL_LIB) \ -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(STAND_ALONE_OBJECTS) \ - $(PIPE_LIB) $(CELL_LIB) $(CELL_LIB_SPU) $(GL_LIB_DEPS) + $(PIPE_LIB) $(CELL_LIB) $(CELL_LIB_SPU) $(LLVM_LIB) $(GL_LIB_DEPS) # Make the OSMesa library $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS) diff --git a/src/mesa/pipe/Makefile b/src/mesa/pipe/Makefile index c0345a9cb5..da044036ff 100644 --- a/src/mesa/pipe/Makefile +++ b/src/mesa/pipe/Makefile @@ -6,7 +6,11 @@ ifeq ($(CONFIG_NAME), linux-cell) CELL_DIR = cell endif -SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) +ifeq ($(CONFIG_NAME), linux-llvm) +LLVM_DIR = llvm +endif + +SUBDIRS = softpipe llvm i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR) default: subdirs diff --git a/src/mesa/pipe/Makefile.template b/src/mesa/pipe/Makefile.template index 8c2f84b328..3cd07660b6 100644 --- a/src/mesa/pipe/Makefile.template +++ b/src/mesa/pipe/Makefile.template @@ -8,6 +8,7 @@ COMMON_SOURCES = OBJECTS = $(C_SOURCES:.c=.o) \ + $(CPP_SOURCES:.cpp=.o) \ $(ASM_SOURCES:.S=.o) @@ -22,7 +23,10 @@ INCLUDES = \ ##### RULES ##### .c.o: - $(CC) -c $(INCLUDES) $(LLVM_CFLAGS) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@ .S.o: $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ @@ -37,10 +41,10 @@ $(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template $(TOP)/bin/mklib -o $@ -static $(OBJECTS) -depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) +depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \ + $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \ $(ASM_SOURCES) 2> /dev/null diff --git a/src/mesa/pipe/llvm/Makefile b/src/mesa/pipe/llvm/Makefile new file mode 100644 index 0000000000..b1463f67cf --- /dev/null +++ b/src/mesa/pipe/llvm/Makefile @@ -0,0 +1,80 @@ +# -*-makefile-*- +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = gallivm + + +GALLIVM_SOURCES = \ + gallivm.cpp \ + instructions.cpp \ + storage.cpp + +INC_SOURCES = gallivm_builtins.cpp llvm_base_shader.cpp + +CPP_SOURCES = \ + $(GALLIVM_SOURCES) + +C_SOURCES = +ASM_SOURCES = + +OBJECTS = $(C_SOURCES:.c=.o) \ + $(CPP_SOURCES:.cpp=.o) \ + $(ASM_SOURCES:.S=.o) + +### Include directories +INCLUDES = \ + -I. \ + -I$(TOP)/src/mesa/pipe \ + -I$(TOP)/src/mesa \ + -I$(TOP)/include + + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(LLVM_CFLAGS) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(LLVM_CXXFLAGS) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + +##### TARGETS ##### + +default:: depend symlinks $(LIBNAME) + + +$(LIBNAME): $(OBJECTS) Makefile + $(TOP)/bin/mklib -o $@ -static $(OBJECTS) + + +depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \ + $(ASM_SOURCES) $(INC_SOURCES) 2> /dev/null + + +gallivm_builtins.cpp: llvm_builtins.c + clang --emit-llvm $< |llvm-as|opt -std-compile-opts|llvm2cpp -gen-contents -o=$@ -f -for=shader -funcname=createGallivmBuiltins + +llvm_base_shader.cpp: llvm_entry.c + clang --emit-llvm $< |llvm-as |opt -std-compile-opts |llvm2cpp -for=Shader -gen-module -o=$@ -funcname=createBaseShader + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + + +# Remove .o and backup files +clean: + -rm -f *.o */*.o *~ *.so *~ server/*.o + -rm -f depend depend.bak + -rm -f gallivm_builtins.cpp llvm_base_shader.cpp + +symlinks: + + +include depend diff --git a/src/mesa/pipe/llvm/llvm_base_shader.cpp b/src/mesa/pipe/llvm/llvm_base_shader.cpp index 951afc390e..b574b550ae 100644 --- a/src/mesa/pipe/llvm/llvm_base_shader.cpp +++ b/src/mesa/pipe/llvm/llvm_base_shader.cpp @@ -209,7 +209,7 @@ Module* createBaseShader() { /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"run_vertex_shader", mod); func_run_vertex_shader->setCallingConv(CallingConv::C); - ParamAttrsList *func_run_vertex_shader_PAL = 0; + const ParamAttrsList *func_run_vertex_shader_PAL = 0; func_run_vertex_shader->setParamAttrs(func_run_vertex_shader_PAL); Function* func_execute_shader = new Function( @@ -217,7 +217,7 @@ Module* createBaseShader() { /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"execute_shader", mod); // (external, no body) func_execute_shader->setCallingConv(CallingConv::C); - ParamAttrsList *func_execute_shader_PAL = 0; + const ParamAttrsList *func_execute_shader_PAL = 0; func_execute_shader->setParamAttrs(func_execute_shader_PAL); Function* func_run_fragment_shader = new Function( @@ -225,7 +225,7 @@ Module* createBaseShader() { /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"run_fragment_shader", mod); func_run_fragment_shader->setCallingConv(CallingConv::C); - ParamAttrsList *func_run_fragment_shader_PAL = 0; + const ParamAttrsList *func_run_fragment_shader_PAL = 0; func_run_fragment_shader->setParamAttrs(func_run_fragment_shader_PAL); // Global Variable Declarations @@ -644,7 +644,7 @@ Module* createBaseShader() { StoreInst* void_110 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_forbody_92); CallInst* void_111 = new CallInst(func_execute_shader, ptr_args, "", label_forbody_92); void_111->setCallingConv(CallingConv::C); - void_111->setTailCall(false);ParamAttrsList *void_111_PAL = 0; + void_111->setTailCall(false);const ParamAttrsList *void_111_PAL = 0; void_111->setParamAttrs(void_111_PAL); BinaryOperator* int32_indvar_next_112 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_106, const_int32_31, "indvar.next", label_forbody_92); @@ -790,7 +790,7 @@ Module* createBaseShader() { StoreInst* void_162 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); CallInst* void_163 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); void_163->setCallingConv(CallingConv::C); - void_163->setTailCall(false);ParamAttrsList *void_163_PAL = 0; + void_163->setTailCall(false);const ParamAttrsList *void_163_PAL = 0; void_163->setParamAttrs(void_163_PAL); LoadInst* int32_tmp23 = new LoadInst(ptr_tmp, "tmp23", false, label_from_consts_exit_124); @@ -807,7 +807,7 @@ Module* createBaseShader() { StoreInst* void_166 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); CallInst* void_167 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); void_167->setCallingConv(CallingConv::C); - void_167->setTailCall(false);ParamAttrsList *void_167_PAL = 0; + void_167->setTailCall(false);const ParamAttrsList *void_167_PAL = 0; void_167->setParamAttrs(void_167_PAL); LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp, "tmp23.1", false, label_from_consts_exit_124); @@ -826,7 +826,7 @@ Module* createBaseShader() { StoreInst* void_170 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); CallInst* void_171 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); void_171->setCallingConv(CallingConv::C); - void_171->setTailCall(false);ParamAttrsList *void_171_PAL = 0; + void_171->setTailCall(false);const ParamAttrsList *void_171_PAL = 0; void_171->setParamAttrs(void_171_PAL); LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp, "tmp23.2", false, label_from_consts_exit_124); @@ -845,7 +845,7 @@ Module* createBaseShader() { StoreInst* void_174 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124); CallInst* void_175 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124); void_175->setCallingConv(CallingConv::C); - void_175->setTailCall(false);ParamAttrsList *void_175_PAL = 0; + void_175->setTailCall(false);const ParamAttrsList *void_175_PAL = 0; void_175->setParamAttrs(void_175_PAL); LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp, "tmp23.3", false, label_from_consts_exit_124); diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 830c873b25..945c93411f 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -59,13 +59,6 @@ softpipe_create_fs_state(struct pipe_context *pipe, tgsi_dump(state->shader.tokens, 0); } -#if defined(__i386__) || defined(__386__) - if (softpipe->use_sse) { - x86_init_func( &state->sse2_program ); - tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program ); - } -#endif - #ifdef MESA_LLVM state->llvm_prog = gallivm_from_tgsi(state->shader.tokens, GALLIVM_FS); if (!gallivm_global_cpu_engine()) { @@ -73,6 +66,11 @@ softpipe_create_fs_state(struct pipe_context *pipe, } else gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog); +#elif defined(__i386__) || defined(__386__) + if (softpipe->use_sse) { + x86_init_func( &state->sse2_program ); + tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program ); + } #endif return state; diff --git a/src/mesa/sources b/src/mesa/sources index 56ea6dbce2..90ce9ce370 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -186,12 +186,6 @@ TGSIUTIL_SOURCES = \ pipe/tgsi/util/tgsi_parse.c \ pipe/tgsi/util/tgsi_util.c - -LLVMTGSI_SOURCES = \ - pipe/llvm/gallivm.cpp \ - pipe/llvm/storage.cpp \ - pipe/llvm/instructions.cpp - STATECACHE_SOURCES = \ pipe/cso_cache/cso_hash.c \ pipe/cso_cache/cso_cache.c @@ -370,7 +364,6 @@ FBDEV_DRIVER_SOURCES = \ ALL_SOURCES = \ $(GLAPI_SOURCES) \ $(SOLO_SOURCES) \ - $(LLVMTGSI_SOURCES) \ $(ASM_SOURCES) \ $(COMMON_DRIVER_SOURCES)\ $(X11_DRIVER_SOURCES) \ @@ -397,15 +390,13 @@ SOLO_SOURCES = \ CORE_SOURCES = \ $(GLAPI_SOURCES) \ - $(SOLO_SOURCES) \ - $(LLVMTGSI_SOURCES) + $(SOLO_SOURCES) ### Object files SOLO_OBJECTS = \ $(SOLO_SOURCES:.c=.o) \ - $(LLVMTGSI_SOURCES:.cpp=.o) \ $(ASM_SOURCES:.S=.o) GLAPI_OBJECTS = \ -- cgit v1.2.3 From 6f012904318311207a20bbf586f1a9f9f8b7fc20 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 4 Jan 2008 10:01:32 -0500 Subject: llvm: if llvm is enabled don't even try to use sse for vs --- src/mesa/pipe/draw/draw_vertex_shader.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index 240149118f..c2e038453e 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -245,15 +245,6 @@ draw_create_vertex_shader(struct draw_context *draw, vs->state = shader; -#if defined(__i386__) || defined(__386__) - if (draw->use_sse) { - /* cast-away const */ - struct pipe_shader_state *sh = (struct pipe_shader_state *) shader; - - x86_init_func( &vs->sse2_program ); - tgsi_emit_sse2( (struct tgsi_token *) sh->tokens, &vs->sse2_program ); - } -#endif #ifdef MESA_LLVM vs->llvm_prog = gallivm_from_tgsi(shader->tokens, GALLIVM_VS); draw->engine = gallivm_global_cpu_engine(); @@ -263,6 +254,14 @@ draw_create_vertex_shader(struct draw_context *draw, else { gallivm_cpu_jit_compile(draw->engine, vs->llvm_prog); } +#elif defined(__i386__) || defined(__386__) + if (draw->use_sse) { + /* cast-away const */ + struct pipe_shader_state *sh = (struct pipe_shader_state *) shader; + + x86_init_func( &vs->sse2_program ); + tgsi_emit_sse2( (struct tgsi_token *) sh->tokens, &vs->sse2_program ); + } #endif return vs; -- cgit v1.2.3 From 1c5f27a18b775b3784fcd265d60e0affa0b31581 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 4 Jan 2008 17:06:55 +0100 Subject: gallium: Make texture target an enum for better debuggability. Also make enum pipe_format used in a couple more places. --- src/mesa/pipe/i965simple/brw_wm_surface_state.c | 6 +++--- src/mesa/pipe/p_defines.h | 10 ++++++---- src/mesa/pipe/p_state.h | 5 +++-- src/mesa/state_tracker/st_cb_texture.c | 2 +- src/mesa/state_tracker/st_texture.c | 4 ++-- src/mesa/state_tracker/st_texture.h | 4 ++-- 6 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_wm_surface_state.c b/src/mesa/pipe/i965simple/brw_wm_surface_state.c index 5c7dee5790..fc40e0438c 100644 --- a/src/mesa/pipe/i965simple/brw_wm_surface_state.c +++ b/src/mesa/pipe/i965simple/brw_wm_surface_state.c @@ -33,7 +33,7 @@ #include "brw_state.h" #include "brw_defines.h" -static unsigned translate_tex_target( int target ) +static unsigned translate_tex_target( enum pipe_texture_target target ) { switch (target) { case PIPE_TEXTURE_1D: @@ -54,9 +54,9 @@ static unsigned translate_tex_target( int target ) } } -static unsigned translate_tex_format( unsigned mesa_format ) +static unsigned translate_tex_format( enum pipe_format pipe_format ) { - switch( mesa_format ) { + switch( pipe_format ) { case PIPE_FORMAT_U_L8: return BRW_SURFACEFORMAT_L8_UNORM; diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index a67ed60547..c6d9c02bd9 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -115,10 +115,12 @@ #define PIPE_STENCIL_OP_INVERT 7 /** Texture types */ -#define PIPE_TEXTURE_1D 0 -#define PIPE_TEXTURE_2D 1 -#define PIPE_TEXTURE_3D 2 -#define PIPE_TEXTURE_CUBE 3 +enum pipe_texture_target { + PIPE_TEXTURE_1D = 0, + PIPE_TEXTURE_2D = 1, + PIPE_TEXTURE_3D = 2, + PIPE_TEXTURE_CUBE = 3 +}; #define PIPE_TEX_FACE_POS_X 0 #define PIPE_TEX_FACE_NEG_X 1 diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 16d50fdb82..76e633e930 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -39,6 +39,7 @@ #define PIPE_STATE_H #include "p_compiler.h" +#include "p_defines.h" #include "p_format.h" /** @@ -262,8 +263,8 @@ struct pipe_texture { /* Effectively the key: */ - unsigned target; /**< PIPE_TEXTURE_x */ - enum pipe_format format; /**< PIPE_FORMAT_x */ + enum pipe_texture_target target; /**< PIPE_TEXTURE_x */ + enum pipe_format format; /**< PIPE_FORMAT_x */ unsigned first_level; unsigned last_level; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index e813bdb47a..773fc0012e 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -97,7 +97,7 @@ st_get_texobj_texture(struct gl_texture_object *texObj) } -static unsigned +static enum pipe_texture_target gl_target_to_pipe(GLenum target) { switch (target) { diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index c7d28eeca2..a2bdf846ca 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -61,8 +61,8 @@ target_to_target(GLenum target) struct pipe_texture * st_texture_create(struct st_context *st, - unsigned target, - unsigned format, + enum pipe_texture_target target, + enum pipe_format format, GLuint first_level, GLuint last_level, GLuint width0, diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 7524c219e0..d8b1bcad9d 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -37,8 +37,8 @@ struct pipe_texture; extern struct pipe_texture * st_texture_create(struct st_context *st, - unsigned target, - unsigned format, + enum pipe_texture_target target, + enum pipe_format format, GLuint first_level, GLuint last_level, GLuint width0, -- cgit v1.2.3 From 934468296c33a04125e42e5d0f8747f65405a393 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Thu, 10 Jan 2008 01:11:53 +0100 Subject: softpipe: map only once in softpipe_map_surfaces softpipe_map_surfaces get call several time but softpipe_unmap_surfaces get call only once. So to make sure stuff are properly unmap when softpipe_unmap_surfaces get call we map surfaces only one time in softpipe_map_surfaces. --- src/mesa/pipe/softpipe/sp_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index c7af63cc2d..0759092305 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -80,16 +80,16 @@ softpipe_map_surfaces(struct softpipe_context *sp) for (i = 0; i < sp->framebuffer.num_cbufs; i++) { ps = sp->framebuffer.cbufs[i]; - if (ps->buffer) + if (ps->buffer && !ps->map) pipe_surface_map(ps); } ps = sp->framebuffer.zbuf; - if (ps && ps->buffer) + if (ps && ps->buffer && !ps->map) pipe_surface_map(ps); ps = sp->framebuffer.sbuf; - if (ps && ps->buffer) + if (ps && ps->buffer && !ps->map) pipe_surface_map(ps); } -- cgit v1.2.3 From abee68a7220e5ee16216caf22841ad934fb37334 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 Jan 2008 14:10:59 -0700 Subject: Cell: implemement basic Z testing Also, improve some surface clearing code --- src/mesa/pipe/cell/common.h | 17 +++++----- src/mesa/pipe/cell/ppu/cell_spu.c | 3 +- src/mesa/pipe/cell/ppu/cell_surface.c | 47 +++++++++++++------------- src/mesa/pipe/cell/spu/main.c | 44 ++++++++++++++++--------- src/mesa/pipe/cell/spu/main.h | 2 +- src/mesa/pipe/cell/spu/tri.c | 62 +++++++++++++++++++++++++++++++++-- 6 files changed, 124 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index dff0b1f8ec..4c770f5c32 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -47,11 +47,11 @@ #define TILE_SIZE 32 -#define CELL_CMD_EXIT 1 -#define CELL_CMD_FRAMEBUFFER 2 -#define CELL_CMD_CLEAR_TILES 3 -#define CELL_CMD_FINISH 5 -#define CELL_CMD_RENDER 6 +#define CELL_CMD_EXIT 1 +#define CELL_CMD_FRAMEBUFFER 2 +#define CELL_CMD_CLEAR_SURFACE 3 +#define CELL_CMD_FINISH 4 +#define CELL_CMD_RENDER 5 /** @@ -66,10 +66,11 @@ struct cell_command_framebuffer /** - * Clear framebuffer tiles to given value/color. + * Clear framebuffer to the given value/color. */ -struct cell_command_clear_tiles +struct cell_command_clear_surface { + uint surface; /**< Temporary: 0=color, 1=Z */ uint value; } ALIGN16_ATTRIB; @@ -87,7 +88,7 @@ struct cell_command_render struct cell_command { struct cell_command_framebuffer fb; - struct cell_command_clear_tiles clear; + struct cell_command_clear_surface clear; struct cell_command_render render; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 15b89682fa..a7dbf24dd8 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -176,7 +176,8 @@ test_spus(struct cell_context *cell) for (i = 0; i < cell->num_spus; i++) { cell_global.command[i].clear.value = 0xff880044; /* XXX */ - send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES); + cell_global.command[i].clear.surface = 0; + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_SURFACE); } finish_all(cell->num_spus); diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 62e0febc0c..1e1548c8b6 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -47,42 +47,43 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, { struct cell_context *cell = cell_context(pipe); uint i; + uint surfIndex; if (!ps->map) pipe_surface_map(ps); - if (pf_get_size(ps->format) != 4) { - printf("Cell: Skipping non 32bpp clear_surface\n"); - return; + if (ps == cell->framebuffer.zbuf) { + surfIndex = 1; } -#if 0 - for (i = 0; i < cell->num_spus; i++) { - struct cell_command_framebuffer *fb = &cell_global.command[i].fb; - printf("%s %u start = 0x%x\n", __FUNCTION__, i, ps->map); - fb->color_start = ps->map; - fb->width = ps->width; - fb->height = ps->height; - fb->color_format = ps->format; - send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER); + else { + surfIndex = 0; } -#endif + + printf("Clear surf %u\n", surfIndex); for (i = 0; i < cell->num_spus; i++) { #if 1 uint clr = clearValue; - /* XXX debug: clear color varied per-SPU to visualize tiles */ - if ((clr & 0xff) == 0) - clr |= 64 + i * 8; - if ((clr & 0xff00) == 0) - clr |= (64 + i * 8) << 8; - if ((clr & 0xff0000) == 0) - clr |= (64 + i * 8) << 16; - if ((clr & 0xff000000) == 0) - clr |= (64 + i * 8) << 24; + if (surfIndex == 0) { + /* XXX debug: clear color varied per-SPU to visualize tiles */ + if ((clr & 0xff) == 0) + clr |= 64 + i * 8; + if ((clr & 0xff00) == 0) + clr |= (64 + i * 8) << 8; + if ((clr & 0xff0000) == 0) + clr |= (64 + i * 8) << 16; + if ((clr & 0xff000000) == 0) + clr |= (64 + i * 8) << 24; + } cell_global.command[i].clear.value = clr; #else cell_global.command[i].clear.value = clearValue; #endif - send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES); + cell_global.command[i].clear.surface = surfIndex; + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_SURFACE); } + + /* XXX temporary */ + cell_flush(&cell->pipe, 0x0); + } diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 9580281971..1552452ab7 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -50,7 +50,7 @@ volatile struct cell_init_info init; struct framebuffer fb; uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; int DefaultTag; @@ -70,7 +70,7 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, int tag, int zBuf) { const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); const ubyte *src = zBuf ? fb->depth_start : fb->color_start; src += offset * bytesPerTile; @@ -96,7 +96,7 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, int tag, int zBuf) { const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); ubyte *dst = zBuf ? fb->depth_start : fb->color_start; dst += offset * bytesPerTile; @@ -119,15 +119,22 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, static void -clear_tiles(const struct cell_command_clear_tiles *clear) +clear_surface(const struct cell_command_clear_surface *clear) { uint num_tiles = fb.width_tiles * fb.height_tiles; uint i, j; int tag = init.id; - for (i = 0; i < TILE_SIZE; i++) - for (j = 0; j < TILE_SIZE; j++) - ctile[i][j] = clear->value; + if (clear->surface == 0) { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ctile[i][j] = clear->value; + } + else { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ztile[i][j] = clear->value; + } /* printf("SPU: %s num=%d w=%d h=%d\n", @@ -137,7 +144,10 @@ clear_tiles(const struct cell_command_clear_tiles *clear) for (i = init.id; i < num_tiles; i += init.num_spus) { uint tx = i % fb.width_tiles; uint ty = i / fb.width_tiles; - put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); + if (clear->surface == 0) + put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); + else + put_tile(&fb, tx, ty, (uint *) ztile, tag, 1); /* XXX we don't want this here, but it fixes bad tile results */ wait_on_mask(1 << tag); } @@ -227,7 +237,7 @@ render(const struct cell_command_render *render) get_tile(&fb, tx, ty, (uint *) ctile, tag, 0); wait_on_mask(1 << tag); /* XXX temporary */ - if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) { + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { get_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); wait_on_mask(1 << (tag+1)); /* XXX temporary */ } @@ -265,7 +275,7 @@ render(const struct cell_command_render *render) put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); wait_on_mask(1 << tag); /* XXX temp */ - if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) { + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { put_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); wait_on_mask(1 << (tag+1)); /* XXX temporary */ } @@ -313,11 +323,14 @@ main_loop(void) exitFlag = 1; break; case CELL_CMD_FRAMEBUFFER: - printf("SPU %u: FRAMEBUFFER: %d x %d at %p, format 0x%x\n", init.id, + printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", + init.id, cmd.fb.width, cmd.fb.height, cmd.fb.color_start, - cmd.fb.color_format); + cmd.fb.color_format, + cmd.fb.depth_format); + printf("Z16 = 0x%x\n", PIPE_FORMAT_Z16_UNORM); fb.color_start = cmd.fb.color_start; fb.depth_start = cmd.fb.depth_start; fb.color_format = cmd.fb.color_format; @@ -331,9 +344,10 @@ main_loop(void) init.id, fb.width_tiles, fb.height_tiles); */ break; - case CELL_CMD_CLEAR_TILES: - printf("SPU %u: CLEAR to 0x%08x\n", init.id, cmd.clear.value); - clear_tiles(&cmd.clear); + case CELL_CMD_CLEAR_SURFACE: + printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, + cmd.clear.surface, cmd.clear.value); + clear_surface(&cmd.clear); break; case CELL_CMD_RENDER: printf("SPU %u: RENDER %u verts, prim %u\n", diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index c22679c5d9..5e0516d0c1 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -50,7 +50,7 @@ struct framebuffer { extern struct framebuffer fb; extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -extern uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; extern int DefaultTag; diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 36599297b9..58fca2e34a 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -227,6 +227,22 @@ eval_coeff( struct setup_stage *setup, uint slot, } +static INLINE void +eval_z( struct setup_stage *setup, + float x, float y, float result[4]) +{ + uint slot = 0; + uint i = 2; + const float *dadx = setup->coef[slot].dadx; + const float *dady = setup->coef[slot].dady; + + result[QUAD_TOP_LEFT] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i]; + result[QUAD_TOP_RIGHT] = result[0] + dadx[i]; + result[QUAD_BOTTOM_LEFT] = result[0] + dady[i]; + result[QUAD_BOTTOM_RIGHT] = result[0] + dadx[i] + dady[i]; +} + + static INLINE uint pack_color(const float color[4]) { @@ -263,9 +279,48 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) int ix = x - cliprect_minx; int iy = y - cliprect_miny; float colors[4][4]; + uint z; eval_coeff(setup, 1, (float) x, (float) y, colors); + + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + float zvals[4]; + eval_z(setup, (float) x, (float) y, zvals); + + if (mask & MASK_TOP_LEFT) { + z = (uint) (zvals[0] * 65535.0); + if (z < ztile[iy][ix]) + ztile[iy][ix] = z; + else + mask &= ~MASK_TOP_LEFT; + } + + if (mask & MASK_TOP_RIGHT) { + z = (uint) (zvals[1] * 65535.0); + if (z < ztile[iy][ix+1]) + ztile[iy][ix+1] = z; + else + mask &= ~MASK_TOP_RIGHT; + } + + if (mask & MASK_BOTTOM_LEFT) { + z = (uint) (zvals[2] * 65535.0); + if (z < ztile[iy+1][ix]) + ztile[iy+1][ix] = z; + else + mask &= ~MASK_BOTTOM_LEFT; + } + + if (mask & MASK_BOTTOM_RIGHT) { + z = (uint) (zvals[3] * 65535.0); + if (z < ztile[iy+1][ix+1]) + ztile[iy+1][ix+1] = z; + else + mask &= ~MASK_BOTTOM_RIGHT; + } + } + if (mask & MASK_TOP_LEFT) ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); if (mask & MASK_TOP_RIGHT) @@ -512,10 +567,10 @@ static void const_coeff( struct setup_stage *setup, * for a triangle. */ static void tri_linear_coeff( struct setup_stage *setup, - unsigned slot ) + uint slot, uint firstComp, uint lastComp ) { uint i; - for (i = 0; i < 4; i++) { + for (i = firstComp; i < lastComp; i++) { float botda = setup->vmid->data[slot][i] - setup->vmin->data[slot][i]; float majda = setup->vmax->data[slot][i] - setup->vmin->data[slot][i]; float a = setup->ebot.dy * majda - botda * setup->emaj.dy; @@ -637,7 +692,8 @@ static void setup_tri_coefficients( struct setup_stage *setup ) } } #else - tri_linear_coeff(setup, 1); /* slot 1 = color */ + tri_linear_coeff(setup, 0, 2, 3); /* slot 0, z */ + tri_linear_coeff(setup, 1, 0, 4); /* slot 1, color */ #endif } -- cgit v1.2.3 From d48c6e7b21839791ff53308187cc2aeed9fb618c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 Jan 2008 14:14:24 -0700 Subject: Cell: remove some debug printfs, predicate others with Debug boolean --- src/mesa/pipe/cell/ppu/cell_flush.c | 2 -- src/mesa/pipe/cell/ppu/cell_render.c | 3 --- src/mesa/pipe/cell/ppu/cell_surface.c | 2 -- src/mesa/pipe/cell/spu/main.c | 49 +++++++++++++++++++++-------------- 4 files changed, 30 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_flush.c b/src/mesa/pipe/cell/ppu/cell_flush.c index 47003bef18..977c50da32 100644 --- a/src/mesa/pipe/cell/ppu/cell_flush.c +++ b/src/mesa/pipe/cell/ppu/cell_flush.c @@ -38,8 +38,6 @@ cell_flush(struct pipe_context *pipe, unsigned flags) struct cell_context *cell = cell_context(pipe); uint i; - printf("%s\n", __FUNCTION__); - cell_flush_prim_buffer(cell); /* Send CMD_FINISH to all SPUs */ diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c index f5a91776a5..ecdd47e28b 100644 --- a/src/mesa/pipe/cell/ppu/cell_render.c +++ b/src/mesa/pipe/cell/ppu/cell_render.c @@ -123,8 +123,6 @@ render_tri(struct draw_stage *stage, struct prim_header *prim) struct cell_prim_buffer *buf = &cell->prim_buffer; uint i; - printf("Cell render tri\n"); - if (buf->num_verts + 3 > CELL_MAX_VERTS) { cell_flush_prim_buffer(cell); } @@ -150,7 +148,6 @@ cell_flush_prim_buffer(struct cell_context *cell) if (cell->prim_buffer.num_verts == 0) return; - printf("*** Flushing prim buffer\n"); for (i = 0; i < cell->num_spus; i++) { struct cell_command_render *render = &cell_global.command[i].render; render->prim_type = PIPE_PRIM_TRIANGLES; diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 1e1548c8b6..03dd41583f 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -59,8 +59,6 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, surfIndex = 0; } - printf("Clear surf %u\n", surfIndex); - for (i = 0; i < cell->num_spus; i++) { #if 1 uint clr = clearValue; diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 1552452ab7..8e7f8be1eb 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -45,6 +45,8 @@ helpful headers: /opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h */ +static boolean Debug = TRUE; + volatile struct cell_init_info init; struct framebuffer fb; @@ -292,7 +294,8 @@ main_loop(void) struct cell_command cmd; int exitFlag = 0; - printf("SPU %u: Enter main loop\n", init.id); + if (Debug) + printf("SPU %u: Enter main loop\n", init.id); assert((sizeof(struct cell_command) & 0xf) == 0); ASSERT_ALIGN16(&cmd); @@ -301,12 +304,14 @@ main_loop(void) unsigned opcode; int tag = 0; - printf("SPU %u: Wait for cmd...\n", init.id); + if (Debug) + printf("SPU %u: Wait for cmd...\n", init.id); /* read/wait from mailbox */ opcode = (unsigned int) spu_read_in_mbox(); - printf("SPU %u: got cmd %u\n", init.id, opcode); + if (Debug) + printf("SPU %u: got cmd %u\n", init.id, opcode); /* command payload */ mfc_get(&cmd, /* dest */ @@ -319,18 +324,19 @@ main_loop(void) switch (opcode) { case CELL_CMD_EXIT: - printf("SPU %u: EXIT\n", init.id); + if (Debug) + printf("SPU %u: EXIT\n", init.id); exitFlag = 1; break; case CELL_CMD_FRAMEBUFFER: - printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", - init.id, - cmd.fb.width, - cmd.fb.height, - cmd.fb.color_start, - cmd.fb.color_format, - cmd.fb.depth_format); - printf("Z16 = 0x%x\n", PIPE_FORMAT_Z16_UNORM); + if (Debug) + printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", + init.id, + cmd.fb.width, + cmd.fb.height, + cmd.fb.color_start, + cmd.fb.color_format, + cmd.fb.depth_format); fb.color_start = cmd.fb.color_start; fb.depth_start = cmd.fb.depth_start; fb.color_format = cmd.fb.color_format; @@ -345,18 +351,21 @@ main_loop(void) */ break; case CELL_CMD_CLEAR_SURFACE: - printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, - cmd.clear.surface, cmd.clear.value); + if (Debug) + printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, + cmd.clear.surface, cmd.clear.value); clear_surface(&cmd.clear); break; case CELL_CMD_RENDER: - printf("SPU %u: RENDER %u verts, prim %u\n", - init.id, cmd.render.num_verts, cmd.render.prim_type); + if (Debug) + printf("SPU %u: RENDER %u verts, prim %u\n", + init.id, cmd.render.num_verts, cmd.render.prim_type); render(&cmd.render); break; case CELL_CMD_FINISH: - printf("SPU %u: FINISH\n", init.id); + if (Debug) + printf("SPU %u: FINISH\n", init.id); /* wait for all outstanding DMAs to finish */ mfc_write_tag_mask(~0); mfc_read_tag_status_all(); @@ -369,7 +378,8 @@ main_loop(void) } - printf("SPU %u: Exit main loop\n", init.id); + if (Debug) + printf("SPU %u: Exit main loop\n", init.id); } @@ -388,7 +398,8 @@ main(unsigned long speid, unsigned long argp) DefaultTag = 1; - printf("SPU: main() speid=%lu\n", speid); + if (Debug) + printf("SPU: main() speid=%lu\n", speid); mfc_get(&init, /* dest */ (unsigned int) argp, /* src */ -- cgit v1.2.3 From c7a22c39792d6ff430af84502d578824081dbd3f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 Jan 2008 14:44:19 -0700 Subject: move cliprect bounds, do trivial rejection triangle clipping --- src/mesa/pipe/cell/spu/tri.c | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 58fca2e34a..5d4790fe6c 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -72,8 +72,6 @@ #define PIPE_MAX_SHADER_INPUTS 8 /* XXX temp */ -static int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; - #endif @@ -124,6 +122,8 @@ struct setup_stage { float oneoverarea; + int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; + #if 0 struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS]; #else @@ -276,8 +276,8 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) sp->quad.first->run(sp->quad.first, &setup->quad); #else /* Cell: "write" quad fragments to the tile by setting prim color */ - int ix = x - cliprect_minx; - int iy = y - cliprect_miny; + int ix = x - setup->cliprect_minx; + int iy = y - setup->cliprect_miny; float colors[4][4]; uint z; @@ -497,6 +497,20 @@ static boolean setup_sort_vertices( struct setup_stage *setup, } } + /* Check if triangle is completely outside the tile bounds */ + if (setup->vmin->data[0][1] > setup->cliprect_maxy) + return FALSE; + if (setup->vmax->data[0][1] < setup->cliprect_miny) + return FALSE; + if (setup->vmin->data[0][0] < setup->cliprect_minx && + setup->vmid->data[0][0] < setup->cliprect_minx && + setup->vmax->data[0][0] < setup->cliprect_minx) + return FALSE; + if (setup->vmin->data[0][0] > setup->cliprect_maxx && + setup->vmid->data[0][0] > setup->cliprect_maxx && + setup->vmax->data[0][0] > setup->cliprect_maxx) + return FALSE; + setup->ebot.dx = setup->vmid->data[0][0] - setup->vmin->data[0][0]; setup->ebot.dy = setup->vmid->data[0][1] - setup->vmin->data[0][1]; setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0]; @@ -733,18 +747,10 @@ static void subtriangle( struct setup_stage *setup, struct edge *eright, unsigned lines ) { -#if 0 - const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect; - const int minx = (int) cliprect->minx; - const int maxx = (int) cliprect->maxx; - const int miny = (int) cliprect->miny; - const int maxy = (int) cliprect->maxy; -#else - const int minx = cliprect_minx; - const int maxx = cliprect_maxx; - const int miny = cliprect_miny; - const int maxy = cliprect_maxy; -#endif + const int minx = setup->cliprect_minx; + const int maxx = setup->cliprect_maxx; + const int miny = setup->cliprect_miny; + const int maxy = setup->cliprect_maxy; int y, start_y, finish_y; int sy = (int)eleft->sy; @@ -810,25 +816,19 @@ static void subtriangle( struct setup_stage *setup, /** * Do setup for triangle rasterization, then render the triangle. */ -static void setup_tri( -#if 0 - struct draw_stage *stage, -#endif - struct prim_header *prim ) +static void +setup_tri(struct setup_stage *setup, struct prim_header *prim) { -#if 0 - struct setup_stage *setup = setup_stage( stage ); -#else - struct setup_stage ss; - struct setup_stage *setup = &ss; - ss.color = prim->color; -#endif + setup->color = prim->color; /* XXX temporary */ /* _mesa_printf("%s\n", __FUNCTION__ ); */ - setup_sort_vertices( setup, prim ); + if (!setup_sort_vertices( setup, prim )) { + return; /* totally clipped */ + } + setup_tri_coefficients( setup ); setup_tri_edges( setup ); @@ -930,13 +930,13 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) void tri_draw(struct prim_header *tri, uint tx, uint ty) { + struct setup_stage setup; + /* set clipping bounds to tile bounds */ - cliprect_minx = tx * TILE_SIZE; - cliprect_miny = ty * TILE_SIZE; - cliprect_maxx = (tx + 1) * TILE_SIZE; - cliprect_maxy = (ty + 1) * TILE_SIZE; + setup.cliprect_minx = tx * TILE_SIZE; + setup.cliprect_miny = ty * TILE_SIZE; + setup.cliprect_maxx = (tx + 1) * TILE_SIZE; + setup.cliprect_maxy = (ty + 1) * TILE_SIZE; - setup_tri(tri); + setup_tri(&setup, tri); } - - -- cgit v1.2.3 From 18b0f345212a5950bddebe00edc3ec5f54781456 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 Jan 2008 16:12:25 -0700 Subject: Cell: start using DMA tags in a more sensible way, move waits() later when possible. --- src/mesa/pipe/cell/spu/main.c | 52 +++++++++++++++++++++++++++---------------- src/mesa/pipe/cell/spu/main.h | 12 ++++++++++ src/mesa/pipe/cell/spu/tri.c | 7 +++++- 3 files changed, 51 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 8e7f8be1eb..7b63e85ae2 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -45,7 +45,7 @@ helpful headers: /opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h */ -static boolean Debug = TRUE; +static boolean Debug = FALSE; volatile struct cell_init_info init; @@ -59,9 +59,10 @@ int DefaultTag; void -wait_on_mask(unsigned tag) +wait_on_mask(unsigned tagMask) { - mfc_write_tag_mask( tag ); + mfc_write_tag_mask( tagMask ); + /* wait for completion of _any_ DMAs specified by tagMask */ mfc_read_tag_status_any(); } @@ -125,7 +126,6 @@ clear_surface(const struct cell_command_clear_surface *clear) { uint num_tiles = fb.width_tiles * fb.height_tiles; uint i, j; - int tag = init.id; if (clear->surface == 0) { for (i = 0; i < TILE_SIZE; i++) @@ -147,13 +147,15 @@ clear_surface(const struct cell_command_clear_surface *clear) uint tx = i % fb.width_tiles; uint ty = i / fb.width_tiles; if (clear->surface == 0) - put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); else - put_tile(&fb, tx, ty, (uint *) ztile, tag, 1); + put_tile(&fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); /* XXX we don't want this here, but it fixes bad tile results */ - wait_on_mask(1 << tag); } +#if 0 + wait_on_mask(1 << TAG_SURFACE_CLEAR); +#endif } @@ -198,7 +200,6 @@ static void render(const struct cell_command_render *render) { struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; - int tag = init.id /**DefaultTag**/; uint i, j, vertex_bytes; /* @@ -217,16 +218,18 @@ render(const struct cell_command_render *render) mfc_get(&prim_buffer, /* dest */ (unsigned int) render->vertex_data, /* src */ vertex_bytes, /* size */ - tag, + TAG_VERTEX_BUFFER, 0, /* tid */ 0 /* rid */); - wait_on_mask( 1 << tag ); /* XXX temporary */ + wait_on_mask(1 << TAG_VERTEX_BUFFER); /* find tiles which intersect the prim bounding box */ uint txmin, tymin, box_width_tiles, box_num_tiles; tile_bounding_box(render, &txmin, &tymin, &box_num_tiles, &box_width_tiles); + /* make sure any pending clears have completed */ + wait_on_mask(1 << TAG_SURFACE_CLEAR); /* loop over tiles */ for (i = init.id; i < box_num_tiles; i += init.num_spus) { @@ -236,12 +239,12 @@ render(const struct cell_command_render *render) assert(tx < fb.width_tiles); assert(ty < fb.height_tiles); - get_tile(&fb, tx, ty, (uint *) ctile, tag, 0); - wait_on_mask(1 << tag); /* XXX temporary */ - + /* Start fetching color/z tiles. We'll wait for completion when + * we need read/write to them later in triangle rasterization. + */ + get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - get_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); - wait_on_mask(1 << (tag+1)); /* XXX temporary */ + get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); } assert(render->prim_type == PIPE_PRIM_TRIANGLES); @@ -274,12 +277,23 @@ render(const struct cell_command_render *render) tri_draw(&prim, tx, ty); } - put_tile(&fb, tx, ty, (uint *) ctile, tag, 0); - wait_on_mask(1 << tag); /* XXX temp */ + /* in case nothing was drawn, wait now for completion */ + /* XXX temporary */ + wait_on_mask(1 << TAG_READ_TILE_COLOR); + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + wait_on_mask(1 << TAG_READ_TILE_Z); /* XXX temporary */ + } + + /* XXX IF we wrote anything into the tile... */ + + put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + } + wait_on_mask(1 << TAG_WRITE_TILE_COLOR); /* XXX temp */ if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - put_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1); - wait_on_mask(1 << (tag+1)); /* XXX temporary */ + wait_on_mask(1 << TAG_WRITE_TILE_Z); /* XXX temporary */ } } } diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 5e0516d0c1..656d28ea0e 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -55,6 +55,18 @@ extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; extern int DefaultTag; +/* DMA TAGS */ + +#define TAG_SURFACE_CLEAR 10 +#define TAG_VERTEX_BUFFER 11 +#define TAG_READ_TILE_COLOR 12 +#define TAG_READ_TILE_Z 13 +#define TAG_WRITE_TILE_COLOR 14 +#define TAG_WRITE_TILE_Z 15 + + + + void wait_on_mask(unsigned tag); diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 5d4790fe6c..b7dfd6ab8c 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -283,11 +283,13 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) eval_coeff(setup, 1, (float) x, (float) y, colors); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { float zvals[4]; eval_z(setup, (float) x, (float) y, zvals); + wait_on_mask(1 << TAG_READ_TILE_Z); /* XXX temporary */ + + if (mask & MASK_TOP_LEFT) { z = (uint) (zvals[0] * 65535.0); if (z < ztile[iy][ix]) @@ -321,6 +323,9 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) } } + if (mask) + wait_on_mask(1 << TAG_READ_TILE_COLOR); + if (mask & MASK_TOP_LEFT) ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); if (mask & MASK_TOP_RIGHT) -- cgit v1.2.3 From d23869a88a1e9e41c9ebbd5f918ede16a8ee838f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 Jan 2008 17:49:43 -0700 Subject: Cell: initial implementation of tile status optimizations Tiles are marked as CLEAR, DEFINED or DIRTY to avoid making unnecessary get_tile() and put_tile() calls. --- src/mesa/pipe/cell/spu/main.c | 128 ++++++++++++++++++++++++++++++++++++------ src/mesa/pipe/cell/spu/main.h | 22 +++++++- src/mesa/pipe/cell/spu/tri.c | 47 +++++++++++----- 3 files changed, 164 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 7b63e85ae2..5d47ca85d3 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -54,7 +54,9 @@ struct framebuffer fb; uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -int DefaultTag; +ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + @@ -120,13 +122,91 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, } +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + + +/** + * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled + * tiles back to the main framebuffer. + */ +static void +really_clear_tiles(uint surfaceIndex) +{ + const uint num_tiles = fb.width_tiles * fb.height_tiles; + uint i, j; + + if (surfaceIndex == 0) { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ctile[i][j] = fb.color_clear_value; + + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + if (tile_status[ty][tx] == TILE_STATUS_CLEAR) { + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + } + } + } + else { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ztile[i][j] = fb.depth_clear_value; + + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR) + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); + } + } + +#if 0 + wait_on_mask(1 << TAG_SURFACE_CLEAR); +#endif +} + static void clear_surface(const struct cell_command_clear_surface *clear) { - uint num_tiles = fb.width_tiles * fb.height_tiles; + const uint num_tiles = fb.width_tiles * fb.height_tiles; uint i, j; +#define CLEAR_OPT 1 +#if CLEAR_OPT + /* set all tile's status to CLEAR */ + if (clear->surface == 0) { + memset(tile_status, TILE_STATUS_CLEAR, sizeof(tile_status)); + fb.color_clear_value = clear->value; + } + else { + memset(tile_status_z, TILE_STATUS_CLEAR, sizeof(tile_status_z)); + fb.depth_clear_value = clear->value; + } + return; +#endif + if (clear->surface == 0) { for (i = 0; i < TILE_SIZE; i++) for (j = 0; j < TILE_SIZE; j++) @@ -195,7 +275,6 @@ tile_bounding_box(const struct cell_command_render *render, } - static void render(const struct cell_command_render *render) { @@ -242,9 +321,14 @@ render(const struct cell_command_render *render) /* Start fetching color/z tiles. We'll wait for completion when * we need read/write to them later in triangle rasterization. */ - get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + } + } + + if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); } assert(render->prim_type == PIPE_PRIM_TRIANGLES); @@ -277,23 +361,22 @@ render(const struct cell_command_render *render) tri_draw(&prim, tx, ty); } - /* in case nothing was drawn, wait now for completion */ - /* XXX temporary */ - wait_on_mask(1 << TAG_READ_TILE_COLOR); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - wait_on_mask(1 << TAG_READ_TILE_Z); /* XXX temporary */ + /* write color/z tiles back to main framebuffer, if dirtied */ + if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + tile_status[ty][tx] = TILE_STATUS_DEFINED; } - - /* XXX IF we wrote anything into the tile... */ - - put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + tile_status_z[ty][tx] = TILE_STATUS_DEFINED; + } } - wait_on_mask(1 << TAG_WRITE_TILE_COLOR); /* XXX temp */ + /* XXX move these... */ + wait_on_mask(1 << TAG_WRITE_TILE_COLOR); if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - wait_on_mask(1 << TAG_WRITE_TILE_Z); /* XXX temporary */ + wait_on_mask(1 << TAG_WRITE_TILE_Z); } } } @@ -380,6 +463,7 @@ main_loop(void) case CELL_CMD_FINISH: if (Debug) printf("SPU %u: FINISH\n", init.id); + really_clear_tiles(0); /* wait for all outstanding DMAs to finish */ mfc_write_tag_mask(~0); mfc_read_tag_status_all(); @@ -398,6 +482,14 @@ main_loop(void) +static void +one_time_init(void) +{ + memset(tile_status, TILE_STATUS_DEFINED, sizeof(tile_status)); + memset(tile_status_z, TILE_STATUS_DEFINED, sizeof(tile_status_z)); +} + + /** * SPE entrypoint. * Note: example programs declare params as 'unsigned long long' but @@ -410,7 +502,7 @@ main(unsigned long speid, unsigned long argp) (void) speid; - DefaultTag = 1; + one_time_init(); if (Debug) printf("SPU: main() speid=%lu\n", speid); diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 656d28ea0e..ee4248ead6 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -34,6 +34,10 @@ #include "pipe/cell/common.h" +#define MAX_WIDTH 1024 +#define MAX_HEIGHT 1024 + + extern volatile struct cell_init_info init; struct framebuffer { @@ -43,6 +47,9 @@ struct framebuffer { enum pipe_format depth_format; uint width, height; /**< size in pixels */ uint width_tiles, height_tiles; /**< width and height in tiles */ + + uint color_clear_value; + uint depth_clear_value; }; /* XXX Collect these globals in a struct: */ @@ -52,8 +59,6 @@ extern struct framebuffer fb; extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -extern int DefaultTag; - /* DMA TAGS */ @@ -66,6 +71,13 @@ extern int DefaultTag; +#define TILE_STATUS_CLEAR 1 +#define TILE_STATUS_DEFINED 2 /**< defined pixel data */ +#define TILE_STATUS_DIRTY 3 /**< modified, but not put back yet */ + +extern ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + void wait_on_mask(unsigned tag); @@ -78,5 +90,11 @@ void put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, int tag, int zBuf); +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); + #endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index b7dfd6ab8c..78cc7a591f 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -122,6 +122,8 @@ struct setup_stage { float oneoverarea; + uint tx, ty; + int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; #if 0 @@ -287,8 +289,15 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) float zvals[4]; eval_z(setup, (float) x, (float) y, zvals); - wait_on_mask(1 << TAG_READ_TILE_Z); /* XXX temporary */ - + if (tile_status_z[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { + /* now, _really_ clear the tile */ + clear_tile_z(ztile, fb.depth_clear_value); + } + else { + /* make sure we've got the tile from main mem */ + wait_on_mask(1 << TAG_READ_TILE_Z); + } + tile_status_z[setup->ty][setup->tx] = TILE_STATUS_DIRTY; if (mask & MASK_TOP_LEFT) { z = (uint) (zvals[0] * 65535.0); @@ -323,17 +332,26 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) } } - if (mask) - wait_on_mask(1 << TAG_READ_TILE_COLOR); - - if (mask & MASK_TOP_LEFT) - ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); - if (mask & MASK_TOP_RIGHT) - ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); - if (mask & MASK_BOTTOM_LEFT) - ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); - if (mask & MASK_BOTTOM_RIGHT) - ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); + if (mask) { + if (tile_status[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { + /* now, _really_ clear the tile */ + clear_tile(ctile, fb.color_clear_value); + } + else { + /* make sure we've got the tile from main mem */ + wait_on_mask(1 << TAG_READ_TILE_COLOR); + } + tile_status[setup->ty][setup->tx] = TILE_STATUS_DIRTY; + + if (mask & MASK_TOP_LEFT) + ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); + if (mask & MASK_TOP_RIGHT) + ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); + if (mask & MASK_BOTTOM_LEFT) + ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); + if (mask & MASK_BOTTOM_RIGHT) + ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); + } #endif } @@ -937,6 +955,9 @@ tri_draw(struct prim_header *tri, uint tx, uint ty) { struct setup_stage setup; + setup.tx = tx; + setup.ty = ty; + /* set clipping bounds to tile bounds */ setup.cliprect_minx = tx * TILE_SIZE; setup.cliprect_miny = ty * TILE_SIZE; -- cgit v1.2.3 From 51ea675745f4212c0bd859a940350faf466df102 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 10 Jan 2008 10:03:17 +0100 Subject: Add glapi/ path for inclusion of glapioffsets.h. Not sure why this is only needed now... --- src/mesa/x86/glapi_x86.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index 1d04779d14..8b7204cdb7 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -27,7 +27,7 @@ */ #include "assyntax.h" -#include "glapioffsets.h" +#include "glapi/glapioffsets.h" #if defined(STDCALL_API) # if defined(USE_MGL_NAMESPACE) -- cgit v1.2.3 From ede7b00b59b37f078de0663918c0c84d572c27e8 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 10 Jan 2008 10:03:47 +0100 Subject: softpipe: Simplify texture memory layout. --- src/mesa/pipe/softpipe/sp_surface.c | 27 ++- src/mesa/pipe/softpipe/sp_texture.c | 330 ++---------------------------------- src/mesa/pipe/softpipe/sp_texture.h | 19 +-- 3 files changed, 30 insertions(+), 346 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 5259fbfd20..ece30e36ec 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -46,20 +46,6 @@ softpipe_get_tex_surface(struct pipe_context *pipe, { struct softpipe_texture *spt = softpipe_texture(pt); struct pipe_surface *ps; - unsigned offset; /* in bytes */ - - offset = spt->level_offset[level]; - - if (pt->target == PIPE_TEXTURE_CUBE) { - offset += spt->image_offset[level][face] * pt->cpp; - } - else if (pt->target == PIPE_TEXTURE_3D) { - offset += spt->image_offset[level][zslice] * pt->cpp; - } - else { - assert(face == 0); - assert(zslice == 0); - } ps = pipe->winsys->surface_alloc(pipe->winsys); if (ps) { @@ -69,8 +55,17 @@ softpipe_get_tex_surface(struct pipe_context *pipe, ps->cpp = pt->cpp; ps->width = pt->width[level]; ps->height = pt->height[level]; - ps->pitch = spt->pitch; - ps->offset = offset; + ps->pitch = ps->width; + ps->offset = spt->level_offset[level]; + + if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) { + ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) * + (pt->compressed ? ps->height/4 : ps->height) * + ps->width * ps->cpp; + } else { + assert(face == 0); + assert(zslice == 0); + } } return ps; } diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c index 44512e4281..e5e6bfe01b 100644 --- a/src/mesa/pipe/softpipe/sp_texture.c +++ b/src/mesa/pipe/softpipe/sp_texture.c @@ -41,10 +41,7 @@ #include "sp_texture.h" -/* At the moment, just make softpipe use the same layout for its - * textures as the i945. Softpipe needs some sort of texture layout, - * this one was handy. May be worthwhile to simplify this code a - * little. +/* Simple, maximally packed layout. */ static unsigned minify( unsigned d ) @@ -53,319 +50,35 @@ static unsigned minify( unsigned d ) } - -static void -sp_miptree_set_level_info(struct softpipe_texture *spt, - unsigned level, - unsigned nr_images, - unsigned x, unsigned y, unsigned w, unsigned h, - unsigned d) -{ - struct pipe_texture *pt = &spt->base; - - assert(level < PIPE_MAX_TEXTURE_LEVELS); - - pt->width[level] = w; - pt->height[level] = h; - pt->depth[level] = d; - - spt->nr_images[level] = nr_images; - spt->level_offset[level] = (x + y * spt->pitch) * pt->cpp; - - /* - DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, - level, w, h, d, x, y, spt->level_offset[level]); - */ - - /* Not sure when this would happen, but anyway: - */ - if (spt->image_offset[level]) { - FREE( spt->image_offset[level] ); - spt->image_offset[level] = NULL; - } - - assert(nr_images); - assert(!spt->image_offset[level]); - - spt->image_offset[level] = (unsigned *) MALLOC( nr_images * sizeof(unsigned) ); - spt->image_offset[level][0] = 0; -} - - -static void -sp_miptree_set_image_offset(struct softpipe_texture *spt, - unsigned level, unsigned img, unsigned x, unsigned y) -{ - if (img == 0 && level == 0) - assert(x == 0 && y == 0); - - assert(img < spt->nr_images[level]); - - spt->image_offset[level][img] = (x + y * spt->pitch); - - /* - DBG("%s level %d img %d pos %d,%d image_offset %x\n", - __FUNCTION__, level, img, x, y, spt->image_offset[level][img]); - */ -} - - static void -sp_miptree_layout_2d( struct softpipe_texture *spt ) +softpipe_texture_layout(struct softpipe_texture * spt) { struct pipe_texture *pt = &spt->base; - int align_h = 2, align_w = 4; unsigned level; - unsigned x = 0; - unsigned y = 0; unsigned width = pt->width[0]; unsigned height = pt->height[0]; + unsigned depth = pt->depth[0]; - spt->pitch = pt->width[0]; - /* XXX FIX THIS: - * we use alignment=64 bytes in sp_region_alloc(). If we change - * that, change this too. - */ - if (spt->pitch < 16) - spt->pitch = 16; - - /* May need to adjust pitch to accomodate the placement of - * the 2nd mipmap. This occurs when the alignment - * constraints of mipmap placement push the right edge of the - * 2nd mipmap out past the width of its parent. - */ - if (pt->first_level != pt->last_level) { - unsigned mip1_width = align(minify(pt->width[0]), align_w) - + minify(minify(pt->width[0])); - - if (mip1_width > pt->width[0]) - spt->pitch = mip1_width; - } - - /* Pitch must be a whole number of dwords, even though we - * express it in texels. - */ - spt->pitch = align(spt->pitch * pt->cpp, 4) / pt->cpp; - spt->total_height = 0; + spt->buffer_size = 0; for ( level = pt->first_level ; level <= pt->last_level ; level++ ) { - unsigned img_height; - - sp_miptree_set_level_info(spt, level, 1, x, y, width, height, 1); - - if (pt->compressed) - img_height = MAX2(1, height/4); - else - img_height = align(height, align_h); + pt->width[level] = width; + pt->height[level] = height; + pt->depth[level] = depth; + spt->level_offset[level] = spt->buffer_size; - /* Because the images are packed better, the final offset - * might not be the maximal one: - */ - spt->total_height = MAX2(spt->total_height, y + img_height); - - /* Layout_below: step right after second mipmap. - */ - if (level == pt->first_level + 1) { - x += align(width, align_w); - } - else { - y += img_height; - } + spt->buffer_size += ((pt->compressed) ? MAX2(1, height/4) : height) * + ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) * + width * pt->cpp; width = minify(width); height = minify(height); + depth = minify(depth); } } -static const int initial_offsets[6][2] = { - {0, 0}, - {0, 2}, - {1, 0}, - {1, 2}, - {1, 1}, - {1, 3} -}; - -static const int step_offsets[6][2] = { - {0, 2}, - {0, 2}, - {-1, 2}, - {-1, 2}, - {-1, 1}, - {-1, 1} -}; - - - -static boolean -softpipe_mipmap_tree_layout(struct pipe_context *pipe, struct softpipe_texture * spt) -{ - struct pipe_texture *pt = &spt->base; - unsigned level; - - switch (pt->target) { - case PIPE_TEXTURE_CUBE:{ - const unsigned dim = pt->width[0]; - unsigned face; - unsigned lvlWidth = pt->width[0], lvlHeight = pt->height[0]; - - assert(lvlWidth == lvlHeight); /* cubemap images are square */ - - /* Depending on the size of the largest images, pitch can be - * determined either by the old-style packing of cubemap faces, - * or the final row of 4x4, 2x2 and 1x1 faces below this. - */ - if (dim > 32) - spt->pitch = ((dim * pt->cpp * 2 + 3) & ~3) / pt->cpp; - else - spt->pitch = 14 * 8; - - spt->total_height = dim * 4 + 4; - - /* Set all the levels to effectively occupy the whole rectangular region. - */ - for (level = pt->first_level; level <= pt->last_level; level++) { - sp_miptree_set_level_info(spt, level, 6, - 0, 0, - lvlWidth, lvlHeight, 1); - lvlWidth /= 2; - lvlHeight /= 2; - } - - - for (face = 0; face < 6; face++) { - unsigned x = initial_offsets[face][0] * dim; - unsigned y = initial_offsets[face][1] * dim; - unsigned d = dim; - - if (dim == 4 && face >= 4) { - y = spt->total_height - 4; - x = (face - 4) * 8; - } - else if (dim < 4 && (face > 0 || pt->first_level > 0)) { - y = spt->total_height - 4; - x = face * 8; - } - - for (level = pt->first_level; level <= pt->last_level; level++) { - sp_miptree_set_image_offset(spt, level, face, x, y); - - d >>= 1; - - switch (d) { - case 4: - switch (face) { - case PIPE_TEX_FACE_POS_X: - case PIPE_TEX_FACE_NEG_X: - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - break; - case PIPE_TEX_FACE_POS_Y: - case PIPE_TEX_FACE_NEG_Y: - y += 12; - x -= 8; - break; - case PIPE_TEX_FACE_POS_Z: - case PIPE_TEX_FACE_NEG_Z: - y = spt->total_height - 4; - x = (face - 4) * 8; - break; - } - - case 2: - y = spt->total_height - 4; - x = 16 + face * 8; - break; - - case 1: - x += 48; - break; - - default: - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - break; - } - } - } - break; - } - case PIPE_TEXTURE_3D:{ - unsigned width = pt->width[0]; - unsigned height = pt->height[0]; - unsigned depth = pt->depth[0]; - unsigned pack_x_pitch, pack_x_nr; - unsigned pack_y_pitch; - unsigned level; - - spt->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp; - spt->total_height = 0; - - pack_y_pitch = MAX2(pt->height[0], 2); - pack_x_pitch = spt->pitch; - pack_x_nr = 1; - - for (level = pt->first_level; level <= pt->last_level; level++) { - unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6; - int x = 0; - int y = 0; - unsigned q, j; - - sp_miptree_set_level_info(spt, level, nr_images, - 0, spt->total_height, - width, height, depth); - - for (q = 0; q < nr_images;) { - for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) { - sp_miptree_set_image_offset(spt, level, q, x, y); - x += pack_x_pitch; - } - - x = 0; - y += pack_y_pitch; - } - - - spt->total_height += y; - - if (pack_x_pitch > 4) { - pack_x_pitch >>= 1; - pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr <= spt->pitch); - } - - if (pack_y_pitch > 2) { - pack_y_pitch >>= 1; - } - - width = minify(width); - height = minify(height); - depth = minify(depth); - } - break; - } - - case PIPE_TEXTURE_1D: - case PIPE_TEXTURE_2D: -// case PIPE_TEXTURE_RECTANGLE: - sp_miptree_layout_2d(spt); - break; - default: - assert(0); - break; - } - - /* - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - spt->pitch, - spt->total_height, pt->cpp, spt->pitch * spt->total_height * pt->cpp); - */ - - return TRUE; -} - void softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt) { @@ -376,15 +89,13 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt) memset(&spt->base + 1, 0, sizeof(struct softpipe_texture) - sizeof(struct pipe_texture)); - if (softpipe_mipmap_tree_layout(pipe, spt)) { - spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); + softpipe_texture_layout(spt); - if (spt->buffer) { - pipe->winsys->buffer_data(pipe->winsys, spt->buffer, - spt->pitch * spt->base.cpp * - spt->total_height, NULL, - PIPE_BUFFER_USAGE_PIXEL); - } + spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); + + if (spt->buffer) { + pipe->winsys->buffer_data(pipe->winsys, spt->buffer, spt->buffer_size, + NULL, PIPE_BUFFER_USAGE_PIXEL); } if (!spt->buffer) { @@ -408,7 +119,6 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) */ if (--(*pt)->refcount <= 0) { struct softpipe_texture *spt = softpipe_texture(*pt); - uint i; /* DBG("%s deleting %p\n", __FUNCTION__, (void *) spt); @@ -416,10 +126,6 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL); - for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) - if (spt->image_offset[i]) - free(spt->image_offset[i]); - free(spt); } *pt = NULL; diff --git a/src/mesa/pipe/softpipe/sp_texture.h b/src/mesa/pipe/softpipe/sp_texture.h index 732064d986..e1a5db2791 100644 --- a/src/mesa/pipe/softpipe/sp_texture.h +++ b/src/mesa/pipe/softpipe/sp_texture.h @@ -10,29 +10,12 @@ struct softpipe_texture { struct pipe_texture base; - /* Derived from the above: - */ - unsigned pitch; - unsigned depth_pitch; /* per-image on i945? */ - unsigned total_height; - - unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS]; - - /* Explicitly store the offset of each image for each cube face or - * depth value. Pretty much have to accept that hardware formats - * are going to be so diverse that there is no unified way to - * compute the offsets of depth/cube images within a mipmap level, - * so have to store them as a lookup table: - */ - unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */ - - /* Includes image offset tables: - */ unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS]; /* The data is held here: */ struct pipe_buffer_handle *buffer; + unsigned long buffer_size; }; -- cgit v1.2.3 From fd8b5ede950eb809165c783db2844130fb4c072d Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 10:22:01 -0700 Subject: clean-up comments, code --- src/mesa/pipe/softpipe/sp_context.c | 2 +- src/mesa/pipe/softpipe/sp_prim_setup.c | 16 +++--- src/mesa/pipe/softpipe/sp_prim_setup.h | 99 ++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 0759092305..4f22539629 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -345,7 +345,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, if (GETENV( "SP_VBUF" ) != NULL) { softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw, &softpipe->pipe, - sp_vbuf_setup_draw); + sp_vbuf_render); draw_set_rasterize_stage(softpipe->draw, softpipe->vbuf); } diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index de45529bf9..722cadc5c0 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -1286,18 +1286,20 @@ static void calc_det( struct prim_header *header ) -/* Test harness - feed vertex buffer back into prim pipeline. +/** + * Render buffer of points/lines/triangles. + * Called by vbuf code when the vertex or index buffer is filled. * * The big issue at this point is that reset_stipple doesn't make it * through the interface. Probably need to split primitives at reset * stipple, perhaps using the ~0 index marker. */ -void sp_vbuf_setup_draw( struct pipe_context *pipe, - unsigned primitive, - const ushort *elements, - unsigned nr_elements, - const void *vertex_buffer, - unsigned nr_vertices ) +void sp_vbuf_render( struct pipe_context *pipe, + unsigned primitive, + const ushort *elements, + unsigned nr_elements, + const void *vertex_buffer, + unsigned nr_vertices ) { struct softpipe_context *softpipe = softpipe_context( pipe ); struct setup_stage *setup = setup_stage( softpipe->setup ); diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.h b/src/mesa/pipe/softpipe/sp_prim_setup.h index 598394f73e..c16dc634b0 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.h +++ b/src/mesa/pipe/softpipe/sp_prim_setup.h @@ -1,33 +1,49 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ #ifndef SP_PRIM_SETUP_H #define SP_PRIM_SETUP_H -/* Vertices are just an array of floats, with all the attributes +/** + * vbuf is a special stage to gather the stream of triangles, lines, points + * together and reconstruct vertex buffers for hardware upload. + * + * First attempt, work in progress. + * + * TODO: + * - separate out vertex buffer building and primitive emit, ie >1 draw per vb. + * - tell vbuf stage how to build hw vertices directly + * - pass vbuf stage a buffer pointer for direct emit to agp/vram. + * + * + * + * Vertices are just an array of floats, with all the attributes * packed. We currently assume a layout like: * * attr[0][0..3] - window position @@ -37,23 +53,11 @@ * all the enabled attributes run contiguously. */ + struct draw_stage; struct softpipe_context; -extern struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ); - - -/* A special stage to gather the stream of triangles, lines, points - * together and reconstruct vertex buffers for hardware upload. - * - * First attempt, work in progress. - * - * TODO: - * - separate out vertex buffer building and primitive emit, ie >1 draw per vb. - * - tell vbuf stage how to build hw vertices directly - * - pass vbuf stage a buffer pointer for direct emit to agp/vram. - */ typedef void (*vbuf_draw_func)( struct pipe_context *pipe, unsigned prim, const ushort *elements, @@ -62,20 +66,23 @@ typedef void (*vbuf_draw_func)( struct pipe_context *pipe, unsigned nr_vertices ); -extern struct draw_stage *sp_draw_vbuf_stage( struct draw_context *draw_context, - struct pipe_context *pipe, - vbuf_draw_func draw ); +extern struct draw_stage * +sp_draw_render_stage( struct softpipe_context *softpipe ); +extern struct draw_stage * +sp_draw_vbuf_stage( struct draw_context *draw_context, + struct pipe_context *pipe, + vbuf_draw_func draw ); -/* Test harness - */ -void sp_vbuf_setup_draw( struct pipe_context *pipe, - unsigned prim, - const ushort *elements, - unsigned nr_elements, - const void *vertex_buffer, - unsigned nr_vertices ); + +extern void +sp_vbuf_render( struct pipe_context *pipe, + unsigned prim, + const ushort *elements, + unsigned nr_elements, + const void *vertex_buffer, + unsigned nr_vertices ); -- cgit v1.2.3 From 3d9c84c1b88d30115682763d2762a3c2bf4e5ff3 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 10:38:28 -0700 Subject: comment about vertex data in emit_vertex() --- src/mesa/pipe/softpipe/sp_prim_vbuf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c index 2cfdeb5809..e9bd4dd5e4 100644 --- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c @@ -120,6 +120,12 @@ static void emit_vertex( struct vbuf_stage *vbuf, vertex->vertex_id = vbuf->nr_vertices++; //vbuf->emit_vertex( vbuf->vertex_ptr, vertex ); + + /* Note: for softpipe, the vertex includes the vertex header info + * such as clip flags and clip coords. In the future when vbuf is + * always used, we could just copy the vertex attributes/data here. + * The sp_prim_setup.c code doesn't use any of the vertex header info. + */ memcpy(vbuf->vertex_ptr, vertex, vbuf->vertex_size); vbuf->vertex_ptr += vbuf->vertex_size; -- cgit v1.2.3 From e6b33b6f35ab2f7b240ac902cc748d8e1a2fd4ef Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 08:32:27 -0700 Subject: bump CELL_MAX_VERTS to 240 --- src/mesa/pipe/cell/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 4c770f5c32..d7de0beece 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -103,7 +103,7 @@ struct cell_init_info /** Temporary */ -#define CELL_MAX_VERTS 48 +#define CELL_MAX_VERTS 240 #define CELL_MAX_ATTRIBS 2 struct cell_prim_buffer { -- cgit v1.2.3 From d07b86dedfd87ed7c301fa81242314c891031693 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 09:13:10 -0700 Subject: Cell: clean-up cell_spu_exit() code --- src/mesa/pipe/cell/ppu/cell_context.c | 2 -- src/mesa/pipe/cell/ppu/cell_spu.c | 25 ++++++++----------------- src/mesa/pipe/cell/ppu/cell_spu.h | 3 --- 3 files changed, 8 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 4fcf804d82..57178c835f 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -148,7 +148,6 @@ cell_destroy_context( struct pipe_context *pipe ) struct cell_context *cell = cell_context(pipe); cell_spu_exit(cell); - wait_spus(cell->num_spus); free(cell); } @@ -255,7 +254,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) #if 0 test_spus(cell); - wait_spus(); #endif return &cell->pipe; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index a7dbf24dd8..44ad3f22b3 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -194,32 +194,23 @@ test_spus(struct cell_context *cell) } -/** - * Wait for all SPUs to exit/return. - */ -void -wait_spus(uint num_spus) -{ - uint i; - void *value; - - for (i = 0; i < num_spus; i++) { - pthread_join(cell_global.spe_threads[i], &value); - } -} - - /** * Tell all the SPUs to stop/exit. */ void cell_spu_exit(struct cell_context *cell) { - unsigned i; + uint i; for (i = 0; i < cell->num_spus; i++) { send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_EXIT); } - wait_spus(cell->num_spus); + /* wait for threads to exit */ + for (i = 0; i < cell->num_spus; i++) { + void *value; + pthread_join(cell_global.spe_threads[i], &value); + cell_global.spe_threads[i] = 0; + cell_global.spe_contexts[i] = 0; + } } diff --git a/src/mesa/pipe/cell/ppu/cell_spu.h b/src/mesa/pipe/cell/ppu/cell_spu.h index 612cb45c59..d11001af62 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.h +++ b/src/mesa/pipe/cell/ppu/cell_spu.h @@ -82,9 +82,6 @@ void test_spus(struct cell_context *cell); -void -wait_spus(uint num_spus); - void cell_spu_exit(struct cell_context *cell); -- cgit v1.2.3 From cd89fe2d390d2e8cdf7039c8405fd34d28419b5e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 09:22:22 -0700 Subject: Cell: s/free/align_free/ --- src/mesa/pipe/cell/ppu/cell_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 57178c835f..fee72eabc2 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -149,7 +149,7 @@ cell_destroy_context( struct pipe_context *pipe ) cell_spu_exit(cell); - free(cell); + align_free(cell); } -- cgit v1.2.3 From 2da5afbd3ffd50409fc729e166fe5133c7a7e7a8 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 15:13:14 -0700 Subject: Cell: call draw_compute_vertex_size() --- src/mesa/pipe/cell/ppu/cell_state_derived.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_state_derived.c b/src/mesa/pipe/cell/ppu/cell_state_derived.c index ee7c0204b8..ec3a8f3a81 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_derived.c +++ b/src/mesa/pipe/cell/ppu/cell_state_derived.c @@ -159,7 +159,8 @@ static void calculate_vertex_layout( struct cell_context *cell ) if (1/*vinfo->attr_mask != cell->attr_mask*/) { /*cell->attr_mask = vinfo->attr_mask;*/ - draw_set_vertex_info( cell->draw, vinfo); + draw_compute_vertex_size(vinfo); + draw_set_vertex_info(cell->draw, vinfo); #if 0 draw_set_twoside_attributes(cell->draw, -- cgit v1.2.3 From 763e30748e99064fafeb0d9b34de8d732732689c Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 15:14:58 -0700 Subject: Cell: initial implementation of vbuf code. The draw module's vbuf stage builds buffers of post-transformed vertices and issues draw-elements calls to render them. We'll pass the vertex and index buffers to the SPUs... --- src/mesa/pipe/cell/ppu/Makefile | 1 + src/mesa/pipe/cell/ppu/cell_context.c | 8 +- src/mesa/pipe/cell/ppu/cell_context.h | 6 ++ src/mesa/pipe/cell/ppu/cell_vbuf.c | 136 ++++++++++++++++++++++++++++++++++ src/mesa/pipe/cell/ppu/cell_vbuf.h | 38 ++++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 src/mesa/pipe/cell/ppu/cell_vbuf.c create mode 100644 src/mesa/pipe/cell/ppu/cell_vbuf.h (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile index 2758e1b77f..9bf89702d5 100644 --- a/src/mesa/pipe/cell/ppu/Makefile +++ b/src/mesa/pipe/cell/ppu/Makefile @@ -30,6 +30,7 @@ SOURCES = \ cell_state_vertex.c \ cell_spu.c \ cell_surface.c \ + cell_vbuf.c \ cell_winsys.c diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index fee72eabc2..091e593e1f 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -46,6 +46,7 @@ #include "cell_state.h" #include "cell_surface.h" #include "cell_spu.h" +#include "cell_vbuf.h" @@ -236,9 +237,14 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) cell->draw = draw_create(); +#define VBUF 0 +#if VBUF + cell_init_vbuf(cell); + draw_set_rasterize_stage(cell->draw, cell->vbuf); +#else cell->render_stage = cell_draw_render_stage(cell); draw_set_rasterize_stage(cell->draw, cell->render_stage); - +#endif cell->prim_buffer.xmin = 1e100; cell->prim_buffer.ymin = 1e100; diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index be985820d1..4ff39a53c6 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -33,10 +33,13 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/draw/draw_vertex.h" +#include "pipe/draw/draw_vbuf.h" #include "cell_winsys.h" #include "pipe/cell/common.h" +struct cell_vbuf_render; + struct cell_vertex_shader_state { struct pipe_shader_state shader; @@ -81,6 +84,9 @@ struct cell_context /** The primitive drawing context */ struct draw_context *draw; struct draw_stage *render_stage; + + /** For post-transformed vertex buffering: */ + struct cell_vbuf_render *vbuf_render; struct draw_stage *vbuf; struct vertex_info vertex_info; diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c new file mode 100644 index 0000000000..1a43d237d9 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -0,0 +1,136 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Authors + * Brian Paul + */ + + +#include "cell_context.h" +#include "cell_vbuf.h" +#include "pipe/draw/draw_vbuf.h" + + +/** + * Subclass of vbuf_render because we need a cell_context pointer in + * a few places. + */ +struct cell_vbuf_render +{ + struct vbuf_render base; + struct cell_context *cell; + uint prim; +}; + + +/** cast wrapper */ +static struct cell_vbuf_render * +cell_vbuf_render(struct vbuf_render *vbr) +{ + return (struct cell_vbuf_render *) vbr; +} + + + +static const struct vertex_info * +cell_vbuf_get_vertex_info(struct vbuf_render *vbr) +{ + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); + return &cvbr->cell->vertex_info; +} + + +static void * +cell_vbuf_allocate_vertices(struct vbuf_render *vbr, + ushort vertex_size, ushort nr_vertices) +{ + printf("Alloc verts %u * %u\n", vertex_size, nr_vertices); + return align_malloc(vertex_size * nr_vertices, 16); +} + + +static void +cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) +{ + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); + cvbr->prim = prim; + printf("cell_set_prim %u\n", prim); +} + + +static void +cell_vbuf_draw(struct vbuf_render *vbr, + const ushort *indices, unsigned nr_indices) +{ + printf("cell_vbuf_draw nr_indices = %u\n", nr_indices); +} + + +static void +cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices, + unsigned vertex_size, unsigned vertices_used) +{ + printf("Free verts %u * %u\n", vertex_size, vertices_used); + align_free(vertices); +} + + +static void +cell_vbuf_destroy(struct vbuf_render *vbr) +{ + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); + cvbr->cell->vbuf_render = NULL; + FREE(cvbr); +} + + +/** + * Initialize the post-transform vertex buffer information for the given + * context. + */ +void +cell_init_vbuf(struct cell_context *cell) +{ + assert(cell->draw); + + cell->vbuf_render = CALLOC_STRUCT(cell_vbuf_render); + + cell->vbuf_render->base.max_indices = 100; + cell->vbuf_render->base.max_vertex_buffer_bytes = 16 * 1024; + + cell->vbuf_render->base.get_vertex_info = cell_vbuf_get_vertex_info; + cell->vbuf_render->base.allocate_vertices = cell_vbuf_allocate_vertices; + cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive; + cell->vbuf_render->base.draw = cell_vbuf_draw; + cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices; + cell->vbuf_render->base.destroy = cell_vbuf_destroy; + + cell->vbuf_render->cell = cell; + + cell->vbuf = draw_vbuf_stage(cell->draw, &cell->vbuf_render->base); +} diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.h b/src/mesa/pipe/cell/ppu/cell_vbuf.h new file mode 100644 index 0000000000..d265cbf770 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.h @@ -0,0 +1,38 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef CELL_VBUF_H +#define CELL_VBUF_H + + +struct cell_context; + +extern void +cell_init_vbuf(struct cell_context *cell); + + +#endif /* CELL_VBUF_H */ -- cgit v1.2.3 From cac8892ddb24ddb92b6f367689712925ee6c2d86 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 17:01:11 -0700 Subject: Additional parameters to vbuf_render->draw() Pass complete information about vertex/index buffer location, size, etc. --- src/mesa/pipe/draw/draw_vbuf.c | 14 ++++++++++---- src/mesa/pipe/draw/draw_vbuf.h | 6 +++++- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 6 +++++- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index d010aaba07..3f6606de86 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -291,8 +291,14 @@ vbuf_flush_indices( struct draw_stage *stage ) assert(0); } - vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices); - + vbuf->render->draw( vbuf->render, + vbuf->prim, + vbuf->indices, + vbuf->nr_indices, + vbuf->vertices, + vbuf->nr_vertices, + vbuf->vertex_size ); + vbuf->nr_indices = 0; } @@ -373,7 +379,7 @@ static void vbuf_destroy( struct draw_stage *stage ) { struct vbuf_stage *vbuf = vbuf_stage( stage ); - FREE( vbuf->indices ); + align_free( vbuf->indices ); FREE( stage ); } @@ -399,7 +405,7 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw, assert(render->max_indices < UNDEFINED_VERTEX_ID); vbuf->max_indices = render->max_indices; - vbuf->indices = MALLOC( vbuf->max_indices ); + vbuf->indices = align_malloc( vbuf->max_indices, 16 ); vbuf->vertices = NULL; vbuf->vertex_ptr = vbuf->vertices; diff --git a/src/mesa/pipe/draw/draw_vbuf.h b/src/mesa/pipe/draw/draw_vbuf.h index 43aa740f64..be4c4ab77b 100644 --- a/src/mesa/pipe/draw/draw_vbuf.h +++ b/src/mesa/pipe/draw/draw_vbuf.h @@ -82,8 +82,12 @@ struct vbuf_render { * DrawElements, note indices are ushort: */ void (*draw)( struct vbuf_render *, + uint prim, const ushort *indices, - unsigned nr_indices ); + uint nr_indices, + const void *vertices, + uint nr_vertices, + uint vertex_bytes); /** * Called when vbuf is done with this set of vertices: diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index 571ad40595..bdcc027ed7 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -136,8 +136,12 @@ i915_vbuf_render_set_primitive( struct vbuf_render *render, static void i915_vbuf_render_draw( struct vbuf_render *render, + uint prim, const ushort *indices, - unsigned nr_indices ) + uint nr_indices, + const void *vertices, + uint nr_vertices, + uint vertex_bytes) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; -- cgit v1.2.3 From 152f1d84d4d942d9e912b116c5fc67ba96ed9859 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 17:01:52 -0700 Subject: Cell: checkpoint: draw_vbuf code in place and works, but not enabled by default yet. --- src/mesa/pipe/cell/common.h | 15 ++++ src/mesa/pipe/cell/ppu/cell_vbuf.c | 59 +++++++++++++-- src/mesa/pipe/cell/spu/main.c | 146 +++++++++++++++++++++++++++++++++++++ src/mesa/pipe/cell/spu/main.h | 1 + 4 files changed, 213 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index d7de0beece..dc2db299c4 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -52,6 +52,7 @@ #define CELL_CMD_CLEAR_SURFACE 3 #define CELL_CMD_FINISH 4 #define CELL_CMD_RENDER 5 +#define CELL_CMD_RENDER_VBUF 6 /** @@ -84,12 +85,26 @@ struct cell_command_render } ALIGN16_ATTRIB; +#define CELL_MAX_VBUF_SIZE (16 * 1024) +#define CELL_MAX_VBUF_INDEXES 1024 +struct cell_command_render_vbuf +{ + uint prim_type; + uint num_verts, num_attribs; + uint num_indexes; + const void *vertex_data; + const ushort *index_data; + float xmin, ymin, xmax, ymax; +} ALIGN16_ATTRIB; + + /** XXX unions don't seem to work */ struct cell_command { struct cell_command_framebuffer fb; struct cell_command_clear_surface clear; struct cell_command_render render; + struct cell_command_render_vbuf render_vbuf; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 1a43d237d9..cf468204bb 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -32,6 +32,7 @@ #include "cell_context.h" +#include "cell_spu.h" #include "cell_vbuf.h" #include "pipe/draw/draw_vbuf.h" @@ -69,7 +70,7 @@ static void * cell_vbuf_allocate_vertices(struct vbuf_render *vbr, ushort vertex_size, ushort nr_vertices) { - printf("Alloc verts %u * %u\n", vertex_size, nr_vertices); + /*printf("Alloc verts %u * %u\n", vertex_size, nr_vertices);*/ return align_malloc(vertex_size * nr_vertices, 16); } @@ -79,23 +80,63 @@ cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) { struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); cvbr->prim = prim; - printf("cell_set_prim %u\n", prim); + /*printf("cell_set_prim %u\n", prim);*/ } +#if 0 static void cell_vbuf_draw(struct vbuf_render *vbr, - const ushort *indices, unsigned nr_indices) + uint prim, + const ushort *indices, + uint nr_indices, + const void *vertices, + uint nr_vertices, + uint vertex_size) { - printf("cell_vbuf_draw nr_indices = %u\n", nr_indices); + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); + struct cell_context *cell = cvbr->cell; + uint i; + + /*printf("cell_vbuf_draw nr_indices = %u\n", nr_indices);*/ + + if (prim != PIPE_PRIM_TRIANGLES) + return; /* only render tris for now */ + + for (i = 0; i < cell->num_spus; i++) { + struct cell_command_render_vbuf *render = &cell_global.command[i].render_vbuf; + render->prim_type = prim; + render->num_verts = nr_vertices; + render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ + render->vertex_data = vertices; + render->index_data = indices; + render->num_indexes = nr_indices; +#if 0 + render->xmin = cell->prim_buffer.xmin; + render->ymin = cell->prim_buffer.ymin; + render->xmax = cell->prim_buffer.xmax; + render->ymax = cell->prim_buffer.ymax; +#else + render->xmin = -100; + render->ymin = -100; + render->xmax = 100; + render->ymax = 100; +#endif + + ASSERT_ALIGN16(render->vertex_data); + ASSERT_ALIGN16(render->index_data); + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER_VBUF); + } + + cell_flush(&cell->pipe, 0x0); } - +#endif static void cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices, unsigned vertex_size, unsigned vertices_used) { - printf("Free verts %u * %u\n", vertex_size, vertices_used); + /*printf("Free verts %u * %u\n", vertex_size, vertices_used);*/ align_free(vertices); } @@ -120,13 +161,15 @@ cell_init_vbuf(struct cell_context *cell) cell->vbuf_render = CALLOC_STRUCT(cell_vbuf_render); - cell->vbuf_render->base.max_indices = 100; - cell->vbuf_render->base.max_vertex_buffer_bytes = 16 * 1024; + cell->vbuf_render->base.max_indices = CELL_MAX_VBUF_INDEXES; + cell->vbuf_render->base.max_vertex_buffer_bytes = CELL_MAX_VBUF_SIZE; cell->vbuf_render->base.get_vertex_info = cell_vbuf_get_vertex_info; cell->vbuf_render->base.allocate_vertices = cell_vbuf_allocate_vertices; cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive; +#if 0 cell->vbuf_render->base.draw = cell_vbuf_draw; +#endif cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices; cell->vbuf_render->base.destroy = cell_vbuf_destroy; diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 5d47ca85d3..6dbd93f530 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -382,6 +382,143 @@ render(const struct cell_command_render *render) } +static void +render_vbuf(const struct cell_command_render_vbuf *render) +{ + /* we'll DMA into these buffers */ + ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; + ushort indexes[CELL_MAX_VBUF_INDEXES] ALIGN16_ATTRIB; + uint i, j, vertex_bytes, index_bytes; + + ASSERT_ALIGN16(render->vertex_data); + ASSERT_ALIGN16(render->index_data); + + /* how much vertex data */ + vertex_bytes = render->num_verts * render->num_attribs * 4 * sizeof(float); + index_bytes = render->num_indexes * sizeof(ushort); + if (index_bytes < 8) + index_bytes = 8; + else + index_bytes = (index_bytes + 15) & ~0xf; /* multiple of 16 */ + + /* + printf("VBUF: indices at %p, vertices at %p vertex_bytes %u ind_bytes %u\n", + render->index_data, render->vertex_data, vertex_bytes, index_bytes); + */ + + /* get vertex data from main memory */ + mfc_get(vertex_data, /* dest */ + (unsigned int) render->vertex_data, /* src */ + vertex_bytes, /* size */ + TAG_VERTEX_BUFFER, + 0, /* tid */ + 0 /* rid */); + + /* get index data from main memory */ + mfc_get(indexes, /* dest */ + (unsigned int) render->index_data, /* src */ + index_bytes, + TAG_INDEX_BUFFER, + 0, /* tid */ + 0 /* rid */); + + wait_on_mask(1 << TAG_VERTEX_BUFFER); + wait_on_mask(1 << TAG_INDEX_BUFFER); + + /* find tiles which intersect the prim bounding box */ + uint txmin, tymin, box_width_tiles, box_num_tiles; +#if 0 + tile_bounding_box(render, &txmin, &tymin, + &box_num_tiles, &box_width_tiles); +#else + txmin = 0; + tymin = 0; + box_num_tiles = fb.width_tiles * fb.height_tiles; + box_width_tiles = fb.width_tiles; +#endif + + /* make sure any pending clears have completed */ + wait_on_mask(1 << TAG_SURFACE_CLEAR); + + /* loop over tiles */ + for (i = init.id; i < box_num_tiles; i += init.num_spus) { + const uint tx = txmin + i % box_width_tiles; + const uint ty = tymin + i / box_width_tiles; + + assert(tx < fb.width_tiles); + assert(ty < fb.height_tiles); + + /* Start fetching color/z tiles. We'll wait for completion when + * we need read/write to them later in triangle rasterization. + */ + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + } + } + + if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); + } + + assert(render->prim_type == PIPE_PRIM_TRIANGLES); + + /* loop over tris */ + for (j = 0; j < render->num_indexes; j += 3) { + struct prim_header prim; + const float *vbuf = (const float *) vertex_data; + const float *v0, *v1, *v2; + + v0 = vbuf + indexes[j] * render->num_attribs * 4; + v1 = vbuf + indexes[j+1] * render->num_attribs * 4; + v2 = vbuf + indexes[j+2] * render->num_attribs * 4; + + /* + printf(" %u: Triangle %g,%g %g,%g %g,%g\n", + init.id, + prim_buffer.vertex[j*3+0][0][0], + prim_buffer.vertex[j*3+0][0][1], + prim_buffer.vertex[j*3+1][0][0], + prim_buffer.vertex[j*3+1][0][1], + prim_buffer.vertex[j*3+2][0][0], + prim_buffer.vertex[j*3+2][0][1]); + */ + + /* pos */ + COPY_4V(prim.v[0].data[0], v0); + COPY_4V(prim.v[1].data[0], v1); + COPY_4V(prim.v[2].data[0], v2); + + /* color */ + COPY_4V(prim.v[0].data[1], v0 + 4); + COPY_4V(prim.v[1].data[1], v1 + 4); + COPY_4V(prim.v[2].data[1], v2 + 4); + + tri_draw(&prim, tx, ty); + } + + /* write color/z tiles back to main framebuffer, if dirtied */ + if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + tile_status[ty][tx] = TILE_STATUS_DEFINED; + } + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + tile_status_z[ty][tx] = TILE_STATUS_DEFINED; + } + } + + /* XXX move these... */ + wait_on_mask(1 << TAG_WRITE_TILE_COLOR); + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + wait_on_mask(1 << TAG_WRITE_TILE_Z); + } + } +} + + + /** * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. */ @@ -459,6 +596,15 @@ main_loop(void) init.id, cmd.render.num_verts, cmd.render.prim_type); render(&cmd.render); break; + case CELL_CMD_RENDER_VBUF: + if (Debug) + printf("SPU %u: RENDER_VBUF prim %u, indices: %u, nr_vert: %u\n", + init.id, + cmd.render_vbuf.prim_type, + cmd.render_vbuf.num_verts, + cmd.render_vbuf.num_indexes); + render_vbuf(&cmd.render_vbuf); + break; case CELL_CMD_FINISH: if (Debug) diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index ee4248ead6..fce113b77d 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -64,6 +64,7 @@ extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; #define TAG_SURFACE_CLEAR 10 #define TAG_VERTEX_BUFFER 11 +#define TAG_INDEX_BUFFER 16 #define TAG_READ_TILE_COLOR 12 #define TAG_READ_TILE_Z 13 #define TAG_WRITE_TILE_COLOR 14 -- cgit v1.2.3 From b3247225423213c156ce4f428d1d246758a96d50 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 17:03:21 -0700 Subject: Cell: enable vbuf path by default --- src/mesa/pipe/cell/ppu/cell_context.c | 2 +- src/mesa/pipe/cell/ppu/cell_vbuf.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 091e593e1f..52c97c939b 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -237,7 +237,7 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) cell->draw = draw_create(); -#define VBUF 0 +#define VBUF 1 #if VBUF cell_init_vbuf(cell); draw_set_rasterize_stage(cell->draw, cell->vbuf); diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index cf468204bb..059a098914 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -84,7 +84,6 @@ cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) } -#if 0 static void cell_vbuf_draw(struct vbuf_render *vbr, uint prim, @@ -130,7 +129,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, cell_flush(&cell->pipe, 0x0); } -#endif + static void cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices, @@ -167,9 +166,7 @@ cell_init_vbuf(struct cell_context *cell) cell->vbuf_render->base.get_vertex_info = cell_vbuf_get_vertex_info; cell->vbuf_render->base.allocate_vertices = cell_vbuf_allocate_vertices; cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive; -#if 0 cell->vbuf_render->base.draw = cell_vbuf_draw; -#endif cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices; cell->vbuf_render->base.destroy = cell_vbuf_destroy; -- cgit v1.2.3 From 6c11485405700865895b7c5f14e08bc5bede2a35 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 17:14:06 -0700 Subject: Cell: use new ASSERT macro instead of standard assert The later doesn't seem to work properly in SPU code. --- src/mesa/pipe/cell/spu/main.c | 23 +++++++++++------------ src/mesa/pipe/cell/spu/main.h | 10 ++++++++++ src/mesa/pipe/cell/spu/tri.c | 6 +++--- 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 6dbd93f530..5ad15bc639 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -30,7 +30,6 @@ #include -#include #include #include @@ -80,8 +79,8 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, src += offset * bytesPerTile; - assert(tx < fb->width_tiles); - assert(ty < fb->height_tiles); + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); ASSERT_ALIGN16(tile); /* printf("get_tile: dest: %p src: 0x%x size: %d\n", @@ -106,8 +105,8 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, dst += offset * bytesPerTile; - assert(tx < fb->width_tiles); - assert(ty < fb->height_tiles); + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); ASSERT_ALIGN16(tile); /* printf("put_tile: src: %p dst: 0x%x size: %d\n", @@ -315,8 +314,8 @@ render(const struct cell_command_render *render) const uint tx = txmin + i % box_width_tiles; const uint ty = tymin + i / box_width_tiles; - assert(tx < fb.width_tiles); - assert(ty < fb.height_tiles); + ASSERT(tx < fb.width_tiles); + ASSERT(ty < fb.height_tiles); /* Start fetching color/z tiles. We'll wait for completion when * we need read/write to them later in triangle rasterization. @@ -331,7 +330,7 @@ render(const struct cell_command_render *render) get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); } - assert(render->prim_type == PIPE_PRIM_TRIANGLES); + ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); /* loop over tris */ for (j = 0; j < render->num_verts; j += 3) { @@ -445,8 +444,8 @@ render_vbuf(const struct cell_command_render_vbuf *render) const uint tx = txmin + i % box_width_tiles; const uint ty = tymin + i / box_width_tiles; - assert(tx < fb.width_tiles); - assert(ty < fb.height_tiles); + ASSERT(tx < fb.width_tiles); + ASSERT(ty < fb.height_tiles); /* Start fetching color/z tiles. We'll wait for completion when * we need read/write to them later in triangle rasterization. @@ -461,7 +460,7 @@ render_vbuf(const struct cell_command_render_vbuf *render) get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); } - assert(render->prim_type == PIPE_PRIM_TRIANGLES); + ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); /* loop over tris */ for (j = 0; j < render->num_indexes; j += 3) { @@ -531,7 +530,7 @@ main_loop(void) if (Debug) printf("SPU %u: Enter main loop\n", init.id); - assert((sizeof(struct cell_command) & 0xf) == 0); + ASSERT((sizeof(struct cell_command) & 0xf) == 0); ASSERT_ALIGN16(&cmd); while (!exitFlag) { diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index fce113b77d..c539385a07 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -98,4 +98,14 @@ void clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); + +/** The standard assert macro doesn't seem to work on SPUs */ +#define ASSERT(x) \ + if (!(x)) { \ + fprintf(stderr, "SPU %d: %s:%d: %s(): assertion %s failed.\n", \ + init.id, __FILE__, __LINE__, __FUNCTION__, #x); \ + exit(1); \ + } + + #endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 78cc7a591f..b40f35bc69 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -258,7 +258,7 @@ pack_color(const float color[4]) case PIPE_FORMAT_B8G8R8A8_UNORM: return (b << 24) | (g << 16) | (r << 8) | a; default: - assert(0); + ASSERT(0); return 0; } } @@ -613,7 +613,7 @@ static void tri_linear_coeff( struct setup_stage *setup, float a = setup->ebot.dy * majda - botda * setup->emaj.dy; float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - assert(slot < PIPE_MAX_SHADER_INPUTS); + ASSERT(slot < PIPE_MAX_SHADER_INPUTS); setup->coef[slot].dadx[i] = a * setup->oneoverarea; setup->coef[slot].dady[i] = b * setup->oneoverarea; @@ -777,7 +777,7 @@ static void subtriangle( struct setup_stage *setup, int y, start_y, finish_y; int sy = (int)eleft->sy; - assert((int)eleft->sy == (int) eright->sy); + ASSERT((int)eleft->sy == (int) eright->sy); /* clip top/bottom */ start_y = sy; -- cgit v1.2.3 From 02f6f9f8d47fc36c8edf4661c4e78c9c1a1941fc Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 17:30:51 -0700 Subject: Cell: move tile-related code into new tile.[ch] files. --- src/mesa/pipe/cell/spu/Makefile | 4 ++ src/mesa/pipe/cell/spu/main.c | 83 +---------------------------- src/mesa/pipe/cell/spu/main.h | 39 ++------------ src/mesa/pipe/cell/spu/tile.c | 115 ++++++++++++++++++++++++++++++++++++++++ src/mesa/pipe/cell/spu/tile.h | 69 ++++++++++++++++++++++++ src/mesa/pipe/cell/spu/tri.c | 1 + 6 files changed, 194 insertions(+), 117 deletions(-) create mode 100644 src/mesa/pipe/cell/spu/tile.c create mode 100644 src/mesa/pipe/cell/spu/tile.h (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/Makefile b/src/mesa/pipe/cell/spu/Makefile index 8e606dd1a2..bf97a49e78 100644 --- a/src/mesa/pipe/cell/spu/Makefile +++ b/src/mesa/pipe/cell/spu/Makefile @@ -17,6 +17,7 @@ PROG_SPU_EMBED_O = $(PROG)_spu-embed.o SOURCES = \ main.c \ + tile.c \ tri.c SPU_OBJECTS = $(SOURCES:.c=.o) \ @@ -40,6 +41,9 @@ $(PROG_SPU): $(SPU_OBJECTS) main.o: main.c $(SPU_CC) $(SPU_CFLAGS) -c main.c +tile.o: tile.c + $(SPU_CC) $(SPU_CFLAGS) -c tile.c + tri.o: tri.c $(SPU_CC) $(SPU_CFLAGS) -c tri.c diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 5ad15bc639..84134b893a 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -35,6 +35,7 @@ #include "main.h" #include "tri.h" +#include "tile.h" #include "pipe/cell/common.h" #include "pipe/p_defines.h" @@ -50,13 +51,6 @@ volatile struct cell_init_info init; struct framebuffer fb; -uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; - -ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; -ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; - - void @@ -69,81 +63,6 @@ wait_on_mask(unsigned tagMask) -void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf) -{ - const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - const ubyte *src = zBuf ? fb->depth_start : fb->color_start; - - src += offset * bytesPerTile; - - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); - ASSERT_ALIGN16(tile); - /* - printf("get_tile: dest: %p src: 0x%x size: %d\n", - tile, (unsigned int) src, bytesPerTile); - */ - mfc_get(tile, /* dest in local memory */ - (unsigned int) src, /* src in main memory */ - bytesPerTile, - tag, - 0, /* tid */ - 0 /* rid */); -} - - -void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf) -{ - const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - ubyte *dst = zBuf ? fb->depth_start : fb->color_start; - - dst += offset * bytesPerTile; - - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); - ASSERT_ALIGN16(tile); - /* - printf("put_tile: src: %p dst: 0x%x size: %d\n", - tile, (unsigned int) dst, bytesPerTile); - */ - mfc_put((void *) tile, /* src in local memory */ - (unsigned int) dst, /* dst in main memory */ - bytesPerTile, - tag, - 0, /* tid */ - 0 /* rid */); -} - - -void -clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value) -{ - uint i, j; - for (i = 0; i < TILE_SIZE; i++) { - for (j = 0; j < TILE_SIZE; j++) { - tile[i][j] = value; - } - } -} - -void -clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value) -{ - uint i, j; - for (i = 0; i < TILE_SIZE; i++) { - for (j = 0; j < TILE_SIZE; j++) { - tile[i][j] = value; - } - } -} - - /** * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled * tiles back to the main framebuffer. diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index c539385a07..68280eb67b 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -34,10 +34,6 @@ #include "pipe/cell/common.h" -#define MAX_WIDTH 1024 -#define MAX_HEIGHT 1024 - - extern volatile struct cell_init_info init; struct framebuffer { @@ -56,9 +52,6 @@ struct framebuffer { extern struct framebuffer fb; -extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; - /* DMA TAGS */ @@ -71,34 +64,6 @@ extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; #define TAG_WRITE_TILE_Z 15 - -#define TILE_STATUS_CLEAR 1 -#define TILE_STATUS_DEFINED 2 /**< defined pixel data */ -#define TILE_STATUS_DIRTY 3 /**< modified, but not put back yet */ - -extern ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; -extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; - - -void -wait_on_mask(unsigned tag); - -void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf); - -void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf); - -void -clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); - -void -clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); - - - /** The standard assert macro doesn't seem to work on SPUs */ #define ASSERT(x) \ if (!(x)) { \ @@ -108,4 +73,8 @@ clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); } +void +wait_on_mask(unsigned tag); + + #endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tile.c b/src/mesa/pipe/cell/spu/tile.c new file mode 100644 index 0000000000..ac89d0fab0 --- /dev/null +++ b/src/mesa/pipe/cell/spu/tile.c @@ -0,0 +1,115 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + + +#include "tile.h" + + + +uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; + +ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + + + +void +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag, int zBuf) +{ + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); + const ubyte *src = zBuf ? fb->depth_start : fb->color_start; + + src += offset * bytesPerTile; + + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); + ASSERT_ALIGN16(tile); + /* + printf("get_tile: dest: %p src: 0x%x size: %d\n", + tile, (unsigned int) src, bytesPerTile); + */ + mfc_get(tile, /* dest in local memory */ + (unsigned int) src, /* src in main memory */ + bytesPerTile, + tag, + 0, /* tid */ + 0 /* rid */); +} + + +void +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag, int zBuf) +{ + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); + ubyte *dst = zBuf ? fb->depth_start : fb->color_start; + + dst += offset * bytesPerTile; + + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); + ASSERT_ALIGN16(tile); + /* + printf("put_tile: src: %p dst: 0x%x size: %d\n", + tile, (unsigned int) dst, bytesPerTile); + */ + mfc_put((void *) tile, /* src in local memory */ + (unsigned int) dst, /* dst in main memory */ + bytesPerTile, + tag, + 0, /* tid */ + 0 /* rid */); +} + + +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + diff --git a/src/mesa/pipe/cell/spu/tile.h b/src/mesa/pipe/cell/spu/tile.h new file mode 100644 index 0000000000..832cf29e30 --- /dev/null +++ b/src/mesa/pipe/cell/spu/tile.h @@ -0,0 +1,69 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef TILE_H +#define TILE_H + + +#include +#include +#include "main.h" +#include "pipe/cell/common.h" + + +#define MAX_WIDTH 1024 +#define MAX_HEIGHT 1024 + + +extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; + + +#define TILE_STATUS_CLEAR 1 +#define TILE_STATUS_DEFINED 2 /**< defined pixel data */ +#define TILE_STATUS_DIRTY 3 /**< modified, but not put back yet */ + +extern ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + + +void +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag, int zBuf); + +void +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag, int zBuf); + +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); + + +#endif /* TILE_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index b40f35bc69..f902bf2126 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -45,6 +45,7 @@ #include "pipe/p_format.h" #include "pipe/p_util.h" #include "main.h" +#include "tile.h" #include "tri.h" /* -- cgit v1.2.3 From 44f4b9b9ea81974a8e7de444280e471ca05e9261 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:22:03 -0700 Subject: Cell: avoid copying vertex data --- src/mesa/pipe/cell/spu/main.c | 49 ++++++++----------------------------------- src/mesa/pipe/cell/spu/tri.c | 6 ------ src/mesa/pipe/cell/spu/tri.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 84134b893a..27e1169a7f 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -174,6 +174,9 @@ tile_bounding_box(const struct cell_command_render *render, *tymin = 0; *box_num_tiles = fb.width_tiles * fb.height_tiles; *box_width_tiles = fb.width_tiles; + (void) render; + (void) txmax; + (void) tymax; #else uint txmax, tymax, box_height_tiles; @@ -255,26 +258,9 @@ render(const struct cell_command_render *render) for (j = 0; j < render->num_verts; j += 3) { struct prim_header prim; - /* - printf(" %u: Triangle %g,%g %g,%g %g,%g\n", - init.id, - prim_buffer.vertex[j*3+0][0][0], - prim_buffer.vertex[j*3+0][0][1], - prim_buffer.vertex[j*3+1][0][0], - prim_buffer.vertex[j*3+1][0][1], - prim_buffer.vertex[j*3+2][0][0], - prim_buffer.vertex[j*3+2][0][1]); - */ - - /* pos */ - COPY_4V(prim.v[0].data[0], prim_buffer.vertex[j+0][0]); - COPY_4V(prim.v[1].data[0], prim_buffer.vertex[j+1][0]); - COPY_4V(prim.v[2].data[0], prim_buffer.vertex[j+2][0]); - - /* color */ - COPY_4V(prim.v[0].data[1], prim_buffer.vertex[j+0][1]); - COPY_4V(prim.v[1].data[1], prim_buffer.vertex[j+1][1]); - COPY_4V(prim.v[2].data[1], prim_buffer.vertex[j+2][1]); + prim.v[0] = (struct vertex_header *) prim_buffer.vertex[j+0]; + prim.v[1] = (struct vertex_header *) prim_buffer.vertex[j+1]; + prim.v[2] = (struct vertex_header *) prim_buffer.vertex[j+2]; tri_draw(&prim, tx, ty); } @@ -391,26 +377,9 @@ render_vbuf(const struct cell_command_render_vbuf *render) v1 = vbuf + indexes[j+1] * render->num_attribs * 4; v2 = vbuf + indexes[j+2] * render->num_attribs * 4; - /* - printf(" %u: Triangle %g,%g %g,%g %g,%g\n", - init.id, - prim_buffer.vertex[j*3+0][0][0], - prim_buffer.vertex[j*3+0][0][1], - prim_buffer.vertex[j*3+1][0][0], - prim_buffer.vertex[j*3+1][0][1], - prim_buffer.vertex[j*3+2][0][0], - prim_buffer.vertex[j*3+2][0][1]); - */ - - /* pos */ - COPY_4V(prim.v[0].data[0], v0); - COPY_4V(prim.v[1].data[0], v1); - COPY_4V(prim.v[2].data[0], v2); - - /* color */ - COPY_4V(prim.v[0].data[1], v0 + 4); - COPY_4V(prim.v[1].data[1], v1 + 4); - COPY_4V(prim.v[2].data[1], v2 + 4); + prim.v[0] = (struct vertex_header *) v0; + prim.v[1] = (struct vertex_header *) v1; + prim.v[2] = (struct vertex_header *) v2; tri_draw(&prim, tx, ty); } diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index f902bf2126..77f7052cd5 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -455,15 +455,9 @@ static void print_vertex(const struct setup_stage *setup, static boolean setup_sort_vertices( struct setup_stage *setup, const struct prim_header *prim ) { -#if 0 const struct vertex_header *v0 = prim->v[0]; const struct vertex_header *v1 = prim->v[1]; const struct vertex_header *v2 = prim->v[2]; -#else - const struct vertex_header *v0 = &prim->v[0]; - const struct vertex_header *v1 = &prim->v[1]; - const struct vertex_header *v2 = &prim->v[2]; -#endif #if DEBUG_VERTS fprintf(stderr, "Triangle:\n"); diff --git a/src/mesa/pipe/cell/spu/tri.h b/src/mesa/pipe/cell/spu/tri.h index 01612a2579..bcb42852b2 100644 --- a/src/mesa/pipe/cell/spu/tri.h +++ b/src/mesa/pipe/cell/spu/tri.h @@ -40,7 +40,7 @@ struct vertex_header { struct prim_header { - struct vertex_header v[3]; + struct vertex_header *v[3]; uint color; }; -- cgit v1.2.3 From c56b20971bfe554f2b9ba74c40b350f950bb31ff Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:35:13 -0700 Subject: Cell: make vertex_header and prim_header types private to tri.c --- src/mesa/pipe/cell/spu/main.c | 31 +++++++++++++------------------ src/mesa/pipe/cell/spu/tri.c | 26 ++++++++++++++++++++++++-- src/mesa/pipe/cell/spu/tri.h | 17 +---------------- 3 files changed, 38 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 27e1169a7f..7c42013279 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -256,13 +256,11 @@ render(const struct cell_command_render *render) /* loop over tris */ for (j = 0; j < render->num_verts; j += 3) { - struct prim_header prim; + const float *v0 = (const float *) prim_buffer.vertex[j+0]; + const float *v1 = (const float *) prim_buffer.vertex[j+1]; + const float *v2 = (const float *) prim_buffer.vertex[j+2]; - prim.v[0] = (struct vertex_header *) prim_buffer.vertex[j+0]; - prim.v[1] = (struct vertex_header *) prim_buffer.vertex[j+1]; - prim.v[2] = (struct vertex_header *) prim_buffer.vertex[j+2]; - - tri_draw(&prim, tx, ty); + tri_draw(v0, v1, v2, tx, ty); } /* write color/z tiles back to main framebuffer, if dirtied */ @@ -292,13 +290,16 @@ render_vbuf(const struct cell_command_render_vbuf *render) /* we'll DMA into these buffers */ ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; ushort indexes[CELL_MAX_VBUF_INDEXES] ALIGN16_ATTRIB; - uint i, j, vertex_bytes, index_bytes; + + uint i, j, vertex_size, vertex_bytes, index_bytes; ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(render->index_data); + vertex_size = render->num_attribs * 4 * sizeof(float); + /* how much vertex data */ - vertex_bytes = render->num_verts * render->num_attribs * 4 * sizeof(float); + vertex_bytes = render->num_verts * vertex_size; index_bytes = render->num_indexes * sizeof(ushort); if (index_bytes < 8) index_bytes = 8; @@ -369,19 +370,13 @@ render_vbuf(const struct cell_command_render_vbuf *render) /* loop over tris */ for (j = 0; j < render->num_indexes; j += 3) { - struct prim_header prim; - const float *vbuf = (const float *) vertex_data; const float *v0, *v1, *v2; - v0 = vbuf + indexes[j] * render->num_attribs * 4; - v1 = vbuf + indexes[j+1] * render->num_attribs * 4; - v2 = vbuf + indexes[j+2] * render->num_attribs * 4; - - prim.v[0] = (struct vertex_header *) v0; - prim.v[1] = (struct vertex_header *) v1; - prim.v[2] = (struct vertex_header *) v2; + v0 = (const float *) (vertex_data + indexes[j+0] * vertex_size); + v1 = (const float *) (vertex_data + indexes[j+1] * vertex_size); + v2 = (const float *) (vertex_data + indexes[j+2] * vertex_size); - tri_draw(&prim, tx, ty); + tri_draw(v0, v1, v2, tx, ty); } /* write color/z tiles back to main framebuffer, if dirtied */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 77f7052cd5..9eaf1df90b 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -54,6 +54,23 @@ */ +/** + * Simplified types taken from other parts of Gallium + */ + +struct vertex_header { + float data[2][4]; /* pos and color */ +}; + + +struct prim_header { + struct vertex_header *v[3]; + uint color; +}; + + + + #if 1 /* XXX fix this */ @@ -946,10 +963,15 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) * The tile data should have already been fetched. */ void -tri_draw(struct prim_header *tri, uint tx, uint ty) +tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty) { + struct prim_header tri; struct setup_stage setup; + tri.v[0] = (struct vertex_header *) v0; + tri.v[1] = (struct vertex_header *) v1; + tri.v[2] = (struct vertex_header *) v2; + setup.tx = tx; setup.ty = ty; @@ -959,5 +981,5 @@ tri_draw(struct prim_header *tri, uint tx, uint ty) setup.cliprect_maxx = (tx + 1) * TILE_SIZE; setup.cliprect_maxy = (ty + 1) * TILE_SIZE; - setup_tri(&setup, tri); + setup_tri(&setup, &tri); } diff --git a/src/mesa/pipe/cell/spu/tri.h b/src/mesa/pipe/cell/spu/tri.h index bcb42852b2..f10c4077d3 100644 --- a/src/mesa/pipe/cell/spu/tri.h +++ b/src/mesa/pipe/cell/spu/tri.h @@ -30,23 +30,8 @@ #define TRI_H -/** - * Simplified types taken from other parts of Gallium - */ - -struct vertex_header { - float data[2][4]; /* pos and color */ -}; - - -struct prim_header { - struct vertex_header *v[3]; - uint color; -}; - - extern void -tri_draw(struct prim_header *tri, uint tx, uint ty); +tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty); #endif /* TRI_H */ -- cgit v1.2.3 From 6059ecaabefc273f39353825dde568d1a2e2ba19 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:37:55 -0700 Subject: Cell: remove unused code --- src/mesa/pipe/cell/spu/tri.c | 83 -------------------------------------------- 1 file changed, 83 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 9eaf1df90b..52e48e3dd2 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -29,18 +29,6 @@ * Triangle rendering within a tile. */ - -#if 0 -#include "sp_context.h" -#include "sp_headers.h" -#include "sp_quad.h" -#include "sp_prim_setup.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/p_util.h" -#endif - - #include "pipe/p_compiler.h" #include "pipe/p_format.h" #include "pipe/p_util.h" @@ -48,10 +36,6 @@ #include "tile.h" #include "tri.h" -/* -#include -#include -*/ /** @@ -62,7 +46,6 @@ struct vertex_header { float data[2][4]; /* pos and color */ }; - struct prim_header { struct vertex_header *v[3]; uint color; @@ -119,11 +102,6 @@ struct interp_coef * Also used for line drawing (taking some liberties). */ struct setup_stage { -#if 0 - struct draw_stage stage; /**< This must be first (base class) */ - - struct softpipe_context *softpipe; -#endif /* Vertices are just an array of floats making up each attribute in * turn. Currently fixed at 4 floats, but should change in time. @@ -897,67 +875,6 @@ setup_tri(struct setup_stage *setup, struct prim_header *prim) - -#if 0 -static void setup_begin( struct draw_stage *stage ) -{ - struct setup_stage *setup = setup_stage(stage); - struct softpipe_context *sp = setup->softpipe; - - setup->quad.nr_attrs = setup->softpipe->nr_frag_attrs; - - sp->quad.first->begin(sp->quad.first); -} -#endif - -#if 0 -static void setup_end( struct draw_stage *stage ) -{ -} -#endif - - -#if 0 -static void reset_stipple_counter( struct draw_stage *stage ) -{ - struct setup_stage *setup = setup_stage(stage); - setup->softpipe->line_stipple_counter = 0; -} -#endif - -#if 0 -static void render_destroy( struct draw_stage *stage ) -{ - FREE( stage ); -} -#endif - - -#if 0 -/** - * Create a new primitive setup/render stage. - */ -struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) -{ - struct setup_stage *setup = CALLOC_STRUCT(setup_stage); - - setup->softpipe = softpipe; - setup->stage.draw = softpipe->draw; - setup->stage.begin = setup_begin; - setup->stage.point = setup_point; - setup->stage.line = setup_line; - setup->stage.tri = setup_tri; - setup->stage.end = setup_end; - setup->stage.reset_stipple_counter = reset_stipple_counter; - setup->stage.destroy = render_destroy; - - setup->quad.coef = setup->coef; - - return &setup->stage; -} -#endif - - /** * Draw triangle into tile at (tx, ty) (tile coords) * The tile data should have already been fetched. -- cgit v1.2.3 From ea190f4b41d8959aa3edfd46503a3077201cdefd Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:50:31 -0700 Subject: Cell: remove unused color field --- src/mesa/pipe/cell/spu/tri.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 52e48e3dd2..a4fcb71d20 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -48,7 +48,6 @@ struct vertex_header { struct prim_header { struct vertex_header *v[3]; - uint color; }; @@ -131,9 +130,6 @@ struct setup_stage { #if 0 struct quad_header quad; #endif -#if 1 - uint color; -#endif struct { int left[2]; /**< [0] = row0, [1] = row1 */ @@ -832,12 +828,6 @@ static void subtriangle( struct setup_stage *setup, static void setup_tri(struct setup_stage *setup, struct prim_header *prim) { - setup->color = prim->color; /* XXX temporary */ - - /* - _mesa_printf("%s\n", __FUNCTION__ ); - */ - if (!setup_sort_vertices( setup, prim )) { return; /* totally clipped */ } -- cgit v1.2.3 From 71caa922e0bf9f6378bd02374402eaea2990b493 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:50:55 -0700 Subject: Cell: compute bounding box in cell_vbuf_draw() --- src/mesa/pipe/cell/ppu/cell_vbuf.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 059a098914..62d453cb7f 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -95,8 +95,24 @@ cell_vbuf_draw(struct vbuf_render *vbr, { struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); struct cell_context *cell = cvbr->cell; + float xmin, ymin, xmax, ymax; uint i; + /* compute x/y bounding box */ + xmin = ymin = 1e50; + xmax = ymax = -1e50; + for (i = 0; i < nr_vertices; i++) { + const float *v = (float *) ((ubyte *) vertices + i * vertex_size); + if (v[0] < xmin) + xmin = v[0]; + if (v[0] > xmax) + xmax = v[0]; + if (v[1] < ymin) + ymin = v[1]; + if (v[1] > ymax) + ymax = v[1]; + } + /*printf("cell_vbuf_draw nr_indices = %u\n", nr_indices);*/ if (prim != PIPE_PRIM_TRIANGLES) @@ -110,17 +126,10 @@ cell_vbuf_draw(struct vbuf_render *vbr, render->vertex_data = vertices; render->index_data = indices; render->num_indexes = nr_indices; -#if 0 - render->xmin = cell->prim_buffer.xmin; - render->ymin = cell->prim_buffer.ymin; - render->xmax = cell->prim_buffer.xmax; - render->ymax = cell->prim_buffer.ymax; -#else - render->xmin = -100; - render->ymin = -100; - render->xmax = 100; - render->ymax = 100; -#endif + render->xmin = xmin; + render->ymin = ymin; + render->xmax = xmax; + render->ymax = ymax; ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(render->index_data); -- cgit v1.2.3 From aee5f471ce30f0511769c02a24160e9bb5047792 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:53:38 -0700 Subject: Cell: remove unneeded #includes --- src/mesa/pipe/cell/spu/main.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 68280eb67b..9351aa340b 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -29,8 +29,6 @@ #define MAIN_H -#include -#include #include "pipe/cell/common.h" -- cgit v1.2.3 From 299dffce4fafa2ed03a6e1f7ca7a5357c147477e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jan 2008 21:59:15 -0700 Subject: Cell: wait_on_mask_all() --- src/mesa/pipe/cell/spu/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 7c42013279..548ef127ba 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -62,6 +62,15 @@ wait_on_mask(unsigned tagMask) } +static void +wait_on_mask_all(unsigned tagMask) +{ + mfc_write_tag_mask( tagMask ); + /* wait for completion of _any_ DMAs specified by tagMask */ + mfc_read_tag_status_all(); +} + + /** * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled @@ -327,8 +336,8 @@ render_vbuf(const struct cell_command_render_vbuf *render) 0, /* tid */ 0 /* rid */); - wait_on_mask(1 << TAG_VERTEX_BUFFER); - wait_on_mask(1 << TAG_INDEX_BUFFER); + wait_on_mask_all((1 << TAG_VERTEX_BUFFER) | + (1 << TAG_INDEX_BUFFER)); /* find tiles which intersect the prim bounding box */ uint txmin, tymin, box_width_tiles, box_num_tiles; -- cgit v1.2.3 From 1217d5cca3503103cc40221ea8287960236e3734 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 08:14:42 -0700 Subject: Cell: Remove the pre-vbuf rendering code --- src/mesa/pipe/cell/common.h | 13 +---- src/mesa/pipe/cell/ppu/Makefile | 1 - src/mesa/pipe/cell/ppu/cell_context.c | 8 +-- src/mesa/pipe/cell/ppu/cell_vbuf.c | 4 +- src/mesa/pipe/cell/spu/main.c | 104 ++-------------------------------- 5 files changed, 9 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index dc2db299c4..60abe2d9bc 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -52,7 +52,6 @@ #define CELL_CMD_CLEAR_SURFACE 3 #define CELL_CMD_FINISH 4 #define CELL_CMD_RENDER 5 -#define CELL_CMD_RENDER_VBUF 6 /** @@ -76,18 +75,9 @@ struct cell_command_clear_surface } ALIGN16_ATTRIB; -struct cell_command_render -{ - uint prim_type; - uint num_verts, num_attribs; - float xmin, ymin, xmax, ymax; - void *vertex_data; -} ALIGN16_ATTRIB; - - #define CELL_MAX_VBUF_SIZE (16 * 1024) #define CELL_MAX_VBUF_INDEXES 1024 -struct cell_command_render_vbuf +struct cell_command_render { uint prim_type; uint num_verts, num_attribs; @@ -104,7 +94,6 @@ struct cell_command struct cell_command_framebuffer fb; struct cell_command_clear_surface clear; struct cell_command_render render; - struct cell_command_render_vbuf render_vbuf; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile index 9bf89702d5..44f14c0211 100644 --- a/src/mesa/pipe/cell/ppu/Makefile +++ b/src/mesa/pipe/cell/ppu/Makefile @@ -19,7 +19,6 @@ SOURCES = \ cell_context.c \ cell_draw_arrays.c \ cell_flush.c \ - cell_render.c \ cell_state_blend.c \ cell_state_clip.c \ cell_state_derived.c \ diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 52c97c939b..defce2869a 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -237,14 +237,8 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) cell->draw = draw_create(); -#define VBUF 1 -#if VBUF cell_init_vbuf(cell); draw_set_rasterize_stage(cell->draw, cell->vbuf); -#else - cell->render_stage = cell_draw_render_stage(cell); - draw_set_rasterize_stage(cell->draw, cell->render_stage); -#endif cell->prim_buffer.xmin = 1e100; cell->prim_buffer.ymin = 1e100; @@ -254,7 +248,7 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) /* * SPU stuff */ - cell->num_spus = 6; /* XXX >6 seems to fail */ + cell->num_spus = 6; cell_start_spus(cell->num_spus); diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 62d453cb7f..1d9a57ce44 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -119,7 +119,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, return; /* only render tris for now */ for (i = 0; i < cell->num_spus; i++) { - struct cell_command_render_vbuf *render = &cell_global.command[i].render_vbuf; + struct cell_command_render *render = &cell_global.command[i].render; render->prim_type = prim; render->num_verts = nr_vertices; render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ @@ -133,7 +133,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(render->index_data); - send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER_VBUF); + send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER); } cell_flush(&cell->pipe, 0x0); diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 548ef127ba..20f15029e1 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -207,94 +207,6 @@ tile_bounding_box(const struct cell_command_render *render, static void render(const struct cell_command_render *render) -{ - struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB; - uint i, j, vertex_bytes; - - /* - printf("SPU %u: RENDER buffer dst=%p src=%p size=%d\n", - init.id, - &prim_buffer, render->vertex_data, (int)sizeof(prim_buffer)); - */ - - ASSERT_ALIGN16(render->vertex_data); - ASSERT_ALIGN16(&prim_buffer); - - /* how much vertex data */ - vertex_bytes = render->num_verts * render->num_attribs * 4 * sizeof(float); - - /* get vertex data from main memory */ - mfc_get(&prim_buffer, /* dest */ - (unsigned int) render->vertex_data, /* src */ - vertex_bytes, /* size */ - TAG_VERTEX_BUFFER, - 0, /* tid */ - 0 /* rid */); - wait_on_mask(1 << TAG_VERTEX_BUFFER); - - /* find tiles which intersect the prim bounding box */ - uint txmin, tymin, box_width_tiles, box_num_tiles; - tile_bounding_box(render, &txmin, &tymin, - &box_num_tiles, &box_width_tiles); - - /* make sure any pending clears have completed */ - wait_on_mask(1 << TAG_SURFACE_CLEAR); - - /* loop over tiles */ - for (i = init.id; i < box_num_tiles; i += init.num_spus) { - const uint tx = txmin + i % box_width_tiles; - const uint ty = tymin + i / box_width_tiles; - - ASSERT(tx < fb.width_tiles); - ASSERT(ty < fb.height_tiles); - - /* Start fetching color/z tiles. We'll wait for completion when - * we need read/write to them later in triangle rasterization. - */ - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); - } - } - - if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); - } - - ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); - - /* loop over tris */ - for (j = 0; j < render->num_verts; j += 3) { - const float *v0 = (const float *) prim_buffer.vertex[j+0]; - const float *v1 = (const float *) prim_buffer.vertex[j+1]; - const float *v2 = (const float *) prim_buffer.vertex[j+2]; - - tri_draw(v0, v1, v2, tx, ty); - } - - /* write color/z tiles back to main framebuffer, if dirtied */ - if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); - tile_status[ty][tx] = TILE_STATUS_DEFINED; - } - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); - tile_status_z[ty][tx] = TILE_STATUS_DEFINED; - } - } - - /* XXX move these... */ - wait_on_mask(1 << TAG_WRITE_TILE_COLOR); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - wait_on_mask(1 << TAG_WRITE_TILE_Z); - } - } -} - - -static void -render_vbuf(const struct cell_command_render_vbuf *render) { /* we'll DMA into these buffers */ ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; @@ -483,18 +395,12 @@ main_loop(void) break; case CELL_CMD_RENDER: if (Debug) - printf("SPU %u: RENDER %u verts, prim %u\n", - init.id, cmd.render.num_verts, cmd.render.prim_type); - render(&cmd.render); - break; - case CELL_CMD_RENDER_VBUF: - if (Debug) - printf("SPU %u: RENDER_VBUF prim %u, indices: %u, nr_vert: %u\n", + printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", init.id, - cmd.render_vbuf.prim_type, - cmd.render_vbuf.num_verts, - cmd.render_vbuf.num_indexes); - render_vbuf(&cmd.render_vbuf); + cmd.render.prim_type, + cmd.render.num_verts, + cmd.render.num_indexes); + render(&cmd.render); break; case CELL_CMD_FINISH: -- cgit v1.2.3 From 45230b4e082473f7e1f0c0a18dd0e2fc9e5508e1 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 10:10:45 -0700 Subject: Fix malloc size buf, silence signed/unsigned comparision warning --- src/mesa/pipe/draw/draw_vbuf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 3f6606de86..62aa6de68f 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -275,7 +275,7 @@ vbuf_flush_indices( struct draw_stage *stage ) if(!vbuf->nr_indices) return; - assert(vbuf->vertex_ptr - vbuf->vertices == + assert((uint) (vbuf->vertex_ptr - vbuf->vertices) == vbuf->nr_vertices * vbuf->vertex_size / sizeof(unsigned)); switch(vbuf->prim) { @@ -405,7 +405,8 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw, assert(render->max_indices < UNDEFINED_VERTEX_ID); vbuf->max_indices = render->max_indices; - vbuf->indices = align_malloc( vbuf->max_indices, 16 ); + vbuf->indices + = align_malloc( vbuf->max_indices * sizeof(vbuf->indices[0]), 16 ); vbuf->vertices = NULL; vbuf->vertex_ptr = vbuf->vertices; -- cgit v1.2.3 From d4c806302e96a0fd97a4613bc29f4c9863ae89fe Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 11:27:09 -0700 Subject: s/int/uint/ to silence warning --- src/mesa/pipe/draw/draw_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index a9ff54404f..d134b05717 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -69,7 +69,7 @@ struct draw_context *draw_create( void ) /* Statically allocate maximum sized vertices for the cache - could be cleverer... */ { - int i; + uint i; char *tmp = MALLOC( Elements(draw->vcache.vertex) * MAX_VERTEX_SIZE ); for (i = 0; i < Elements(draw->vcache.vertex); i++) -- cgit v1.2.3 From f313a1ece297e2a3bea5b611082f8cc0012c64b8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 11:27:24 -0700 Subject: Cell: reformattting --- src/mesa/pipe/cell/ppu/cell_draw_arrays.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c index c014f5b29d..537cec8785 100644 --- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c +++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c @@ -121,18 +121,17 @@ cell_draw_elements(struct pipe_context *pipe, */ for (i = 0; i < PIPE_ATTRIB_MAX; i++) { if (sp->vertex_buffer[i].buffer) { - void *buf - = pipe->winsys->buffer_map(pipe->winsys, - sp->vertex_buffer[i].buffer, - PIPE_BUFFER_FLAG_READ); + void *buf = pipe->winsys->buffer_map(pipe->winsys, + sp->vertex_buffer[i].buffer, + PIPE_BUFFER_FLAG_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } /* Map index buffer, if present */ if (indexBuffer) { - void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_FLAG_READ); + void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, + indexBuffer, + PIPE_BUFFER_FLAG_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -161,7 +160,6 @@ cell_draw_elements(struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - /* Note: leave drawing surfaces mapped */ cell_unmap_constant_buffers(sp); -- cgit v1.2.3 From 21b282e9347d06272e5dfc795aa7c0b861c240e1 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 11:30:02 -0700 Subject: vbuf_flush_vertices() instead of vbuf_flush_indices() in vbuf_end() --- src/mesa/pipe/draw/draw_vbuf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 62aa6de68f..4f59b1b25d 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -360,8 +360,14 @@ vbuf_begin( struct draw_stage *stage ) static void vbuf_end( struct draw_stage *stage ) { +#if 0 /* XXX: Overkill */ vbuf_flush_indices( stage ); +#else + /* By flushing vertices we avoid having the vertex buffer grow and grow */ + struct vbuf_stage *vbuf = vbuf_stage(stage); + vbuf_flush_vertices( stage, vbuf->vertex_size ); +#endif stage->point = vbuf_first_point; stage->line = vbuf_first_line; -- cgit v1.2.3 From 6b5d674f915b67f3b51c331e3a6ba02e9f82473f Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 11:31:03 -0700 Subject: Cell: debug code, comments --- src/mesa/pipe/cell/ppu/cell_vbuf.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 1d9a57ce44..63c3b39ec7 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -98,6 +98,20 @@ cell_vbuf_draw(struct vbuf_render *vbr, float xmin, ymin, xmax, ymax; uint i; +#if 0 + printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u\n", + nr_indices, nr_vertices); + printf(" "); + for (i = 0; i < nr_indices; i += 3) { + printf("%u %u %u, ", indices[i+0], indices[i+1], indices[i+2]); + } + printf("\n"); +#elif 0 + printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u indexes = [%u %u %u ...]\n", + nr_indices, nr_vertices, + indices[0], indices[1], indices[2]); +#endif + /* compute x/y bounding box */ xmin = ymin = 1e50; xmax = ymax = -1e50; @@ -113,8 +127,6 @@ cell_vbuf_draw(struct vbuf_render *vbr, ymax = v[1]; } - /*printf("cell_vbuf_draw nr_indices = %u\n", nr_indices);*/ - if (prim != PIPE_PRIM_TRIANGLES) return; /* only render tris for now */ @@ -136,6 +148,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER); } + /* XXX this is temporary */ cell_flush(&cell->pipe, 0x0); } -- cgit v1.2.3 From 7db94ba03173f345a47fd727e8d866a87a484415 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 11:35:03 -0700 Subject: Cell: remove obsolete cell_prim_buffer struct and code --- src/mesa/pipe/cell/common.h | 14 ++------------ src/mesa/pipe/cell/ppu/cell_context.c | 5 ----- src/mesa/pipe/cell/ppu/cell_context.h | 2 -- 3 files changed, 2 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 60abe2d9bc..c00cee6a02 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -54,6 +54,7 @@ #define CELL_CMD_RENDER 5 + /** * Tell SPUs about the framebuffer size, location */ @@ -77,6 +78,7 @@ struct cell_command_clear_surface #define CELL_MAX_VBUF_SIZE (16 * 1024) #define CELL_MAX_VBUF_INDEXES 1024 +#define CELL_MAX_ATTRIBS 2 /* temporary! */ struct cell_command_render { uint prim_type; @@ -106,16 +108,4 @@ struct cell_init_info } ALIGN16_ATTRIB; -/** Temporary */ -#define CELL_MAX_VERTS 240 -#define CELL_MAX_ATTRIBS 2 -struct cell_prim_buffer -{ - float vertex[CELL_MAX_VERTS][CELL_MAX_ATTRIBS][4] ALIGN16_ATTRIB; - float xmin, ymin, xmax, ymax; - uint num_verts; -} ALIGN16_ATTRIB; - - - #endif /* CELL_COMMON_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index defce2869a..000217b259 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -240,11 +240,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) cell_init_vbuf(cell); draw_set_rasterize_stage(cell->draw, cell->vbuf); - cell->prim_buffer.xmin = 1e100; - cell->prim_buffer.ymin = 1e100; - cell->prim_buffer.xmax = -1e100; - cell->prim_buffer.ymax = -1e100; - /* * SPU stuff */ diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index 4ff39a53c6..d7754d5d61 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -96,8 +96,6 @@ struct cell_context uint num_spus; - - struct cell_prim_buffer prim_buffer; }; -- cgit v1.2.3 From 08c2571fb48d41731c81cc402acabf709523c831 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 12:04:55 -0700 Subject: Cell: initial work for a hw-like batch buffer system --- src/mesa/pipe/cell/common.h | 22 +++++++++ src/mesa/pipe/cell/ppu/Makefile | 1 + src/mesa/pipe/cell/ppu/cell_batch.c | 85 +++++++++++++++++++++++++++++++++++ src/mesa/pipe/cell/ppu/cell_batch.h | 40 +++++++++++++++++ src/mesa/pipe/cell/ppu/cell_context.c | 7 ++- src/mesa/pipe/cell/ppu/cell_context.h | 5 +++ src/mesa/pipe/cell/ppu/cell_spu.c | 13 +++--- src/mesa/pipe/cell/ppu/cell_spu.h | 10 ++--- src/mesa/pipe/cell/spu/main.c | 19 +++++++- 9 files changed, 190 insertions(+), 12 deletions(-) create mode 100644 src/mesa/pipe/cell/ppu/cell_batch.c create mode 100644 src/mesa/pipe/cell/ppu/cell_batch.h (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index c00cee6a02..450ca1d722 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -47,13 +47,23 @@ #define TILE_SIZE 32 +/** + * The low byte of a mailbox word contains the command opcode. + * Remaining higher bytes are command specific. + */ +#define CELL_CMD_OPCODE_MASK 0xf + #define CELL_CMD_EXIT 1 #define CELL_CMD_FRAMEBUFFER 2 #define CELL_CMD_CLEAR_SURFACE 3 #define CELL_CMD_FINISH 4 #define CELL_CMD_RENDER 5 +#define CELL_CMD_BATCH 6 +#define CELL_NUM_BATCH_BUFFERS 2 +#define CELL_BATCH_BUFFER_SIZE 1024 /**< 16KB would be the max */ + /** * Tell SPUs about the framebuffer size, location @@ -90,12 +100,23 @@ struct cell_command_render } ALIGN16_ATTRIB; +/** + * Execute a command/batch buffer. + */ +struct cell_command_batch +{ + ushort buffer; /**< which buffer [0, CELL_NUM_CMD_BUFFFERS-1] */ + ushort length; /**< in bytes */ +} ALIGN16_ATTRIB; + + /** XXX unions don't seem to work */ struct cell_command { struct cell_command_framebuffer fb; struct cell_command_clear_surface clear; struct cell_command_render render; + struct cell_command_batch batch; } ALIGN16_ATTRIB; @@ -105,6 +126,7 @@ struct cell_init_info unsigned id; unsigned num_spus; struct cell_command *cmd; + ubyte *batch_buffers[CELL_NUM_BATCH_BUFFERS]; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile index 44f14c0211..f7e3dd09f4 100644 --- a/src/mesa/pipe/cell/ppu/Makefile +++ b/src/mesa/pipe/cell/ppu/Makefile @@ -16,6 +16,7 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a SOURCES = \ + cell_batch.c \ cell_context.c \ cell_draw_arrays.c \ cell_flush.c \ diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c new file mode 100644 index 0000000000..a71573cbf7 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -0,0 +1,85 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "cell_context.h" +#include "cell_batch.h" +#include "cell_spu.h" + + +void +cell_batch_flush(struct cell_context *cell) +{ + const uint batch = cell->cur_batch; + const uint size = cell->batch_buffer_size[batch]; + uint i, cmd_word; + + if (size == 0) + return; + + assert(batch < CELL_NUM_BATCH_BUFFERS); + + printf("cell_batch_dispatch: buf %u, size %u\n", batch, size); + + cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16); + + for (i = 0; i < cell->num_spus; i++) { + send_mbox_message(cell_global.spe_contexts[i], cmd_word); + } + + /* XXX wait on DMA xfer of prev buffer to complete */ + + cell->cur_batch = (batch + 1) % CELL_NUM_BATCH_BUFFERS; + + cell->batch_buffer_size[cell->cur_batch] = 0; /* empty */ +} + + +/** + * \param cmd command to append + * \param length command size in bytes + */ +void +cell_batch_append(struct cell_context *cell, const void *cmd, uint length) +{ + uint size; + + assert(cell->cur_batch >= 0); + + size = cell->batch_buffer_size[cell->cur_batch]; + + if (size + length > CELL_BATCH_BUFFER_SIZE) { + cell_batch_flush(cell); + size = 0; + } + + assert(size + length <= CELL_BATCH_BUFFER_SIZE); + + memcpy(cell->batch_buffer[cell->cur_batch] + size, cmd, length); + + cell->batch_buffer_size[cell->cur_batch] = size + length; +} diff --git a/src/mesa/pipe/cell/ppu/cell_batch.h b/src/mesa/pipe/cell/ppu/cell_batch.h new file mode 100644 index 0000000000..02d7edf8b9 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_batch.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef CELL_BATCH_H +#define CELL_BATCH_H + + +extern void +cell_batch_flush(struct cell_context *cell); + +extern void +cell_batch_append(struct cell_context *cell, const void *cmd, uint length); + + +#endif /* CELL_BATCH_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 000217b259..6ba3b0d413 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -160,6 +160,7 @@ struct pipe_context * cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) { struct cell_context *cell; + uint i; /* some fields need to be 16-byte aligned, so align the whole object */ cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16); @@ -245,7 +246,11 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) */ cell->num_spus = 6; - cell_start_spus(cell->num_spus); + cell_start_spus(cell); + + for (i = 0; i < CELL_NUM_BATCH_BUFFERS; i++) { + cell->batch_buffer_size[i] = 0; + } #if 0 test_spus(cell); diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index d7754d5d61..94d8f08da8 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -96,6 +96,11 @@ struct cell_context uint num_spus; + + ubyte batch_buffer_size[CELL_NUM_BATCH_BUFFERS]; + ubyte batch_buffer[CELL_NUM_BATCH_BUFFERS][CELL_BATCH_BUFFER_SIZE] ALIGN16_ATTRIB; + int cur_batch; /**< which batch buffer is being filled */ + }; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 44ad3f22b3..88a620e669 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -95,11 +95,11 @@ static void *cell_thread_function(void *arg) * Create the SPU threads */ void -cell_start_spus(uint num_spus) +cell_start_spus(struct cell_context *cell) { - uint i; + uint i, j; - assert(num_spus <= MAX_SPUS); + assert(cell->num_spus <= MAX_SPUS); ASSERT_ALIGN16(&cell_global.command[0]); ASSERT_ALIGN16(&cell_global.command[1]); @@ -107,10 +107,13 @@ cell_start_spus(uint num_spus) ASSERT_ALIGN16(&cell_global.inits[0]); ASSERT_ALIGN16(&cell_global.inits[1]); - for (i = 0; i < num_spus; i++) { + for (i = 0; i < cell->num_spus; i++) { cell_global.inits[i].id = i; - cell_global.inits[i].num_spus = num_spus; + cell_global.inits[i].num_spus = cell->num_spus; cell_global.inits[i].cmd = &cell_global.command[i]; + for (j = 0; j < CELL_NUM_BATCH_BUFFERS; j++) { + cell_global.inits[i].batch_buffers[j] = cell->batch_buffer[j]; + } cell_global.spe_contexts[i] = spe_context_create(0, NULL); if (!cell_global.spe_contexts[i]) { diff --git a/src/mesa/pipe/cell/ppu/cell_spu.h b/src/mesa/pipe/cell/ppu/cell_spu.h index d11001af62..b4bfbced80 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.h +++ b/src/mesa/pipe/cell/ppu/cell_spu.h @@ -71,18 +71,18 @@ extern uint wait_mbox_message(spe_context_ptr_t ctx); -void -cell_start_spus(uint num_spus); +extern void +cell_start_spus(struct cell_context *cell); -void +extern void finish_all(uint num_spus); -void +extern void test_spus(struct cell_context *cell); -void +extern void cell_spu_exit(struct cell_context *cell); diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 20f15029e1..04bb087cf9 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -322,6 +322,13 @@ render(const struct cell_command_render *render) +static void +batch(const struct cell_command_batch *batch) +{ +} + + + /** * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. */ @@ -359,7 +366,7 @@ main_loop(void) 0 /* rid */); wait_on_mask( 1 << tag ); - switch (opcode) { + switch (opcode & CELL_CMD_OPCODE_MASK) { case CELL_CMD_EXIT: if (Debug) printf("SPU %u: EXIT\n", init.id); @@ -403,6 +410,16 @@ main_loop(void) render(&cmd.render); break; + case CELL_CMD_BATCH: + /* execute a batch buffer */ + if (Debug) + printf("SPU %u: BATCH buffer %u, len %u\n", + init.id, + cmd.batch.buffer, + cmd.batch.length); + batch(&cmd.batch); + break; + case CELL_CMD_FINISH: if (Debug) printf("SPU %u: FINISH\n", init.id); -- cgit v1.2.3 From 8dd678208e4dcd90e07dc271d11d73d87465e0fd Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 16:08:53 -0700 Subject: Cell: basic batch buffer working --- src/mesa/pipe/cell/common.h | 14 +-- src/mesa/pipe/cell/ppu/cell_batch.c | 27 ++++- src/mesa/pipe/cell/ppu/cell_batch.h | 6 + src/mesa/pipe/cell/ppu/cell_flush.c | 19 ++- src/mesa/pipe/cell/ppu/cell_state_surface.c | 20 +++- src/mesa/pipe/cell/ppu/cell_surface.c | 12 ++ src/mesa/pipe/cell/ppu/cell_vbuf.c | 27 ++++- src/mesa/pipe/cell/spu/main.c | 175 +++++++++++++++++++--------- src/mesa/pipe/cell/spu/main.h | 4 +- 9 files changed, 231 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 450ca1d722..3d6f1c4ba0 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -70,6 +70,7 @@ */ struct cell_command_framebuffer { + uint opcode; int width, height; void *color_start, *depth_start; enum pipe_format color_format, depth_format; @@ -81,6 +82,7 @@ struct cell_command_framebuffer */ struct cell_command_clear_surface { + uint opcode; uint surface; /**< Temporary: 0=color, 1=Z */ uint value; } ALIGN16_ATTRIB; @@ -91,6 +93,7 @@ struct cell_command_clear_surface #define CELL_MAX_ATTRIBS 2 /* temporary! */ struct cell_command_render { + uint opcode; uint prim_type; uint num_verts, num_attribs; uint num_indexes; @@ -100,23 +103,12 @@ struct cell_command_render } ALIGN16_ATTRIB; -/** - * Execute a command/batch buffer. - */ -struct cell_command_batch -{ - ushort buffer; /**< which buffer [0, CELL_NUM_CMD_BUFFFERS-1] */ - ushort length; /**< in bytes */ -} ALIGN16_ATTRIB; - - /** XXX unions don't seem to work */ struct cell_command { struct cell_command_framebuffer fb; struct cell_command_clear_surface clear; struct cell_command_render render; - struct cell_command_batch batch; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index a71573cbf7..7eb1b50ddb 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -43,7 +43,7 @@ cell_batch_flush(struct cell_context *cell) assert(batch < CELL_NUM_BATCH_BUFFERS); - printf("cell_batch_dispatch: buf %u, size %u\n", batch, size); + /*printf("cell_batch_dispatch: buf %u, size %u\n", batch, size);*/ cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16); @@ -83,3 +83,28 @@ cell_batch_append(struct cell_context *cell, const void *cmd, uint length) cell->batch_buffer_size[cell->cur_batch] = size + length; } + + +void * +cell_batch_alloc(struct cell_context *cell, uint bytes) +{ + void *pos; + uint size; + + assert(cell->cur_batch >= 0); + + size = cell->batch_buffer_size[cell->cur_batch]; + + if (size + bytes > CELL_BATCH_BUFFER_SIZE) { + cell_batch_flush(cell); + size = 0; + } + + assert(size + bytes <= CELL_BATCH_BUFFER_SIZE); + + pos = (void *) (cell->batch_buffer[cell->cur_batch] + size); + + cell->batch_buffer_size[cell->cur_batch] = size + bytes; + + return pos; +} diff --git a/src/mesa/pipe/cell/ppu/cell_batch.h b/src/mesa/pipe/cell/ppu/cell_batch.h index 02d7edf8b9..7a5c6392d7 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.h +++ b/src/mesa/pipe/cell/ppu/cell_batch.h @@ -30,11 +30,17 @@ #define CELL_BATCH_H +struct cell_context; + + extern void cell_batch_flush(struct cell_context *cell); extern void cell_batch_append(struct cell_context *cell, const void *cmd, uint length); +extern void * +cell_batch_alloc(struct cell_context *cell, uint bytes); + #endif /* CELL_BATCH_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_flush.c b/src/mesa/pipe/cell/ppu/cell_flush.c index 977c50da32..33cbe2a085 100644 --- a/src/mesa/pipe/cell/ppu/cell_flush.c +++ b/src/mesa/pipe/cell/ppu/cell_flush.c @@ -38,16 +38,25 @@ cell_flush(struct pipe_context *pipe, unsigned flags) struct cell_context *cell = cell_context(pipe); uint i; - cell_flush_prim_buffer(cell); + if (flags & PIPE_FLUSH_WAIT) { + uint *cmd = (uint *) cell_batch_alloc(cell, sizeof(uint)); + *cmd = CELL_CMD_FINISH; + } + + cell_batch_flush(cell); +#if 0 /* Send CMD_FINISH to all SPUs */ for (i = 0; i < cell->num_spus; i++) { send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FINISH); } +#endif - /* Wait for ack */ - for (i = 0; i < cell->num_spus; i++) { - uint k = wait_mbox_message(cell_global.spe_contexts[i]); - assert(k == CELL_CMD_FINISH); + if (flags & PIPE_FLUSH_WAIT) { + /* Wait for ack */ + for (i = 0; i < cell->num_spus; i++) { + uint k = wait_mbox_message(cell_global.spe_contexts[i]); + assert(k == CELL_CMD_FINISH); + } } } diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c index cd8e5def31..ff8fdbd334 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -27,6 +27,7 @@ #include "pipe/p_inlines.h" +#include "cell_batch.h" #include "cell_context.h" #include "cell_state.h" #include "cell_spu.h" @@ -68,8 +69,10 @@ cell_set_framebuffer_state(struct pipe_context *pipe, if (zsurf && !zsurf->map) pipe_surface_map(zsurf); +#if 0 for (i = 0; i < cell->num_spus; i++) { struct cell_command_framebuffer *fb = &cell_global.command[i].fb; + fb->opcode = CELL_CMD_FRAMEBUFFER; fb->color_start = csurf->map; fb->color_format = csurf->format; fb->depth_start = zsurf ? zsurf->map : NULL; @@ -78,7 +81,22 @@ cell_set_framebuffer_state(struct pipe_context *pipe, fb->height = csurf->height; send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER); } - +#endif +#if 1 + { + struct cell_command_framebuffer *fb + = cell_batch_alloc(cell, sizeof(*fb)); + fb->opcode = CELL_CMD_FRAMEBUFFER; + fb->color_start = csurf->map; + fb->color_format = csurf->format; + fb->depth_start = zsurf ? zsurf->map : NULL; + fb->depth_format = zsurf ? zsurf->format : PIPE_FORMAT_NONE; + fb->width = csurf->width; + fb->height = csurf->height; + /*cell_batch_flush(cell);*/ + /*cell_flush(&cell->pipe, 0x0);*/ + } +#endif cell->dirty |= CELL_NEW_FRAMEBUFFER; } diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 03dd41583f..ea1c2bd644 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -37,6 +37,7 @@ #include "pipe/p_util.h" #include "pipe/cell/common.h" #include "cell_context.h" +#include "cell_batch.h" #include "cell_surface.h" #include "cell_spu.h" @@ -59,6 +60,7 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, surfIndex = 0; } +#if 0 for (i = 0; i < cell->num_spus; i++) { #if 1 uint clr = clearValue; @@ -80,6 +82,16 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, cell_global.command[i].clear.surface = surfIndex; send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_SURFACE); } +#else + { + struct cell_command_clear_surface *clr + = (struct cell_command_clear_surface *) + cell_batch_alloc(cell, sizeof(*clr)); + clr->opcode = CELL_CMD_CLEAR_SURFACE; + clr->surface = surfIndex; + clr->value = clearValue; + } +#endif /* XXX temporary */ cell_flush(&cell->pipe, 0x0); diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 63c3b39ec7..d27d718dae 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -130,8 +130,10 @@ cell_vbuf_draw(struct vbuf_render *vbr, if (prim != PIPE_PRIM_TRIANGLES) return; /* only render tris for now */ +#if 0 for (i = 0; i < cell->num_spus; i++) { struct cell_command_render *render = &cell_global.command[i].render; + render->opcode = CELL_CMD_RENDER; render->prim_type = prim; render->num_verts = nr_vertices; render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ @@ -147,9 +149,32 @@ cell_vbuf_draw(struct vbuf_render *vbr, ASSERT_ALIGN16(render->index_data); send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER); } +#else + { + struct cell_command_render *render + = (struct cell_command_render *) + cell_batch_alloc(cell, sizeof(*render)); + render->opcode = CELL_CMD_RENDER; + render->prim_type = prim; + render->num_verts = nr_vertices; + render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ + render->vertex_data = vertices; + render->index_data = indices; + render->num_indexes = nr_indices; + render->xmin = xmin; + render->ymin = ymin; + render->xmax = xmax; + render->ymax = ymax; + + ASSERT_ALIGN16(render->vertex_data); + ASSERT_ALIGN16(render->index_data); + } +#endif +#if 01 /* XXX this is temporary */ - cell_flush(&cell->pipe, 0x0); + cell_flush(&cell->pipe, PIPE_FLUSH_WAIT); +#endif } diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index 04bb087cf9..0b1e3d46da 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -115,11 +115,15 @@ really_clear_tiles(uint surfaceIndex) static void -clear_surface(const struct cell_command_clear_surface *clear) +cmd_clear_surface(const struct cell_command_clear_surface *clear) { const uint num_tiles = fb.width_tiles * fb.height_tiles; uint i, j; + if (Debug) + printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, + clear->surface, clear->value); + #define CLEAR_OPT 1 #if CLEAR_OPT /* set all tile's status to CLEAR */ @@ -206,7 +210,7 @@ tile_bounding_box(const struct cell_command_render *render, static void -render(const struct cell_command_render *render) +cmd_render(const struct cell_command_render *render) { /* we'll DMA into these buffers */ ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; @@ -214,6 +218,14 @@ render(const struct cell_command_render *render) uint i, j, vertex_size, vertex_bytes, index_bytes; + if (Debug) + printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", + init.id, + render->prim_type, + render->num_verts, + render->num_indexes); + + ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(render->index_data); @@ -321,13 +333,115 @@ render(const struct cell_command_render *render) } +static void +cmd_framebuffer(const struct cell_command_framebuffer *cmd) +{ + if (Debug) + printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", + init.id, + cmd->width, + cmd->height, + cmd->color_start, + cmd->color_format, + cmd->depth_format); + + fb.color_start = cmd->color_start; + fb.depth_start = cmd->depth_start; + fb.color_format = cmd->color_format; + fb.depth_format = cmd->depth_format; + fb.width = cmd->width; + fb.height = cmd->height; + fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; + fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; +} + static void -batch(const struct cell_command_batch *batch) +cmd_finish(void) { + if (Debug) + printf("SPU %u: FINISH\n", init.id); + really_clear_tiles(0); + /* wait for all outstanding DMAs to finish */ + mfc_write_tag_mask(~0); + mfc_read_tag_status_all(); + /* send mbox message to PPU */ + spu_write_out_mbox(CELL_CMD_FINISH); } +/** + * Execute a batch of commands + * The opcode param encodes the location of the buffer and its size. + */ +static void +cmd_batch(uint opcode) +{ + const uint buf = (opcode >> 8) & 0xff; + uint size = (opcode >> 16); + uint buffer[CELL_BATCH_BUFFER_SIZE / 4] ALIGN16_ATTRIB; + const uint usize = size / sizeof(uint); + uint pos; + + if (Debug) + printf("SPU %u: BATCH buffer %u, len %u, from %p\n", + init.id, buf, size, init.batch_buffers[buf]); + + ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH); + + ASSERT_ALIGN16(init.batch_buffers[buf]); + + size = (size + 0xf) & ~0xf; + + mfc_get(buffer, /* dest */ + (unsigned int) init.batch_buffers[buf], /* src */ + size, + TAG_BATCH_BUFFER, + 0, /* tid */ + 0 /* rid */); + wait_on_mask(1 << TAG_BATCH_BUFFER); + + for (pos = 0; pos < usize; /* no incr */) { + switch (buffer[pos]) { + case CELL_CMD_FRAMEBUFFER: + { + struct cell_command_framebuffer *fb + = (struct cell_command_framebuffer *) &buffer[pos]; + cmd_framebuffer(fb); + pos += sizeof(*fb) / 4; + } + break; + case CELL_CMD_CLEAR_SURFACE: + { + struct cell_command_clear_surface *clr + = (struct cell_command_clear_surface *) &buffer[pos]; + cmd_clear_surface(clr); + pos += sizeof(*clr) / 4; + } + break; + case CELL_CMD_RENDER: + { + struct cell_command_render *render + = (struct cell_command_render *) &buffer[pos]; + cmd_render(render); + pos += sizeof(*render) / 4; + } + break; + case CELL_CMD_FINISH: + cmd_finish(); + pos += 1; + break; + default: + printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]); + ASSERT(0); + break; + } + } + + if (Debug) + printf("SPU %u: BATCH complete\n", init.id); +} + /** * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. @@ -355,7 +469,7 @@ main_loop(void) opcode = (unsigned int) spu_read_in_mbox(); if (Debug) - printf("SPU %u: got cmd %u\n", init.id, opcode); + printf("SPU %u: got cmd 0x%x\n", init.id, opcode); /* command payload */ mfc_get(&cmd, /* dest */ @@ -373,62 +487,19 @@ main_loop(void) exitFlag = 1; break; case CELL_CMD_FRAMEBUFFER: - if (Debug) - printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", - init.id, - cmd.fb.width, - cmd.fb.height, - cmd.fb.color_start, - cmd.fb.color_format, - cmd.fb.depth_format); - fb.color_start = cmd.fb.color_start; - fb.depth_start = cmd.fb.depth_start; - fb.color_format = cmd.fb.color_format; - fb.depth_format = cmd.fb.depth_format; - fb.width = cmd.fb.width; - fb.height = cmd.fb.height; - fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; - fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; - /* - printf("SPU %u: %u x %u tiles\n", - init.id, fb.width_tiles, fb.height_tiles); - */ + cmd_framebuffer(&cmd.fb); break; case CELL_CMD_CLEAR_SURFACE: - if (Debug) - printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, - cmd.clear.surface, cmd.clear.value); - clear_surface(&cmd.clear); + cmd_clear_surface(&cmd.clear); break; case CELL_CMD_RENDER: - if (Debug) - printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", - init.id, - cmd.render.prim_type, - cmd.render.num_verts, - cmd.render.num_indexes); - render(&cmd.render); + cmd_render(&cmd.render); break; - case CELL_CMD_BATCH: - /* execute a batch buffer */ - if (Debug) - printf("SPU %u: BATCH buffer %u, len %u\n", - init.id, - cmd.batch.buffer, - cmd.batch.length); - batch(&cmd.batch); + cmd_batch(opcode); break; - case CELL_CMD_FINISH: - if (Debug) - printf("SPU %u: FINISH\n", init.id); - really_clear_tiles(0); - /* wait for all outstanding DMAs to finish */ - mfc_write_tag_mask(~0); - mfc_read_tag_status_all(); - /* send mbox message to PPU */ - spu_write_out_mbox(CELL_CMD_FINISH); + cmd_finish(); break; default: printf("Bad opcode!\n"); diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 9351aa340b..cc70fdd7a6 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -55,12 +55,12 @@ extern struct framebuffer fb; #define TAG_SURFACE_CLEAR 10 #define TAG_VERTEX_BUFFER 11 -#define TAG_INDEX_BUFFER 16 #define TAG_READ_TILE_COLOR 12 #define TAG_READ_TILE_Z 13 #define TAG_WRITE_TILE_COLOR 14 #define TAG_WRITE_TILE_Z 15 - +#define TAG_INDEX_BUFFER 16 +#define TAG_BATCH_BUFFER 17 /** The standard assert macro doesn't seem to work on SPUs */ #define ASSERT(x) \ -- cgit v1.2.3 From 50eb29ed9492a34db4ba53f1f28a2868b808955a Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 16:31:58 -0700 Subject: whitespace, comment changes --- src/mesa/pipe/p_state.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 76e633e930..f9c5bfb6c6 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -56,18 +56,13 @@ #define PIPE_MAX_SHADER_OUTPUTS 16 -/* fwd decl */ +/* fwd decls */ struct pipe_surface; +struct pipe_winsys; /* opaque type */ struct pipe_buffer_handle; -struct pipe_winsys; - - -/*** - *** State objects - ***/ /** @@ -115,6 +110,7 @@ struct pipe_viewport_state { float translate[4]; }; + struct pipe_scissor_state { unsigned minx:16; unsigned miny:16; @@ -122,6 +118,7 @@ struct pipe_scissor_state { unsigned maxy:16; }; + struct pipe_clip_state { float ucp[PIPE_MAX_CLIP_PLANES][4]; unsigned nr; @@ -148,13 +145,14 @@ struct pipe_shader_state { ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; }; + struct pipe_depth_stencil_alpha_state { struct { - unsigned enabled:1; /**< depth test enabled? */ - unsigned writemask:1; /**< allow depth buffer writes? */ - unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ - unsigned occlusion_count:1; /**< XXX move this elsewhere? */ + unsigned enabled:1; /**< depth test enabled? */ + unsigned writemask:1; /**< allow depth buffer writes? */ + unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ + unsigned occlusion_count:1; /**< do occlusion counting? */ } depth; struct { unsigned enabled:1; @@ -165,12 +163,11 @@ struct pipe_depth_stencil_alpha_state ubyte ref_value; ubyte value_mask; ubyte write_mask; - } stencil[2]; /**< [0] = front, [1] = back */ - + } stencil[2]; /**< [0] = front, [1] = back */ struct { unsigned enabled:1; - unsigned func:3; /**< PIPE_FUNC_x */ - float ref; /**< reference value */ + unsigned func:3; /**< PIPE_FUNC_x */ + float ref; /**< reference value */ } alpha; }; @@ -193,10 +190,12 @@ struct pipe_blend_state { unsigned dither:1; }; + struct pipe_blend_color { float color[4]; }; + struct pipe_framebuffer_state { /** multiple colorbuffers for multiple render targets */ @@ -314,5 +313,4 @@ struct pipe_vertex_element }; - #endif -- cgit v1.2.3 From 1c22b5955953973c2c7988bef998f336493e11bc Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 11 Jan 2008 16:32:20 -0700 Subject: s/int/uint/ to silence warnings --- src/mesa/pipe/i965simple/brw_tex_layout.c | 2 +- src/mesa/pipe/i965simple/brw_winsys.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c index 7d6e2851b1..2b2bf16f1b 100644 --- a/src/mesa/pipe/i965simple/brw_tex_layout.c +++ b/src/mesa/pipe/i965simple/brw_tex_layout.c @@ -237,7 +237,7 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6; int x = 0; int y = 0; - int q, j; + uint q, j; intel_miptree_set_level_info(tex, level, nr_images, 0, tex->total_height, diff --git a/src/mesa/pipe/i965simple/brw_winsys.h b/src/mesa/pipe/i965simple/brw_winsys.h index 49a12a1c27..253599896c 100644 --- a/src/mesa/pipe/i965simple/brw_winsys.h +++ b/src/mesa/pipe/i965simple/brw_winsys.h @@ -190,7 +190,7 @@ static inline boolean brw_batchbuffer_data(struct brw_winsys *winsys, unsigned bytes) { static const unsigned incr = sizeof(unsigned); - int i; + uint i; const unsigned *udata = (const unsigned*)(data); unsigned size = bytes/incr; for (i = 0; i < size; ++i) { -- cgit v1.2.3 From 07276d676c757d3be2e3090d6c67fbbb2f9768eb Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 10:06:27 -0700 Subject: Cell: sketch out needed rasterizer state --- src/mesa/pipe/cell/ppu/cell_state_rasterizer.c | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c index 11e7de7309..6b1675af26 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c +++ b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c @@ -32,6 +32,48 @@ #include "cell_state.h" + +struct spu_rasterizer_state +{ + unsigned flatshade:1; +#if 0 + unsigned light_twoside:1; + unsigned front_winding:2; /**< PIPE_WINDING_x */ + unsigned cull_mode:2; /**< PIPE_WINDING_x */ + unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */ + unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ + unsigned offset_cw:1; + unsigned offset_ccw:1; +#endif + unsigned scissor:1; + unsigned poly_smooth:1; + unsigned poly_stipple_enable:1; + unsigned point_smooth:1; +#if 0 + unsigned point_sprite:1; + unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ +#endif + unsigned multisample:1; /* XXX maybe more ms state in future */ + unsigned line_smooth:1; + unsigned line_stipple_enable:1; + unsigned line_stipple_factor:8; /**< [1..256] actually */ + unsigned line_stipple_pattern:16; +#if 0 + unsigned bypass_clipping:1; +#endif + unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */ + + float line_width; + float point_size; /**< used when no per-vertex size */ +#if 0 + float offset_units; + float offset_scale; + ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */ +#endif +}; + + + void * cell_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *setup) -- cgit v1.2.3 From a9a84674726a58c183fe8983321208a32cdf940e Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 10:33:24 -0700 Subject: Cell: prefix SPU sources with spu_ --- src/mesa/pipe/cell/spu/Makefile | 19 +- src/mesa/pipe/cell/spu/spu_main.c | 553 +++++++++++++++++++++++ src/mesa/pipe/cell/spu/spu_main.h | 78 ++++ src/mesa/pipe/cell/spu/spu_tile.c | 115 +++++ src/mesa/pipe/cell/spu/spu_tile.h | 69 +++ src/mesa/pipe/cell/spu/spu_tri.c | 892 ++++++++++++++++++++++++++++++++++++++ src/mesa/pipe/cell/spu/spu_tri.h | 37 ++ 7 files changed, 1751 insertions(+), 12 deletions(-) create mode 100644 src/mesa/pipe/cell/spu/spu_main.c create mode 100644 src/mesa/pipe/cell/spu/spu_main.h create mode 100644 src/mesa/pipe/cell/spu/spu_tile.c create mode 100644 src/mesa/pipe/cell/spu/spu_tile.h create mode 100644 src/mesa/pipe/cell/spu/spu_tri.c create mode 100644 src/mesa/pipe/cell/spu/spu_tri.h (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/Makefile b/src/mesa/pipe/cell/spu/Makefile index bf97a49e78..b92a756cd5 100644 --- a/src/mesa/pipe/cell/spu/Makefile +++ b/src/mesa/pipe/cell/spu/Makefile @@ -16,15 +16,19 @@ PROG_SPU_EMBED_O = $(PROG)_spu-embed.o SOURCES = \ - main.c \ - tile.c \ - tri.c + spu_main.c \ + spu_tile.c \ + spu_tri.c SPU_OBJECTS = $(SOURCES:.c=.o) \ INCLUDE_DIRS = -I$(TOP)/src/mesa +.c.o: + $(SPU_CC) $(SPU_CFLAGS) -c $< + + # The .a file will be linked into the main/PPU executable default: $(PROG_SPU_A) @@ -38,15 +42,6 @@ $(PROG_SPU): $(SPU_OBJECTS) $(SPU_CC) -o $(PROG_SPU) $(SPU_OBJECTS) $(SPU_LFLAGS) -main.o: main.c - $(SPU_CC) $(SPU_CFLAGS) -c main.c - -tile.o: tile.c - $(SPU_CC) $(SPU_CFLAGS) -c tile.c - -tri.o: tri.c - $(SPU_CC) $(SPU_CFLAGS) -c tri.c - clean: rm -f *~ *.o *.a *.d $(PROG_SPU) diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c new file mode 100644 index 0000000000..df708e65d1 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -0,0 +1,553 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +/* main() for Cell SPU code */ + + +#include +#include +#include + +#include "spu_main.h" +#include "spu_tri.h" +#include "spu_tile.h" +#include "pipe/cell/common.h" +#include "pipe/p_defines.h" + +/* +helpful headers: +/usr/lib/gcc/spu/4.1.1/include/spu_mfcio.h +/opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h +*/ + +static boolean Debug = FALSE; + +volatile struct cell_init_info init; + +struct framebuffer fb; + + + +void +wait_on_mask(unsigned tagMask) +{ + mfc_write_tag_mask( tagMask ); + /* wait for completion of _any_ DMAs specified by tagMask */ + mfc_read_tag_status_any(); +} + + +static void +wait_on_mask_all(unsigned tagMask) +{ + mfc_write_tag_mask( tagMask ); + /* wait for completion of _any_ DMAs specified by tagMask */ + mfc_read_tag_status_all(); +} + + + +/** + * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled + * tiles back to the main framebuffer. + */ +static void +really_clear_tiles(uint surfaceIndex) +{ + const uint num_tiles = fb.width_tiles * fb.height_tiles; + uint i, j; + + if (surfaceIndex == 0) { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ctile[i][j] = fb.color_clear_value; + + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + if (tile_status[ty][tx] == TILE_STATUS_CLEAR) { + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + } + } + } + else { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ztile[i][j] = fb.depth_clear_value; + + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR) + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); + } + } + +#if 0 + wait_on_mask(1 << TAG_SURFACE_CLEAR); +#endif +} + + +static void +cmd_clear_surface(const struct cell_command_clear_surface *clear) +{ + const uint num_tiles = fb.width_tiles * fb.height_tiles; + uint i, j; + + if (Debug) + printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, + clear->surface, clear->value); + +#define CLEAR_OPT 1 +#if CLEAR_OPT + /* set all tile's status to CLEAR */ + if (clear->surface == 0) { + memset(tile_status, TILE_STATUS_CLEAR, sizeof(tile_status)); + fb.color_clear_value = clear->value; + } + else { + memset(tile_status_z, TILE_STATUS_CLEAR, sizeof(tile_status_z)); + fb.depth_clear_value = clear->value; + } + return; +#endif + + if (clear->surface == 0) { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ctile[i][j] = clear->value; + } + else { + for (i = 0; i < TILE_SIZE; i++) + for (j = 0; j < TILE_SIZE; j++) + ztile[i][j] = clear->value; + } + + /* + printf("SPU: %s num=%d w=%d h=%d\n", + __FUNCTION__, num_tiles, fb.width_tiles, fb.height_tiles); + */ + + for (i = init.id; i < num_tiles; i += init.num_spus) { + uint tx = i % fb.width_tiles; + uint ty = i / fb.width_tiles; + if (clear->surface == 0) + put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + else + put_tile(&fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); + /* XXX we don't want this here, but it fixes bad tile results */ + } + +#if 0 + wait_on_mask(1 << TAG_SURFACE_CLEAR); +#endif +} + + +/** + * Given a rendering command's bounding box (in pixels) compute the + * location of the corresponding screen tile bounding box. + */ +static INLINE void +tile_bounding_box(const struct cell_command_render *render, + uint *txmin, uint *tymin, + uint *box_num_tiles, uint *box_width_tiles) +{ +#if 1 + /* Debug: full-window bounding box */ + uint txmax = fb.width_tiles - 1; + uint tymax = fb.height_tiles - 1; + *txmin = 0; + *tymin = 0; + *box_num_tiles = fb.width_tiles * fb.height_tiles; + *box_width_tiles = fb.width_tiles; + (void) render; + (void) txmax; + (void) tymax; +#else + uint txmax, tymax, box_height_tiles; + + *txmin = (uint) render->xmin / TILE_SIZE; + *tymin = (uint) render->ymin / TILE_SIZE; + txmax = (uint) render->xmax / TILE_SIZE; + tymax = (uint) render->ymax / TILE_SIZE; + *box_width_tiles = txmax - *txmin + 1; + box_height_tiles = tymax - *tymin + 1; + *box_num_tiles = *box_width_tiles * box_height_tiles; +#endif +#if 0 + printf("Render bounds: %g, %g ... %g, %g\n", + render->xmin, render->ymin, render->xmax, render->ymax); + printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax); +#endif +} + + +static void +cmd_render(const struct cell_command_render *render) +{ + /* we'll DMA into these buffers */ + ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; + ushort indexes[CELL_MAX_VBUF_INDEXES] ALIGN16_ATTRIB; + + uint i, j, vertex_size, vertex_bytes, index_bytes; + + if (Debug) + printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", + init.id, + render->prim_type, + render->num_verts, + render->num_indexes); + + + ASSERT_ALIGN16(render->vertex_data); + ASSERT_ALIGN16(render->index_data); + + vertex_size = render->num_attribs * 4 * sizeof(float); + + /* how much vertex data */ + vertex_bytes = render->num_verts * vertex_size; + index_bytes = render->num_indexes * sizeof(ushort); + if (index_bytes < 8) + index_bytes = 8; + else + index_bytes = (index_bytes + 15) & ~0xf; /* multiple of 16 */ + + /* + printf("VBUF: indices at %p, vertices at %p vertex_bytes %u ind_bytes %u\n", + render->index_data, render->vertex_data, vertex_bytes, index_bytes); + */ + + /* get vertex data from main memory */ + mfc_get(vertex_data, /* dest */ + (unsigned int) render->vertex_data, /* src */ + vertex_bytes, /* size */ + TAG_VERTEX_BUFFER, + 0, /* tid */ + 0 /* rid */); + + /* get index data from main memory */ + mfc_get(indexes, /* dest */ + (unsigned int) render->index_data, /* src */ + index_bytes, + TAG_INDEX_BUFFER, + 0, /* tid */ + 0 /* rid */); + + wait_on_mask_all((1 << TAG_VERTEX_BUFFER) | + (1 << TAG_INDEX_BUFFER)); + + /* find tiles which intersect the prim bounding box */ + uint txmin, tymin, box_width_tiles, box_num_tiles; +#if 0 + tile_bounding_box(render, &txmin, &tymin, + &box_num_tiles, &box_width_tiles); +#else + txmin = 0; + tymin = 0; + box_num_tiles = fb.width_tiles * fb.height_tiles; + box_width_tiles = fb.width_tiles; +#endif + + /* make sure any pending clears have completed */ + wait_on_mask(1 << TAG_SURFACE_CLEAR); + + /* loop over tiles */ + for (i = init.id; i < box_num_tiles; i += init.num_spus) { + const uint tx = txmin + i % box_width_tiles; + const uint ty = tymin + i / box_width_tiles; + + ASSERT(tx < fb.width_tiles); + ASSERT(ty < fb.height_tiles); + + /* Start fetching color/z tiles. We'll wait for completion when + * we need read/write to them later in triangle rasterization. + */ + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + } + } + + if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { + get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); + } + + ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); + + /* loop over tris */ + for (j = 0; j < render->num_indexes; j += 3) { + const float *v0, *v1, *v2; + + v0 = (const float *) (vertex_data + indexes[j+0] * vertex_size); + v1 = (const float *) (vertex_data + indexes[j+1] * vertex_size); + v2 = (const float *) (vertex_data + indexes[j+2] * vertex_size); + + tri_draw(v0, v1, v2, tx, ty); + } + + /* write color/z tiles back to main framebuffer, if dirtied */ + if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + tile_status[ty][tx] = TILE_STATUS_DEFINED; + } + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { + put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + tile_status_z[ty][tx] = TILE_STATUS_DEFINED; + } + } + + /* XXX move these... */ + wait_on_mask(1 << TAG_WRITE_TILE_COLOR); + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + wait_on_mask(1 << TAG_WRITE_TILE_Z); + } + } +} + + +static void +cmd_framebuffer(const struct cell_command_framebuffer *cmd) +{ + if (Debug) + printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", + init.id, + cmd->width, + cmd->height, + cmd->color_start, + cmd->color_format, + cmd->depth_format); + + fb.color_start = cmd->color_start; + fb.depth_start = cmd->depth_start; + fb.color_format = cmd->color_format; + fb.depth_format = cmd->depth_format; + fb.width = cmd->width; + fb.height = cmd->height; + fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; + fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; +} + + +static void +cmd_finish(void) +{ + if (Debug) + printf("SPU %u: FINISH\n", init.id); + really_clear_tiles(0); + /* wait for all outstanding DMAs to finish */ + mfc_write_tag_mask(~0); + mfc_read_tag_status_all(); + /* send mbox message to PPU */ + spu_write_out_mbox(CELL_CMD_FINISH); +} + + +/** + * Execute a batch of commands + * The opcode param encodes the location of the buffer and its size. + */ +static void +cmd_batch(uint opcode) +{ + const uint buf = (opcode >> 8) & 0xff; + uint size = (opcode >> 16); + uint buffer[CELL_BATCH_BUFFER_SIZE / 4] ALIGN16_ATTRIB; + const uint usize = size / sizeof(uint); + uint pos; + + if (Debug) + printf("SPU %u: BATCH buffer %u, len %u, from %p\n", + init.id, buf, size, init.batch_buffers[buf]); + + ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH); + + ASSERT_ALIGN16(init.batch_buffers[buf]); + + size = (size + 0xf) & ~0xf; + + mfc_get(buffer, /* dest */ + (unsigned int) init.batch_buffers[buf], /* src */ + size, + TAG_BATCH_BUFFER, + 0, /* tid */ + 0 /* rid */); + wait_on_mask(1 << TAG_BATCH_BUFFER); + + for (pos = 0; pos < usize; /* no incr */) { + switch (buffer[pos]) { + case CELL_CMD_FRAMEBUFFER: + { + struct cell_command_framebuffer *fb + = (struct cell_command_framebuffer *) &buffer[pos]; + cmd_framebuffer(fb); + pos += sizeof(*fb) / 4; + } + break; + case CELL_CMD_CLEAR_SURFACE: + { + struct cell_command_clear_surface *clr + = (struct cell_command_clear_surface *) &buffer[pos]; + cmd_clear_surface(clr); + pos += sizeof(*clr) / 4; + } + break; + case CELL_CMD_RENDER: + { + struct cell_command_render *render + = (struct cell_command_render *) &buffer[pos]; + cmd_render(render); + pos += sizeof(*render) / 4; + } + break; + case CELL_CMD_FINISH: + cmd_finish(); + pos += 1; + break; + default: + printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]); + ASSERT(0); + break; + } + } + + if (Debug) + printf("SPU %u: BATCH complete\n", init.id); +} + + +/** + * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. + */ +static void +main_loop(void) +{ + struct cell_command cmd; + int exitFlag = 0; + + if (Debug) + printf("SPU %u: Enter main loop\n", init.id); + + ASSERT((sizeof(struct cell_command) & 0xf) == 0); + ASSERT_ALIGN16(&cmd); + + while (!exitFlag) { + unsigned opcode; + int tag = 0; + + if (Debug) + printf("SPU %u: Wait for cmd...\n", init.id); + + /* read/wait from mailbox */ + opcode = (unsigned int) spu_read_in_mbox(); + + if (Debug) + printf("SPU %u: got cmd 0x%x\n", init.id, opcode); + + /* command payload */ + mfc_get(&cmd, /* dest */ + (unsigned int) init.cmd, /* src */ + sizeof(struct cell_command), /* bytes */ + tag, + 0, /* tid */ + 0 /* rid */); + wait_on_mask( 1 << tag ); + + switch (opcode & CELL_CMD_OPCODE_MASK) { + case CELL_CMD_EXIT: + if (Debug) + printf("SPU %u: EXIT\n", init.id); + exitFlag = 1; + break; + case CELL_CMD_FRAMEBUFFER: + cmd_framebuffer(&cmd.fb); + break; + case CELL_CMD_CLEAR_SURFACE: + cmd_clear_surface(&cmd.clear); + break; + case CELL_CMD_RENDER: + cmd_render(&cmd.render); + break; + case CELL_CMD_BATCH: + cmd_batch(opcode); + break; + case CELL_CMD_FINISH: + cmd_finish(); + break; + default: + printf("Bad opcode!\n"); + } + + } + + if (Debug) + printf("SPU %u: Exit main loop\n", init.id); +} + + + +static void +one_time_init(void) +{ + memset(tile_status, TILE_STATUS_DEFINED, sizeof(tile_status)); + memset(tile_status_z, TILE_STATUS_DEFINED, sizeof(tile_status_z)); +} + + +/** + * SPE entrypoint. + * Note: example programs declare params as 'unsigned long long' but + * that doesn't work. + */ +int +main(unsigned long speid, unsigned long argp) +{ + int tag = 0; + + (void) speid; + + one_time_init(); + + if (Debug) + printf("SPU: main() speid=%lu\n", speid); + + mfc_get(&init, /* dest */ + (unsigned int) argp, /* src */ + sizeof(struct cell_init_info), /* bytes */ + tag, + 0, /* tid */ + 0 /* rid */); + wait_on_mask( 1 << tag ); + + + main_loop(); + + return 0; +} diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h new file mode 100644 index 0000000000..9ef8cf0709 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -0,0 +1,78 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef SPU_MAIN_H +#define SPU_MAIN_H + + +#include "pipe/cell/common.h" + + +extern volatile struct cell_init_info init; + +struct framebuffer { + void *color_start; /**< addr of color surface in main memory */ + void *depth_start; /**< addr of depth surface in main memory */ + enum pipe_format color_format; + enum pipe_format depth_format; + uint width, height; /**< size in pixels */ + uint width_tiles, height_tiles; /**< width and height in tiles */ + + uint color_clear_value; + uint depth_clear_value; +}; + +/* XXX Collect these globals in a struct: */ + +extern struct framebuffer fb; + + +/* DMA TAGS */ + +#define TAG_SURFACE_CLEAR 10 +#define TAG_VERTEX_BUFFER 11 +#define TAG_READ_TILE_COLOR 12 +#define TAG_READ_TILE_Z 13 +#define TAG_WRITE_TILE_COLOR 14 +#define TAG_WRITE_TILE_Z 15 +#define TAG_INDEX_BUFFER 16 +#define TAG_BATCH_BUFFER 17 + +/** The standard assert macro doesn't seem to work on SPUs */ +#define ASSERT(x) \ + if (!(x)) { \ + fprintf(stderr, "SPU %d: %s:%d: %s(): assertion %s failed.\n", \ + init.id, __FILE__, __LINE__, __FUNCTION__, #x); \ + exit(1); \ + } + + +void +wait_on_mask(unsigned tag); + + +#endif /* SPU_MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/spu_tile.c b/src/mesa/pipe/cell/spu/spu_tile.c new file mode 100644 index 0000000000..8fd9ab2905 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_tile.c @@ -0,0 +1,115 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + + +#include "spu_tile.h" + + + +uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; + +ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + + + +void +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag, int zBuf) +{ + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); + const ubyte *src = zBuf ? fb->depth_start : fb->color_start; + + src += offset * bytesPerTile; + + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); + ASSERT_ALIGN16(tile); + /* + printf("get_tile: dest: %p src: 0x%x size: %d\n", + tile, (unsigned int) src, bytesPerTile); + */ + mfc_get(tile, /* dest in local memory */ + (unsigned int) src, /* src in main memory */ + bytesPerTile, + tag, + 0, /* tid */ + 0 /* rid */); +} + + +void +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag, int zBuf) +{ + const uint offset = ty * fb->width_tiles + tx; + const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); + ubyte *dst = zBuf ? fb->depth_start : fb->color_start; + + dst += offset * bytesPerTile; + + ASSERT(tx < fb->width_tiles); + ASSERT(ty < fb->height_tiles); + ASSERT_ALIGN16(tile); + /* + printf("put_tile: src: %p dst: 0x%x size: %d\n", + tile, (unsigned int) dst, bytesPerTile); + */ + mfc_put((void *) tile, /* src in local memory */ + (unsigned int) dst, /* dst in main memory */ + bytesPerTile, + tag, + 0, /* tid */ + 0 /* rid */); +} + + +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value) +{ + uint i, j; + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile[i][j] = value; + } + } +} + diff --git a/src/mesa/pipe/cell/spu/spu_tile.h b/src/mesa/pipe/cell/spu/spu_tile.h new file mode 100644 index 0000000000..2ad469b584 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_tile.h @@ -0,0 +1,69 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef SPU_TILE_H +#define SPU_TILE_H + + +#include +#include +#include "spu_main.h" +#include "pipe/cell/common.h" + + +#define MAX_WIDTH 1024 +#define MAX_HEIGHT 1024 + + +extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; +extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; + + +#define TILE_STATUS_CLEAR 1 +#define TILE_STATUS_DEFINED 2 /**< defined pixel data */ +#define TILE_STATUS_DIRTY 3 /**< modified, but not put back yet */ + +extern ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; +extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + + +void +get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, + int tag, int zBuf); + +void +put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, + int tag, int zBuf); + +void +clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); + +void +clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); + + +#endif /* SPU_TILE_H */ diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c new file mode 100644 index 0000000000..af24e42435 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_tri.c @@ -0,0 +1,892 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Triangle rendering within a tile. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "pipe/p_util.h" +#include "spu_main.h" +#include "spu_tile.h" +#include "spu_tri.h" + + + +/** + * Simplified types taken from other parts of Gallium + */ + +struct vertex_header { + float data[2][4]; /* pos and color */ +}; + +struct prim_header { + struct vertex_header *v[3]; +}; + + + + +#if 1 + +/* XXX fix this */ +#undef CEILF +#define CEILF(X) ((float) (int) ((X) + 0.99999)) + + +#define QUAD_TOP_LEFT 0 +#define QUAD_TOP_RIGHT 1 +#define QUAD_BOTTOM_LEFT 2 +#define QUAD_BOTTOM_RIGHT 3 +#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT) +#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT) +#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT) +#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT) +#define MASK_ALL 0xf + +#define PIPE_MAX_SHADER_INPUTS 8 /* XXX temp */ + +#endif + + +#define DEBUG_VERTS 0 + +/** + * Triangle edge info + */ +struct edge { + float dx; /**< X(v1) - X(v0), used only during setup */ + float dy; /**< Y(v1) - Y(v0), used only during setup */ + float dxdy; /**< dx/dy */ + float sx, sy; /**< first sample point coord */ + int lines; /**< number of lines on this edge */ +}; + + +struct interp_coef +{ + float a0[4]; + float dadx[4]; + float dady[4]; +}; + +/** + * Triangle setup info (derived from draw_stage). + * Also used for line drawing (taking some liberties). + */ +struct setup_stage { + + /* Vertices are just an array of floats making up each attribute in + * turn. Currently fixed at 4 floats, but should change in time. + * Codegen will help cope with this. + */ + const struct vertex_header *vmax; + const struct vertex_header *vmid; + const struct vertex_header *vmin; + const struct vertex_header *vprovoke; + + struct edge ebot; + struct edge etop; + struct edge emaj; + + float oneoverarea; + + uint tx, ty; + + int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; + +#if 0 + struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS]; +#else + struct interp_coef coef[PIPE_MAX_SHADER_INPUTS]; +#endif + +#if 0 + struct quad_header quad; +#endif + + struct { + int left[2]; /**< [0] = row0, [1] = row1 */ + int right[2]; + int y; + unsigned y_flags; + unsigned mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */ + } span; +}; + + +#if 0 +/** + * Basically a cast wrapper. + */ +static INLINE struct setup_stage *setup_stage( struct draw_stage *stage ) +{ + return (struct setup_stage *)stage; +} +#endif + +#if 0 +/** + * Clip setup->quad against the scissor/surface bounds. + */ +static INLINE void +quad_clip(struct setup_stage *setup) +{ + const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect; + const int minx = (int) cliprect->minx; + const int maxx = (int) cliprect->maxx; + const int miny = (int) cliprect->miny; + const int maxy = (int) cliprect->maxy; + + if (setup->quad.x0 >= maxx || + setup->quad.y0 >= maxy || + setup->quad.x0 + 1 < minx || + setup->quad.y0 + 1 < miny) { + /* totally clipped */ + setup->quad.mask = 0x0; + return; + } + if (setup->quad.x0 < minx) + setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); + if (setup->quad.y0 < miny) + setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); + if (setup->quad.x0 == maxx - 1) + setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); + if (setup->quad.y0 == maxy - 1) + setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); +} +#endif + +#if 0 +/** + * Emit a quad (pass to next stage) with clipping. + */ +static INLINE void +clip_emit_quad(struct setup_stage *setup) +{ + quad_clip(setup); + if (setup->quad.mask) { + struct softpipe_context *sp = setup->softpipe; + sp->quad.first->run(sp->quad.first, &setup->quad); + } +} +#endif + +/** + * Evaluate attribute coefficients (plane equations) to compute + * attribute values for the four fragments in a quad. + * Eg: four colors will be compute. + */ +static INLINE void +eval_coeff( struct setup_stage *setup, uint slot, + float x, float y, float result[4][4]) +{ + uint i; + const float *dadx = setup->coef[slot].dadx; + const float *dady = setup->coef[slot].dady; + + /* loop over XYZW comps */ + for (i = 0; i < 4; i++) { + result[QUAD_TOP_LEFT][i] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i]; + result[QUAD_TOP_RIGHT][i] = result[0][i] + dadx[i]; + result[QUAD_BOTTOM_LEFT][i] = result[0][i] + dady[i]; + result[QUAD_BOTTOM_RIGHT][i] = result[0][i] + dadx[i] + dady[i]; + } +} + + +static INLINE void +eval_z( struct setup_stage *setup, + float x, float y, float result[4]) +{ + uint slot = 0; + uint i = 2; + const float *dadx = setup->coef[slot].dadx; + const float *dady = setup->coef[slot].dady; + + result[QUAD_TOP_LEFT] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i]; + result[QUAD_TOP_RIGHT] = result[0] + dadx[i]; + result[QUAD_BOTTOM_LEFT] = result[0] + dady[i]; + result[QUAD_BOTTOM_RIGHT] = result[0] + dadx[i] + dady[i]; +} + + +static INLINE uint +pack_color(const float color[4]) +{ + uint r = (uint) (color[0] * 255.0); + uint g = (uint) (color[1] * 255.0); + uint b = (uint) (color[2] * 255.0); + uint a = (uint) (color[3] * 255.0); + switch (fb.color_format) { + case PIPE_FORMAT_A8R8G8B8_UNORM: + return (a << 24) | (r << 16) | (g << 8) | b; + case PIPE_FORMAT_B8G8R8A8_UNORM: + return (b << 24) | (g << 16) | (r << 8) | a; + default: + ASSERT(0); + return 0; + } +} + + +/** + * Emit a quad (pass to next stage). No clipping is done. + */ +static INLINE void +emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) +{ +#if 0 + struct softpipe_context *sp = setup->softpipe; + setup->quad.x0 = x; + setup->quad.y0 = y; + setup->quad.mask = mask; + sp->quad.first->run(sp->quad.first, &setup->quad); +#else + /* Cell: "write" quad fragments to the tile by setting prim color */ + int ix = x - setup->cliprect_minx; + int iy = y - setup->cliprect_miny; + float colors[4][4]; + uint z; + + eval_coeff(setup, 1, (float) x, (float) y, colors); + + if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + float zvals[4]; + eval_z(setup, (float) x, (float) y, zvals); + + if (tile_status_z[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { + /* now, _really_ clear the tile */ + clear_tile_z(ztile, fb.depth_clear_value); + } + else { + /* make sure we've got the tile from main mem */ + wait_on_mask(1 << TAG_READ_TILE_Z); + } + tile_status_z[setup->ty][setup->tx] = TILE_STATUS_DIRTY; + + if (mask & MASK_TOP_LEFT) { + z = (uint) (zvals[0] * 65535.0); + if (z < ztile[iy][ix]) + ztile[iy][ix] = z; + else + mask &= ~MASK_TOP_LEFT; + } + + if (mask & MASK_TOP_RIGHT) { + z = (uint) (zvals[1] * 65535.0); + if (z < ztile[iy][ix+1]) + ztile[iy][ix+1] = z; + else + mask &= ~MASK_TOP_RIGHT; + } + + if (mask & MASK_BOTTOM_LEFT) { + z = (uint) (zvals[2] * 65535.0); + if (z < ztile[iy+1][ix]) + ztile[iy+1][ix] = z; + else + mask &= ~MASK_BOTTOM_LEFT; + } + + if (mask & MASK_BOTTOM_RIGHT) { + z = (uint) (zvals[3] * 65535.0); + if (z < ztile[iy+1][ix+1]) + ztile[iy+1][ix+1] = z; + else + mask &= ~MASK_BOTTOM_RIGHT; + } + } + + if (mask) { + if (tile_status[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { + /* now, _really_ clear the tile */ + clear_tile(ctile, fb.color_clear_value); + } + else { + /* make sure we've got the tile from main mem */ + wait_on_mask(1 << TAG_READ_TILE_COLOR); + } + tile_status[setup->ty][setup->tx] = TILE_STATUS_DIRTY; + + if (mask & MASK_TOP_LEFT) + ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); + if (mask & MASK_TOP_RIGHT) + ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); + if (mask & MASK_BOTTOM_LEFT) + ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); + if (mask & MASK_BOTTOM_RIGHT) + ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); + } +#endif +} + + +/** + * Given an X or Y coordinate, return the block/quad coordinate that it + * belongs to. + */ +static INLINE int block( int x ) +{ + return x & ~1; +} + + +/** + * Compute mask which indicates which pixels in the 2x2 quad are actually inside + * the triangle's bounds. + * + * this is pretty nasty... may need to rework flush_spans again to + * fix it, if possible. + */ +static unsigned calculate_mask( struct setup_stage *setup, int x ) +{ + unsigned mask = 0x0; + + if (x >= setup->span.left[0] && x < setup->span.right[0]) + mask |= MASK_TOP_LEFT; + + if (x >= setup->span.left[1] && x < setup->span.right[1]) + mask |= MASK_BOTTOM_LEFT; + + if (x+1 >= setup->span.left[0] && x+1 < setup->span.right[0]) + mask |= MASK_TOP_RIGHT; + + if (x+1 >= setup->span.left[1] && x+1 < setup->span.right[1]) + mask |= MASK_BOTTOM_RIGHT; + + return mask; +} + + +/** + * Render a horizontal span of quads + */ +static void flush_spans( struct setup_stage *setup ) +{ + int minleft, maxright; + int x; + + switch (setup->span.y_flags) { + case 0x3: + /* both odd and even lines written (both quad rows) */ + minleft = MIN2(setup->span.left[0], setup->span.left[1]); + maxright = MAX2(setup->span.right[0], setup->span.right[1]); + break; + + case 0x1: + /* only even line written (quad top row) */ + minleft = setup->span.left[0]; + maxright = setup->span.right[0]; + break; + + case 0x2: + /* only odd line written (quad bottom row) */ + minleft = setup->span.left[1]; + maxright = setup->span.right[1]; + break; + + default: + return; + } + + /* XXX this loop could be moved into the above switch cases and + * calculate_mask() could be simplified a bit... + */ + for (x = block(minleft); x <= block(maxright); x += 2) { + emit_quad( setup, x, setup->span.y, + calculate_mask( setup, x ) ); + } + + setup->span.y = 0; + setup->span.y_flags = 0; + setup->span.right[0] = 0; + setup->span.right[1] = 0; +} + +#if DEBUG_VERTS +static void print_vertex(const struct setup_stage *setup, + const struct vertex_header *v) +{ + int i; + fprintf(stderr, "Vertex: (%p)\n", v); + for (i = 0; i < setup->quad.nr_attrs; i++) { + fprintf(stderr, " %d: %f %f %f %f\n", i, + v->data[i][0], v->data[i][1], v->data[i][2], v->data[i][3]); + } +} +#endif + +static boolean setup_sort_vertices( struct setup_stage *setup, + const struct prim_header *prim ) +{ + const struct vertex_header *v0 = prim->v[0]; + const struct vertex_header *v1 = prim->v[1]; + const struct vertex_header *v2 = prim->v[2]; + +#if DEBUG_VERTS + fprintf(stderr, "Triangle:\n"); + print_vertex(setup, v0); + print_vertex(setup, v1); + print_vertex(setup, v2); +#endif + + setup->vprovoke = v2; + + /* determine bottom to top order of vertices */ + { + float y0 = v0->data[0][1]; + float y1 = v1->data[0][1]; + float y2 = v2->data[0][1]; + if (y0 <= y1) { + if (y1 <= y2) { + /* y0<=y1<=y2 */ + setup->vmin = v0; + setup->vmid = v1; + setup->vmax = v2; + } + else if (y2 <= y0) { + /* y2<=y0<=y1 */ + setup->vmin = v2; + setup->vmid = v0; + setup->vmax = v1; + } + else { + /* y0<=y2<=y1 */ + setup->vmin = v0; + setup->vmid = v2; + setup->vmax = v1; + } + } + else { + if (y0 <= y2) { + /* y1<=y0<=y2 */ + setup->vmin = v1; + setup->vmid = v0; + setup->vmax = v2; + } + else if (y2 <= y1) { + /* y2<=y1<=y0 */ + setup->vmin = v2; + setup->vmid = v1; + setup->vmax = v0; + } + else { + /* y1<=y2<=y0 */ + setup->vmin = v1; + setup->vmid = v2; + setup->vmax = v0; + } + } + } + + /* Check if triangle is completely outside the tile bounds */ + if (setup->vmin->data[0][1] > setup->cliprect_maxy) + return FALSE; + if (setup->vmax->data[0][1] < setup->cliprect_miny) + return FALSE; + if (setup->vmin->data[0][0] < setup->cliprect_minx && + setup->vmid->data[0][0] < setup->cliprect_minx && + setup->vmax->data[0][0] < setup->cliprect_minx) + return FALSE; + if (setup->vmin->data[0][0] > setup->cliprect_maxx && + setup->vmid->data[0][0] > setup->cliprect_maxx && + setup->vmax->data[0][0] > setup->cliprect_maxx) + return FALSE; + + setup->ebot.dx = setup->vmid->data[0][0] - setup->vmin->data[0][0]; + setup->ebot.dy = setup->vmid->data[0][1] - setup->vmin->data[0][1]; + setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0]; + setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[0][1]; + setup->etop.dx = setup->vmax->data[0][0] - setup->vmid->data[0][0]; + setup->etop.dy = setup->vmax->data[0][1] - setup->vmid->data[0][1]; + + /* + * Compute triangle's area. Use 1/area to compute partial + * derivatives of attributes later. + * + * The area will be the same as prim->det, but the sign may be + * different depending on how the vertices get sorted above. + * + * To determine whether the primitive is front or back facing we + * use the prim->det value because its sign is correct. + */ + { + const float area = (setup->emaj.dx * setup->ebot.dy - + setup->ebot.dx * setup->emaj.dy); + + setup->oneoverarea = 1.0f / area; + /* + _mesa_printf("%s one-over-area %f area %f det %f\n", + __FUNCTION__, setup->oneoverarea, area, prim->det ); + */ + } + +#if 0 + /* We need to know if this is a front or back-facing triangle for: + * - the GLSL gl_FrontFacing fragment attribute (bool) + * - two-sided stencil test + */ + setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW); +#endif + + return TRUE; +} + + +#if 0 +/** + * Compute a0 for a constant-valued coefficient (GL_FLAT shading). + * The value value comes from vertex->data[slot][i]. + * The result will be put into setup->coef[slot].a0[i]. + * \param slot which attribute slot + * \param i which component of the slot (0..3) + */ +static void const_coeff( struct setup_stage *setup, + unsigned slot, + unsigned i ) +{ + assert(slot < PIPE_MAX_SHADER_INPUTS); + assert(i <= 3); + + setup->coef[slot].dadx[i] = 0; + setup->coef[slot].dady[i] = 0; + + /* need provoking vertex info! + */ + setup->coef[slot].a0[i] = setup->vprovoke->data[slot][i]; +} +#endif + + +/** + * Compute a0, dadx and dady for a linearly interpolated coefficient, + * for a triangle. + */ +static void tri_linear_coeff( struct setup_stage *setup, + uint slot, uint firstComp, uint lastComp ) +{ + uint i; + for (i = firstComp; i < lastComp; i++) { + float botda = setup->vmid->data[slot][i] - setup->vmin->data[slot][i]; + float majda = setup->vmax->data[slot][i] - setup->vmin->data[slot][i]; + float a = setup->ebot.dy * majda - botda * setup->emaj.dy; + float b = setup->emaj.dx * botda - majda * setup->ebot.dx; + + ASSERT(slot < PIPE_MAX_SHADER_INPUTS); + + setup->coef[slot].dadx[i] = a * setup->oneoverarea; + setup->coef[slot].dady[i] = b * setup->oneoverarea; + + /* calculate a0 as the value which would be sampled for the + * fragment at (0,0), taking into account that we want to sample at + * pixel centers, in other words (0.5, 0.5). + * + * this is neat but unfortunately not a good way to do things for + * triangles with very large values of dadx or dady as it will + * result in the subtraction and re-addition from a0 of a very + * large number, which means we'll end up loosing a lot of the + * fractional bits and precision from a0. the way to fix this is + * to define a0 as the sample at a pixel center somewhere near vmin + * instead - i'll switch to this later. + */ + setup->coef[slot].a0[i] = (setup->vmin->data[slot][i] - + (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5f) + + setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5f))); + } + + /* + _mesa_printf("attr[%d].%c: %f dx:%f dy:%f\n", + slot, "xyzw"[i], + setup->coef[slot].a0[i], + setup->coef[slot].dadx[i], + setup->coef[slot].dady[i]); + */ +} + + +#if 0 +/** + * Compute a0, dadx and dady for a perspective-corrected interpolant, + * for a triangle. + * We basically multiply the vertex value by 1/w before computing + * the plane coefficients (a0, dadx, dady). + * Later, when we compute the value at a particular fragment position we'll + * divide the interpolated value by the interpolated W at that fragment. + */ +static void tri_persp_coeff( struct setup_stage *setup, + unsigned slot, + unsigned i ) +{ + /* premultiply by 1/w: + */ + float mina = setup->vmin->data[slot][i] * setup->vmin->data[0][3]; + float mida = setup->vmid->data[slot][i] * setup->vmid->data[0][3]; + float maxa = setup->vmax->data[slot][i] * setup->vmax->data[0][3]; + + float botda = mida - mina; + float majda = maxa - mina; + float a = setup->ebot.dy * majda - botda * setup->emaj.dy; + float b = setup->emaj.dx * botda - majda * setup->ebot.dx; + + /* + printf("tri persp %d,%d: %f %f %f\n", slot, i, + setup->vmin->data[slot][i], + setup->vmid->data[slot][i], + setup->vmax->data[slot][i] + ); + */ + + assert(slot < PIPE_MAX_SHADER_INPUTS); + assert(i <= 3); + + setup->coef[slot].dadx[i] = a * setup->oneoverarea; + setup->coef[slot].dady[i] = b * setup->oneoverarea; + setup->coef[slot].a0[i] = (mina - + (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5f) + + setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5f))); +} +#endif + + +/** + * Compute the setup->coef[] array dadx, dady, a0 values. + * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized. + */ +static void setup_tri_coefficients( struct setup_stage *setup ) +{ +#if 0 + const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; + unsigned slot, j; + + /* z and w are done by linear interpolation: + */ + tri_linear_coeff(setup, 0, 2); + tri_linear_coeff(setup, 0, 3); + + /* setup interpolation for all the remaining attributes: + */ + for (slot = 1; slot < setup->quad.nr_attrs; slot++) { + switch (interp[slot]) { + case INTERP_CONSTANT: + for (j = 0; j < NUM_CHANNELS; j++) + const_coeff(setup, slot, j); + break; + + case INTERP_LINEAR: + for (j = 0; j < NUM_CHANNELS; j++) + tri_linear_coeff(setup, slot, j); + break; + + case INTERP_PERSPECTIVE: + for (j = 0; j < NUM_CHANNELS; j++) + tri_persp_coeff(setup, slot, j); + break; + + default: + /* invalid interp mode */ + assert(0); + } + } +#else + tri_linear_coeff(setup, 0, 2, 3); /* slot 0, z */ + tri_linear_coeff(setup, 1, 0, 4); /* slot 1, color */ +#endif +} + + +static void setup_tri_edges( struct setup_stage *setup ) +{ + float vmin_x = setup->vmin->data[0][0] + 0.5f; + float vmid_x = setup->vmid->data[0][0] + 0.5f; + + float vmin_y = setup->vmin->data[0][1] - 0.5f; + float vmid_y = setup->vmid->data[0][1] - 0.5f; + float vmax_y = setup->vmax->data[0][1] - 0.5f; + + setup->emaj.sy = CEILF(vmin_y); + setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy); + setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy; + setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy; + + setup->etop.sy = CEILF(vmid_y); + setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy); + setup->etop.dxdy = setup->etop.dx / setup->etop.dy; + setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy; + + setup->ebot.sy = CEILF(vmin_y); + setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy); + setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy; + setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy; +} + + +/** + * Render the upper or lower half of a triangle. + * Scissoring/cliprect is applied here too. + */ +static void subtriangle( struct setup_stage *setup, + struct edge *eleft, + struct edge *eright, + unsigned lines ) +{ + const int minx = setup->cliprect_minx; + const int maxx = setup->cliprect_maxx; + const int miny = setup->cliprect_miny; + const int maxy = setup->cliprect_maxy; + int y, start_y, finish_y; + int sy = (int)eleft->sy; + + ASSERT((int)eleft->sy == (int) eright->sy); + + /* clip top/bottom */ + start_y = sy; + finish_y = sy + lines; + + if (start_y < miny) + start_y = miny; + + if (finish_y > maxy) + finish_y = maxy; + + start_y -= sy; + finish_y -= sy; + + /* + _mesa_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y); + */ + + for (y = start_y; y < finish_y; y++) { + + /* avoid accumulating adds as floats don't have the precision to + * accurately iterate large triangle edges that way. luckily we + * can just multiply these days. + * + * this is all drowned out by the attribute interpolation anyway. + */ + int left = (int)(eleft->sx + y * eleft->dxdy); + int right = (int)(eright->sx + y * eright->dxdy); + + /* clip left/right */ + if (left < minx) + left = minx; + if (right > maxx) + right = maxx; + + if (left < right) { + int _y = sy + y; + if (block(_y) != setup->span.y) { + flush_spans(setup); + setup->span.y = block(_y); + } + + setup->span.left[_y&1] = left; + setup->span.right[_y&1] = right; + setup->span.y_flags |= 1<<(_y&1); + } + } + + + /* save the values so that emaj can be restarted: + */ + eleft->sx += lines * eleft->dxdy; + eright->sx += lines * eright->dxdy; + eleft->sy += lines; + eright->sy += lines; +} + + +/** + * Do setup for triangle rasterization, then render the triangle. + */ +static void +setup_tri(struct setup_stage *setup, struct prim_header *prim) +{ + if (!setup_sort_vertices( setup, prim )) { + return; /* totally clipped */ + } + + setup_tri_coefficients( setup ); + setup_tri_edges( setup ); + +#if 0 + setup->quad.prim = PRIM_TRI; +#endif + + setup->span.y = 0; + setup->span.y_flags = 0; + setup->span.right[0] = 0; + setup->span.right[1] = 0; + /* setup->span.z_mode = tri_z_mode( setup->ctx ); */ + + /* init_constant_attribs( setup ); */ + + if (setup->oneoverarea < 0.0) { + /* emaj on left: + */ + subtriangle( setup, &setup->emaj, &setup->ebot, setup->ebot.lines ); + subtriangle( setup, &setup->emaj, &setup->etop, setup->etop.lines ); + } + else { + /* emaj on right: + */ + subtriangle( setup, &setup->ebot, &setup->emaj, setup->ebot.lines ); + subtriangle( setup, &setup->etop, &setup->emaj, setup->etop.lines ); + } + + flush_spans( setup ); +} + + + +/** + * Draw triangle into tile at (tx, ty) (tile coords) + * The tile data should have already been fetched. + */ +void +tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty) +{ + struct prim_header tri; + struct setup_stage setup; + + tri.v[0] = (struct vertex_header *) v0; + tri.v[1] = (struct vertex_header *) v1; + tri.v[2] = (struct vertex_header *) v2; + + setup.tx = tx; + setup.ty = ty; + + /* set clipping bounds to tile bounds */ + setup.cliprect_minx = tx * TILE_SIZE; + setup.cliprect_miny = ty * TILE_SIZE; + setup.cliprect_maxx = (tx + 1) * TILE_SIZE; + setup.cliprect_maxy = (ty + 1) * TILE_SIZE; + + setup_tri(&setup, &tri); +} diff --git a/src/mesa/pipe/cell/spu/spu_tri.h b/src/mesa/pipe/cell/spu/spu_tri.h new file mode 100644 index 0000000000..86c42b6339 --- /dev/null +++ b/src/mesa/pipe/cell/spu/spu_tri.h @@ -0,0 +1,37 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef SPU_TRI_H +#define SPU_TRI_H + + +extern void +tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty); + + +#endif /* SPU_TRI_H */ -- cgit v1.2.3 From 2e469775b3f52adf496802f286e46ac4a31cdba1 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 10:33:50 -0700 Subject: Cell: prefix SPU files with spu_ --- src/mesa/pipe/cell/spu/main.c | 553 -------------------------- src/mesa/pipe/cell/spu/main.h | 78 ---- src/mesa/pipe/cell/spu/tile.c | 115 ------ src/mesa/pipe/cell/spu/tile.h | 69 ---- src/mesa/pipe/cell/spu/tri.c | 892 ------------------------------------------ src/mesa/pipe/cell/spu/tri.h | 37 -- 6 files changed, 1744 deletions(-) delete mode 100644 src/mesa/pipe/cell/spu/main.c delete mode 100644 src/mesa/pipe/cell/spu/main.h delete mode 100644 src/mesa/pipe/cell/spu/tile.c delete mode 100644 src/mesa/pipe/cell/spu/tile.h delete mode 100644 src/mesa/pipe/cell/spu/tri.c delete mode 100644 src/mesa/pipe/cell/spu/tri.h (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c deleted file mode 100644 index 0b1e3d46da..0000000000 --- a/src/mesa/pipe/cell/spu/main.c +++ /dev/null @@ -1,553 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -/* main() for Cell SPU code */ - - -#include -#include -#include - -#include "main.h" -#include "tri.h" -#include "tile.h" -#include "pipe/cell/common.h" -#include "pipe/p_defines.h" - -/* -helpful headers: -/usr/lib/gcc/spu/4.1.1/include/spu_mfcio.h -/opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h -*/ - -static boolean Debug = FALSE; - -volatile struct cell_init_info init; - -struct framebuffer fb; - - - -void -wait_on_mask(unsigned tagMask) -{ - mfc_write_tag_mask( tagMask ); - /* wait for completion of _any_ DMAs specified by tagMask */ - mfc_read_tag_status_any(); -} - - -static void -wait_on_mask_all(unsigned tagMask) -{ - mfc_write_tag_mask( tagMask ); - /* wait for completion of _any_ DMAs specified by tagMask */ - mfc_read_tag_status_all(); -} - - - -/** - * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled - * tiles back to the main framebuffer. - */ -static void -really_clear_tiles(uint surfaceIndex) -{ - const uint num_tiles = fb.width_tiles * fb.height_tiles; - uint i, j; - - if (surfaceIndex == 0) { - for (i = 0; i < TILE_SIZE; i++) - for (j = 0; j < TILE_SIZE; j++) - ctile[i][j] = fb.color_clear_value; - - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; - if (tile_status[ty][tx] == TILE_STATUS_CLEAR) { - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); - } - } - } - else { - for (i = 0; i < TILE_SIZE; i++) - for (j = 0; j < TILE_SIZE; j++) - ztile[i][j] = fb.depth_clear_value; - - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; - if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR) - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); - } - } - -#if 0 - wait_on_mask(1 << TAG_SURFACE_CLEAR); -#endif -} - - -static void -cmd_clear_surface(const struct cell_command_clear_surface *clear) -{ - const uint num_tiles = fb.width_tiles * fb.height_tiles; - uint i, j; - - if (Debug) - printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, - clear->surface, clear->value); - -#define CLEAR_OPT 1 -#if CLEAR_OPT - /* set all tile's status to CLEAR */ - if (clear->surface == 0) { - memset(tile_status, TILE_STATUS_CLEAR, sizeof(tile_status)); - fb.color_clear_value = clear->value; - } - else { - memset(tile_status_z, TILE_STATUS_CLEAR, sizeof(tile_status_z)); - fb.depth_clear_value = clear->value; - } - return; -#endif - - if (clear->surface == 0) { - for (i = 0; i < TILE_SIZE; i++) - for (j = 0; j < TILE_SIZE; j++) - ctile[i][j] = clear->value; - } - else { - for (i = 0; i < TILE_SIZE; i++) - for (j = 0; j < TILE_SIZE; j++) - ztile[i][j] = clear->value; - } - - /* - printf("SPU: %s num=%d w=%d h=%d\n", - __FUNCTION__, num_tiles, fb.width_tiles, fb.height_tiles); - */ - - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; - if (clear->surface == 0) - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); - else - put_tile(&fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); - /* XXX we don't want this here, but it fixes bad tile results */ - } - -#if 0 - wait_on_mask(1 << TAG_SURFACE_CLEAR); -#endif -} - - -/** - * Given a rendering command's bounding box (in pixels) compute the - * location of the corresponding screen tile bounding box. - */ -static INLINE void -tile_bounding_box(const struct cell_command_render *render, - uint *txmin, uint *tymin, - uint *box_num_tiles, uint *box_width_tiles) -{ -#if 1 - /* Debug: full-window bounding box */ - uint txmax = fb.width_tiles - 1; - uint tymax = fb.height_tiles - 1; - *txmin = 0; - *tymin = 0; - *box_num_tiles = fb.width_tiles * fb.height_tiles; - *box_width_tiles = fb.width_tiles; - (void) render; - (void) txmax; - (void) tymax; -#else - uint txmax, tymax, box_height_tiles; - - *txmin = (uint) render->xmin / TILE_SIZE; - *tymin = (uint) render->ymin / TILE_SIZE; - txmax = (uint) render->xmax / TILE_SIZE; - tymax = (uint) render->ymax / TILE_SIZE; - *box_width_tiles = txmax - *txmin + 1; - box_height_tiles = tymax - *tymin + 1; - *box_num_tiles = *box_width_tiles * box_height_tiles; -#endif -#if 0 - printf("Render bounds: %g, %g ... %g, %g\n", - render->xmin, render->ymin, render->xmax, render->ymax); - printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax); -#endif -} - - -static void -cmd_render(const struct cell_command_render *render) -{ - /* we'll DMA into these buffers */ - ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB; - ushort indexes[CELL_MAX_VBUF_INDEXES] ALIGN16_ATTRIB; - - uint i, j, vertex_size, vertex_bytes, index_bytes; - - if (Debug) - printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", - init.id, - render->prim_type, - render->num_verts, - render->num_indexes); - - - ASSERT_ALIGN16(render->vertex_data); - ASSERT_ALIGN16(render->index_data); - - vertex_size = render->num_attribs * 4 * sizeof(float); - - /* how much vertex data */ - vertex_bytes = render->num_verts * vertex_size; - index_bytes = render->num_indexes * sizeof(ushort); - if (index_bytes < 8) - index_bytes = 8; - else - index_bytes = (index_bytes + 15) & ~0xf; /* multiple of 16 */ - - /* - printf("VBUF: indices at %p, vertices at %p vertex_bytes %u ind_bytes %u\n", - render->index_data, render->vertex_data, vertex_bytes, index_bytes); - */ - - /* get vertex data from main memory */ - mfc_get(vertex_data, /* dest */ - (unsigned int) render->vertex_data, /* src */ - vertex_bytes, /* size */ - TAG_VERTEX_BUFFER, - 0, /* tid */ - 0 /* rid */); - - /* get index data from main memory */ - mfc_get(indexes, /* dest */ - (unsigned int) render->index_data, /* src */ - index_bytes, - TAG_INDEX_BUFFER, - 0, /* tid */ - 0 /* rid */); - - wait_on_mask_all((1 << TAG_VERTEX_BUFFER) | - (1 << TAG_INDEX_BUFFER)); - - /* find tiles which intersect the prim bounding box */ - uint txmin, tymin, box_width_tiles, box_num_tiles; -#if 0 - tile_bounding_box(render, &txmin, &tymin, - &box_num_tiles, &box_width_tiles); -#else - txmin = 0; - tymin = 0; - box_num_tiles = fb.width_tiles * fb.height_tiles; - box_width_tiles = fb.width_tiles; -#endif - - /* make sure any pending clears have completed */ - wait_on_mask(1 << TAG_SURFACE_CLEAR); - - /* loop over tiles */ - for (i = init.id; i < box_num_tiles; i += init.num_spus) { - const uint tx = txmin + i % box_width_tiles; - const uint ty = tymin + i / box_width_tiles; - - ASSERT(tx < fb.width_tiles); - ASSERT(ty < fb.height_tiles); - - /* Start fetching color/z tiles. We'll wait for completion when - * we need read/write to them later in triangle rasterization. - */ - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); - } - } - - if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); - } - - ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); - - /* loop over tris */ - for (j = 0; j < render->num_indexes; j += 3) { - const float *v0, *v1, *v2; - - v0 = (const float *) (vertex_data + indexes[j+0] * vertex_size); - v1 = (const float *) (vertex_data + indexes[j+1] * vertex_size); - v2 = (const float *) (vertex_data + indexes[j+2] * vertex_size); - - tri_draw(v0, v1, v2, tx, ty); - } - - /* write color/z tiles back to main framebuffer, if dirtied */ - if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); - tile_status[ty][tx] = TILE_STATUS_DEFINED; - } - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); - tile_status_z[ty][tx] = TILE_STATUS_DEFINED; - } - } - - /* XXX move these... */ - wait_on_mask(1 << TAG_WRITE_TILE_COLOR); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - wait_on_mask(1 << TAG_WRITE_TILE_Z); - } - } -} - - -static void -cmd_framebuffer(const struct cell_command_framebuffer *cmd) -{ - if (Debug) - printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", - init.id, - cmd->width, - cmd->height, - cmd->color_start, - cmd->color_format, - cmd->depth_format); - - fb.color_start = cmd->color_start; - fb.depth_start = cmd->depth_start; - fb.color_format = cmd->color_format; - fb.depth_format = cmd->depth_format; - fb.width = cmd->width; - fb.height = cmd->height; - fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; - fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; -} - - -static void -cmd_finish(void) -{ - if (Debug) - printf("SPU %u: FINISH\n", init.id); - really_clear_tiles(0); - /* wait for all outstanding DMAs to finish */ - mfc_write_tag_mask(~0); - mfc_read_tag_status_all(); - /* send mbox message to PPU */ - spu_write_out_mbox(CELL_CMD_FINISH); -} - - -/** - * Execute a batch of commands - * The opcode param encodes the location of the buffer and its size. - */ -static void -cmd_batch(uint opcode) -{ - const uint buf = (opcode >> 8) & 0xff; - uint size = (opcode >> 16); - uint buffer[CELL_BATCH_BUFFER_SIZE / 4] ALIGN16_ATTRIB; - const uint usize = size / sizeof(uint); - uint pos; - - if (Debug) - printf("SPU %u: BATCH buffer %u, len %u, from %p\n", - init.id, buf, size, init.batch_buffers[buf]); - - ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH); - - ASSERT_ALIGN16(init.batch_buffers[buf]); - - size = (size + 0xf) & ~0xf; - - mfc_get(buffer, /* dest */ - (unsigned int) init.batch_buffers[buf], /* src */ - size, - TAG_BATCH_BUFFER, - 0, /* tid */ - 0 /* rid */); - wait_on_mask(1 << TAG_BATCH_BUFFER); - - for (pos = 0; pos < usize; /* no incr */) { - switch (buffer[pos]) { - case CELL_CMD_FRAMEBUFFER: - { - struct cell_command_framebuffer *fb - = (struct cell_command_framebuffer *) &buffer[pos]; - cmd_framebuffer(fb); - pos += sizeof(*fb) / 4; - } - break; - case CELL_CMD_CLEAR_SURFACE: - { - struct cell_command_clear_surface *clr - = (struct cell_command_clear_surface *) &buffer[pos]; - cmd_clear_surface(clr); - pos += sizeof(*clr) / 4; - } - break; - case CELL_CMD_RENDER: - { - struct cell_command_render *render - = (struct cell_command_render *) &buffer[pos]; - cmd_render(render); - pos += sizeof(*render) / 4; - } - break; - case CELL_CMD_FINISH: - cmd_finish(); - pos += 1; - break; - default: - printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]); - ASSERT(0); - break; - } - } - - if (Debug) - printf("SPU %u: BATCH complete\n", init.id); -} - - -/** - * Temporary/simple main loop for SPEs: Get a command, execute it, repeat. - */ -static void -main_loop(void) -{ - struct cell_command cmd; - int exitFlag = 0; - - if (Debug) - printf("SPU %u: Enter main loop\n", init.id); - - ASSERT((sizeof(struct cell_command) & 0xf) == 0); - ASSERT_ALIGN16(&cmd); - - while (!exitFlag) { - unsigned opcode; - int tag = 0; - - if (Debug) - printf("SPU %u: Wait for cmd...\n", init.id); - - /* read/wait from mailbox */ - opcode = (unsigned int) spu_read_in_mbox(); - - if (Debug) - printf("SPU %u: got cmd 0x%x\n", init.id, opcode); - - /* command payload */ - mfc_get(&cmd, /* dest */ - (unsigned int) init.cmd, /* src */ - sizeof(struct cell_command), /* bytes */ - tag, - 0, /* tid */ - 0 /* rid */); - wait_on_mask( 1 << tag ); - - switch (opcode & CELL_CMD_OPCODE_MASK) { - case CELL_CMD_EXIT: - if (Debug) - printf("SPU %u: EXIT\n", init.id); - exitFlag = 1; - break; - case CELL_CMD_FRAMEBUFFER: - cmd_framebuffer(&cmd.fb); - break; - case CELL_CMD_CLEAR_SURFACE: - cmd_clear_surface(&cmd.clear); - break; - case CELL_CMD_RENDER: - cmd_render(&cmd.render); - break; - case CELL_CMD_BATCH: - cmd_batch(opcode); - break; - case CELL_CMD_FINISH: - cmd_finish(); - break; - default: - printf("Bad opcode!\n"); - } - - } - - if (Debug) - printf("SPU %u: Exit main loop\n", init.id); -} - - - -static void -one_time_init(void) -{ - memset(tile_status, TILE_STATUS_DEFINED, sizeof(tile_status)); - memset(tile_status_z, TILE_STATUS_DEFINED, sizeof(tile_status_z)); -} - - -/** - * SPE entrypoint. - * Note: example programs declare params as 'unsigned long long' but - * that doesn't work. - */ -int -main(unsigned long speid, unsigned long argp) -{ - int tag = 0; - - (void) speid; - - one_time_init(); - - if (Debug) - printf("SPU: main() speid=%lu\n", speid); - - mfc_get(&init, /* dest */ - (unsigned int) argp, /* src */ - sizeof(struct cell_init_info), /* bytes */ - tag, - 0, /* tid */ - 0 /* rid */); - wait_on_mask( 1 << tag ); - - - main_loop(); - - return 0; -} diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h deleted file mode 100644 index cc70fdd7a6..0000000000 --- a/src/mesa/pipe/cell/spu/main.h +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef MAIN_H -#define MAIN_H - - -#include "pipe/cell/common.h" - - -extern volatile struct cell_init_info init; - -struct framebuffer { - void *color_start; /**< addr of color surface in main memory */ - void *depth_start; /**< addr of depth surface in main memory */ - enum pipe_format color_format; - enum pipe_format depth_format; - uint width, height; /**< size in pixels */ - uint width_tiles, height_tiles; /**< width and height in tiles */ - - uint color_clear_value; - uint depth_clear_value; -}; - -/* XXX Collect these globals in a struct: */ - -extern struct framebuffer fb; - - -/* DMA TAGS */ - -#define TAG_SURFACE_CLEAR 10 -#define TAG_VERTEX_BUFFER 11 -#define TAG_READ_TILE_COLOR 12 -#define TAG_READ_TILE_Z 13 -#define TAG_WRITE_TILE_COLOR 14 -#define TAG_WRITE_TILE_Z 15 -#define TAG_INDEX_BUFFER 16 -#define TAG_BATCH_BUFFER 17 - -/** The standard assert macro doesn't seem to work on SPUs */ -#define ASSERT(x) \ - if (!(x)) { \ - fprintf(stderr, "SPU %d: %s:%d: %s(): assertion %s failed.\n", \ - init.id, __FILE__, __LINE__, __FUNCTION__, #x); \ - exit(1); \ - } - - -void -wait_on_mask(unsigned tag); - - -#endif /* MAIN_H */ diff --git a/src/mesa/pipe/cell/spu/tile.c b/src/mesa/pipe/cell/spu/tile.c deleted file mode 100644 index ac89d0fab0..0000000000 --- a/src/mesa/pipe/cell/spu/tile.c +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - - -#include "tile.h" - - - -uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; - -ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; -ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; - - - -void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf) -{ - const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - const ubyte *src = zBuf ? fb->depth_start : fb->color_start; - - src += offset * bytesPerTile; - - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); - ASSERT_ALIGN16(tile); - /* - printf("get_tile: dest: %p src: 0x%x size: %d\n", - tile, (unsigned int) src, bytesPerTile); - */ - mfc_get(tile, /* dest in local memory */ - (unsigned int) src, /* src in main memory */ - bytesPerTile, - tag, - 0, /* tid */ - 0 /* rid */); -} - - -void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf) -{ - const uint offset = ty * fb->width_tiles + tx; - const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - ubyte *dst = zBuf ? fb->depth_start : fb->color_start; - - dst += offset * bytesPerTile; - - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); - ASSERT_ALIGN16(tile); - /* - printf("put_tile: src: %p dst: 0x%x size: %d\n", - tile, (unsigned int) dst, bytesPerTile); - */ - mfc_put((void *) tile, /* src in local memory */ - (unsigned int) dst, /* dst in main memory */ - bytesPerTile, - tag, - 0, /* tid */ - 0 /* rid */); -} - - -void -clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value) -{ - uint i, j; - for (i = 0; i < TILE_SIZE; i++) { - for (j = 0; j < TILE_SIZE; j++) { - tile[i][j] = value; - } - } -} - -void -clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value) -{ - uint i, j; - for (i = 0; i < TILE_SIZE; i++) { - for (j = 0; j < TILE_SIZE; j++) { - tile[i][j] = value; - } - } -} - diff --git a/src/mesa/pipe/cell/spu/tile.h b/src/mesa/pipe/cell/spu/tile.h deleted file mode 100644 index 832cf29e30..0000000000 --- a/src/mesa/pipe/cell/spu/tile.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef TILE_H -#define TILE_H - - -#include -#include -#include "main.h" -#include "pipe/cell/common.h" - - -#define MAX_WIDTH 1024 -#define MAX_HEIGHT 1024 - - -extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; -extern ushort ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB; - - -#define TILE_STATUS_CLEAR 1 -#define TILE_STATUS_DEFINED 2 /**< defined pixel data */ -#define TILE_STATUS_DIRTY 3 /**< modified, but not put back yet */ - -extern ubyte tile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; -extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; - - -void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf); - -void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf); - -void -clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); - -void -clear_tile_z(ushort tile[TILE_SIZE][TILE_SIZE], uint value); - - -#endif /* TILE_H */ diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c deleted file mode 100644 index a4fcb71d20..0000000000 --- a/src/mesa/pipe/cell/spu/tri.c +++ /dev/null @@ -1,892 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * Triangle rendering within a tile. - */ - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_util.h" -#include "main.h" -#include "tile.h" -#include "tri.h" - - - -/** - * Simplified types taken from other parts of Gallium - */ - -struct vertex_header { - float data[2][4]; /* pos and color */ -}; - -struct prim_header { - struct vertex_header *v[3]; -}; - - - - -#if 1 - -/* XXX fix this */ -#undef CEILF -#define CEILF(X) ((float) (int) ((X) + 0.99999)) - - -#define QUAD_TOP_LEFT 0 -#define QUAD_TOP_RIGHT 1 -#define QUAD_BOTTOM_LEFT 2 -#define QUAD_BOTTOM_RIGHT 3 -#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT) -#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT) -#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT) -#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT) -#define MASK_ALL 0xf - -#define PIPE_MAX_SHADER_INPUTS 8 /* XXX temp */ - -#endif - - -#define DEBUG_VERTS 0 - -/** - * Triangle edge info - */ -struct edge { - float dx; /**< X(v1) - X(v0), used only during setup */ - float dy; /**< Y(v1) - Y(v0), used only during setup */ - float dxdy; /**< dx/dy */ - float sx, sy; /**< first sample point coord */ - int lines; /**< number of lines on this edge */ -}; - - -struct interp_coef -{ - float a0[4]; - float dadx[4]; - float dady[4]; -}; - -/** - * Triangle setup info (derived from draw_stage). - * Also used for line drawing (taking some liberties). - */ -struct setup_stage { - - /* Vertices are just an array of floats making up each attribute in - * turn. Currently fixed at 4 floats, but should change in time. - * Codegen will help cope with this. - */ - const struct vertex_header *vmax; - const struct vertex_header *vmid; - const struct vertex_header *vmin; - const struct vertex_header *vprovoke; - - struct edge ebot; - struct edge etop; - struct edge emaj; - - float oneoverarea; - - uint tx, ty; - - int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; - -#if 0 - struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS]; -#else - struct interp_coef coef[PIPE_MAX_SHADER_INPUTS]; -#endif - -#if 0 - struct quad_header quad; -#endif - - struct { - int left[2]; /**< [0] = row0, [1] = row1 */ - int right[2]; - int y; - unsigned y_flags; - unsigned mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */ - } span; -}; - - -#if 0 -/** - * Basically a cast wrapper. - */ -static INLINE struct setup_stage *setup_stage( struct draw_stage *stage ) -{ - return (struct setup_stage *)stage; -} -#endif - -#if 0 -/** - * Clip setup->quad against the scissor/surface bounds. - */ -static INLINE void -quad_clip(struct setup_stage *setup) -{ - const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect; - const int minx = (int) cliprect->minx; - const int maxx = (int) cliprect->maxx; - const int miny = (int) cliprect->miny; - const int maxy = (int) cliprect->maxy; - - if (setup->quad.x0 >= maxx || - setup->quad.y0 >= maxy || - setup->quad.x0 + 1 < minx || - setup->quad.y0 + 1 < miny) { - /* totally clipped */ - setup->quad.mask = 0x0; - return; - } - if (setup->quad.x0 < minx) - setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); - if (setup->quad.y0 < miny) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); - if (setup->quad.x0 == maxx - 1) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); - if (setup->quad.y0 == maxy - 1) - setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); -} -#endif - -#if 0 -/** - * Emit a quad (pass to next stage) with clipping. - */ -static INLINE void -clip_emit_quad(struct setup_stage *setup) -{ - quad_clip(setup); - if (setup->quad.mask) { - struct softpipe_context *sp = setup->softpipe; - sp->quad.first->run(sp->quad.first, &setup->quad); - } -} -#endif - -/** - * Evaluate attribute coefficients (plane equations) to compute - * attribute values for the four fragments in a quad. - * Eg: four colors will be compute. - */ -static INLINE void -eval_coeff( struct setup_stage *setup, uint slot, - float x, float y, float result[4][4]) -{ - uint i; - const float *dadx = setup->coef[slot].dadx; - const float *dady = setup->coef[slot].dady; - - /* loop over XYZW comps */ - for (i = 0; i < 4; i++) { - result[QUAD_TOP_LEFT][i] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i]; - result[QUAD_TOP_RIGHT][i] = result[0][i] + dadx[i]; - result[QUAD_BOTTOM_LEFT][i] = result[0][i] + dady[i]; - result[QUAD_BOTTOM_RIGHT][i] = result[0][i] + dadx[i] + dady[i]; - } -} - - -static INLINE void -eval_z( struct setup_stage *setup, - float x, float y, float result[4]) -{ - uint slot = 0; - uint i = 2; - const float *dadx = setup->coef[slot].dadx; - const float *dady = setup->coef[slot].dady; - - result[QUAD_TOP_LEFT] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i]; - result[QUAD_TOP_RIGHT] = result[0] + dadx[i]; - result[QUAD_BOTTOM_LEFT] = result[0] + dady[i]; - result[QUAD_BOTTOM_RIGHT] = result[0] + dadx[i] + dady[i]; -} - - -static INLINE uint -pack_color(const float color[4]) -{ - uint r = (uint) (color[0] * 255.0); - uint g = (uint) (color[1] * 255.0); - uint b = (uint) (color[2] * 255.0); - uint a = (uint) (color[3] * 255.0); - switch (fb.color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - return (a << 24) | (r << 16) | (g << 8) | b; - case PIPE_FORMAT_B8G8R8A8_UNORM: - return (b << 24) | (g << 16) | (r << 8) | a; - default: - ASSERT(0); - return 0; - } -} - - -/** - * Emit a quad (pass to next stage). No clipping is done. - */ -static INLINE void -emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) -{ -#if 0 - struct softpipe_context *sp = setup->softpipe; - setup->quad.x0 = x; - setup->quad.y0 = y; - setup->quad.mask = mask; - sp->quad.first->run(sp->quad.first, &setup->quad); -#else - /* Cell: "write" quad fragments to the tile by setting prim color */ - int ix = x - setup->cliprect_minx; - int iy = y - setup->cliprect_miny; - float colors[4][4]; - uint z; - - eval_coeff(setup, 1, (float) x, (float) y, colors); - - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { - float zvals[4]; - eval_z(setup, (float) x, (float) y, zvals); - - if (tile_status_z[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { - /* now, _really_ clear the tile */ - clear_tile_z(ztile, fb.depth_clear_value); - } - else { - /* make sure we've got the tile from main mem */ - wait_on_mask(1 << TAG_READ_TILE_Z); - } - tile_status_z[setup->ty][setup->tx] = TILE_STATUS_DIRTY; - - if (mask & MASK_TOP_LEFT) { - z = (uint) (zvals[0] * 65535.0); - if (z < ztile[iy][ix]) - ztile[iy][ix] = z; - else - mask &= ~MASK_TOP_LEFT; - } - - if (mask & MASK_TOP_RIGHT) { - z = (uint) (zvals[1] * 65535.0); - if (z < ztile[iy][ix+1]) - ztile[iy][ix+1] = z; - else - mask &= ~MASK_TOP_RIGHT; - } - - if (mask & MASK_BOTTOM_LEFT) { - z = (uint) (zvals[2] * 65535.0); - if (z < ztile[iy+1][ix]) - ztile[iy+1][ix] = z; - else - mask &= ~MASK_BOTTOM_LEFT; - } - - if (mask & MASK_BOTTOM_RIGHT) { - z = (uint) (zvals[3] * 65535.0); - if (z < ztile[iy+1][ix+1]) - ztile[iy+1][ix+1] = z; - else - mask &= ~MASK_BOTTOM_RIGHT; - } - } - - if (mask) { - if (tile_status[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { - /* now, _really_ clear the tile */ - clear_tile(ctile, fb.color_clear_value); - } - else { - /* make sure we've got the tile from main mem */ - wait_on_mask(1 << TAG_READ_TILE_COLOR); - } - tile_status[setup->ty][setup->tx] = TILE_STATUS_DIRTY; - - if (mask & MASK_TOP_LEFT) - ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]); - if (mask & MASK_TOP_RIGHT) - ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]); - if (mask & MASK_BOTTOM_LEFT) - ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]); - if (mask & MASK_BOTTOM_RIGHT) - ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]); - } -#endif -} - - -/** - * Given an X or Y coordinate, return the block/quad coordinate that it - * belongs to. - */ -static INLINE int block( int x ) -{ - return x & ~1; -} - - -/** - * Compute mask which indicates which pixels in the 2x2 quad are actually inside - * the triangle's bounds. - * - * this is pretty nasty... may need to rework flush_spans again to - * fix it, if possible. - */ -static unsigned calculate_mask( struct setup_stage *setup, int x ) -{ - unsigned mask = 0x0; - - if (x >= setup->span.left[0] && x < setup->span.right[0]) - mask |= MASK_TOP_LEFT; - - if (x >= setup->span.left[1] && x < setup->span.right[1]) - mask |= MASK_BOTTOM_LEFT; - - if (x+1 >= setup->span.left[0] && x+1 < setup->span.right[0]) - mask |= MASK_TOP_RIGHT; - - if (x+1 >= setup->span.left[1] && x+1 < setup->span.right[1]) - mask |= MASK_BOTTOM_RIGHT; - - return mask; -} - - -/** - * Render a horizontal span of quads - */ -static void flush_spans( struct setup_stage *setup ) -{ - int minleft, maxright; - int x; - - switch (setup->span.y_flags) { - case 0x3: - /* both odd and even lines written (both quad rows) */ - minleft = MIN2(setup->span.left[0], setup->span.left[1]); - maxright = MAX2(setup->span.right[0], setup->span.right[1]); - break; - - case 0x1: - /* only even line written (quad top row) */ - minleft = setup->span.left[0]; - maxright = setup->span.right[0]; - break; - - case 0x2: - /* only odd line written (quad bottom row) */ - minleft = setup->span.left[1]; - maxright = setup->span.right[1]; - break; - - default: - return; - } - - /* XXX this loop could be moved into the above switch cases and - * calculate_mask() could be simplified a bit... - */ - for (x = block(minleft); x <= block(maxright); x += 2) { - emit_quad( setup, x, setup->span.y, - calculate_mask( setup, x ) ); - } - - setup->span.y = 0; - setup->span.y_flags = 0; - setup->span.right[0] = 0; - setup->span.right[1] = 0; -} - -#if DEBUG_VERTS -static void print_vertex(const struct setup_stage *setup, - const struct vertex_header *v) -{ - int i; - fprintf(stderr, "Vertex: (%p)\n", v); - for (i = 0; i < setup->quad.nr_attrs; i++) { - fprintf(stderr, " %d: %f %f %f %f\n", i, - v->data[i][0], v->data[i][1], v->data[i][2], v->data[i][3]); - } -} -#endif - -static boolean setup_sort_vertices( struct setup_stage *setup, - const struct prim_header *prim ) -{ - const struct vertex_header *v0 = prim->v[0]; - const struct vertex_header *v1 = prim->v[1]; - const struct vertex_header *v2 = prim->v[2]; - -#if DEBUG_VERTS - fprintf(stderr, "Triangle:\n"); - print_vertex(setup, v0); - print_vertex(setup, v1); - print_vertex(setup, v2); -#endif - - setup->vprovoke = v2; - - /* determine bottom to top order of vertices */ - { - float y0 = v0->data[0][1]; - float y1 = v1->data[0][1]; - float y2 = v2->data[0][1]; - if (y0 <= y1) { - if (y1 <= y2) { - /* y0<=y1<=y2 */ - setup->vmin = v0; - setup->vmid = v1; - setup->vmax = v2; - } - else if (y2 <= y0) { - /* y2<=y0<=y1 */ - setup->vmin = v2; - setup->vmid = v0; - setup->vmax = v1; - } - else { - /* y0<=y2<=y1 */ - setup->vmin = v0; - setup->vmid = v2; - setup->vmax = v1; - } - } - else { - if (y0 <= y2) { - /* y1<=y0<=y2 */ - setup->vmin = v1; - setup->vmid = v0; - setup->vmax = v2; - } - else if (y2 <= y1) { - /* y2<=y1<=y0 */ - setup->vmin = v2; - setup->vmid = v1; - setup->vmax = v0; - } - else { - /* y1<=y2<=y0 */ - setup->vmin = v1; - setup->vmid = v2; - setup->vmax = v0; - } - } - } - - /* Check if triangle is completely outside the tile bounds */ - if (setup->vmin->data[0][1] > setup->cliprect_maxy) - return FALSE; - if (setup->vmax->data[0][1] < setup->cliprect_miny) - return FALSE; - if (setup->vmin->data[0][0] < setup->cliprect_minx && - setup->vmid->data[0][0] < setup->cliprect_minx && - setup->vmax->data[0][0] < setup->cliprect_minx) - return FALSE; - if (setup->vmin->data[0][0] > setup->cliprect_maxx && - setup->vmid->data[0][0] > setup->cliprect_maxx && - setup->vmax->data[0][0] > setup->cliprect_maxx) - return FALSE; - - setup->ebot.dx = setup->vmid->data[0][0] - setup->vmin->data[0][0]; - setup->ebot.dy = setup->vmid->data[0][1] - setup->vmin->data[0][1]; - setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0]; - setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[0][1]; - setup->etop.dx = setup->vmax->data[0][0] - setup->vmid->data[0][0]; - setup->etop.dy = setup->vmax->data[0][1] - setup->vmid->data[0][1]; - - /* - * Compute triangle's area. Use 1/area to compute partial - * derivatives of attributes later. - * - * The area will be the same as prim->det, but the sign may be - * different depending on how the vertices get sorted above. - * - * To determine whether the primitive is front or back facing we - * use the prim->det value because its sign is correct. - */ - { - const float area = (setup->emaj.dx * setup->ebot.dy - - setup->ebot.dx * setup->emaj.dy); - - setup->oneoverarea = 1.0f / area; - /* - _mesa_printf("%s one-over-area %f area %f det %f\n", - __FUNCTION__, setup->oneoverarea, area, prim->det ); - */ - } - -#if 0 - /* We need to know if this is a front or back-facing triangle for: - * - the GLSL gl_FrontFacing fragment attribute (bool) - * - two-sided stencil test - */ - setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW); -#endif - - return TRUE; -} - - -#if 0 -/** - * Compute a0 for a constant-valued coefficient (GL_FLAT shading). - * The value value comes from vertex->data[slot][i]. - * The result will be put into setup->coef[slot].a0[i]. - * \param slot which attribute slot - * \param i which component of the slot (0..3) - */ -static void const_coeff( struct setup_stage *setup, - unsigned slot, - unsigned i ) -{ - assert(slot < PIPE_MAX_SHADER_INPUTS); - assert(i <= 3); - - setup->coef[slot].dadx[i] = 0; - setup->coef[slot].dady[i] = 0; - - /* need provoking vertex info! - */ - setup->coef[slot].a0[i] = setup->vprovoke->data[slot][i]; -} -#endif - - -/** - * Compute a0, dadx and dady for a linearly interpolated coefficient, - * for a triangle. - */ -static void tri_linear_coeff( struct setup_stage *setup, - uint slot, uint firstComp, uint lastComp ) -{ - uint i; - for (i = firstComp; i < lastComp; i++) { - float botda = setup->vmid->data[slot][i] - setup->vmin->data[slot][i]; - float majda = setup->vmax->data[slot][i] - setup->vmin->data[slot][i]; - float a = setup->ebot.dy * majda - botda * setup->emaj.dy; - float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - - ASSERT(slot < PIPE_MAX_SHADER_INPUTS); - - setup->coef[slot].dadx[i] = a * setup->oneoverarea; - setup->coef[slot].dady[i] = b * setup->oneoverarea; - - /* calculate a0 as the value which would be sampled for the - * fragment at (0,0), taking into account that we want to sample at - * pixel centers, in other words (0.5, 0.5). - * - * this is neat but unfortunately not a good way to do things for - * triangles with very large values of dadx or dady as it will - * result in the subtraction and re-addition from a0 of a very - * large number, which means we'll end up loosing a lot of the - * fractional bits and precision from a0. the way to fix this is - * to define a0 as the sample at a pixel center somewhere near vmin - * instead - i'll switch to this later. - */ - setup->coef[slot].a0[i] = (setup->vmin->data[slot][i] - - (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5f) + - setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5f))); - } - - /* - _mesa_printf("attr[%d].%c: %f dx:%f dy:%f\n", - slot, "xyzw"[i], - setup->coef[slot].a0[i], - setup->coef[slot].dadx[i], - setup->coef[slot].dady[i]); - */ -} - - -#if 0 -/** - * Compute a0, dadx and dady for a perspective-corrected interpolant, - * for a triangle. - * We basically multiply the vertex value by 1/w before computing - * the plane coefficients (a0, dadx, dady). - * Later, when we compute the value at a particular fragment position we'll - * divide the interpolated value by the interpolated W at that fragment. - */ -static void tri_persp_coeff( struct setup_stage *setup, - unsigned slot, - unsigned i ) -{ - /* premultiply by 1/w: - */ - float mina = setup->vmin->data[slot][i] * setup->vmin->data[0][3]; - float mida = setup->vmid->data[slot][i] * setup->vmid->data[0][3]; - float maxa = setup->vmax->data[slot][i] * setup->vmax->data[0][3]; - - float botda = mida - mina; - float majda = maxa - mina; - float a = setup->ebot.dy * majda - botda * setup->emaj.dy; - float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - - /* - printf("tri persp %d,%d: %f %f %f\n", slot, i, - setup->vmin->data[slot][i], - setup->vmid->data[slot][i], - setup->vmax->data[slot][i] - ); - */ - - assert(slot < PIPE_MAX_SHADER_INPUTS); - assert(i <= 3); - - setup->coef[slot].dadx[i] = a * setup->oneoverarea; - setup->coef[slot].dady[i] = b * setup->oneoverarea; - setup->coef[slot].a0[i] = (mina - - (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5f) + - setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5f))); -} -#endif - - -/** - * Compute the setup->coef[] array dadx, dady, a0 values. - * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized. - */ -static void setup_tri_coefficients( struct setup_stage *setup ) -{ -#if 0 - const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; - unsigned slot, j; - - /* z and w are done by linear interpolation: - */ - tri_linear_coeff(setup, 0, 2); - tri_linear_coeff(setup, 0, 3); - - /* setup interpolation for all the remaining attributes: - */ - for (slot = 1; slot < setup->quad.nr_attrs; slot++) { - switch (interp[slot]) { - case INTERP_CONSTANT: - for (j = 0; j < NUM_CHANNELS; j++) - const_coeff(setup, slot, j); - break; - - case INTERP_LINEAR: - for (j = 0; j < NUM_CHANNELS; j++) - tri_linear_coeff(setup, slot, j); - break; - - case INTERP_PERSPECTIVE: - for (j = 0; j < NUM_CHANNELS; j++) - tri_persp_coeff(setup, slot, j); - break; - - default: - /* invalid interp mode */ - assert(0); - } - } -#else - tri_linear_coeff(setup, 0, 2, 3); /* slot 0, z */ - tri_linear_coeff(setup, 1, 0, 4); /* slot 1, color */ -#endif -} - - -static void setup_tri_edges( struct setup_stage *setup ) -{ - float vmin_x = setup->vmin->data[0][0] + 0.5f; - float vmid_x = setup->vmid->data[0][0] + 0.5f; - - float vmin_y = setup->vmin->data[0][1] - 0.5f; - float vmid_y = setup->vmid->data[0][1] - 0.5f; - float vmax_y = setup->vmax->data[0][1] - 0.5f; - - setup->emaj.sy = CEILF(vmin_y); - setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy); - setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy; - setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy; - - setup->etop.sy = CEILF(vmid_y); - setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy); - setup->etop.dxdy = setup->etop.dx / setup->etop.dy; - setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy; - - setup->ebot.sy = CEILF(vmin_y); - setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy); - setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy; - setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy; -} - - -/** - * Render the upper or lower half of a triangle. - * Scissoring/cliprect is applied here too. - */ -static void subtriangle( struct setup_stage *setup, - struct edge *eleft, - struct edge *eright, - unsigned lines ) -{ - const int minx = setup->cliprect_minx; - const int maxx = setup->cliprect_maxx; - const int miny = setup->cliprect_miny; - const int maxy = setup->cliprect_maxy; - int y, start_y, finish_y; - int sy = (int)eleft->sy; - - ASSERT((int)eleft->sy == (int) eright->sy); - - /* clip top/bottom */ - start_y = sy; - finish_y = sy + lines; - - if (start_y < miny) - start_y = miny; - - if (finish_y > maxy) - finish_y = maxy; - - start_y -= sy; - finish_y -= sy; - - /* - _mesa_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y); - */ - - for (y = start_y; y < finish_y; y++) { - - /* avoid accumulating adds as floats don't have the precision to - * accurately iterate large triangle edges that way. luckily we - * can just multiply these days. - * - * this is all drowned out by the attribute interpolation anyway. - */ - int left = (int)(eleft->sx + y * eleft->dxdy); - int right = (int)(eright->sx + y * eright->dxdy); - - /* clip left/right */ - if (left < minx) - left = minx; - if (right > maxx) - right = maxx; - - if (left < right) { - int _y = sy + y; - if (block(_y) != setup->span.y) { - flush_spans(setup); - setup->span.y = block(_y); - } - - setup->span.left[_y&1] = left; - setup->span.right[_y&1] = right; - setup->span.y_flags |= 1<<(_y&1); - } - } - - - /* save the values so that emaj can be restarted: - */ - eleft->sx += lines * eleft->dxdy; - eright->sx += lines * eright->dxdy; - eleft->sy += lines; - eright->sy += lines; -} - - -/** - * Do setup for triangle rasterization, then render the triangle. - */ -static void -setup_tri(struct setup_stage *setup, struct prim_header *prim) -{ - if (!setup_sort_vertices( setup, prim )) { - return; /* totally clipped */ - } - - setup_tri_coefficients( setup ); - setup_tri_edges( setup ); - -#if 0 - setup->quad.prim = PRIM_TRI; -#endif - - setup->span.y = 0; - setup->span.y_flags = 0; - setup->span.right[0] = 0; - setup->span.right[1] = 0; - /* setup->span.z_mode = tri_z_mode( setup->ctx ); */ - - /* init_constant_attribs( setup ); */ - - if (setup->oneoverarea < 0.0) { - /* emaj on left: - */ - subtriangle( setup, &setup->emaj, &setup->ebot, setup->ebot.lines ); - subtriangle( setup, &setup->emaj, &setup->etop, setup->etop.lines ); - } - else { - /* emaj on right: - */ - subtriangle( setup, &setup->ebot, &setup->emaj, setup->ebot.lines ); - subtriangle( setup, &setup->etop, &setup->emaj, setup->etop.lines ); - } - - flush_spans( setup ); -} - - - -/** - * Draw triangle into tile at (tx, ty) (tile coords) - * The tile data should have already been fetched. - */ -void -tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty) -{ - struct prim_header tri; - struct setup_stage setup; - - tri.v[0] = (struct vertex_header *) v0; - tri.v[1] = (struct vertex_header *) v1; - tri.v[2] = (struct vertex_header *) v2; - - setup.tx = tx; - setup.ty = ty; - - /* set clipping bounds to tile bounds */ - setup.cliprect_minx = tx * TILE_SIZE; - setup.cliprect_miny = ty * TILE_SIZE; - setup.cliprect_maxx = (tx + 1) * TILE_SIZE; - setup.cliprect_maxy = (ty + 1) * TILE_SIZE; - - setup_tri(&setup, &tri); -} diff --git a/src/mesa/pipe/cell/spu/tri.h b/src/mesa/pipe/cell/spu/tri.h deleted file mode 100644 index f10c4077d3..0000000000 --- a/src/mesa/pipe/cell/spu/tri.h +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef TRI_H -#define TRI_H - - -extern void -tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty); - - -#endif /* TRI_H */ -- cgit v1.2.3 From 68f5a6f74335e252e6a04dd6ae9ef7ae1482be97 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 11:41:23 -0700 Subject: Cell: whitespace/cleanup --- src/mesa/pipe/cell/ppu/cell_state_blend.c | 34 ++++++++++++++++---------- src/mesa/pipe/cell/ppu/cell_state_rasterizer.c | 9 +++---- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_state_blend.c b/src/mesa/pipe/cell/ppu/cell_state_blend.c index da3fcfd3a5..4e49655820 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_blend.c +++ b/src/mesa/pipe/cell/ppu/cell_state_blend.c @@ -32,17 +32,19 @@ #include "cell_context.h" #include "cell_state.h" + void * cell_create_blend_state(struct pipe_context *pipe, - const struct pipe_blend_state *blend) + const struct pipe_blend_state *blend) { - struct pipe_blend_state *state = MALLOC( sizeof(struct pipe_blend_state) ); + struct pipe_blend_state *state = MALLOC(sizeof(struct pipe_blend_state)); memcpy(state, blend, sizeof(struct pipe_blend_state)); return state; } -void cell_bind_blend_state( struct pipe_context *pipe, - void *blend ) + +void +cell_bind_blend_state(struct pipe_context *pipe, void *blend) { struct cell_context *cell = cell_context(pipe); @@ -51,15 +53,17 @@ void cell_bind_blend_state( struct pipe_context *pipe, cell->dirty |= CELL_NEW_BLEND; } -void cell_delete_blend_state(struct pipe_context *pipe, - void *blend) + +void +cell_delete_blend_state(struct pipe_context *pipe, void *blend) { - FREE( blend ); + FREE(blend); } -void cell_set_blend_color( struct pipe_context *pipe, - const struct pipe_blend_color *blend_color ) +void +cell_set_blend_color(struct pipe_context *pipe, + const struct pipe_blend_color *blend_color) { struct cell_context *cell = cell_context(pipe); @@ -70,29 +74,33 @@ void cell_set_blend_color( struct pipe_context *pipe, + void * cell_create_depth_stencil_alpha_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_alpha_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { struct pipe_depth_stencil_alpha_state *state = - MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) ); + MALLOC(sizeof(struct pipe_depth_stencil_alpha_state)); memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state)); return state; } + void cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth_stencil) { struct cell_context *cell = cell_context(pipe); - cell->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; + cell->depth_stencil + = (const struct pipe_depth_stencil_alpha_state *) depth_stencil; cell->dirty |= CELL_NEW_DEPTH_STENCIL; } + void cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth) { - FREE( depth ); + FREE(depth); } diff --git a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c index 6b1675af26..d8128ece54 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c +++ b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c @@ -78,8 +78,8 @@ void * cell_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *setup) { - struct pipe_rasterizer_state *state = - MALLOC( sizeof(struct pipe_rasterizer_state) ); + struct pipe_rasterizer_state *state + = MALLOC(sizeof(struct pipe_rasterizer_state)); memcpy(state, setup, sizeof(struct pipe_rasterizer_state)); return state; } @@ -98,10 +98,9 @@ cell_bind_rasterizer_state(struct pipe_context *pipe, void *setup) cell->dirty |= CELL_NEW_RASTERIZER; } + void cell_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer) { - FREE( rasterizer ); + FREE(rasterizer); } - - -- cgit v1.2.3 From dae719a68173bddedbb531c030cd4a12bcb0435b Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 12:39:26 -0700 Subject: Cell: first state object (depth/stencil/alpha) emitted to SPUs --- src/mesa/pipe/cell/common.h | 1 + src/mesa/pipe/cell/ppu/Makefile | 1 + src/mesa/pipe/cell/ppu/cell_batch.c | 1 + src/mesa/pipe/cell/ppu/cell_state_blend.c | 1 + src/mesa/pipe/cell/ppu/cell_state_derived.c | 2 ++ src/mesa/pipe/cell/ppu/cell_state_emit.c | 45 +++++++++++++++++++++++++++++ src/mesa/pipe/cell/ppu/cell_state_emit.h | 36 +++++++++++++++++++++++ src/mesa/pipe/cell/spu/spu_main.c | 20 ++++++++++++- 8 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/mesa/pipe/cell/ppu/cell_state_emit.c create mode 100644 src/mesa/pipe/cell/ppu/cell_state_emit.h (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 3d6f1c4ba0..74b3d3cbee 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -59,6 +59,7 @@ #define CELL_CMD_FINISH 4 #define CELL_CMD_RENDER 5 #define CELL_CMD_BATCH 6 +#define CELL_CMD_STATE_DEPTH_STENCIL 7 #define CELL_NUM_BATCH_BUFFERS 2 diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile index f7e3dd09f4..6a1bd5982f 100644 --- a/src/mesa/pipe/cell/ppu/Makefile +++ b/src/mesa/pipe/cell/ppu/Makefile @@ -23,6 +23,7 @@ SOURCES = \ cell_state_blend.c \ cell_state_clip.c \ cell_state_derived.c \ + cell_state_emit.c \ cell_state_fs.c \ cell_state_rasterizer.c \ cell_state_sampler.c \ diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index 7eb1b50ddb..45d49d0465 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -68,6 +68,7 @@ cell_batch_append(struct cell_context *cell, const void *cmd, uint length) { uint size; + assert(length % 4 == 0); assert(cell->cur_batch >= 0); size = cell->batch_buffer_size[cell->cur_batch]; diff --git a/src/mesa/pipe/cell/ppu/cell_state_blend.c b/src/mesa/pipe/cell/ppu/cell_state_blend.c index 4e49655820..34ae0128ea 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_blend.c +++ b/src/mesa/pipe/cell/ppu/cell_state_blend.c @@ -33,6 +33,7 @@ #include "cell_state.h" + void * cell_create_blend_state(struct pipe_context *pipe, const struct pipe_blend_state *blend) diff --git a/src/mesa/pipe/cell/ppu/cell_state_derived.c b/src/mesa/pipe/cell/ppu/cell_state_derived.c index ec3a8f3a81..dc2879b915 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_derived.c +++ b/src/mesa/pipe/cell/ppu/cell_state_derived.c @@ -219,5 +219,7 @@ void cell_update_derived( struct cell_context *cell ) compute_cliprect(cell); #endif + cell_emit_state(cell); + cell->dirty = 0; } diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.c b/src/mesa/pipe/cell/ppu/cell_state_emit.c new file mode 100644 index 0000000000..e1a1458f39 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_emit.c @@ -0,0 +1,45 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "pipe/p_util.h" +#include "cell_context.h" +#include "cell_state.h" +#include "cell_state_emit.h" +#include "cell_batch.h" + + + +void +cell_emit_state(struct cell_context *cell) +{ + if (cell->dirty & CELL_NEW_DEPTH_STENCIL) { + uint cmd = CELL_CMD_STATE_DEPTH_STENCIL; + cell_batch_append(cell, &cmd, 4); + cell_batch_append(cell, cell->depth_stencil, + sizeof(struct pipe_depth_stencil_alpha_state)); + } +} diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.h b/src/mesa/pipe/cell/ppu/cell_state_emit.h new file mode 100644 index 0000000000..59f8affe8d --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_emit.h @@ -0,0 +1,36 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef CELL_STATE_EMIT_H +#define CELL_STATE_EMIT_H + + +extern void +cell_emit_state(struct cell_context *cell); + + +#endif /* CELL_STATE_EMIT_H */ diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index df708e65d1..f9d7302c36 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -38,6 +38,8 @@ #include "spu_tile.h" #include "pipe/cell/common.h" #include "pipe/p_defines.h" +#include "pipe/p_state.h" + /* helpful headers: @@ -45,7 +47,7 @@ helpful headers: /opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h */ -static boolean Debug = FALSE; +static boolean Debug = TRUE; volatile struct cell_init_info init; @@ -356,6 +358,17 @@ cmd_framebuffer(const struct cell_command_framebuffer *cmd) } +static void +cmd_state_depth_stencil(const struct pipe_depth_stencil_alpha_state *state) +{ + if (Debug) + printf("SPU %u: DEPTH_STENCIL: ztest %d\n", + init.id, + state->depth.enabled); + /* XXX copy/save the state */ +} + + static void cmd_finish(void) { @@ -431,6 +444,11 @@ cmd_batch(uint opcode) cmd_finish(); pos += 1; break; + case CELL_CMD_STATE_DEPTH_STENCIL: + cmd_state_depth_stencil((struct pipe_depth_stencil_alpha_state *) + &buffer[pos+1]); + pos += (1 + sizeof(struct pipe_depth_stencil_alpha_state) / 4); + break; default: printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]); ASSERT(0); -- cgit v1.2.3 From d53e1c255aad83ee6c183f6e144d309327898669 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 12:53:49 -0700 Subject: Cell: collect vars in a spu_global struct --- src/mesa/pipe/cell/spu/spu_main.c | 128 ++++++++++++++++++-------------------- src/mesa/pipe/cell/spu/spu_main.h | 27 ++++++-- src/mesa/pipe/cell/spu/spu_tri.c | 18 ++---- 3 files changed, 88 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index f9d7302c36..7446cc3eff 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -38,7 +38,6 @@ #include "spu_tile.h" #include "pipe/cell/common.h" #include "pipe/p_defines.h" -#include "pipe/p_state.h" /* @@ -49,10 +48,7 @@ helpful headers: static boolean Debug = TRUE; -volatile struct cell_init_info init; - -struct framebuffer fb; - +struct spu_global spu; void @@ -81,32 +77,32 @@ wait_on_mask_all(unsigned tagMask) static void really_clear_tiles(uint surfaceIndex) { - const uint num_tiles = fb.width_tiles * fb.height_tiles; + const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles; uint i, j; if (surfaceIndex == 0) { for (i = 0; i < TILE_SIZE; i++) for (j = 0; j < TILE_SIZE; j++) - ctile[i][j] = fb.color_clear_value; + ctile[i][j] = spu.fb.color_clear_value; - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; + for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) { + uint tx = i % spu.fb.width_tiles; + uint ty = i / spu.fb.width_tiles; if (tile_status[ty][tx] == TILE_STATUS_CLEAR) { - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); } } } else { for (i = 0; i < TILE_SIZE; i++) for (j = 0; j < TILE_SIZE; j++) - ztile[i][j] = fb.depth_clear_value; + ztile[i][j] = spu.fb.depth_clear_value; - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; + for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) { + uint tx = i % spu.fb.width_tiles; + uint ty = i / spu.fb.width_tiles; if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR) - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); + put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); } } @@ -119,11 +115,11 @@ really_clear_tiles(uint surfaceIndex) static void cmd_clear_surface(const struct cell_command_clear_surface *clear) { - const uint num_tiles = fb.width_tiles * fb.height_tiles; + const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles; uint i, j; if (Debug) - printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id, + printf("SPU %u: CLEAR SURF %u to 0x%08x\n", spu.init.id, clear->surface, clear->value); #define CLEAR_OPT 1 @@ -131,11 +127,11 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear) /* set all tile's status to CLEAR */ if (clear->surface == 0) { memset(tile_status, TILE_STATUS_CLEAR, sizeof(tile_status)); - fb.color_clear_value = clear->value; + spu.fb.color_clear_value = clear->value; } else { memset(tile_status_z, TILE_STATUS_CLEAR, sizeof(tile_status_z)); - fb.depth_clear_value = clear->value; + spu.fb.depth_clear_value = clear->value; } return; #endif @@ -153,16 +149,16 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear) /* printf("SPU: %s num=%d w=%d h=%d\n", - __FUNCTION__, num_tiles, fb.width_tiles, fb.height_tiles); + __FUNCTION__, num_tiles, spu.fb.width_tiles, spu.fb.height_tiles); */ - for (i = init.id; i < num_tiles; i += init.num_spus) { - uint tx = i % fb.width_tiles; - uint ty = i / fb.width_tiles; + for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) { + uint tx = i % spu.fb.width_tiles; + uint ty = i / spu.fb.width_tiles; if (clear->surface == 0) - put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); else - put_tile(&fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); + put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); /* XXX we don't want this here, but it fixes bad tile results */ } @@ -183,12 +179,12 @@ tile_bounding_box(const struct cell_command_render *render, { #if 1 /* Debug: full-window bounding box */ - uint txmax = fb.width_tiles - 1; - uint tymax = fb.height_tiles - 1; + uint txmax = spu.fb.width_tiles - 1; + uint tymax = spu.fb.height_tiles - 1; *txmin = 0; *tymin = 0; - *box_num_tiles = fb.width_tiles * fb.height_tiles; - *box_width_tiles = fb.width_tiles; + *box_num_tiles = spu.fb.width_tiles * spu.fb.height_tiles; + *box_width_tiles = spu.fb.width_tiles; (void) render; (void) txmax; (void) tymax; @@ -222,7 +218,7 @@ cmd_render(const struct cell_command_render *render) if (Debug) printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", - init.id, + spu.init.id, render->prim_type, render->num_verts, render->num_indexes); @@ -273,32 +269,32 @@ cmd_render(const struct cell_command_render *render) #else txmin = 0; tymin = 0; - box_num_tiles = fb.width_tiles * fb.height_tiles; - box_width_tiles = fb.width_tiles; + box_num_tiles = spu.fb.width_tiles * spu.fb.height_tiles; + box_width_tiles = spu.fb.width_tiles; #endif /* make sure any pending clears have completed */ wait_on_mask(1 << TAG_SURFACE_CLEAR); /* loop over tiles */ - for (i = init.id; i < box_num_tiles; i += init.num_spus) { + for (i = spu.init.id; i < box_num_tiles; i += spu.init.num_spus) { const uint tx = txmin + i % box_width_tiles; const uint ty = tymin + i / box_width_tiles; - ASSERT(tx < fb.width_tiles); - ASSERT(ty < fb.height_tiles); + ASSERT(tx < spu.fb.width_tiles); + ASSERT(ty < spu.fb.height_tiles); /* Start fetching color/z tiles. We'll wait for completion when * we need read/write to them later in triangle rasterization. */ - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + get_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); } } if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); + get_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); } ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); @@ -316,19 +312,19 @@ cmd_render(const struct cell_command_render *render) /* write color/z tiles back to main framebuffer, if dirtied */ if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); tile_status[ty][tx] = TILE_STATUS_DEFINED; } - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); tile_status_z[ty][tx] = TILE_STATUS_DEFINED; } } /* XXX move these... */ wait_on_mask(1 << TAG_WRITE_TILE_COLOR); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { wait_on_mask(1 << TAG_WRITE_TILE_Z); } } @@ -340,21 +336,21 @@ cmd_framebuffer(const struct cell_command_framebuffer *cmd) { if (Debug) printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", - init.id, + spu.init.id, cmd->width, cmd->height, cmd->color_start, cmd->color_format, cmd->depth_format); - fb.color_start = cmd->color_start; - fb.depth_start = cmd->depth_start; - fb.color_format = cmd->color_format; - fb.depth_format = cmd->depth_format; - fb.width = cmd->width; - fb.height = cmd->height; - fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE; - fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE; + spu.fb.color_start = cmd->color_start; + spu.fb.depth_start = cmd->depth_start; + spu.fb.color_format = cmd->color_format; + spu.fb.depth_format = cmd->depth_format; + spu.fb.width = cmd->width; + spu.fb.height = cmd->height; + spu.fb.width_tiles = (spu.fb.width + TILE_SIZE - 1) / TILE_SIZE; + spu.fb.height_tiles = (spu.fb.height + TILE_SIZE - 1) / TILE_SIZE; } @@ -363,7 +359,7 @@ cmd_state_depth_stencil(const struct pipe_depth_stencil_alpha_state *state) { if (Debug) printf("SPU %u: DEPTH_STENCIL: ztest %d\n", - init.id, + spu.init.id, state->depth.enabled); /* XXX copy/save the state */ } @@ -373,7 +369,7 @@ static void cmd_finish(void) { if (Debug) - printf("SPU %u: FINISH\n", init.id); + printf("SPU %u: FINISH\n", spu.init.id); really_clear_tiles(0); /* wait for all outstanding DMAs to finish */ mfc_write_tag_mask(~0); @@ -398,16 +394,16 @@ cmd_batch(uint opcode) if (Debug) printf("SPU %u: BATCH buffer %u, len %u, from %p\n", - init.id, buf, size, init.batch_buffers[buf]); + spu.init.id, buf, size, spu.init.batch_buffers[buf]); ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH); - ASSERT_ALIGN16(init.batch_buffers[buf]); + ASSERT_ALIGN16(spu.init.batch_buffers[buf]); size = (size + 0xf) & ~0xf; mfc_get(buffer, /* dest */ - (unsigned int) init.batch_buffers[buf], /* src */ + (unsigned int) spu.init.batch_buffers[buf], /* src */ size, TAG_BATCH_BUFFER, 0, /* tid */ @@ -450,14 +446,14 @@ cmd_batch(uint opcode) pos += (1 + sizeof(struct pipe_depth_stencil_alpha_state) / 4); break; default: - printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]); + printf("SPU %u: bad opcode: 0x%x\n", spu.init.id, buffer[pos]); ASSERT(0); break; } } if (Debug) - printf("SPU %u: BATCH complete\n", init.id); + printf("SPU %u: BATCH complete\n", spu.init.id); } @@ -471,7 +467,7 @@ main_loop(void) int exitFlag = 0; if (Debug) - printf("SPU %u: Enter main loop\n", init.id); + printf("SPU %u: Enter main loop\n", spu.init.id); ASSERT((sizeof(struct cell_command) & 0xf) == 0); ASSERT_ALIGN16(&cmd); @@ -481,17 +477,17 @@ main_loop(void) int tag = 0; if (Debug) - printf("SPU %u: Wait for cmd...\n", init.id); + printf("SPU %u: Wait for cmd...\n", spu.init.id); /* read/wait from mailbox */ opcode = (unsigned int) spu_read_in_mbox(); if (Debug) - printf("SPU %u: got cmd 0x%x\n", init.id, opcode); + printf("SPU %u: got cmd 0x%x\n", spu.init.id, opcode); /* command payload */ mfc_get(&cmd, /* dest */ - (unsigned int) init.cmd, /* src */ + (unsigned int) spu.init.cmd, /* src */ sizeof(struct cell_command), /* bytes */ tag, 0, /* tid */ @@ -501,7 +497,7 @@ main_loop(void) switch (opcode & CELL_CMD_OPCODE_MASK) { case CELL_CMD_EXIT: if (Debug) - printf("SPU %u: EXIT\n", init.id); + printf("SPU %u: EXIT\n", spu.init.id); exitFlag = 1; break; case CELL_CMD_FRAMEBUFFER: @@ -526,7 +522,7 @@ main_loop(void) } if (Debug) - printf("SPU %u: Exit main loop\n", init.id); + printf("SPU %u: Exit main loop\n", spu.init.id); } @@ -556,7 +552,7 @@ main(unsigned long speid, unsigned long argp) if (Debug) printf("SPU: main() speid=%lu\n", speid); - mfc_get(&init, /* dest */ + mfc_get(&spu.init, /* dest */ (unsigned int) argp, /* src */ sizeof(struct cell_init_info), /* bytes */ tag, diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h index 9ef8cf0709..ea43224d02 100644 --- a/src/mesa/pipe/cell/spu/spu_main.h +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -30,10 +30,9 @@ #include "pipe/cell/common.h" +#include "pipe/p_state.h" -extern volatile struct cell_init_info init; - struct framebuffer { void *color_start; /**< addr of color surface in main memory */ void *depth_start; /**< addr of depth surface in main memory */ @@ -44,11 +43,27 @@ struct framebuffer { uint color_clear_value; uint depth_clear_value; -}; +} ALIGN16_ATTRIB; + + +/** + * All SPU global/context state will be in singleton object of this type: + */ +struct spu_global +{ + struct cell_init_info init; + + struct framebuffer fb; + struct pipe_depth_stencil_alpha_state depth_stencil; + struct pipe_blend_state blend; + /* XXX more state to come */ + +} ALIGN16_ATTRIB; + + +extern struct spu_global spu; -/* XXX Collect these globals in a struct: */ -extern struct framebuffer fb; /* DMA TAGS */ @@ -66,7 +81,7 @@ extern struct framebuffer fb; #define ASSERT(x) \ if (!(x)) { \ fprintf(stderr, "SPU %d: %s:%d: %s(): assertion %s failed.\n", \ - init.id, __FILE__, __LINE__, __FUNCTION__, #x); \ + spu.init.id, __FILE__, __LINE__, __FUNCTION__, #x); \ exit(1); \ } diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c index af24e42435..b42b321c32 100644 --- a/src/mesa/pipe/cell/spu/spu_tri.c +++ b/src/mesa/pipe/cell/spu/spu_tri.c @@ -41,7 +41,6 @@ /** * Simplified types taken from other parts of Gallium */ - struct vertex_header { float data[2][4]; /* pos and color */ }; @@ -51,10 +50,6 @@ struct prim_header { }; - - -#if 1 - /* XXX fix this */ #undef CEILF #define CEILF(X) ((float) (int) ((X) + 0.99999)) @@ -70,10 +65,6 @@ struct prim_header { #define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT) #define MASK_ALL 0xf -#define PIPE_MAX_SHADER_INPUTS 8 /* XXX temp */ - -#endif - #define DEBUG_VERTS 0 @@ -96,6 +87,7 @@ struct interp_coef float dady[4]; }; + /** * Triangle setup info (derived from draw_stage). * Also used for line drawing (taking some liberties). @@ -244,7 +236,7 @@ pack_color(const float color[4]) uint g = (uint) (color[1] * 255.0); uint b = (uint) (color[2] * 255.0); uint a = (uint) (color[3] * 255.0); - switch (fb.color_format) { + switch (spu.fb.color_format) { case PIPE_FORMAT_A8R8G8B8_UNORM: return (a << 24) | (r << 16) | (g << 8) | b; case PIPE_FORMAT_B8G8R8A8_UNORM: @@ -277,13 +269,13 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) eval_coeff(setup, 1, (float) x, (float) y, colors); - if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) { + if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { float zvals[4]; eval_z(setup, (float) x, (float) y, zvals); if (tile_status_z[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { /* now, _really_ clear the tile */ - clear_tile_z(ztile, fb.depth_clear_value); + clear_tile_z(ztile, spu.fb.depth_clear_value); } else { /* make sure we've got the tile from main mem */ @@ -327,7 +319,7 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask ) if (mask) { if (tile_status[setup->ty][setup->tx] == TILE_STATUS_CLEAR) { /* now, _really_ clear the tile */ - clear_tile(ctile, fb.color_clear_value); + clear_tile(ctile, spu.fb.color_clear_value); } else { /* make sure we've got the tile from main mem */ -- cgit v1.2.3 From 8b1bfd1d27989c9a880ce269d56ea1dfd88a5811 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 16:57:55 -0700 Subject: Cell: disable cell_emit_state() for now --- src/mesa/pipe/cell/ppu/cell_state_derived.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_state_derived.c b/src/mesa/pipe/cell/ppu/cell_state_derived.c index dc2879b915..c654990325 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_derived.c +++ b/src/mesa/pipe/cell/ppu/cell_state_derived.c @@ -219,7 +219,7 @@ void cell_update_derived( struct cell_context *cell ) compute_cliprect(cell); #endif - cell_emit_state(cell); + //cell_emit_state(cell); cell->dirty = 0; } -- cgit v1.2.3 From a511200e5f0c384e68258879bab76563d8e01f01 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 12 Jan 2008 16:58:50 -0700 Subject: Cell: remove fb parameter to get/put_tile() --- src/mesa/pipe/cell/spu/spu_main.c | 30 +++++++++++++++++------------- src/mesa/pipe/cell/spu/spu_main.h | 4 ++-- src/mesa/pipe/cell/spu/spu_tile.c | 22 ++++++++++------------ src/mesa/pipe/cell/spu/spu_tile.h | 6 ++---- 4 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 7446cc3eff..0aee2aa6f9 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -83,13 +83,13 @@ really_clear_tiles(uint surfaceIndex) if (surfaceIndex == 0) { for (i = 0; i < TILE_SIZE; i++) for (j = 0; j < TILE_SIZE; j++) - ctile[i][j] = spu.fb.color_clear_value; + ctile[i][j] = spu.fb.color_clear_value; /*0xff00ff;*/ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) { uint tx = i % spu.fb.width_tiles; uint ty = i / spu.fb.width_tiles; if (tile_status[ty][tx] == TILE_STATUS_CLEAR) { - put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + put_tile(tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); } } } @@ -102,11 +102,11 @@ really_clear_tiles(uint surfaceIndex) uint tx = i % spu.fb.width_tiles; uint ty = i / spu.fb.width_tiles; if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR) - put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); + put_tile(tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1); } } -#if 0 +#if 01 wait_on_mask(1 << TAG_SURFACE_CLEAR); #endif } @@ -156,9 +156,9 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear) uint tx = i % spu.fb.width_tiles; uint ty = i / spu.fb.width_tiles; if (clear->surface == 0) - put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); + put_tile(tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0); else - put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); + put_tile(tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1); /* XXX we don't want this here, but it fixes bad tile results */ } @@ -216,13 +216,15 @@ cmd_render(const struct cell_command_render *render) uint i, j, vertex_size, vertex_bytes, index_bytes; - if (Debug) + if (Debug) { printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n", spu.init.id, render->prim_type, render->num_verts, render->num_indexes); - + printf(" bound: %g, %g .. %g, %g\n", + render->xmin, render->ymin, render->xmax, render->ymax); + } ASSERT_ALIGN16(render->vertex_data); ASSERT_ALIGN16(render->index_data); @@ -289,12 +291,12 @@ cmd_render(const struct cell_command_render *render) */ if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); + get_tile(tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1); } } if (tile_status[ty][tx] != TILE_STATUS_CLEAR) { - get_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); + get_tile(tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0); } ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES); @@ -312,12 +314,12 @@ cmd_render(const struct cell_command_render *render) /* write color/z tiles back to main framebuffer, if dirtied */ if (tile_status[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); + put_tile(tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0); tile_status[ty][tx] = TILE_STATUS_DEFINED; } if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) { if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) { - put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); + put_tile(tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1); tile_status_z[ty][tx] = TILE_STATUS_DEFINED; } } @@ -361,7 +363,9 @@ cmd_state_depth_stencil(const struct pipe_depth_stencil_alpha_state *state) printf("SPU %u: DEPTH_STENCIL: ztest %d\n", spu.init.id, state->depth.enabled); - /* XXX copy/save the state */ + /* + memcpy(&spu.depth_stencil, state, sizeof(*state)); + */ } diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h index ea43224d02..75fb5b388b 100644 --- a/src/mesa/pipe/cell/spu/spu_main.h +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -33,7 +33,7 @@ #include "pipe/p_state.h" -struct framebuffer { +struct spu_framebuffer { void *color_start; /**< addr of color surface in main memory */ void *depth_start; /**< addr of depth surface in main memory */ enum pipe_format color_format; @@ -53,7 +53,7 @@ struct spu_global { struct cell_init_info init; - struct framebuffer fb; + struct spu_framebuffer fb; struct pipe_depth_stencil_alpha_state depth_stencil; struct pipe_blend_state blend; /* XXX more state to come */ diff --git a/src/mesa/pipe/cell/spu/spu_tile.c b/src/mesa/pipe/cell/spu/spu_tile.c index 8fd9ab2905..99d779007e 100644 --- a/src/mesa/pipe/cell/spu/spu_tile.c +++ b/src/mesa/pipe/cell/spu/spu_tile.c @@ -40,17 +40,16 @@ ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf) +get_tile(uint tx, uint ty, uint *tile, int tag, int zBuf) { - const uint offset = ty * fb->width_tiles + tx; + const uint offset = ty * spu.fb.width_tiles + tx; const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - const ubyte *src = zBuf ? fb->depth_start : fb->color_start; + const ubyte *src = zBuf ? spu.fb.depth_start : spu.fb.color_start; src += offset * bytesPerTile; - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); + ASSERT(tx < spu.fb.width_tiles); + ASSERT(ty < spu.fb.height_tiles); ASSERT_ALIGN16(tile); /* printf("get_tile: dest: %p src: 0x%x size: %d\n", @@ -66,17 +65,16 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf) +put_tile(uint tx, uint ty, const uint *tile, int tag, int zBuf) { - const uint offset = ty * fb->width_tiles + tx; + const uint offset = ty * spu.fb.width_tiles + tx; const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? 2 : 4); - ubyte *dst = zBuf ? fb->depth_start : fb->color_start; + ubyte *dst = zBuf ? spu.fb.depth_start : spu.fb.color_start; dst += offset * bytesPerTile; - ASSERT(tx < fb->width_tiles); - ASSERT(ty < fb->height_tiles); + ASSERT(tx < spu.fb.width_tiles); + ASSERT(ty < spu.fb.height_tiles); ASSERT_ALIGN16(tile); /* printf("put_tile: src: %p dst: 0x%x size: %d\n", diff --git a/src/mesa/pipe/cell/spu/spu_tile.h b/src/mesa/pipe/cell/spu/spu_tile.h index 2ad469b584..637923764b 100644 --- a/src/mesa/pipe/cell/spu/spu_tile.h +++ b/src/mesa/pipe/cell/spu/spu_tile.h @@ -52,12 +52,10 @@ extern ubyte tile_status_z[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_AT void -get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, - int tag, int zBuf); +get_tile(uint tx, uint ty, uint *tile, int tag, int zBuf); void -put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, - int tag, int zBuf); +put_tile(uint tx, uint ty, const uint *tile, int tag, int zBuf); void clear_tile(uint tile[TILE_SIZE][TILE_SIZE], uint value); -- cgit v1.2.3 From c76efb96b405e43e3261d1dc9e8812fdb2cfbac8 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 10 Jan 2008 17:44:04 +0100 Subject: Remove mapping fields from struct pipe_surface. It's now the responsibility of surface users to keep track of their mappings. --- src/mesa/pipe/i915simple/i915_surface.c | 17 ++-- src/mesa/pipe/i965simple/brw_surface.c | 17 ++-- src/mesa/pipe/p_context.h | 4 +- src/mesa/pipe/p_inlines.h | 26 ++---- src/mesa/pipe/p_state.h | 2 - src/mesa/pipe/softpipe/sp_context.c | 26 ++---- src/mesa/pipe/softpipe/sp_state_surface.c | 42 ++------- src/mesa/pipe/softpipe/sp_surface.c | 16 ++-- src/mesa/pipe/softpipe/sp_tile_cache.c | 45 ++++++++-- src/mesa/pipe/softpipe/sp_tile_cache.h | 6 ++ src/mesa/pipe/util/p_tile.c | 128 +++++++++++++++++----------- src/mesa/pipe/xlib/xm_api.c | 21 ++--- src/mesa/state_tracker/st_cb_accum.c | 137 ++++-------------------------- src/mesa/state_tracker/st_cb_drawpixels.c | 6 -- src/mesa/state_tracker/st_cb_fbo.c | 3 - src/mesa/state_tracker/st_cb_readpixels.c | 4 - src/mesa/state_tracker/st_cb_texture.c | 13 +-- 17 files changed, 191 insertions(+), 322 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index 79e74e1143..4e1b0929ee 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -171,10 +171,10 @@ i915_surface_copy(struct pipe_context *pipe, /* Fill a rectangular sub-region. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ -static ubyte * -get_pointer(struct pipe_surface *dst, unsigned x, unsigned y) +static void * +get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y) { - return dst->map + (y * dst->pitch + x) * dst->cpp; + return (char *)dst_map + (y * dst->pitch + x) * dst->cpp; } @@ -186,12 +186,11 @@ i915_surface_fill(struct pipe_context *pipe, { if (0) { unsigned i, j; - - (void)pipe_surface_map(dst); + void *dst_map = pipe_surface_map(dst); switch (dst->cpp) { case 1: { - ubyte *row = get_pointer(dst, dstx, dsty); + ubyte *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { memset(row, value, width); row += dst->pitch; @@ -199,7 +198,7 @@ i915_surface_fill(struct pipe_context *pipe, } break; case 2: { - ushort *row = (ushort *) get_pointer(dst, dstx, dsty); + ushort *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = (ushort) value; @@ -208,7 +207,7 @@ i915_surface_fill(struct pipe_context *pipe, } break; case 4: { - unsigned *row = (unsigned *) get_pointer(dst, dstx, dsty); + unsigned *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = value; @@ -220,6 +219,8 @@ i915_surface_fill(struct pipe_context *pipe, assert(0); break; } + + pipe_surface_unmap( dst ); } else { i915_fill_blit( i915_context(pipe), diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c index d0e7229d5c..850423bdd5 100644 --- a/src/mesa/pipe/i965simple/brw_surface.c +++ b/src/mesa/pipe/i965simple/brw_surface.c @@ -171,10 +171,10 @@ brw_surface_copy(struct pipe_context *pipe, /* Fill a rectangular sub-region. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ -static ubyte * -get_pointer(struct pipe_surface *dst, unsigned x, unsigned y) +static void * +get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y) { - return dst->map + (y * dst->pitch + x) * dst->cpp; + return (char *)dst_map + (y * dst->pitch + x) * dst->cpp; } @@ -186,12 +186,11 @@ brw_surface_fill(struct pipe_context *pipe, { if (0) { unsigned i, j; - - (void)pipe_surface_map(dst); + void *dst_map = pipe_surface_map(dst); switch (dst->cpp) { case 1: { - ubyte *row = get_pointer(dst, dstx, dsty); + ubyte *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { memset(row, value, width); row += dst->pitch; @@ -199,7 +198,7 @@ brw_surface_fill(struct pipe_context *pipe, } break; case 2: { - ushort *row = (ushort *) get_pointer(dst, dstx, dsty); + ushort *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = (ushort) value; @@ -208,7 +207,7 @@ brw_surface_fill(struct pipe_context *pipe, } break; case 4: { - unsigned *row = (unsigned *) get_pointer(dst, dstx, dsty); + unsigned *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = value; @@ -220,6 +219,8 @@ brw_surface_fill(struct pipe_context *pipe, assert(0); break; } + + pipe_surface_unmap( dst ); } else { brw_fill_blit(brw_context(pipe), diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 1afb38a868..1a1f4f4e78 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -194,9 +194,9 @@ struct pipe_context { const void *p, int src_stride); /* XXX temporary here, move these to softpipe */ void (*get_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps, - uint x, uint y, uint w, uint h, float *p); + uint x, uint y, uint w, uint h, float *p); void (*put_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps, - uint x, uint y, uint w, uint h, const float *p); + uint x, uint y, uint w, uint h, const float *p); /* diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h index e7303c45c1..6976d087f9 100644 --- a/src/mesa/pipe/p_inlines.h +++ b/src/mesa/pipe/p_inlines.h @@ -33,35 +33,21 @@ #include "p_winsys.h" -static INLINE ubyte * +static INLINE void * pipe_surface_map(struct pipe_surface *surface) { - if (!surface->map_refcount++) { - surface->map - = (ubyte *) surface->winsys->buffer_map( surface->winsys, - surface->buffer, - PIPE_BUFFER_FLAG_WRITE | - PIPE_BUFFER_FLAG_READ ) - + surface->offset; - } - - return surface->map; + return (char *)surface->winsys->buffer_map( surface->winsys, surface->buffer, + PIPE_BUFFER_FLAG_WRITE | + PIPE_BUFFER_FLAG_READ ) + + surface->offset; } static INLINE void pipe_surface_unmap(struct pipe_surface *surface) { - if (surface->map_refcount > 0) { - assert(surface->map); - if (!--surface->map_refcount) { - surface->winsys->buffer_unmap( surface->winsys, - surface->buffer ); - surface->map = NULL; - } - } + surface->winsys->buffer_unmap( surface->winsys, surface->buffer ); } - /** * Set 'ptr' to point to 'surf' and update reference counting. * The old thing pointed to, if any, will be unreferenced first. diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index f9c5bfb6c6..ccd2a5f9e2 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -242,8 +242,6 @@ struct pipe_sampler_state struct pipe_surface { struct pipe_buffer_handle *buffer; /**< driver private buffer handle */ - ubyte *map; /**< only non-NULL when surface is actually mapped */ - unsigned map_refcount; /**< Reference count for mapping */ enum pipe_format format; /**< PIPE_FORMAT_x */ unsigned cpp; /**< bytes per pixel */ unsigned width, height; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 4f22539629..68c18e2d05 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -75,22 +75,15 @@ softpipe_is_format_supported( struct pipe_context *pipe, void softpipe_map_surfaces(struct softpipe_context *sp) { - struct pipe_surface *ps; unsigned i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) { - ps = sp->framebuffer.cbufs[i]; - if (ps->buffer && !ps->map) - pipe_surface_map(ps); + sp_tile_cache_map_surfaces(sp->cbuf_cache[i]); } - ps = sp->framebuffer.zbuf; - if (ps && ps->buffer && !ps->map) - pipe_surface_map(ps); + sp_tile_cache_map_surfaces(sp->zbuf_cache); - ps = sp->framebuffer.sbuf; - if (ps && ps->buffer && !ps->map) - pipe_surface_map(ps); + sp_tile_cache_map_surfaces(sp->sbuf_cache); } @@ -100,7 +93,6 @@ softpipe_map_surfaces(struct softpipe_context *sp) void softpipe_unmap_surfaces(struct softpipe_context *sp) { - struct pipe_surface *ps; uint i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) @@ -109,18 +101,12 @@ softpipe_unmap_surfaces(struct softpipe_context *sp) sp_flush_tile_cache(sp, sp->sbuf_cache); for (i = 0; i < sp->framebuffer.num_cbufs; i++) { - ps = sp->framebuffer.cbufs[i]; - if (ps->map) - pipe_surface_unmap(ps); + sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]); } - ps = sp->framebuffer.zbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); + sp_tile_cache_unmap_surfaces(sp->zbuf_cache); - ps = sp->framebuffer.sbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); + sp_tile_cache_unmap_surfaces(sp->sbuf_cache); } diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c index ee72aaf4c5..4a9a28cc4d 100644 --- a/src/mesa/pipe/softpipe/sp_state_surface.c +++ b/src/mesa/pipe/softpipe/sp_state_surface.c @@ -38,7 +38,7 @@ /** * XXX this might get moved someday * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer. - * Here, we map the surfaces and update the tile cache to point to the new + * Here, we flush the old surfaces and update the tile cache to point to the new * surfaces. */ void @@ -46,7 +46,6 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, const struct pipe_framebuffer_state *fb) { struct softpipe_context *sp = softpipe_context(pipe); - struct pipe_surface *ps; uint i; for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { @@ -54,19 +53,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { /* flush old */ sp_flush_tile_cache(sp, sp->cbuf_cache[i]); - /* unmap old */ - ps = sp->framebuffer.cbufs[i]; - if (ps && ps->map) - pipe_surface_unmap(ps); - /* map new */ - ps = fb->cbufs[i]; - if (ps) - pipe_surface_map(ps); + /* assign new */ sp->framebuffer.cbufs[i] = fb->cbufs[i]; /* update cache */ - sp_tile_cache_set_surface(sp->cbuf_cache[i], ps); + sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]); } } @@ -76,23 +68,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, if (sp->framebuffer.zbuf != fb->zbuf) { /* flush old */ sp_flush_tile_cache(sp, sp->zbuf_cache); - /* unmap old */ - ps = sp->framebuffer.zbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); - if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) { - /* combined z/stencil */ - sp->framebuffer.sbuf = NULL; - } - /* map new */ - ps = fb->zbuf; - if (ps) - pipe_surface_map(ps); + /* assign new */ sp->framebuffer.zbuf = fb->zbuf; /* update cache */ - sp_tile_cache_set_surface(sp->zbuf_cache, ps); + sp_tile_cache_set_surface(sp->zbuf_cache, fb->zbuf); } /* XXX combined depth/stencil here */ @@ -101,14 +82,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, if (sp->framebuffer.sbuf != fb->sbuf) { /* flush old */ sp_flush_tile_cache(sp, sp->sbuf_cache_sep); - /* unmap old */ - ps = sp->framebuffer.sbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); - /* map new */ - ps = fb->sbuf; - if (ps && fb->sbuf != fb->zbuf) - pipe_surface_map(ps); + /* assign new */ sp->framebuffer.sbuf = fb->sbuf; @@ -116,12 +90,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, if (fb->sbuf != fb->zbuf) { /* separate stencil buf */ sp->sbuf_cache = sp->sbuf_cache_sep; - sp_tile_cache_set_surface(sp->sbuf_cache, ps); + sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf); } else { /* combined depth/stencil */ sp->sbuf_cache = sp->zbuf_cache; - sp_tile_cache_set_surface(sp->sbuf_cache, ps); + sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf); } } diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index ece30e36ec..b44ba3e957 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -158,10 +158,10 @@ sp_surface_copy(struct pipe_context *pipe, } -static ubyte * -get_pointer(struct pipe_surface *dst, unsigned x, unsigned y) +static void * +get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y) { - return dst->map + (y * dst->pitch + x) * dst->cpp; + return (char *)dst_map + (y * dst->pitch + x) * dst->cpp; } @@ -179,16 +179,16 @@ sp_surface_fill(struct pipe_context *pipe, unsigned width, unsigned height, unsigned value) { unsigned i, j; + void *dst_map = pipe_surface_map(dst); assert(dst->pitch > 0); assert(width <= dst->pitch); - (void)pipe_surface_map(dst); switch (dst->cpp) { case 1: { - ubyte *row = get_pointer(dst, dstx, dsty); + ubyte *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { memset(row, value, width); row += dst->pitch; @@ -197,7 +197,7 @@ sp_surface_fill(struct pipe_context *pipe, break; case 2: { - ushort *row = (ushort *) get_pointer(dst, dstx, dsty); + ushort *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = (ushort) value; @@ -207,7 +207,7 @@ sp_surface_fill(struct pipe_context *pipe, break; case 4: { - unsigned *row = (unsigned *) get_pointer(dst, dstx, dsty); + unsigned *row = get_pointer(dst, dst_map, dstx, dsty); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) row[j] = value; @@ -218,7 +218,7 @@ sp_surface_fill(struct pipe_context *pipe, case 8: { /* expand the 4-byte clear value to an 8-byte value */ - ushort *row = (ushort *) get_pointer(dst, dstx, dsty); + ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty); ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c index 1dbcc5aadd..d6f60807e6 100644 --- a/src/mesa/pipe/softpipe/sp_tile_cache.c +++ b/src/mesa/pipe/softpipe/sp_tile_cache.c @@ -49,6 +49,7 @@ struct softpipe_tile_cache { struct pipe_surface *surface; /**< the surface we're caching */ + void *surface_map; struct pipe_texture *texture; /**< if caching a texture */ struct softpipe_cached_tile entries[NUM_ENTRIES]; uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32]; @@ -57,6 +58,7 @@ struct softpipe_tile_cache boolean depth_stencil; /** Is the surface a depth/stencil format? */ struct pipe_surface *tex_surf; + void *tex_surf_map; int tex_face, tex_level, tex_z; struct softpipe_cached_tile tile; /**< scratch tile for clears */ @@ -150,7 +152,7 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, { assert(!tc->texture); - if (tc->surface && tc->surface->map) { + if (tc->surface_map) { /*assert(tc->surface != ps);*/ pipe_surface_unmap(tc->surface); } @@ -158,8 +160,8 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, pipe_surface_reference(&tc->surface, ps); if (ps) { - if (!ps->map) - pipe_surface_map(ps); + if (tc->surface_map) + tc->surface_map = pipe_surface_map(ps); tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM || ps->format == PIPE_FORMAT_Z16_UNORM || @@ -179,6 +181,32 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc) } +void +sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc) +{ + if (tc->surface && !tc->surface_map) + tc->surface_map = pipe_surface_map(tc->surface); + + if (tc->tex_surf && !tc->tex_surf_map) + tc->tex_surf_map = pipe_surface_map(tc->tex_surf); +} + + +void +sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc) +{ + if (tc->surface_map) { + pipe_surface_unmap(tc->surface); + tc->surface_map = NULL; + } + + if (tc->tex_surf_map) { + pipe_surface_unmap(tc->tex_surf); + tc->tex_surf_map = NULL; + } +} + + /** * Specify the texture to cache. */ @@ -192,8 +220,10 @@ sp_tile_cache_set_texture(struct softpipe_tile_cache *tc, tc->texture = texture; - if (tc->tex_surf && tc->tex_surf->map) + if (tc->tex_surf_map) { pipe_surface_unmap(tc->tex_surf); + tc->tex_surf_map = NULL; + } pipe_surface_reference(&tc->tex_surf, NULL); /* mark as entries as invalid/empty */ @@ -330,9 +360,6 @@ sp_flush_tile_cache(struct softpipe_context *softpipe, if (!ps || !ps->buffer) return; - if (!ps->map) - pipe_surface_map(ps); - for (pos = 0; pos < NUM_ENTRIES; pos++) { struct softpipe_cached_tile *tile = tc->entries + pos; if (tile->x >= 0) { @@ -475,11 +502,11 @@ sp_get_cached_tile_tex(struct pipe_context *pipe, tc->tex_z != z) { /* get new surface (view into texture) */ - if (tc->tex_surf && tc->tex_surf->map) + if (tc->tex_surf_map) pipe_surface_unmap(tc->tex_surf); tc->tex_surf = pipe->get_tex_surface(pipe, tc->texture, face, level, z); - pipe_surface_map(tc->tex_surf); + tc->tex_surf_map = pipe_surface_map(tc->tex_surf); tc->tex_face = face; tc->tex_level = level; diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.h b/src/mesa/pipe/softpipe/sp_tile_cache.h index 91fb2795a2..7fd1081286 100644 --- a/src/mesa/pipe/softpipe/sp_tile_cache.h +++ b/src/mesa/pipe/softpipe/sp_tile_cache.h @@ -73,6 +73,12 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, extern struct pipe_surface * sp_tile_cache_get_surface(struct softpipe_tile_cache *tc); +extern void +sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc); + +extern void +sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc); + extern void sp_tile_cache_set_texture(struct softpipe_tile_cache *tc, struct pipe_texture *texture); diff --git a/src/mesa/pipe/util/p_tile.c b/src/mesa/pipe/util/p_tile.c index 8bc3c22c83..f2e19f19dc 100644 --- a/src/mesa/pipe/util/p_tile.c +++ b/src/mesa/pipe/util/p_tile.c @@ -56,8 +56,6 @@ pipe_get_tile_raw(struct pipe_context *pipe, ubyte *pDest; uint i; - assert(ps->map); - if (dst_stride == 0) { dst_stride = w * cpp; } @@ -65,7 +63,7 @@ pipe_get_tile_raw(struct pipe_context *pipe, if (pipe_clip_tile(x, y, &w, &h, ps)) return; - pSrc = ps->map + (y * ps->pitch + x) * cpp; + pSrc = (const ubyte *) pipe_surface_map(ps) + (y * ps->pitch + x) * cpp; pDest = (ubyte *) p; for (i = 0; i < h; i++) { @@ -73,6 +71,8 @@ pipe_get_tile_raw(struct pipe_context *pipe, pDest += dst_stride; pSrc += src_stride; } + + pipe_surface_unmap(ps); } @@ -92,8 +92,6 @@ pipe_put_tile_raw(struct pipe_context *pipe, ubyte *pDest; uint i; - assert(ps->map); - if (src_stride == 0) { src_stride = w * cpp; } @@ -102,13 +100,15 @@ pipe_put_tile_raw(struct pipe_context *pipe, return; pSrc = (const ubyte *) p; - pDest = ps->map + (y * ps->pitch + x) * cpp; + pDest = (ubyte *) pipe_surface_map(ps) + (y * ps->pitch + x) * cpp; for (i = 0; i < h; i++) { memcpy(pDest, pSrc, w * cpp); pDest += dst_stride; pSrc += src_stride; } + + pipe_surface_unmap(ps); } @@ -126,11 +126,12 @@ pipe_put_tile_raw(struct pipe_context *pipe, static void a8r8g8b8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const unsigned *src - = ((const unsigned *) (ps->map)) + = ((const unsigned *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -158,11 +159,12 @@ a8r8g8b8_get_tile_rgba(struct pipe_surface *ps, static void a8r8g8b8_put_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, const float *p) { unsigned *dst - = ((unsigned *) (ps->map)) + = ((unsigned *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -193,11 +195,12 @@ a8r8g8b8_put_tile_rgba(struct pipe_surface *ps, static void b8g8r8a8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const unsigned *src - = ((const unsigned *) (ps->map)) + = ((const unsigned *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -225,11 +228,12 @@ b8g8r8a8_get_tile_rgba(struct pipe_surface *ps, static void b8g8r8a8_put_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, const float *p) { unsigned *dst - = ((unsigned *) (ps->map)) + = ((unsigned *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -260,11 +264,12 @@ b8g8r8a8_put_tile_rgba(struct pipe_surface *ps, static void a1r5g5b5_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src - = ((const ushort *) (ps->map)) + = ((const ushort *) map) + y * ps->pitch + x; unsigned i, j; @@ -288,11 +293,12 @@ a1r5g5b5_get_tile_rgba(struct pipe_surface *ps, static void a4r4g4b4_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src - = ((const ushort *) (ps->map)) + = ((const ushort *) map) + y * ps->pitch + x; unsigned i, j; @@ -316,11 +322,12 @@ a4r4g4b4_get_tile_rgba(struct pipe_surface *ps, static void r5g6b5_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src - = ((const ushort *) (ps->map)) + = ((const ushort *) map) + y * ps->pitch + x; unsigned i, j; @@ -342,11 +349,12 @@ r5g6b5_get_tile_rgba(struct pipe_surface *ps, static void r5g5b5_put_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, const float *p) { ushort *dst - = ((ushort *) (ps->map)) + = ((ushort *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -379,11 +387,12 @@ r5g5b5_put_tile_rgba(struct pipe_surface *ps, */ static void z16_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src - = ((const ushort *) (ps->map)) + = ((const ushort *) map) + y * ps->pitch + x; const float scale = 1.0f / 65535.0f; unsigned i, j; @@ -414,11 +423,12 @@ z16_get_tile_rgba(struct pipe_surface *ps, static void l8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ubyte *src - = ((const ubyte *) (ps->map)) + = ((const ubyte *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -447,11 +457,12 @@ l8_get_tile_rgba(struct pipe_surface *ps, static void a8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ubyte *src - = ((const ubyte *) (ps->map)) + = ((const ubyte *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -480,11 +491,12 @@ a8_get_tile_rgba(struct pipe_surface *ps, static void r16g16b16a16_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const short *src - = ((const short *) (ps->map)) + = ((const short *) map) + (y * ps->pitch + x) * 4; unsigned i, j; unsigned w0 = w; @@ -513,11 +525,12 @@ r16g16b16a16_get_tile_rgba(struct pipe_surface *ps, static void r16g16b16a16_put_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, const float *p) { short *dst - = ((short *) (ps->map)) + = ((short *) map) + (y * ps->pitch + x) * 4; unsigned i, j; unsigned w0 = w; @@ -552,11 +565,12 @@ r16g16b16a16_put_tile_rgba(struct pipe_surface *ps, static void i8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ubyte *src - = ((const ubyte *) (ps->map)) + = ((const ubyte *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -585,11 +599,12 @@ i8_get_tile_rgba(struct pipe_surface *ps, static void a8_l8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src - = ((const ushort *) (ps->map)) + = ((const ushort *) map) + y * ps->pitch + x; unsigned i, j; unsigned w0 = w; @@ -624,11 +639,12 @@ a8_l8_get_tile_rgba(struct pipe_surface *ps, */ static void z32_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const uint *src - = ((const uint *) (ps->map)) + = ((const uint *) map) + y * ps->pitch + x; const double scale = 1.0 / (double) 0xffffffff; unsigned i, j; @@ -660,11 +676,12 @@ z32_get_tile_rgba(struct pipe_surface *ps, */ static void s8z24_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const uint *src - = ((const uint *) (ps->map)) + = ((const uint *) map) + y * ps->pitch + x; const double scale = 1.0 / ((1 << 24) - 1); unsigned i, j; @@ -696,11 +713,12 @@ s8z24_get_tile_rgba(struct pipe_surface *ps, */ static void z24s8_get_tile_rgba(struct pipe_surface *ps, + void *map, unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const uint *src - = ((const uint *) (ps->map)) + = ((const uint *) map) + y * ps->pitch + x; const double scale = 1.0 / ((1 << 24) - 1); unsigned i, j; @@ -731,52 +749,56 @@ pipe_get_tile_rgba(struct pipe_context *pipe, uint x, uint y, uint w, uint h, float *p) { + void *map = pipe_surface_map(ps); + switch (ps->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: - a8r8g8b8_get_tile_rgba(ps, x, y, w, h, p); + a8r8g8b8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_B8G8R8A8_UNORM: - b8g8r8a8_get_tile_rgba(ps, x, y, w, h, p); + b8g8r8a8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_A1R5G5B5_UNORM: - a1r5g5b5_get_tile_rgba(ps, x, y, w, h, p); + a1r5g5b5_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_A4R4G4B4_UNORM: - a4r4g4b4_get_tile_rgba(ps, x, y, w, h, p); + a4r4g4b4_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_R5G6B5_UNORM: - r5g6b5_get_tile_rgba(ps, x, y, w, h, p); + r5g6b5_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_U_L8: - l8_get_tile_rgba(ps, x, y, w, h, p); + l8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_U_A8: - a8_get_tile_rgba(ps, x, y, w, h, p); + a8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_U_I8: - i8_get_tile_rgba(ps, x, y, w, h, p); + i8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_U_A8_L8: - a8_l8_get_tile_rgba(ps, x, y, w, h, p); + a8_l8_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_get_tile_rgba(ps, x, y, w, h, p); + r16g16b16a16_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_Z16_UNORM: - z16_get_tile_rgba(ps, x, y, w, h, p); + z16_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_Z32_UNORM: - z32_get_tile_rgba(ps, x, y, w, h, p); + z32_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_S8Z24_UNORM: - s8z24_get_tile_rgba(ps, x, y, w, h, p); + s8z24_get_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_Z24S8_UNORM: - z24s8_get_tile_rgba(ps, x, y, w, h, p); + z24s8_get_tile_rgba(ps, map, x, y, w, h, p); break; default: assert(0); } + + pipe_surface_unmap(ps); } @@ -786,49 +808,53 @@ pipe_put_tile_rgba(struct pipe_context *pipe, uint x, uint y, uint w, uint h, const float *p) { + void *map = pipe_surface_map(ps); + switch (ps->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: - a8r8g8b8_put_tile_rgba(ps, x, y, w, h, p); + a8r8g8b8_put_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_B8G8R8A8_UNORM: - b8g8r8a8_put_tile_rgba(ps, x, y, w, h, p); + b8g8r8a8_put_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_A1R5G5B5_UNORM: - /*a1r5g5b5_put_tile_rgba(ps, x, y, w, h, p);*/ + /*a1r5g5b5_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_R5G6B5_UNORM: - r5g5b5_put_tile_rgba(ps, x, y, w, h, p); + r5g5b5_put_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_R8G8B8A8_UNORM: break; case PIPE_FORMAT_U_L8: - /*l8_put_tile_rgba(ps, x, y, w, h, p);*/ + /*l8_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_U_A8: - /*a8_put_tile_rgba(ps, x, y, w, h, p);*/ + /*a8_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_U_I8: - /*i8_put_tile_rgba(ps, x, y, w, h, p);*/ + /*i8_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_U_A8_L8: - /*a8_l8_put_tile_rgba(ps, x, y, w, h, p);*/ + /*a8_l8_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_put_tile_rgba(ps, x, y, w, h, p); + r16g16b16a16_put_tile_rgba(ps, map, x, y, w, h, p); break; case PIPE_FORMAT_Z16_UNORM: - /*z16_put_tile_rgba(ps, x, y, w, h, p);*/ + /*z16_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_Z32_UNORM: - /*z32_put_tile_rgba(ps, x, y, w, h, p);*/ + /*z32_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_S8Z24_UNORM: - /*s8z24_put_tile_rgba(ps, x, y, w, h, p);*/ + /*s8z24_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; case PIPE_FORMAT_Z24S8_UNORM: - /*z24s8_put_tile_rgba(ps, x, y, w, h, p);*/ + /*z24s8_put_tile_rgba(ps, map, x, y, w, h, p);*/ break; default: assert(0); } + + pipe_surface_unmap(ps); } diff --git a/src/mesa/pipe/xlib/xm_api.c b/src/mesa/pipe/xlib/xm_api.c index 168eba0784..03985eab5a 100644 --- a/src/mesa/pipe/xlib/xm_api.c +++ b/src/mesa/pipe/xlib/xm_api.c @@ -1247,22 +1247,11 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, GLint *bytesPerValue, void **buffer ) { - struct pipe_surface *surf - = st_get_framebuffer_surface(b->stfb, ST_SURFACE_DEPTH); - if (surf) { - *width = surf->width; - *height = surf->pitch; - *bytesPerValue = surf->cpp; - *buffer = surf->map; - return GL_TRUE; - } - else { - *width = 0; - *height = 0; - *bytesPerValue = 0; - *buffer = 0; - return GL_FALSE; - } + *width = 0; + *height = 0; + *bytesPerValue = 0; + *buffer = 0; + return GL_FALSE; } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index cf2e9db51c..73cd7db18d 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -59,6 +59,7 @@ void st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) { + struct pipe_context *pipe = ctx->st->pipe; struct st_renderbuffer *acc_strb = st_renderbuffer(rb); struct pipe_surface *acc_ps = acc_strb->surface; const GLint xpos = ctx->DrawBuffer->_Xmin; @@ -69,102 +70,17 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) const GLfloat g = ctx->Accum.ClearColor[1]; const GLfloat b = ctx->Accum.ClearColor[2]; const GLfloat a = ctx->Accum.ClearColor[3]; + GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + int i; - (void) pipe_surface_map(acc_ps); - - switch (acc_ps->format) { - case PIPE_FORMAT_R16G16B16A16_SNORM: - { - const short sr = (short) (32767 * r); - const short sg = (short) (32767 * g); - const short sb = (short) (32767 * b); - const short sa = (short) (32767 * a); - short *acc = ((short *) acc_ps->map) - + (ypos * acc_ps->pitch + xpos) * 4; - int i, j; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - acc[j*4+0] = sr; - acc[j*4+1] = sg; - acc[j*4+2] = sb; - acc[j*4+3] = sa; - } - acc += acc_ps->pitch * 4; - } - } - break; - default: - assert(0); + for (i = 0; i < width * height; i++) { + accBuf[i*4+0] = r; + accBuf[i*4+1] = g; + accBuf[i*4+2] = b; + accBuf[i*4+3] = a; } - pipe_surface_unmap(acc_ps); -} - - -/** Get block of values from accum buffer, converting to float */ -static void -get_accum_tile(struct pipe_context *pipe, - struct pipe_surface *acc_surf, - int xpos, int ypos, int width, int height, - float *buf) -{ - switch (acc_surf->format) { - case PIPE_FORMAT_R16G16B16A16_SNORM: - { - const short *acc = ((const short *) acc_surf->map) - + (ypos * acc_surf->pitch + xpos) * 4; - int i, j; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - buf[j*4+0] = SHORT_TO_FLOAT(acc[j*4+0]); - buf[j*4+1] = SHORT_TO_FLOAT(acc[j*4+1]); - buf[j*4+2] = SHORT_TO_FLOAT(acc[j*4+2]); - buf[j*4+3] = SHORT_TO_FLOAT(acc[j*4+3]); - } - acc += acc_surf->pitch * 4; - buf += width * 4; - } - } - break; - default: - assert(0); - } -} - - -/** Put block of values into accum buffer, converting from float */ -static void -put_accum_tile(struct pipe_context *pipe, - struct pipe_surface *acc_surf, - int xpos, int ypos, int width, int height, - const float *buf) -{ - switch (acc_surf->format) { - case PIPE_FORMAT_R16G16B16A16_SNORM: - { - short *acc = ((short *) acc_surf->map) - + (ypos * acc_surf->pitch + xpos) * 4; - int i, j; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - short r, g, b, a; - UNCLAMPED_FLOAT_TO_SHORT(r, buf[j*4+0]); - UNCLAMPED_FLOAT_TO_SHORT(g, buf[j*4+1]); - UNCLAMPED_FLOAT_TO_SHORT(b, buf[j*4+2]); - UNCLAMPED_FLOAT_TO_SHORT(a, buf[j*4+3]); - acc[j*4+0] = r; - acc[j*4+1] = g; - acc[j*4+2] = b; - acc[j*4+3] = a; - } - acc += acc_surf->pitch * 4; - buf += width * 4; - } - } - break; - default: - assert(0); - } + pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); } @@ -179,19 +95,15 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - (void) pipe_surface_map(acc_ps); - - get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { accBuf[i] = accBuf[i] * scale + bias; } - put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); free(accBuf); - - pipe_surface_unmap(acc_ps); } @@ -201,30 +113,23 @@ accum_accum(struct pipe_context *pipe, GLfloat value, struct pipe_surface *acc_ps, struct pipe_surface *color_ps) { - ubyte *colorMap, *accMap; GLfloat *colorBuf, *accBuf; GLint i; colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - colorMap = pipe_surface_map(color_ps); - accMap = pipe_surface_map(acc_ps); - pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf); - get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { accBuf[i] = accBuf[i] + colorBuf[i] * value; } - put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); free(colorBuf); free(accBuf); - - pipe_surface_unmap(color_ps); - pipe_surface_unmap(acc_ps); } @@ -239,21 +144,15 @@ accum_load(struct pipe_context *pipe, GLfloat value, buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - (void) pipe_surface_map(color_ps); - (void) pipe_surface_map(acc_ps); - pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf); for (i = 0; i < 4 * width * height; i++) { buf[i] = buf[i] * value; } - put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, buf); + pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf); free(buf); - - pipe_surface_unmap(color_ps); - pipe_surface_unmap(acc_ps); } @@ -270,10 +169,7 @@ accum_return(GLcontext *ctx, GLfloat value, abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - (void) pipe_surface_map(color_ps); - (void) pipe_surface_map(acc_ps); - - get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, abuf); + pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); @@ -297,9 +193,6 @@ accum_return(GLcontext *ctx, GLfloat value, free(abuf); if (cbuf) free(cbuf); - - pipe_surface_unmap(color_ps); - pipe_surface_unmap(acc_ps); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 2db12c653b..5ea2f08b8a 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1261,15 +1261,9 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - (void) pipe_surface_map(psRead); - (void) pipe_surface_map(psTex); - pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf); pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf); - pipe_surface_unmap(psRead); - pipe_surface_unmap(psTex); - free(buf); } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index bc0f26ffb0..2d6b3fc749 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -97,9 +97,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, return GL_FALSE; } - /* loop here since mapping is refcounted */ - while (strb->surface->map) - pipe_surface_unmap(strb->surface); if (strb->surface->buffer) pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer, NULL); diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index b0c9275c6f..585fe04dee 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -179,8 +179,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (!strb) return; - pipe_surface_map(strb->surface); - if (format == GL_RGBA && type == GL_FLOAT) { /* write tile(row) directly into user's buffer */ df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width, @@ -229,8 +227,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - - pipe_surface_unmap(strb->surface); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 773fc0012e..19274570a1 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1063,15 +1063,13 @@ fallback_copy_texsubimage(GLcontext *ctx, dest_surf = pipe->get_tex_surface(pipe, pt, face, level, destZ); - (void) pipe_surface_map(dest_surf); - (void) pipe_surface_map(src_surf); - /* buffer for one row */ data = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); /* do copy row by row */ for (row = 0; row < height; row++) { - pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data); + pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, + data); /* XXX we're ignoring convolution for now */ if (ctx->_ImageTransferState) { @@ -1080,14 +1078,11 @@ fallback_copy_texsubimage(GLcontext *ctx, width, (GLfloat (*)[4])data); } - pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data); + pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, + data); destY += yStep; } - - (void) pipe_surface_unmap(dest_surf); - (void) pipe_surface_unmap(src_surf); - free(data); } -- cgit v1.2.3 From 2014e0bacbd2661bf98d084120a109b1c0bf0df2 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Mon, 14 Jan 2008 16:17:01 +0100 Subject: Remove pipe->get/put_tile_rgba. pipe_get/put_tile_rgba() now use pipe->get/put_tile internally. Also simplify the _get/put_tile_rgba() helper functions and clean up some inconsitencies in them. --- src/mesa/pipe/i915simple/i915_surface.c | 2 - src/mesa/pipe/i965simple/brw_surface.c | 2 - src/mesa/pipe/p_context.h | 5 - src/mesa/pipe/softpipe/sp_surface.c | 2 - src/mesa/pipe/softpipe/sp_tile_cache.c | 25 +- src/mesa/pipe/util/p_tile.c | 585 +++++++++++------------------- src/mesa/state_tracker/st_cb_accum.c | 23 +- src/mesa/state_tracker/st_cb_drawpixels.c | 5 +- src/mesa/state_tracker/st_cb_readpixels.c | 3 +- src/mesa/state_tracker/st_cb_texture.c | 7 +- 10 files changed, 245 insertions(+), 414 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index 4e1b0929ee..e3c3cdd2e4 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -240,8 +240,6 @@ i915_init_surface_functions(struct i915_context *i915) i915->pipe.get_tex_surface = i915_get_tex_surface; i915->pipe.get_tile = pipe_get_tile_raw; i915->pipe.put_tile = pipe_put_tile_raw; - i915->pipe.get_tile_rgba = pipe_get_tile_rgba; - i915->pipe.put_tile_rgba = pipe_put_tile_rgba; i915->pipe.surface_data = i915_surface_data; i915->pipe.surface_copy = i915_surface_copy; diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c index 850423bdd5..4eacbdf82b 100644 --- a/src/mesa/pipe/i965simple/brw_surface.c +++ b/src/mesa/pipe/i965simple/brw_surface.c @@ -239,8 +239,6 @@ brw_init_surface_functions(struct brw_context *brw) brw->pipe.get_tex_surface = brw_get_tex_surface; brw->pipe.get_tile = pipe_get_tile_raw; brw->pipe.put_tile = pipe_put_tile_raw; - brw->pipe.get_tile_rgba = pipe_get_tile_rgba; - brw->pipe.put_tile_rgba = pipe_put_tile_rgba; brw->pipe.surface_data = brw_surface_data; brw->pipe.surface_copy = brw_surface_copy; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 1a1f4f4e78..25b5dc35e4 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -192,11 +192,6 @@ struct pipe_context { struct pipe_surface *ps, uint x, uint y, uint w, uint h, const void *p, int src_stride); - /* XXX temporary here, move these to softpipe */ - void (*get_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps, - uint x, uint y, uint w, uint h, float *p); - void (*put_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps, - uint x, uint y, uint w, uint h, const float *p); /* diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index b44ba3e957..6c080d5b5c 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -252,8 +252,6 @@ sp_init_surface_functions(struct softpipe_context *sp) { sp->pipe.get_tile = pipe_get_tile_raw; sp->pipe.put_tile = pipe_put_tile_raw; - sp->pipe.get_tile_rgba = pipe_get_tile_rgba; - sp->pipe.put_tile_rgba = pipe_put_tile_rgba; sp->pipe.surface_data = sp_surface_data; sp->pipe.surface_copy = sp_surface_copy; diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c index d6f60807e6..6515ce668c 100644 --- a/src/mesa/pipe/softpipe/sp_tile_cache.c +++ b/src/mesa/pipe/softpipe/sp_tile_cache.c @@ -34,6 +34,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" +#include "pipe/util/p_tile.h" #include "sp_context.h" #include "sp_surface.h" #include "sp_tile_cache.h" @@ -369,9 +370,9 @@ sp_flush_tile_cache(struct softpipe_context *softpipe, tile->data.depth32, 0/*STRIDE*/); } else { - pipe->put_tile_rgba(pipe, ps, - tile->x, tile->y, TILE_SIZE, TILE_SIZE, - (float *) tile->data.color); + pipe_put_tile_rgba(pipe, ps, + tile->x, tile->y, TILE_SIZE, TILE_SIZE, + (float *) tile->data.color); } tile->x = tile->y = -1; /* mark as empty */ inuse++; @@ -418,9 +419,9 @@ sp_get_cached_tile(struct softpipe_context *softpipe, tile->data.depth32, 0/*STRIDE*/); } else { - pipe->put_tile_rgba(pipe, ps, - tile->x, tile->y, TILE_SIZE, TILE_SIZE, - (float *) tile->data.color); + pipe_put_tile_rgba(pipe, ps, + tile->x, tile->y, TILE_SIZE, TILE_SIZE, + (float *) tile->data.color); } } @@ -445,9 +446,9 @@ sp_get_cached_tile(struct softpipe_context *softpipe, tile->data.depth32, 0/*STRIDE*/); } else { - pipe->get_tile_rgba(pipe, ps, - tile->x, tile->y, TILE_SIZE, TILE_SIZE, - (float *) tile->data.color); + pipe_get_tile_rgba(pipe, ps, + tile->x, tile->y, TILE_SIZE, TILE_SIZE, + (float *) tile->data.color); } } } @@ -514,9 +515,9 @@ sp_get_cached_tile_tex(struct pipe_context *pipe, } /* get tile from the surface (view into texture) */ - pipe->get_tile_rgba(pipe, tc->tex_surf, - tile_x, tile_y, TILE_SIZE, TILE_SIZE, - (float *) tile->data.color); + pipe_get_tile_rgba(pipe, tc->tex_surf, + tile_x, tile_y, TILE_SIZE, TILE_SIZE, + (float *) tile->data.color); tile->x = tile_x; tile->y = tile_y; tile->z = z; diff --git a/src/mesa/pipe/util/p_tile.c b/src/mesa/pipe/util/p_tile.c index f2e19f19dc..85a863db8a 100644 --- a/src/mesa/pipe/util/p_tile.c +++ b/src/mesa/pipe/util/p_tile.c @@ -125,68 +125,46 @@ pipe_put_tile_raw(struct pipe_context *pipe, /*** PIPE_FORMAT_A8R8G8B8_UNORM ***/ static void -a8r8g8b8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +a8r8g8b8_get_tile_rgba(unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const unsigned *src - = ((const unsigned *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_A8R8G8B8_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - const unsigned pixel = src[j]; + for (j = 0; j < w; j++, pRow += 4) { + const unsigned pixel = *src++; pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff); pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff); pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff); pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff); - pRow += 4; } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } static void -a8r8g8b8_put_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - const float *p) +a8r8g8b8_put_tile_rgba(unsigned *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) { - unsigned *dst - = ((unsigned *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_A8R8G8B8_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { const float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, pRow += 4) { unsigned r, g, b, a; UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]); UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]); UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]); UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]); - dst[j] = (a << 24) | (r << 16) | (g << 8) | b; - pRow += 4; + *dst++ = (a << 24) | (r << 16) | (g << 8) | b; } - dst += ps->pitch; - p += w0 * 4; + p += src_stride; } } @@ -194,68 +172,46 @@ a8r8g8b8_put_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_B8G8R8A8_UNORM ***/ static void -b8g8r8a8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +b8g8r8a8_get_tile_rgba(unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const unsigned *src - = ((const unsigned *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_B8G8R8A8_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - const unsigned pixel = src[j]; + for (j = 0; j < w; j++, pRow += 4) { + const unsigned pixel = *src++; pRow[0] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff); pRow[1] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff); pRow[2] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff); pRow[3] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff); - pRow += 4; } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } static void -b8g8r8a8_put_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - const float *p) +b8g8r8a8_put_tile_rgba(unsigned *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) { - unsigned *dst - = ((unsigned *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_B8G8R8A8_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { const float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, pRow += 4) { unsigned r, g, b, a; UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]); UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]); UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]); UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]); - dst[j] = (b << 24) | (g << 16) | (r << 8) | a; - pRow += 4; + *dst++ = (b << 24) | (g << 16) | (r << 8) | a; } - dst += ps->pitch; - p += w0 * 4; + p += src_stride; } } @@ -263,28 +219,23 @@ b8g8r8a8_put_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_A1R5G5B5_UNORM ***/ static void -a1r5g5b5_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +a1r5g5b5_get_tile_rgba(ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ushort *src - = ((const ushort *) map) - + y * ps->pitch + x; unsigned i, j; - assert(ps->format == PIPE_FORMAT_A1R5G5B5_UNORM); - for (i = 0; i < h; i++) { - for (j = 0; j < w; j++) { - const ushort pixel = src[j]; - p[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f); - p[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f); - p[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); - p[3] = ((pixel >> 15) ) * 1.0f; - p += 4; + float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + const ushort pixel = *src++; + pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f); + pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f); + pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); + pRow[3] = ((pixel >> 15) ) * 1.0f; } - src += ps->pitch; + p += dst_stride; } } @@ -292,28 +243,23 @@ a1r5g5b5_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_A4R4G4B4_UNORM ***/ static void -a4r4g4b4_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +a4r4g4b4_get_tile_rgba(ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ushort *src - = ((const ushort *) map) - + y * ps->pitch + x; unsigned i, j; - assert(ps->format == PIPE_FORMAT_A4R4G4B4_UNORM); - for (i = 0; i < h; i++) { - for (j = 0; j < w; j++) { - const ushort pixel = src[j]; - p[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f); - p[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f); - p[2] = ((pixel ) & 0xf) * (1.0f / 15.0f); - p[3] = ((pixel >> 12) ) * (1.0f / 15.0f); - p += 4; + float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + const ushort pixel = *src++; + pRow[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f); + pRow[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f); + pRow[2] = ((pixel ) & 0xf) * (1.0f / 15.0f); + pRow[3] = ((pixel >> 12) ) * (1.0f / 15.0f); } - src += ps->pitch; + p += dst_stride; } } @@ -321,60 +267,44 @@ a4r4g4b4_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_R5G6B5_UNORM ***/ static void -r5g6b5_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +r5g6b5_get_tile_rgba(ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ushort *src - = ((const ushort *) map) - + y * ps->pitch + x; unsigned i, j; - assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM); - for (i = 0; i < h; i++) { - for (j = 0; j < w; j++) { - const ushort pixel = src[j]; - p[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f); - p[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f); - p[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); - p[3] = 1.0f; - p += 4; + float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + const ushort pixel = *src++; + pRow[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f); + pRow[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f); + pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); + pRow[3] = 1.0f; } - src += ps->pitch; + p += dst_stride; } } static void -r5g5b5_put_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - const float *p) +r5g5b5_put_tile_rgba(ushort *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) { - ushort *dst - = ((ushort *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { const float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, pRow += 4) { uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0); uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0); uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0); - dst[j] = (r << 11) | (g << 5) | (b); - pRow += 4; + *dst++ = (r << 11) | (g << 5) | (b); } - dst += ps->pitch; - p += w0 * 4; + p += src_stride; } } @@ -386,33 +316,23 @@ r5g5b5_put_tile_rgba(struct pipe_surface *ps, * Return each Z value as four floats in [0,1]. */ static void -z16_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +z16_get_tile_rgba(ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ushort *src - = ((const ushort *) map) - + y * ps->pitch + x; const float scale = 1.0f / 65535.0f; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_Z16_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - pRow[j * 4 + 0] = - pRow[j * 4 + 1] = - pRow[j * 4 + 2] = - pRow[j * 4 + 3] = src[j] * scale; + for (j = 0; j < w; j++, pRow += 4) { + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = *src++ * scale; } - src += ps->pitch; - p += 4 * w0; + p += dst_stride; } } @@ -422,33 +342,22 @@ z16_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_U_L8 ***/ static void -l8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +l8_get_tile_rgba(ubyte *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ubyte *src - = ((const ubyte *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_U_L8); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, src++, pRow += 4) { pRow[0] = pRow[1] = - pRow[2] = UBYTE_TO_FLOAT(src[j]); + pRow[2] = UBYTE_TO_FLOAT(*src); pRow[3] = 1.0; - pRow += 4; } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } @@ -456,33 +365,22 @@ l8_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_U_A8 ***/ static void -a8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +a8_get_tile_rgba(ubyte *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ubyte *src - = ((const ubyte *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_U_A8); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, src++, pRow += 4) { pRow[0] = pRow[1] = pRow[2] = 0.0; - pRow[3] = UBYTE_TO_FLOAT(src[j]); - pRow += 4; + pRow[3] = UBYTE_TO_FLOAT(*src); } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } @@ -490,72 +388,43 @@ a8_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_R16G16B16A16_SNORM ***/ static void -r16g16b16a16_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +r16g16b16a16_get_tile_rgba(short *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const short *src - = ((const short *) map) - + (y * ps->pitch + x) * 4; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_R16G16B16A16_SNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - const short *pixel = src; - for (j = 0; j < w; j++) { - pRow[0] = SHORT_TO_FLOAT(pixel[0]); - pRow[1] = SHORT_TO_FLOAT(pixel[1]); - pRow[2] = SHORT_TO_FLOAT(pixel[2]); - pRow[3] = SHORT_TO_FLOAT(pixel[3]); - pRow += 4; - pixel += 4; + for (j = 0; j < w; j++, src += 4, pRow += 4) { + pRow[0] = SHORT_TO_FLOAT(src[0]); + pRow[1] = SHORT_TO_FLOAT(src[1]); + pRow[2] = SHORT_TO_FLOAT(src[2]); + pRow[3] = SHORT_TO_FLOAT(src[3]); } - src += ps->pitch * 4; - p += w0 * 4; + p += dst_stride; } } static void -r16g16b16a16_put_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - const float *p) +r16g16b16a16_put_tile_rgba(short *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) { - short *dst - = ((short *) map) - + (y * ps->pitch + x) * 4; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_R16G16B16A16_SNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { const float *pRow = p; - for (j = 0; j < w; j++) { - short r, g, b, a; - UNCLAMPED_FLOAT_TO_SHORT(r, pRow[0]); - UNCLAMPED_FLOAT_TO_SHORT(g, pRow[1]); - UNCLAMPED_FLOAT_TO_SHORT(b, pRow[2]); - UNCLAMPED_FLOAT_TO_SHORT(a, pRow[3]); - dst[j*4+0] = r; - dst[j*4+1] = g; - dst[j*4+2] = b; - dst[j*4+3] = a; - pRow += 4; + for (j = 0; j < w; j++, dst += 4, pRow += 4) { + UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]); + UNCLAMPED_FLOAT_TO_SHORT(dst[1], pRow[1]); + UNCLAMPED_FLOAT_TO_SHORT(dst[2], pRow[2]); + UNCLAMPED_FLOAT_TO_SHORT(dst[3], pRow[3]); } - dst += ps->pitch * 4; - p += w0 * 4; + p += src_stride; } } @@ -564,33 +433,22 @@ r16g16b16a16_put_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_U_I8 ***/ static void -i8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +i8_get_tile_rgba(ubyte *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ubyte *src - = ((const ubyte *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_U_I8); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { + for (j = 0; j < w; j++, src++, pRow += 4) { pRow[0] = pRow[1] = pRow[2] = - pRow[3] = UBYTE_TO_FLOAT(src[j]); - pRow += 4; + pRow[3] = UBYTE_TO_FLOAT(*src); } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } @@ -598,34 +456,23 @@ i8_get_tile_rgba(struct pipe_surface *ps, /*** PIPE_FORMAT_U_A8_L8 ***/ static void -a8_l8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +a8_l8_get_tile_rgba(ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const ushort *src - = ((const ushort *) map) - + y * ps->pitch + x; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_U_A8_L8); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - const ushort p = src[j]; + for (j = 0; j < w; j++, pRow += 4) { + ushort p = *src++; pRow[0] = pRow[1] = pRow[2] = UBYTE_TO_FLOAT(p & 0xff); pRow[3] = UBYTE_TO_FLOAT(p >> 8); - pRow += 4; } - src += ps->pitch; - p += w0 * 4; + p += dst_stride; } } @@ -638,33 +485,23 @@ a8_l8_get_tile_rgba(struct pipe_surface *ps, * Return each Z value as four floats in [0,1]. */ static void -z32_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +z32_get_tile_rgba(unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const uint *src - = ((const uint *) map) - + y * ps->pitch + x; const double scale = 1.0 / (double) 0xffffffff; unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_Z16_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - pRow[j * 4 + 0] = - pRow[j * 4 + 1] = - pRow[j * 4 + 2] = - pRow[j * 4 + 3] = (float) (scale * src[j]); + for (j = 0; j < w; j++, pRow += 4) { + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = (float) (*src++ * scale); } - src += ps->pitch; - p += 4 * w0; + p += dst_stride; } } @@ -675,33 +512,23 @@ z32_get_tile_rgba(struct pipe_surface *ps, * Return Z component as four float in [0,1]. Stencil part ignored. */ static void -s8z24_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +s8z24_get_tile_rgba(unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const uint *src - = ((const uint *) map) - + y * ps->pitch + x; const double scale = 1.0 / ((1 << 24) - 1); unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_S8Z24_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - pRow[j * 4 + 0] = - pRow[j * 4 + 1] = - pRow[j * 4 + 2] = - pRow[j * 4 + 3] = (float) (scale * (src[j] & 0xffffff)); + for (j = 0; j < w; j++, pRow += 4) { + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = (float) (scale * (*src++ & 0xffffff)); } - src += ps->pitch; - p += 4 * w0; + p += dst_stride; } } @@ -712,33 +539,23 @@ s8z24_get_tile_rgba(struct pipe_surface *ps, * Return Z component as four float in [0,1]. Stencil part ignored. */ static void -z24s8_get_tile_rgba(struct pipe_surface *ps, - void *map, - unsigned x, unsigned y, unsigned w, unsigned h, - float *p) +z24s8_get_tile_rgba(unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) { - const uint *src - = ((const uint *) map) - + y * ps->pitch + x; const double scale = 1.0 / ((1 << 24) - 1); unsigned i, j; - unsigned w0 = w; - - assert(ps->format == PIPE_FORMAT_Z24S8_UNORM); - - if (pipe_clip_tile(x, y, &w, &h, ps)) - return; for (i = 0; i < h; i++) { float *pRow = p; - for (j = 0; j < w; j++) { - pRow[j * 4 + 0] = - pRow[j * 4 + 1] = - pRow[j * 4 + 2] = - pRow[j * 4 + 3] = (float) (scale * (src[j] >> 8)); + for (j = 0; j < w; j++, pRow += 4) { + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = (float) (scale * (*src++ >> 8)); } - src += ps->pitch; - p += 4 * w0; + p += dst_stride; } } @@ -749,56 +566,67 @@ pipe_get_tile_rgba(struct pipe_context *pipe, uint x, uint y, uint w, uint h, float *p) { - void *map = pipe_surface_map(ps); + unsigned dst_stride = w * 4; + void *packed; + + if (pipe_clip_tile(x, y, &w, &h, ps)) + return; + + packed = MALLOC(h * w * ps->cpp); + + if (!packed) + return; + + pipe->get_tile(pipe, ps, x, y, w, h, packed, w * ps->cpp); switch (ps->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: - a8r8g8b8_get_tile_rgba(ps, map, x, y, w, h, p); + a8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_B8G8R8A8_UNORM: - b8g8r8a8_get_tile_rgba(ps, map, x, y, w, h, p); + b8g8r8a8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_A1R5G5B5_UNORM: - a1r5g5b5_get_tile_rgba(ps, map, x, y, w, h, p); + a1r5g5b5_get_tile_rgba((ushort *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_A4R4G4B4_UNORM: - a4r4g4b4_get_tile_rgba(ps, map, x, y, w, h, p); + a4r4g4b4_get_tile_rgba((ushort *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_R5G6B5_UNORM: - r5g6b5_get_tile_rgba(ps, map, x, y, w, h, p); + r5g6b5_get_tile_rgba((ushort *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_U_L8: - l8_get_tile_rgba(ps, map, x, y, w, h, p); + l8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_U_A8: - a8_get_tile_rgba(ps, map, x, y, w, h, p); + a8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_U_I8: - i8_get_tile_rgba(ps, map, x, y, w, h, p); + i8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_U_A8_L8: - a8_l8_get_tile_rgba(ps, map, x, y, w, h, p); + a8_l8_get_tile_rgba((ushort *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_get_tile_rgba(ps, map, x, y, w, h, p); + r16g16b16a16_get_tile_rgba((short *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_Z16_UNORM: - z16_get_tile_rgba(ps, map, x, y, w, h, p); + z16_get_tile_rgba((ushort *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_Z32_UNORM: - z32_get_tile_rgba(ps, map, x, y, w, h, p); + z32_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_S8Z24_UNORM: - s8z24_get_tile_rgba(ps, map, x, y, w, h, p); + s8z24_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride); break; case PIPE_FORMAT_Z24S8_UNORM: - z24s8_get_tile_rgba(ps, map, x, y, w, h, p); + z24s8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride); break; default: assert(0); } - pipe_surface_unmap(ps); + FREE(packed); } @@ -808,53 +636,64 @@ pipe_put_tile_rgba(struct pipe_context *pipe, uint x, uint y, uint w, uint h, const float *p) { - void *map = pipe_surface_map(ps); + unsigned src_stride = w * 4; + void *packed; + + if (pipe_clip_tile(x, y, &w, &h, ps)) + return; + + packed = MALLOC(h * w * ps->cpp); + + if (!packed) + return; switch (ps->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: - a8r8g8b8_put_tile_rgba(ps, map, x, y, w, h, p); + a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_B8G8R8A8_UNORM: - b8g8r8a8_put_tile_rgba(ps, map, x, y, w, h, p); + b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_A1R5G5B5_UNORM: - /*a1r5g5b5_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_R5G6B5_UNORM: - r5g5b5_put_tile_rgba(ps, map, x, y, w, h, p); + r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_R8G8B8A8_UNORM: break; case PIPE_FORMAT_U_L8: - /*l8_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_U_A8: - /*a8_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_U_I8: - /*i8_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_U_A8_L8: - /*a8_l8_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*a8_l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_put_tile_rgba(ps, map, x, y, w, h, p); + r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_Z16_UNORM: - /*z16_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*z16_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_Z32_UNORM: - /*z32_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_S8Z24_UNORM: - /*s8z24_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_Z24S8_UNORM: - /*z24s8_put_tile_rgba(ps, map, x, y, w, h, p);*/ + /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; default: assert(0); } - pipe_surface_unmap(ps); + pipe->put_tile(pipe, ps, x, y, w, h, packed, w * ps->cpp); + + FREE(packed); } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 73cd7db18d..3a3bf9016d 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -43,6 +43,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" +#include "pipe/util/p_tile.h" #define UNCLAMPED_FLOAT_TO_SHORT(us, f) \ @@ -80,7 +81,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) accBuf[i*4+3] = a; } - pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); } @@ -95,13 +96,13 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { accBuf[i] = accBuf[i] * scale + bias; } - pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); free(accBuf); } @@ -119,14 +120,14 @@ accum_accum(struct pipe_context *pipe, GLfloat value, colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf); - pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf); + pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { accBuf[i] = accBuf[i] + colorBuf[i] * value; } - pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); + pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); free(colorBuf); free(accBuf); @@ -144,13 +145,13 @@ accum_load(struct pipe_context *pipe, GLfloat value, buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf); + pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf); for (i = 0; i < 4 * width * height; i++) { buf[i] = buf[i] * value; } - pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf); + pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf); free(buf); } @@ -169,11 +170,11 @@ accum_return(GLcontext *ctx, GLfloat value, abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf); + pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf); + pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf); } for (i = 0; i < width * height; i++) { @@ -188,7 +189,7 @@ accum_return(GLcontext *ctx, GLfloat value, } } - pipe->put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf); + pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf); free(abuf); if (cbuf) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 5ea2f08b8a..be5434f91b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -56,6 +56,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" +#include "pipe/util/p_tile.h" #include "shader/prog_instruction.h" @@ -1261,8 +1262,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf); - pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf); + pipe_get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf); + pipe_put_tile_rgba(pipe, psTex, 0, 0, width, height, buf); free(buf); } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 585fe04dee..a1bbb3a831 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -40,6 +40,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" +#include "pipe/util/p_tile.h" #include "st_context.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" @@ -210,7 +211,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { - pipe->get_tile_rgba(pipe, strb->surface, x, y, width, 1, df); + pipe_get_tile_rgba(pipe, strb->surface, x, y, width, 1, df); y += yStep; df += dfStride; if (!dfStride) { diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 19274570a1..ba0950e295 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -45,6 +45,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" +#include "pipe/util/p_tile.h" #define DBG if (0) printf @@ -1068,8 +1069,7 @@ fallback_copy_texsubimage(GLcontext *ctx, /* do copy row by row */ for (row = 0; row < height; row++) { - pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, - data); + pipe_get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data); /* XXX we're ignoring convolution for now */ if (ctx->_ImageTransferState) { @@ -1078,8 +1078,7 @@ fallback_copy_texsubimage(GLcontext *ctx, width, (GLfloat (*)[4])data); } - pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, - data); + pipe_put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data); destY += yStep; } -- cgit v1.2.3 From eff70f67c558c90c5419b43729a6dc8a9a8c47ec Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 11:11:08 -0700 Subject: Cell: update surface map code to match recent changes in pipe_surface struct --- src/mesa/pipe/cell/ppu/cell_context.h | 2 ++ src/mesa/pipe/cell/ppu/cell_spu.c | 6 +++--- src/mesa/pipe/cell/ppu/cell_state_surface.c | 21 +++++++++++---------- src/mesa/pipe/cell/ppu/cell_surface.c | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index 94d8f08da8..43e32a8abb 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -78,6 +78,8 @@ struct cell_context struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS]; + ubyte *zbuf_map; uint dirty; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 88a620e669..77ddd9ccbf 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -168,8 +168,8 @@ test_spus(struct cell_context *cell) sleep(2); for (i = 0; i < cell->num_spus; i++) { - cell_global.command[i].fb.color_start = csurf->map; - cell_global.command[i].fb.depth_start = zsurf ? zsurf->map : NULL; + cell_global.command[i].fb.color_start = cell->cbuf_map[0]; + cell_global.command[i].fb.depth_start = cell->zbuf_map; cell_global.command[i].fb.width = csurf->width; cell_global.command[i].fb.height = csurf->height; cell_global.command[i].fb.color_format = PIPE_FORMAT_A8R8G8B8_UNORM; @@ -186,7 +186,7 @@ test_spus(struct cell_context *cell) finish_all(cell->num_spus); { - uint *b = (uint*) csurf->map; + uint *b = (uint*) cell->cbuf_map[0]; printf("PPU: Clear results: 0x%x 0x%x 0x%x 0x%x\n", b[0], b[1000], b[2000], b[3000]); } diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c index ff8fdbd334..9bf3c339d2 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -39,6 +39,7 @@ cell_set_framebuffer_state(struct pipe_context *pipe, { struct cell_context *cell = cell_context(pipe); + /* XXX revisit this memcmp! */ if (memcmp(&cell->framebuffer, fb, sizeof(*fb))) { struct pipe_surface *csurf = fb->cbufs[0]; struct pipe_surface *zsurf = fb->zbuf; @@ -48,26 +49,26 @@ cell_set_framebuffer_state(struct pipe_context *pipe, /* unmap old surfaces */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { - if (cell->framebuffer.cbufs[i] && - cell->framebuffer.cbufs[i]->map) { + if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) { pipe_surface_unmap(cell->framebuffer.cbufs[i]); + cell->cbuf_map[i] = NULL; } } - if (cell->framebuffer.zbuf && - cell->framebuffer.zbuf->map) { + if (cell->framebuffer.zbuf && cell->zbuf_map) { pipe_surface_unmap(cell->framebuffer.zbuf); + cell->zbuf_map = NULL; } /* update my state */ cell->framebuffer = *fb; /* map new surfaces */ - if (csurf && !csurf->map) - pipe_surface_map(csurf); + if (csurf) + cell->cbuf_map[0] = pipe_surface_map(csurf); - if (zsurf && !zsurf->map) - pipe_surface_map(zsurf); + if (zsurf) + cell->zbuf_map = pipe_surface_map(zsurf); #if 0 for (i = 0; i < cell->num_spus; i++) { @@ -87,9 +88,9 @@ cell_set_framebuffer_state(struct pipe_context *pipe, struct cell_command_framebuffer *fb = cell_batch_alloc(cell, sizeof(*fb)); fb->opcode = CELL_CMD_FRAMEBUFFER; - fb->color_start = csurf->map; + fb->color_start = cell->cbuf_map[0]; fb->color_format = csurf->format; - fb->depth_start = zsurf ? zsurf->map : NULL; + fb->depth_start = cell->zbuf_map; fb->depth_format = zsurf ? zsurf->format : PIPE_FORMAT_NONE; fb->width = csurf->width; fb->height = csurf->height; diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index ea1c2bd644..53c5325ddd 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -50,8 +50,8 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, uint i; uint surfIndex; - if (!ps->map) - pipe_surface_map(ps); + if (!cell->cbuf_map[0]) + cell->cbuf_map[0] = pipe_surface_map(ps); if (ps == cell->framebuffer.zbuf) { surfIndex = 1; -- cgit v1.2.3 From c28b112ce37022aa6e00ac4557ad6fe5a57ae578 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 16:37:13 -0700 Subject: clamp colors during float->int conversion --- src/mesa/pipe/cell/spu/spu_tri.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c index b42b321c32..ddd5e662d2 100644 --- a/src/mesa/pipe/cell/spu/spu_tri.c +++ b/src/mesa/pipe/cell/spu/spu_tri.c @@ -236,6 +236,10 @@ pack_color(const float color[4]) uint g = (uint) (color[1] * 255.0); uint b = (uint) (color[2] * 255.0); uint a = (uint) (color[3] * 255.0); + r = MIN2(r, 255); + g = MIN2(g, 255); + b = MIN2(b, 255); + a = MIN2(a, 255); switch (spu.fb.color_format) { case PIPE_FORMAT_A8R8G8B8_UNORM: return (a << 24) | (r << 16) | (g << 8) | b; -- cgit v1.2.3 From f20cb1d81b120c8de9b00e2fb523e2367b25e875 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 16:39:26 -0700 Subject: Cell: after sending a batch, wait for a DMA completion signal. This fixes sporadic rendering glitches. Using a mailbox msg for now, until spe_mfcio_tag_status_read() or similar is found to work. --- src/mesa/pipe/cell/common.h | 2 ++ src/mesa/pipe/cell/ppu/cell_batch.c | 17 ++++++++++++++--- src/mesa/pipe/cell/spu/spu_main.c | 23 +++++++++++++++++++++-- src/mesa/pipe/cell/spu/spu_tile.c | 4 +++- 4 files changed, 40 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 74b3d3cbee..29d1cbedda 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -65,6 +65,8 @@ #define CELL_NUM_BATCH_BUFFERS 2 #define CELL_BATCH_BUFFER_SIZE 1024 /**< 16KB would be the max */ +#define CELL_BATCH_FINISHED 0x1234 /**< mbox message */ + /** * Tell SPUs about the framebuffer size, location diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index 45d49d0465..45f62ac3ad 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -43,16 +43,27 @@ cell_batch_flush(struct cell_context *cell) assert(batch < CELL_NUM_BATCH_BUFFERS); - /*printf("cell_batch_dispatch: buf %u, size %u\n", batch, size);*/ - + /* + printf("cell_batch_dispatch: buf %u at %p, size %u\n", + batch, &cell->batch_buffer[batch][0], size); + */ + cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16); for (i = 0; i < cell->num_spus; i++) { send_mbox_message(cell_global.spe_contexts[i], cmd_word); } - /* XXX wait on DMA xfer of prev buffer to complete */ + /* XXX wait for the DMX xfer to finish. + * Using mailboxes here is temporary. + * Ideally, we want to use a PPE-side DMA status check function... + */ + for (i = 0; i < cell->num_spus; i++) { + uint k = wait_mbox_message(cell_global.spe_contexts[i]); + assert(k == CELL_BATCH_FINISHED); + } + /* next buffer */ cell->cur_batch = (batch + 1) % CELL_NUM_BATCH_BUFFERS; cell->batch_buffer_size[cell->cur_batch] = 0; /* empty */ diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 0aee2aa6f9..2727b03756 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -46,7 +46,7 @@ helpful headers: /opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h */ -static boolean Debug = TRUE; +static boolean Debug = FALSE; struct spu_global spu; @@ -106,7 +106,7 @@ really_clear_tiles(uint surfaceIndex) } } -#if 01 +#if 0 wait_on_mask(1 << TAG_SURFACE_CLEAR); #endif } @@ -165,6 +165,9 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear) #if 0 wait_on_mask(1 << TAG_SURFACE_CLEAR); #endif + + if (Debug) + printf("SPU %u: CLEAR SURF done\n", spu.init.id); } @@ -222,8 +225,10 @@ cmd_render(const struct cell_command_render *render) render->prim_type, render->num_verts, render->num_indexes); + /* printf(" bound: %g, %g .. %g, %g\n", render->xmin, render->ymin, render->xmax, render->ymax); + */ } ASSERT_ALIGN16(render->vertex_data); @@ -244,6 +249,7 @@ cmd_render(const struct cell_command_render *render) render->index_data, render->vertex_data, vertex_bytes, index_bytes); */ + ASSERT(vertex_bytes % 16 == 0); /* get vertex data from main memory */ mfc_get(vertex_data, /* dest */ (unsigned int) render->vertex_data, /* src */ @@ -252,6 +258,8 @@ cmd_render(const struct cell_command_render *render) 0, /* tid */ 0 /* rid */); + ASSERT(index_bytes % 16 == 0); + /* get index data from main memory */ mfc_get(indexes, /* dest */ (unsigned int) render->index_data, /* src */ @@ -330,6 +338,10 @@ cmd_render(const struct cell_command_render *render) wait_on_mask(1 << TAG_WRITE_TILE_Z); } } + + if (Debug) + printf("SPU %u: RENDER done\n", + spu.init.id); } @@ -406,6 +418,9 @@ cmd_batch(uint opcode) size = (size + 0xf) & ~0xf; + ASSERT(size % 16 == 0); + ASSERT((unsigned int) spu.init.batch_buffers[buf] % 16 == 0); + mfc_get(buffer, /* dest */ (unsigned int) spu.init.batch_buffers[buf], /* src */ size, @@ -414,6 +429,10 @@ cmd_batch(uint opcode) 0 /* rid */); wait_on_mask(1 << TAG_BATCH_BUFFER); + /* send mbox message to indicate DMA completed */ + /* XXX temporary */ + spu_write_out_mbox(CELL_BATCH_FINISHED); + for (pos = 0; pos < usize; /* no incr */) { switch (buffer[pos]) { case CELL_CMD_FRAMEBUFFER: diff --git a/src/mesa/pipe/cell/spu/spu_tile.c b/src/mesa/pipe/cell/spu/spu_tile.c index 99d779007e..1505cb322b 100644 --- a/src/mesa/pipe/cell/spu/spu_tile.c +++ b/src/mesa/pipe/cell/spu/spu_tile.c @@ -77,9 +77,11 @@ put_tile(uint tx, uint ty, const uint *tile, int tag, int zBuf) ASSERT(ty < spu.fb.height_tiles); ASSERT_ALIGN16(tile); /* - printf("put_tile: src: %p dst: 0x%x size: %d\n", + printf("SPU %u: put_tile: src: %p dst: 0x%x size: %d\n", + spu.init.id, tile, (unsigned int) dst, bytesPerTile); */ + mfc_put((void *) tile, /* src in local memory */ (unsigned int) dst, /* dst in main memory */ bytesPerTile, -- cgit v1.2.3 From b4e4fafb4157d416077e985c03204ed5bbe0f2e1 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 19:04:45 -0700 Subject: disable debug printf --- src/mesa/pipe/softpipe/sp_prim_vbuf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c index e9bd4dd5e4..055cb19f9a 100644 --- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c @@ -227,7 +227,9 @@ static void vbuf_flush_elements( struct draw_stage *stage ) struct vbuf_stage *vbuf = vbuf_stage( stage ); if (vbuf->nr_elements) { + /* fprintf(stderr, "%s (%d elts)\n", __FUNCTION__, vbuf->nr_elements); + */ /* Draw now or add to list of primitives??? */ -- cgit v1.2.3 From ac95fee4fffee77bb7bd798d094ed2e3a7c4019b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 19:12:46 -0700 Subject: Fix problems with vertex shaders and the private draw module. The CSO returned by pipe->create_vs_state() can't be passed to the private draw module. That was causing glRasterPos to blow up. Add a 'draw_shader' field to st_vertex_program for use with the private draw module. Change st_context->state.vs type from cso_vertex_shader to st_vertex_program. --- src/mesa/state_tracker/st_atom_shader.c | 23 +++++++++++++---------- src/mesa/state_tracker/st_cb_clear.c | 6 +++--- src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- src/mesa/state_tracker/st_cb_program.c | 11 +++++++---- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_debug.c | 4 ++-- src/mesa/state_tracker/st_draw.c | 12 ++++++++---- src/mesa/state_tracker/st_program.c | 6 ++---- src/mesa/state_tracker/st_program.h | 7 +++++-- 9 files changed, 43 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 2a182c7d9c..1ed9333556 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,6 +43,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" +#include "pipe/cso_cache/cso_cache.h" + #include "st_context.h" #include "st_cache.h" #include "st_atom.h" @@ -71,8 +73,8 @@ struct translated_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - /** Pointer to the translated, cached vertex shader */ - const struct cso_vertex_shader *vs; + /** Pointer to the translated vertex program */ + struct st_vertex_program *vp; struct translated_vertex_program *next; /**< next in linked list */ }; @@ -257,12 +259,13 @@ find_translated_vp(struct st_context *st, assert(stvp->Base.Base.NumInstructions > 1); - xvp->vs = st_translate_vertex_program(st, stvp, - xvp->output_to_slot, - xvp->tokens, - ST_MAX_SHADER_TOKENS); - assert(xvp->vs); - stvp->vs = NULL; /* don't want to use this */ + st_translate_vertex_program(st, stvp, + xvp->output_to_slot, + xvp->tokens, + ST_MAX_SHADER_TOKENS); + + assert(stvp->cso); + xvp->vp = stvp; /* translated VP is up to date now */ xvp->serialNo = stvp->serialNo; @@ -291,8 +294,8 @@ update_linkage( struct st_context *st ) xvp = find_translated_vp(st, stvp, stfp); st->vp = stvp; - st->state.vs = xvp->vs; - st->pipe->bind_vs_state(st->pipe, st->state.vs->data); + st->state.vs = xvp->vp; + st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data); st->fp = stfp; st->state.fs = stfp->fs; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 40319f4b4b..758d4a4086 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -208,7 +208,7 @@ make_vertex_shader(struct st_context *st) stvp = (struct st_vertex_program *) p; st_translate_vertex_program(st, stvp, NULL, stvp->tokens, ST_MAX_SHADER_TOKENS); - assert(stvp->vs); + assert(stvp->cso); return stvp; } @@ -350,7 +350,7 @@ clear_with_quad(GLcontext *ctx, if (!stvp) { stvp = make_vertex_shader(st); } - pipe->bind_vs_state(pipe, stvp->vs->data); + pipe->bind_vs_state(pipe, stvp->cso->data); } /* viewport state: viewport matching window dims */ @@ -376,7 +376,7 @@ clear_with_quad(GLcontext *ctx, pipe->bind_blend_state(pipe, st->state.blend->data); pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data); pipe->bind_fs_state(pipe, st->state.fs->data); - pipe->bind_vs_state(pipe, st->state.vs->data); + pipe->bind_vs_state(pipe, st->state.vs->cso->data); pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); pipe->set_viewport_state(pipe, &st->state.viewport); /* OR: diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index be5434f91b..f4d6b9362c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -662,7 +662,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, pipe->bind_fs_state(pipe, stfp->fs->data); /* vertex shader state: position + texcoord pass-through */ - pipe->bind_vs_state(pipe, stvp->vs->data); + pipe->bind_vs_state(pipe, stvp->cso->data); /* texture sampling state: */ { @@ -719,7 +719,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* restore GL state */ pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); pipe->bind_fs_state(pipe, ctx->st->state.fs->data); - pipe->bind_vs_state(pipe, ctx->st->state.vs->data); + pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data); pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]); pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index aed6b1ee97..63a954264e 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -39,6 +39,8 @@ #include "shader/programopt.h" #include "shader/shader_api.h" +#include "pipe/cso_cache/cso_cache.h" + #include "st_context.h" #include "st_program.h" #include "st_atom_shader.h" @@ -181,10 +183,11 @@ static void st_program_string_notify( GLcontext *ctx, stvp->serialNo++; - if (stvp->vs) { - /* free the TGSI code */ - // cso_delete(stfp->vs); - stvp->vs = NULL; + if (stvp->cso) { + /* free the CSO data */ + st->pipe->delete_vs_state(st->pipe, stvp->cso->data); + FREE((void *) stvp->cso); + stvp->cso = NULL; } stvp->param_state = stvp->Base.Base.Parameters->StateFlags; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 0f40f3ceee..5ae21c93f9 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -100,7 +100,7 @@ struct st_context const struct cso_depth_stencil_alpha *depth_stencil; const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; - const struct cso_vertex_shader *vs; + struct st_vertex_program *vs; struct pipe_blend_color blend_color; struct pipe_clip_state clip; diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index cffd66751d..57450e52bf 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -53,11 +53,11 @@ st_print_current(void) int i; printf("Vertex Transform Inputs:\n"); - for (i = 0; i < st->state.vs->state.num_inputs; i++) { + for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) { printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]); } - tgsi_dump( st->state.vs->state.tokens, 0 ); + tgsi_dump( st->state.vs->cso->state.tokens, 0 ); if (st->vp->Base.Base.Parameters) _mesa_print_parameter_list(st->vp->Base.Base.Parameters); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 96db9e3c03..94b3a9531a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -241,7 +241,7 @@ st_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->state; + vs = &ctx->st->state.vs->cso->state; /* loop over TGSI shader inputs to determine vertex buffer * and attribute info @@ -447,7 +447,7 @@ set_feedback_vertex_format(GLcontext *ctx) else { /* GL_FEEDBACK, or glRasterPos */ /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ - vinfo.num_attribs = st->state.vs->state.num_outputs; + vinfo.num_attribs = st->state.vs->cso->state.num_outputs; for (i = 0; i < vinfo.num_attribs; i++) { vinfo.format[i] = FORMAT_4F; vinfo.interp_mode[i] = INTERP_LINEAR; @@ -491,7 +491,11 @@ st_feedback_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->state; + vs = &ctx->st->state.vs->cso->state; + + if (!st->state.vs->draw_shader) { + st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs); + } /* * Set up the draw module's state. @@ -503,7 +507,7 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_viewport_state(draw, &st->state.viewport); draw_set_clip_state(draw, &st->state.clip); draw_set_rasterizer_state(draw, &st->state.rasterizer->state); - draw_bind_vertex_shader(draw, st->state.vs->data); + draw_bind_vertex_shader(draw, st->state.vs->draw_shader); set_feedback_vertex_format(ctx); /* loop over TGSI shader inputs to determine vertex buffer diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 1852228b29..1f1e6500e0 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -57,7 +57,7 @@ * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ -const struct cso_vertex_shader * +void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *stvp, const GLuint outputMapping[], @@ -256,12 +256,10 @@ st_translate_vertex_program(struct st_context *st, vs.tokens = tokensOut; cso = st_cached_vs_state(st, &vs); - stvp->vs = cso; + stvp->cso = cso; if (TGSI_DEBUG) tgsi_dump( tokensOut, 0 ); - - return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 049f9f659f..de02c3185f 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -90,7 +90,10 @@ struct st_vertex_program struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; /** Pointer to the corresponding cached shader */ - const struct cso_vertex_shader *vs; + const struct cso_vertex_shader *cso; + + /** For using our private draw module (glRasterPos) */ + struct draw_vertex_shader *draw_shader; GLuint param_state; }; @@ -122,7 +125,7 @@ st_translate_fragment_program(struct st_context *st, GLuint maxTokens); -extern const struct cso_vertex_shader * +extern void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *vp, const GLuint vert_output_to_slot[], -- cgit v1.2.3 From d280206c7f74c6c0fc22798b5945db3bf369364e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 19:18:35 -0700 Subject: free stvp->draw_shader --- src/mesa/state_tracker/st_cb_program.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 63a954264e..1f34fc86ad 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -190,11 +190,15 @@ static void st_program_string_notify( GLcontext *ctx, stvp->cso = NULL; } + if (stvp->draw_shader) { + draw_delete_vertex_shader(st->draw, stvp->draw_shader); + stvp->draw_shader = NULL; + } + stvp->param_state = stvp->Base.Base.Parameters->StateFlags; if (st->vp == stvp) st->dirty.st |= ST_NEW_VERTEX_PROGRAM; - } } -- cgit v1.2.3 From dd5a8d234b95c6f85d0a6ecb18db8aadefb71dbd Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 14:18:17 -0700 Subject: Add surface status/clear_value fields, PIPE_SURFACE_STATUS_x tokens --- src/mesa/pipe/p_defines.h | 8 ++++++++ src/mesa/pipe/p_state.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index c6d9c02bd9..50bea691e7 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -169,6 +169,14 @@ enum pipe_texture_target { #define PIPE_SURFACE 2 /**< user-created surfaces */ +/** + * Surface status + */ +#define PIPE_SURFACE_STATUS_UNDEFINED 0 +#define PIPE_SURFACE_STATUS_DEFINED 1 +#define PIPE_SURFACE_STATUS_CLEAR 2 + + /** * Buffer access flags */ diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index ccd2a5f9e2..46328d2a8f 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -243,6 +243,8 @@ struct pipe_surface { struct pipe_buffer_handle *buffer; /**< driver private buffer handle */ enum pipe_format format; /**< PIPE_FORMAT_x */ + unsigned status; /**< PIPE_SURFACE_STATUS_x */ + unsigned clear_value; /**< may be temporary */ unsigned cpp; /**< bytes per pixel */ unsigned width, height; unsigned pitch; /**< in pixels */ -- cgit v1.2.3 From 14a1e5908dc204f033eaff88e6b3f5cbc9793c0c Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 18:22:23 -0700 Subject: include pipe/draw/draw_context.h --- src/mesa/state_tracker/st_cb_program.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 1f34fc86ad..f1f33fb0dd 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -40,6 +40,7 @@ #include "shader/shader_api.h" #include "pipe/cso_cache/cso_cache.h" +#include "pipe/draw/draw_context.h" #include "st_context.h" #include "st_program.h" -- cgit v1.2.3 From 0cec2e18d5a11244f1b2c989b3f17161a95ee416 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 18:22:35 -0700 Subject: remove redundant llvm subdir --- src/mesa/pipe/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/pipe/Makefile b/src/mesa/pipe/Makefile index da044036ff..d880d090c1 100644 --- a/src/mesa/pipe/Makefile +++ b/src/mesa/pipe/Makefile @@ -10,7 +10,7 @@ ifeq ($(CONFIG_NAME), linux-llvm) LLVM_DIR = llvm endif -SUBDIRS = softpipe llvm i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR) +SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR) default: subdirs -- cgit v1.2.3 From 5a185ca09ae9d0774c99a187463d975a40ce9770 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 18:26:21 -0700 Subject: replace _mesa_printf() with fprintf() --- src/mesa/pipe/i965simple/brw_sf.c | 8 ++++---- src/mesa/pipe/i965simple/brw_sf_emit.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/i965simple/brw_sf.c b/src/mesa/pipe/i965simple/brw_sf.c index 362196a0d1..b89b2e4087 100644 --- a/src/mesa/pipe/i965simple/brw_sf.c +++ b/src/mesa/pipe/i965simple/brw_sf.c @@ -175,7 +175,7 @@ static void upload_sf_prog( struct brw_context *brw ) //int semantic = parse.FullToken.FullDeclaration.Semantic.SemanticName; //int semantic_index = parse.FullToken.FullDeclaration.Semantic.SemanticIndex; - _mesa_printf("fs input %d..%d interp mode %d\n", first, last, interp_mode); + fprintf(stderr, "fs input %d..%d interp mode %d\n", first, last, interp_mode); switch (interp_mode) { case TGSI_INTERPOLATE_CONSTANT: @@ -213,9 +213,9 @@ static void upload_sf_prog( struct brw_context *brw ) key.linear_mask |= 1; key.const_mask <<= 1; - _mesa_printf("key.persp_mask: %x\n", key.persp_mask); - _mesa_printf("key.linear_mask: %x\n", key.linear_mask); - _mesa_printf("key.const_mask: %x\n", key.const_mask); + fprintf(stderr, "key.persp_mask: %x\n", key.persp_mask); + fprintf(stderr, "key.linear_mask: %x\n", key.linear_mask); + fprintf(stderr, "key.const_mask: %x\n", key.const_mask); // key.do_point_sprite = brw->attribs.Point->PointSprite; diff --git a/src/mesa/pipe/i965simple/brw_sf_emit.c b/src/mesa/pipe/i965simple/brw_sf_emit.c index bc3878a93a..6ff5254ff7 100644 --- a/src/mesa/pipe/i965simple/brw_sf_emit.c +++ b/src/mesa/pipe/i965simple/brw_sf_emit.c @@ -137,8 +137,8 @@ static boolean calculate_masks( struct brw_sf_compile *c, unsigned persp_mask = c->key.persp_mask; unsigned linear_mask = c->key.linear_mask; - _mesa_printf("persp_mask: %x\n", persp_mask); - _mesa_printf("linear_mask: %x\n", linear_mask); + fprintf(stderr, "persp_mask: %x\n", persp_mask); + fprintf(stderr, "linear_mask: %x\n", linear_mask); *pc_persp = 0; *pc_linear = 0; @@ -162,9 +162,9 @@ static boolean calculate_masks( struct brw_sf_compile *c, *pc_linear |= 0xf0; } - _mesa_printf("pc: %x\n", *pc); - _mesa_printf("pc_persp: %x\n", *pc_persp); - _mesa_printf("pc_linear: %x\n", *pc_linear); + fprintf(stderr, "pc: %x\n", *pc); + fprintf(stderr, "pc_persp: %x\n", *pc_persp); + fprintf(stderr, "pc_linear: %x\n", *pc_linear); return is_last_attr; @@ -177,7 +177,7 @@ void brw_emit_tri_setup( struct brw_sf_compile *c ) struct brw_compile *p = &c->func; unsigned i; - _mesa_printf("%s START ==============\n", __FUNCTION__); + fprintf(stderr, "%s START ==============\n", __FUNCTION__); c->nr_verts = 3; alloc_regs(c); @@ -250,7 +250,7 @@ void brw_emit_tri_setup( struct brw_sf_compile *c ) } } - _mesa_printf("%s DONE ==============\n", __FUNCTION__); + fprintf(stderr, "%s DONE ==============\n", __FUNCTION__); } -- cgit v1.2.3 From 62ef6376bef7dcc7f23c676519683e99cd9f7717 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 18:27:14 -0700 Subject: Don't include stdint.h or inttypes. Use the uint64 typedef instead of uint64_t. --- src/mesa/pipe/p_context.h | 4 ++-- src/mesa/pipe/p_util.h | 1 - src/mesa/pipe/softpipe/sp_context.h | 2 +- src/mesa/pipe/softpipe/sp_query.c | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 25b5dc35e4..7a18d48865 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -29,7 +29,7 @@ #define PIPE_CONTEXT_H #include "p_state.h" -#include + struct pipe_state_cache; @@ -97,7 +97,7 @@ struct pipe_context { boolean (*get_query_result)(struct pipe_context *pipe, struct pipe_query *q, boolean wait, - uint64_t *result); + uint64 *result); /* * State functions diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 46edcf3075..1bf606bf4b 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -30,7 +30,6 @@ #include "p_compiler.h" #include -#include #ifdef WIN32 diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 394baf0109..3537f86a61 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -76,7 +76,7 @@ struct softpipe_context { /* Counter for occlusion queries. Note this supports overlapping * queries. */ - uint64_t occlusion_count; + uint64 occlusion_count; /* * Mapped vertex buffers diff --git a/src/mesa/pipe/softpipe/sp_query.c b/src/mesa/pipe/softpipe/sp_query.c index bf753dad98..6a8a43aeda 100644 --- a/src/mesa/pipe/softpipe/sp_query.c +++ b/src/mesa/pipe/softpipe/sp_query.c @@ -37,8 +37,8 @@ #include "sp_query.h" struct softpipe_query { - uint64_t start; - uint64_t end; + uint64 start; + uint64 end; }; @@ -87,7 +87,7 @@ static boolean softpipe_get_query_result(struct pipe_context *pipe, struct pipe_query *q, boolean wait, - uint64_t *result ) + uint64 *result ) { struct softpipe_query *sq = softpipe_query(q); *result = sq->end - sq->start; -- cgit v1.2.3 From 587e2becc237bc1c900a1c0ba114a1a0192690ff Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Jan 2008 18:32:51 -0700 Subject: typedef uintptr_t for non-HAVE_POSIX_MEMALIGN build --- src/mesa/pipe/p_util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 1bf606bf4b..69ec62e307 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -123,6 +123,7 @@ align_malloc(size_t bytes, uint alignment) (void) posix_memalign(& mem, alignment, bytes); return mem; #else + typedef unsigned long int uintptr_t; uintptr_t ptr, buf; assert( alignment > 0 ); -- cgit v1.2.3