diff options
Diffstat (limited to 'src/gallium/drivers/noop/noop_pipe.c')
-rw-r--r-- | src/gallium/drivers/noop/noop_pipe.c | 136 |
1 files changed, 45 insertions, 91 deletions
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c index fb5cdb4..3680f46 100644 --- a/src/gallium/drivers/noop/noop_pipe.c +++ b/src/gallium/drivers/noop/noop_pipe.c @@ -30,10 +30,16 @@ #include <util/u_inlines.h> #include <util/u_format.h> #include "noop_public.h" -#include "state_tracker/sw_winsys.h" + +DEBUG_GET_ONCE_BOOL_OPTION(noop, "GALLIUM_NOOP", FALSE) void noop_init_state_functions(struct pipe_context *ctx); +struct noop_pipe_screen { + struct pipe_screen pscreen; + struct pipe_screen *oscreen; +}; + /* * query */ @@ -83,7 +89,7 @@ struct noop_resource { static unsigned noop_is_resource_referenced(struct pipe_context *pipe, struct pipe_resource *resource, - unsigned face, unsigned level) + unsigned level, int layer) { return PIPE_UNREFERENCED; } @@ -108,52 +114,29 @@ static struct pipe_resource *noop_resource_create(struct pipe_screen *screen, FREE(nresource); return NULL; } -#if 0 - if (nresource->base.bind & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { - struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys; - unsigned stride; - - nresource->dt = winsys->displaytarget_create(winsys, nresource->base.bind, - nresource->base.format, - nresource->base.width0, - nresource->base.height0, - 16, &stride); - } -#endif return &nresource->base; } -static struct pipe_resource *noop_resource_from_handle(struct pipe_screen * screen, +static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *screen, const struct pipe_resource *templ, - struct winsys_handle *whandle) + struct winsys_handle *handle) { - struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys; - struct noop_resource *nresource; - struct sw_displaytarget *dt; - unsigned stride; + struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)screen; + struct pipe_screen *oscreen = noop_screen->oscreen; + struct pipe_resource *result; + struct pipe_resource *noop_resource; - dt = winsys->displaytarget_from_handle(winsys, templ, whandle, &stride); - if (dt == NULL) { - return NULL; - } - nresource = (struct noop_resource *)noop_resource_create(screen, templ); - nresource->dt = dt; - return &nresource->base; + result = oscreen->resource_from_handle(oscreen, templ, handle); + noop_resource = noop_resource_create(screen, result); + pipe_resource_reference(&result, NULL); + return noop_resource; } static boolean noop_resource_get_handle(struct pipe_screen *screen, struct pipe_resource *resource, struct winsys_handle *handle) { - struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys; - struct noop_resource *nresource = (struct noop_resource *)resource; - - if (nresource->dt == NULL) - return FALSE; - - return winsys->displaytarget_get_handle(winsys, nresource->dt, handle); + return FALSE; } static void noop_resource_destroy(struct pipe_screen *screen, @@ -161,11 +144,6 @@ static void noop_resource_destroy(struct pipe_screen *screen, { struct noop_resource *nresource = (struct noop_resource *)resource; - if (nresource->dt) { - /* display target */ - struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys; - winsys->displaytarget_destroy(winsys, nresource->dt); - } free(nresource->data); FREE(resource); } @@ -193,7 +171,7 @@ static struct pipe_resource *noop_user_buffer_create(struct pipe_screen *screen, */ static struct pipe_transfer *noop_get_transfer(struct pipe_context *context, struct pipe_resource *resource, - struct pipe_subresource sr, + unsigned level, enum pipe_transfer_usage usage, const struct pipe_box *box) { @@ -203,11 +181,11 @@ static struct pipe_transfer *noop_get_transfer(struct pipe_context *context, if (transfer == NULL) return NULL; pipe_resource_reference(&transfer->resource, resource); - transfer->sr = sr; + transfer->level = level; transfer->usage = usage; transfer->box = *box; transfer->stride = 1; - transfer->slice_stride = 1; + transfer->layer_stride = 1; return transfer; } @@ -239,12 +217,12 @@ static void noop_transfer_destroy(struct pipe_context *pipe, static void noop_transfer_inline_write(struct pipe_context *pipe, struct pipe_resource *resource, - struct pipe_subresource sr, + unsigned level, unsigned usage, const struct pipe_box *box, const void *data, unsigned stride, - unsigned slice_stride) + unsigned layer_stride) { } @@ -277,12 +255,11 @@ static void noop_clear_depth_stencil(struct pipe_context *ctx, static void noop_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, - struct pipe_subresource subdst, + unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, - struct pipe_subresource subsrc, - unsigned srcx, unsigned srcy, unsigned srcz, - unsigned width, unsigned height) + unsigned src_level, + const struct pipe_box *src_box) { } @@ -332,46 +309,14 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen, void return ctx; } -/* - * texture - */ -static struct pipe_surface *noop_get_tex_surface(struct pipe_screen *screen, - struct pipe_resource *texture, - unsigned face, unsigned level, - unsigned zslice, unsigned flags) -{ - struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface); - - if (surface == NULL) - return NULL; - pipe_reference_init(&surface->reference, 1); - pipe_resource_reference(&surface->texture, texture); - surface->format = texture->format; - surface->width = texture->width0; - surface->height = texture->height0; - surface->offset = 0; - surface->usage = flags; - surface->zslice = zslice; - surface->texture = texture; - surface->face = face; - surface->level = level; - - return surface; -} - -static void noop_tex_surface_destroy(struct pipe_surface *surface) -{ - pipe_resource_reference(&surface->texture, NULL); - FREE(surface); -} - /* * pipe_screen */ static void noop_flush_frontbuffer(struct pipe_screen *_screen, - struct pipe_surface *surface, - void *context_private) + struct pipe_resource *resource, + unsigned level, unsigned layer, + void *context_private) { } @@ -516,19 +461,30 @@ static boolean noop_is_format_supported(struct pipe_screen* screen, static void noop_destroy_screen(struct pipe_screen *screen) { + struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)screen; + struct pipe_screen *oscreen = noop_screen->oscreen; + + oscreen->destroy(oscreen); FREE(screen); } -struct pipe_screen *noop_screen_create(struct sw_winsys *winsys) +struct pipe_screen *noop_screen_create(struct pipe_screen *oscreen) { + struct noop_pipe_screen *noop_screen; struct pipe_screen *screen; - screen = CALLOC_STRUCT(pipe_screen); - if (screen == NULL) { + if (!debug_get_option_noop()) { + return oscreen; + } + + noop_screen = CALLOC_STRUCT(noop_pipe_screen); + if (noop_screen == NULL) { return NULL; } + noop_screen->oscreen = oscreen; + screen = &noop_screen->pscreen; - screen->winsys = (struct pipe_winsys*)winsys; + screen->winsys = oscreen->winsys; screen->destroy = noop_destroy_screen; screen->get_name = noop_get_name; screen->get_vendor = noop_get_vendor; @@ -537,8 +493,6 @@ struct pipe_screen *noop_screen_create(struct sw_winsys *winsys) screen->get_paramf = noop_get_paramf; screen->is_format_supported = noop_is_format_supported; screen->context_create = noop_create_context; - screen->get_tex_surface = noop_get_tex_surface; - screen->tex_surface_destroy = noop_tex_surface_destroy; screen->resource_create = noop_resource_create; screen->resource_from_handle = noop_resource_from_handle; screen->resource_get_handle = noop_resource_get_handle; |