r600g: reduce size of context structure.
authorDave Airlie <airlied@redhat.com>
Wed, 13 Oct 2010 05:22:04 +0000 (15:22 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 13 Oct 2010 05:25:00 +0000 (15:25 +1000)
this thing will be in the cache a lot, so having massive big struct
arrays inside it won't be helping anyone.

src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h

index 52fe3c777b3276f6ef776f032f7c0e04c20e10db..69bfb2a1a4e3d1329a049928a79b2722b6362274 100644 (file)
@@ -85,6 +85,10 @@ static void r600_destroy_context(struct pipe_context *context)
        u_upload_destroy(rctx->upload_vb);
        u_upload_destroy(rctx->upload_ib);
 
+       FREE(rctx->ps_resource);
+       FREE(rctx->vs_resource);
+       FREE(rctx->vs_const);
+       FREE(rctx->ps_const);
        FREE(rctx);
 }
 
@@ -171,6 +175,30 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                return NULL;
        }
 
+       rctx->vs_const = CALLOC(R600_CONSTANT_ARRAY_SIZE, sizeof(struct r600_pipe_state));
+       if (!rctx->vs_const) {
+               FREE(rctx);
+               return NULL;
+       }
+
+       rctx->ps_const = CALLOC(R600_CONSTANT_ARRAY_SIZE, sizeof(struct r600_pipe_state));
+       if (!rctx->vs_const) {
+               FREE(rctx);
+               return NULL;
+       }
+
+       rctx->vs_resource = CALLOC(R600_RESOURCE_ARRAY_SIZE, sizeof(struct r600_pipe_state));
+       if (!rctx->vs_resource) {
+               FREE(rctx);
+               return NULL;
+       }
+
+       rctx->ps_resource = CALLOC(R600_RESOURCE_ARRAY_SIZE, sizeof(struct r600_pipe_state));
+       if (!rctx->ps_resource) {
+               FREE(rctx);
+               return NULL;
+       }
+
        class = r600_get_family_class(rctx->radeon);
        if (class == R600 || class == R700)
                rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx);
index 34a59646d5136cf9e4c1c5aaebae2a73030a84a2..6ce1f96952271e0cdc5e0357b8ea6a02a3505a7f 100644 (file)
@@ -100,6 +100,9 @@ struct r600_textures_info {
        unsigned                        n_samplers;
 };
 
+#define R600_CONSTANT_ARRAY_SIZE 256
+#define R600_RESOURCE_ARRAY_SIZE 160
+
 struct r600_pipe_context {
        struct pipe_context             context;
        struct blitter_context          *blitter;
@@ -122,10 +125,10 @@ struct r600_pipe_context {
        struct pipe_clip_state          clip;
        unsigned                        vs_nconst;
        unsigned                        ps_nconst;
-       struct r600_pipe_state          vs_const[256];
-       struct r600_pipe_state          ps_const[256];
-       struct r600_pipe_state          vs_resource[160];
-       struct r600_pipe_state          ps_resource[160];
+       struct r600_pipe_state          *vs_const;
+       struct r600_pipe_state          *ps_const;
+       struct r600_pipe_state          *vs_resource;
+       struct r600_pipe_state          *ps_resource;
        struct r600_pipe_state          config;
        struct r600_pipe_shader         *ps_shader;
        struct r600_pipe_shader         *vs_shader;