#include "draw_vertex.h"
#include "draw_pipe.h"
#include "translate/translate.h"
+#include "translate/translate_cache.h"
/**
/* Cache point size somewhere it's address won't change:
*/
float point_size;
+
+ struct translate_cache *cache;
};
/* Translate from pipeline vertices to hw vertices.
*/
dst_offset = 0;
- memset(&hw_key, 0, sizeof(hw_key));
for (i = 0; i < vbuf->vinfo->num_attribs; i++) {
unsigned emit_sz = 0;
/* Don't bother with caching at this stage:
*/
if (!vbuf->translate ||
- memcmp(&vbuf->translate->key, &hw_key, sizeof(hw_key)) != 0)
+ translate_key_compare(&vbuf->translate->key, &hw_key) != 0)
{
- if (vbuf->translate)
- vbuf->translate->release(vbuf->translate);
-
- vbuf->translate = translate_create( &hw_key );
+ translate_key_sanitize(&hw_key);
+ vbuf->translate = translate_cache_find(vbuf->cache, &hw_key);
vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0);
}
if (vbuf->render)
vbuf->render->destroy( vbuf->render );
+ if (vbuf->cache)
+ translate_cache_destroy(vbuf->cache);
+
FREE( stage );
}
16 );
if (!vbuf->indices)
goto fail;
+
+ vbuf->cache = translate_cache_create();
+ if (!vbuf->cache)
+ goto fail;
+
vbuf->vertices = NULL;
vbuf->vertex_ptr = vbuf->vertices;
const struct vertex_info *vinfo;
unsigned dst_offset;
struct translate_key hw_key;
- unsigned keysize;
unsigned i;
boolean ok;
/* Must do this after set_primitive() above:
*/
vinfo = draw->render->get_vertex_info(draw->render);
- keysize = 2*4 + vinfo->num_attribs * sizeof(hw_key.element[0]);
+
/* Translate from pipeline vertices to hw vertices.
*/
hw_key.output_stride = vinfo->size * 4;
if (!emit->translate ||
- memcmp(&emit->translate->key, &hw_key, keysize) != 0)
+ translate_key_compare(&emit->translate->key, &hw_key) != 0)
{
- memset((char *)&hw_key + keysize, 0, sizeof(hw_key) - keysize);
+ translate_key_sanitize(&hw_key);
emit->translate = translate_cache_find(emit->cache, &hw_key);
}
}
void draw_pt_emit_destroy( struct pt_emit *emit )
{
- translate_cache_destroy(emit->cache);
+ if (emit->cache)
+ translate_cache_destroy(emit->cache);
FREE(emit);
}
unsigned i, nr = 0;
unsigned dst_offset = 0;
struct translate_key key;
- unsigned keysize;
fetch->vertex_size = vertex_size;
- keysize = (2*4 +
- (draw->pt.nr_vertex_elements + 1) * sizeof(key.element[0]));
/* Always emit/leave space for a vertex header.
*
if (!fetch->translate ||
- memcmp(&fetch->translate->key, &key, keysize) != 0)
+ translate_key_compare(&fetch->translate->key, &key) != 0)
{
- memset((char *)&key + keysize, 0, sizeof(key) - keysize);
+ translate_key_sanitize(&key);
fetch->translate = translate_cache_find(fetch->cache, &key);
{
/* Don't bother with caching at this stage:
*/
if (!feme->translate ||
- memcmp(&feme->translate->key, &key, sizeof(key)) != 0)
+ translate_key_compare(&feme->translate->key, &key) != 0)
{
+ translate_key_sanitize(&key);
feme->translate = translate_cache_find(feme->cache,
&key);