diff options
Diffstat (limited to 'src/gallium/drivers/r300/r300_context.c')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.c | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index e8c09b214af..91263ad7bcd 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -35,7 +35,9 @@ #include "r300_screen_buffer.h" #include "r300_winsys.h" -#include <inttypes.h> +#ifdef HAVE_LLVM +#include "gallivm/lp_bld_init.h" +#endif static void r300_update_num_contexts(struct r300_screen *r300screen, int diff) @@ -44,14 +46,14 @@ static void r300_update_num_contexts(struct r300_screen *r300screen, p_atomic_inc(&r300screen->num_contexts); if (r300screen->num_contexts > 1) - util_mempool_set_thread_safety(&r300screen->pool_buffers, - UTIL_MEMPOOL_MULTITHREADED); + util_slab_set_thread_safety(&r300screen->pool_buffers, + UTIL_SLAB_MULTITHREADED); } else { p_atomic_dec(&r300screen->num_contexts); if (r300screen->num_contexts <= 1) - util_mempool_set_thread_safety(&r300screen->pool_buffers, - UTIL_MEMPOOL_SINGLETHREADED); + util_slab_set_thread_safety(&r300screen->pool_buffers, + UTIL_SLAB_SINGLETHREADED); } } @@ -88,6 +90,7 @@ static void r300_release_referenced_objects(struct r300_context *r300) /* Vertex buffers. */ for (i = 0; i < r300->vertex_buffer_count; i++) { pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL); + pipe_resource_reference(&r300->valid_vertex_buffer[i], NULL); } /* If there are any queries pending or not destroyed, remove them now. */ @@ -100,21 +103,15 @@ static void r300_release_referenced_objects(struct r300_context *r300) static void r300_destroy_context(struct pipe_context* context) { struct r300_context* r300 = r300_context(context); - struct r300_atom *atom; if (r300->blitter) util_blitter_destroy(r300->blitter); - if (r300->draw) + if (r300->draw) { draw_destroy(r300->draw); - /* Print stats, if enabled. */ - if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) { - fprintf(stderr, "r300: Stats for context %p:\n", r300); - fprintf(stderr, " : Flushes: %" PRIu64 "\n", r300->flush_counter); - foreach(atom, &r300->atom_list) { - fprintf(stderr, " : %s: %" PRIu64 " emits\n", - atom->name, atom->counter); - } +#ifdef HAVE_LLVM + gallivm_destroy(r300->gallivm); +#endif } if (r300->upload_vb) @@ -135,7 +132,7 @@ static void r300_destroy_context(struct pipe_context* context) r300->rws->cs_destroy(r300->cs); /* XXX: No way to tell if this was initialized or not? */ - util_mempool_destroy(&r300->pool_transfers); + util_slab_destroy(&r300->pool_transfers); r300_update_num_contexts(r300->screen, -1); @@ -177,10 +174,16 @@ void r300_flush_cb(void *data) r300->atomname.size = atomsize; \ r300->atomname.emit = r300_emit_##atomname; \ r300->atomname.dirty = FALSE; \ - insert_at_tail(&r300->atom_list, &r300->atomname); \ } while (0) -static void r300_setup_atoms(struct r300_context* r300) +#define R300_ALLOC_ATOM(atomname, statetype) \ +do { \ + r300->atomname.state = CALLOC_STRUCT(statetype); \ + if (r300->atomname.state == NULL) \ + return FALSE; \ +} while (0) + +static boolean r300_setup_atoms(struct r300_context* r300) { boolean is_rv350 = r300->screen->caps.is_rv350; boolean is_r500 = r300->screen->caps.is_r500; @@ -192,9 +195,6 @@ static void r300_setup_atoms(struct r300_context* r300) /* Create the actual atom list. * - * Each atom is examined and emitted in the order it appears here, which - * can affect performance and conformance if not handled with care. - * * Some atoms never change size, others change every emit - those have * the size of 0 here. * @@ -206,7 +206,6 @@ static void r300_setup_atoms(struct r300_context* r300) * - fb_state_pipelined (pipelined regs) * The motivation behind this is to be able to emit a strict * subset of the regs, and to have reasonable register ordering. */ - make_empty_list(&r300->atom_list); /* SC, GB (unpipelined), RB3D (unpipelined), ZB (unpipelined). */ R300_INIT_ATOM(gpu_flush, 9); R300_INIT_ATOM(aa_state, 4); @@ -261,23 +260,23 @@ static void r300_setup_atoms(struct r300_context* r300) } /* Some non-CSO atoms need explicit space to store the state locally. */ - r300->aa_state.state = CALLOC_STRUCT(r300_aa_state); - r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); - r300->clip_state.state = CALLOC_STRUCT(r300_clip_state); - r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state); - r300->gpu_flush.state = CALLOC_STRUCT(pipe_framebuffer_state); - r300->hyperz_state.state = CALLOC_STRUCT(r300_hyperz_state); - r300->invariant_state.state = CALLOC_STRUCT(r300_invariant_state); - r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); - r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); - r300->textures_state.state = CALLOC_STRUCT(r300_textures_state); - r300->vap_invariant_state.state = CALLOC_STRUCT(r300_vap_invariant_state); - r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); - r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); - r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer); - r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer); + R300_ALLOC_ATOM(aa_state, r300_aa_state); + R300_ALLOC_ATOM(blend_color_state, r300_blend_color_state); + R300_ALLOC_ATOM(clip_state, r300_clip_state); + R300_ALLOC_ATOM(hyperz_state, r300_hyperz_state); + R300_ALLOC_ATOM(invariant_state, r300_invariant_state); + R300_ALLOC_ATOM(textures_state, r300_textures_state); + R300_ALLOC_ATOM(vap_invariant_state, r300_vap_invariant_state); + R300_ALLOC_ATOM(viewport_state, r300_viewport_state); + R300_ALLOC_ATOM(ztop_state, r300_ztop_state); + R300_ALLOC_ATOM(fb_state, pipe_framebuffer_state); + R300_ALLOC_ATOM(gpu_flush, pipe_framebuffer_state); + R300_ALLOC_ATOM(scissor_state, pipe_scissor_state); + R300_ALLOC_ATOM(rs_block_state, r300_rs_block); + R300_ALLOC_ATOM(fs_constants, r300_constant_buffer); + R300_ALLOC_ATOM(vs_constants, r300_constant_buffer); if (!r300->screen->caps.has_tcl) { - r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state); + R300_ALLOC_ATOM(vertex_stream_state, r300_vertex_stream_state); } /* Some non-CSO atoms don't use the state pointer. */ @@ -289,11 +288,13 @@ static void r300_setup_atoms(struct r300_context* r300) /* Some states must be marked as dirty here to properly set up * hardware in the first command stream. */ - r300->invariant_state.dirty = TRUE; - r300->pvs_flush.dirty = TRUE; - r300->vap_invariant_state.dirty = TRUE; - r300->texture_cache_inval.dirty = TRUE; - r300->textures_state.dirty = TRUE; + r300_mark_atom_dirty(r300, &r300->invariant_state); + r300_mark_atom_dirty(r300, &r300->pvs_flush); + r300_mark_atom_dirty(r300, &r300->vap_invariant_state); + r300_mark_atom_dirty(r300, &r300->texture_cache_inval); + r300_mark_atom_dirty(r300, &r300->textures_state); + + return TRUE; } /* Not every state tracker calls every driver function before the first draw @@ -319,7 +320,7 @@ static void r300_init_states(struct pipe_context *pipe) pipe->set_scissor_state(pipe, &ss); /* Initialize the clip state. */ - if (r300_context(pipe)->screen->caps.has_tcl) { + if (r300->screen->caps.has_tcl) { pipe->set_clip_state(pipe, &cs); } else { BEGIN_CB(clip->cb, 2); @@ -421,9 +422,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, make_empty_list(&r300->query_list); - util_mempool_create(&r300->pool_transfers, - sizeof(struct pipe_transfer), 64, - UTIL_MEMPOOL_SINGLETHREADED); + util_slab_create(&r300->pool_transfers, + sizeof(struct pipe_transfer), 64, + UTIL_SLAB_SINGLETHREADED); r300->cs = rws->cs_create(rws); if (r300->cs == NULL) @@ -431,7 +432,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, if (!r300screen->caps.has_tcl) { /* Create a Draw. This is used for SW TCL. */ +#ifdef HAVE_LLVM + r300->gallivm = gallivm_create(); + r300->draw = draw_create_gallivm(&r300->context, r300->gallivm); +#else r300->draw = draw_create(&r300->context); +#endif + if (r300->draw == NULL) + goto fail; /* Enable our renderer. */ draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300)); /* Disable converting points/lines to triangles. */ @@ -439,7 +447,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, draw_wide_point_threshold(r300->draw, 10000000.f); } - r300_setup_atoms(r300); + if (!r300_setup_atoms(r300)) + goto fail; r300_init_blit_functions(r300); r300_init_flush_functions(r300); @@ -462,14 +471,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, goto fail; r300->upload_ib = u_upload_create(&r300->context, - 32 * 1024, 16, + 64 * 1024, 16, PIPE_BIND_INDEX_BUFFER); if (r300->upload_ib == NULL) goto fail; r300->upload_vb = u_upload_create(&r300->context, - 128 * 1024, 16, + 1024 * 1024, 16, PIPE_BIND_VERTEX_BUFFER); if (r300->upload_vb == NULL) goto fail; |