Home | History | Annotate | Download | only in nv30
      1 /*
      2  * Copyright 2012 Red Hat Inc.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice shall be included in
     12  * all copies or substantial portions of the Software.
     13  *
     14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     17  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     18  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
     19  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     20  * SOFTWARE.
     21  *
     22  * Authors: Ben Skeggs
     23  *
     24  */
     25 
     26 #include "util/u_format.h"
     27 #include "util/u_inlines.h"
     28 
     29 #include "nv30_screen.h"
     30 #include "nv30_context.h"
     31 #include "nv30_resource.h"
     32 #include "nv30_transfer.h"
     33 
     34 static struct pipe_resource *
     35 nv30_resource_create(struct pipe_screen *pscreen,
     36                      const struct pipe_resource *tmpl)
     37 {
     38    switch (tmpl->target) {
     39    case PIPE_BUFFER:
     40       return nouveau_buffer_create(pscreen, tmpl);
     41    default:
     42       return nv30_miptree_create(pscreen, tmpl);
     43    }
     44 }
     45 
     46 static struct pipe_resource *
     47 nv30_resource_from_handle(struct pipe_screen *pscreen,
     48                           const struct pipe_resource *tmpl,
     49                           struct winsys_handle *handle)
     50 {
     51    if (tmpl->target == PIPE_BUFFER)
     52       return NULL;
     53    else
     54       return nv30_miptree_from_handle(pscreen, tmpl, handle);
     55 }
     56 
     57 void
     58 nv30_resource_screen_init(struct pipe_screen *pscreen)
     59 {
     60    pscreen->resource_create = nv30_resource_create;
     61    pscreen->resource_from_handle = nv30_resource_from_handle;
     62    pscreen->resource_get_handle = u_resource_get_handle_vtbl;
     63    pscreen->resource_destroy = u_resource_destroy_vtbl;
     64 }
     65 
     66 void
     67 nv30_resource_init(struct pipe_context *pipe)
     68 {
     69    pipe->get_transfer = u_get_transfer_vtbl;
     70    pipe->transfer_map = u_transfer_map_vtbl;
     71    pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
     72    pipe->transfer_unmap = u_transfer_unmap_vtbl;
     73    pipe->transfer_destroy = u_transfer_destroy_vtbl;
     74    pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
     75    pipe->create_surface = nv30_miptree_surface_new;
     76    pipe->surface_destroy = nv30_miptree_surface_del;
     77    pipe->resource_copy_region = nv30_resource_copy_region;
     78    pipe->resource_resolve = nv30_resource_resolve;
     79 }
     80