2
* Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
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:
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
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. */
23
#include "vertexbuffer9.h"
25
#include "nine_helpers.h"
26
#include "nine_pipe.h"
28
#include "pipe/p_screen.h"
29
#include "pipe/p_context.h"
30
#include "pipe/p_state.h"
31
#include "pipe/p_defines.h"
32
#include "pipe/p_format.h"
33
#include "util/u_box.h"
35
#define DBG_CHANNEL DBG_VERTEXBUFFER
38
NineVertexBuffer9_ctor( struct NineVertexBuffer9 *This,
39
struct NineUnknownParams *pParams,
40
D3DVERTEXBUFFER_DESC *pDesc )
44
DBG("This=%p Size=0x%x Usage=%x Pool=%u\n", This,
45
pDesc->Size, pDesc->Usage, pDesc->Pool);
47
hr = NineBuffer9_ctor(&This->base, pParams, D3DRTYPE_VERTEXBUFFER,
48
pDesc->Usage, pDesc->Size, pDesc->Pool);
52
pDesc->Type = D3DRTYPE_VERTEXBUFFER;
53
pDesc->Format = D3DFMT_VERTEXDATA;
60
NineVertexBuffer9_dtor( struct NineVertexBuffer9 *This )
62
NineBuffer9_dtor(&This->base);
65
struct pipe_resource *
66
NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This, unsigned *offset )
68
return NineBuffer9_GetResource(&This->base, offset);
72
NineVertexBuffer9_Lock( struct NineVertexBuffer9 *This,
78
return NineBuffer9_Lock(&This->base, OffsetToLock, SizeToLock, ppbData, Flags);
82
NineVertexBuffer9_Unlock( struct NineVertexBuffer9 *This )
84
return NineBuffer9_Unlock(&This->base);
88
NineVertexBuffer9_GetDesc( struct NineVertexBuffer9 *This,
89
D3DVERTEXBUFFER_DESC *pDesc )
91
user_assert(pDesc, E_POINTER);
96
IDirect3DVertexBuffer9Vtbl NineVertexBuffer9_vtable = {
97
(void *)NineUnknown_QueryInterface,
98
(void *)NineUnknown_AddRef,
99
(void *)NineUnknown_Release,
100
(void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
101
(void *)NineUnknown_SetPrivateData,
102
(void *)NineUnknown_GetPrivateData,
103
(void *)NineUnknown_FreePrivateData,
104
(void *)NineResource9_SetPriority,
105
(void *)NineResource9_GetPriority,
106
(void *)NineResource9_PreLoad,
107
(void *)NineResource9_GetType,
108
(void *)NineVertexBuffer9_Lock,
109
(void *)NineVertexBuffer9_Unlock,
110
(void *)NineVertexBuffer9_GetDesc
113
static const GUID *NineVertexBuffer9_IIDs[] = {
114
&IID_IDirect3DVertexBuffer9,
115
&IID_IDirect3DResource9,
121
NineVertexBuffer9_new( struct NineDevice9 *pDevice,
122
D3DVERTEXBUFFER_DESC *pDesc,
123
struct NineVertexBuffer9 **ppOut )
125
NINE_DEVICE_CHILD_NEW(VertexBuffer9, ppOut, /* args */ pDevice, pDesc);