2 #include "pipe/p_context.h"
3 #include "nv50_resource.h"
4 #include "nouveau/nouveau_screen.h"
7 /* This doesn't look quite right - this query is supposed to ask
8 * whether the particular context has references to the resource in
9 * any unflushed rendering command buffer, and hence requires a
10 * pipe->flush() for serializing some modification to that resource.
12 * This seems to be answering the question of whether the resource is
13 * currently on hardware.
16 nv50_resource_is_referenced(struct pipe_context *pipe,
17 struct pipe_resource *resource,
18 unsigned face, unsigned level)
20 return nouveau_reference_flags(nv50_resource(resource)->bo);
23 static struct pipe_resource *
24 nv50_resource_create(struct pipe_screen *screen,
25 const struct pipe_resource *template)
27 if (template->target == PIPE_BUFFER)
28 return nv50_buffer_create(screen, template);
30 return nv50_miptree_create(screen, template);
33 static struct pipe_resource *
34 nv50_resource_from_handle(struct pipe_screen * screen,
35 const struct pipe_resource *template,
36 struct winsys_handle *whandle)
38 if (template->target == PIPE_BUFFER)
41 return nv50_miptree_from_handle(screen, template, whandle);
45 nv50_init_resource_functions(struct pipe_context *pcontext)
47 pcontext->get_transfer = u_get_transfer_vtbl;
48 pcontext->transfer_map = u_transfer_map_vtbl;
49 pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
50 pcontext->transfer_unmap = u_transfer_unmap_vtbl;
51 pcontext->transfer_destroy = u_transfer_destroy_vtbl;
52 pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
53 pcontext->is_resource_referenced = nv50_resource_is_referenced;
57 nv50_screen_init_resource_functions(struct pipe_screen *pscreen)
59 pscreen->resource_create = nv50_resource_create;
60 pscreen->resource_from_handle = nv50_resource_from_handle;
61 pscreen->resource_get_handle = u_resource_get_handle_vtbl;
62 pscreen->resource_destroy = u_resource_destroy_vtbl;
63 pscreen->user_buffer_create = nv50_user_buffer_create;
65 pscreen->get_tex_surface = nv50_miptree_surface_new;
66 pscreen->tex_surface_destroy = nv50_miptree_surface_del;