1 /**********************************************************
2 * Copyright 2008-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 **********************************************************/
30 #include "pipe/p_compiler.h"
31 #include "pipe/p_state.h"
33 #include "util/u_double_list.h"
35 #include "svga_screen_cache.h"
38 #define SVGA_BUFFER_MAGIC 0x344f9005
41 * Maximum number of discontiguous ranges
43 #define SVGA_BUFFER_MAX_RANGES 32
48 struct svga_winsys_buffer
;
49 struct svga_winsys_surface
;
52 struct svga_buffer_range
62 * This holds the information to emit a SVGA3dCmdSurfaceDMA.
64 struct svga_buffer_upload
67 * Guest memory region.
69 struct svga_winsys_buffer
*buf
;
71 struct svga_buffer_range ranges
[SVGA_BUFFER_MAX_RANGES
];
74 SVGA3dSurfaceDMAFlags flags
;
77 * Pointer to the DMA copy box *inside* the command buffer.
82 * Context that has the pending DMA to this buffer.
84 struct svga_context
*svga
;
93 struct pipe_buffer base
;
96 * Marker to detect bad casts in runtime.
101 * Regular (non DMA'able) memory.
103 * Used for user buffers or for buffers which we know before hand that can
104 * never be used by the virtual hardware directly, such as constant buffers.
109 * Whether swbuf was created by the user or not.
116 * A piece of GMR memory. It is created when mapping the buffer, and will be
117 * used to upload/download vertex data from the host.
119 struct svga_buffer_upload hw
;
122 * Creation key for the host surface handle.
124 * This structure describes all the host surface characteristics so that it
125 * can be looked up in cache, since creating a host surface is often a slow
128 struct svga_host_surface_cache_key key
;
131 * Host surface handle.
133 * This is a platform independent abstraction for host SID. We create when
136 struct svga_winsys_surface
*handle
;
141 boolean flush_explicit
;
145 struct list_head head
;
149 static INLINE
struct svga_buffer
*
150 svga_buffer(struct pipe_buffer
*buffer
)
153 assert(((struct svga_buffer
*)buffer
)->magic
== SVGA_BUFFER_MAGIC
);
154 return (struct svga_buffer
*)buffer
;
161 * Returns TRUE for user buffers. We may
162 * decide to use an alternate upload path for these buffers.
164 static INLINE boolean
165 svga_buffer_is_user_buffer( struct pipe_buffer
*buffer
)
167 return svga_buffer(buffer
)->user
;
172 svga_screen_init_buffer_functions(struct pipe_screen
*screen
);
174 struct svga_winsys_surface
*
175 svga_buffer_handle(struct svga_context
*svga
,
176 struct pipe_buffer
*buf
);
179 svga_context_flush_buffers(struct svga_context
*svga
);
181 struct svga_winsys_buffer
*
182 svga_winsys_buffer_create(struct svga_screen
*ss
,
187 #endif /* SVGA_BUFFER_H */