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_DEVICE9_H_
24 #define _NINE_DEVICE9_H_
25 
26 #include "d3dadapter/d3dadapter9.h"
27 
28 #include "iunknown.h"
29 #include "adapter9.h"
30 
31 #include "nine_helpers.h"
32 #include "nine_state.h"
33 
34 struct gen_mipmap_state;
35 struct hash_table;
36 struct pipe_screen;
37 struct pipe_context;
38 struct cso_context;
39 struct hud_context;
40 struct u_upload_mgr;
41 struct csmt_context;
42 
43 struct NineSwapChain9;
44 struct NineStateBlock9;
45 
46 #include "util/list.h"
47 
48 struct NineDevice9
49 {
50     struct NineUnknown base;
51     boolean ex;
52     boolean may_swvp;
53 
54     /* G3D context */
55     struct pipe_screen *screen;
56     /* For first time upload. No Sync with rendering thread */
57     struct pipe_context *pipe_secondary;
58     struct pipe_screen *screen_sw;
59     struct pipe_context *pipe_sw;
60     struct cso_context *cso_sw;
61 
62     /* CSMT context */
63     struct csmt_context *csmt_ctx;
64     BOOL csmt_active;
65 
66     /* For DISCARD/NOOVERWRITE */
67     struct nine_buffer_upload *buffer_upload;
68 
69     /* creation parameters */
70     D3DCAPS9 caps;
71     D3DDEVICE_CREATION_PARAMETERS params;
72     IDirect3D9 *d3d9;
73 
74     /* swapchain stuff */
75     ID3DPresentGroup *present;
76     struct NineSwapChain9 **swapchains;
77     unsigned nswapchains;
78 
79     struct NineStateBlock9 *record;
80     struct nine_state *update; /* state to update (&state / &record->state) */
81     struct nine_state state;   /* device state */
82     struct nine_context context;
83     struct nine_state_sw_internal state_sw_internal;
84 
85     struct list_head update_buffers;
86     struct list_head update_textures;
87     struct list_head managed_buffers;
88     struct list_head managed_textures;
89 
90     boolean is_recording;
91     boolean in_scene;
92 
93     uint16_t vs_const_size;
94     uint16_t ps_const_size;
95     uint16_t max_vs_const_f;
96     uint16_t max_ps_const_f;
97 
98     struct pipe_resource *dummy_texture;
99     struct pipe_sampler_view *dummy_sampler_view;
100     struct pipe_sampler_state dummy_sampler_state;
101 
102     struct gen_mipmap_state *gen_mipmap;
103 
104     struct {
105         struct hash_table *ht_vs;
106         struct hash_table *ht_ps;
107         struct NineVertexShader9 *vs;
108         struct NinePixelShader9 *ps;
109         unsigned num_vs;
110         unsigned num_ps;
111         float *vs_const;
112         float *ps_const;
113 
114         struct hash_table *ht_fvf;
115     } ff;
116 
117     struct {
118         struct pipe_resource *image;
119         unsigned w;
120         unsigned h;
121         POINT hotspot; /* -1, -1 if no cursor image set */
122         POINT pos;
123         BOOL visible;
124         boolean software;
125         void *hw_upload_temp;
126     } cursor;
127 
128     struct {
129         boolean user_vbufs;
130         boolean user_sw_vbufs;
131         boolean window_space_position_support;
132         boolean vs_integer;
133         boolean ps_integer;
134         boolean offset_units_unscaled;
135     } driver_caps;
136 
137     struct {
138         boolean buggy_barycentrics;
139     } driver_bugs;
140 
141     struct {
142         boolean dynamic_texture_workaround;
143     } workarounds;
144 
145     struct u_upload_mgr *vertex_uploader;
146 
147     struct nine_range_pool range_pool;
148 
149     struct hud_context *hud; /* NULL if hud is disabled */
150 
151     /* dummy vbo (containing 0 0 0 0) to bind if vertex shader input
152      * is not bound to anything by the vertex declaration */
153     struct pipe_resource *dummy_vbo;
154     BOOL device_needs_reset;
155     int minor_version_num;
156     long long available_texture_mem;
157     long long available_texture_limit;
158 
159     /* software vertex processing */
160     boolean swvp;
161     /* pure device */
162     boolean pure;
163 };
164 static inline struct NineDevice9 *
NineDevice9(void * data)165 NineDevice9( void *data )
166 {
167     return (struct NineDevice9 *)data;
168 }
169 
170 HRESULT
171 NineDevice9_new( struct pipe_screen *pScreen,
172                  D3DDEVICE_CREATION_PARAMETERS *pCreationParameters,
173                  D3DCAPS9 *pCaps,
174                  D3DPRESENT_PARAMETERS *pPresentationParameters,
175                  IDirect3D9 *pD3D9,
176                  ID3DPresentGroup *pPresentationGroup,
177                  struct d3dadapter9_context *pCTX,
178                  boolean ex,
179                  D3DDISPLAYMODEEX *pFullscreenDisplayMode,
180                  struct NineDevice9 **ppOut,
181                  int minorVersionNum );
182 
183 HRESULT
184 NineDevice9_ctor( struct NineDevice9 *This,
185                   struct NineUnknownParams *pParams,
186                   struct pipe_screen *pScreen,
187                   D3DDEVICE_CREATION_PARAMETERS *pCreationParameters,
188                   D3DCAPS9 *pCaps,
189                   D3DPRESENT_PARAMETERS *pPresentationParameters,
190                   IDirect3D9 *pD3D9,
191                   ID3DPresentGroup *pPresentationGroup,
192                   struct d3dadapter9_context *pCTX,
193                   boolean ex,
194                   D3DDISPLAYMODEEX *pFullscreenDisplayMode,
195                   int minorVersionNum );
196 
197 void
198 NineDevice9_dtor( struct NineDevice9 *This );
199 
200 /*** Nine private ***/
201 struct pipe_resource *
202 nine_resource_create_with_retry( struct NineDevice9 *This,
203                                  struct pipe_screen *screen,
204                                  const struct pipe_resource *templat );
205 
206 void
207 NineDevice9_SetDefaultState( struct NineDevice9 *This, boolean is_reset );
208 
209 struct pipe_screen *
210 NineDevice9_GetScreen( struct NineDevice9 *This );
211 
212 struct pipe_context *
213 NineDevice9_GetPipe( struct NineDevice9 *This );
214 
215 const D3DCAPS9 *
216 NineDevice9_GetCaps( struct NineDevice9 *This );
217 
218 void
219 NineDevice9_EvictManagedResourcesInternal( struct NineDevice9 *This );
220 
221 /*** Direct3D public ***/
222 
223 HRESULT NINE_WINAPI
224 NineDevice9_TestCooperativeLevel( struct NineDevice9 *This );
225 
226 UINT NINE_WINAPI
227 NineDevice9_GetAvailableTextureMem( struct NineDevice9 *This );
228 
229 HRESULT NINE_WINAPI
230 NineDevice9_EvictManagedResources( struct NineDevice9 *This );
231 
232 HRESULT NINE_WINAPI
233 NineDevice9_GetDirect3D( struct NineDevice9 *This,
234                          IDirect3D9 **ppD3D9 );
235 
236 HRESULT NINE_WINAPI
237 NineDevice9_GetDeviceCaps( struct NineDevice9 *This,
238                            D3DCAPS9 *pCaps );
239 
240 HRESULT NINE_WINAPI
241 NineDevice9_GetDisplayMode( struct NineDevice9 *This,
242                             UINT iSwapChain,
243                             D3DDISPLAYMODE *pMode );
244 
245 HRESULT NINE_WINAPI
246 NineDevice9_GetCreationParameters( struct NineDevice9 *This,
247                                    D3DDEVICE_CREATION_PARAMETERS *pParameters );
248 
249 HRESULT NINE_WINAPI
250 NineDevice9_SetCursorProperties( struct NineDevice9 *This,
251                                  UINT XHotSpot,
252                                  UINT YHotSpot,
253                                  IDirect3DSurface9 *pCursorBitmap );
254 
255 void NINE_WINAPI
256 NineDevice9_SetCursorPosition( struct NineDevice9 *This,
257                                int X,
258                                int Y,
259                                DWORD Flags );
260 
261 BOOL NINE_WINAPI
262 NineDevice9_ShowCursor( struct NineDevice9 *This,
263                         BOOL bShow );
264 
265 HRESULT NINE_WINAPI
266 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9 *This,
267                                        D3DPRESENT_PARAMETERS *pPresentationParameters,
268                                        IDirect3DSwapChain9 **pSwapChain );
269 
270 HRESULT NINE_WINAPI
271 NineDevice9_GetSwapChain( struct NineDevice9 *This,
272                           UINT iSwapChain,
273                           IDirect3DSwapChain9 **pSwapChain );
274 
275 UINT NINE_WINAPI
276 NineDevice9_GetNumberOfSwapChains( struct NineDevice9 *This );
277 
278 HRESULT NINE_WINAPI
279 NineDevice9_Reset( struct NineDevice9 *This,
280                    D3DPRESENT_PARAMETERS *pPresentationParameters );
281 
282 HRESULT NINE_WINAPI
283 NineDevice9_Present( struct NineDevice9 *This,
284                      const RECT *pSourceRect,
285                      const RECT *pDestRect,
286                      HWND hDestWindowOverride,
287                      const RGNDATA *pDirtyRegion );
288 
289 HRESULT NINE_WINAPI
290 NineDevice9_GetBackBuffer( struct NineDevice9 *This,
291                            UINT iSwapChain,
292                            UINT iBackBuffer,
293                            D3DBACKBUFFER_TYPE Type,
294                            IDirect3DSurface9 **ppBackBuffer );
295 
296 HRESULT NINE_WINAPI
297 NineDevice9_GetRasterStatus( struct NineDevice9 *This,
298                              UINT iSwapChain,
299                              D3DRASTER_STATUS *pRasterStatus );
300 
301 HRESULT NINE_WINAPI
302 NineDevice9_SetDialogBoxMode( struct NineDevice9 *This,
303                               BOOL bEnableDialogs );
304 
305 void NINE_WINAPI
306 NineDevice9_SetGammaRamp( struct NineDevice9 *This,
307                           UINT iSwapChain,
308                           DWORD Flags,
309                           const D3DGAMMARAMP *pRamp );
310 
311 void NINE_WINAPI
312 NineDevice9_GetGammaRamp( struct NineDevice9 *This,
313                           UINT iSwapChain,
314                           D3DGAMMARAMP *pRamp );
315 
316 HRESULT NINE_WINAPI
317 NineDevice9_CreateTexture( struct NineDevice9 *This,
318                            UINT Width,
319                            UINT Height,
320                            UINT Levels,
321                            DWORD Usage,
322                            D3DFORMAT Format,
323                            D3DPOOL Pool,
324                            IDirect3DTexture9 **ppTexture,
325                            HANDLE *pSharedHandle );
326 
327 HRESULT NINE_WINAPI
328 NineDevice9_CreateVolumeTexture( struct NineDevice9 *This,
329                                  UINT Width,
330                                  UINT Height,
331                                  UINT Depth,
332                                  UINT Levels,
333                                  DWORD Usage,
334                                  D3DFORMAT Format,
335                                  D3DPOOL Pool,
336                                  IDirect3DVolumeTexture9 **ppVolumeTexture,
337                                  HANDLE *pSharedHandle );
338 
339 HRESULT NINE_WINAPI
340 NineDevice9_CreateCubeTexture( struct NineDevice9 *This,
341                                UINT EdgeLength,
342                                UINT Levels,
343                                DWORD Usage,
344                                D3DFORMAT Format,
345                                D3DPOOL Pool,
346                                IDirect3DCubeTexture9 **ppCubeTexture,
347                                HANDLE *pSharedHandle );
348 
349 HRESULT NINE_WINAPI
350 NineDevice9_CreateVertexBuffer( struct NineDevice9 *This,
351                                 UINT Length,
352                                 DWORD Usage,
353                                 DWORD FVF,
354                                 D3DPOOL Pool,
355                                 IDirect3DVertexBuffer9 **ppVertexBuffer,
356                                 HANDLE *pSharedHandle );
357 
358 HRESULT NINE_WINAPI
359 NineDevice9_CreateIndexBuffer( struct NineDevice9 *This,
360                                UINT Length,
361                                DWORD Usage,
362                                D3DFORMAT Format,
363                                D3DPOOL Pool,
364                                IDirect3DIndexBuffer9 **ppIndexBuffer,
365                                HANDLE *pSharedHandle );
366 
367 HRESULT NINE_WINAPI
368 NineDevice9_CreateRenderTarget( struct NineDevice9 *This,
369                                 UINT Width,
370                                 UINT Height,
371                                 D3DFORMAT Format,
372                                 D3DMULTISAMPLE_TYPE MultiSample,
373                                 DWORD MultisampleQuality,
374                                 BOOL Lockable,
375                                 IDirect3DSurface9 **ppSurface,
376                                 HANDLE *pSharedHandle );
377 
378 HRESULT NINE_WINAPI
379 NineDevice9_CreateDepthStencilSurface( struct NineDevice9 *This,
380                                        UINT Width,
381                                        UINT Height,
382                                        D3DFORMAT Format,
383                                        D3DMULTISAMPLE_TYPE MultiSample,
384                                        DWORD MultisampleQuality,
385                                        BOOL Discard,
386                                        IDirect3DSurface9 **ppSurface,
387                                        HANDLE *pSharedHandle );
388 
389 HRESULT NINE_WINAPI
390 NineDevice9_UpdateSurface( struct NineDevice9 *This,
391                            IDirect3DSurface9 *pSourceSurface,
392                            const RECT *pSourceRect,
393                            IDirect3DSurface9 *pDestinationSurface,
394                            const POINT *pDestPoint );
395 
396 HRESULT NINE_WINAPI
397 NineDevice9_UpdateTexture( struct NineDevice9 *This,
398                            IDirect3DBaseTexture9 *pSourceTexture,
399                            IDirect3DBaseTexture9 *pDestinationTexture );
400 
401 HRESULT NINE_WINAPI
402 NineDevice9_GetRenderTargetData( struct NineDevice9 *This,
403                                  IDirect3DSurface9 *pRenderTarget,
404                                  IDirect3DSurface9 *pDestSurface );
405 
406 HRESULT NINE_WINAPI
407 NineDevice9_GetFrontBufferData( struct NineDevice9 *This,
408                                 UINT iSwapChain,
409                                 IDirect3DSurface9 *pDestSurface );
410 
411 HRESULT NINE_WINAPI
412 NineDevice9_StretchRect( struct NineDevice9 *This,
413                          IDirect3DSurface9 *pSourceSurface,
414                          const RECT *pSourceRect,
415                          IDirect3DSurface9 *pDestSurface,
416                          const RECT *pDestRect,
417                          D3DTEXTUREFILTERTYPE Filter );
418 
419 HRESULT NINE_WINAPI
420 NineDevice9_ColorFill( struct NineDevice9 *This,
421                        IDirect3DSurface9 *pSurface,
422                        const RECT *pRect,
423                        D3DCOLOR color );
424 
425 HRESULT NINE_WINAPI
426 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9 *This,
427                                          UINT Width,
428                                          UINT Height,
429                                          D3DFORMAT Format,
430                                          D3DPOOL Pool,
431                                          IDirect3DSurface9 **ppSurface,
432                                          HANDLE *pSharedHandle );
433 
434 HRESULT NINE_WINAPI
435 NineDevice9_SetRenderTarget( struct NineDevice9 *This,
436                              DWORD RenderTargetIndex,
437                              IDirect3DSurface9 *pRenderTarget );
438 
439 HRESULT NINE_WINAPI
440 NineDevice9_GetRenderTarget( struct NineDevice9 *This,
441                              DWORD RenderTargetIndex,
442                              IDirect3DSurface9 **ppRenderTarget );
443 
444 HRESULT NINE_WINAPI
445 NineDevice9_SetDepthStencilSurface( struct NineDevice9 *This,
446                                     IDirect3DSurface9 *pNewZStencil );
447 
448 HRESULT NINE_WINAPI
449 NineDevice9_GetDepthStencilSurface( struct NineDevice9 *This,
450                                     IDirect3DSurface9 **ppZStencilSurface );
451 
452 HRESULT NINE_WINAPI
453 NineDevice9_BeginScene( struct NineDevice9 *This );
454 
455 HRESULT NINE_WINAPI
456 NineDevice9_EndScene( struct NineDevice9 *This );
457 
458 HRESULT NINE_WINAPI
459 NineDevice9_Clear( struct NineDevice9 *This,
460                    DWORD Count,
461                    const D3DRECT *pRects,
462                    DWORD Flags,
463                    D3DCOLOR Color,
464                    float Z,
465                    DWORD Stencil );
466 
467 HRESULT NINE_WINAPI
468 NineDevice9_SetTransform( struct NineDevice9 *This,
469                           D3DTRANSFORMSTATETYPE State,
470                           const D3DMATRIX *pMatrix );
471 
472 HRESULT NINE_WINAPI
473 NineDevice9_GetTransform( struct NineDevice9 *This,
474                           D3DTRANSFORMSTATETYPE State,
475                           D3DMATRIX *pMatrix );
476 
477 HRESULT NINE_WINAPI
478 NineDevice9_MultiplyTransform( struct NineDevice9 *This,
479                                D3DTRANSFORMSTATETYPE State,
480                                const D3DMATRIX *pMatrix );
481 
482 HRESULT NINE_WINAPI
483 NineDevice9_SetViewport( struct NineDevice9 *This,
484                          const D3DVIEWPORT9 *pViewport );
485 
486 HRESULT NINE_WINAPI
487 NineDevice9_GetViewport( struct NineDevice9 *This,
488                          D3DVIEWPORT9 *pViewport );
489 
490 HRESULT NINE_WINAPI
491 NineDevice9_SetMaterial( struct NineDevice9 *This,
492                          const D3DMATERIAL9 *pMaterial );
493 
494 HRESULT NINE_WINAPI
495 NineDevice9_GetMaterial( struct NineDevice9 *This,
496                          D3DMATERIAL9 *pMaterial );
497 
498 HRESULT NINE_WINAPI
499 NineDevice9_SetLight( struct NineDevice9 *This,
500                       DWORD Index,
501                       const D3DLIGHT9 *pLight );
502 
503 HRESULT NINE_WINAPI
504 NineDevice9_GetLight( struct NineDevice9 *This,
505                       DWORD Index,
506                       D3DLIGHT9 *pLight );
507 
508 HRESULT NINE_WINAPI
509 NineDevice9_LightEnable( struct NineDevice9 *This,
510                          DWORD Index,
511                          BOOL Enable );
512 
513 HRESULT NINE_WINAPI
514 NineDevice9_GetLightEnable( struct NineDevice9 *This,
515                             DWORD Index,
516                             BOOL *pEnable );
517 
518 HRESULT NINE_WINAPI
519 NineDevice9_SetClipPlane( struct NineDevice9 *This,
520                           DWORD Index,
521                           const float *pPlane );
522 
523 HRESULT NINE_WINAPI
524 NineDevice9_GetClipPlane( struct NineDevice9 *This,
525                           DWORD Index,
526                           float *pPlane );
527 
528 HRESULT NINE_WINAPI
529 NineDevice9_SetRenderState( struct NineDevice9 *This,
530                             D3DRENDERSTATETYPE State,
531                             DWORD Value );
532 
533 HRESULT NINE_WINAPI
534 NineDevice9_GetRenderState( struct NineDevice9 *This,
535                             D3DRENDERSTATETYPE State,
536                             DWORD *pValue );
537 
538 HRESULT NINE_WINAPI
539 NineDevice9_CreateStateBlock( struct NineDevice9 *This,
540                               D3DSTATEBLOCKTYPE Type,
541                               IDirect3DStateBlock9 **ppSB );
542 
543 HRESULT NINE_WINAPI
544 NineDevice9_BeginStateBlock( struct NineDevice9 *This );
545 
546 HRESULT NINE_WINAPI
547 NineDevice9_EndStateBlock( struct NineDevice9 *This,
548                            IDirect3DStateBlock9 **ppSB );
549 
550 HRESULT NINE_WINAPI
551 NineDevice9_SetClipStatus( struct NineDevice9 *This,
552                            const D3DCLIPSTATUS9 *pClipStatus );
553 
554 HRESULT NINE_WINAPI
555 NineDevice9_GetClipStatus( struct NineDevice9 *This,
556                            D3DCLIPSTATUS9 *pClipStatus );
557 
558 HRESULT NINE_WINAPI
559 NineDevice9_GetTexture( struct NineDevice9 *This,
560                         DWORD Stage,
561                         IDirect3DBaseTexture9 **ppTexture );
562 
563 HRESULT NINE_WINAPI
564 NineDevice9_SetTexture( struct NineDevice9 *This,
565                         DWORD Stage,
566                         IDirect3DBaseTexture9 *pTexture );
567 
568 HRESULT NINE_WINAPI
569 NineDevice9_GetTextureStageState( struct NineDevice9 *This,
570                                   DWORD Stage,
571                                   D3DTEXTURESTAGESTATETYPE Type,
572                                   DWORD *pValue );
573 
574 HRESULT NINE_WINAPI
575 NineDevice9_SetTextureStageState( struct NineDevice9 *This,
576                                   DWORD Stage,
577                                   D3DTEXTURESTAGESTATETYPE Type,
578                                   DWORD Value );
579 
580 HRESULT NINE_WINAPI
581 NineDevice9_GetSamplerState( struct NineDevice9 *This,
582                              DWORD Sampler,
583                              D3DSAMPLERSTATETYPE Type,
584                              DWORD *pValue );
585 
586 HRESULT NINE_WINAPI
587 NineDevice9_SetSamplerState( struct NineDevice9 *This,
588                              DWORD Sampler,
589                              D3DSAMPLERSTATETYPE Type,
590                              DWORD Value );
591 
592 HRESULT NINE_WINAPI
593 NineDevice9_ValidateDevice( struct NineDevice9 *This,
594                             DWORD *pNumPasses );
595 
596 HRESULT NINE_WINAPI
597 NineDevice9_SetPaletteEntries( struct NineDevice9 *This,
598                                UINT PaletteNumber,
599                                const PALETTEENTRY *pEntries );
600 
601 HRESULT NINE_WINAPI
602 NineDevice9_GetPaletteEntries( struct NineDevice9 *This,
603                                UINT PaletteNumber,
604                                PALETTEENTRY *pEntries );
605 
606 HRESULT NINE_WINAPI
607 NineDevice9_SetCurrentTexturePalette( struct NineDevice9 *This,
608                                       UINT PaletteNumber );
609 
610 HRESULT NINE_WINAPI
611 NineDevice9_GetCurrentTexturePalette( struct NineDevice9 *This,
612                                       UINT *PaletteNumber );
613 
614 HRESULT NINE_WINAPI
615 NineDevice9_SetScissorRect( struct NineDevice9 *This,
616                             const RECT *pRect );
617 
618 HRESULT NINE_WINAPI
619 NineDevice9_GetScissorRect( struct NineDevice9 *This,
620                             RECT *pRect );
621 
622 HRESULT NINE_WINAPI
623 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9 *This,
624                                          BOOL bSoftware );
625 
626 BOOL NINE_WINAPI
627 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9 *This );
628 
629 HRESULT NINE_WINAPI
630 NineDevice9_SetNPatchMode( struct NineDevice9 *This,
631                            float nSegments );
632 
633 float NINE_WINAPI
634 NineDevice9_GetNPatchMode( struct NineDevice9 *This );
635 
636 HRESULT NINE_WINAPI
637 NineDevice9_DrawPrimitive( struct NineDevice9 *This,
638                            D3DPRIMITIVETYPE PrimitiveType,
639                            UINT StartVertex,
640                            UINT PrimitiveCount );
641 
642 HRESULT NINE_WINAPI
643 NineDevice9_DrawIndexedPrimitive( struct NineDevice9 *This,
644                                   D3DPRIMITIVETYPE PrimitiveType,
645                                   INT BaseVertexIndex,
646                                   UINT MinVertexIndex,
647                                   UINT NumVertices,
648                                   UINT startIndex,
649                                   UINT primCount );
650 
651 HRESULT NINE_WINAPI
652 NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
653                              D3DPRIMITIVETYPE PrimitiveType,
654                              UINT PrimitiveCount,
655                              const void *pVertexStreamZeroData,
656                              UINT VertexStreamZeroStride );
657 
658 HRESULT NINE_WINAPI
659 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
660                                     D3DPRIMITIVETYPE PrimitiveType,
661                                     UINT MinVertexIndex,
662                                     UINT NumVertices,
663                                     UINT PrimitiveCount,
664                                     const void *pIndexData,
665                                     D3DFORMAT IndexDataFormat,
666                                     const void *pVertexStreamZeroData,
667                                     UINT VertexStreamZeroStride );
668 
669 HRESULT NINE_WINAPI
670 NineDevice9_ProcessVertices( struct NineDevice9 *This,
671                              UINT SrcStartIndex,
672                              UINT DestIndex,
673                              UINT VertexCount,
674                              IDirect3DVertexBuffer9 *pDestBuffer,
675                              IDirect3DVertexDeclaration9 *pVertexDecl,
676                              DWORD Flags );
677 
678 HRESULT NINE_WINAPI
679 NineDevice9_CreateVertexDeclaration( struct NineDevice9 *This,
680                                      const D3DVERTEXELEMENT9 *pVertexElements,
681                                      IDirect3DVertexDeclaration9 **ppDecl );
682 
683 HRESULT NINE_WINAPI
684 NineDevice9_SetVertexDeclaration( struct NineDevice9 *This,
685                                   IDirect3DVertexDeclaration9 *pDecl );
686 
687 HRESULT NINE_WINAPI
688 NineDevice9_GetVertexDeclaration( struct NineDevice9 *This,
689                                   IDirect3DVertexDeclaration9 **ppDecl );
690 
691 HRESULT NINE_WINAPI
692 NineDevice9_SetFVF( struct NineDevice9 *This,
693                     DWORD FVF );
694 
695 HRESULT NINE_WINAPI
696 NineDevice9_GetFVF( struct NineDevice9 *This,
697                     DWORD *pFVF );
698 
699 HRESULT NINE_WINAPI
700 NineDevice9_CreateVertexShader( struct NineDevice9 *This,
701                                 const DWORD *pFunction,
702                                 IDirect3DVertexShader9 **ppShader );
703 
704 HRESULT NINE_WINAPI
705 NineDevice9_SetVertexShader( struct NineDevice9 *This,
706                              IDirect3DVertexShader9 *pShader );
707 
708 HRESULT NINE_WINAPI
709 NineDevice9_GetVertexShader( struct NineDevice9 *This,
710                              IDirect3DVertexShader9 **ppShader );
711 
712 HRESULT NINE_WINAPI
713 NineDevice9_SetVertexShaderConstantF( struct NineDevice9 *This,
714                                       UINT StartRegister,
715                                       const float *pConstantData,
716                                       UINT Vector4fCount );
717 
718 HRESULT NINE_WINAPI
719 NineDevice9_GetVertexShaderConstantF( struct NineDevice9 *This,
720                                       UINT StartRegister,
721                                       float *pConstantData,
722                                       UINT Vector4fCount );
723 
724 HRESULT NINE_WINAPI
725 NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
726                                       UINT StartRegister,
727                                       const int *pConstantData,
728                                       UINT Vector4iCount );
729 
730 HRESULT NINE_WINAPI
731 NineDevice9_GetVertexShaderConstantI( struct NineDevice9 *This,
732                                       UINT StartRegister,
733                                       int *pConstantData,
734                                       UINT Vector4iCount );
735 
736 HRESULT NINE_WINAPI
737 NineDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
738                                       UINT StartRegister,
739                                       const BOOL *pConstantData,
740                                       UINT BoolCount );
741 
742 HRESULT NINE_WINAPI
743 NineDevice9_GetVertexShaderConstantB( struct NineDevice9 *This,
744                                       UINT StartRegister,
745                                       BOOL *pConstantData,
746                                       UINT BoolCount );
747 
748 HRESULT NINE_WINAPI
749 NineDevice9_SetStreamSource( struct NineDevice9 *This,
750                              UINT StreamNumber,
751                              IDirect3DVertexBuffer9 *pStreamData,
752                              UINT OffsetInBytes,
753                              UINT Stride );
754 
755 HRESULT NINE_WINAPI
756 NineDevice9_GetStreamSource( struct NineDevice9 *This,
757                              UINT StreamNumber,
758                              IDirect3DVertexBuffer9 **ppStreamData,
759                              UINT *pOffsetInBytes,
760                              UINT *pStride );
761 
762 HRESULT NINE_WINAPI
763 NineDevice9_SetStreamSourceFreq( struct NineDevice9 *This,
764                                  UINT StreamNumber,
765                                  UINT Setting );
766 
767 HRESULT NINE_WINAPI
768 NineDevice9_GetStreamSourceFreq( struct NineDevice9 *This,
769                                  UINT StreamNumber,
770                                  UINT *pSetting );
771 
772 HRESULT NINE_WINAPI
773 NineDevice9_SetIndices( struct NineDevice9 *This,
774                         IDirect3DIndexBuffer9 *pIndexData );
775 
776 HRESULT NINE_WINAPI
777 NineDevice9_GetIndices( struct NineDevice9 *This,
778                         IDirect3DIndexBuffer9 **ppIndexData /*,
779                         UINT *pBaseVertexIndex */ );
780 
781 HRESULT NINE_WINAPI
782 NineDevice9_CreatePixelShader( struct NineDevice9 *This,
783                                const DWORD *pFunction,
784                                IDirect3DPixelShader9 **ppShader );
785 
786 HRESULT NINE_WINAPI
787 NineDevice9_SetPixelShader( struct NineDevice9 *This,
788                             IDirect3DPixelShader9 *pShader );
789 
790 HRESULT NINE_WINAPI
791 NineDevice9_GetPixelShader( struct NineDevice9 *This,
792                             IDirect3DPixelShader9 **ppShader );
793 
794 HRESULT NINE_WINAPI
795 NineDevice9_SetPixelShaderConstantF( struct NineDevice9 *This,
796                                      UINT StartRegister,
797                                      const float *pConstantData,
798                                      UINT Vector4fCount );
799 
800 HRESULT NINE_WINAPI
801 NineDevice9_GetPixelShaderConstantF( struct NineDevice9 *This,
802                                      UINT StartRegister,
803                                      float *pConstantData,
804                                      UINT Vector4fCount );
805 
806 HRESULT NINE_WINAPI
807 NineDevice9_SetPixelShaderConstantI( struct NineDevice9 *This,
808                                      UINT StartRegister,
809                                      const int *pConstantData,
810                                      UINT Vector4iCount );
811 
812 HRESULT NINE_WINAPI
813 NineDevice9_GetPixelShaderConstantI( struct NineDevice9 *This,
814                                      UINT StartRegister,
815                                      int *pConstantData,
816                                      UINT Vector4iCount );
817 
818 HRESULT NINE_WINAPI
819 NineDevice9_SetPixelShaderConstantB( struct NineDevice9 *This,
820                                      UINT StartRegister,
821                                      const BOOL *pConstantData,
822                                      UINT BoolCount );
823 
824 HRESULT NINE_WINAPI
825 NineDevice9_GetPixelShaderConstantB( struct NineDevice9 *This,
826                                      UINT StartRegister,
827                                      BOOL *pConstantData,
828                                      UINT BoolCount );
829 
830 HRESULT NINE_WINAPI
831 NineDevice9_DrawRectPatch( struct NineDevice9 *This,
832                            UINT Handle,
833                            const float *pNumSegs,
834                            const D3DRECTPATCH_INFO *pRectPatchInfo );
835 
836 HRESULT NINE_WINAPI
837 NineDevice9_DrawTriPatch( struct NineDevice9 *This,
838                           UINT Handle,
839                           const float *pNumSegs,
840                           const D3DTRIPATCH_INFO *pTriPatchInfo );
841 
842 HRESULT NINE_WINAPI
843 NineDevice9_DeletePatch( struct NineDevice9 *This,
844                          UINT Handle );
845 
846 HRESULT NINE_WINAPI
847 NineDevice9_CreateQuery( struct NineDevice9 *This,
848                          D3DQUERYTYPE Type,
849                          IDirect3DQuery9 **ppQuery );
850 
851 #endif /* _NINE_DEVICE9_H_ */
852