diff options
author | Marek Olšák <[email protected]> | 2011-02-18 15:29:00 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-02-18 16:15:03 +0100 |
commit | fd8d4b32ede6ebeae332539b71d38c36420e2654 (patch) | |
tree | b885d31842ac9d76046872f2110a413fed4401f5 /src/gallium | |
parent | bb46eeade3a3eb604aba5c084d1e21942c2fa2ac (diff) |
r300g: remove tracking whether vertex buffers need to be validated
This was getting hard to maintain and didn't really bring any real benefits.
Instead, validate buffers when the vertex array state is dirty.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 7 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_flush.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 85 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render_translate.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_screen_buffer.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 9 |
7 files changed, 27 insertions, 88 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 883b5f99c07..30073759476 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -575,13 +575,6 @@ struct r300_context { boolean vertex_arrays_dirty; boolean vertex_arrays_indexed; int vertex_arrays_offset; - - /* Whether any buffer (FB, textures, VBOs) has been set, but buffers - * haven't been validated yet. */ - boolean validate_buffers; - /* Whether user buffers have been validated. */ - boolean upload_vb_validated; - boolean upload_ib_validated; }; #define foreach_atom(r300, atom) \ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index bd864b96167..e2e4719ec82 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1181,7 +1181,7 @@ validate: r300->rws->cs_add_reloc(r300->cs, r300_resource(r300->vbo)->cs_buf, r300_resource(r300->vbo)->domain, 0); /* ...vertex buffers for HWTCL path... */ - if (do_validate_vertex_buffers) { + if (do_validate_vertex_buffers && r300->vertex_arrays_dirty) { struct pipe_resource **buf = r300->vbuf_mgr->real_vertex_buffer; struct pipe_resource **last = r300->vbuf_mgr->real_vertex_buffer + r300->vbuf_mgr->nr_real_vertex_buffers; diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index c4bb332aec3..c77cc08539d 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -77,10 +77,6 @@ static void r300_flush(struct pipe_context* pipe, r300->vs_state.dirty = FALSE; r300->vs_constants.dirty = FALSE; } - - r300->validate_buffers = TRUE; - r300->upload_vb_validated = FALSE; - r300->upload_ib_validated = FALSE; } else { if (rfence) { /* We have to create a fence object, but the command stream is empty diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7dc8ff08fa4..2ead8667bda 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -239,8 +239,7 @@ static boolean r300_emit_states(struct r300_context *r300, enum r300_prepare_flags flags, struct pipe_resource *index_buffer, int buffer_offset, - int index_bias, - boolean user_buffers) + int index_bias) { boolean first_draw = flags & PREP_FIRST_DRAW; boolean emit_vertex_arrays = flags & PREP_EMIT_AOS; @@ -250,24 +249,11 @@ static boolean r300_emit_states(struct r300_context *r300, /* Validate buffers and emit dirty state if needed. */ if (first_draw) { - if (r300->validate_buffers) { - if (!r300_emit_buffer_validate(r300, validate_vbos, - index_buffer)) { - fprintf(stderr, "r300: CS space validation failed. " - "(not enough memory?) Skipping rendering.\n"); - return FALSE; - } - - /* Consider the validation done only if everything was validated. */ - if (validate_vbos) { - r300->validate_buffers = FALSE; - if (user_buffers) - r300->upload_vb_validated = TRUE; - if (r300->index_buffer.buffer && - r300_resource(r300->index_buffer.buffer)->b.user_ptr) { - r300->upload_ib_validated = TRUE; - } - } + if (!r300_emit_buffer_validate(r300, validate_vbos, + index_buffer)) { + fprintf(stderr, "r300: CS space validation failed. " + "(not enough memory?) Skipping rendering.\n"); + return FALSE; } r300_emit_dirty_state(r300); @@ -312,14 +298,13 @@ static boolean r300_prepare_for_rendering(struct r300_context *r300, struct pipe_resource *index_buffer, unsigned cs_dwords, int buffer_offset, - int index_bias, - boolean user_buffers) + int index_bias) { if (r300_reserve_cs_dwords(r300, flags, cs_dwords)) flags |= PREP_FIRST_DRAW; return r300_emit_states(r300, flags, index_buffer, buffer_offset, - index_bias, user_buffers); + index_bias); } static boolean immd_is_good_idea(struct r300_context *r300, @@ -394,8 +379,7 @@ static void r300_draw_arrays_immediate(struct r300_context *r300, CS_LOCALS(r300); - if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0, - FALSE)) + if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0)) return; /* Calculate the vertex size, offsets, strides etc. and map the buffers. */ @@ -545,8 +529,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, static void r300_draw_elements_immediate(struct r300_context *r300, int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, - unsigned start, unsigned count, - boolean user_buffers) + unsigned start, unsigned count) { uint8_t *ptr1; uint16_t *ptr2; @@ -558,8 +541,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, /* 19 dwords for r300_draw_elements_immediate. Give up if the function fails. */ if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS | - PREP_INDEXED, NULL, 2+count_dwords, 0, indexBias, - user_buffers)) + PREP_INDEXED, NULL, 2+count_dwords, 0, indexBias)) return; r300_emit_draw_init(r300, mode, minIndex, maxIndex); @@ -632,8 +614,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, static void r300_draw_elements(struct r300_context *r300, int indexBias, unsigned minIndex, unsigned maxIndex, - unsigned mode, unsigned start, unsigned count, - boolean user_buffers) + unsigned mode, unsigned start, unsigned count) { struct pipe_resource *indexBuffer = r300->index_buffer.buffer; unsigned indexSize = r300->index_buffer.index_size; @@ -681,8 +662,7 @@ static void r300_draw_elements(struct r300_context *r300, int indexBias, /* 19 dwords for emit_draw_elements. Give up if the function fails. */ if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS | - PREP_INDEXED, indexBuffer, 19, buffer_offset, indexBias, - user_buffers)) + PREP_INDEXED, indexBuffer, 19, buffer_offset, indexBias)) goto done; if (alt_num_verts || count <= 65535) { @@ -706,7 +686,7 @@ static void r300_draw_elements(struct r300_context *r300, int indexBias, if (count) { if (!r300_prepare_for_rendering(r300, PREP_VALIDATE_VBOS | PREP_EMIT_AOS | PREP_INDEXED, - indexBuffer, 19, buffer_offset, indexBias, user_buffers)) + indexBuffer, 19, buffer_offset, indexBias)) goto done; } } while (count); @@ -719,8 +699,7 @@ done: } static void r300_draw_arrays(struct r300_context *r300, unsigned mode, - unsigned start, unsigned count, - boolean user_buffers) + unsigned start, unsigned count) { boolean alt_num_verts = r300->screen->caps.is_r500 && count > 65536 && @@ -730,7 +709,7 @@ static void r300_draw_arrays(struct r300_context *r300, unsigned mode, /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */ if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS, - NULL, 9, start, 0, user_buffers)) + NULL, 9, start, 0)) return; if (alt_num_verts || count <= 65535) { @@ -747,7 +726,7 @@ static void r300_draw_arrays(struct r300_context *r300, unsigned mode, if (count) { if (!r300_prepare_for_rendering(r300, PREP_VALIDATE_VBOS | PREP_EMIT_AOS, NULL, 9, - start, 0, user_buffers)) + start, 0)) return; } } while (count); @@ -774,13 +753,6 @@ static void r300_draw_vbo(struct pipe_context* pipe, &buffers_updated, &uploader_flushed); if (buffers_updated) { r300->vertex_arrays_dirty = TRUE; - - if (uploader_flushed || !r300->upload_vb_validated) { - r300->upload_vb_validated = FALSE; - r300->validate_buffers = TRUE; - } - } else { - r300->upload_vb_validated = FALSE; } /* Draw. */ @@ -791,19 +763,16 @@ static void r300_draw_vbo(struct pipe_context* pipe, r300_resource(r300->index_buffer.buffer)->b.user_ptr) { r300_draw_elements_immediate(r300, info->index_bias, info->min_index, max_index, - info->mode, start_indexed, count, - buffers_updated); + info->mode, start_indexed, count); } else { r300_draw_elements(r300, info->index_bias, info->min_index, - max_index, info->mode, start_indexed, count, - buffers_updated); + max_index, info->mode, start_indexed, count); } } else { if (immd_is_good_idea(r300, count)) { r300_draw_arrays_immediate(r300, info->mode, info->start, count); } else { - r300_draw_arrays(r300, info->mode, info->start, count, - buffers_updated); + r300_draw_arrays(r300, info->mode, info->start, count); } } @@ -935,7 +904,6 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render, R300_MAX_DRAW_VBO_SIZE); r300->draw_vbo_offset = 0; r300->draw_vbo_size = R300_MAX_DRAW_VBO_SIZE; - r300->validate_buffers = TRUE; } r300render->vertex_size = vertex_size; @@ -1022,12 +990,12 @@ static void r300_render_draw_arrays(struct vbuf_render* render, if (r300->draw_first_emitted) { if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_EMIT_AOS_SWTCL, - NULL, dwords, 0, 0, FALSE)) + NULL, dwords, 0, 0)) return; } else { if (!r300_emit_states(r300, PREP_FIRST_DRAW | PREP_EMIT_AOS_SWTCL, - NULL, 0, 0, FALSE)) + NULL, 0, 0)) return; } @@ -1062,12 +1030,12 @@ static void r300_render_draw_elements(struct vbuf_render* render, if (r300->draw_first_emitted) { if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_EMIT_AOS_SWTCL | PREP_INDEXED, - NULL, 256, 0, 0, FALSE)) + NULL, 256, 0, 0)) return; } else { if (!r300_emit_states(r300, PREP_FIRST_DRAW | PREP_EMIT_AOS_SWTCL | PREP_INDEXED, - NULL, 0, 0, FALSE)) + NULL, 0, 0)) return; } @@ -1104,7 +1072,7 @@ static void r300_render_draw_elements(struct vbuf_render* render, if (count) { if (!r300_prepare_for_rendering(r300, PREP_EMIT_AOS_SWTCL | PREP_INDEXED, - NULL, 256, 0, 0, FALSE)) + NULL, 256, 0, 0)) return; end_cs_dwords = r300_get_num_cs_end_dwords(r300); @@ -1208,8 +1176,7 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, r300->clip_state.dirty = FALSE; r300->viewport_state.dirty = FALSE; - if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0, - FALSE)) + if (!r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0)) goto done; DBG(r300, DBG_DRAW, "r300: draw_rectangle\n"); diff --git a/src/gallium/drivers/r300/r300_render_translate.c b/src/gallium/drivers/r300/r300_render_translate.c index 777857514fc..f8c7558f4b4 100644 --- a/src/gallium/drivers/r300/r300_render_translate.c +++ b/src/gallium/drivers/r300/r300_render_translate.c @@ -48,7 +48,6 @@ void r300_translate_index_buffer(struct r300_context *r300, pipe_resource_reference(index_buffer, out_buffer); *index_size = 2; *start = out_offset / 2; - r300->validate_buffers = TRUE; break; case 2: @@ -63,7 +62,6 @@ void r300_translate_index_buffer(struct r300_context *r300, *index_buffer = NULL; pipe_resource_reference(index_buffer, out_buffer); *start = out_offset / 2; - r300->validate_buffers = TRUE; } break; @@ -79,7 +77,6 @@ void r300_translate_index_buffer(struct r300_context *r300, *index_buffer = NULL; pipe_resource_reference(index_buffer, out_buffer); *start = out_offset / 4; - r300->validate_buffers = TRUE; } break; } diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 7855d70a973..1045911f3ae 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -65,11 +65,6 @@ void r300_upload_index_buffer(struct r300_context *r300, index_buffer, &flushed); *start = index_offset / index_size; - - if (flushed || !r300->upload_ib_validated) { - r300->upload_ib_validated = FALSE; - r300->validate_buffers = TRUE; - } } static void r300_buffer_destroy(struct pipe_screen *screen, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 5d8298341d3..09f18b3e624 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -783,7 +783,6 @@ r300_set_framebuffer_state(struct pipe_context* pipe, } r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE); - r300->validate_buffers = TRUE; if (state->zsbuf) { switch (util_format_get_blocksize(state->zsbuf->texture->format)) { @@ -1359,7 +1358,6 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, state->sampler_view_count = count; r300_mark_atom_dirty(r300, &r300->textures_state); - r300->validate_buffers = TRUE; if (dirty_tex) { r300_mark_atom_dirty(r300, &r300->texture_cache_inval); @@ -1491,7 +1489,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, for (i = 0; i < count; i++) { if (buffers[i].buffer && !r300_resource(buffers[i].buffer)->b.user_ptr) { - r300->validate_buffers = TRUE; } } r300->vertex_arrays_dirty = TRUE; @@ -1512,12 +1509,6 @@ static void r300_set_index_buffer(struct pipe_context* pipe, pipe_resource_reference(&r300->index_buffer.buffer, ib->buffer); memcpy(&r300->index_buffer, ib, sizeof(r300->index_buffer)); r300->index_buffer.offset /= r300->index_buffer.index_size; - - if (r300->screen->caps.has_tcl && - !r300_resource(ib->buffer)->b.user_ptr) { - r300->validate_buffers = TRUE; - r300->upload_ib_validated = FALSE; - } } else { pipe_resource_reference(&r300->index_buffer.buffer, NULL); |