summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-10-31 01:37:47 +0200
committerFrancisco Jerez <currojerez@riseup.net>2010-10-31 02:01:24 +0100
commitf67fa5229331f6d4920175dd0d6e1e6a2c69c060 (patch)
tree994bf53e24c460e23ae2df780422e08813cd773a /src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
parente89af209261e51988b99d954d09f2cbc59e55358 (diff)
dri/nouveau: Keep small DYNAMIC_DRAW vertex buffers in system ram.
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
index c1453416347..e60b91f64be 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
@@ -36,7 +36,9 @@ get_bufferobj_map(struct gl_buffer_object *obj, unsigned flags)
struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
void *map = NULL;
- if (nbo->bo) {
+ if (nbo->sys) {
+ map = nbo->sys;
+ } else if (nbo->bo) {
nouveau_bo_map(nbo->bo, flags);
map = nbo->bo->map;
nouveau_bo_unmap(nbo->bo);
@@ -65,6 +67,7 @@ nouveau_bufferobj_del(struct gl_context *ctx, struct gl_buffer_object *obj)
struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
nouveau_bo_ref(NULL, &nbo->bo);
+ FREE(nbo->sys);
FREE(nbo);
}
@@ -79,11 +82,23 @@ nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size
obj->Size = size;
obj->Usage = usage;
+ /* Free previous storage */
nouveau_bo_ref(NULL, &nbo->bo);
- ret = nouveau_bo_new(context_dev(ctx),
- NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
- size, &nbo->bo);
- assert(!ret);
+ FREE(nbo->sys);
+
+ if (target == GL_ELEMENT_ARRAY_BUFFER_ARB ||
+ (size < 512 && usage == GL_DYNAMIC_DRAW_ARB) ||
+ context_chipset(ctx) < 0x10) {
+ /* Heuristic: keep it in system ram */
+ nbo->sys = MALLOC(size);
+
+ } else {
+ /* Get a hardware BO */
+ ret = nouveau_bo_new(context_dev(ctx),
+ NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
+ size, &nbo->bo);
+ assert(!ret);
+ }
if (data)
memcpy(get_bufferobj_map(obj, NOUVEAU_BO_WR), data, size);