r600g: add support for kernel bo
[mesa.git] / src / gallium / drivers / r600 / r600_context.c
index ed8f2655fba21453a5b0d54691a330861c9d777b..cca1e3567341826df29c190bb2aa15be6f0b469b 100644 (file)
@@ -32,8 +32,6 @@
 #include "r600_screen.h"
 #include "r600_context.h"
 #include "r600_resource.h"
-#include "r600d.h"
-
 
 static void r600_destroy_context(struct pipe_context *context)
 {
@@ -58,7 +56,7 @@ static void r600_destroy_context(struct pipe_context *context)
        free(rctx->vs_constant);
        free(rctx->vs_resource);
 
-       radeon_ctx_fini(&rctx->ctx);
+       radeon_ctx_fini(rctx->ctx);
        FREE(rctx);
 }
 
@@ -66,37 +64,29 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
                        struct pipe_fence_handle **fence)
 {
        struct r600_context *rctx = r600_context(ctx);
-       struct r600_query *rquery;
-       static int dc = 0;
-       char dname[256];
+       struct r600_query *rquery = NULL;
 
        /* suspend queries */
        r600_queries_suspend(ctx);
-       /* FIXME dumping should be removed once shader support instructions
-        * without throwing bad code
-        */
-       if (!rctx->ctx.cdwords)
-               goto out;
-#if 0
-       sprintf(dname, "gallium-%08d.bof", dc);
-       if (dc < 2) {
-               radeon_ctx_dump_bof(&rctx->ctx, dname);
-               R600_ERR("dumped %s\n", dname);
-       }
-#endif
-#if 1
-       radeon_ctx_submit(&rctx->ctx);
-#endif
+
+       radeon_ctx_submit(rctx->ctx);
+
        LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
                rquery->flushed = true;
        }
-       dc++;
-out:
-       radeon_ctx_clear(&rctx->ctx);
+
+       radeon_ctx_clear(rctx->ctx);
        /* resume queries */
        r600_queries_resume(ctx);
 }
 
+void r600_flush_ctx(void *data)
+{
+        struct r600_context *rctx = data;
+
+        rctx->context.flush(&rctx->context, 0, NULL);
+}
+
 struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
 {
        struct r600_context *rctx = CALLOC_STRUCT(r600_context);
@@ -115,7 +105,10 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
        rctx->screen = rscreen;
        rctx->rw = rscreen->rw;
 
-       rctx->vtbl = &r600_hw_state_vtbl;
+       if (rscreen->chip_class == EVERGREEN)
+               rctx->vtbl = &eg_hw_state_vtbl;
+       else
+               rctx->vtbl = &r600_hw_state_vtbl;
 
        r600_init_blit_functions(rctx);
        r600_init_query_functions(rctx);
@@ -148,7 +141,7 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
                return NULL;
        }                                                  
 
-       radeon_ctx_init(&rctx->ctx, rscreen->rw);
+       rctx->ctx = radeon_ctx_init(rscreen->rw);
        radeon_draw_init(&rctx->draw, rscreen->rw);
        return &rctx->context;
 }