1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**********************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2008-2012 VMware, Inc.  All rights reserved.
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * obtaining a copy of this software and associated documentation
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * files (the "Software"), to deal in the Software without
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * restriction, including without limitation the rights to use, copy,
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * modify, merge, publish, distribute, sublicense, and/or sell copies
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software, and to permit persons to whom the Software is
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * furnished to do so, subject to the following conditions:
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * included in all copies or substantial portions of the Software.
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE.
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **********************************************************/
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_debug.h"
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_resource.h"
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_resource_buffer.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_resource_texture.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_context.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_screen.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct pipe_resource *
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_resource_create(struct pipe_screen *screen,
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                     const struct pipe_resource *template)
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (template->target == PIPE_BUFFER)
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return svga_buffer_create(screen, template);
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   else
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return svga_texture_create(screen, template);
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct pipe_resource *
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_resource_from_handle(struct pipe_screen * screen,
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          const struct pipe_resource *template,
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          struct winsys_handle *whandle)
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (template->target == PIPE_BUFFER)
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   else
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return svga_texture_from_handle(screen, template, whandle);
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_init_resource_functions(struct svga_context *svga)
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.get_transfer = u_get_transfer_vtbl;
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.transfer_map = u_transfer_map_vtbl;
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.transfer_flush_region = u_transfer_flush_region_vtbl;
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.transfer_unmap = u_transfer_unmap_vtbl;
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.transfer_destroy = u_transfer_destroy_vtbl;
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   svga->pipe.transfer_inline_write = u_transfer_inline_write_vtbl;
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_init_screen_resource_functions(struct svga_screen *is)
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   is->screen.resource_create = svga_resource_create;
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   is->screen.resource_from_handle = svga_resource_from_handle;
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   is->screen.resource_get_handle = u_resource_get_handle_vtbl;
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   is->screen.resource_destroy = u_resource_destroy_vtbl;
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
77