summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-02-18 18:11:50 +0000
committerJosé Fonseca <[email protected]>2010-02-22 21:46:30 +0000
commit6390dbb3734a7979b5a8a9410f02c7f2db4fa8ec (patch)
tree521cd79e6f508ec34013b9f78a20912c1157f375
parent21480fb9e4cad4f0e411c2ffc64e8c9a752d45e8 (diff)
svga: Temporarily create a sw vertex buf when failed to create a hw buf.
Many apps don't check the return of map buffer so it is better not to fail.
-rw-r--r--src/gallium/drivers/svga/svga_screen_buffer.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c
index 525352f347c..8f591e19772 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.c
+++ b/src/gallium/drivers/svga/svga_screen_buffer.c
@@ -410,18 +410,31 @@ svga_buffer_map_range( struct pipe_screen *screen,
struct svga_buffer *sbuf = svga_buffer( buf );
void *map;
- if(sbuf->swbuf) {
+ if (!sbuf->swbuf && !sbuf->hw.buf) {
+ if (svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) {
+ /*
+ * We can't create a hardware buffer big enough, so create a malloc
+ * buffer instead.
+ */
+
+ debug_printf("%s: failed to allocate %u KB of DMA, splitting DMA transfers\n",
+ __FUNCTION__,
+ (sbuf->base.size + 1023)/1024);
+
+ sbuf->swbuf = align_malloc(sbuf->base.size, sbuf->base.alignment);
+ }
+ }
+
+ if (sbuf->swbuf) {
/* User/malloc buffer */
map = sbuf->swbuf;
}
- else {
- if(!sbuf->hw.buf) {
- if(svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK)
- return NULL;
- }
-
+ else if (sbuf->hw.buf) {
map = sws->buffer_map(sws, sbuf->hw.buf, usage);
}
+ else {
+ map = NULL;
+ }
if(map) {
pipe_mutex_lock(ss->swc_mutex);