diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2008-01-20 10:38:35 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-01-20 10:38:35 +1100 |
commit | df09ed9d1ecf11be14ee7f189273c14375fbaa57 (patch) | |
tree | 7322a2670877dff003f57a5485c9e92226b57167 | |
parent | 0feec292ddc279998a1e25c10ea70d211f7b4b62 (diff) | |
parent | a1f4a5e802ad62c88fca6834b9de1c83672230a6 (diff) |
Merge branch 'upstream-gallium-0.1' into darktama-gallium-0.1
54 files changed, 620 insertions, 361 deletions
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore new file mode 100644 index 0000000000..cdd04092bd --- /dev/null +++ b/progs/trivial/.gitignore @@ -0,0 +1,101 @@ +clear +clear-fbo +clear-fbo-tex +clear-scissor +dlist-dangling +dlist-edgeflag +dlist-edgeflag-dangling +drawarrays +drawelements +drawrange +extfuncs.h +flat-clip +fs-tri +line +line-clip +line-cull +line-stipple-wide +line-userclip +line-userclip-clip +line-userclip-nop +line-userclip-nop-clip +line-wide +lineloop +lineloop-clip +lineloop-elts +linestrip +linestrip-flat-stipple +linestrip-stipple +linestrip-stipple-wide +point +point-clip +point-param +point-sprite +point-wide +poly +poly-flat +poly-unfilled +quad +quad-clip +quad-clip-all-vertices +quad-clip-nearplane +quad-degenerate +quad-flat +quad-offset-factor +quad-offset-unfilled +quad-offset-units +quad-tex-2d +quad-tex-3d +quad-tex-alpha +quad-tex-pbo +quad-unfilled +quad-unfilled-clip +quad-unfilled-stipple +quads +quadstrip +quadstrip-cont +quadstrip-flat +readtex.c +readtex.h +tri +tri-alpha +tri-blend +tri-blend-color +tri-blend-max +tri-blend-min +tri-blend-revsub +tri-blend-sub +tri-clip +tri-cull +tri-cull-both +tri-dlist +tri-edgeflag +tri-fbo +tri-fbo-tex +tri-flat +tri-flat-clip +tri-fog +tri-mask-tri +tri-query +tri-scissor-tri +tri-stencil +tri-tex-3d +tri-tri +tri-unfilled +tri-unfilled-clip +tri-unfilled-smooth +tri-unfilled-userclip +tri-unfilled-userclip-stip +tri-userclip +tri-z +tri-z-eq +tristrip +tristrip-clip +vbo-drawarrays +vbo-drawelements +vbo-drawrange +vp-array +vp-clip +vp-line-clip +vp-tri +vp-unfilled diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c index c7b519d95b..340fa2fb85 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -227,7 +227,7 @@ intel_i915_surface_alloc_storage(struct pipe_winsys *winsys, surf->buffer, surf->pitch * surf->cpp * height, NULL, - 0); + PIPE_BUFFER_USAGE_PIXEL); if(ret) { winsys->buffer_reference(winsys, &surf->buffer, NULL); return ret; diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 4a9a0cd975..04ece4cda8 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -436,7 +436,7 @@ static struct ureg register_const4f( struct tnl_program *p, idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); ASSERT(swizzle == SWIZZLE_NOOP); - return make_ureg(PROGRAM_STATE_VAR, idx); + return make_ureg(PROGRAM_CONSTANT, idx); } #define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index d866d10017..644b1f39c7 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -582,7 +582,7 @@ static struct ureg register_const4f( struct texenv_fragment_program *p, idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); ASSERT(swizzle == SWIZZLE_NOOP); - return make_ureg(PROGRAM_STATE_VAR, idx); + return make_ureg(PROGRAM_CONSTANT, idx); } #define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) diff --git a/src/mesa/pipe/Makefile.template b/src/mesa/pipe/Makefile.template index 3cd07660b6..8e84f8eb2d 100644 --- a/src/mesa/pipe/Makefile.template +++ b/src/mesa/pipe/Makefile.template @@ -17,7 +17,8 @@ INCLUDES = \ -I. \ -I$(TOP)/src/mesa/pipe \ -I$(TOP)/src/mesa \ - -I$(TOP)/include + -I$(TOP)/include \ + $(DRIVER_INCLUDES) ##### RULES ##### @@ -34,11 +35,11 @@ INCLUDES = \ ##### TARGETS ##### -default:: depend symlinks $(LIBNAME) +default: depend symlinks $(LIBNAME) $(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template - $(TOP)/bin/mklib -o $@ -static $(OBJECTS) + $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS) depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) @@ -54,7 +55,7 @@ tags: # Remove .o and backup files -clean: +clean:: -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS) -rm -f depend depend.bak diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 29d1cbedda..f05070d25a 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -62,10 +62,12 @@ #define CELL_CMD_STATE_DEPTH_STENCIL 7 -#define CELL_NUM_BATCH_BUFFERS 2 +#define CELL_NUM_BATCH_BUFFERS 3 #define CELL_BATCH_BUFFER_SIZE 1024 /**< 16KB would be the max */ -#define CELL_BATCH_FINISHED 0x1234 /**< mbox message */ +#define CELL_BUFFER_STATUS_FREE 10 +#define CELL_BUFFER_STATUS_USED 20 + /** @@ -122,6 +124,7 @@ struct cell_init_info unsigned num_spus; struct cell_command *cmd; ubyte *batch_buffers[CELL_NUM_BATCH_BUFFERS]; + uint *buffer_status; /**< points at cell_context->buffer_status */ } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index 45f62ac3ad..ab4553f16c 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -34,9 +34,9 @@ void cell_batch_flush(struct cell_context *cell) { - const uint batch = cell->cur_batch; + uint batch = cell->cur_batch; const uint size = cell->batch_buffer_size[batch]; - uint i, cmd_word; + uint spu, cmd_word; if (size == 0) return; @@ -48,25 +48,44 @@ cell_batch_flush(struct cell_context *cell) batch, &cell->batch_buffer[batch][0], size); */ + /* + * Build "BATCH" command and sent to all SPUs. + */ 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); + for (spu = 0; spu < cell->num_spus; spu++) { + assert(cell->buffer_status[spu][batch][0] == CELL_BUFFER_STATUS_USED); + send_mbox_message(cell_global.spe_contexts[spu], cmd_word); } - /* 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... + /* When the SPUs are done copying the buffer into their locals stores + * they'll write a BUFFER_STATUS_FREE message into the buffer_status[] + * array indicating that the PPU can re-use the buffer. */ - 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 */ + /* Find a buffer that's marked as free by all SPUs */ + while (1) { + uint num_free = 0; + + batch = (batch + 1) % CELL_NUM_BATCH_BUFFERS; + + for (spu = 0; spu < cell->num_spus; spu++) { + if (cell->buffer_status[spu][batch][0] == CELL_BUFFER_STATUS_FREE) + num_free++; + } + + if (num_free == cell->num_spus) { + /* found a free buffer, now mark status as used */ + for (spu = 0; spu < cell->num_spus; spu++) { + cell->buffer_status[spu][batch][0] = CELL_BUFFER_STATUS_USED; + } + break; + } + } + + cell->batch_buffer_size[batch] = 0; /* empty */ + cell->cur_batch = batch; } diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index 6ba3b0d413..897c187d65 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -160,7 +160,7 @@ struct pipe_context * cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) { struct cell_context *cell; - uint i; + uint spu, buf; /* some fields need to be 16-byte aligned, so align the whole object */ cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16); @@ -248,13 +248,30 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) cell_start_spus(cell); - for (i = 0; i < CELL_NUM_BATCH_BUFFERS; i++) { - cell->batch_buffer_size[i] = 0; + for (buf = 0; buf < CELL_NUM_BATCH_BUFFERS; buf++) { + cell->batch_buffer_size[buf] = 0; + + /* init batch buffer status values, + * mark 0th buffer as used, rest as free. + */ + for (spu = 0; spu < cell->num_spus; spu++) { + if (buf == 0) + cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED; + else + cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_FREE; + } } + #if 0 test_spus(cell); #endif return &cell->pipe; } + + +#if 0 +/** [4] to ensure 16-byte alignment for each status word */ +uint buffer_status[CELL_MAX_SPUS][CELL_NUM_BATCH_BUFFERS][4] ALIGN16_ATTRIB; +#endif diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index 43e32a8abb..08e448f14f 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -38,6 +38,9 @@ #include "pipe/cell/common.h" +#define CELL_MAX_SPUS 6 + + struct cell_vbuf_render; struct cell_vertex_shader_state @@ -103,10 +106,14 @@ struct cell_context ubyte batch_buffer[CELL_NUM_BATCH_BUFFERS][CELL_BATCH_BUFFER_SIZE] ALIGN16_ATTRIB; int cur_batch; /**< which batch buffer is being filled */ + /** [4] to ensure 16-byte alignment for each status word */ + uint buffer_status[CELL_MAX_SPUS][CELL_NUM_BATCH_BUFFERS][4] ALIGN16_ATTRIB; + }; + static INLINE struct cell_context * cell_context(struct pipe_context *pipe) { diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 77ddd9ccbf..a21ab9ff3a 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -114,6 +114,7 @@ cell_start_spus(struct cell_context *cell) for (j = 0; j < CELL_NUM_BATCH_BUFFERS; j++) { cell_global.inits[i].batch_buffers[j] = cell->batch_buffer[j]; } + cell_global.inits[i].buffer_status = &cell->buffer_status[0][0][0]; 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_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index d27d718dae..a420de041a 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -46,6 +46,8 @@ struct cell_vbuf_render struct vbuf_render base; struct cell_context *cell; uint prim; + uint vertex_size; + void *vertex_buffer; }; @@ -70,8 +72,12 @@ static void * cell_vbuf_allocate_vertices(struct vbuf_render *vbr, ushort vertex_size, ushort nr_vertices) { + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); /*printf("Alloc verts %u * %u\n", vertex_size, nr_vertices);*/ - return align_malloc(vertex_size * nr_vertices, 16); + assert(!cvbr->vertex_buffer); + cvbr->vertex_buffer = align_malloc(vertex_size * nr_vertices, 16); + cvbr->vertex_size = vertex_size; + return cvbr->vertex_buffer; } @@ -86,17 +92,22 @@ cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) static void cell_vbuf_draw(struct vbuf_render *vbr, - uint prim, const ushort *indices, - uint nr_indices, - const void *vertices, - uint nr_vertices, - uint vertex_size) + uint nr_indices) { struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); struct cell_context *cell = cvbr->cell; float xmin, ymin, xmax, ymax; uint i; + uint nr_vertices = 0; + const void *vertices = cvbr->vertex_buffer; + const uint vertex_size = cvbr->vertex_size; + + for (i = 0; i < nr_indices; i++) { + if (indices[i] > nr_vertices) + nr_vertices = indices[i]; + } + nr_vertices++; #if 0 printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u\n", @@ -127,14 +138,14 @@ cell_vbuf_draw(struct vbuf_render *vbr, ymax = v[1]; } - if (prim != PIPE_PRIM_TRIANGLES) + if (cvbr->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->prim_type = cvbr->prim; render->num_verts = nr_vertices; render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ render->vertex_data = vertices; @@ -155,7 +166,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, = (struct cell_command_render *) cell_batch_alloc(cell, sizeof(*render)); render->opcode = CELL_CMD_RENDER; - render->prim_type = prim; + render->prim_type = cvbr->prim; render->num_verts = nr_vertices; render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */ render->vertex_data = vertices; @@ -182,8 +193,13 @@ static void cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices, unsigned vertex_size, unsigned vertices_used) { + struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); + /*printf("Free verts %u * %u\n", vertex_size, vertices_used);*/ align_free(vertices); + + assert(vertices == cvbr->vertex_buffer); + cvbr->vertex_buffer = NULL; } diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 2727b03756..bff098f06e 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -396,6 +396,38 @@ cmd_finish(void) /** + * Tell the PPU that this SPU has finished copying a batch buffer to + * local store and that it may be reused by the PPU. + * This is done by writting a 16-byte batch-buffer-status block back into + * main memory (in cell_contex->buffer_status[]). + */ +static void +release_batch_buffer(uint buffer) +{ + /* Evidently, using less than a 16-byte status doesn't work reliably */ + static const uint status[4] ALIGN16_ATTRIB + = {CELL_BUFFER_STATUS_FREE, 0, 0, 0}; + + const uint index = 4 * (spu.init.id * CELL_NUM_BATCH_BUFFERS + buffer); + uint *dst = spu.init.buffer_status + index; + + ASSERT(buffer < CELL_NUM_BATCH_BUFFERS); + + /* + printf("SPU %u: Set batch status buf=%u, index %u, at %p to FREE\n", + spu.init.id, buffer, index, dst); + */ + + mfc_put((void *) &status, /* src in local memory */ + (unsigned int) dst, /* dst in main memory */ + sizeof(status), /* size */ + TAG_MISC, /* tag is unimportant */ + 0, /* tid */ + 0 /* rid */); +} + + +/** * Execute a batch of commands * The opcode param encodes the location of the buffer and its size. */ @@ -429,9 +461,9 @@ 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); + /* Tell PPU we're done copying the buffer to local store */ + release_batch_buffer(buf); + for (pos = 0; pos < usize; /* no incr */) { switch (buffer[pos]) { diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h index 75fb5b388b..f39f375d24 100644 --- a/src/mesa/pipe/cell/spu/spu_main.h +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -76,6 +76,8 @@ extern struct spu_global spu; #define TAG_WRITE_TILE_Z 15 #define TAG_INDEX_BUFFER 16 #define TAG_BATCH_BUFFER 17 +#define TAG_MISC 18 + /** The standard assert macro doesn't seem to work on SPUs */ #define ASSERT(x) \ diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index d134b05717..fd43d690f6 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -76,10 +76,10 @@ struct draw_context *draw_create( void ) draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE); } - draw->attrib_front0 = -1; - draw->attrib_back0 = -1; - draw->attrib_front1 = -1; - draw->attrib_back1 = -1; + draw->attrib_front0 = 0; + draw->attrib_back0 = 0; + draw->attrib_front1 = 0; + draw->attrib_back1 = 0; draw->prim = ~0; /* != any of PIPE_PRIM_x */ @@ -238,17 +238,6 @@ void draw_alloc_tmps( struct draw_stage *stage, unsigned nr ) } } -/** - * Reset the vertex ids for the stage's temp verts. - */ -void draw_reset_tmps( struct draw_stage *stage ) -{ - unsigned i; - - if (stage->tmp) - for (i = 0; i < stage->nr_tmps; i++) - stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; -} void draw_free_tmps( struct draw_stage *stage ) { @@ -271,10 +260,11 @@ void draw_reset_vertex_ids(struct draw_context *draw) struct draw_stage *stage = draw->pipeline.first; while (stage) { - if (stage->reset_tmps) - stage->reset_tmps(stage); - else - draw_reset_tmps(stage); + unsigned i; + + for (i = 0; i < stage->nr_tmps; i++) + stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; + stage = stage->next; } diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 60be3e194d..91e11e6930 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -100,15 +100,13 @@ void draw_delete_vertex_shader(struct draw_context *draw, boolean draw_use_sse(struct draw_context *draw); -void -draw_set_vertex_buffer(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_buffer *buffer); - -void -draw_set_vertex_element(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_element *element); +void draw_set_vertex_buffer(struct draw_context *draw, + unsigned attr, + const struct pipe_vertex_buffer *buffer); + +void draw_set_vertex_element(struct draw_context *draw, + unsigned attr, + const struct pipe_vertex_element *element); void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, void *elements ); diff --git a/src/mesa/pipe/draw/draw_linestipple.c b/src/mesa/pipe/draw/draw_linestipple.c index 5f0db99b23..d7fe1071f0 100644 --- a/src/mesa/pipe/draw/draw_linestipple.c +++ b/src/mesa/pipe/draw/draw_linestipple.c @@ -265,7 +265,6 @@ struct clip_pipe_stage *clip_pipe_stipple( struct clip_pipeline *pipe ) stipple->stage.point = clip_passthrough_point; stipple->stage.line = stipple_line; stipple->stage.tri = clip_passthrough_tri; - stipple->stage.reset_tmps = clip_pipe_reset_tmps; stipple->stage.end = stipple_end; stipple->stage.destroy = stipple_destroy; diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 5f89ac121e..d8832449ea 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -116,13 +116,6 @@ struct draw_stage void (*end)( struct draw_stage * ); - /** - * Reset temporary vertex ids in this stage - * - * draw_free_tmps will be called instead if null. - */ - void (*reset_tmps)( struct draw_stage * ); - void (*reset_stipple_counter)( struct draw_stage * ); void (*destroy)( struct draw_stage * ); diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 00b4ee45cd..c7e268f11e 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -79,11 +79,9 @@ static struct vertex_header *copy_bfc( struct twoside_stage *twoside, const struct draw_context *draw = twoside->stage.draw; if (draw->attrib_front0 && draw->attrib_back0) { - assert(draw->attrib_back0); copy_attrib(draw->attrib_front0, draw->attrib_back0, tmp); } if (draw->attrib_front1 && draw->attrib_back1) { - assert(draw->attrib_back1); copy_attrib(draw->attrib_front1, draw->attrib_back1, tmp); } diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 4f59b1b25d..6cda122c3a 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -83,7 +83,8 @@ vbuf_stage( struct draw_stage *stage ) static void vbuf_flush_indices( struct draw_stage *stage ); -static void vbuf_flush_vertices( struct draw_stage *stage, +static void vbuf_flush_vertices( struct draw_stage *stage ); +static void vbuf_alloc_vertices( struct draw_stage *stage, unsigned new_vertex_size ); @@ -98,8 +99,10 @@ overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz ) static INLINE void check_space( struct vbuf_stage *vbuf, unsigned nr ) { - if (vbuf->nr_vertices + nr > vbuf->max_vertices ) - vbuf_flush_vertices(&vbuf->stage, vbuf->vertex_size ); + if (vbuf->nr_vertices + nr > vbuf->max_vertices ) { + vbuf_flush_vertices(&vbuf->stage); + vbuf_alloc_vertices(&vbuf->stage, vbuf->vertex_size); + } if (vbuf->nr_indices + nr > vbuf->max_indices ) vbuf_flush_indices(&vbuf->stage); @@ -232,10 +235,12 @@ vbuf_first_tri( struct draw_stage *stage, struct vbuf_stage *vbuf = vbuf_stage( stage ); vbuf_flush_indices( stage ); + stage->tri = vbuf_tri; - stage->tri( stage, prim ); vbuf->prim = PIPE_PRIM_TRIANGLES; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_TRIANGLES); + + stage->tri( stage, prim ); } @@ -247,9 +252,10 @@ vbuf_first_line( struct draw_stage *stage, vbuf_flush_indices( stage ); stage->line = vbuf_line; - stage->line( stage, prim ); vbuf->prim = PIPE_PRIM_LINES; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_LINES); + + stage->line( stage, prim ); } @@ -260,10 +266,12 @@ vbuf_first_point( struct draw_stage *stage, struct vbuf_stage *vbuf = vbuf_stage( stage ); vbuf_flush_indices( stage ); + stage->point = vbuf_point; - stage->point( stage, prim ); vbuf->prim = PIPE_PRIM_POINTS; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_POINTS); + + stage->point( stage, prim ); } @@ -291,15 +299,13 @@ vbuf_flush_indices( struct draw_stage *stage ) assert(0); } - vbuf->render->draw( vbuf->render, - vbuf->prim, - vbuf->indices, - vbuf->nr_indices, - vbuf->vertices, - vbuf->nr_vertices, - vbuf->vertex_size ); - + vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices); + vbuf->nr_indices = 0; + + stage->point = vbuf_first_point; + stage->line = vbuf_first_line; + stage->tri = vbuf_first_tri; } @@ -311,8 +317,7 @@ vbuf_flush_indices( struct draw_stage *stage ) * we flush. */ static void -vbuf_flush_vertices( struct draw_stage *stage, - unsigned new_vertex_size ) +vbuf_flush_vertices( struct draw_stage *stage ) { struct vbuf_stage *vbuf = vbuf_stage( stage ); @@ -332,15 +337,24 @@ vbuf_flush_vertices( struct draw_stage *stage, vbuf->vertex_ptr = vbuf->vertices = NULL; } +} + +static void +vbuf_alloc_vertices( struct draw_stage *stage, + unsigned new_vertex_size ) +{ + struct vbuf_stage *vbuf = vbuf_stage( stage ); + assert(!vbuf->nr_indices); + assert(!vbuf->vertices); /* Allocate a new vertex buffer */ vbuf->vertex_size = new_vertex_size; vbuf->max_vertices = vbuf->render->max_vertex_buffer_bytes / vbuf->vertex_size; vbuf->vertices = vbuf->render->allocate_vertices(vbuf->render, - vbuf->vertex_size, - vbuf->max_vertices) ; + (ushort) vbuf->vertex_size, + (ushort) vbuf->max_vertices); vbuf->vertex_ptr = vbuf->vertices; } @@ -352,22 +366,17 @@ vbuf_begin( struct draw_stage *stage ) const struct vertex_info *vinfo = vbuf->render->get_vertex_info(vbuf->render); unsigned vertex_size = vinfo->size * sizeof(float); - if(vbuf->vertex_size != vertex_size) - vbuf_flush_vertices(&vbuf->stage, vertex_size); + /* XXX: Overkill */ + vbuf_alloc_vertices(&vbuf->stage, vertex_size); } static void vbuf_end( struct draw_stage *stage ) { -#if 0 +// vbuf_flush_indices( stage ); /* 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 + vbuf_flush_vertices( stage ); stage->point = vbuf_first_point; stage->line = vbuf_first_line; diff --git a/src/mesa/pipe/draw/draw_vbuf.h b/src/mesa/pipe/draw/draw_vbuf.h index be4c4ab77b..cfd2b9820c 100644 --- a/src/mesa/pipe/draw/draw_vbuf.h +++ b/src/mesa/pipe/draw/draw_vbuf.h @@ -82,12 +82,8 @@ struct vbuf_render { * DrawElements, note indices are ushort: */ void (*draw)( struct vbuf_render *, - uint prim, const ushort *indices, - uint nr_indices, - const void *vertices, - uint nr_vertices, - uint vertex_bytes); + uint nr_indices ); /** * Called when vbuf is done with this set of vertices: diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 7d983ebd29..3ca17f8829 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -37,7 +37,7 @@ #include "draw_vertex.h" -#define DBG 0 +#define DRAW_DBG 0 /** @@ -107,7 +107,7 @@ void draw_vertex_fetch( struct draw_context *draw, for (j = 0; j < count; j++) { uint attr; -#if DBG +#if DRAW_DBG printf("fetch vertex %u: \n", j); #endif @@ -124,7 +124,7 @@ void draw_vertex_fetch( struct draw_context *draw, fetch_attrib4(src, draw->vertex_element[attr].src_format, p); -#if DBG +#if DRAW_DBG printf(" %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]); #endif diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h index 13197f3595..0bcd094233 100644 --- a/src/mesa/pipe/i915simple/i915_debug.h +++ b/src/mesa/pipe/i915simple/i915_debug.h @@ -69,11 +69,13 @@ void i915_print_ureg(const char *msg, unsigned ureg); #define DEBUG_SURFACE 0x2000 #define DEBUG_WINSYS 0x4000 +#include "pipe/p_compiler.h" + #if defined(DEBUG) && defined(FILE_DEBUG_FLAG) #include "pipe/p_winsys.h" -static void +static INLINE void I915_DBG( struct i915_context *i915, const char *fmt, @@ -92,7 +94,7 @@ I915_DBG( #else -static void +static INLINE void I915_DBG( struct i915_context *i915, const char *fmt, diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index bdcc027ed7..edc62e25e5 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -136,12 +136,8 @@ i915_vbuf_render_set_primitive( struct vbuf_render *render, static void i915_vbuf_render_draw( struct vbuf_render *render, - uint prim, const ushort *indices, - uint nr_indices, - const void *vertices, - uint nr_vertices, - uint vertex_bytes) + uint nr_indices) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -206,7 +202,7 @@ static void i915_vbuf_render_destroy( struct vbuf_render *render ) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); - free(i915_render); + FREE(i915_render); } diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index e3c3cdd2e4..e625f5a68c 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -64,6 +64,7 @@ i915_get_tex_surface(struct pipe_context *pipe, ps = pipe->winsys->surface_alloc(pipe->winsys); if (ps) { assert(ps->refcount); + assert(ps->winsys); pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); ps->format = pt->format; ps->cpp = pt->cpp; @@ -76,41 +77,6 @@ i915_get_tex_surface(struct pipe_context *pipe, } -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte *src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * dst_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -125,9 +91,9 @@ i915_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst), - dst->cpp, dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -147,14 +113,14 @@ i915_surface_copy(struct pipe_context *pipe, assert( dst->cpp == src->cpp ); if (0) { - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src), - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src), + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c index 44f72e63cc..6b0a4a96f3 100644 --- a/src/mesa/pipe/i915simple/i915_texture.c +++ b/src/mesa/pipe/i915simple/i915_texture.c @@ -123,7 +123,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) * 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) + unsigned mip1_width = align_int(minify(pt->width[0]), align_w) + minify(minify(pt->width[0])); if (mip1_width > pt->width[0]) @@ -133,7 +133,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* Pitch must be a whole number of dwords, even though we * express it in texels. */ - tex->pitch = align(tex->pitch * pt->cpp, 4) / pt->cpp; + tex->pitch = align_int(tex->pitch * pt->cpp, 4) / pt->cpp; tex->total_height = 0; for ( level = pt->first_level ; level <= pt->last_level ; level++ ) { @@ -144,7 +144,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) if (pt->compressed) img_height = MAX2(1, height/4); else - img_height = align(height, align_h); + img_height = align_int(height, align_h); /* Because the images are packed better, the final offset @@ -155,7 +155,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* Layout_below: step right after second mipmap. */ if (level == pt->first_level + 1) { - x += align(width, align_w); + x += align_int(width, align_w); } else { y += img_height; @@ -531,9 +531,9 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) - free(tex->image_offset[i]); + FREE(tex->image_offset[i]); - free(tex); + FREE(tex); } *pt = NULL; } diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c index 4eacbdf82b..76b8c73d5c 100644 --- a/src/mesa/pipe/i965simple/brw_surface.c +++ b/src/mesa/pipe/i965simple/brw_surface.c @@ -76,40 +76,6 @@ brw_get_tex_surface(struct pipe_context *pipe, } -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte *src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * dst_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -124,9 +90,9 @@ brw_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst) + dst->offset, - dst->cpp, dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst) + dst->offset, + dst->cpp, dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -146,14 +112,14 @@ brw_surface_copy(struct pipe_context *pipe, assert(dst->cpp == src->cpp); if (0) { - copy_rect(pipe_surface_map(dst) + dst->offset, - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src) + src->offset, - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst) + dst->offset, + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src) + src->offset, + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/p_compiler.h b/src/mesa/pipe/p_compiler.h index 4f2c9ef88a..ab9609deab 100644 --- a/src/mesa/pipe/p_compiler.h +++ b/src/mesa/pipe/p_compiler.h @@ -50,6 +50,25 @@ typedef unsigned short ushort; typedef unsigned long long uint64; +#if defined(__MSC__) + +typedef unsigned short uint16_t; +typedef long int32_t; +typedef unsigned long uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; + +#if defined(_WIN64) +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif + +#else +#include <stdint.h> +#endif + + #define TRUE 1 #define FALSE 0 diff --git a/src/mesa/pipe/p_format.h b/src/mesa/pipe/p_format.h index b1772b352f..9f60cdbb04 100644 --- a/src/mesa/pipe/p_format.h +++ b/src/mesa/pipe/p_format.h @@ -97,6 +97,8 @@ static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask) return (f >> shift) & mask; } +/* XXX: The bit layout needs to be revised, can't currently encode 10-bit components. */ + #define pf_swizzle_x(f) pf_get(f, 2, 0x7) /**< PIPE_FORMAT_COMP_ */ #define pf_swizzle_y(f) pf_get(f, 5, 0x7) /**< PIPE_FORMAT_COMP_ */ #define pf_swizzle_z(f) pf_get(f, 8, 0x7) /**< PIPE_FORMAT_COMP_ */ diff --git a/src/mesa/pipe/p_shader_tokens.h b/src/mesa/pipe/p_shader_tokens.h index e5922b439f..e9d1d66bda 100644 --- a/src/mesa/pipe/p_shader_tokens.h +++ b/src/mesa/pipe/p_shader_tokens.h @@ -109,7 +109,8 @@ struct tgsi_declaration_interpolation #define TGSI_SEMANTIC_FOG 3 #define TGSI_SEMANTIC_PSIZE 4 #define TGSI_SEMANTIC_GENERIC 5 -#define TGSI_SEMANTIC_COUNT 6 /**< number of semantic values */ +#define TGSI_SEMANTIC_NORMAL 6 +#define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 69ec62e307..a2bc330424 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -111,6 +111,32 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size ) #define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T)) +/** + * Return a pointer aligned to next multiple of N bytes. + */ +static INLINE void * +align_pointer( void *unaligned, uint alignment ) +{ + if (sizeof(void *) == 64) { + union { + void *p; + uint64 u; + } pu; + pu.p = unaligned; + pu.u = (pu.u + alignment - 1) & ~(uint64) (alignment - 1); + return pu.p; + } + else { + /* 32-bit pointers */ + union { + void *p; + uint u; + } pu; + pu.p = unaligned; + pu.u = (pu.u + alignment - 1) & ~(alignment - 1); + return pu.p; + } +} /** * Return memory on given byte alignment @@ -123,19 +149,18 @@ 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; + char *ptr, *buf; assert( alignment > 0 ); - ptr = (uintptr_t) MALLOC(bytes + alignment + sizeof(void *)); + ptr = (char *) MALLOC(bytes + alignment + sizeof(void *)); if (!ptr) return NULL; - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; + buf = (char *) align_pointer( ptr + sizeof(void *), alignment ); + *(char **)(buf - sizeof(void *)) = ptr; - return (void *) buf; + return buf; #endif /* defined(HAVE_POSIX_MEMALIGN) */ } @@ -169,28 +194,17 @@ align_free(void *ptr) static INLINE void * align16( void *unaligned ) { - if (sizeof(void *) == 64) { - union { - void *p; - uint64 u; - } pu; - pu.p = unaligned; - pu.u = (pu.u + 15) & ~15; - return pu.p; - } - else { - /* 32-bit pointers */ - union { - void *p; - uint u; - } pu; - pu.p = unaligned; - pu.u = (pu.u + 15) & ~15; - return pu.p; - } + return align_pointer( unaligned, 16 ); +} + + +static INLINE int align_int(int x, int align) +{ + return (x + align - 1) & ~(align - 1); } + #if defined(__MSC__) && defined(__WIN32__) static INLINE unsigned ffs( unsigned u ) { @@ -369,4 +383,13 @@ static INLINE int align(int value, int alignment) */ extern void _mesa_printf(const char *str, ...); + +/* util/p_util.c + */ +extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch, + unsigned dst_x, unsigned dst_y, unsigned width, + unsigned height, const ubyte * src, + unsigned src_pitch, unsigned src_x, unsigned src_y); + + #endif diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index aa9362ec0b..75c6dc7e85 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -79,7 +79,10 @@ struct pipe_winsys /** allocate a new surface (no context dependency) */ struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws); - /** allocate storage for a pipe_surface */ + /** + * Allocate storage for a pipe_surface. + * Returns 0 if succeeds. + */ int (*surface_alloc_storage)(struct pipe_winsys *ws, struct pipe_surface *surf, unsigned width, unsigned height, diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c index e69f88a323..dfb80b1dcf 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c @@ -230,6 +230,9 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list, { struct fenced_buffer *buf; + if(!buffer) + return NULL; + buf = (struct fenced_buffer *)calloc(1, sizeof(struct fenced_buffer)); if(!buf) return NULL; diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h index 0e6c3a8d37..12e36323a8 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h @@ -65,7 +65,7 @@ struct buffer_manager /* XXX: we will likely need more allocation flags */ struct pipe_buffer * (*create_buffer)( struct buffer_manager *mgr, - size_t size); + size_t size ); void (*destroy)( struct buffer_manager *mgr ); @@ -96,6 +96,15 @@ struct buffer_manager * mm_bufmgr_create(struct buffer_manager *provider, size_t size, size_t align2); +/** + * Same as mm_bufmgr_create. + * + * Buffer will be release when the manager is destroyed. + */ +struct buffer_manager * +mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, + size_t size, size_t align2); + /** * Fenced buffer manager. diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c index 8e6dcf1116..e9bc34b4a4 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c @@ -218,17 +218,18 @@ mm_bufmgr_destroy(struct buffer_manager *mgr) struct buffer_manager * -mm_bufmgr_create(struct buffer_manager *provider, - size_t size, size_t align2) +mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, + size_t size, size_t align2) { struct mm_buffer_manager *mm; + if(!buffer) + return NULL; + mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm)); if (!mm) return NULL; - assert(provider); - assert(provider->create_buffer); mm->base.create_buffer = mm_bufmgr_create_buffer; mm->base.destroy = mm_bufmgr_destroy; @@ -237,9 +238,7 @@ mm_bufmgr_create(struct buffer_manager *provider, _glthread_INIT_MUTEX(mm->mutex); - mm->buffer = provider->create_buffer(provider, size); - if (!mm->buffer) - goto failure; + mm->buffer = buffer; mm->map = buffer_map(mm->buffer, PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE ); @@ -257,9 +256,30 @@ if(mm->heap) mmDestroy(mm->heap); if(mm->map) buffer_unmap(mm->buffer); - if(mm->buffer) - buffer_release(mm->buffer); if(mm) free(mm); return NULL; } + + +struct buffer_manager * +mm_bufmgr_create(struct buffer_manager *provider, + size_t size, size_t align2) +{ + struct pipe_buffer *buffer; + struct buffer_manager *mgr; + + assert(provider); + assert(provider->create_buffer); + buffer = provider->create_buffer(provider, size); + if (!buffer) + return NULL; + + mgr = mm_bufmgr_create_from_buffer(buffer, size, align2); + if (!mgr) { + buffer_release(buffer); + return NULL; + } + + return mgr; +} diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 722cadc5c0..89f8df945c 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -488,7 +488,7 @@ setup_fragcoord_coeff(struct setup_stage *setup) if (setup->softpipe->rasterizer->origin_lower_left) { /* y=0=bottom */ const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; - setup->coef[0].a0[1] = winHeight - 1; + setup->coef[0].a0[1] = (float) (winHeight - 1); setup->coef[0].dady[1] = -1.0; } else { @@ -554,12 +554,6 @@ static void setup_tri_coefficients( struct setup_stage *setup ) */ setup_fragcoord_coeff(setup); } - else if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { - /* FOG.y = front/back facing XXX fix this */ - setup->coef[fragSlot].a0[1] = 1 - setup->quad.facing; - setup->coef[fragSlot].dadx[1] = 0.0; - setup->coef[fragSlot].dady[1] = 0.0; - } else { #endif uint j; @@ -578,8 +572,18 @@ static void setup_tri_coefficients( struct setup_stage *setup ) break; default: /* invalid interp mode */ - assert(0); + /* assert(0); re-enable this and run demos/fogcoord.c ... */ + ; + } + + if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { + /* FOG.y = front/back facing XXX fix this */ + setup->coef[fragSlot].a0[1] = 1 - setup->quad.facing; + setup->coef[fragSlot].dadx[1] = 0.0; + setup->coef[fragSlot].dady[1] = 0.0; } + + #if USE_INPUT_MAP } #endif diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 921dfbaccb..0001c76a80 100644 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -133,7 +133,7 @@ shade_quad( machine->InterpCoefs = quad->coef; /* Compute X, Y, Z, W vals for this quad */ - setup_pos_vector(quad->posCoef, quad->x0, quad->y0, &machine->QuadPos); + setup_pos_vector(quad->posCoef, (float) quad->x0, (float) quad->y0, &machine->QuadPos); /* run shader */ #if defined(__i386__) || defined(__386__) diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c index 0c42963dfe..8660432259 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stipple.c +++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c @@ -36,6 +36,7 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; #if 1 + { const int col0 = quad->x0 % 32; if ((stipple0 & (bit31 >> col0)) == 0) quad->mask &= ~MASK_TOP_LEFT; @@ -48,6 +49,7 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) if ((stipple1 & (bit30 >> col0)) == 0) quad->mask &= ~MASK_BOTTOM_RIGHT; + } #else /* We'd like to use this code, but we'd need to redefine * MASK_TOP_LEFT to be (1 << 1) and MASK_TOP_RIGHT to be (1 << 0), diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 6c080d5b5c..d5119654ed 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -50,6 +50,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe, ps = pipe->winsys->surface_alloc(pipe->winsys); if (ps) { assert(ps->refcount); + assert(ps->winsys); pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer); ps->format = pt->format; ps->cpp = pt->cpp; @@ -71,45 +72,6 @@ softpipe_get_tex_surface(struct pipe_context *pipe, } -/** - * Copy 2D rect from one place to another. - * Position and sizes are in pixels. - */ -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte * src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * src_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -124,10 +86,10 @@ sp_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -144,14 +106,14 @@ sp_surface_copy(struct pipe_context *pipe, { assert( dst->cpp == src->cpp ); - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src), - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src), + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c index e5e6bfe01b..532bcfcc51 100644 --- a/src/mesa/pipe/softpipe/sp_texture.c +++ b/src/mesa/pipe/softpipe/sp_texture.c @@ -126,7 +126,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL); - free(spt); + FREE(spt); } *pt = NULL; } diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c index 6515ce668c..1974f77459 100644 --- a/src/mesa/pipe/softpipe/sp_tile_cache.c +++ b/src/mesa/pipe/softpipe/sp_tile_cache.c @@ -286,7 +286,7 @@ clear_tile(struct softpipe_cached_tile *tile, else { for (i = 0; i < TILE_SIZE; i++) { for (j = 0; j < TILE_SIZE; j++) { - tile->data.depth16[i][j] = clear_value; + tile->data.depth16[i][j] = (ushort) clear_value; } } } @@ -564,10 +564,10 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue) r = g = b = a = 0; } - tc->clear_color[0] = r / 255.0; - tc->clear_color[1] = g / 255.0; - tc->clear_color[2] = b / 255.0; - tc->clear_color[3] = a / 255.0; + tc->clear_color[0] = r / 255.0f; + tc->clear_color[1] = g / 255.0f; + tc->clear_color[2] = b / 255.0f; + tc->clear_color[3] = a / 255.0f; #if TILE_CLEAR_OPTIMIZATION /* set flags to indicate all the tiles are cleared */ diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h index cbf64ebb85..d6b379f58c 100644 --- a/src/mesa/pipe/softpipe/sp_winsys.h +++ b/src/mesa/pipe/softpipe/sp_winsys.h @@ -37,6 +37,7 @@ #include "pipe/p_compiler.h" /* for boolean */ +enum pipe_format; struct softpipe_winsys { /** test if the given format is supported for front/back color bufs */ diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c index 49affc12f3..dcc39362a9 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c @@ -1135,10 +1135,8 @@ store_dest( case TGSI_SAT_ZERO_ONE: /* XXX need to obey ExecMask here */ - micro_lt( dst, chan, &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], - &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], chan ); - micro_lt( dst, chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], - chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] ); + micro_max(dst, chan, &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]); + micro_min(dst, dst, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C]); break; case TGSI_SAT_MINUS_PLUS_ONE: @@ -1646,6 +1644,7 @@ exec_instruction( FETCH(&r[0], 0, chan_index); FETCH(&r[1], 1, chan_index); + /* XXX use micro_min()?? */ micro_lt( &r[0], &r[0], &r[1], &r[0], &r[1] ); STORE(&r[0], 0, chan_index); @@ -1657,6 +1656,7 @@ exec_instruction( FETCH(&r[0], 0, chan_index); FETCH(&r[1], 1, chan_index); + /* XXX use micro_max()?? */ micro_lt( &r[0], &r[0], &r[1], &r[1], &r[0] ); STORE(&r[0], 0, chan_index ); diff --git a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c b/src/mesa/pipe/tgsi/exec/tgsi_sse2.c index 8ee43f59b5..f8660e7ad1 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_sse2.c @@ -1967,6 +1967,7 @@ emit_instruction( break; case TGSI_OPCODE_RET: + case TGSI_OPCODE_END: #ifdef WIN32 emit_retw( func, 16 ); #else diff --git a/src/mesa/pipe/tgsi/util/tgsi_build.c b/src/mesa/pipe/tgsi/util/tgsi_build.c index 19b2aad921..67f7d2c2c2 100644 --- a/src/mesa/pipe/tgsi/util/tgsi_build.c +++ b/src/mesa/pipe/tgsi/util/tgsi_build.c @@ -365,7 +365,7 @@ tgsi_build_immediate( immediate = tgsi_default_immediate(); - header_bodysize_grow( header ); + header_bodysize_grow( header ); return immediate; } @@ -415,7 +415,7 @@ tgsi_build_full_immediate( struct tgsi_header *header, unsigned maxsize ) { - unsigned size = 0, i; + unsigned size = 0, i; struct tgsi_immediate *immediate; if( maxsize <= size ) @@ -433,7 +433,7 @@ tgsi_build_full_immediate( if32 = (struct tgsi_immediate_float32 *) &tokens[size]; size++; - *if32 = tgsi_build_immediate_float32( + *if32 = tgsi_build_immediate_float32( full_imm->u.ImmediateFloat32[i].Float, immediate, header ); diff --git a/src/mesa/pipe/util/p_util.c b/src/mesa/pipe/util/p_util.c new file mode 100644 index 0000000000..c4882b77d2 --- /dev/null +++ b/src/mesa/pipe/util/p_util.c @@ -0,0 +1,73 @@ +/************************************************************************** + * + * Copyright 2008 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. + * + **************************************************************************/ + +/** + * Miscellaneous utility functions. + */ + + +#include "pipe/p_defines.h" +#include "pipe/p_util.h" + + +/** + * Copy 2D rect from one place to another. + * Position and sizes are in pixels. + */ +void +pipe_copy_rect(ubyte * dst, + unsigned cpp, + unsigned dst_pitch, + unsigned dst_x, + unsigned dst_y, + unsigned width, + unsigned height, + const ubyte * src, + unsigned src_pitch, + unsigned src_x, + unsigned src_y) +{ + unsigned i; + + dst_pitch *= cpp; + src_pitch *= cpp; + dst += dst_x * cpp; + src += src_x * cpp; + dst += dst_y * dst_pitch; + src += src_y * src_pitch; + width *= cpp; + + if (width == dst_pitch && width == src_pitch) + memcpy(dst, src, height * width); + else { + for (i = 0; i < height; i++) { + memcpy(dst, src, width); + dst += dst_pitch; + src += src_pitch; + } + } +} diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 9a5290d920..d662e0b8b5 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1695,7 +1695,7 @@ parse_attrib (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head if (found) { error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", attrib_var->name); program_error(ctx, Program->Position, error_msg); _mesa_free (error_msg); @@ -1825,12 +1825,14 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst, break; case PARAM_CONSTANT: + /* parsing something like {1.0, 2.0, 3.0, 4.0} */ parse_constant (inst, const_values, Program, use); idx = _mesa_add_named_constant(Program->Base.Parameters, (char *) param_var->name, const_values, 4); if (param_var->param_binding_begin == ~0U) param_var->param_binding_begin = idx; + param_var->param_binding_type = PROGRAM_CONSTANT; param_var->param_binding_length++; Program->Base.NumParameters++; break; @@ -1878,7 +1880,7 @@ parse_param (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, if (found) { char *error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", param_var->name); program_error (ctx, Program->Position, error_msg); _mesa_free (error_msg); @@ -1978,7 +1980,7 @@ parse_temp (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, if (found) { char *error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", temp_var->name); program_error(ctx, Program->Position, error_msg); _mesa_free (error_msg); @@ -2024,7 +2026,7 @@ parse_output (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head if (found) { char *error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", output_var->name); program_error (ctx, Program->Position, error_msg); _mesa_free (error_msg); @@ -2055,7 +2057,7 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, if (found) { char *error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", temp_var->name); program_error(ctx, Program->Position, error_msg); _mesa_free (error_msg); @@ -2098,7 +2100,7 @@ parse_address (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_hea if (found) { char *error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", + _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s", temp_var->name); program_error (ctx, Program->Position, error_msg); _mesa_free (error_msg); diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 969b9757cc..1145f0c7a4 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -304,7 +304,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended) if (!extended) s[i++] = '.'; - if (negateBase & 0x1) + if (negateBase & NEGATE_X) s[i++] = '-'; s[i++] = swz[GET_SWZ(swizzle, 0)]; @@ -312,7 +312,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended) s[i++] = ','; } - if (negateBase & 0x2) + if (negateBase & NEGATE_Y) s[i++] = '-'; s[i++] = swz[GET_SWZ(swizzle, 1)]; @@ -320,7 +320,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended) s[i++] = ','; } - if (negateBase & 0x4) + if (negateBase & NEGATE_Z) s[i++] = '-'; s[i++] = swz[GET_SWZ(swizzle, 2)]; @@ -328,7 +328,7 @@ _mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended) s[i++] = ','; } - if (negateBase & 0x8) + if (negateBase & NEGATE_W) s[i++] = '-'; s[i++] = swz[GET_SWZ(swizzle, 3)]; diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index fc53b5737c..3869e31714 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -497,6 +497,13 @@ _mesa_combine_programs(GLcontext *ctx, newProg->NumInstructions = newLength; if (newProg->Target == GL_FRAGMENT_PROGRAM_ARB) { + struct gl_fragment_program *fprogA, *fprogB, *newFprog; + fprogA = (struct gl_fragment_program *) progA; + fprogB = (struct gl_fragment_program *) progB; + newFprog = (struct gl_fragment_program *) newProg; + + newFprog->UsesKill = fprogA->UsesKill || fprogB->UsesKill; + /* connect color outputs/inputs */ if ((progA->OutputsWritten & (1 << FRAG_RESULT_COLR)) && (progB->InputsRead & (1 << FRAG_ATTRIB_COL0))) { diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index fc5b0497fe..9eeb71db1b 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -192,13 +192,13 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) inst->DstReg.WriteMask = WRITEMASK_X; inst->SrcReg[0].File = PROGRAM_INPUT; inst->SrcReg[0].Index = FRAG_ATTRIB_FOGC; - inst->SrcReg[0].Swizzle = SWIZZLE_X; + inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; inst->SrcReg[1].File = PROGRAM_STATE_VAR; inst->SrcReg[1].Index = fogPRefOpt; - inst->SrcReg[1].Swizzle = SWIZZLE_X; + inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; inst->SrcReg[2].File = PROGRAM_STATE_VAR; inst->SrcReg[2].Index = fogPRefOpt; - inst->SrcReg[2].Swizzle = SWIZZLE_Y; + inst->SrcReg[2].Swizzle = SWIZZLE_YYYY; inst->SaturateMode = SATURATE_ZERO_ONE; inst++; } @@ -214,10 +214,10 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) inst->SrcReg[0].File = PROGRAM_STATE_VAR; inst->SrcReg[0].Index = fogPRefOpt; inst->SrcReg[0].Swizzle - = (fprog->FogOption == GL_EXP) ? SWIZZLE_Z : SWIZZLE_W; + = (fprog->FogOption == GL_EXP) ? SWIZZLE_ZZZZ : SWIZZLE_WWWW; inst->SrcReg[1].File = PROGRAM_INPUT; inst->SrcReg[1].Index = FRAG_ATTRIB_FOGC; - inst->SrcReg[1].Swizzle = SWIZZLE_X; + inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; inst++; if (fprog->FogOption == GL_EXP2) { /* MUL fogFactorTemp.x, fogFactorTemp.x, fogFactorTemp.x; */ @@ -227,10 +227,10 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) inst->DstReg.WriteMask = WRITEMASK_X; inst->SrcReg[0].File = PROGRAM_TEMPORARY; inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].Swizzle = SWIZZLE_X; + inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; inst->SrcReg[1].File = PROGRAM_TEMPORARY; inst->SrcReg[1].Index = fogFactorTemp; - inst->SrcReg[1].Swizzle = SWIZZLE_X; + inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; inst++; } /* EX2_SAT fogFactorTemp.x, -fogFactorTemp.x; */ @@ -240,8 +240,8 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) inst->DstReg.WriteMask = WRITEMASK_X; inst->SrcReg[0].File = PROGRAM_TEMPORARY; inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].NegateBase = GL_TRUE; - inst->SrcReg[0].Swizzle = SWIZZLE_X; + inst->SrcReg[0].NegateBase = NEGATE_XYZW; + inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; inst->SaturateMode = SATURATE_ZERO_ONE; inst++; } @@ -252,8 +252,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) inst->DstReg.WriteMask = WRITEMASK_XYZ; inst->SrcReg[0].File = PROGRAM_TEMPORARY; inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].Swizzle - = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X); + inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; inst->SrcReg[1].File = PROGRAM_TEMPORARY; inst->SrcReg[1].Index = colorTemp; inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; diff --git a/src/mesa/sources b/src/mesa/sources index 90ce9ce370..d8760ba134 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -191,7 +191,8 @@ STATECACHE_SOURCES = \ pipe/cso_cache/cso_cache.c PIPEUTIL_SOURCES = \ - pipe/util/p_tile.c + pipe/util/p_tile.c \ + pipe/util/p_util.c STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 35fd506458..beae36bca0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -110,7 +110,14 @@ static void update_raster_state( struct st_context *st ) * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Current) { - raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + if (ctx->VertexProgram._Enabled) { + /* user-defined program */ + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + } + else { + /* TNL-generated program */ + raster.light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; + } } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { raster.light_twoside = 1; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index f4d6b9362c..eaa88d3c6c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -158,6 +158,7 @@ make_bitmap_fragment_program(GLcontext *ctx) p->OutputsWritten = 0x0; stfp = (struct st_fragment_program *) p; + stfp->Base.UsesKill = GL_TRUE; st_translate_fragment_program(ctx->st, stfp, NULL, stfp->tokens, ST_MAX_SHADER_TOKENS); @@ -536,30 +537,31 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, { GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; + GLfloat sLeft = 0.0, sRight = 1.0; GLfloat tTop = invertTex, tBot = 1.0 - tTop; /* upper-left */ verts[0][0][0] = x0; /* attr[0].x */ - verts[0][0][1] = y0; /* attr[0].x */ - verts[0][1][0] = 0.0; /* attr[1].s */ + verts[0][0][1] = y0; /* attr[0].y */ + verts[0][1][0] = sLeft; /* attr[1].s */ verts[0][1][1] = tTop; /* attr[1].t */ /* upper-right */ verts[1][0][0] = x1; verts[1][0][1] = y0; - verts[1][1][0] = 1.0; + verts[1][1][0] = sRight; verts[1][1][1] = tTop; /* lower-right */ verts[2][0][0] = x1; verts[2][0][1] = y1; - verts[2][1][0] = 1.0; + verts[2][1][0] = sRight; verts[2][1][1] = tBot; /* lower-left */ verts[3][0][0] = x0; verts[3][0][1] = y1; - verts[3][1][0] = 0.0; + verts[3][1][0] = sLeft; verts[3][1][1] = tBot; /* same for all verts: */ @@ -581,30 +583,31 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, { GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */ GLuint i; + GLfloat sLeft = 0.0, sRight = 1.0; GLfloat tTop = invertTex, tBot = 1.0 - tTop; /* upper-left */ verts[0][0][0] = x0; /* attr[0].x */ verts[0][0][1] = y0; /* attr[0].y */ - verts[0][2][0] = 0.0; /* attr[2].s */ + verts[0][2][0] = sLeft; /* attr[2].s */ verts[0][2][1] = tTop; /* attr[2].t */ /* upper-right */ verts[1][0][0] = x1; verts[1][0][1] = y0; - verts[1][2][0] = 1.0; + verts[1][2][0] = sRight; verts[1][2][1] = tTop; /* lower-right */ verts[2][0][0] = x1; verts[2][0][1] = y1; - verts[2][2][0] = 1.0; + verts[2][2][0] = sRight; verts[2][2][1] = tBot; /* lower-left */ verts[3][0][0] = x0; verts[3][0][1] = y1; - verts[3][2][0] = 0.0; + verts[3][2][0] = sLeft; verts[3][2][1] = tBot; /* same for all verts: */ @@ -669,9 +672,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_sampler_state sampler; const struct cso_sampler *cso; memset(&sampler, 0, sizeof(sampler)); - sampler.wrap_s = PIPE_TEX_WRAP_REPEAT; - sampler.wrap_t = PIPE_TEX_WRAP_REPEAT; - sampler.wrap_r = PIPE_TEX_WRAP_REPEAT; + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP; + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP; + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP; sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 2d6b3fc749..f02cb3d133 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -93,6 +93,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, if (!strb->surface) { strb->surface = pipe->winsys->surface_alloc(pipe->winsys); assert(strb->surface); + assert(strb->surface->refcount); + assert(strb->surface->winsys); if (!strb->surface) return GL_FALSE; } diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index ed5ef1f159..78a8fde82b 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -28,6 +28,9 @@ #ifndef ST_PUBLIC_H #define ST_PUBLIC_H +#include "GL/gl.h" +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + #include "pipe/p_compiler.h" #include "pipe/p_format.h" |