gallium: use new buffer wrapper functions in p_inlines.h

This allows us to remove most of the direct references to winsys in the state tracker.
This commit is contained in:
Brian Paul 2008-04-30 10:43:59 -06:00
parent 15318c8d8e
commit 99fba5466b
10 changed files with 62 additions and 89 deletions

View File

@ -36,7 +36,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
#include "st_context.h"
@ -54,7 +53,7 @@ void st_upload_constants( struct st_context *st,
struct gl_program_parameter_list *params,
unsigned id)
{
struct pipe_winsys *ws = st->pipe->winsys;
struct pipe_context *pipe = st->pipe;
struct pipe_constant_buffer *cbuf = &st->state.constants[id];
assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT);
@ -74,8 +73,8 @@ void st_upload_constants( struct st_context *st,
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
pipe_buffer_reference( ws, &cbuf->buffer, NULL );
cbuf->buffer = ws->buffer_create( ws, 1, PIPE_BUFFER_USAGE_CONSTANT,
pipe_reference_buffer(pipe, &cbuf->buffer, NULL );
cbuf->buffer = pipe_buffer_create(pipe, 1, PIPE_BUFFER_USAGE_CONSTANT,
paramBytes );
if (0)
@ -87,9 +86,10 @@ void st_upload_constants( struct st_context *st,
/* load Mesa constants into the constant buffer */
if (cbuf->buffer) {
memcpy(ws->buffer_map(ws, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
params->ParameterValues, paramBytes);
ws->buffer_unmap(ws, cbuf->buffer);
void *map = pipe_buffer_map(pipe, cbuf->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map, params->ParameterValues, paramBytes);
pipe_buffer_unmap(pipe, cbuf->buffer);
}
cbuf->size = paramBytes;

View File

@ -50,7 +50,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "util/p_tile.h"
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
@ -372,9 +371,8 @@ setup_bitmap_vertex_data(struct st_context *st,
void *buf;
if (!st->bitmap.vbuf) {
st->bitmap.vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->bitmap.vertices));
st->bitmap.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->bitmap.vertices));
}
/* Positions are in clip coords since we need to do clipping in case
@ -413,10 +411,9 @@ setup_bitmap_vertex_data(struct st_context *st,
}
/* put vertex data into vbuf */
buf = pipe->winsys->buffer_map(pipe->winsys, st->bitmap.vbuf,
PIPE_BUFFER_USAGE_CPU_WRITE);
buf = pipe_buffer_map(pipe, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices));
pipe->winsys->buffer_unmap(pipe->winsys, st->bitmap.vbuf);
pipe_buffer_unmap(pipe, st->bitmap.vbuf);
}
@ -761,7 +758,7 @@ st_destroy_bitmap(struct st_context *st)
}
if (st->bitmap.vbuf) {
pipe->winsys->buffer_destroy(pipe->winsys, st->bitmap.vbuf);
pipe_buffer_destroy(pipe, st->bitmap.vbuf);
st->bitmap.vbuf = NULL;
}

View File

@ -35,7 +35,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
@ -79,7 +78,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_buffer_reference(pipe->winsys, &st_obj->buffer, NULL);
pipe_reference_buffer(pipe, &st_obj->buffer, NULL);
free(st_obj);
}
@ -106,10 +105,9 @@ st_bufferobj_subdata(GLcontext *ctx,
if (offset >= st_obj->size || size > (st_obj->size - offset))
return;
map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE);
map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map + offset, data, size);
pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer);
pipe_buffer_unmap(pipe, st_obj->buffer);
}
@ -130,10 +128,9 @@ st_bufferobj_get_subdata(GLcontext *ctx,
if (offset >= st_obj->size || size > (st_obj->size - offset))
return;
map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer,
PIPE_BUFFER_USAGE_CPU_READ);
map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
memcpy(data, map + offset, size);
pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer);
pipe_buffer_unmap(pipe, st_obj->buffer);
}
@ -174,10 +171,9 @@ st_bufferobj_data(GLcontext *ctx,
buffer_usage = 0;
}
pipe_buffer_reference( pipe->winsys, &st_obj->buffer, NULL );
pipe_reference_buffer( pipe, &st_obj->buffer, NULL );
st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage,
size );
st_obj->buffer = pipe_buffer_create( pipe, 32, buffer_usage, size );
st_obj->size = size;
@ -211,7 +207,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
break;
}
obj->Pointer = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, flags);
obj->Pointer = pipe_buffer_map(pipe, st_obj->buffer, flags);
return obj->Pointer;
}
@ -225,7 +221,7 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer);
pipe_buffer_unmap(pipe, st_obj->buffer);
obj->Pointer = NULL;
return GL_TRUE;
}

View File

@ -45,9 +45,9 @@
#include "st_mesa_to_tgsi.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "util/u_pack_color.h"
#include "util/u_simple_shaders.h"
#include "util/u_draw_quad.h"
@ -106,7 +106,7 @@ st_destroy_clear(struct st_context *st)
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
pipe->winsys->buffer_destroy(pipe->winsys, st->clear.vbuf);
pipe_buffer_destroy(pipe, st->clear.vbuf);
st->clear.vbuf = NULL;
}
}
@ -142,9 +142,8 @@ draw_quad(GLcontext *ctx,
void *buf;
if (!st->clear.vbuf) {
st->clear.vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->clear.vertices));
st->clear.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->clear.vertices));
}
/* positions */
@ -171,10 +170,9 @@ draw_quad(GLcontext *ctx,
}
/* put vertex data into vbuf */
buf = pipe->winsys->buffer_map(pipe->winsys, st->clear.vbuf,
PIPE_BUFFER_USAGE_CPU_WRITE);
buf = pipe_buffer_map(pipe, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, st->clear.vertices, sizeof(st->clear.vertices));
pipe->winsys->buffer_unmap(pipe->winsys, st->clear.vbuf);
pipe_buffer_unmap(pipe, st->clear.vbuf);
/* draw */
util_draw_vertex_buffer(pipe, st->clear.vbuf,

View File

@ -55,7 +55,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "util/p_tile.h"
#include "util/u_draw_quad.h"
#include "shader/prog_instruction.h"
@ -483,20 +482,18 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
ubyte *map;
/* allocate/load buffer object with vertex data */
buf = pipe->winsys->buffer_create(pipe->winsys, 32,
PIPE_BUFFER_USAGE_VERTEX,
sizeof(verts));
map = pipe->winsys->buffer_map(pipe->winsys, buf,
PIPE_BUFFER_USAGE_CPU_WRITE);
buf = pipe_buffer_create(pipe,32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(verts));
map = pipe_buffer_map(pipe, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map, verts, sizeof(verts));
pipe->winsys->buffer_unmap(pipe->winsys, buf);
pipe_buffer_unmap(pipe, buf);
util_draw_vertex_buffer(pipe, buf,
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
pipe->winsys->buffer_destroy(pipe->winsys, buf);
pipe_buffer_destroy(pipe, buf);
}
}

View File

@ -105,7 +105,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
else if (strb->surface->buffer) {
/* release/discard the old surface buffer */
pipe_buffer_reference(pipe->winsys, &strb->surface->buffer, NULL);
pipe_reference_buffer(pipe, &strb->surface->buffer, NULL);
}
/* Determine surface format here */

View File

@ -55,7 +55,6 @@
#include "st_gen_mipmap.h"
#include "st_program.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
#include "cso_cache/cso_cache.h"
@ -157,7 +156,6 @@ struct st_context *st_create_context(struct pipe_context *pipe,
static void st_destroy_context_priv( struct st_context *st )
{
struct pipe_winsys *ws = st->pipe->winsys;
uint i;
draw_destroy(st->draw);
@ -172,7 +170,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) {
pipe_buffer_reference(ws, &st->state.constants[i].buffer, NULL);
pipe_reference_buffer(st->pipe, &st->state.constants[i].buffer, NULL);
}
}

View File

@ -43,7 +43,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
#include "draw/draw_private.h"
@ -219,8 +218,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
if (!vec)
return NULL;
map = pipe->winsys->buffer_map(pipe->winsys, stobj->buffer,
PIPE_BUFFER_USAGE_CPU_READ);
map = pipe_buffer_map(pipe, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
map = ADD_POINTERS(map, array->Ptr);
for (i = 0; i < count; i++) {
@ -230,7 +228,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
map += array->StrideB;
}
pipe->winsys->buffer_unmap(pipe->winsys, stobj->buffer);
pipe_buffer_unmap(pipe, stobj->buffer);
pipe->set_edgeflags(pipe, vec);
@ -260,7 +258,6 @@ st_draw_vbo(GLcontext *ctx,
GLuint max_index)
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_winsys *winsys = pipe->winsys;
const struct st_vertex_program *vp;
const struct pipe_shader_state *vs;
struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
@ -292,7 +289,7 @@ st_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffer[attr].buffer = NULL;
pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer);
pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
assert(velements[attr].src_offset <= 2048); /* 11-bit field */
@ -310,9 +307,8 @@ st_draw_vbo(GLcontext *ctx,
/* wrap user data */
vbuffer[attr].buffer
= winsys->user_buffer_create(winsys,
(void *) arrays[mesaAttr]->Ptr,
bytes);
= pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr,
bytes);
vbuffer[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
}
@ -358,14 +354,13 @@ 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);
pipe_buffer_reference(winsys, &indexBuf, stobj->buffer);
pipe_reference_buffer(pipe, &indexBuf, stobj->buffer);
indexOffset = (unsigned) ib->ptr / indexSize;
}
else {
/* element/indicies are in user space memory */
indexBuf = winsys->user_buffer_create(winsys,
(void *) ib->ptr,
ib->count * indexSize);
indexBuf = pipe_user_buffer_create(pipe, (void *) ib->ptr,
ib->count * indexSize);
indexOffset = 0;
}
@ -380,7 +375,7 @@ st_draw_vbo(GLcontext *ctx,
prims[i].start + indexOffset, prims[i].count);
}
pipe_buffer_reference(winsys, &indexBuf, NULL);
pipe_reference_buffer(pipe, &indexBuf, NULL);
}
else {
/* non-indexed */
@ -396,7 +391,7 @@ st_draw_vbo(GLcontext *ctx,
/* unreference buffers (frees wrapped user-space buffer objects) */
for (attr = 0; attr < vp->num_inputs; attr++) {
pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL);
pipe_reference_buffer(pipe, &vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer);
@ -458,7 +453,6 @@ st_feedback_draw_vbo(GLcontext *ctx,
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
struct draw_context *draw = st->draw;
struct pipe_winsys *winsys = pipe->winsys;
const struct st_vertex_program *vp;
const struct pipe_shader_state *vs;
struct pipe_buffer *index_buffer_handle = 0;
@ -509,7 +503,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffers[attr].buffer = NULL;
pipe_buffer_reference(winsys, &vbuffers[attr].buffer, stobj->buffer);
pipe_reference_buffer(pipe, &vbuffers[attr].buffer, stobj->buffer);
vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
@ -521,9 +515,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* wrap user data */
vbuffers[attr].buffer
= winsys->user_buffer_create(winsys,
(void *) arrays[mesaAttr]->Ptr,
bytes);
= pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr,
bytes);
vbuffers[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
}
@ -544,9 +537,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
#endif
/* map the attrib buffer */
map = pipe->winsys->buffer_map(pipe->winsys,
vbuffers[attr].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, attr, map);
}
@ -572,9 +564,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
return;
}
map = pipe->winsys->buffer_map(pipe->winsys,
index_buffer_handle,
PIPE_BUFFER_USAGE_CPU_READ);
map = pipe_buffer_map(pipe, index_buffer_handle,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, map);
}
else {
@ -584,7 +575,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map constant buffers */
mapped_constants = winsys->buffer_map(winsys,
mapped_constants = pipe_buffer_map(pipe,
st->state.constants[PIPE_SHADER_VERTEX].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_constant_buffer(st->draw, mapped_constants);
@ -597,21 +588,20 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* unmap constant buffers */
winsys->buffer_unmap(winsys, st->state.constants[PIPE_SHADER_VERTEX].buffer);
pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX].buffer);
/*
* unmap vertex/index buffers
*/
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
if (draw->pt.vertex_buffer[i].buffer) {
pipe->winsys->buffer_unmap(pipe->winsys,
draw->pt.vertex_buffer[i].buffer);
pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL);
pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer);
pipe_reference_buffer(pipe, &draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}
if (ib) {
pipe->winsys->buffer_unmap(pipe->winsys, index_buffer_handle);
pipe_buffer_unmap(pipe, index_buffer_handle);
draw_set_mapped_element_buffer(draw, 0, NULL);
}
}

View File

@ -36,7 +36,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "util/u_gen_mipmap.h"
#include "cso_cache/cso_cache.h"
@ -105,7 +104,6 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_winsys *ws = pipe->winsys;
struct pipe_texture *pt = st_get_texobj_texture(texObj);
const uint baseLevel = texObj->BaseLevel;
const uint lastLevel = pt->last_level;
@ -128,11 +126,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice);
dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice);
srcData = (ubyte *) ws->buffer_map(ws, srcSurf->buffer,
PIPE_BUFFER_USAGE_CPU_READ)
srcData = (ubyte *) pipe_buffer_map(pipe, srcSurf->buffer,
PIPE_BUFFER_USAGE_CPU_READ)
+ srcSurf->offset;
dstData = (ubyte *) ws->buffer_map(ws, dstSurf->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE)
dstData = (ubyte *) pipe_buffer_map(pipe, dstSurf->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstSurf->offset;
_mesa_generate_mipmap_level(target, datatype, comps,
@ -144,8 +142,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
dstSurf->pitch * dstSurf->cpp, /* stride in bytes */
dstData);
ws->buffer_unmap(ws, srcSurf->buffer);
ws->buffer_unmap(ws, dstSurf->buffer);
pipe_buffer_unmap(pipe, srcSurf->buffer);
pipe_buffer_unmap(pipe, dstSurf->buffer);
pipe_surface_reference(&srcSurf, NULL);
pipe_surface_reference(&dstSurf, NULL);

View File

@ -38,7 +38,6 @@
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#define DBG if(0) printf