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 #ifndef _NINE_DEVICE9_H_
24 #define _NINE_DEVICE9_H_
26 #include "d3dadapter/d3dadapter9.h"
31 #include "nine_helpers.h"
32 #include "nine_state.h"
34 struct gen_mipmap_state
;
35 struct util_hash_table
;
42 struct NineSwapChain9
;
43 struct NineStateBlock9
;
45 #include "util/u_double_list.h"
49 struct NineUnknown base
;
53 struct pipe_screen
*screen
;
54 struct pipe_context
*pipe
;
55 struct cso_context
*cso
;
57 /* creation parameters */
59 D3DDEVICE_CREATION_PARAMETERS params
;
63 ID3DPresentGroup
*present
;
64 struct NineSwapChain9
**swapchains
;
67 struct NineStateBlock9
*record
;
68 struct nine_state
*update
; /* state to update (&state / &record->state) */
69 struct nine_state state
; /* device state */
71 struct list_head update_textures
;
76 boolean prefer_user_constbuf
;
78 struct pipe_resource
*constbuf_vs
;
79 struct pipe_resource
*constbuf_ps
;
80 uint16_t vs_const_size
;
81 uint16_t ps_const_size
;
82 uint16_t max_vs_const_f
;
83 uint16_t max_ps_const_f
;
85 struct pipe_resource
*dummy_texture
;
86 struct pipe_sampler_view
*dummy_sampler
;
88 struct gen_mipmap_state
*gen_mipmap
;
91 struct util_hash_table
*ht_vs
;
92 struct util_hash_table
*ht_ps
;
93 struct NineVertexShader9
*vs
;
94 struct NinePixelShader9
*ps
;
100 struct util_hash_table
*ht_fvf
;
104 struct pipe_resource
*image
;
107 POINT hotspot
; /* -1, -1 if no cursor image set */
116 boolean window_space_position_support
;
121 struct u_upload_mgr
*upload
;
123 struct nine_range_pool range_pool
;
125 struct hud_context
*hud
; /* NULL if hud is disabled */
127 static INLINE
struct NineDevice9
*
128 NineDevice9( void *data
)
130 return (struct NineDevice9
*)data
;
134 NineDevice9_new( struct pipe_screen
*pScreen
,
135 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
137 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
139 ID3DPresentGroup
*pPresentationGroup
,
140 struct d3dadapter9_context
*pCTX
,
142 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
143 struct NineDevice9
**ppOut
);
146 NineDevice9_ctor( struct NineDevice9
*This
,
147 struct NineUnknownParams
*pParams
,
148 struct pipe_screen
*pScreen
,
149 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
151 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
153 ID3DPresentGroup
*pPresentationGroup
,
154 struct d3dadapter9_context
*pCTX
,
156 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
159 NineDevice9_dtor( struct NineDevice9
*This
);
161 /*** Nine private ***/
164 NineDevice9_GetScreen( struct NineDevice9
*This
);
166 struct pipe_context
*
167 NineDevice9_GetPipe( struct NineDevice9
*This
);
170 NineDevice9_GetCSO( struct NineDevice9
*This
);
173 NineDevice9_GetCaps( struct NineDevice9
*This
);
175 /* Mask: 0x1 = constant buffers, 0x2 = stipple */
177 NineDevice9_RestoreNonCSOState( struct NineDevice9
*This
, unsigned mask
);
179 /*** Direct3D public ***/
182 NineDevice9_TestCooperativeLevel( struct NineDevice9
*This
);
185 NineDevice9_GetAvailableTextureMem( struct NineDevice9
*This
);
188 NineDevice9_EvictManagedResources( struct NineDevice9
*This
);
191 NineDevice9_GetDirect3D( struct NineDevice9
*This
,
192 IDirect3D9
**ppD3D9
);
195 NineDevice9_GetDeviceCaps( struct NineDevice9
*This
,
199 NineDevice9_GetDisplayMode( struct NineDevice9
*This
,
201 D3DDISPLAYMODE
*pMode
);
204 NineDevice9_GetCreationParameters( struct NineDevice9
*This
,
205 D3DDEVICE_CREATION_PARAMETERS
*pParameters
);
208 NineDevice9_SetCursorProperties( struct NineDevice9
*This
,
211 IDirect3DSurface9
*pCursorBitmap
);
214 NineDevice9_SetCursorPosition( struct NineDevice9
*This
,
220 NineDevice9_ShowCursor( struct NineDevice9
*This
,
224 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9
*This
,
225 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
226 IDirect3DSwapChain9
**pSwapChain
);
229 NineDevice9_GetSwapChain( struct NineDevice9
*This
,
231 IDirect3DSwapChain9
**pSwapChain
);
234 NineDevice9_GetNumberOfSwapChains( struct NineDevice9
*This
);
237 NineDevice9_Reset( struct NineDevice9
*This
,
238 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
241 NineDevice9_Present( struct NineDevice9
*This
,
242 const RECT
*pSourceRect
,
243 const RECT
*pDestRect
,
244 HWND hDestWindowOverride
,
245 const RGNDATA
*pDirtyRegion
);
248 NineDevice9_GetBackBuffer( struct NineDevice9
*This
,
251 D3DBACKBUFFER_TYPE Type
,
252 IDirect3DSurface9
**ppBackBuffer
);
255 NineDevice9_GetRasterStatus( struct NineDevice9
*This
,
257 D3DRASTER_STATUS
*pRasterStatus
);
260 NineDevice9_SetDialogBoxMode( struct NineDevice9
*This
,
261 BOOL bEnableDialogs
);
264 NineDevice9_SetGammaRamp( struct NineDevice9
*This
,
267 const D3DGAMMARAMP
*pRamp
);
270 NineDevice9_GetGammaRamp( struct NineDevice9
*This
,
272 D3DGAMMARAMP
*pRamp
);
275 NineDevice9_CreateTexture( struct NineDevice9
*This
,
282 IDirect3DTexture9
**ppTexture
,
283 HANDLE
*pSharedHandle
);
286 NineDevice9_CreateVolumeTexture( struct NineDevice9
*This
,
294 IDirect3DVolumeTexture9
**ppVolumeTexture
,
295 HANDLE
*pSharedHandle
);
298 NineDevice9_CreateCubeTexture( struct NineDevice9
*This
,
304 IDirect3DCubeTexture9
**ppCubeTexture
,
305 HANDLE
*pSharedHandle
);
308 NineDevice9_CreateVertexBuffer( struct NineDevice9
*This
,
313 IDirect3DVertexBuffer9
**ppVertexBuffer
,
314 HANDLE
*pSharedHandle
);
317 NineDevice9_CreateIndexBuffer( struct NineDevice9
*This
,
322 IDirect3DIndexBuffer9
**ppIndexBuffer
,
323 HANDLE
*pSharedHandle
);
326 NineDevice9_CreateRenderTarget( struct NineDevice9
*This
,
330 D3DMULTISAMPLE_TYPE MultiSample
,
331 DWORD MultisampleQuality
,
333 IDirect3DSurface9
**ppSurface
,
334 HANDLE
*pSharedHandle
);
337 NineDevice9_CreateDepthStencilSurface( struct NineDevice9
*This
,
341 D3DMULTISAMPLE_TYPE MultiSample
,
342 DWORD MultisampleQuality
,
344 IDirect3DSurface9
**ppSurface
,
345 HANDLE
*pSharedHandle
);
348 NineDevice9_UpdateSurface( struct NineDevice9
*This
,
349 IDirect3DSurface9
*pSourceSurface
,
350 const RECT
*pSourceRect
,
351 IDirect3DSurface9
*pDestinationSurface
,
352 const POINT
*pDestPoint
);
355 NineDevice9_UpdateTexture( struct NineDevice9
*This
,
356 IDirect3DBaseTexture9
*pSourceTexture
,
357 IDirect3DBaseTexture9
*pDestinationTexture
);
360 NineDevice9_GetRenderTargetData( struct NineDevice9
*This
,
361 IDirect3DSurface9
*pRenderTarget
,
362 IDirect3DSurface9
*pDestSurface
);
365 NineDevice9_GetFrontBufferData( struct NineDevice9
*This
,
367 IDirect3DSurface9
*pDestSurface
);
370 NineDevice9_StretchRect( struct NineDevice9
*This
,
371 IDirect3DSurface9
*pSourceSurface
,
372 const RECT
*pSourceRect
,
373 IDirect3DSurface9
*pDestSurface
,
374 const RECT
*pDestRect
,
375 D3DTEXTUREFILTERTYPE Filter
);
378 NineDevice9_ColorFill( struct NineDevice9
*This
,
379 IDirect3DSurface9
*pSurface
,
384 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9
*This
,
389 IDirect3DSurface9
**ppSurface
,
390 HANDLE
*pSharedHandle
);
393 NineDevice9_SetRenderTarget( struct NineDevice9
*This
,
394 DWORD RenderTargetIndex
,
395 IDirect3DSurface9
*pRenderTarget
);
398 NineDevice9_GetRenderTarget( struct NineDevice9
*This
,
399 DWORD RenderTargetIndex
,
400 IDirect3DSurface9
**ppRenderTarget
);
403 NineDevice9_SetDepthStencilSurface( struct NineDevice9
*This
,
404 IDirect3DSurface9
*pNewZStencil
);
407 NineDevice9_GetDepthStencilSurface( struct NineDevice9
*This
,
408 IDirect3DSurface9
**ppZStencilSurface
);
411 NineDevice9_BeginScene( struct NineDevice9
*This
);
414 NineDevice9_EndScene( struct NineDevice9
*This
);
417 NineDevice9_Clear( struct NineDevice9
*This
,
419 const D3DRECT
*pRects
,
426 NineDevice9_SetTransform( struct NineDevice9
*This
,
427 D3DTRANSFORMSTATETYPE State
,
428 const D3DMATRIX
*pMatrix
);
431 NineDevice9_GetTransform( struct NineDevice9
*This
,
432 D3DTRANSFORMSTATETYPE State
,
433 D3DMATRIX
*pMatrix
);
436 NineDevice9_MultiplyTransform( struct NineDevice9
*This
,
437 D3DTRANSFORMSTATETYPE State
,
438 const D3DMATRIX
*pMatrix
);
441 NineDevice9_SetViewport( struct NineDevice9
*This
,
442 const D3DVIEWPORT9
*pViewport
);
445 NineDevice9_GetViewport( struct NineDevice9
*This
,
446 D3DVIEWPORT9
*pViewport
);
449 NineDevice9_SetMaterial( struct NineDevice9
*This
,
450 const D3DMATERIAL9
*pMaterial
);
453 NineDevice9_GetMaterial( struct NineDevice9
*This
,
454 D3DMATERIAL9
*pMaterial
);
457 NineDevice9_SetLight( struct NineDevice9
*This
,
459 const D3DLIGHT9
*pLight
);
462 NineDevice9_GetLight( struct NineDevice9
*This
,
467 NineDevice9_LightEnable( struct NineDevice9
*This
,
472 NineDevice9_GetLightEnable( struct NineDevice9
*This
,
477 NineDevice9_SetClipPlane( struct NineDevice9
*This
,
479 const float *pPlane
);
482 NineDevice9_GetClipPlane( struct NineDevice9
*This
,
487 NineDevice9_SetRenderState( struct NineDevice9
*This
,
488 D3DRENDERSTATETYPE State
,
492 NineDevice9_GetRenderState( struct NineDevice9
*This
,
493 D3DRENDERSTATETYPE State
,
497 NineDevice9_CreateStateBlock( struct NineDevice9
*This
,
498 D3DSTATEBLOCKTYPE Type
,
499 IDirect3DStateBlock9
**ppSB
);
502 NineDevice9_BeginStateBlock( struct NineDevice9
*This
);
505 NineDevice9_EndStateBlock( struct NineDevice9
*This
,
506 IDirect3DStateBlock9
**ppSB
);
509 NineDevice9_SetClipStatus( struct NineDevice9
*This
,
510 const D3DCLIPSTATUS9
*pClipStatus
);
513 NineDevice9_GetClipStatus( struct NineDevice9
*This
,
514 D3DCLIPSTATUS9
*pClipStatus
);
517 NineDevice9_GetTexture( struct NineDevice9
*This
,
519 IDirect3DBaseTexture9
**ppTexture
);
522 NineDevice9_SetTexture( struct NineDevice9
*This
,
524 IDirect3DBaseTexture9
*pTexture
);
527 NineDevice9_GetTextureStageState( struct NineDevice9
*This
,
529 D3DTEXTURESTAGESTATETYPE Type
,
533 NineDevice9_SetTextureStageState( struct NineDevice9
*This
,
535 D3DTEXTURESTAGESTATETYPE Type
,
539 NineDevice9_GetSamplerState( struct NineDevice9
*This
,
541 D3DSAMPLERSTATETYPE Type
,
545 NineDevice9_SetSamplerState( struct NineDevice9
*This
,
547 D3DSAMPLERSTATETYPE Type
,
551 NineDevice9_ValidateDevice( struct NineDevice9
*This
,
555 NineDevice9_SetPaletteEntries( struct NineDevice9
*This
,
557 const PALETTEENTRY
*pEntries
);
560 NineDevice9_GetPaletteEntries( struct NineDevice9
*This
,
562 PALETTEENTRY
*pEntries
);
565 NineDevice9_SetCurrentTexturePalette( struct NineDevice9
*This
,
566 UINT PaletteNumber
);
569 NineDevice9_GetCurrentTexturePalette( struct NineDevice9
*This
,
570 UINT
*PaletteNumber
);
573 NineDevice9_SetScissorRect( struct NineDevice9
*This
,
577 NineDevice9_GetScissorRect( struct NineDevice9
*This
,
581 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9
*This
,
585 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9
*This
);
588 NineDevice9_SetNPatchMode( struct NineDevice9
*This
,
592 NineDevice9_GetNPatchMode( struct NineDevice9
*This
);
595 NineDevice9_DrawPrimitive( struct NineDevice9
*This
,
596 D3DPRIMITIVETYPE PrimitiveType
,
598 UINT PrimitiveCount
);
601 NineDevice9_DrawIndexedPrimitive( struct NineDevice9
*This
,
602 D3DPRIMITIVETYPE PrimitiveType
,
610 NineDevice9_DrawPrimitiveUP( struct NineDevice9
*This
,
611 D3DPRIMITIVETYPE PrimitiveType
,
613 const void *pVertexStreamZeroData
,
614 UINT VertexStreamZeroStride
);
617 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9
*This
,
618 D3DPRIMITIVETYPE PrimitiveType
,
622 const void *pIndexData
,
623 D3DFORMAT IndexDataFormat
,
624 const void *pVertexStreamZeroData
,
625 UINT VertexStreamZeroStride
);
628 NineDevice9_ProcessVertices( struct NineDevice9
*This
,
632 IDirect3DVertexBuffer9
*pDestBuffer
,
633 IDirect3DVertexDeclaration9
*pVertexDecl
,
637 NineDevice9_CreateVertexDeclaration( struct NineDevice9
*This
,
638 const D3DVERTEXELEMENT9
*pVertexElements
,
639 IDirect3DVertexDeclaration9
**ppDecl
);
642 NineDevice9_SetVertexDeclaration( struct NineDevice9
*This
,
643 IDirect3DVertexDeclaration9
*pDecl
);
646 NineDevice9_GetVertexDeclaration( struct NineDevice9
*This
,
647 IDirect3DVertexDeclaration9
**ppDecl
);
650 NineDevice9_SetFVF( struct NineDevice9
*This
,
654 NineDevice9_GetFVF( struct NineDevice9
*This
,
658 NineDevice9_CreateVertexShader( struct NineDevice9
*This
,
659 const DWORD
*pFunction
,
660 IDirect3DVertexShader9
**ppShader
);
663 NineDevice9_SetVertexShader( struct NineDevice9
*This
,
664 IDirect3DVertexShader9
*pShader
);
667 NineDevice9_GetVertexShader( struct NineDevice9
*This
,
668 IDirect3DVertexShader9
**ppShader
);
671 NineDevice9_SetVertexShaderConstantF( struct NineDevice9
*This
,
673 const float *pConstantData
,
674 UINT Vector4fCount
);
677 NineDevice9_GetVertexShaderConstantF( struct NineDevice9
*This
,
679 float *pConstantData
,
680 UINT Vector4fCount
);
683 NineDevice9_SetVertexShaderConstantI( struct NineDevice9
*This
,
685 const int *pConstantData
,
686 UINT Vector4iCount
);
689 NineDevice9_GetVertexShaderConstantI( struct NineDevice9
*This
,
692 UINT Vector4iCount
);
695 NineDevice9_SetVertexShaderConstantB( struct NineDevice9
*This
,
697 const BOOL
*pConstantData
,
701 NineDevice9_GetVertexShaderConstantB( struct NineDevice9
*This
,
707 NineDevice9_SetStreamSource( struct NineDevice9
*This
,
709 IDirect3DVertexBuffer9
*pStreamData
,
714 NineDevice9_GetStreamSource( struct NineDevice9
*This
,
716 IDirect3DVertexBuffer9
**ppStreamData
,
717 UINT
*pOffsetInBytes
,
721 NineDevice9_SetStreamSourceFreq( struct NineDevice9
*This
,
726 NineDevice9_GetStreamSourceFreq( struct NineDevice9
*This
,
731 NineDevice9_SetIndices( struct NineDevice9
*This
,
732 IDirect3DIndexBuffer9
*pIndexData
);
735 NineDevice9_GetIndices( struct NineDevice9
*This
,
736 IDirect3DIndexBuffer9
**ppIndexData
/*,
737 UINT *pBaseVertexIndex */ );
740 NineDevice9_CreatePixelShader( struct NineDevice9
*This
,
741 const DWORD
*pFunction
,
742 IDirect3DPixelShader9
**ppShader
);
745 NineDevice9_SetPixelShader( struct NineDevice9
*This
,
746 IDirect3DPixelShader9
*pShader
);
749 NineDevice9_GetPixelShader( struct NineDevice9
*This
,
750 IDirect3DPixelShader9
**ppShader
);
753 NineDevice9_SetPixelShaderConstantF( struct NineDevice9
*This
,
755 const float *pConstantData
,
756 UINT Vector4fCount
);
759 NineDevice9_GetPixelShaderConstantF( struct NineDevice9
*This
,
761 float *pConstantData
,
762 UINT Vector4fCount
);
765 NineDevice9_SetPixelShaderConstantI( struct NineDevice9
*This
,
767 const int *pConstantData
,
768 UINT Vector4iCount
);
771 NineDevice9_GetPixelShaderConstantI( struct NineDevice9
*This
,
774 UINT Vector4iCount
);
777 NineDevice9_SetPixelShaderConstantB( struct NineDevice9
*This
,
779 const BOOL
*pConstantData
,
783 NineDevice9_GetPixelShaderConstantB( struct NineDevice9
*This
,
789 NineDevice9_DrawRectPatch( struct NineDevice9
*This
,
791 const float *pNumSegs
,
792 const D3DRECTPATCH_INFO
*pRectPatchInfo
);
795 NineDevice9_DrawTriPatch( struct NineDevice9
*This
,
797 const float *pNumSegs
,
798 const D3DTRIPATCH_INFO
*pTriPatchInfo
);
801 NineDevice9_DeletePatch( struct NineDevice9
*This
,
805 NineDevice9_CreateQuery( struct NineDevice9
*This
,
807 IDirect3DQuery9
**ppQuery
);
809 #endif /* _NINE_DEVICE9_H_ */