1 /*
2 * Copyright 2011 Joakim Sindholt <[email protected]>
3 * SPDX-License-Identifier: MIT
4 */
5
6 #ifndef _NINE_VERTEXDECLARATION9_H_
7 #define _NINE_VERTEXDECLARATION9_H_
8
9 #include "nine_defines.h"
10 #include "iunknown.h"
11
12 struct pipe_resource;
13 struct pipe_vertex_element;
14 struct pipe_stream_output_info;
15 struct NineDevice9;
16 struct NineVertexBuffer9;
17 struct nine_vs_output_info;
18
19 struct NineVertexDeclaration9
20 {
21 struct NineUnknown base;
22
23 /* G3D state */
24 struct pipe_vertex_element *elems;
25 unsigned nelems;
26
27 /* index -> DECLUSAGE, for selecting the vertex element
28 * for each VS input */
29 uint16_t *usage_map;
30
31 D3DVERTEXELEMENT9 *decls;
32 DWORD fvf;
33
34 BOOL position_t;
35 };
36 static inline struct NineVertexDeclaration9 *
NineVertexDeclaration9(void * data)37 NineVertexDeclaration9( void *data )
38 {
39 return (struct NineVertexDeclaration9 *)data;
40 }
41
42 HRESULT
43 NineVertexDeclaration9_new( struct NineDevice9 *pDevice,
44 const D3DVERTEXELEMENT9 *pElements,
45 struct NineVertexDeclaration9 **ppOut );
46
47 HRESULT
48 NineVertexDeclaration9_new_from_fvf( struct NineDevice9 *pDevice,
49 DWORD FVF,
50 struct NineVertexDeclaration9 **ppOut );
51
52 HRESULT
53 NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This,
54 struct NineUnknownParams *pParams,
55 const D3DVERTEXELEMENT9 *pElements );
56
57 void
58 NineVertexDeclaration9_dtor( struct NineVertexDeclaration9 *This );
59
60 HRESULT NINE_WINAPI
61 NineVertexDeclaration9_GetDeclaration( struct NineVertexDeclaration9 *This,
62 D3DVERTEXELEMENT9 *pElement,
63 UINT *pNumElements );
64
65 void
66 NineVertexDeclaration9_FillStreamOutputInfo(
67 struct NineVertexDeclaration9 *This,
68 struct nine_vs_output_info *ShaderOutputsInfo,
69 unsigned numOutputs,
70 struct pipe_stream_output_info *so );
71
72 /* Convert stream output data to the vertex declaration's format. */
73 HRESULT
74 NineVertexDeclaration9_ConvertStreamOutput(
75 struct NineVertexDeclaration9 *This,
76 struct NineVertexBuffer9 *pDstBuf,
77 UINT DestIndex,
78 UINT VertexCount,
79 void *pSrcBuf,
80 const struct pipe_stream_output_info *so );
81
82 #endif /* _NINE_VERTEXDECLARATION9_H_ */
83