1 /*
2  * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22 
23 #ifndef _NINE_VOLUME9_H_
24 #define _NINE_VOLUME9_H_
25 
26 #include "iunknown.h"
27 
28 #include "pipe/p_state.h"
29 #include "util/u_inlines.h"
30 
31 struct util_hash_table;
32 
33 struct NineDevice9;
34 
35 struct NineVolume9
36 {
37     struct NineUnknown base;
38 
39     struct pipe_resource *resource;
40     unsigned level;
41     unsigned level_actual;
42 
43     uint8_t *data; /* system memory backing */
44     uint8_t *data_conversion; /* for conversions */
45 
46     D3DVOLUME_DESC desc;
47     struct pipe_resource info;
48     enum pipe_format format_conversion;
49     unsigned stride;
50     unsigned stride_conversion;
51     unsigned layer_stride;
52     unsigned layer_stride_conversion;
53 
54     struct pipe_transfer *transfer;
55     unsigned lock_count;
56 
57     unsigned pending_uploads_counter; /* pending uploads */
58 };
59 static inline struct NineVolume9 *
60 NineVolume9( void *data )
61 {
62     return (struct NineVolume9 *)data;
63 }
64 
65 HRESULT
66 NineVolume9_new( struct NineDevice9 *pDevice,
67                  struct NineUnknown *pContainer,
68                  struct pipe_resource *pResource,
69                  unsigned Level,
70                  D3DVOLUME_DESC *pDesc,
71                  struct NineVolume9 **ppOut );
72 
73 /*** Nine private ***/
74 
75 static inline void
76 NineVolume9_SetResource( struct NineVolume9 *This,
77                          struct pipe_resource *resource, unsigned level )
78 {
79     This->level = level;
80     pipe_resource_reference(&This->resource, resource);
81 }
82 
83 void
84 NineVolume9_AddDirtyRegion( struct NineVolume9 *This,
85                             const struct pipe_box *box );
86 
87 void
88 NineVolume9_CopyMemToDefault( struct NineVolume9 *This,
89                               struct NineVolume9 *From,
90                               unsigned dstx, unsigned dsty, unsigned dstz,
91                               struct pipe_box *pSrcBox );
92 
93 HRESULT
94 NineVolume9_UploadSelf( struct NineVolume9 *This,
95                         const struct pipe_box *damaged );
96 
97 
98 /*** Direct3D public ***/
99 
100 HRESULT NINE_WINAPI
101 NineVolume9_GetContainer( struct NineVolume9 *This,
102                           REFIID riid,
103                           void **ppContainer );
104 
105 HRESULT NINE_WINAPI
106 NineVolume9_GetDesc( struct NineVolume9 *This,
107                      D3DVOLUME_DESC *pDesc );
108 
109 HRESULT NINE_WINAPI
110 NineVolume9_LockBox( struct NineVolume9 *This,
111                      D3DLOCKED_BOX *pLockedVolume,
112                      const D3DBOX *pBox,
113                      DWORD Flags );
114 
115 HRESULT NINE_WINAPI
116 NineVolume9_UnlockBox( struct NineVolume9 *This );
117 
118 #endif /* _NINE_VOLUME9_H_ */
119