st/nine: Rename pipe to pipe_data in nine_context
[mesa.git] / src / gallium / state_trackers / nine / buffer9.h
1 /*
2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3 * Copyright 2015 Patrick Rudolph <siro@das-labor.org>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23
24 #ifndef _NINE_BUFFER9_H_
25 #define _NINE_BUFFER9_H_
26
27 #include "device9.h"
28 #include "resource9.h"
29 #include "pipe/p_context.h"
30 #include "pipe/p_state.h"
31 #include "util/list.h"
32
33 struct pipe_screen;
34 struct pipe_context;
35 struct pipe_transfer;
36
37 struct NineBuffer9
38 {
39 struct NineResource9 base;
40
41 /* G3D */
42 struct pipe_transfer **maps;
43 int nmaps, maxmaps;
44 UINT size;
45
46 /* Specific to managed buffers */
47 struct {
48 void *data;
49 boolean dirty;
50 struct pipe_box dirty_box;
51 struct list_head list; /* for update_buffers */
52 struct list_head list2; /* for managed_buffers */
53 } managed;
54 };
55 static inline struct NineBuffer9 *
56 NineBuffer9( void *data )
57 {
58 return (struct NineBuffer9 *)data;
59 }
60
61 HRESULT
62 NineBuffer9_ctor( struct NineBuffer9 *This,
63 struct NineUnknownParams *pParams,
64 D3DRESOURCETYPE Type,
65 DWORD Usage,
66 UINT Size,
67 D3DPOOL Pool );
68
69 void
70 NineBuffer9_dtor( struct NineBuffer9 *This );
71
72 struct pipe_resource *
73 NineBuffer9_GetResource( struct NineBuffer9 *This );
74
75 HRESULT NINE_WINAPI
76 NineBuffer9_Lock( struct NineBuffer9 *This,
77 UINT OffsetToLock,
78 UINT SizeToLock,
79 void **ppbData,
80 DWORD Flags );
81
82 HRESULT NINE_WINAPI
83 NineBuffer9_Unlock( struct NineBuffer9 *This );
84
85 static inline void
86 NineBuffer9_Upload( struct NineBuffer9 *This )
87 {
88 struct pipe_context *pipe = NineDevice9_GetPipe(This->base.base.device);
89
90 assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty);
91 pipe->buffer_subdata(pipe, This->base.resource, 0,
92 This->managed.dirty_box.x,
93 This->managed.dirty_box.width,
94 (char *)This->managed.data + This->managed.dirty_box.x);
95 This->managed.dirty = FALSE;
96 }
97
98 void
99 NineBuffer9_SetDirty( struct NineBuffer9 *This );
100
101 #endif /* _NINE_BUFFER9_H_ */