diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2007-05-12 17:32:01 +0100 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2007-05-12 17:32:01 +0100 |
commit | 157bd1cb1267bc60a2189affe72f5bfa2093ae38 (patch) | |
tree | acef0007ad9c56cb21275496203c3e6853170bd8 | |
parent | 6ef242759af78e3a7da8e0a9a34efa49e7bc104d (diff) |
Remove debug, fix up culling for swz triangles
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 24 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_cmdstream.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_frame_tracker.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_swrast.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_swz.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_swz.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_swz_prims.c | 140 |
7 files changed, 123 insertions, 69 deletions
diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index b23dd914e5..21d10dd640 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -104,22 +104,6 @@ static void dump(struct intel_context *intel, } -const GLuint foo[] = { -0x7d800003, 0x00000000, 0x00000000, 0x001f003f, 0x00000000, 0x7d040ff7, 0x08300000, 0x04040000, -0xffffffff, 0x00000000, 0x00902440, 0x00000002, 0x00000006, 0x00000000, 0x7d071202, 0x2c20002b, - 0x2c201003, 0x00000006, 0x7f280005, 0x43000000, 0x42000000, 0x00000000, 0x42000000, 0x00000000, - 0x00000000, 0x7f820000, 0x00010000, 0xffff0002, 0x05000000, 0x00000000, 0x00000000, 0x00000000 -}; - -static void dump_foo( struct intel_context *intel ) -{ - GLuint offset = 0xeabcf000; - _mesa_printf("FOO\n"); - dump(intel, foo, offset, offset + sizeof(foo), 0); - _mesa_printf("END_FOO\n"); -} - - static void intel_dump_batchbuffer(struct intel_batchbuffer *batch, GLubyte *batch_map, @@ -244,9 +228,6 @@ intel_batchbuffer_alloc(struct intel_context *intel) batch->max_relocs = page_size / sizeof(struct buffer_reloc); - //dump_foo(intel); - (void) dump_foo; - batch->intel = intel; driGenBuffers(intel->intelScreen->batchPool, "batchbuffer", 1, @@ -449,8 +430,9 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch, if (used == 0) return batch->last_fence; - - _mesa_printf("%s used %d relocs: %d\n", __FUNCTION__, used, batch->nr_relocs); + + if (0) + _mesa_printf("%s used %d relocs: %d\n", __FUNCTION__, used, batch->nr_relocs); assert(used < SEGMENT_SZ); diff --git a/src/mesa/drivers/dri/i915tex/intel_cmdstream.c b/src/mesa/drivers/dri/i915tex/intel_cmdstream.c index 57de58cbeb..48068dd766 100644 --- a/src/mesa/drivers/dri/i915tex/intel_cmdstream.c +++ b/src/mesa/drivers/dri/i915tex/intel_cmdstream.c @@ -58,8 +58,9 @@ void intel_cmdstream_use_batch_range( struct intel_context *intel, */ void intel_cmdstream_reset( struct intel_context *intel ) { - _mesa_printf("%s used %x of %x\n", __FUNCTION__, - intel->cmdstream.used, intel->cmdstream.size); + if (0) + _mesa_printf("%s used %x of %x\n", __FUNCTION__, + intel->cmdstream.used, intel->cmdstream.size); intel->cmdstream.map = intel->batch->map + intel->cmdstream.offset; intel->cmdstream.used = 0; diff --git a/src/mesa/drivers/dri/i915tex/intel_frame_tracker.c b/src/mesa/drivers/dri/i915tex/intel_frame_tracker.c index 072efee74b..71c94fe2d0 100644 --- a/src/mesa/drivers/dri/i915tex/intel_frame_tracker.c +++ b/src/mesa/drivers/dri/i915tex/intel_frame_tracker.c @@ -276,9 +276,9 @@ void intel_frame_set_mode( struct intel_frame_tracker *ft, if (ft->mode == new_mode) return; - _mesa_printf("transiton %s -> %s\n", - mode_name[ft->mode], - mode_name[new_mode]); + if (0) _mesa_printf("transiton %s -> %s\n", + mode_name[ft->mode], + mode_name[new_mode]); switch (ft->mode) { case INTEL_FT_SWAP_BUFFERS: diff --git a/src/mesa/drivers/dri/i915tex/intel_swrast.c b/src/mesa/drivers/dri/i915tex/intel_swrast.c index 2819bb6566..9fa658151b 100644 --- a/src/mesa/drivers/dri/i915tex/intel_swrast.c +++ b/src/mesa/drivers/dri/i915tex/intel_swrast.c @@ -82,9 +82,6 @@ static void *swrender_allocate_vertices( struct intel_render *render, assert(vertex_size == swrender->vf->vertex_stride); - _mesa_printf("%s %d %d %p\n", __FUNCTION__, vertex_size, nr_vertices, - swrender->hw_verts); - return swrender->hw_verts; } @@ -246,7 +243,6 @@ static void swrender_draw_prim( struct intel_render *render, case GL_LINE_STRIP: for (i = 0; i+1 < nr; i++) { - _mesa_printf("line %d %d\n", i, i+1); line( swrender, get_vertex(swrender, start+i), get_vertex(swrender, start+i+1) ); @@ -408,7 +404,7 @@ static void swrender_start_render( struct intel_render *render, struct swrast_render *swrender = swrast_render( render ); struct intel_context *intel = swrender->intel; - _mesa_printf("%s\n", __FUNCTION__); + //_mesa_printf("%s\n", __FUNCTION__); /* Wait for pending flip. */ diff --git a/src/mesa/drivers/dri/i915tex/intel_swz.c b/src/mesa/drivers/dri/i915tex/intel_swz.c index 7641261d8e..7ce07904c9 100644 --- a/src/mesa/drivers/dri/i915tex/intel_swz.c +++ b/src/mesa/drivers/dri/i915tex/intel_swz.c @@ -119,7 +119,6 @@ static void init_zones( struct swz_render *swz ) space = intel->vtbl.get_state_emit_size( intel, swz->initial_driver_flags ); - _mesa_printf("draw origin: %d,%d\n", intel->drawX, intel->drawY); for (i = y = 0; y < swz->zone_height; y++) { @@ -189,7 +188,7 @@ static void swz_start_render( struct intel_render *render, swz->nr_zones = swz->zone_width * swz->zone_height; assert(swz->nr_zones < MAX_ZONES); - if (1) _mesa_printf("%s %dx%d --> %dx%d\n", + if (0) _mesa_printf("%s %dx%d --> %dx%d\n", __FUNCTION__, intel->driDrawable->w, intel->driDrawable->h, @@ -295,7 +294,7 @@ static void swz_flush( struct intel_render *render, GLuint i = 0; GLuint x, y; - _mesa_printf("%s finished: %d\n", __FUNCTION__, finished); + if (0) _mesa_printf("%s finished: %d\n", __FUNCTION__, finished); if (swz->started_binning) { @@ -432,7 +431,6 @@ static void swz_clear( struct intel_render *render, } else { - _mesa_printf("%d, %d\n", x2, y2); swz_clear_rect( render, mask, x1, y1, x2, y2 ); } @@ -443,7 +441,6 @@ static void swz_clear( struct intel_render *render, static void swz_destroy_context( struct intel_render *render ) { struct swz_render *swz = swz_render( render ); - _mesa_printf("%s\n", __FUNCTION__); _mesa_free(swz->last_driver_state); _mesa_free(swz->initial_driver_state); diff --git a/src/mesa/drivers/dri/i915tex/intel_swz.h b/src/mesa/drivers/dri/i915tex/intel_swz.h index d6dd447c57..7a875005f3 100644 --- a/src/mesa/drivers/dri/i915tex/intel_swz.h +++ b/src/mesa/drivers/dri/i915tex/intel_swz.h @@ -80,6 +80,7 @@ struct swz_render { GLuint vbo_offset; GLfloat xoff, yoff; + GLfloat cull; struct intel_hw_dirty reset_state; @@ -330,7 +331,7 @@ static INLINE void zone_loadreg_imm( struct swz_zone *zone, { GLuint *out = zone_get_dwords( zone, 3 ); - _mesa_printf("zone_loadreg_imm: %x / %08x\n", reg, value); + //_mesa_printf("zone_loadreg_imm: %x / %08x\n", reg, value); out[0] = MI_LOAD_REGISTER_IMM; out[1] = reg; @@ -354,7 +355,6 @@ static INLINE void zone_get_space( struct swz_render *swz, GLubyte *newptr = intel_cmdstream_alloc_block( swz->intel ); if (newptr == NULL) { - _mesa_printf("FLUSHING ****************\n"); intel_frame_flush_and_restart( swz->intel->ft ); } else { diff --git a/src/mesa/drivers/dri/i915tex/intel_swz_prims.c b/src/mesa/drivers/dri/i915tex/intel_swz_prims.c index 63e9fd6156..a84399eaa1 100644 --- a/src/mesa/drivers/dri/i915tex/intel_swz_prims.c +++ b/src/mesa/drivers/dri/i915tex/intel_swz_prims.c @@ -65,6 +65,20 @@ static void invalidate_bins( struct swz_render *swz ) swz->draws++; + switch(intel->draw_state.cull_mode) { + case WINDING_NONE: + case WINDING_BOTH: + swz->cull = 0; + break; + case WINDING_CW: + swz->cull = -1; + break; + case WINDING_CCW: + swz->cull = 1; + break; + } + + { /* XXX: only want to do this once per VB, not once per prim... */ @@ -174,25 +188,85 @@ static void tri( struct swz_render *swz, i1 += swz->vbo_offset; i2 += swz->vbo_offset; -#if 0 - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; + x0 = v0[0]; + x1 = v0[0]; + y0 = v0[1]; + y1 = v0[1]; + + if (x0 > v1[0]) x0 = v1[0]; + if (x0 > v2[0]) x0 = v2[0]; + if (y0 > v1[1]) y0 = v1[1]; + if (y0 > v2[1]) y0 = v2[1]; + + if (x1 < v1[0]) x1 = v1[0]; + if (x1 < v2[0]) x1 = v2[0]; + if (y1 < v1[1]) y1 = v1[1]; + if (y1 < v2[1]) y1 = v2[1]; + + zone_x0 = x0 + swz->xoff; + zone_x1 = x1 + swz->xoff; + zone_y0 = y0 + swz->yoff; + zone_y1 = y1 + swz->yoff; + + zone_x0 /= ZONE_WIDTH; + zone_x1 /= ZONE_WIDTH; + zone_y0 /= ZONE_HEIGHT; + zone_y1 /= ZONE_HEIGHT; + + if (zone_x0 < 0) zone_x0 = 0; + if (zone_y0 < 0) zone_y0 = 0; + if (zone_x1 >= swz->zone_width) zone_x1 = swz->zone_width-1; + if (zone_y1 >= swz->zone_height) zone_y1 = swz->zone_height-1; - GLfloat det = ex * fy - ey * fx; - - if (det >= 0) - return; -#endif - - /* Calculate bounds: NOTE: reading back from the vbo - must be - * declared with appropriate flags. - * - * Almost all of the slowdown of swz relative to other rendering is - * attributable to this calculation. Need an optimized sse version - * to get performance back. + + if (0) _mesa_printf("tri (%f..%f)x(%f..%f) --> (%d..%d)x(%d..%d)\n", + x0, x1, y0, y1, + zone_x0, zone_x1, zone_y0, zone_y1 ); + + + /* Emit to each zone: */ + for (y = zone_y0; y <= zone_y1; y++) { + struct swz_zone *zone = &swz->zone[y * swz->zone_width + zone_x0]; + + for (x = zone_x0; x <= zone_x1; x++, zone++) { + zone_update_state(swz, zone, ZONE_TRIS, ZONE_PRIM_SPACE ); + zone_emit_tri(zone, i0, i1, i2); + ASSERT(intel_cmdstream_space(zone->ptr) >= ZONE_WRAP_SPACE); + } + } +} + + +static void cull_tri( struct swz_render *swz, + GLuint i0, + GLuint i1, + GLuint i2 ) +{ + GLfloat x0, x1, y0, y1; + GLint zone_x0, zone_x1, zone_y0, zone_y1; + GLint x,y; + + const GLfloat *v0 = get_vertex(swz, i0); + const GLfloat *v1 = get_vertex(swz, i1); + const GLfloat *v2 = get_vertex(swz, i2); + + i0 += swz->vbo_offset; + i1 += swz->vbo_offset; + i2 += swz->vbo_offset; + + { + GLfloat ex = v0[0] - v2[0]; + GLfloat ey = v0[1] - v2[1]; + GLfloat fx = v1[0] - v2[0]; + GLfloat fy = v1[1] - v2[1]; + + GLfloat det = ex * fy - ey * fx; + + if (det * swz->cull > 0) + return; + } + x0 = v0[0]; x1 = v0[0]; y0 = v0[1]; @@ -377,7 +451,7 @@ void swz_clear_rect( struct intel_render *render, GLint zone_x0, zone_x1, zone_y0, zone_y1; GLint x, y; - _mesa_printf("%s %d..%d %d..%d\n", __FUNCTION__, x0, x1, y0, y1); + if (0) _mesa_printf("%s %d..%d %d..%d\n", __FUNCTION__, x0, x1, y0, y1); assert( swz->started_binning ); @@ -417,7 +491,7 @@ void swz_zone_init( struct intel_render *render, GLint zone_x0, zone_x1, zone_y0, zone_y1; GLint x, y; - _mesa_printf("%s %d..%d %d..%d\n", __FUNCTION__, x0, x1, y0, y1); + if (0) _mesa_printf("%s %d..%d %d..%d\n", __FUNCTION__, x0, x1, y0, y1); assert( swz->started_binning ); @@ -446,7 +520,8 @@ void swz_zone_init( struct intel_render *render, - +typedef void (*trifunc)( struct swz_render *swz, + GLuint, GLuint, GLuint ); static void swz_draw_prim( struct intel_render *render, @@ -459,6 +534,8 @@ static void swz_draw_prim( struct intel_render *render, invalidate_bins( swz ); + trifunc do_tri = swz->cull ? cull_tri : tri; + switch (swz->prim) { case GL_POINTS: for (i = 0; i < nr; i++) { @@ -477,7 +554,6 @@ static void swz_draw_prim( struct intel_render *render, case GL_LINE_STRIP: for (i = 0; i+1 < nr; i++) { - _mesa_printf("line %d %d\n", i, i+1); line( swz, start+i, start+i+1 ); @@ -486,7 +562,7 @@ static void swz_draw_prim( struct intel_render *render, case GL_TRIANGLES: for (i = 0; i+2 < nr; i += 3) { - tri( swz, + do_tri( swz, start+i, start+i+1, start+i+2 ); @@ -496,12 +572,12 @@ static void swz_draw_prim( struct intel_render *render, case GL_TRIANGLE_STRIP: for (i = 0; i+2 < nr; i++) { if (i & 1) - tri( swz, + do_tri( swz, start+i+1, start+i+0, start+i+2 ); else - tri( swz, + do_tri( swz, start+i+0, start+i+1, start+i+2 ); @@ -510,7 +586,7 @@ static void swz_draw_prim( struct intel_render *render, case GL_TRIANGLE_FAN: for (i = 0; i+2 < nr; i++) { - tri( swz, + do_tri( swz, start+0, start+i+1, start+i+2 ); @@ -519,7 +595,7 @@ static void swz_draw_prim( struct intel_render *render, case GL_POLYGON: for (i = 0; i+2 < nr; i++) { - tri( swz, + do_tri( swz, start+i+1, start+i+2, start+0 ); @@ -543,6 +619,8 @@ static void swz_draw_indexed_prim( struct intel_render *render, invalidate_bins( swz ); + trifunc do_tri = swz->cull ? cull_tri : tri; + switch (swz->prim) { case GL_POINTS: for (i = 0; i < nr; i++) { @@ -569,7 +647,7 @@ static void swz_draw_indexed_prim( struct intel_render *render, case GL_TRIANGLES: for (i = 0; i+2 < nr; i += 3) { - tri( swz, + do_tri( swz, indices[i], indices[i+1], indices[i+2] ); @@ -579,12 +657,12 @@ static void swz_draw_indexed_prim( struct intel_render *render, case GL_TRIANGLE_STRIP: for (i = 0; i+2 < nr; i++) { if (i & 1) - tri( swz, + do_tri( swz, indices[i+1], indices[i+0], indices[i+2] ); else - tri( swz, + do_tri( swz, indices[i+0], indices[i+1], indices[i+2] ); @@ -593,7 +671,7 @@ static void swz_draw_indexed_prim( struct intel_render *render, case GL_TRIANGLE_FAN: for (i = 0; i+2 < nr; i++) { - tri( swz, + do_tri( swz, indices[0], indices[i+1], indices[i+2] ); @@ -602,7 +680,7 @@ static void swz_draw_indexed_prim( struct intel_render *render, case GL_POLYGON: for (i = 0; i+2 < nr; i++) { - tri( swz, + do_tri( swz, indices[i+1], indices[i+2], indices[0] ); |