summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300/r300_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/r300/r300_context.c')
-rw-r--r--src/gallium/drivers/r300/r300_context.c109
1 files changed, 61 insertions, 48 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index fb099e2a7d..67b011a145 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -44,14 +44,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);
}
}
@@ -79,6 +79,9 @@ static void r300_release_referenced_objects(struct r300_context *r300)
NULL);
}
+ /* The dummy VBO. */
+ pipe_resource_reference(&r300->dummy_vb, NULL);
+
/* The SWTCL VBO. */
pipe_resource_reference(&r300->vbo, NULL);
@@ -97,23 +100,12 @@ 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)
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);
- }
- }
-
if (r300->upload_vb)
u_upload_destroy(r300->upload_vb);
if (r300->upload_ib)
@@ -132,7 +124,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);
@@ -174,10 +166,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;
@@ -189,9 +187,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.
*
@@ -203,7 +198,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);
@@ -258,23 +252,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. */
@@ -286,11 +280,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
@@ -316,7 +312,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);
@@ -418,9 +414,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)
@@ -429,6 +425,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
if (!r300screen->caps.has_tcl) {
/* Create a Draw. This is used for SW TCL. */
r300->draw = draw_create(&r300->context);
+ 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. */
@@ -436,7 +434,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);
@@ -488,6 +487,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
rtempl.target = PIPE_TEXTURE_2D;
rtempl.format = PIPE_FORMAT_I8_UNORM;
rtempl.bind = PIPE_BIND_SAMPLER_VIEW;
+ rtempl.usage = PIPE_USAGE_IMMUTABLE;
rtempl.width0 = 1;
rtempl.height0 = 1;
rtempl.depth0 = 1;
@@ -501,6 +501,19 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
pipe_resource_reference(&tex, NULL);
}
+ {
+ struct pipe_resource vb = {};
+ vb.target = PIPE_BUFFER;
+ vb.format = PIPE_FORMAT_R8_UNORM;
+ vb.bind = PIPE_BIND_VERTEX_BUFFER;
+ vb.usage = PIPE_USAGE_IMMUTABLE;
+ vb.width0 = sizeof(float) * 16;
+ vb.height0 = 1;
+ vb.depth0 = 1;
+
+ r300->dummy_vb = screen->resource_create(screen, &vb);
+ }
+
return &r300->context;
fail: