Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5563 | serge | 1 | |
2 | #include "util/u_inlines.h" |
||
3 | #include "util/u_format.h" |
||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | nv50_resource_create(struct pipe_screen *screen, |
||
11 | const struct pipe_resource *templ) |
||
12 | { |
||
13 | switch (templ->target) { |
||
14 | case PIPE_BUFFER: |
||
15 | return nouveau_buffer_create(screen, templ); |
||
16 | default: |
||
17 | return nv50_miptree_create(screen, templ); |
||
18 | } |
||
19 | } |
||
20 | |||
21 | |||
22 | nv50_resource_from_handle(struct pipe_screen * screen, |
||
23 | const struct pipe_resource *templ, |
||
24 | struct winsys_handle *whandle) |
||
25 | { |
||
26 | if (templ->target == PIPE_BUFFER) |
||
27 | return NULL; |
||
28 | else |
||
29 | return nv50_miptree_from_handle(screen, templ, whandle); |
||
30 | } |
||
31 | |||
32 | |||
33 | nv50_surface_from_buffer(struct pipe_context *pipe, |
||
34 | struct pipe_resource *pbuf, |
||
35 | const struct pipe_surface *templ) |
||
36 | { |
||
37 | struct nv50_surface *sf = CALLOC_STRUCT(nv50_surface); |
||
38 | if (!sf) |
||
39 | return NULL; |
||
40 | |||
41 | |||
42 | pipe_resource_reference(&sf->base.texture, pbuf); |
||
43 | |||
44 | |||
45 | sf->base.writable = templ->writable; |
||
46 | sf->base.u.buf.first_element = templ->u.buf.first_element; |
||
47 | sf->base.u.buf.last_element = templ->u.buf.last_element; |
||
48 | |||
49 | |||
50 | templ->u.buf.first_element * util_format_get_blocksize(sf->base.format); |
||
51 | |||
52 | |||
53 | |||
54 | |||
55 | sf->height = 1; |
||
56 | sf->depth = 1; |
||
57 | |||
58 | |||
59 | sf->base.height = sf->height; |
||
60 | |||
61 | |||
62 | return &sf->base; |
||
63 | } |
||
64 | |||
65 | |||
66 | nv50_surface_create(struct pipe_context *pipe, |
||
67 | struct pipe_resource *pres, |
||
68 | const struct pipe_surface *templ) |
||
69 | { |
||
70 | if (unlikely(pres->target == PIPE_BUFFER)) |
||
71 | return nv50_surface_from_buffer(pipe, pres, templ); |
||
72 | return nv50_miptree_surface_new(pipe, pres, templ); |
||
73 | } |
||
74 | |||
75 | |||
76 | nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps) |
||
77 | { |
||
78 | struct nv50_surface *s = nv50_surface(ps); |
||
79 | |||
80 | |||
81 | |||
82 | |||
83 | } |
||
84 | |||
85 | |||
86 | nv50_init_resource_functions(struct pipe_context *pcontext) |
||
87 | { |
||
88 | pcontext->transfer_map = u_transfer_map_vtbl; |
||
89 | pcontext->transfer_flush_region = u_transfer_flush_region_vtbl; |
||
90 | pcontext->transfer_unmap = u_transfer_unmap_vtbl; |
||
91 | pcontext->transfer_inline_write = u_transfer_inline_write_vtbl; |
||
92 | pcontext->create_surface = nv50_surface_create; |
||
93 | pcontext->surface_destroy = nv50_surface_destroy; |
||
94 | } |
||
95 | |||
96 | |||
97 | nv50_screen_init_resource_functions(struct pipe_screen *pscreen) |
||
98 | { |
||
99 | pscreen->resource_create = nv50_resource_create; |
||
100 | pscreen->resource_from_handle = nv50_resource_from_handle; |
||
101 | pscreen->resource_get_handle = u_resource_get_handle_vtbl; |
||
102 | pscreen->resource_destroy = u_resource_destroy_vtbl; |
||
103 | } |
||
104 |