r300g: refuse to create too large textures
authorMarek Olšák <maraeo@gmail.com>
Sat, 1 Dec 2012 21:40:00 +0000 (22:40 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 1 Dec 2012 21:41:39 +0000 (22:41 +0100)
src/gallium/drivers/r300/r300_texture.c

index 33333ca51b52c866d1246bfe72a41765e98da85f..c16bb03e702171e221e48ba04902781899d4413c 100644 (file)
@@ -980,6 +980,21 @@ r300_texture_create_object(struct r300_screen *rscreen,
 
     r300_texture_desc_init(rscreen, tex, base);
 
+    /* Figure out the ideal placement for the texture.. */
+    if (tex->domain & RADEON_DOMAIN_VRAM &&
+        tex->tex.size_in_bytes >= rscreen->info.vram_size) {
+        tex->domain &= ~RADEON_DOMAIN_VRAM;
+        tex->domain |= RADEON_DOMAIN_GTT;
+    }
+    if (tex->domain & RADEON_DOMAIN_GTT &&
+        tex->tex.size_in_bytes >= rscreen->info.gart_size) {
+        tex->domain &= ~RADEON_DOMAIN_GTT;
+    }
+    /* Just fail if the texture is too large. */
+    if (!tex->domain) {
+        goto fail;
+    }
+
     /* Create the backing buffer if needed. */
     if (!tex->buf) {
         tex->buf = rws->buffer_create(rws, tex->tex.size_in_bytes, 2048,