r300-gallium: Finish space accounting.

Still broken...
This commit is contained in:
Corbin Simpson 2009-05-08 15:28:09 -07:00
parent 1d11220771
commit 4816764777
4 changed files with 66 additions and 26 deletions

View file

@ -264,6 +264,11 @@ struct r300_context {
/* Draw module. Used mostly for SW TCL. */
struct draw_context* draw;
/* Vertex buffer for rendering. */
struct pipe_buffer* vbo;
/* Offset into the VBO. */
size_t vbo_offset;
/* Various CSO state objects. */
/* Blend state. */
struct r300_blend_state* blend_state;
@ -289,7 +294,7 @@ struct r300_context {
/* Texture states. */
struct r300_texture* textures[8];
int texture_count;
/* Vertex buffers. */
/* Vertex buffers for Gallium. */
struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
int vertex_buffer_count;
/* Vertex information. */

View file

@ -296,6 +296,30 @@ void r300_emit_texture(struct r300_context* r300,
END_CS;
}
void r300_emit_vertex_buffer(struct r300_context* r300)
{
CS_LOCALS(r300);
debug_printf("r300: Preparing vertex buffer %p for render, "
"vertex size %d\n", r300->vbo,
r300->vertex_info.vinfo.size);
/* Set the pointer to our vertex buffer. The emitted values are this:
* PACKET3 [3D_LOAD_VBPNTR]
* COUNT [1]
* FORMAT [size | stride << 8]
* OFFSET [offset into BO]
* VBPNTR [relocated BO]
*/
BEGIN_CS(7);
OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3);
OUT_CS(1);
OUT_CS(r300->vertex_info.vinfo.size |
(r300->vertex_info.vinfo.size << 8));
OUT_CS(r300->vbo_offset);
OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
END_CS;
}
void r300_emit_vertex_format_state(struct r300_context* r300)
{
int i;
@ -421,20 +445,41 @@ void r300_flush_textures(struct r300_context* r300)
void r300_emit_dirty_state(struct r300_context* r300)
{
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct r300_texture* tex;
int i;
int dirty_tex = 0;
if (!(r300->dirty_hw)) {
if (!(r300->dirty_state)) {
return;
}
r300_update_derived_state(r300);
/* XXX check size */
struct r300_texture* fb_tex =
(struct r300_texture*)r300->framebuffer_state.cbufs[0];
r300->winsys->add_buffer(r300->winsys, fb_tex->buffer,
0, RADEON_GEM_DOMAIN_VRAM);
/* Color buffers... */
for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) {
tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i];
//assert(tex && tex->buffer && "cbuf is marked, but NULL!");
if (!tex->buffer) return;
r300->winsys->add_buffer(r300->winsys, tex->buffer,
0, RADEON_GEM_DOMAIN_VRAM);
}
/* ...depth buffer... */
if (r300->framebuffer_state.zsbuf) {
tex = (struct r300_texture*)r300->framebuffer_state.zsbuf;
//assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
if (!tex->buffer) return;
r300->winsys->add_buffer(r300->winsys, tex->buffer,
0, RADEON_GEM_DOMAIN_VRAM);
}
/* ...and vertex buffer. */
if (r300->vbo) {
r300->winsys->add_buffer(r300->winsys, r300->vbo,
RADEON_GEM_DOMAIN_GTT, 0);
} else {
debug_printf("No VBO while emitting dirty state!\n");
}
if (r300->winsys->validate(r300->winsys)) {
/* XXX */
r300->context.flush(&r300->context, 0, NULL);
@ -519,4 +564,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
r300_emit_vertex_format_state(r300);
r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT;
}
/* Finally, emit the VBO. */
r300_emit_vertex_buffer(r300);
r300->dirty_hw++;
}

View file

@ -62,6 +62,8 @@ void r300_emit_scissor_state(struct r300_context* r300,
void r300_emit_texture(struct r300_context* r300,
struct r300_texture* tex, unsigned offset);
void r300_emit_vertex_buffer(struct r300_context* r300);
void r300_emit_vertex_format_state(struct r300_context* r300);
void r300_emit_vertex_shader(struct r300_context* r300,

View file

@ -180,27 +180,10 @@ static void prepare_render(struct r300_render* render, unsigned count)
CS_LOCALS(r300);
/* Make sure that all possible state is emitted. */
r300_emit_dirty_state(r300);
r300->vbo = render->vbo;
r300->vbo_offset = render->vbo_offset;
debug_printf("r300: Preparing vertex buffer %p for render, "
"vertex size %d, vertex count %d\n", render->vbo,
r300->vertex_info.vinfo.size, count);
/* Set the pointer to our vertex buffer. The emitted values are this:
* PACKET3 [3D_LOAD_VBPNTR]
* COUNT [1]
* FORMAT [size | stride << 8]
* OFFSET [0]
* VBPNTR [relocated BO]
*/
BEGIN_CS(7);
OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3);
OUT_CS(1);
OUT_CS(r300->vertex_info.vinfo.size |
(r300->vertex_info.vinfo.size << 8));
OUT_CS(render->vbo_offset);
OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
END_CS;
r300_emit_dirty_state(r300);
}
static void r300_render_draw_arrays(struct vbuf_render* render,