1287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_debug.h"
2287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
3287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_resource.h"
4287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_context.h"
5287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_screen.h"
6287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
7287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
8287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstatic struct pipe_resource *
9287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_resource_create(struct pipe_screen *screen,
101a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin                     const struct pipe_resource *template)
11287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{
12287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   if (template->target == PIPE_BUFFER)
13287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell      return i915_buffer_create(screen, template);
14287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   else
151a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin      return i915_texture_create(screen, template, FALSE);
16287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
17287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}
18287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
19287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstatic struct pipe_resource *
20287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_resource_from_handle(struct pipe_screen * screen,
21287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell			 const struct pipe_resource *template,
22287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell			 struct winsys_handle *whandle)
23287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{
24287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   if (template->target == PIPE_BUFFER)
25287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell      return NULL;
26287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   else
27287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell      return i915_texture_from_handle(screen, template, whandle);
28287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}
29287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
30287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
31287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid
32287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_init_resource_functions(struct i915_context *i915 )
33287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{
34287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.get_transfer = u_get_transfer_vtbl;
35287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.transfer_map = u_transfer_map_vtbl;
36287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
37287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.transfer_unmap = u_transfer_unmap_vtbl;
38287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.transfer_destroy = u_transfer_destroy_vtbl;
39287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   i915->base.transfer_inline_write = u_transfer_inline_write_vtbl;
40287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}
41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell
42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid
43287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_init_screen_resource_functions(struct i915_screen *is)
44287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{
45287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   is->base.resource_create = i915_resource_create;
46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   is->base.resource_from_handle = i915_resource_from_handle;
47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   is->base.resource_get_handle = u_resource_get_handle_vtbl;
48287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell   is->base.resource_destroy = u_resource_destroy_vtbl;
49287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}
50