summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/radeon/drm/radeon_drm_common.c
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-12-04 04:38:15 +0100
committerMarek Olšák <maraeo@gmail.com>2011-01-08 07:05:42 +0100
commit1f0348c4a2ba4f8ca812a2daccf3b01c3f984ef1 (patch)
tree7328b1f10d13cf90ceffb337cdb8af2e0d6dcce9 /src/gallium/winsys/radeon/drm/radeon_drm_common.c
parent29c4f95cbcad29d52bf3b6c875840b38b8823e4c (diff)
r300g: rework command submission and resource space checking
The motivation behind this rework is to get some speed by reducing CPU overhead. The performance increase depends on many factors, but it's measurable (I think it's about 10% increase in Torcs). This commit replaces libdrm's radeon_cs_gem with our own implemention. It's optimized specifically for r300g, but r600g could use it as well. Reloc writes and space checking are faster and simpler than their counterparts in libdrm (the time complexity of all the functions is O(1) in nearly all scenarios, thanks to hashing). (libdrm's radeon_bo_gem is still being used in the driver.) It works like this: cs_add_reloc(cs, buf, read_domain, write_domain) adds a new relocation and also adds the size of 'buf' to the used_gart and used_vram winsys variables based on the domains, which are simply or'd for the accounting purposes. The adding is skipped if the reloc is already present in the list, but it accounts any newly-referenced domains. cs_validate is then called, which just checks: used_vram/gart < vram/gart_size * 0.8 The 0.8 number allows for some memory fragmentation. If the validation fails, the pipe driver flushes CS and tries do the validation again, i.e. it validates only that one operation. If it fails again, it drops the operation on the floor and prints some nasty message to stderr. cs_write_reloc(cs, buf) just writes a reloc that has been added using cs_add_reloc. The read_domain and write_domain parameters have been removed, because we already specify them in cs_add_reloc. The space checking has been tested by putting small values in vram/gart_size variables.
Diffstat (limited to 'src/gallium/winsys/radeon/drm/radeon_drm_common.c')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_common.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_common.c b/src/gallium/winsys/radeon/drm/radeon_drm_common.c
index edd7cd3b7b..fe71f08059 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_common.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_common.c
@@ -31,6 +31,7 @@
#include "radeon_winsys.h"
#include "radeon_drm_buffer.h"
+#include "radeon_drm_cs.h"
#include "radeon_drm_public.h"
#include "pipebuffer/pb_bufmgr.h"
@@ -185,7 +186,6 @@ static void radeon_winsys_destroy(struct r300_winsys_screen *rws)
ws->kman->destroy(ws->kman);
radeon_bo_manager_gem_dtor(ws->bom);
- radeon_cs_manager_gem_dtor(ws->csm);
FREE(rws);
}
@@ -207,9 +207,6 @@ struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd)
ws->bom = radeon_bo_manager_gem_ctor(fd);
if (!ws->bom)
goto fail;
- ws->csm = radeon_cs_manager_gem_ctor(fd);
- if (!ws->csm)
- goto fail;
ws->kman = radeon_drm_bufmgr_create(ws);
if (!ws->kman)
goto fail;
@@ -221,6 +218,7 @@ struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd)
ws->base.destroy = radeon_winsys_destroy;
radeon_drm_bufmgr_init_functions(ws);
+ radeon_drm_cs_init_functions(ws);
radeon_winsys_init_functions(ws);
return &ws->base;
@@ -228,8 +226,6 @@ struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd)
fail:
if (ws->bom)
radeon_bo_manager_gem_dtor(ws->bom);
- if (ws->csm)
- radeon_cs_manager_gem_dtor(ws->csm);
if (ws->cman)
ws->cman->destroy(ws->cman);