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