i915->base.draw_vbo = i915_draw_vbo;
+ /* init this before draw */
+ util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
+ 16, UTIL_SLAB_SINGLETHREADED);
+
/*
* Create drawing context and plug our rendering stage into it.
*/
#include "tgsi/tgsi_scan.h"
+#include "util/u_slab.h"
+
struct i915_winsys;
struct i915_winsys_buffer;
struct i915_state current;
unsigned hardware_dirty;
+
+ struct util_slab_mempool transfer_pool;
};
/* A flag for each state_tracker state object:
}
+static struct pipe_transfer *
+i915_get_transfer(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
+
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->level = level;
+ transfer->usage = usage;
+ transfer->box = *box;
+
+ /* Note strides are zero, this is ok for buffers, but not for
+ * textures 2d & higher at least.
+ */
+ return transfer;
+}
+
+static void
+i915_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ util_slab_free(&i915->transfer_pool, transfer);
+}
+
static void *
i915_buffer_transfer_map( struct pipe_context *pipe,
struct pipe_transfer *transfer )
i915_buffer_get_handle, /* get_handle */
i915_buffer_destroy, /* resource_destroy */
NULL, /* is_resource_referenced */
- u_default_get_transfer, /* get_transfer */
- u_default_transfer_destroy, /* transfer_destroy */
+ i915_get_transfer, /* get_transfer */
+ i915_transfer_destroy, /* transfer_destroy */
i915_buffer_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
u_default_transfer_unmap, /* transfer_unmap */
}
static struct pipe_transfer *
-i915_texture_get_transfer(struct pipe_context *context,
+i915_texture_get_transfer(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box)
{
+ struct i915_context *i915 = i915_context(pipe);
struct i915_texture *tex = i915_texture(resource);
- struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
+
if (transfer == NULL)
return NULL;
return transfer;
}
+static void
+i915_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ util_slab_free(&i915->transfer_pool, transfer);
+}
+
static void *
i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_transfer *transfer)
i915_texture_destroy, /* resource_destroy */
NULL, /* is_resource_referenced */
i915_texture_get_transfer, /* get_transfer */
- u_default_transfer_destroy, /* transfer_destroy */
+ i915_transfer_destroy, /* transfer_destroy */
i915_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
i915_texture_transfer_unmap, /* transfer_unmap */
boolean is_i945;
};
-/**
- * Subclass of pipe_transfer
- */
-struct i915_transfer
-{
- struct pipe_transfer base;
-
- unsigned offset;
-};
-
/*
* Cast wrappers
return (struct i915_screen *) pscreen;
}
-static INLINE struct i915_transfer *
-i915_transfer(struct pipe_transfer *transfer)
-{
- return (struct i915_transfer *)transfer;
-}
-
#endif /* I915_SCREEN_H */