1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
29 * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
33 #include "sp_context.h"
34 #include "sp_winsys.h"
35 #include "sp_buffer.h"
39 /* Most callbacks map direcly onto winsys operations:
41 static struct pipe_buffer_handle
*
42 sp_create_buffer(struct pipe_context
*pipe
,
46 struct softpipe_context
*sp
= softpipe_context( pipe
);
47 return sp
->winsys
->create_buffer( sp
->winsys
, alignment
);
50 static void *sp_buffer_map(struct pipe_context
*pipe
,
51 struct pipe_buffer_handle
*buf
,
54 struct softpipe_context
*sp
= softpipe_context( pipe
);
55 return sp
->winsys
->buffer_map( sp
->winsys
, buf
);
58 static void sp_buffer_unmap(struct pipe_context
*pipe
,
59 struct pipe_buffer_handle
*buf
)
61 struct softpipe_context
*sp
= softpipe_context( pipe
);
62 sp
->winsys
->buffer_unmap( sp
->winsys
, buf
);
65 static struct pipe_buffer_handle
*
66 sp_buffer_reference(struct pipe_context
*pipe
,
67 struct pipe_buffer_handle
*buf
)
69 struct softpipe_context
*sp
= softpipe_context( pipe
);
70 return sp
->winsys
->buffer_reference( sp
->winsys
, buf
);
73 static void sp_buffer_unreference(struct pipe_context
*pipe
,
74 struct pipe_buffer_handle
**buf
)
76 struct softpipe_context
*sp
= softpipe_context( pipe
);
77 sp
->winsys
->buffer_unreference( sp
->winsys
, buf
);
80 static void sp_buffer_data(struct pipe_context
*pipe
,
81 struct pipe_buffer_handle
*buf
,
82 unsigned size
, const void *data
)
84 struct softpipe_context
*sp
= softpipe_context( pipe
);
85 sp
->winsys
->buffer_data( sp
->winsys
, buf
, size
, data
);
88 static void sp_buffer_subdata(struct pipe_context
*pipe
,
89 struct pipe_buffer_handle
*buf
,
94 struct softpipe_context
*sp
= softpipe_context( pipe
);
95 sp
->winsys
->buffer_subdata( sp
->winsys
, buf
, offset
, size
, data
);
98 static void sp_buffer_get_subdata(struct pipe_context
*pipe
,
99 struct pipe_buffer_handle
*buf
,
100 unsigned long offset
,
104 struct softpipe_context
*sp
= softpipe_context( pipe
);
105 sp
->winsys
->buffer_get_subdata( sp
->winsys
, buf
, offset
, size
, data
);
110 sp_init_buffer_functions( struct softpipe_context
*sp
)
112 sp
->pipe
.create_buffer
= sp_create_buffer
;
113 sp
->pipe
.buffer_map
= sp_buffer_map
;
114 sp
->pipe
.buffer_unmap
= sp_buffer_unmap
;
115 sp
->pipe
.buffer_reference
= sp_buffer_reference
;
116 sp
->pipe
.buffer_unreference
= sp_buffer_unreference
;
117 sp
->pipe
.buffer_data
= sp_buffer_data
;
118 sp
->pipe
.buffer_subdata
= sp_buffer_subdata
;
119 sp
->pipe
.buffer_get_subdata
= sp_buffer_get_subdata
;