diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2008-01-28 18:32:46 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-01-28 18:32:46 +1100 |
commit | 3e39bc3d87a82d81ffaf383303ada32e530b879e (patch) | |
tree | 530249743415875917c0ebbf53eaf92d7901bd2d /src/mesa/drivers | |
parent | a556034514582dc8e1b8b65f56020031d513331b (diff) |
nouveau: quicky-port to gallium changes
Diffstat (limited to 'src/mesa/drivers')
8 files changed, 76 insertions, 140 deletions
diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.c index 9c524fa001..01fada5b89 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.c @@ -73,6 +73,7 @@ nouveau_context_create(const __GLcontextModes *glVis, */ { struct pipe_surface *fb_surf; + struct nouveau_pipe_buffer *fb_buf; struct nouveau_bo_priv *fb_bo; fb_bo = calloc(1, sizeof(struct nouveau_bo_priv)); @@ -87,12 +88,15 @@ nouveau_context_create(const __GLcontextModes *glVis, fb_bo->base.size = fb_bo->drm.size; fb_bo->base.device = nv_screen->device; + fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer)); + fb_buf->bo = &fb_bo->base; + fb_surf = calloc(1, sizeof(struct pipe_surface)); fb_surf->cpp = nv_screen->front_cpp; fb_surf->pitch = nv_screen->front_pitch / fb_surf->cpp; fb_surf->height = nv_screen->front_height; fb_surf->refcount = 1; - fb_surf->buffer = (void *)fb_bo; + fb_surf->buffer = &fb_buf->base; nv->frontbuffer = fb_surf; } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.h b/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.h index 2fd3336065..7a74f7deec 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_context.h @@ -54,9 +54,6 @@ struct nouveau_context { void (*surface_copy_done)(struct nouveau_context *); int (*surface_fill)(struct nouveau_context *, struct pipe_surface *, unsigned, unsigned, unsigned, unsigned, unsigned); - int (*surface_data)(struct nouveau_context *, struct pipe_surface *, - unsigned, unsigned, const void *, unsigned, - unsigned, unsigned, unsigned, unsigned); }; extern GLboolean nouveau_context_create(const __GLcontextModes *, diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_local.h b/src/mesa/drivers/dri/nouveau_winsys/nouveau_local.h index a53b699202..7a539c81a9 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_local.h +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_local.h @@ -60,9 +60,9 @@ OUT_RING (nv->o->handle); \ } while(0) -#define OUT_RELOC(bo,data,flags,vor,tor) do { \ - nouveau_pushbuf_emit_reloc(nv->channel, nv->channel->pushbuf->cur, \ - (void*)(bo), (data), (flags), (vor), (tor));\ +#define OUT_RELOC(buf,data,flags,vor,tor) do { \ + nouveau_pipe_emit_reloc(nv->channel, nv->channel->pushbuf->cur, \ + buf, (data), (flags), (vor), (tor)); \ OUT_RING(0); \ } while(0) diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c index f5e4546100..ddf3cba5f0 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c @@ -59,16 +59,13 @@ nouveau_pipe_surface_fill(struct nouveau_winsys *nvws, struct pipe_surface *dst, return 0; } -static int -nouveau_pipe_surface_data(struct nouveau_winsys *nvws, struct pipe_surface *dst, - unsigned dx, unsigned dy, const void *src, - unsigned src_pitch, unsigned sx, unsigned sy, - unsigned w, unsigned h) +int +nouveau_pipe_emit_reloc(struct nouveau_channel *chan, void *ptr, + struct pipe_buffer *buf, uint32_t data, + uint32_t flags, uint32_t vor, uint32_t tor) { - if (nvws->nv->surface_data(nvws->nv, dst, dx, dy, src, src_pitch, sx, - sy, w, h)) - return 1; - return 0; + return nouveau_pushbuf_emit_reloc(chan, ptr, nouveau_buffer(buf)->bo, + data, flags, vor, tor); } struct pipe_context * @@ -102,7 +99,7 @@ nouveau_pipe_create(struct nouveau_context *nv) nvws->res_alloc = nouveau_resource_alloc; nvws->res_free = nouveau_resource_free; - nvws->push_reloc = nouveau_pushbuf_emit_reloc; + nvws->push_reloc = nouveau_pipe_emit_reloc; nvws->push_flush = nouveau_pushbuf_flush; nvws->grobj_alloc = nouveau_pipe_grobj_alloc; @@ -117,7 +114,6 @@ nouveau_pipe_create(struct nouveau_context *nv) nvws->surface_copy = nouveau_pipe_surface_copy; nvws->surface_fill = nouveau_pipe_surface_fill; - nvws->surface_data = nouveau_pipe_surface_data; return hw_create(nouveau_create_pipe_winsys(nv), nvws, nv->chipset); } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c index 1e160f04ed..f2087aaf9a 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c @@ -1,6 +1,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "nouveau_context.h" #include "nouveau_device.h" @@ -54,7 +55,6 @@ nouveau_surface_alloc_storage(struct pipe_winsys *ws, struct pipe_surface *surf, enum pipe_format format, unsigned flags) { unsigned pitch = ((width * pf_get_size(format)) + 63) & ~63; - int ret; surf->format = format; surf->width = width; @@ -62,16 +62,11 @@ nouveau_surface_alloc_storage(struct pipe_winsys *ws, struct pipe_surface *surf, surf->cpp = pf_get_size(format); surf->pitch = pitch / surf->cpp; - surf->buffer = ws->buffer_create(ws, 256, 0, 0); + surf->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL, + pitch * height); if (!surf->buffer) return 1; - ret = ws->buffer_data(ws, surf->buffer, pitch * height, NULL, 0); - if (ret) { - ws->buffer_reference(ws, &surf->buffer, NULL); - return ret; - } - return 0; } @@ -83,131 +78,87 @@ nouveau_surface_release(struct pipe_winsys *ws, struct pipe_surface **s) *s = NULL; if (--surf->refcount <= 0) { if (surf->buffer) - ws->buffer_reference(ws, &surf->buffer, NULL); + pipe_buffer_reference(ws, &surf->buffer, NULL); free(surf); } } -static struct pipe_buffer_handle * +static struct pipe_buffer * nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment, - unsigned flags, unsigned hint) + unsigned usage, unsigned size) { struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws; struct nouveau_device *dev = nvpws->nv->nv_screen->device; - struct nouveau_bo *nvbo = NULL; + struct nouveau_pipe_buffer *nvbuf; + + nvbuf = calloc(1, sizeof(*nvbuf)); + if (!nvbuf) + return NULL; + nvbuf->base.refcount = 1; + nvbuf->base.alignment = alignment; + nvbuf->base.usage = usage; + nvbuf->base.size = size; - if (nouveau_bo_new(dev, NOUVEAU_BO_LOCAL, alignment, 0, &nvbo)) + if (nouveau_bo_new(dev, NOUVEAU_BO_LOCAL, alignment, size, &nvbuf->bo)) { + free(nvbuf); return NULL; - return (struct pipe_buffer_handle *)nvbo; + } + + return &nvbuf->base; } -static struct pipe_buffer_handle * +static struct pipe_buffer * nouveau_pipe_bo_user_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) { struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws; struct nouveau_device *dev = nvpws->nv->nv_screen->device; - struct nouveau_bo *nvbo = NULL; + struct nouveau_pipe_buffer *nvbuf; - if (nouveau_bo_user(dev, ptr, bytes, &nvbo)) + nvbuf = calloc(1, sizeof(*nvbuf)); + if (!nvbuf) return NULL; - return (struct pipe_buffer_handle *)nvbo; -} - -static void * -nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer_handle *bo, - unsigned flags) -{ - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo; - uint32_t map_flags = 0; + nvbuf->base.refcount = 1; + nvbuf->base.size = bytes; - if (flags & PIPE_BUFFER_FLAG_READ) - map_flags |= NOUVEAU_BO_RD; - if (flags & PIPE_BUFFER_FLAG_WRITE) - map_flags |= NOUVEAU_BO_WR; - - if (nouveau_bo_map(nvbo, map_flags)) + if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) { + free(nvbuf); return NULL; - return nvbo->map; -} - -static void -nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *bo) -{ - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo; - - nouveau_bo_unmap(nvbo); -} - -static void -nouveau_pipe_bo_reference(struct pipe_winsys *pws, - struct pipe_buffer_handle **ptr, - struct pipe_buffer_handle *bo) -{ - struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws; - struct nouveau_context *nv = nvpws->nv; - struct nouveau_device *dev = nv->nv_screen->device; - - if (*ptr) { - struct nouveau_bo *nvbo = (struct nouveau_bo *)*ptr; - FIRE_RING(); - nouveau_bo_del(&nvbo); - *ptr = NULL; } - if (bo) { - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo, *new = NULL; - nouveau_bo_ref(dev, nvbo->handle, &new); - *ptr = bo; - } + return &nvbuf->base; } -static int -nouveau_pipe_bo_data(struct pipe_winsys *pws, struct pipe_buffer_handle *bo, - unsigned size, const void *data, unsigned usage) +static void +nouveau_pipe_bo_del(struct pipe_winsys *ws, struct pipe_buffer *buf) { - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo; - - if (nvbo->size != size) - nouveau_bo_resize(nvbo, size); + struct nouveau_pipe_buffer *nvbuf = nouveau_buffer(buf); - if (data) { - if (nouveau_bo_map(nvbo, NOUVEAU_BO_WR)) - return 1; - memcpy(nvbo->map, data, size); - nouveau_bo_unmap(nvbo); - } - - return 0; + nouveau_bo_del(&nvbuf->bo); } -static int -nouveau_pipe_bo_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *bo, - unsigned long offset, unsigned long size, - const void *data) +static void * +nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf, + unsigned flags) { - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo; + struct nouveau_pipe_buffer *nvbuf = nouveau_buffer(buf); + uint32_t map_flags = 0; - if (nouveau_bo_map(nvbo, NOUVEAU_BO_WR)) - return 1; - memcpy(nvbo->map + offset, data, size); - nouveau_bo_unmap(nvbo); + if (flags & PIPE_BUFFER_USAGE_CPU_READ) + map_flags |= NOUVEAU_BO_RD; + if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) + map_flags |= NOUVEAU_BO_WR; - return 0; + if (nouveau_bo_map(nvbuf->bo, map_flags)) + return NULL; + return nvbuf->bo->map; } -static int -nouveau_pipe_bo_get_subdata(struct pipe_winsys *pws, - struct pipe_buffer_handle *bo, unsigned long offset, - unsigned long size, void *data) +static void +nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) { - struct nouveau_bo *nvbo = (struct nouveau_bo *)bo; + struct nouveau_pipe_buffer *nvbuf = nouveau_buffer(buf); - if (nouveau_bo_map(nvbo, NOUVEAU_BO_RD)) - return 1; - memcpy(data, nvbo->map + offset, size); - nouveau_bo_unmap(nvbo); - - return 0; + nouveau_bo_unmap(nvbuf->bo); } struct pipe_winsys * @@ -230,13 +181,10 @@ nouveau_create_pipe_winsys(struct nouveau_context *nv) pws->surface_release = nouveau_surface_release; pws->buffer_create = nouveau_pipe_bo_create; + pws->buffer_destroy = nouveau_pipe_bo_del; pws->user_buffer_create = nouveau_pipe_bo_user_create; pws->buffer_map = nouveau_pipe_bo_map; pws->buffer_unmap = nouveau_pipe_bo_unmap; - pws->buffer_reference = nouveau_pipe_bo_reference; - pws->buffer_data = nouveau_pipe_bo_data; - pws->buffer_subdata = nouveau_pipe_bo_subdata; - pws->buffer_get_subdata= nouveau_pipe_bo_get_subdata; pws->get_name = nouveau_get_name; diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.h b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.h index bcac60851c..6a03ac0d77 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.h +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.h @@ -5,6 +5,17 @@ #include "pipe/p_winsys.h" #include "nouveau_context.h" +struct nouveau_pipe_buffer { + struct pipe_buffer base; + struct nouveau_bo *bo; +}; + +static inline struct nouveau_pipe_buffer * +nouveau_buffer(struct pipe_buffer *buf) +{ + return (struct nouveau_pipe_buffer *)buf; +} + struct nouveau_pipe_winsys { struct pipe_winsys pws; diff --git a/src/mesa/drivers/dri/nouveau_winsys/nv04_surface.c b/src/mesa/drivers/dri/nouveau_winsys/nv04_surface.c index 2288f9c71a..fe1ea4ed70 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nv04_surface.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nv04_surface.c @@ -159,15 +159,6 @@ nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst, return 0; } -static int -nv04_surface_data(struct nouveau_context *nv, struct pipe_surface *dst, - unsigned dx, unsigned dy, const void *src, unsigned src_pitch, - unsigned sx, unsigned sy, unsigned w, unsigned h) -{ - NOUVEAU_ERR("unimplemented!!\n"); - return 0; -} - int nouveau_surface_init_nv04(struct nouveau_context *nv) { @@ -230,7 +221,6 @@ nouveau_surface_init_nv04(struct nouveau_context *nv) nv->surface_copy = nv04_surface_copy_blit; nv->surface_copy_done = nv04_surface_copy_done; nv->surface_fill = nv04_surface_fill; - nv->surface_data = nv04_surface_data; return 0; } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nv50_surface.c b/src/mesa/drivers/dri/nouveau_winsys/nv50_surface.c index d00378d904..15a1002861 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nv50_surface.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nv50_surface.c @@ -133,15 +133,6 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst, return 0; } -static int -nv50_surface_data(struct nouveau_context *nv, struct pipe_surface *dst, - unsigned dx, unsigned dy, const void *src, unsigned src_pitch, - unsigned sx, unsigned sy, unsigned w, unsigned h) -{ - NOUVEAU_ERR("unimplemented!!\n"); - return 0; -} - int nouveau_surface_init_nv50(struct nouveau_context *nv) { @@ -164,7 +155,6 @@ nouveau_surface_init_nv50(struct nouveau_context *nv) nv->surface_copy = nv50_surface_copy; nv->surface_copy_done = nv50_surface_copy_done; nv->surface_fill = nv50_surface_fill; - nv->surface_data = nv50_surface_data; return 0; } |