r600g: various fixes
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 19 May 2010 16:46:45 +0000 (18:46 +0200)
committerJerome Glisse <jglisse@redhat.com>
Thu, 27 May 2010 21:24:22 +0000 (23:24 +0200)
- enabled flushing a buffer more than once
- enabled the blitter for r600_clear
- added some more colors to r600_is_format_supported (copied from r600_conv_pipe_format)
- r600_set_framebuffer_state now sets rctx->fb_state
- more states are saved before a blit (had to add some accounting for the viewport and the vertex elements state)
- fixed a few errors with reference counting

src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_buffer.c
src/gallium/drivers/r600/r600_context.c
src/gallium/drivers/r600/r600_context.h
src/gallium/drivers/r600/r600_draw.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c

index 88b865ef9a6862e39c90f08defb6b93edbc9307f..e92e92810592bcb716474416390d9c80651895f4 100644 (file)
@@ -47,6 +47,10 @@ static void r600_blitter_save_states(struct pipe_context *ctx)
                                        rctx->ps_shader);
        util_blitter_save_vertex_shader(rctx->blitter,
                                        rctx->vs_shader);
+       util_blitter_save_vertex_elements(rctx->blitter,
+                                       rctx->vertex_elements);
+       util_blitter_save_viewport(rctx->blitter,
+                                       rctx->viewport);
 }
 
 void r600_clear(struct pipe_context *ctx, unsigned buffers,
@@ -55,12 +59,10 @@ void r600_clear(struct pipe_context *ctx, unsigned buffers,
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct pipe_framebuffer_state *fb = &rctx->fb_state;
 
-#if 0
        r600_blitter_save_states(ctx);
        util_blitter_clear(rctx->blitter, fb->width, fb->height,
                                fb->nr_cbufs, buffers, rgba, depth,
                                stencil);
-#endif
 }
 
 void r600_surface_copy(struct pipe_context *ctx,
index fd94c605bb1f5d99f93b7014c3060a403cb16207..272f4dd6730503a8f20f5098b28f46c5db1f1943 100644 (file)
@@ -73,8 +73,8 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
        if (rbuffer == NULL)
                return NULL;
 
-       pipe_reference_init(&rbuffer->b.b.reference, 1);
        rbuffer->b.b = *templ;
+       pipe_reference_init(&rbuffer->b.b.reference, 1);
        rbuffer->b.b.screen = screen;
        rbuffer->b.vtbl = &r600_buffer_vtbl;
 
index f4d4ed0d3efa1e038e3973f9ae6eadee44b0f638..0d36641a8e2d19bd3bcd6e0f161b6f407368ed20 100644 (file)
@@ -50,9 +50,8 @@ static int dc = 0;
 
        if (radeon_ctx_pm4(rctx->ctx))
                return;
-       if (dc)
-               return;
-       radeon_ctx_dump_bof(rctx->ctx, "gallium.bof");
+       if (!dc)
+           radeon_ctx_dump_bof(rctx->ctx, "gallium.bof");
        radeon_ctx_submit(rctx->ctx);
        rctx->ctx = radeon_ctx_decref(rctx->ctx);
        rctx->ctx = radeon_ctx(rscreen->rw);
@@ -78,13 +77,12 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
        r600_init_query_functions(rctx);
        r600_init_state_functions(rctx);
        r600_init_context_resource_functions(rctx);
-#if 0
+
        rctx->blitter = util_blitter_create(&rctx->context);
        if (rctx->blitter == NULL) {
                FREE(rctx);
                return NULL;
        }
-#endif
 
        rctx->cb_cntl = radeon_state(rscreen->rw, R600_CB_CNTL_TYPE, R600_CB_CNTL);
        rctx->cb_cntl->states[R600_CB_CNTL__CB_SHADER_MASK] = 0x0000000F;
index afe544819c8d51848475017399a0c604ed3de86b..b8ce8b88caef05f4a638f3e4bb742322584695b7 100644 (file)
 struct r600_state;
 typedef void (*r600_state_destroy_t)(struct r600_state *rstate);
 
+/* XXX move this to a more appropriate place */
+struct r600_vertex_elements_state
+{
+       unsigned count;
+       struct pipe_vertex_element elements[32];
+};
+
 struct r600_state {
        unsigned                type;
        struct r600_atom        *atom;
@@ -63,13 +70,13 @@ struct r600_context {
        struct r600_pipe_shader         *vs_shader;
        unsigned                        flat_shade;
        unsigned                        nvertex_buffer;
-       unsigned                        nvertex_element;
+       struct r600_vertex_elements_state *vertex_elements;
        struct pipe_vertex_buffer       vertex_buffer[PIPE_MAX_ATTRIBS];
-       struct pipe_vertex_element      vertex_element[PIPE_MAX_ATTRIBS];
        struct blitter_context          *blitter;
        struct pipe_stencil_ref         stencil_ref;
        struct pipe_framebuffer_state   fb_state;
        struct radeon_draw              *draw;
+       struct pipe_viewport_state *viewport;
 };
 
 void r600_draw_arrays(struct pipe_context *ctx, unsigned mode,
index aa254faf15925ef48622a81cff465641246a9b9c..26cc94f857ba896d81e136932363913120b6dc9f 100644 (file)
@@ -99,11 +99,11 @@ static int r600_draw_common(struct r600_draw *draw)
        if (r)
                return r;
 
-       for (i = 0 ; i < rctx->nvertex_element; i++) {
-               j = rctx->vertex_element[i].vertex_buffer_index;
+       for (i = 0 ; i < rctx->vertex_elements->count; i++) {
+               j = rctx->vertex_elements->elements[i].vertex_buffer_index;
                rbuffer = (struct r600_buffer*)rctx->vertex_buffer[j].buffer;
-               offset = rctx->vertex_element[i].src_offset + rctx->vertex_buffer[j].buffer_offset;
-               r = r600_conv_pipe_format(rctx->vertex_element[i].src_format, &format);
+               offset = rctx->vertex_elements->elements[i].src_offset + rctx->vertex_buffer[j].buffer_offset;
+               r = r600_conv_pipe_format(rctx->vertex_elements->elements[i].src_format, &format);
                if (r)
                        return r;
                vs_resource = radeon_state(rscreen->rw, R600_VS_RESOURCE_TYPE, R600_VS_RESOURCE + i);
index f8a18658a98c30c7bbf447e3fd1c8b3796815d34..e8efdc9db37ceee2e56bdc309855027d64188f7c 100644 (file)
@@ -200,8 +200,8 @@ int r600_pipe_shader_update(struct pipe_context *ctx, struct r600_pipe_shader *r
        rshader = &rpshader->shader;
        switch (rpshader->type) {
        case C_PROGRAM_TYPE_VS:
-               for (i = 0; i < rctx->nvertex_element; i++) {
-                       resource_format[nresources++] = rctx->vertex_element[i].src_format;
+               for (i = 0; i < rctx->vertex_elements->count; i++) {
+                       resource_format[nresources++] = rctx->vertex_elements->elements[i].src_format;
                }
                break;
        default:
index e70ef95c1dae6ba26fbb412be7f23cd289a13401..d57e88dd56eb1fc52ba0e8d625cfb9ac8e7809d7 100644 (file)
@@ -128,6 +128,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
        rctx->db->bo[0] = radeon_bo_incref(rscreen->rw, rstate->bo[0]);
        rctx->db->nbo = 1;
        rctx->db->placement[0] = RADEON_GEM_DOMAIN_GTT;
+       rctx->fb_state = *state;
 }
 
 static void *r600_create_fs_state(struct pipe_context *ctx,
@@ -308,6 +309,7 @@ static void r600_set_viewport_state(struct pipe_context *ctx,
                return;
        }
        radeon_draw_set_new(rctx->draw, rstate);
+       rctx->viewport = state;
 }
 
 static void r600_set_vertex_buffers(struct pipe_context *ctx,
@@ -320,12 +322,6 @@ static void r600_set_vertex_buffers(struct pipe_context *ctx,
        rctx->nvertex_buffer = count;
 }
 
-/* XXX move this to a more appropriate place */
-struct r600_vertex_elements_state
-{
-       unsigned count;
-       struct pipe_vertex_element elements[32];
-};
 
 static void *r600_create_vertex_elements_state(struct pipe_context *ctx,
                                               unsigned count,
@@ -344,8 +340,7 @@ static void r600_bind_vertex_elements_state(struct pipe_context *ctx, void *stat
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct r600_vertex_elements_state *v = (struct r600_vertex_elements_state*)state;
 
-       memcpy(rctx->vertex_element, v->elements, v->count * sizeof(struct pipe_vertex_element));
-       rctx->nvertex_element = v->count;
+       rctx->vertex_elements = v;
 }
 
 static void r600_delete_vertex_elements_state(struct pipe_context *ctx, void *state)
index b41d7a3b00b7909f88a675b824d5e9b99c78aa39..7d94bbe510f4a1bb5e264e6e608c02328abc3a14 100644 (file)
@@ -113,7 +113,6 @@ static void r600_texture_destroy(struct pipe_screen *screen,
 {
        struct r600_texture *rtex = (struct r600_texture*)ptex;
 
-       pipe_resource_reference((struct pipe_resource**)&rtex, NULL);
        FREE(rtex);
 }