• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "util/u_debug.h"
2 
3 #include "i915_resource.h"
4 #include "i915_context.h"
5 #include "i915_screen.h"
6 
7 
8 static struct pipe_resource *
i915_resource_create(struct pipe_screen * screen,const struct pipe_resource * template)9 i915_resource_create(struct pipe_screen *screen,
10                      const struct pipe_resource *template)
11 {
12    if (template->target == PIPE_BUFFER)
13       return i915_buffer_create(screen, template);
14    else
15    {
16       if (!(template->bind & PIPE_BIND_LINEAR))
17          return i915_texture_create(screen, template, FALSE);
18       else
19          return i915_texture_create(screen, template, TRUE);
20    }
21 }
22 
23 static struct pipe_resource *
i915_resource_from_handle(struct pipe_screen * screen,const struct pipe_resource * template,struct winsys_handle * whandle,unsigned usage)24 i915_resource_from_handle(struct pipe_screen * screen,
25 			 const struct pipe_resource *template,
26 			 struct winsys_handle *whandle,
27                           unsigned usage)
28 {
29    if (template->target == PIPE_BUFFER)
30       return NULL;
31    else
32       return i915_texture_from_handle(screen, template, whandle);
33 }
34 
35 
36 void
i915_init_resource_functions(struct i915_context * i915)37 i915_init_resource_functions(struct i915_context *i915 )
38 {
39    i915->base.transfer_map = u_transfer_map_vtbl;
40    i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
41    i915->base.transfer_unmap = u_transfer_unmap_vtbl;
42    i915->base.buffer_subdata = i915_buffer_subdata;
43    i915->base.texture_subdata = u_default_texture_subdata;
44 }
45 
46 void
i915_init_screen_resource_functions(struct i915_screen * is)47 i915_init_screen_resource_functions(struct i915_screen *is)
48 {
49    is->base.resource_create = i915_resource_create;
50    is->base.resource_from_handle = i915_resource_from_handle;
51    is->base.resource_get_handle = u_resource_get_handle_vtbl;
52    is->base.resource_destroy = u_resource_destroy_vtbl;
53 }
54