summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-01-28 23:27:39 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-01-28 23:27:39 +0000
commit9839e272cfd1ab21911238c7b32c8e771d011f44 (patch)
tree8bbf1f52338080098afd8a7fee365d2592374db5 /src
parentb57e79ff145585b1228b88a4a6090a0fa9f78cf3 (diff)
Allow ValidateBuffers to allocate memory for buffers which haven't yet
got it by other methods. Typically this is buffers being written to by hardware excluding the fixed front/back/depth buffers which are have pre-allocated memory. At some point will want to pass BM_READ/BM_WRITE flags to catch the couple of cases where buffers are treated differently in each case.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i915/bufmgr_fake.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i915/bufmgr_fake.c b/src/mesa/drivers/dri/i915/bufmgr_fake.c
index fa5f956a93d..7a2fec8bf42 100644
--- a/src/mesa/drivers/dri/i915/bufmgr_fake.c
+++ b/src/mesa/drivers/dri/i915/bufmgr_fake.c
@@ -229,6 +229,7 @@ static int move_buffers( struct bufmgr *bm,
{
struct block *newMem[BM_LIST_MAX];
GLint i;
+ GLuint nr_uploads = 0;
DBG("%s\n", __FUNCTION__);
@@ -237,7 +238,20 @@ static int move_buffers( struct bufmgr *bm,
/* First do all the allocations (or fail):
*/
for (i = 0; i < nr; i++) {
- if (!(buffers[i]->block->mem_type & flags)) {
+ if (!buffers[i]->block) {
+/* if (flags & BM_NO_ALLOC) */
+/* goto cleanup; */
+
+ newMem[i] = alloc_block(bm,
+ buffers[i]->size,
+ buffers[i]->alignment,
+ flags & BM_MEM_MASK);
+
+ if (!newMem[i])
+ goto cleanup;
+
+ }
+ else if (!(buffers[i]->block->mem_type & flags)) {
if (flags & BM_NO_UPLOAD)
goto cleanup;
@@ -259,16 +273,20 @@ static int move_buffers( struct bufmgr *bm,
*/
for (i = 0; i < nr; i++) {
if (newMem[i]) {
- /* XXX: To be replaced with DMA, GTT bind, and other
- * mechanisms in final version. Memcpy (or sse_memcpy) is
- * probably pretty good for local->agp uploads.
- */
- _mesa_printf("* %d\n", buffers[i]->size);
- memcpy(newMem[i]->virtual,
- buffers[i]->block->virtual,
- buffers[i]->size);
-
- free_block(bm, buffers[i]->block);
+ if (buffers[i]->block) {
+ /* XXX: To be replaced with DMA, GTT bind, and other
+ * mechanisms in final version. Memcpy (or sse_memcpy) is
+ * probably pretty good for local->agp uploads.
+ */
+ _mesa_printf("* %d\n", buffers[i]->size);
+ memcpy(newMem[i]->virtual,
+ buffers[i]->block->virtual,
+ buffers[i]->size);
+
+ free_block(bm, buffers[i]->block);
+ nr_uploads++;
+ }
+
buffers[i]->block = newMem[i];
buffers[i]->block->buf = buffers[i];
}
@@ -276,7 +294,7 @@ static int move_buffers( struct bufmgr *bm,
/* Tell hardware that its texture and other caches may be invalid:
*/
- if (nr && (flags & (BM_MEM_AGP|BM_MEM_VRAM)))
+ if (nr_uploads && (flags & (BM_MEM_AGP|BM_MEM_VRAM)))
bmFlushReadCaches(bm);
DBG("%s - success\n", __FUNCTION__);