Add translate cache to fetch_emit stage and add out of memory
authorZack Rusin <zack@tungstengraphics.com>
Wed, 23 Apr 2008 18:07:53 +0000 (14:07 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 23 Apr 2008 18:07:53 +0000 (14:07 -0400)
checks to code creating the cache.

src/gallium/auxiliary/draw/draw_pt_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch.c
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c

index c6d95375302f94ad4540999c15be821b105abae3..35707af8a89375534b12c01f58e5c98c5687a149 100644 (file)
@@ -185,6 +185,10 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw )
 
    emit->draw = draw;
    emit->cache = translate_cache_create();
+   if (!emit->cache) {
+      FREE(emit);
+      return NULL;
+   }
 
    return emit;
 }
index 8183c5167607fd51f0bb698ef9a8d5c3967be632..cc61b113fd4b5dbc86b23bd14319ca96fd8fcffa 100644 (file)
@@ -158,6 +158,11 @@ struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw )
 
    fetch->draw = draw;
    fetch->cache = translate_cache_create();
+   if (!fetch->cache) {
+      FREE(fetch);
+      return NULL;
+   }
+
    return fetch;
 }
 
index 68b2c5b1e3d0f5893835483b9bd8ddba29044045..a4de341df8e7112329592a455ed2b6ea825dd1df 100644 (file)
@@ -37,6 +37,7 @@
 #include "draw/draw_vertex.h"
 #include "draw/draw_pt.h"
 #include "translate/translate.h"
+#include "translate/translate_cache.h"
 
 /* The simplest 'middle end' in the new vertex code.  
  * 
@@ -81,6 +82,7 @@ struct fetch_emit_middle_end {
     */
    float point_size;
 
+   struct translate_cache *cache;
 };
 
 
@@ -174,10 +176,9 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
    if (!feme->translate ||
        memcmp(&feme->translate->key, &key, sizeof(key)) != 0) 
    {
-      if (feme->translate)
-        feme->translate->release(feme->translate);
+      feme->translate = translate_cache_find(feme->cache,
+                                             &key);
 
-      feme->translate = translate_create( &key );
 
       feme->translate->set_buffer(feme->translate, 
                                  draw->pt.nr_vertex_buffers, 
@@ -266,9 +267,8 @@ static void fetch_emit_destroy( struct draw_pt_middle_end *middle )
 {
    struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle;
 
-   if (feme->translate)
-      feme->translate->release( feme->translate );
-   
+   translate_cache_destroy(feme->cache);
+
    FREE(middle);
 }
 
@@ -278,7 +278,13 @@ struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw )
    struct fetch_emit_middle_end *fetch_emit = CALLOC_STRUCT( fetch_emit_middle_end );
    if (fetch_emit == NULL)
       return NULL;
+
+   fetch_emit->cache = translate_cache_create();
+   if (!fetch_emit->cache) {
+      FREE(fetch_emit);
+      return NULL;
+   }
+
    fetch_emit->base.prepare = fetch_emit_prepare;
    fetch_emit->base.run     = fetch_emit_run;
    fetch_emit->base.finish  = fetch_emit_finish;