2 * Copyright (C) 2016 Christian Gmeiner <christian.gmeiner@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Christian Gmeiner <christian.gmeiner@gmail.com>
31 #include "state_tracker/drm_driver.h"
32 #include "pipe/p_state.h"
34 struct renderonly_scanout
{
41 * Create a renderonly_scanout object for scanout resource.
43 * This function creates a renderonly_scanout object based on the provided
44 * resource. The library is designed that the driver specific pipe_resource
45 * struct holds a pointer to a renderonly_scanout struct.
47 * struct driver_resource {
48 * struct pipe_resource base;
49 * struct renderonly_scanout *scanout;
53 * The renderonly_scanout object exits for two reasons:
54 * - Do any special treatment for a scanout resource like importing the GPU
55 * resource into the scanout hw.
56 * - Make it easier for a gallium driver to detect if anything special needs
57 * to be done in flush_resource(..) like a resolve to linear.
59 struct renderonly_scanout
*(*create_for_resource
)(struct pipe_resource
*rsc
,
60 struct renderonly
*ro
,
61 struct winsys_handle
*out_handle
);
67 renderonly_dup(const struct renderonly
*ro
);
69 static inline struct renderonly_scanout
*
70 renderonly_scanout_for_resource(struct pipe_resource
*rsc
,
71 struct renderonly
*ro
,
72 struct winsys_handle
*out_handle
)
74 return ro
->create_for_resource(rsc
, ro
, out_handle
);
78 renderonly_scanout_destroy(struct renderonly_scanout
*scanout
,
79 struct renderonly
*ro
);
82 renderonly_get_handle(struct renderonly_scanout
*scanout
,
83 struct winsys_handle
*handle
)
88 assert(handle
->type
== DRM_API_HANDLE_TYPE_KMS
);
89 handle
->handle
= scanout
->handle
;
90 handle
->stride
= scanout
->stride
;
96 * Create a dumb buffer object for a resource at scanout hw.
98 struct renderonly_scanout
*
99 renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource
*rsc
,
100 struct renderonly
*ro
,
101 struct winsys_handle
*out_handle
);
104 * Import GPU resource into scanout hw.
106 struct renderonly_scanout
*
107 renderonly_create_gpu_import_for_resource(struct pipe_resource
*rsc
,
108 struct renderonly
*ro
,
109 struct winsys_handle
*out_handle
);
111 #endif /* RENDERONLY_H_ */