2 #include "pipe/p_context.h"
3 #include "util/u_staging.h"
4 #include "nvfx_resource.h"
5 #include "nouveau/nouveau_screen.h"
8 static struct pipe_resource
*
9 nvfx_resource_create(struct pipe_screen
*screen
,
10 const struct pipe_resource
*template)
12 if (template->target
== PIPE_BUFFER
)
13 return nvfx_buffer_create(screen
, template);
15 return nvfx_miptree_create(screen
, template);
19 nvfx_resource_destroy(struct pipe_screen
*screen
, struct pipe_resource
*pr
)
21 if (pr
->target
== PIPE_BUFFER
)
22 return nvfx_buffer_destroy(screen
, pr
);
24 return nvfx_miptree_destroy(screen
, pr
);
27 static struct pipe_resource
*
28 nvfx_resource_from_handle(struct pipe_screen
* screen
,
29 const struct pipe_resource
*template,
30 struct winsys_handle
*whandle
)
32 if (template->target
== PIPE_BUFFER
)
35 return nvfx_miptree_from_handle(screen
, template, whandle
);
39 nvfx_resource_get_handle(struct pipe_screen
*pscreen
,
40 struct pipe_resource
*pr
,
41 struct winsys_handle
*whandle
)
43 struct nvfx_resource
* res
= (struct nvfx_resource
*)pr
;
48 return nouveau_screen_bo_get_handle(pscreen
, res
->bo
, nvfx_subresource_pitch(pr
, 0), whandle
);
52 nvfx_init_resource_functions(struct pipe_context
*pipe
)
54 pipe
->create_surface
= nvfx_miptree_surface_new
;
55 pipe
->surface_destroy
= nvfx_miptree_surface_del
;
59 nvfx_screen_init_resource_functions(struct pipe_screen
*pscreen
)
61 pscreen
->resource_create
= nvfx_resource_create
;
62 pscreen
->resource_from_handle
= nvfx_resource_from_handle
;
63 pscreen
->resource_get_handle
= nvfx_resource_get_handle
;
64 pscreen
->resource_destroy
= nvfx_resource_destroy
;
65 pscreen
->user_buffer_create
= nvfx_user_buffer_create
;