summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/r600/drm/radeon.c
diff options
context:
space:
mode:
authorJerome Glisse <[email protected]>2010-08-30 17:56:59 -0400
committerJerome Glisse <[email protected]>2010-09-01 13:16:23 -0400
commit66e4cb1cd5a55402606a09417349d2be8b009e89 (patch)
treeb9c4e20211fbfc1a979667598f141116f4a5cebd /src/gallium/winsys/r600/drm/radeon.c
parent15ce70252c5357081a61f3494261c7e343174301 (diff)
r600g: avoid dynamic allocation of states
Make state statically allocated, this kills a bunch of code and avoid intensive use of malloc/free. There is still a lot of useless duplicate function wrapping that can be kill. This doesn't improve yet performance, needs to avoid memcpy states in radeon_ctx_set_draw and to avoid rebuilding vs_resources, dsa, scissor, cb_cntl, ... states at each draw command. Signed-off-by: Jerome Glisse <[email protected]>
Diffstat (limited to 'src/gallium/winsys/r600/drm/radeon.c')
-rw-r--r--src/gallium/winsys/r600/drm/radeon.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon.c b/src/gallium/winsys/r600/drm/radeon.c
index 2b16e3ce884..e2d813ebac7 100644
--- a/src/gallium/winsys/r600/drm/radeon.c
+++ b/src/gallium/winsys/r600/drm/radeon.c
@@ -42,24 +42,13 @@ static int radeon_get_device(struct radeon *radeon)
return r;
}
-/* symbol missing drove me crazy hack to get symbol exported */
-static void fake(void)
-{
- struct radeon_ctx *ctx;
- struct radeon_draw *draw;
-
- ctx = radeon_ctx(NULL);
- draw = radeon_draw(NULL);
-}
-
struct radeon *radeon_new(int fd, unsigned device)
{
struct radeon *radeon;
- int r;
+ int r, i, id;
radeon = calloc(1, sizeof(*radeon));
if (radeon == NULL) {
- fake();
return NULL;
}
radeon->fd = fd;
@@ -131,6 +120,19 @@ struct radeon *radeon_new(int fd, unsigned device)
__func__, radeon->device);
break;
}
+ radeon->state_type_id = calloc(radeon->nstype, sizeof(unsigned));
+ if (radeon->state_type_id == NULL) {
+ return radeon_decref(radeon);
+ }
+ for (i = 0, id = 0; i < radeon->nstype; i++) {
+ radeon->state_type_id[i] = id;
+ for (int j = 0; j < radeon->nstype; j++) {
+ if (radeon->stype[j].stype != i)
+ continue;
+ id += radeon->stype[j].num;
+ }
+ }
+ radeon->nstate_per_shader = id;
return radeon;
}