1 /**********************************************************
2 * Copyright 2009 VMware, Inc. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 **********************************************************/
28 * Common definitions for the VMware SVGA winsys.
30 * @author Jose Fonseca <jfonseca@vmware.com>
38 #include "pipe/p_compiler.h"
39 #include "pipe/p_state.h"
41 #include "svga_winsys.h"
42 #include "pipebuffer/pb_buffer_fenced.h"
45 #define VMW_GMR_POOL_SIZE (16*1024*1024)
46 #define VMW_QUERY_POOL_SIZE (8192)
47 #define VMW_DEBUG_FLUSH_STACK 10
50 * Something big, but arbitrary. The kernel reports an error if it can't
51 * handle this, and the svga driver will resort to multiple partial
54 #define VMW_MAX_BUFFER_SIZE (512*1024*1024)
61 SVGA3dDevCapResult result
;
64 struct vmw_winsys_screen
66 struct svga_winsys_screen base
;
68 boolean use_old_scanout_flag
;
74 struct vmw_cap_3d
*cap_3d
;
75 uint64_t max_mob_memory
;
76 uint64_t max_surface_memory
;
77 uint64_t max_texture_size
;
82 struct pb_manager
*gmr
;
83 struct pb_manager
*gmr_mm
;
84 struct pb_manager
*gmr_fenced
;
85 struct pb_manager
*gmr_slab
;
86 struct pb_manager
*gmr_slab_fenced
;
87 struct pb_manager
*query_mm
;
88 struct pb_manager
*query_fenced
;
89 struct pb_manager
*mob_fenced
;
90 struct pb_manager
*mob_cache
;
91 struct pb_manager
*mob_shader_slab
;
92 struct pb_manager
*mob_shader_slab_fenced
;
95 struct pb_fence_ops
*fence_ops
;
105 static INLINE
struct vmw_winsys_screen
*
106 vmw_winsys_screen(struct svga_winsys_screen
*base
)
108 return (struct vmw_winsys_screen
*)base
;
113 vmw_region_size(struct vmw_region
*region
);
116 vmw_ioctl_context_create(struct vmw_winsys_screen
*vws
);
119 vmw_ioctl_context_destroy(struct vmw_winsys_screen
*vws
,
123 vmw_ioctl_surface_create(struct vmw_winsys_screen
*vws
,
124 SVGA3dSurfaceFlags flags
,
125 SVGA3dSurfaceFormat format
,
129 uint32 numMipLevels
);
131 vmw_ioctl_gb_surface_create(struct vmw_winsys_screen
*vws
,
132 SVGA3dSurfaceFlags flags
,
133 SVGA3dSurfaceFormat format
,
138 uint32 buffer_handle
,
139 struct vmw_region
**p_region
);
142 vmw_ioctl_gb_surface_ref(struct vmw_winsys_screen
*vws
,
143 const struct winsys_handle
*whandle
,
144 SVGA3dSurfaceFlags
*flags
,
145 SVGA3dSurfaceFormat
*format
,
146 uint32_t *numMipLevels
,
148 struct vmw_region
**p_region
);
151 vmw_ioctl_surface_destroy(struct vmw_winsys_screen
*vws
,
155 vmw_ioctl_command(struct vmw_winsys_screen
*vws
,
157 uint32_t throttle_us
,
160 struct pipe_fence_handle
**fence
);
163 vmw_ioctl_region_create(struct vmw_winsys_screen
*vws
, uint32_t size
);
166 vmw_ioctl_region_destroy(struct vmw_region
*region
);
169 vmw_ioctl_region_ptr(struct vmw_region
*region
);
172 vmw_ioctl_region_map(struct vmw_region
*region
);
174 vmw_ioctl_region_unmap(struct vmw_region
*region
);
178 vmw_ioctl_fence_finish(struct vmw_winsys_screen
*vws
,
179 uint32_t handle
, uint32_t flags
);
182 vmw_ioctl_fence_signalled(struct vmw_winsys_screen
*vws
,
183 uint32_t handle
, uint32_t flags
);
186 vmw_ioctl_fence_unref(struct vmw_winsys_screen
*vws
,
190 vmw_ioctl_shader_create(struct vmw_winsys_screen
*vws
,
191 SVGA3dShaderType type
,
194 vmw_ioctl_shader_destroy(struct vmw_winsys_screen
*vws
, uint32 shid
);
197 vmw_ioctl_syncforcpu(struct vmw_region
*region
,
202 vmw_ioctl_releasefromcpu(struct vmw_region
*region
,
205 /* Initialize parts of vmw_winsys_screen at startup:
207 boolean
vmw_ioctl_init(struct vmw_winsys_screen
*vws
);
208 boolean
vmw_pools_init(struct vmw_winsys_screen
*vws
);
209 boolean
vmw_query_pools_init(struct vmw_winsys_screen
*vws
);
210 boolean
vmw_mob_pools_init(struct vmw_winsys_screen
*vws
);
211 boolean
vmw_winsys_screen_init_svga(struct vmw_winsys_screen
*vws
);
213 void vmw_ioctl_cleanup(struct vmw_winsys_screen
*vws
);
214 void vmw_pools_cleanup(struct vmw_winsys_screen
*vws
);
216 struct vmw_winsys_screen
*vmw_winsys_create(int fd
, boolean use_old_scanout_flag
);
217 void vmw_winsys_destroy(struct vmw_winsys_screen
*sws
);
218 void vmw_winsys_screen_set_throttling(struct pipe_screen
*screen
,
219 uint32_t throttle_us
);
222 simple_fenced_bufmgr_create(struct pb_manager
*provider
,
223 struct pb_fence_ops
*ops
);
225 vmw_fences_signal(struct pb_fence_ops
*fence_ops
,
228 boolean has_emitted
);
230 #endif /* VMW_SCREEN_H_ */