winsys/amdgpu: add a new winsys for the new kernel driver
[mesa.git] / src / gallium / winsys / amdgpu / drm / amdgpu_bo.h
1 /*
2 * Copyright © 2008 Jérôme Glisse
3 * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
4 * Copyright © 2015 Advanced Micro Devices, Inc.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
19 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * The above copyright notice and this permission notice (including the
25 * next paragraph) shall be included in all copies or substantial portions
26 * of the Software.
27 */
28 /*
29 * Authors:
30 * Marek Olšák <maraeo@gmail.com>
31 */
32
33 #ifndef AMDGPU_BO_H
34 #define AMDGPU_BO_H
35
36 #include "amdgpu_winsys.h"
37 #include "pipebuffer/pb_bufmgr.h"
38
39 struct amdgpu_bo_desc {
40 struct pb_desc base;
41
42 enum radeon_bo_domain initial_domain;
43 unsigned flags;
44 };
45
46 struct amdgpu_winsys_bo {
47 struct pb_buffer base;
48
49 struct amdgpu_winsys *rws;
50 void *user_ptr; /* from buffer_from_ptr */
51
52 amdgpu_bo_handle bo;
53 uint32_t unique_id;
54 amdgpu_va_handle va_handle;
55 uint64_t va;
56 enum radeon_bo_domain initial_domain;
57
58 /* how many command streams is this bo referenced in? */
59 int num_cs_references;
60
61 /* whether buffer_get_handle or buffer_from_handle was called,
62 * it can only transition from false to true
63 */
64 volatile int is_shared; /* bool (int for atomicity) */
65
66 /* Fences for buffer synchronization. */
67 struct pipe_fence_handle *fence[RING_LAST];
68 };
69
70 struct pb_manager *amdgpu_bomgr_create(struct amdgpu_winsys *rws);
71 void amdgpu_bomgr_init_functions(struct amdgpu_winsys *ws);
72
73 static inline
74 void amdgpu_winsys_bo_reference(struct amdgpu_winsys_bo **dst,
75 struct amdgpu_winsys_bo *src)
76 {
77 pb_reference((struct pb_buffer**)dst, (struct pb_buffer*)src);
78 }
79
80 #endif