summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nvfx/nvfx_buffer.c
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-08-03 22:49:19 +0200
committerLuca Barbieri <[email protected]>2010-08-21 20:42:14 +0200
commit4e2080a86e0cbb93c72bbf4acace53867fac8276 (patch)
tree86acc1f76c4a552af7bcd0d3f1d93d88bfffbfb4 /src/gallium/drivers/nvfx/nvfx_buffer.c
parent0481ed25c9c35178bf5151c80f4c36ad42b75648 (diff)
nvfx: new 2D: unify textures and buffers
Stop using the vtbl, and use real transfers for buffers too.
Diffstat (limited to 'src/gallium/drivers/nvfx/nvfx_buffer.c')
-rw-r--r--src/gallium/drivers/nvfx/nvfx_buffer.c77
1 files changed, 2 insertions, 75 deletions
diff --git a/src/gallium/drivers/nvfx/nvfx_buffer.c b/src/gallium/drivers/nvfx/nvfx_buffer.c
index 4482d9683ed..44680e51959 100644
--- a/src/gallium/drivers/nvfx/nvfx_buffer.c
+++ b/src/gallium/drivers/nvfx/nvfx_buffer.c
@@ -7,13 +7,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nvfx_resource.h"
-
-/* Currently using separate implementations for buffers and textures,
- * even though gallium has a unified abstraction of these objects.
- * Eventually these should be combined, and mechanisms like transfers
- * be adapted to work for both buffer and texture uploads.
- */
-static void nvfx_buffer_destroy(struct pipe_screen *pscreen,
+void nvfx_buffer_destroy(struct pipe_screen *pscreen,
struct pipe_resource *presource)
{
struct nvfx_resource *buffer = nvfx_resource(presource);
@@ -22,70 +16,6 @@ static void nvfx_buffer_destroy(struct pipe_screen *pscreen,
FREE(buffer);
}
-
-
-
-/* Utility functions for transfer create/destroy are hooked in and
- * just record the arguments to those functions.
- */
-static void *
-nvfx_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
- uint8_t *map;
-
- map = nouveau_screen_bo_map_range( pipe->screen,
- buffer->bo,
- transfer->box.x,
- transfer->box.width,
- nouveau_screen_transfer_flags(transfer->usage) );
- if (map == NULL)
- return NULL;
-
- return map + transfer->box.x;
-}
-
-
-
-static void nvfx_buffer_transfer_flush_region( struct pipe_context *pipe,
- struct pipe_transfer *transfer,
- const struct pipe_box *box)
-{
- struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
-
- nouveau_screen_bo_map_flush_range(pipe->screen,
- buffer->bo,
- transfer->box.x + box->x,
- box->width);
-}
-
-static void nvfx_buffer_transfer_unmap( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
-
- nouveau_screen_bo_unmap(pipe->screen, buffer->bo);
-}
-
-
-
-
-struct u_resource_vtbl nvfx_buffer_vtbl =
-{
- u_default_resource_get_handle, /* get_handle */
- nvfx_buffer_destroy, /* resource_destroy */
- NULL, /* is_resource_referenced */
- u_default_get_transfer, /* get_transfer */
- u_default_transfer_destroy, /* transfer_destroy */
- nvfx_buffer_transfer_map, /* transfer_map */
- nvfx_buffer_transfer_flush_region, /* transfer_flush_region */
- nvfx_buffer_transfer_unmap, /* transfer_unmap */
- u_default_transfer_inline_write /* transfer_inline_write */
-};
-
-
-
struct pipe_resource *
nvfx_buffer_create(struct pipe_screen *pscreen,
const struct pipe_resource *template)
@@ -98,7 +28,6 @@ nvfx_buffer_create(struct pipe_screen *pscreen,
buffer->base = *template;
buffer->base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
- buffer->vtbl = &nvfx_buffer_vtbl;
pipe_reference_init(&buffer->base.reference, 1);
buffer->base.screen = pscreen;
@@ -132,7 +61,6 @@ nvfx_user_buffer_create(struct pipe_screen *pscreen,
return NULL;
pipe_reference_init(&buffer->base.reference, 1);
- buffer->vtbl = &nvfx_buffer_vtbl;
buffer->base.flags = NVFX_RESOURCE_FLAG_LINEAR;
buffer->base.screen = pscreen;
buffer->base.format = PIPE_FORMAT_R8_UNORM;
@@ -145,11 +73,10 @@ nvfx_user_buffer_create(struct pipe_screen *pscreen,
buffer->bo = nouveau_screen_bo_user(pscreen, ptr, bytes);
if (!buffer->bo)
goto fail;
-
+
return &buffer->base;
fail:
FREE(buffer);
return NULL;
}
-