summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys.h23
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c2
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c53
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c24
-rw-r--r--src/mesa/pipe/cell/ppu/cell_draw_arrays.c2
-rw-r--r--src/mesa/pipe/cell/ppu/cell_draw_arrays.h2
-rw-r--r--src/mesa/pipe/cell/ppu/cell_texture.h2
-rw-r--r--src/mesa/pipe/failover/fo_context.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_blit.c6
-rw-r--r--src/mesa/pipe/i915simple/i915_blit.h6
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h4
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c3
-rw-r--r--src/mesa/pipe/i915simple/i915_state_emit.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_surface.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h4
-rw-r--r--src/mesa/pipe/i965simple/brw_blit.c6
-rw-r--r--src/mesa/pipe/i965simple/brw_blit.h8
-rw-r--r--src/mesa/pipe/i965simple/brw_context.h6
-rw-r--r--src/mesa/pipe/i965simple/brw_draw.c4
-rw-r--r--src/mesa/pipe/i965simple/brw_draw.h2
-rw-r--r--src/mesa/pipe/i965simple/brw_draw_upload.c4
-rw-r--r--src/mesa/pipe/i965simple/brw_state.h2
-rw-r--r--src/mesa/pipe/i965simple/brw_state_pool.c7
-rw-r--r--src/mesa/pipe/i965simple/brw_surface.c2
-rw-r--r--src/mesa/pipe/i965simple/brw_tex_layout.c3
-rw-r--r--src/mesa/pipe/i965simple/brw_winsys.h8
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_surface_state.c2
-rw-r--r--src/mesa/pipe/p_context.h2
-rw-r--r--src/mesa/pipe/p_inlines.h43
-rw-r--r--src/mesa/pipe/p_state.h23
-rw-r--r--src/mesa/pipe/p_winsys.h17
-rw-r--r--src/mesa/pipe/pipebuffer/Makefile2
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.c49
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.h111
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_client.c60
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.c102
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.h10
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.c140
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.h120
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_malloc.c41
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_null.c98
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr.h24
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c36
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c88
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c75
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h2
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c7
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.h2
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c80
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.c44
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.h4
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c3
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c5
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.h4
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c4
-rw-r--r--src/mesa/state_tracker/st_context.c3
-rw-r--r--src/mesa/state_tracker/st_draw.c21
62 files changed, 529 insertions, 894 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
index 89e63e0a797..ffc40782be7 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
@@ -28,10 +28,12 @@
#ifndef INTEL_WINSYS_H
#define INTEL_WINSYS_H
+#include "pipe/p_state.h"
+
struct intel_context;
struct pipe_context;
struct pipe_winsys;
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct _DriBufferObject;
struct pipe_winsys *
@@ -49,20 +51,21 @@ intel_create_i915simple( struct intel_context *intel,
struct pipe_winsys *winsys );
+struct intel_buffer {
+ struct pipe_buffer base;
+ struct _DriBufferObject *driBO;
+};
-/* Turn the pipe opaque buffer pointer into a dri_bufmgr opaque
- * buffer pointer...
- */
-static INLINE struct _DriBufferObject *
-dri_bo( struct pipe_buffer_handle *bo )
+static INLINE struct intel_buffer *
+intel_buffer( struct pipe_buffer *buf )
{
- return (struct _DriBufferObject *)bo;
+ return (struct intel_buffer *)buf;
}
-static INLINE struct pipe_buffer_handle *
-pipe_bo( struct _DriBufferObject *bo )
+static INLINE struct _DriBufferObject *
+dri_bo( struct pipe_buffer *buf )
{
- return (struct pipe_buffer_handle *)bo;
+ return intel_buffer(buf)->driBO;
}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
index 8e0eea43922..1ba6a9e1b25 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
@@ -85,7 +85,7 @@ static void intel_i915_batch_dword( struct i915_winsys *sws,
}
static void intel_i915_batch_reloc( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta )
{
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
index 43ed0602a4b..910c0d2cc5e 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
@@ -43,6 +43,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
@@ -65,7 +66,7 @@ intel_pipe_winsys( struct pipe_winsys *winsys )
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *intel_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned flags )
{
unsigned drm_flags = 0;
@@ -80,26 +81,17 @@ static void *intel_buffer_map(struct pipe_winsys *winsys,
}
static void intel_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf)
+ struct pipe_buffer *buf)
{
driBOUnmap( dri_bo(buf) );
}
static void
-intel_buffer_reference(struct pipe_winsys *winsys,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+intel_buffer_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf)
{
- if (*ptr) {
- driBOUnReference( dri_bo(*ptr) );
- *ptr = NULL;
- }
-
- if (buf) {
- driBOReference( dri_bo(buf) );
- *ptr = buf;
- }
+ driBOUnReference( dri_bo(buf) );
}
@@ -107,16 +99,21 @@ intel_buffer_reference(struct pipe_winsys *winsys,
* for all buffers.
* Grabs the hardware lock!
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
intel_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
unsigned usage,
unsigned size )
{
- struct _DriBufferObject *buffer;
+ struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
unsigned flags = 0;
+ buffer->base.refcount = 1;
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
+
if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) {
flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
} else {
@@ -143,20 +140,24 @@ intel_buffer_create(struct pipe_winsys *winsys,
#endif
driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer, alignment, flags, 0 );
- driBOData( buffer, size, NULL, 0 );
- return pipe_bo(buffer);
+ "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
+
+ driBOData( buffer->driBO, size, NULL, 0 );
+
+ return &buffer->base;
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
- struct _DriBufferObject *buffer;
+ struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
+
driGenUserBuffer( iws->regionPool,
- "pipe user buffer", &buffer, ptr, bytes);
- return pipe_bo(buffer);
+ "pipe user buffer", &buffer->driBO, ptr, bytes);
+
+ return &buffer->base;
}
@@ -224,7 +225,7 @@ intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
return -1;
if(ret) {
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
return ret;
}
@@ -239,7 +240,7 @@ intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -279,7 +280,7 @@ intel_create_pipe_winsys( int fd )
iws->winsys.user_buffer_create = intel_user_buffer_create;
iws->winsys.buffer_map = intel_buffer_map;
iws->winsys.buffer_unmap = intel_buffer_unmap;
- iws->winsys.buffer_reference = intel_buffer_reference;
+ iws->winsys.buffer_destroy = intel_buffer_destroy;
iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
iws->winsys.printf = intel_printf;
iws->winsys.get_name = intel_get_name;
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index dafbe96a1ec..a690df27727 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -71,15 +71,15 @@ struct xm_buffer
* buffer pointer...
*/
static inline struct xm_buffer *
-xm_bo( struct pipe_buffer_handle *bo )
+xm_bo( struct pipe_buffer *bo )
{
return (struct xm_buffer *) bo;
}
-static inline struct pipe_buffer_handle *
+static inline struct pipe_buffer *
pipe_bo( struct xm_buffer *bo )
{
- return (struct pipe_buffer_handle *) bo;
+ return (struct pipe_buffer *) bo;
}
/* Turn a softpipe winsys into an xm/softpipe winsys:
@@ -94,7 +94,7 @@ xm_winsys(struct softpipe_winsys *sws)
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *
-xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned flags)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -103,7 +103,7 @@ xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
+xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
{
struct xm_buffer *xm_buf = xm_bo(buf);
xm_buf->mapped = NULL;
@@ -111,8 +111,8 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
static void
xm_buffer_reference(struct pipe_winsys *pws,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+ struct pipe_buffer **ptr,
+ struct pipe_buffer *buf)
{
if (*ptr) {
struct xm_buffer *oldBuf = xm_bo(*ptr);
@@ -139,7 +139,7 @@ xm_buffer_reference(struct pipe_winsys *pws,
}
static void
-xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned size, const void *data, unsigned usage)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -155,7 +155,7 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned long offset, unsigned long size, const void *data)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -166,7 +166,7 @@ xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned long offset, unsigned long size, void *data)
{
const struct xm_buffer *xm_buf = xm_bo(buf);
@@ -209,7 +209,7 @@ xm_get_name(struct pipe_winsys *pws)
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_buffer_create(struct pipe_winsys *pws,
unsigned alignment,
unsigned flags,
@@ -224,7 +224,7 @@ xm_buffer_create(struct pipe_winsys *pws,
/**
* Create buffer which wraps user-space data.
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
index 537cec8785c..8286da712c4 100644
--- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
+++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
@@ -89,7 +89,7 @@ cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
*/
boolean
cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h b/src/mesa/pipe/cell/ppu/cell_draw_arrays.h
index bd5b703f3ba..d5df4aa05f8 100644
--- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h
+++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.h
@@ -33,7 +33,7 @@ boolean cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
unsigned start, unsigned count);
boolean cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
diff --git a/src/mesa/pipe/cell/ppu/cell_texture.h b/src/mesa/pipe/cell/ppu/cell_texture.h
index 97d8bd12303..ef5808c0862 100644
--- a/src/mesa/pipe/cell/ppu/cell_texture.h
+++ b/src/mesa/pipe/cell/ppu/cell_texture.h
@@ -44,7 +44,7 @@ struct cell_texture
/* The data is held here:
*/
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
unsigned long buffer_size;
};
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c
index a1291f583b0..3799c4dfb0a 100644
--- a/src/mesa/pipe/failover/fo_context.c
+++ b/src/mesa/pipe/failover/fo_context.c
@@ -46,7 +46,7 @@ static void failover_destroy( struct pipe_context *pipe )
static boolean failover_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned prim, unsigned start, unsigned count)
{
diff --git a/src/mesa/pipe/i915simple/i915_blit.c b/src/mesa/pipe/i915simple/i915_blit.c
index 6e95313a0d2..d49876f9708 100644
--- a/src/mesa/pipe/i915simple/i915_blit.c
+++ b/src/mesa/pipe/i915simple/i915_blit.c
@@ -38,7 +38,7 @@ void
i915_fill_blit(struct i915_context *i915,
unsigned cpp,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
short x, short y,
short w, short h,
@@ -87,10 +87,10 @@ void
i915_copy_blit( struct i915_context *i915,
unsigned cpp,
short src_pitch,
- struct pipe_buffer_handle *src_buffer,
+ struct pipe_buffer *src_buffer,
unsigned src_offset,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
short src_x, short src_y,
short dst_x, short dst_y,
diff --git a/src/mesa/pipe/i915simple/i915_blit.h b/src/mesa/pipe/i915simple/i915_blit.h
index 7ea4e979eca..d7a66be10ae 100644
--- a/src/mesa/pipe/i915simple/i915_blit.h
+++ b/src/mesa/pipe/i915simple/i915_blit.h
@@ -33,10 +33,10 @@
extern void i915_copy_blit(struct i915_context *i915,
unsigned cpp,
short src_pitch,
- struct pipe_buffer_handle *src_buffer,
+ struct pipe_buffer *src_buffer,
unsigned src_offset,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
short srcx, short srcy,
short dstx, short dsty,
@@ -45,7 +45,7 @@ extern void i915_copy_blit(struct i915_context *i915,
extern void i915_fill_blit(struct i915_context *i915,
unsigned cpp,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
short x, short y,
short w, short h, unsigned color);
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index c2b96d2554e..497623a7006 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -166,7 +166,7 @@ static void i915_destroy( struct pipe_context *pipe )
static boolean
i915_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned prim, unsigned start, unsigned count)
{
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 2f1f0369934..b4ea63c3e74 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -172,7 +172,7 @@ struct i915_texture {
/* The data is held here:
*/
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
};
struct i915_context
@@ -204,7 +204,7 @@ struct i915_context
unsigned *batch_start;
/** Vertex buffer */
- struct pipe_buffer_handle *vbo;
+ struct pipe_buffer *vbo;
struct i915_state current;
unsigned hardware_dirty;
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index 0887f9a1c66..39154b2488b 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -42,6 +42,7 @@
#include "pipe/draw/draw_vbuf.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "i915_context.h"
@@ -192,7 +193,7 @@ i915_vbuf_render_release_vertices( struct vbuf_render *render,
assert(i915->vbo);
winsys->buffer_unmap(winsys, i915->vbo);
- winsys->buffer_reference(winsys, &i915->vbo, NULL);
+ pipe_buffer_reference(winsys, &i915->vbo, NULL);
}
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c
index 8598eacc9c3..657f5238938 100644
--- a/src/mesa/pipe/i915simple/i915_state_emit.c
+++ b/src/mesa/pipe/i915simple/i915_state_emit.c
@@ -278,7 +278,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
OUT_BATCH(enabled);
for (unit = 0; unit < I915_TEX_UNITS; unit++) {
if (enabled & (1 << unit)) {
- struct pipe_buffer_handle *buf =
+ struct pipe_buffer *buf =
i915->texture[unit]->buffer;
uint offset = 0;
assert(buf);
diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c
index e625f5a68c8..8ef02b99cd1 100644
--- a/src/mesa/pipe/i915simple/i915_surface.c
+++ b/src/mesa/pipe/i915simple/i915_surface.c
@@ -65,7 +65,7 @@ i915_get_tex_surface(struct pipe_context *pipe,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
index bf80e18233f..61944fe7d9a 100644
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ b/src/mesa/pipe/i915simple/i915_texture.c
@@ -523,7 +523,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe->winsys->buffer_reference(pipe->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
index 2c0f335d346..fe49710852b 100644
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ b/src/mesa/pipe/i915simple/i915_winsys.h
@@ -50,7 +50,7 @@
* etc.
*/
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct pipe_winsys;
@@ -93,7 +93,7 @@ struct i915_winsys {
* I915_BUFFER_ACCESS_READ macros.
*/
void (*batch_reloc)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta );
diff --git a/src/mesa/pipe/i965simple/brw_blit.c b/src/mesa/pipe/i965simple/brw_blit.c
index 4692129e402..bbd366294f5 100644
--- a/src/mesa/pipe/i965simple/brw_blit.c
+++ b/src/mesa/pipe/i965simple/brw_blit.c
@@ -42,7 +42,7 @@
void brw_fill_blit(struct brw_context *brw,
unsigned cpp,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
boolean dst_tiled,
short x, short y,
@@ -113,11 +113,11 @@ static unsigned translate_raster_op(unsigned logicop)
void brw_copy_blit(struct brw_context *brw,
unsigned cpp,
short src_pitch,
- struct pipe_buffer_handle *src_buffer,
+ struct pipe_buffer *src_buffer,
unsigned src_offset,
boolean src_tiled,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
boolean dst_tiled,
short src_x, short src_y,
diff --git a/src/mesa/pipe/i965simple/brw_blit.h b/src/mesa/pipe/i965simple/brw_blit.h
index 371a1353754..7f17a701732 100644
--- a/src/mesa/pipe/i965simple/brw_blit.h
+++ b/src/mesa/pipe/i965simple/brw_blit.h
@@ -3,13 +3,13 @@
#include "pipe/p_compiler.h"
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct brw_context;
void brw_fill_blit(struct brw_context *intel,
unsigned cpp,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
boolean dst_tiled,
short x, short y,
@@ -18,11 +18,11 @@ void brw_fill_blit(struct brw_context *intel,
void brw_copy_blit(struct brw_context *intel,
unsigned cpp,
short src_pitch,
- struct pipe_buffer_handle *src_buffer,
+ struct pipe_buffer *src_buffer,
unsigned src_offset,
boolean src_tiled,
short dst_pitch,
- struct pipe_buffer_handle *dst_buffer,
+ struct pipe_buffer *dst_buffer,
unsigned dst_offset,
boolean dst_tiled,
short src_x, short src_y,
diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h
index c610a435e0a..65664d853dd 100644
--- a/src/mesa/pipe/i965simple/brw_context.h
+++ b/src/mesa/pipe/i965simple/brw_context.h
@@ -260,7 +260,7 @@ struct brw_texture {
/* The data is held here:
*/
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
};
/* Data about a particular attempt to compile a program. Note that
@@ -350,7 +350,7 @@ struct brw_surface_binding_table {
struct brw_cache;
struct brw_mem_pool {
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
unsigned size;
unsigned offset; /* offset of first free byte */
@@ -615,7 +615,7 @@ struct brw_context
unsigned nr_surfaces;
unsigned max_threads;
- struct pipe_buffer_handle *scratch_buffer;
+ struct pipe_buffer *scratch_buffer;
unsigned scratch_buffer_size;
unsigned sampler_count;
diff --git a/src/mesa/pipe/i965simple/brw_draw.c b/src/mesa/pipe/i965simple/brw_draw.c
index acfb524a30a..7598e3dc8af 100644
--- a/src/mesa/pipe/i965simple/brw_draw.c
+++ b/src/mesa/pipe/i965simple/brw_draw.c
@@ -144,7 +144,7 @@ static boolean brw_emit_prim( struct brw_context *brw,
* fallback conditions.
*/
static boolean brw_try_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer_handle *index_buffer,
+ struct pipe_buffer *index_buffer,
unsigned index_size,
unsigned mode,
unsigned start,
@@ -183,7 +183,7 @@ static boolean brw_try_draw_elements( struct pipe_context *pipe,
static boolean brw_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode,
unsigned start,
diff --git a/src/mesa/pipe/i965simple/brw_draw.h b/src/mesa/pipe/i965simple/brw_draw.h
index 053f2efb9df..62fe0d5d0ee 100644
--- a/src/mesa/pipe/i965simple/brw_draw.h
+++ b/src/mesa/pipe/i965simple/brw_draw.h
@@ -42,7 +42,7 @@ boolean brw_upload_vertices( struct brw_context *brw,
unsigned max_index );
boolean brw_upload_indices(struct brw_context *brw,
- const struct pipe_buffer_handle *index_buffer,
+ const struct pipe_buffer *index_buffer,
int ib_size, int start, int count);
boolean brw_upload_vertex_buffers( struct brw_context *brw );
diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c
index 43e53914e9d..aa85d93866a 100644
--- a/src/mesa/pipe/i965simple/brw_draw_upload.c
+++ b/src/mesa/pipe/i965simple/brw_draw_upload.c
@@ -47,7 +47,7 @@ struct brw_array_state {
unsigned dword;
} vb0;
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
unsigned offset;
unsigned max_index;
@@ -272,7 +272,7 @@ boolean brw_upload_vertex_elements( struct brw_context *brw )
}
boolean brw_upload_indices( struct brw_context *brw,
- const struct pipe_buffer_handle *index_buffer,
+ const struct pipe_buffer *index_buffer,
int ib_size, int start, int count)
{
/* Emit the indexbuffer packet:
diff --git a/src/mesa/pipe/i965simple/brw_state.h b/src/mesa/pipe/i965simple/brw_state.h
index 8b4d7aabf0a..258e9a556e2 100644
--- a/src/mesa/pipe/i965simple/brw_state.h
+++ b/src/mesa/pipe/i965simple/brw_state.h
@@ -106,7 +106,7 @@ boolean brw_search_cache( struct brw_cache *cache,
void brw_init_caches( struct brw_context *brw );
void brw_destroy_caches( struct brw_context *brw );
-static inline struct pipe_buffer_handle *brw_cache_buffer(struct brw_context *brw,
+static inline struct pipe_buffer *brw_cache_buffer(struct brw_context *brw,
enum brw_cache_id id)
{
return brw->cache[id].pool->buffer;
diff --git a/src/mesa/pipe/i965simple/brw_state_pool.c b/src/mesa/pipe/i965simple/brw_state_pool.c
index 2f930be837b..7c67f0ee25d 100644
--- a/src/mesa/pipe/i965simple/brw_state_pool.c
+++ b/src/mesa/pipe/i965simple/brw_state_pool.c
@@ -44,6 +44,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "brw_context.h"
#include "brw_state.h"
@@ -101,9 +102,9 @@ static void brw_destroy_pool( struct brw_context *brw,
{
struct brw_mem_pool *pool = &brw->pool[pool_id];
- pool->brw->pipe.winsys->buffer_reference( pool->brw->pipe.winsys,
- &pool->buffer,
- NULL );
+ pipe_buffer_reference( pool->brw->pipe.winsys,
+ &pool->buffer,
+ NULL );
}
diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c
index 76b8c73d5c2..252aec7d29c 100644
--- a/src/mesa/pipe/i965simple/brw_surface.c
+++ b/src/mesa/pipe/i965simple/brw_surface.c
@@ -64,7 +64,7 @@ brw_get_tex_surface(struct pipe_context *pipe,
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c
index eadacbf09e8..b8b6b579e22 100644
--- a/src/mesa/pipe/i965simple/brw_tex_layout.c
+++ b/src/mesa/pipe/i965simple/brw_tex_layout.c
@@ -39,6 +39,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "brw_context.h"
@@ -341,7 +342,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe->winsys->buffer_reference(pipe->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
diff --git a/src/mesa/pipe/i965simple/brw_winsys.h b/src/mesa/pipe/i965simple/brw_winsys.h
index b60f63aa5bf..3523a58614f 100644
--- a/src/mesa/pipe/i965simple/brw_winsys.h
+++ b/src/mesa/pipe/i965simple/brw_winsys.h
@@ -50,7 +50,7 @@
* etc.
*/
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct pipe_fence_handle;
struct pipe_winsys;
@@ -136,7 +136,7 @@ struct brw_winsys {
* I915_BUFFER_ACCESS_READ macros.
*/
void (*batch_reloc)(struct brw_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta);
@@ -159,7 +159,7 @@ struct brw_winsys {
* simulator:
*/
void (*buffer_subdata_typed)(struct brw_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned long offset,
unsigned long size,
const void *data,
@@ -170,7 +170,7 @@ struct brw_winsys {
* of places yet:
*/
unsigned (*get_buffer_offset)( struct brw_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned flags );
};
diff --git a/src/mesa/pipe/i965simple/brw_wm_surface_state.c b/src/mesa/pipe/i965simple/brw_wm_surface_state.c
index fc40e0438c4..cbb4f2efd3b 100644
--- a/src/mesa/pipe/i965simple/brw_wm_surface_state.c
+++ b/src/mesa/pipe/i965simple/brw_wm_surface_state.c
@@ -127,7 +127,7 @@ static unsigned translate_tex_format( enum pipe_format pipe_format )
}
static unsigned brw_buffer_offset(struct brw_context *brw,
- struct pipe_buffer_handle *buffer)
+ struct pipe_buffer *buffer)
{
return brw->winsys->get_buffer_offset(brw->winsys,
buffer,
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 7a18d488657..37464c88a13 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -74,7 +74,7 @@ struct pipe_context {
unsigned mode, unsigned start, unsigned count);
boolean (*draw_elements)( struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h
index 8ee0820f921..ebf6ed86bcc 100644
--- a/src/mesa/pipe/p_inlines.h
+++ b/src/mesa/pipe/p_inlines.h
@@ -56,20 +56,38 @@ pipe_surface_unmap(struct pipe_surface *surface)
static INLINE void
pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
{
- assert(ptr);
- if (*ptr) {
+ /* bump the refcount first */
+ if (surf)
+ surf->refcount++;
+
+ if (*ptr /* && --(*ptr)->refcount == 0 */) {
struct pipe_winsys *winsys = (*ptr)->winsys;
winsys->surface_release(winsys, ptr);
assert(!*ptr);
}
- if (surf) {
- /* reference the new thing */
- surf->refcount++;
- *ptr = surf;
- }
+
+ *ptr = surf;
+}
+
+
+/* XXX: thread safety issues!
+ */
+static INLINE void
+pipe_buffer_reference(struct pipe_winsys *winsys,
+ struct pipe_buffer **ptr,
+ struct pipe_buffer *buf)
+{
+ if (buf)
+ buf->refcount++;
+
+ if (*ptr && --(*ptr)->refcount == 0)
+ winsys->buffer_destroy( winsys, *ptr );
+
+ *ptr = buf;
}
+
/**
* \sa pipe_surface_reference
*/
@@ -78,15 +96,16 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
struct pipe_texture *pt)
{
assert(ptr);
+
+ if (pt)
+ pt->refcount++;
+
if (*ptr) {
pipe->texture_release(pipe, ptr);
assert(!*ptr);
}
- if (pt) {
- /* reference the new thing */
- pt->refcount++;
- *ptr = pt;
- }
+
+ *ptr = pt;
}
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 146a479cf37..83ca43f6785 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -60,8 +60,21 @@
struct pipe_surface;
struct pipe_winsys;
-/* opaque type */
-struct pipe_buffer_handle;
+
+
+/**
+ * The driver will certainly subclass this to include actual memory
+ * management information.
+ */
+struct pipe_buffer {
+ unsigned alignment;
+ unsigned usage;
+ unsigned size;
+
+ /** Reference count */
+ unsigned refcount;
+};
+
@@ -129,7 +142,7 @@ struct pipe_clip_state {
* Constants for vertex/fragment shaders
*/
struct pipe_constant_buffer {
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
unsigned size; /** in bytes */
};
@@ -240,7 +253,7 @@ struct pipe_sampler_state
*/
struct pipe_surface
{
- struct pipe_buffer_handle *buffer; /**< driver private buffer handle */
+ struct pipe_buffer *buffer; /**< driver private buffer handle */
enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned status; /**< PIPE_SURFACE_STATUS_x */
unsigned clear_value; /**< may be temporary */
@@ -290,7 +303,7 @@ struct pipe_vertex_buffer
unsigned pitch:11; /**< stride to same attrib in next vertex, in bytes */
unsigned max_index; /**< number of vertices in this buffer */
unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
- struct pipe_buffer_handle *buffer; /**< the actual buffer */
+ struct pipe_buffer *buffer; /**< the actual buffer */
};
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
index 9742f59a4dc..95e3684008d 100644
--- a/src/mesa/pipe/p_winsys.h
+++ b/src/mesa/pipe/p_winsys.h
@@ -39,9 +39,6 @@
*/
-/** Opaque type for a buffer */
-struct pipe_buffer_handle;
-
/** Opaque type */
struct pipe_fence_handle;
@@ -103,13 +100,13 @@ struct pipe_winsys
* usage argument is only an optimization hint, not a guarantee, therefore
* proper behavior must be observed in all circumstances.
*/
- struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws,
+ struct pipe_buffer *(*buffer_create)( struct pipe_winsys *sws,
unsigned alignment,
unsigned usage,
unsigned size );
/** Create a buffer that wraps user-space data */
- struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws,
+ struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *sws,
void *ptr,
unsigned bytes);
@@ -118,16 +115,14 @@ struct pipe_winsys
* flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
*/
void *(*buffer_map)( struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned usage );
void (*buffer_unmap)( struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf );
+ struct pipe_buffer *buf );
- /** Set ptr = buf, with reference counting */
- void (*buffer_reference)( struct pipe_winsys *sws,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf );
+ void (*buffer_destroy)( struct pipe_winsys *sws,
+ struct pipe_buffer *buf );
/** Set ptr = fence, with reference counting */
diff --git a/src/mesa/pipe/pipebuffer/Makefile b/src/mesa/pipe/pipebuffer/Makefile
index 061d8a060fe..0d23e8b8f16 100644
--- a/src/mesa/pipe/pipebuffer/Makefile
+++ b/src/mesa/pipe/pipebuffer/Makefile
@@ -8,10 +8,8 @@ LIBNAME = pipebuffer
DRIVER_SOURCES = \
pb_buffer.c \
pb_buffer_client.c \
- pb_buffer_handle.c \
pb_buffer_fenced.c \
pb_buffer_malloc.c \
- pb_buffer_null.c \
pb_bufmgr_fenced.c \
pb_bufmgr_mm.c \
pb_bufmgr_pool.c
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.c b/src/mesa/pipe/pipebuffer/pb_buffer.c
index 99c960b6979..90ab9044ffb 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.c
@@ -34,19 +34,44 @@
#include "pb_buffer.h"
+#include "pipe/p_winsys.h"
-void
-buffer_reference(struct pipe_buffer **dst,
- struct pipe_buffer *src)
+
+static void *
+pb_winsys_map(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf,
+ unsigned flags)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ return buf->vtbl->map(buf, flags);
+}
+
+static void
+pb_winsys_unmap(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ buf->vtbl->unmap(buf);
+}
+
+static void
+pb_winsys_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ buf->vtbl->destroy(buf);
+}
+
+
+
+void
+pb_init_winsys(struct pipe_winsys *winsys)
{
- if(*dst != src) {
- if (src)
- src->vtbl->reference(src);
-
- if (*dst)
- (*dst)->vtbl->release(*dst);
-
- *dst = src;
- }
+ winsys->buffer_map = pb_winsys_map;
+ winsys->buffer_unmap = pb_winsys_unmap;
+ winsys->buffer_destroy = pb_winsys_destroy;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.h b/src/mesa/pipe/pipebuffer/pb_buffer.h
index 05235313953..f909bded0dd 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer.h
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.h
@@ -47,53 +47,43 @@
#include <assert.h>
#include <stdlib.h>
+#include "pipe/p_state.h"
-struct pipe_buffer_vtbl;
-
+struct pb_vtbl;
/**
- * Base class for all pipe buffers.
+ * Base class for all pb_* buffers.
*/
-struct pipe_buffer
+struct pb_buffer
{
+ struct pipe_buffer base;
+
/**
* Pointer to the virtual function table.
*
* Avoid accessing this table directly. Use the inline functions below
* instead to avoid mistakes.
*/
- const struct pipe_buffer_vtbl *vtbl;
+ const struct pb_vtbl *vtbl;
};
-
/**
* Virtual function table for the buffer storage operations.
*
* Note that creation is not done through this table.
*/
-struct pipe_buffer_vtbl
+struct pb_vtbl
{
- /**
- * Add a reference to the buffer.
- *
- * This method can be a no-op for buffers that don't need reference
- * counting.
- */
- void (*reference)( struct pipe_buffer *buf );
-
- /**
- * Release a reference to this buffer and destroy it.
- */
- void (*release)( struct pipe_buffer *buf );
+ void (*destroy)( struct pb_buffer *buf );
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
*/
- void *(*map)( struct pipe_buffer *buf,
+ void *(*map)( struct pb_buffer *buf,
unsigned flags );
- void (*unmap)( struct pipe_buffer *buf );
+ void (*unmap)( struct pb_buffer *buf );
/**
* Get the base buffer and the offset.
@@ -106,29 +96,17 @@ struct pipe_buffer_vtbl
*
* Note that this will increase the reference count of the base buffer.
*/
- void (*get_base_buffer)( struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+ void (*get_base_buffer)( struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset );
};
-/** *dst = src with reference counting */
-void
-buffer_reference(struct pipe_buffer **dst,
- struct pipe_buffer *src);
-
-
-static inline void
-buffer_release(struct pipe_buffer *buf)
-{
- assert(buf);
- buf->vtbl->release(buf);
-}
-
-
+/* Accessor functions for pb->vtbl:
+ */
static inline void *
-buffer_map(struct pipe_buffer *buf,
- unsigned flags)
+pb_map(struct pb_buffer *buf,
+ unsigned flags)
{
assert(buf);
return buf->vtbl->map(buf, flags);
@@ -136,7 +114,7 @@ buffer_map(struct pipe_buffer *buf,
static inline void
-buffer_unmap(struct pipe_buffer *buf)
+pb_unmap(struct pb_buffer *buf)
{
assert(buf);
buf->vtbl->unmap(buf);
@@ -144,32 +122,63 @@ buffer_unmap(struct pipe_buffer *buf)
static inline void
-buffer_get_base_buffer( struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
- unsigned *offset )
+pb_get_base_buffer( struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
+ unsigned *offset )
{
buf->vtbl->get_base_buffer(buf, base_buf, offset);
}
+static inline void
+pb_destroy(struct pb_buffer *buf)
+{
+ assert(buf);
+ buf->vtbl->destroy(buf);
+}
+
-/** Placeholder for empty buffers. */
-extern struct pipe_buffer null_buffer;
/**
- * Client buffers (also designated as user buffers) are just for convenience
- * of the state tracker, so that it can masquerade its own data as a buffer.
+ * User buffers are special buffers that initially reference memory
+ * held by the user but which may if necessary copy that memory into
+ * device memory behind the scenes, for submission to hardware.
+ *
+ * These are particularly useful when the referenced data is never
+ * submitted to hardware at all, in the particular case of software
+ * vertex processing.
*/
-struct pipe_buffer *
-client_buffer_create(void *data);
+struct pb_buffer *
+pb_user_buffer_create(void *data, unsigned bytes);
/**
* Malloc-based buffer to store data that can't be used by the graphics
* hardware.
*/
-struct pipe_buffer *
-malloc_buffer_create(unsigned size);
+struct pb_buffer *
+pb_malloc_buffer_create( unsigned alignment,
+ unsigned usage,
+ unsigned size );
+
+
+
+static inline struct pipe_buffer *
+pb_pipe_buffer( struct pb_buffer *pbuf )
+{
+ return &pbuf->base;
+}
+
+static inline struct pb_buffer *
+pb_buffer( struct pipe_buffer *buf )
+{
+ /* Could add a magic cookie check on debug builds.
+ */
+ return (struct pb_buffer *)buf;
+}
+
+void
+pb_init_winsys(struct pipe_winsys *winsys);
#endif /*PB_BUFFER_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_client.c b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
index bb7f5a9a947..6bf47453016 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_client.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
@@ -35,36 +35,30 @@
#include "pb_buffer.h"
+#include "pipe/p_util.h"
-struct client_buffer
+struct pb_user_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
void *data;
};
-extern const struct pipe_buffer_vtbl client_buffer_vtbl;
+extern const struct pb_vtbl pb_user_buffer_vtbl;
-static inline struct client_buffer *
-client_buffer(struct pipe_buffer *buf)
+static INLINE struct pb_user_buffer *
+pb_user_buffer(struct pb_buffer *buf)
{
assert(buf);
- assert(buf->vtbl == &client_buffer_vtbl);
- return (struct client_buffer *)buf;
+ assert(buf->vtbl == &pb_user_buffer_vtbl);
+ return (struct pb_user_buffer *)buf;
}
static void
-client_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-client_buffer_release(struct pipe_buffer *buf)
+pb_user_buffer_destroy(struct pb_buffer *buf)
{
assert(buf);
free(buf);
@@ -72,23 +66,23 @@ client_buffer_release(struct pipe_buffer *buf)
static void *
-client_buffer_map(struct pipe_buffer *buf,
+pb_user_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
- return client_buffer(buf)->data;
+ return pb_user_buffer(buf)->data;
}
static void
-client_buffer_unmap(struct pipe_buffer *buf)
+pb_user_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-client_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+pb_user_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
*base_buf = buf;
@@ -96,27 +90,25 @@ client_buffer_get_base_buffer(struct pipe_buffer *buf,
}
-const struct pipe_buffer_vtbl
-client_buffer_vtbl = {
- client_buffer_reference,
- client_buffer_release,
- client_buffer_map,
- client_buffer_unmap,
- client_buffer_get_base_buffer
+const struct pb_vtbl
+pb_user_buffer_vtbl = {
+ pb_user_buffer_destroy,
+ pb_user_buffer_map,
+ pb_user_buffer_unmap,
+ pb_user_buffer_get_base_buffer
};
-struct pipe_buffer *
-client_buffer_create(void *data)
+struct pb_buffer *
+pb_user_buffer_create(void *data, unsigned bytes)
{
- struct client_buffer *buf;
-
- buf = (struct client_buffer *)malloc(sizeof(struct client_buffer));
+ struct pb_user_buffer *buf = CALLOC_STRUCT(pb_user_buffer);
+
if(!buf)
return NULL;
- buf->base.vtbl = &client_buffer_vtbl;
-
+ buf->base.vtbl = &pb_user_buffer_vtbl;
+ buf->base.base.size = bytes;
buf->data = data;
return &buf->base;
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
index dfb80b1dcf4..625120d7143 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
@@ -72,9 +72,9 @@ struct fenced_buffer_list
*/
struct fenced_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
unsigned refcount;
struct pipe_fence_handle *fence;
@@ -84,8 +84,8 @@ struct fenced_buffer
};
-static inline struct fenced_buffer *
-fenced_buffer(struct pipe_buffer *buf)
+static INLINE struct fenced_buffer *
+fenced_buffer(struct pb_buffer *buf)
{
assert(buf);
assert(buf->vtbl == &fenced_buffer_vtbl);
@@ -93,12 +93,6 @@ fenced_buffer(struct pipe_buffer *buf)
}
-static void
-_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
-{
- buffer_release(fenced_buf->buffer);
- free(fenced_buf);
-}
static void
@@ -143,97 +137,81 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
LIST_DEL(list);
fenced_list->numDelayed--;
-
- _fenced_buffer_destroy(fenced_buf);
- }
-}
-
-static void
-fenced_buffer_reference(struct pipe_buffer *buf)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- fenced_buf->refcount++;
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ /* Do the delayed destroy:
+ */
+ pb_destroy(fenced_buf->buffer);
+ free(fenced_buf);
+ }
}
static void
-fenced_buffer_release(struct pipe_buffer *buf)
+fenced_buffer_destroy(struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
-
- fenced_buf->refcount--;
- if(!fenced_buf->refcount) {
- if (fenced_buf->fence) {
- LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
- fenced_list->numDelayed++;
- }
- else {
- _fenced_buffer_destroy(fenced_buf);
- }
-
- if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
- _fenced_buffer_list_check_free(fenced_list, 0);
+ if (fenced_buf->fence) {
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
+ fenced_list->numDelayed++;
+ }
+ else {
+ pb_destroy(fenced_buf->buffer);
+ free(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
+ _fenced_buffer_list_check_free(fenced_list, 0);
}
static void *
-fenced_buffer_map(struct pipe_buffer *buf,
+fenced_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- return buffer_map(fenced_buf->buffer, flags);
+ return pb_map(fenced_buf->buffer, flags);
}
static void
-fenced_buffer_unmap(struct pipe_buffer *buf)
+fenced_buffer_unmap(struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- buffer_unmap(fenced_buf->buffer);
+ pb_unmap(fenced_buf->buffer);
}
static void
-fenced_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+fenced_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- buffer_get_base_buffer(fenced_buf->buffer, base_buf, offset);
+ pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
}
-const struct pipe_buffer_vtbl
+const struct pb_vtbl
fenced_buffer_vtbl = {
- fenced_buffer_reference,
- fenced_buffer_release,
+ fenced_buffer_destroy,
fenced_buffer_map,
fenced_buffer_unmap,
fenced_buffer_get_base_buffer
};
-struct pipe_buffer *
+struct pb_buffer *
fenced_buffer_create(struct fenced_buffer_list *fenced_list,
- struct pipe_buffer *buffer)
+ struct pb_buffer *buffer)
{
struct fenced_buffer *buf;
if(!buffer)
return NULL;
- buf = (struct fenced_buffer *)calloc(1, sizeof(struct fenced_buffer));
+ buf = CALLOC_STRUCT(fenced_buffer);
if(!buf)
return NULL;
@@ -247,20 +225,16 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
void
-buffer_fence(struct pipe_buffer *buf,
+buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence)
{
- if(buf->vtbl == &fenced_buffer_vtbl) {
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
- struct pipe_winsys *winsys = fenced_list->winsys;
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+ struct pipe_winsys *winsys = fenced_list->winsys;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- winsys->fence_reference(winsys, &fenced_buf->fence, fence);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
- }
- else
- assert(0);
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ winsys->fence_reference(winsys, &fenced_buf->fence, fence);
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
index 07e42a67f87..09082a53909 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
@@ -70,7 +70,7 @@ struct fenced_buffer_list;
*
* NOTE: Made public for debugging purposes.
*/
-extern const struct pipe_buffer_vtbl fenced_buffer_vtbl;
+extern const struct pb_vtbl fenced_buffer_vtbl;
/**
@@ -98,19 +98,19 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
*
* NOTE: this will not increase the buffer reference count.
*/
-struct pipe_buffer *
+struct pb_buffer *
fenced_buffer_create(struct fenced_buffer_list *fenced,
- struct pipe_buffer *buffer);
+ struct pb_buffer *buffer);
/**
* Set a buffer's fence.
*
- * NOTE: Although it takes a generic pipe buffer argument, it will fail
+ * NOTE: Although it takes a generic pb_buffer argument, it will fail
* on everything but buffers returned by fenced_buffer_create.
*/
void
-buffer_fence(struct pipe_buffer *buf,
+buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence);
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
deleted file mode 100644
index 9aeff976f31..00000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Drop-in implementation of the winsys driver functions for buffer handles.
- *
- * \author Jos� Fonseca <[email protected]>
- */
-
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_defines.h"
-
-#include "pb_buffer.h"
-#include "pb_buffer_handle.h"
-
-
-static struct pipe_buffer_handle *
-buffer_handle_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct pipe_buffer_handle *handle;
-
- handle = (struct pipe_buffer_handle *)malloc(sizeof(struct pipe_buffer_handle));
- if(!handle)
- return NULL;
-
- handle->refcount = 1;
- handle->alignment = alignment;
- handle->usage = usage;
- handle->size = size;
-
- handle->buf = &null_buffer;
-
- return handle;
-}
-
-
-static struct pipe_buffer_handle *
-buffer_handle_create_user(struct pipe_winsys *winsys,
- void *data, unsigned size)
-{
- struct pipe_buffer_handle *handle;
- struct pipe_buffer *buf;
-
- handle = buffer_handle_create(winsys, 1, 0, size);
- if(!handle)
- return NULL;
-
- buf = client_buffer_create(data);
- if(!buf) {
- free(handle);
- return NULL;
- }
-
- buffer_handle_data(handle, buf);
-
- return handle;
-}
-
-
-static void *
-buffer_handle_map(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle,
- unsigned flags)
-{
- return buffer_map(handle->buf, flags);
-}
-
-
-static void
-buffer_handle_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle)
-{
- buffer_unmap(handle->buf);
-}
-
-
-static void
-buffer_handle_reference(struct pipe_winsys *winsys,
- struct pipe_buffer_handle **dst,
- struct pipe_buffer_handle *src)
-{
- /* XXX: should this be thread safe? */
-
- if (src) {
- src->refcount++;
- }
-
- if (*dst) {
- (*dst)->refcount--;
- if ((*dst)->refcount == 0) {
- buffer_release((*dst)->buf);
- free(*dst);
- }
- }
-
- *dst = src;
-}
-
-
-void
-buffer_handle_init_winsys(struct pipe_winsys *winsys)
-{
- winsys->buffer_create = buffer_handle_create;
- winsys->user_buffer_create = buffer_handle_create_user;
- winsys->buffer_map = buffer_handle_map;
- winsys->buffer_unmap = buffer_handle_unmap;
- winsys->buffer_reference = buffer_handle_reference;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
deleted file mode 100644
index 34133c9fbac..00000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Buffer handle interface.
- *
- * \author Jos� Fonseca <[email protected]>
- */
-
-#ifndef PB_BUFFER_HANDLE_H_
-#define PB_BUFFER_HANDLE_H_
-
-
-#include <assert.h>
-
-#include "pb_buffer.h"
-
-
-/**
- * Buffer handle.
- *
- * The buffer handle and the buffer data storage are separate entities. This
- * is modelled after ARB_vertex_buffer_object, which is the interface that
- * Gallium requires. See p_winsys.h for more information.
- */
-struct pipe_buffer_handle
-{
- /** Reference count */
- unsigned refcount;
-
- /** Allocation characteristics */
- unsigned alignment;
- unsigned usage;
- unsigned size;
-
- /**
- * The actual buffer.
- *
- * It should never be NULL. Use null_buffer instead.
- */
- struct pipe_buffer *buf;
-};
-
-
-/**
- * Set buffer storage.
- *
- * NOTE: this will not increase the buffer reference count.
- */
-static inline void
-buffer_handle_data(struct pipe_buffer_handle *handle,
- struct pipe_buffer *buf)
-{
- assert(handle);
- assert(handle->buf);
- buffer_release(handle->buf);
- assert(buf);
- handle->buf = buf;
-}
-
-
-static inline void
-buffer_handle_clear(struct pipe_buffer_handle *handle)
-{
- buffer_handle_data(handle, &null_buffer);
-}
-
-
-static inline int
-buffer_handle_has_data(struct pipe_buffer_handle *handle) {
- assert(handle);
- assert(handle->buf);
- return handle->buf != &null_buffer;
-}
-
-
-/**
- * Fill in the pipe_winsys' buffer-related callbacks.
- *
- * Specifically, the fullfilled functions are:
- * - buffer_create
- * - user_buffer_create
- * - buffer_map
- * - buffer_unmap
- * - buffer_reference
- * - buffer_subdata
- * - buffer_get_subdata
- *
- * NOTE: buffer_data is left untouched.
- */
-void
-buffer_handle_init_winsys(struct pipe_winsys *winsys);
-
-
-#endif /*PB_BUFFER_HANDLE_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
index 65ad51e1e7e..e02eb1eebd4 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
@@ -42,15 +42,15 @@
struct malloc_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
void *data;
};
-extern const struct pipe_buffer_vtbl malloc_buffer_vtbl;
+extern const struct pb_vtbl malloc_buffer_vtbl;
-static inline struct malloc_buffer *
-malloc_buffer(struct pipe_buffer *buf)
+static INLINE struct malloc_buffer *
+malloc_buffer(struct pb_buffer *buf)
{
assert(buf);
assert(buf->vtbl == &malloc_buffer_vtbl);
@@ -59,14 +59,7 @@ malloc_buffer(struct pipe_buffer *buf)
static void
-malloc_buffer_reference(struct pipe_buffer *buf)
-{
- /* no-op */
-}
-
-
-static void
-malloc_buffer_release(struct pipe_buffer *buf)
+malloc_buffer_destroy(struct pb_buffer *buf)
{
free(malloc_buffer(buf)->data);
free(buf);
@@ -74,7 +67,7 @@ malloc_buffer_release(struct pipe_buffer *buf)
static void *
-malloc_buffer_map(struct pipe_buffer *buf,
+malloc_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
return malloc_buffer(buf)->data;
@@ -82,15 +75,15 @@ malloc_buffer_map(struct pipe_buffer *buf,
static void
-malloc_buffer_unmap(struct pipe_buffer *buf)
+malloc_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-malloc_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+malloc_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
*base_buf = buf;
@@ -98,18 +91,19 @@ malloc_buffer_get_base_buffer(struct pipe_buffer *buf,
}
-const struct pipe_buffer_vtbl
+const struct pb_vtbl
malloc_buffer_vtbl = {
- malloc_buffer_reference,
- malloc_buffer_release,
+ malloc_buffer_destroy,
malloc_buffer_map,
malloc_buffer_unmap,
malloc_buffer_get_base_buffer
};
-struct pipe_buffer *
-malloc_buffer_create(unsigned size)
+struct pb_buffer *
+pb_malloc_buffer_create( unsigned alignment,
+ unsigned usage,
+ unsigned size )
{
struct malloc_buffer *buf;
@@ -121,7 +115,10 @@ malloc_buffer_create(unsigned size)
return NULL;
buf->base.vtbl = &malloc_buffer_vtbl;
-
+ buf->base.base.alignment = alignment;
+ buf->base.base.usage = usage;
+ buf->base.base.size = size;
+
buf->data = malloc(size);
if(!buf->data) {
free(buf);
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_null.c b/src/mesa/pipe/pipebuffer/pb_buffer_null.c
deleted file mode 100644
index a356c6b2d5c..00000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_null.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Null buffer implementation.
- *
- * We have a special null buffer object so that we can safely call buffer
- * operations without having to check whether the buffer pointer is null or not.
- *
- * \author Jos� Fonseca <[email protected]>
- */
-
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_defines.h"
-
-#include "pb_buffer.h"
-
-
-static void
-null_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-null_buffer_release(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void *
-null_buffer_map(struct pipe_buffer *buf,
- unsigned flags)
-{
- assert(0);
- return NULL;
-}
-
-
-static void
-null_buffer_unmap(struct pipe_buffer *buf)
-{
- assert(0);
-}
-
-
-static void
-null_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-const struct pipe_buffer_vtbl
-pipe_buffer_vtbl = {
- null_buffer_reference,
- null_buffer_release,
- null_buffer_map,
- null_buffer_unmap,
- null_buffer_get_base_buffer
-};
-
-
-struct pipe_buffer
-null_buffer = {
- &pipe_buffer_vtbl
-};
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
index 12e36323a83..13d4ea75459 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
@@ -60,15 +60,15 @@ struct pipe_winsys;
/**
* Abstract base class for all buffer managers.
*/
-struct buffer_manager
+struct pb_manager
{
/* XXX: we will likely need more allocation flags */
- struct pipe_buffer *
- (*create_buffer)( struct buffer_manager *mgr,
+ struct pb_buffer *
+ (*create_buffer)( struct pb_manager *mgr,
size_t size );
void
- (*destroy)( struct buffer_manager *mgr );
+ (*destroy)( struct pb_manager *mgr );
};
@@ -80,8 +80,8 @@ struct buffer_manager
*
* It is meant to manage the allocation of batch buffer pools.
*/
-struct buffer_manager *
-pool_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+pool_bufmgr_create(struct pb_manager *provider,
size_t n, size_t size);
@@ -92,8 +92,8 @@ pool_bufmgr_create(struct buffer_manager *provider,
* with the size of the heap, and then using the old mm memory manager to manage
* that heap.
*/
-struct buffer_manager *
-mm_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2);
/**
@@ -101,8 +101,8 @@ mm_bufmgr_create(struct buffer_manager *provider,
*
* Buffer will be release when the manager is destroyed.
*/
-struct buffer_manager *
-mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+struct pb_manager *
+mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2);
@@ -115,8 +115,8 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
* NOTE: the buffer manager that provides the buffers will be destroyed
* at the same time.
*/
-struct buffer_manager *
-fenced_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys);
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
index defd8e4df78..8cdbbed2725 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
@@ -42,30 +42,30 @@
#include "pb_bufmgr.h"
-struct fenced_buffer_manager
+struct fenced_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
- struct buffer_manager *provider;
+ struct pb_manager *provider;
struct fenced_buffer_list *fenced_list;
};
-static inline struct fenced_buffer_manager *
-fenced_buffer_manager(struct buffer_manager *mgr)
+static inline struct fenced_pb_manager *
+fenced_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct fenced_buffer_manager *)mgr;
+ return (struct fenced_pb_manager *)mgr;
}
-static struct pipe_buffer *
-fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+static struct pb_buffer *
+fenced_bufmgr_create_buffer(struct pb_manager *mgr, size_t size)
{
- struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
- struct pipe_buffer *buf;
- struct pipe_buffer *fenced_buf;
+ struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
+ struct pb_buffer *buf;
+ struct pb_buffer *fenced_buf;
/* check for free buffers before allocating new ones */
fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0);
@@ -84,7 +84,7 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
if(!fenced_buf) {
- buffer_release(buf);
+ pb_destroy(buf);
}
return fenced_buf;
@@ -92,9 +92,9 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
static void
-fenced_bufmgr_destroy(struct buffer_manager *mgr)
+fenced_bufmgr_destroy(struct pb_manager *mgr)
{
- struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
+ struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
fenced_buffer_list_destroy(fenced_mgr->fenced_list);
@@ -104,13 +104,13 @@ fenced_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-fenced_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys)
{
- struct fenced_buffer_manager *fenced_mgr;
+ struct fenced_pb_manager *fenced_mgr;
- fenced_mgr = (struct fenced_buffer_manager *)calloc(1, sizeof(*fenced_mgr));
+ fenced_mgr = (struct fenced_pb_manager *)calloc(1, sizeof(*fenced_mgr));
if (!fenced_mgr)
return NULL;
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
index d174f24e325..f456b571d98 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -53,9 +53,9 @@
#define SUPER(__derived) (&(__derived)->base)
-struct mm_buffer_manager
+struct mm_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
_glthread_Mutex mutex;
@@ -64,31 +64,31 @@ struct mm_buffer_manager
size_t align2;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
void *map;
};
-static inline struct mm_buffer_manager *
-mm_buffer_manager(struct buffer_manager *mgr)
+static inline struct mm_pb_manager *
+mm_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct mm_buffer_manager *)mgr;
+ return (struct mm_pb_manager *)mgr;
}
struct mm_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct mm_buffer_manager *mgr;
+ struct mm_pb_manager *mgr;
struct mem_block *block;
};
static inline struct mm_buffer *
-mm_buffer(struct pipe_buffer *buf)
+mm_buffer(struct pb_buffer *buf)
{
assert(buf);
return (struct mm_buffer *)buf;
@@ -96,17 +96,10 @@ mm_buffer(struct pipe_buffer *buf)
static void
-mm_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-mm_buffer_release(struct pipe_buffer *buf)
+mm_buffer_destroy(struct pb_buffer *buf)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
+ struct mm_pb_manager *mm = mm_buf->mgr;
_glthread_LOCK_MUTEX(mm->mutex);
mmFreeMem(mm_buf->block);
@@ -116,50 +109,49 @@ mm_buffer_release(struct pipe_buffer *buf)
static void *
-mm_buffer_map(struct pipe_buffer *buf,
+mm_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
+ struct mm_pb_manager *mm = mm_buf->mgr;
return (unsigned char *) mm->map + mm_buf->block->ofs;
}
static void
-mm_buffer_unmap(struct pipe_buffer *buf)
+mm_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-mm_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+mm_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
- buffer_get_base_buffer(mm->buffer, base_buf, offset);
+ struct mm_pb_manager *mm = mm_buf->mgr;
+ pb_get_base_buffer(mm->buffer, base_buf, offset);
*offset += mm_buf->block->ofs;
}
-static const struct pipe_buffer_vtbl
+static const struct pb_vtbl
mm_buffer_vtbl = {
- mm_buffer_reference,
- mm_buffer_release,
+ mm_buffer_destroy,
mm_buffer_map,
mm_buffer_unmap,
mm_buffer_get_base_buffer
};
-static struct pipe_buffer *
-mm_bufmgr_create_buffer(struct buffer_manager *mgr,
+static struct pb_buffer *
+mm_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size)
{
- struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+ struct mm_pb_manager *mm = mm_pb_manager(mgr);
struct mm_buffer *mm_buf;
_glthread_LOCK_MUTEX(mm->mutex);
@@ -200,16 +192,16 @@ mm_bufmgr_create_buffer(struct buffer_manager *mgr,
static void
-mm_bufmgr_destroy(struct buffer_manager *mgr)
+mm_bufmgr_destroy(struct pb_manager *mgr)
{
- struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+ struct mm_pb_manager *mm = mm_pb_manager(mgr);
_glthread_LOCK_MUTEX(mm->mutex);
mmDestroy(mm->heap);
- buffer_unmap(mm->buffer);
- buffer_release(mm->buffer);
+ pb_unmap(mm->buffer);
+ pb_destroy(mm->buffer);
_glthread_UNLOCK_MUTEX(mm->mutex);
@@ -217,16 +209,16 @@ mm_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+struct pb_manager *
+mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2)
{
- struct mm_buffer_manager *mm;
+ struct mm_pb_manager *mm;
if(!buffer)
return NULL;
- mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm));
+ mm = (struct mm_pb_manager *)calloc(1, sizeof(*mm));
if (!mm)
return NULL;
@@ -240,9 +232,9 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
mm->buffer = buffer;
- mm->map = buffer_map(mm->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ mm->map = pb_map(mm->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if(!mm->map)
goto failure;
@@ -256,19 +248,19 @@ failure:
if(mm->heap)
mmDestroy(mm->heap);
if(mm->map)
- buffer_unmap(mm->buffer);
+ pb_unmap(mm->buffer);
if(mm)
free(mm);
return NULL;
}
-struct buffer_manager *
-mm_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2)
{
- struct pipe_buffer *buffer;
- struct buffer_manager *mgr;
+ struct pb_buffer *buffer;
+ struct pb_manager *mgr;
assert(provider);
assert(provider->create_buffer);
@@ -278,7 +270,7 @@ mm_bufmgr_create(struct buffer_manager *provider,
mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
if (!mgr) {
- buffer_release(buffer);
+ pb_destroy(buffer);
return NULL;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
index e6a8c78668e..7e8494f615f 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
@@ -55,9 +55,9 @@
#define SUPER(__derived) (&(__derived)->base)
-struct pool_buffer_manager
+struct pool_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
_glthread_Mutex mutex;
@@ -68,26 +68,26 @@ struct pool_buffer_manager
struct list_head free;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
void *map;
struct pool_buffer *bufs;
};
-static inline struct pool_buffer_manager *
-pool_buffer_manager(struct buffer_manager *mgr)
+static inline struct pool_pb_manager *
+pool_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct pool_buffer_manager *)mgr;
+ return (struct pool_pb_manager *)mgr;
}
struct pool_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct pool_buffer_manager *mgr;
+ struct pool_pb_manager *mgr;
struct list_head head;
@@ -96,25 +96,19 @@ struct pool_buffer
static inline struct pool_buffer *
-pool_buffer(struct pipe_buffer *buf)
+pool_buffer(struct pb_buffer *buf)
{
assert(buf);
return (struct pool_buffer *)buf;
}
-static void
-pool_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
static void
-pool_buffer_release(struct pipe_buffer *buf)
+pool_buffer_destroy(struct pb_buffer *buf)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
+ struct pool_pb_manager *pool = pool_buf->mgr;
_glthread_LOCK_MUTEX(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
@@ -124,10 +118,10 @@ pool_buffer_release(struct pipe_buffer *buf)
static void *
-pool_buffer_map(struct pipe_buffer *buf, unsigned flags)
+pool_buffer_map(struct pb_buffer *buf, unsigned flags)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
+ struct pool_pb_manager *pool = pool_buf->mgr;
void *map;
_glthread_LOCK_MUTEX(pool->mutex);
@@ -138,38 +132,37 @@ pool_buffer_map(struct pipe_buffer *buf, unsigned flags)
static void
-pool_buffer_unmap(struct pipe_buffer *buf)
+pool_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-pool_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+pool_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
- buffer_get_base_buffer(pool->buffer, base_buf, offset);
+ struct pool_pb_manager *pool = pool_buf->mgr;
+ pb_get_base_buffer(pool->buffer, base_buf, offset);
*offset += pool_buf->start;
}
-static const struct pipe_buffer_vtbl
+static const struct pb_vtbl
pool_buffer_vtbl = {
- pool_buffer_reference,
- pool_buffer_release,
+ pool_buffer_destroy,
pool_buffer_map,
pool_buffer_unmap,
pool_buffer_get_base_buffer
};
-static struct pipe_buffer *
-pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+static struct pb_buffer *
+pool_bufmgr_create_buffer(struct pb_manager *mgr, size_t size)
{
- struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ struct pool_pb_manager *pool = pool_pb_manager(mgr);
struct pool_buffer *pool_buf;
struct list_head *item;
@@ -201,15 +194,15 @@ pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
static void
-pool_bufmgr_destroy(struct buffer_manager *mgr)
+pool_bufmgr_destroy(struct pb_manager *mgr)
{
- struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ struct pool_pb_manager *pool = pool_pb_manager(mgr);
_glthread_LOCK_MUTEX(pool->mutex);
free(pool->bufs);
- buffer_unmap(pool->buffer);
- buffer_release(pool->buffer);
+ pb_unmap(pool->buffer);
+ pb_destroy(pool->buffer);
_glthread_UNLOCK_MUTEX(pool->mutex);
@@ -217,16 +210,16 @@ pool_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-pool_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+pool_bufmgr_create(struct pb_manager *provider,
size_t numBufs,
size_t bufSize)
{
- struct pool_buffer_manager *pool;
+ struct pool_pb_manager *pool;
struct pool_buffer *pool_buf;
int i;
- pool = (struct pool_buffer_manager *)calloc(1, sizeof(*pool));
+ pool = (struct pool_pb_manager *)calloc(1, sizeof(*pool));
if (!pool)
return NULL;
@@ -245,7 +238,7 @@ pool_bufmgr_create(struct buffer_manager *provider,
if (!pool->buffer)
goto failure;
- pool->map = buffer_map(pool->buffer,
+ pool->map = pb_map(pool->buffer,
PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
if(!pool->map)
@@ -270,9 +263,9 @@ failure:
if(pool->bufs)
free(pool->bufs);
if(pool->map)
- buffer_unmap(pool->buffer);
+ pb_unmap(pool->buffer);
if(pool->buffer)
- buffer_release(pool->buffer);
+ pb_destroy(pool->buffer);
if(pool)
free(pool);
return NULL;
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 8dadd9aa74b..cea6b90104f 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -135,7 +135,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < Elements(softpipe->constants); i++) {
if (softpipe->constants[i].buffer) {
- ws->buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
+ pipe_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
}
}
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index 8ee9177e5bd..423c91d4b8e 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -88,7 +88,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
*/
boolean
softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index bac7b0876f6..af955c1e17b 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -157,7 +157,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
unsigned start, unsigned count);
boolean softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer_handle *indexBuffer,
+ struct pipe_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
index 945c93411fc..1430be7869a 100644
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ b/src/mesa/pipe/softpipe/sp_state_fs.c
@@ -30,6 +30,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "pipe/draw/draw_context.h"
#include "pipe/p_shader_tokens.h"
@@ -165,9 +166,9 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
assert(index == 0);
/* note: reference counting */
- ws->buffer_reference(ws,
- &softpipe->constants[shader].buffer,
- buf->buffer);
+ pipe_buffer_reference(ws,
+ &softpipe->constants[shader].buffer,
+ buf->buffer);
softpipe->constants[shader].size = buf->size;
softpipe->dirty |= SP_NEW_CONSTANTS;
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index 23e9c1b376f..172234843d8 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -121,7 +121,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
FREE(spt);
}
@@ -144,7 +144,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
diff --git a/src/mesa/pipe/softpipe/sp_texture.h b/src/mesa/pipe/softpipe/sp_texture.h
index 0494bf365b6..c6cf370351d 100644
--- a/src/mesa/pipe/softpipe/sp_texture.h
+++ b/src/mesa/pipe/softpipe/sp_texture.h
@@ -41,7 +41,7 @@ struct softpipe_texture
/* The data is held here:
*/
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
unsigned long buffer_size;
};
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index cb043ef394c..c3cd22eea3f 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -40,6 +40,7 @@
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/softpipe/sp_winsys.h"
#ifdef GALLIUM_CELL
@@ -57,9 +58,8 @@
*/
struct xm_buffer
{
+ struct pipe_buffer base;
boolean userBuffer; /** Is this a user-space buffer? */
- int refcount;
- unsigned size;
void *data;
void *mapped;
};
@@ -106,63 +106,44 @@ xmesa_softpipe_winsys(struct softpipe_winsys *spws)
* buffer pointer...
*/
static INLINE struct xm_buffer *
-xm_bo( struct pipe_buffer_handle *bo )
+xm_buffer( struct pipe_buffer *buf )
{
- return (struct xm_buffer *) bo;
+ return (struct xm_buffer *)buf;
}
-static INLINE struct pipe_buffer_handle *
-pipe_bo( struct xm_buffer *bo )
-{
- return (struct pipe_buffer_handle *) bo;
-}
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *
-xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned flags)
{
- struct xm_buffer *xm_buf = xm_bo(buf);
+ struct xm_buffer *xm_buf = xm_buffer(buf);
xm_buf->mapped = xm_buf->data;
return xm_buf->mapped;
}
static void
-xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
+xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
{
- struct xm_buffer *xm_buf = xm_bo(buf);
+ struct xm_buffer *xm_buf = xm_buffer(buf);
xm_buf->mapped = NULL;
}
static void
-xm_buffer_reference(struct pipe_winsys *pws,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+xm_buffer_destroy(struct pipe_winsys *pws,
+ struct pipe_buffer *buf)
{
- if (*ptr) {
- struct xm_buffer *oldBuf = xm_bo(*ptr);
- oldBuf->refcount--;
- assert(oldBuf->refcount >= 0);
- if (oldBuf->refcount == 0) {
- if (oldBuf->data) {
- if (!oldBuf->userBuffer)
- align_free(oldBuf->data);
- oldBuf->data = NULL;
- }
- free(oldBuf);
- }
- *ptr = NULL;
- }
+ struct xm_buffer *oldBuf = xm_buffer(buf);
- assert(!(*ptr));
-
- if (buf) {
- struct xm_buffer *newBuf = xm_bo(buf);
- newBuf->refcount++;
- *ptr = buf;
+ if (oldBuf->data) {
+ if (!oldBuf->userBuffer)
+ align_free(oldBuf->data);
+ oldBuf->data = NULL;
}
+
+ free(oldBuf);
}
@@ -174,7 +155,7 @@ static void
xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
{
XImage *ximage = b->tempImage;
- struct xm_buffer *xm_buf = xm_bo(surf->buffer);
+ struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
uint x, y;
@@ -214,7 +195,7 @@ void
xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
{
XImage *ximage = b->tempImage;
- struct xm_buffer *xm_buf = xm_bo(surf->buffer);
+ struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
const struct xmesa_surface *xm_surf
= xmesa_surface((struct pipe_surface *) surf);
@@ -272,35 +253,38 @@ xm_get_name(struct pipe_winsys *pws)
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_buffer_create(struct pipe_winsys *pws,
unsigned alignment,
unsigned usage,
unsigned size)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->refcount = 1;
+ buffer->base.refcount = 1;
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
/* align to 16-byte multiple for Cell */
buffer->data = align_malloc(size, max(alignment, 16));
- buffer->size = size;
- return pipe_bo(buffer);
+ return &buffer->base;
}
/**
* Create buffer which wraps user-space data.
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+ buffer->base.refcount = 1;
+ buffer->base.size = bytes;
buffer->userBuffer = TRUE;
- buffer->refcount = 1;
buffer->data = ptr;
- buffer->size = bytes;
- return pipe_bo(buffer);
+
+ return &buffer->base;
}
@@ -376,7 +360,7 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -407,7 +391,7 @@ xmesa_get_pipe_winsys_aub(void)
ws->user_buffer_create = xm_user_buffer_create;
ws->buffer_map = xm_buffer_map;
ws->buffer_unmap = xm_buffer_unmap;
- ws->buffer_reference = xm_buffer_reference;
+ ws->buffer_destroy = xm_buffer_destroy;
ws->surface_alloc = xm_surface_alloc;
ws->surface_alloc_storage = xm_surface_alloc_storage;
diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c
index 28dd07bc6e9..bf415702570 100644
--- a/src/mesa/pipe/xlib/xm_winsys_aub.c
+++ b/src/mesa/pipe/xlib/xm_winsys_aub.c
@@ -38,6 +38,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/i965simple/brw_winsys.h"
#include "brw_aub.h"
#include "xm_winsys_aub.h"
@@ -79,22 +80,22 @@ aub_pipe_winsys( struct pipe_winsys *winsys )
static INLINE struct aub_buffer *
-aub_bo( struct pipe_buffer_handle *bo )
+aub_bo( struct pipe_buffer *bo )
{
return (struct aub_buffer *)bo;
}
-static INLINE struct pipe_buffer_handle *
+static INLINE struct pipe_buffer *
pipe_bo( struct aub_buffer *bo )
{
- return (struct pipe_buffer_handle *)bo;
+ return (struct pipe_buffer *)bo;
}
static void *aub_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned flags )
{
struct aub_buffer *sbo = aub_bo(buf);
@@ -109,7 +110,7 @@ static void *aub_buffer_map(struct pipe_winsys *winsys,
}
static void aub_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf)
+ struct pipe_buffer *buf)
{
struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
struct aub_buffer *sbo = aub_bo(buf);
@@ -132,26 +133,15 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys,
static void
-aub_buffer_reference(struct pipe_winsys *winsys,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+aub_buffer_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf)
{
- if (*ptr) {
- assert(aub_bo(*ptr)->refcount != 0);
- if (--(aub_bo(*ptr)->refcount) == 0)
- free(*ptr);
- *ptr = NULL;
- }
-
- if (buf) {
- aub_bo(buf)->refcount++;
- *ptr = buf;
- }
+ free(buf);
}
void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned long offset,
unsigned long size,
const void *data,
@@ -206,7 +196,7 @@ void xmesa_display_aub( /* struct pipe_winsys *winsys, */
/* Pipe has no concept of pools. We choose the tex/region pool
* for all buffers.
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
aub_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
unsigned usage,
@@ -231,7 +221,7 @@ aub_buffer_create(struct pipe_winsys *winsys,
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
struct aub_buffer *sbo;
@@ -312,7 +302,7 @@ aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -351,7 +341,7 @@ xmesa_create_pipe_winsys_aub( void )
iws->winsys.user_buffer_create = aub_user_buffer_create;
iws->winsys.buffer_map = aub_buffer_map;
iws->winsys.buffer_unmap = aub_buffer_unmap;
- iws->winsys.buffer_reference = aub_buffer_reference;
+ iws->winsys.buffer_destroy = aub_buffer_destroy;
iws->winsys.flush_frontbuffer = aub_flush_frontbuffer;
iws->winsys.printf = aub_printf;
iws->winsys.get_name = aub_get_name;
@@ -439,7 +429,7 @@ static void aub_i965_batch_dword( struct brw_winsys *sws,
}
static void aub_i965_batch_reloc( struct brw_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta )
{
@@ -450,7 +440,7 @@ static void aub_i965_batch_reloc( struct brw_winsys *sws,
}
static unsigned aub_i965_get_buffer_offset( struct brw_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags )
{
return aub_bo(buf)->offset;
@@ -482,7 +472,7 @@ static void aub_i965_batch_flush( struct brw_winsys *sws,
static void aub_i965_buffer_subdata_typed(struct brw_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned long offset,
unsigned long size,
const void *data,
diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.h b/src/mesa/pipe/xlib/xm_winsys_aub.h
index c0fe449107e..7bee1991169 100644
--- a/src/mesa/pipe/xlib/xm_winsys_aub.h
+++ b/src/mesa/pipe/xlib/xm_winsys_aub.h
@@ -30,7 +30,7 @@
struct pipe_context;
struct pipe_winsys;
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct pipe_surface;
struct pipe_winsys *
@@ -47,7 +47,7 @@ xmesa_create_i965simple( struct pipe_winsys *winsys );
void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned long offset,
unsigned long size,
const void *data,
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index c9d63136b5f..21416da2e01 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -37,6 +37,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "st_context.h"
#include "st_atom.h"
@@ -70,7 +71,7 @@ void st_upload_constants( struct st_context *st,
_mesa_load_state_parameters(st->ctx, params);
if (cbuf->buffer && cbuf->size != paramBytes)
- ws->buffer_reference( ws, &cbuf->buffer, NULL );
+ pipe_buffer_reference( ws, &cbuf->buffer, NULL );
if (!cbuf->buffer) {
cbuf->buffer = ws->buffer_create(ws, 1, PIPE_BUFFER_USAGE_CONSTANT,
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 60bd1d5f0d2..fa1254ff7ca 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -36,6 +36,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
@@ -78,7 +79,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
struct st_buffer_object *st_obj = st_buffer_object(obj);
if (st_obj->buffer)
- pipe->winsys->buffer_reference(pipe->winsys, &st_obj->buffer, NULL);
+ pipe_buffer_reference(pipe->winsys, &st_obj->buffer, NULL);
free(st_obj);
}
@@ -173,7 +174,7 @@ st_bufferobj_data(GLcontext *ctx,
buffer_usage = 0;
}
- pipe->winsys->buffer_reference( pipe->winsys, &st_obj->buffer, NULL );
+ pipe_buffer_reference( pipe->winsys, &st_obj->buffer, NULL );
st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage,
size );
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index 15003ae15d6..dcbb5a52336 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -30,7 +30,7 @@
struct st_context;
struct gl_buffer_object;
-struct pipe_buffer_handle;
+struct pipe_buffer;
/**
* State_tracker vertex/pixel buffer object, derived from Mesa's
@@ -39,7 +39,7 @@ struct pipe_buffer_handle;
struct st_buffer_object
{
struct gl_buffer_object Base;
- struct pipe_buffer_handle *buffer;
+ struct pipe_buffer *buffer;
GLsizeiptrARB size;
};
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index f02cb3d1336..43416232670 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -100,8 +100,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
if (strb->surface->buffer)
- pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer,
- NULL);
+ pipe_buffer_reference(pipe->winsys, &strb->surface->buffer,
+ NULL);
/* Determine surface format here */
if (strb->format != PIPE_FORMAT_NONE) {
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 668ac139f72..9c206c057a0 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -52,6 +52,7 @@
#include "st_program.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "pipe/draw/draw_context.h"
#include "pipe/cso_cache/cso_cache.h"
@@ -152,7 +153,7 @@ static void st_destroy_context_priv( struct st_context *st )
for (i = 0; i < Elements(st->state.constants); i++) {
if (st->state.constants[i].buffer) {
- ws->buffer_reference(ws, &st->state.constants[i].buffer, NULL);
+ pipe_buffer_reference(ws, &st->state.constants[i].buffer, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 371d4e7966b..8ef50ee7684 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -45,6 +45,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "pipe/draw/draw_private.h"
#include "pipe/draw/draw_context.h"
@@ -237,7 +238,7 @@ st_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffer[attr].buffer = NULL;
- winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
assert(velement.src_offset <= 2048); /* 11-bit field */
@@ -282,7 +283,7 @@ st_draw_vbo(GLcontext *ctx,
if (ib) {
/* indexed primitive */
struct gl_buffer_object *bufobj = ib->obj;
- struct pipe_buffer_handle *indexBuf = NULL;
+ struct pipe_buffer *indexBuf = NULL;
unsigned indexSize, indexOffset, i;
switch (ib->type) {
@@ -303,7 +304,7 @@ st_draw_vbo(GLcontext *ctx,
if (bufobj && bufobj->Name) {
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- winsys->buffer_reference(winsys, &indexBuf, stobj->buffer);
+ pipe_buffer_reference(winsys, &indexBuf, stobj->buffer);
indexOffset = (unsigned) ib->ptr / indexSize;
}
else {
@@ -321,7 +322,7 @@ st_draw_vbo(GLcontext *ctx,
prims[i].start + indexOffset, prims[i].count);
}
- winsys->buffer_reference(winsys, &indexBuf, NULL);
+ pipe_buffer_reference(winsys, &indexBuf, NULL);
}
else {
/* non-indexed */
@@ -333,7 +334,7 @@ st_draw_vbo(GLcontext *ctx,
/* unreference buffers (frees wrapped user-space buffer objects) */
for (attr = 0; attr < vs->num_inputs; attr++) {
- winsys->buffer_reference(winsys, &vbuffer[attr].buffer, NULL);
+ pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]);
}
@@ -358,7 +359,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
const float height = ctx->DrawBuffer->Height;
const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float);
struct pipe_context *pipe = ctx->st->pipe;
- struct pipe_buffer_handle *vbuf;
+ struct pipe_buffer *vbuf;
struct pipe_vertex_buffer vbuffer;
struct pipe_vertex_element velement;
unsigned i;
@@ -404,7 +405,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
pipe->draw_arrays(pipe, prim, 0, numVertex);
/* XXX: do one-time */
- pipe->winsys->buffer_reference(pipe->winsys, &vbuf, NULL);
+ pipe_buffer_reference(pipe->winsys, &vbuf, NULL);
}
@@ -465,7 +466,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
struct pipe_winsys *winsys = pipe->winsys;
const struct st_vertex_program *vp;
const struct pipe_shader_state *vs;
- struct pipe_buffer_handle *index_buffer_handle = 0;
+ struct pipe_buffer *index_buffer_handle = 0;
struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
GLuint attr, i;
ubyte *mapped_constants;
@@ -513,7 +514,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffer[attr].buffer = NULL;
- winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
@@ -605,7 +606,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
if (draw->vertex_buffer[i].buffer) {
pipe->winsys->buffer_unmap(pipe->winsys,
draw->vertex_buffer[i].buffer);
- winsys->buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL);
+ pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}