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/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
;
72 struct list_head managed_textures
;
77 boolean prefer_user_constbuf
;
79 struct pipe_resource
*constbuf_vs
;
80 struct pipe_resource
*constbuf_ps
;
81 uint16_t vs_const_size
;
82 uint16_t ps_const_size
;
83 uint16_t max_vs_const_f
;
84 uint16_t max_ps_const_f
;
86 struct pipe_resource
*dummy_texture
;
87 struct pipe_sampler_view
*dummy_sampler_view
;
88 struct pipe_sampler_state dummy_sampler_state
;
90 struct gen_mipmap_state
*gen_mipmap
;
93 struct util_hash_table
*ht_vs
;
94 struct util_hash_table
*ht_ps
;
95 struct NineVertexShader9
*vs
;
96 struct NinePixelShader9
*ps
;
102 struct util_hash_table
*ht_fvf
;
106 struct pipe_resource
*image
;
109 POINT hotspot
; /* -1, -1 if no cursor image set */
119 boolean window_space_position_support
;
125 boolean buggy_barycentrics
;
128 struct u_upload_mgr
*vertex_uploader
;
129 struct u_upload_mgr
*index_uploader
;
130 struct u_upload_mgr
*constbuf_uploader
;
132 struct nine_range_pool range_pool
;
134 struct hud_context
*hud
; /* NULL if hud is disabled */
136 /* dummy vbo (containing 0 0 0 0) to bind if vertex shader input
137 * is not bound to anything by the vertex declaration */
138 struct pipe_resource
*dummy_vbo
;
140 static inline struct NineDevice9
*
141 NineDevice9( void *data
)
143 return (struct NineDevice9
*)data
;
147 NineDevice9_new( struct pipe_screen
*pScreen
,
148 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
150 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
152 ID3DPresentGroup
*pPresentationGroup
,
153 struct d3dadapter9_context
*pCTX
,
155 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
156 struct NineDevice9
**ppOut
);
159 NineDevice9_ctor( struct NineDevice9
*This
,
160 struct NineUnknownParams
*pParams
,
161 struct pipe_screen
*pScreen
,
162 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
164 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
166 ID3DPresentGroup
*pPresentationGroup
,
167 struct d3dadapter9_context
*pCTX
,
169 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
172 NineDevice9_dtor( struct NineDevice9
*This
);
174 /*** Nine private ***/
177 NineDevice9_GetScreen( struct NineDevice9
*This
);
179 struct pipe_context
*
180 NineDevice9_GetPipe( struct NineDevice9
*This
);
183 NineDevice9_GetCSO( struct NineDevice9
*This
);
186 NineDevice9_GetCaps( struct NineDevice9
*This
);
188 /*** Direct3D public ***/
191 NineDevice9_TestCooperativeLevel( struct NineDevice9
*This
);
194 NineDevice9_GetAvailableTextureMem( struct NineDevice9
*This
);
197 NineDevice9_EvictManagedResources( struct NineDevice9
*This
);
200 NineDevice9_GetDirect3D( struct NineDevice9
*This
,
201 IDirect3D9
**ppD3D9
);
204 NineDevice9_GetDeviceCaps( struct NineDevice9
*This
,
208 NineDevice9_GetDisplayMode( struct NineDevice9
*This
,
210 D3DDISPLAYMODE
*pMode
);
213 NineDevice9_GetCreationParameters( struct NineDevice9
*This
,
214 D3DDEVICE_CREATION_PARAMETERS
*pParameters
);
217 NineDevice9_SetCursorProperties( struct NineDevice9
*This
,
220 IDirect3DSurface9
*pCursorBitmap
);
223 NineDevice9_SetCursorPosition( struct NineDevice9
*This
,
229 NineDevice9_ShowCursor( struct NineDevice9
*This
,
233 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9
*This
,
234 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
235 IDirect3DSwapChain9
**pSwapChain
);
238 NineDevice9_GetSwapChain( struct NineDevice9
*This
,
240 IDirect3DSwapChain9
**pSwapChain
);
243 NineDevice9_GetNumberOfSwapChains( struct NineDevice9
*This
);
246 NineDevice9_Reset( struct NineDevice9
*This
,
247 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
250 NineDevice9_Present( struct NineDevice9
*This
,
251 const RECT
*pSourceRect
,
252 const RECT
*pDestRect
,
253 HWND hDestWindowOverride
,
254 const RGNDATA
*pDirtyRegion
);
257 NineDevice9_GetBackBuffer( struct NineDevice9
*This
,
260 D3DBACKBUFFER_TYPE Type
,
261 IDirect3DSurface9
**ppBackBuffer
);
264 NineDevice9_GetRasterStatus( struct NineDevice9
*This
,
266 D3DRASTER_STATUS
*pRasterStatus
);
269 NineDevice9_SetDialogBoxMode( struct NineDevice9
*This
,
270 BOOL bEnableDialogs
);
273 NineDevice9_SetGammaRamp( struct NineDevice9
*This
,
276 const D3DGAMMARAMP
*pRamp
);
279 NineDevice9_GetGammaRamp( struct NineDevice9
*This
,
281 D3DGAMMARAMP
*pRamp
);
284 NineDevice9_CreateTexture( struct NineDevice9
*This
,
291 IDirect3DTexture9
**ppTexture
,
292 HANDLE
*pSharedHandle
);
295 NineDevice9_CreateVolumeTexture( struct NineDevice9
*This
,
303 IDirect3DVolumeTexture9
**ppVolumeTexture
,
304 HANDLE
*pSharedHandle
);
307 NineDevice9_CreateCubeTexture( struct NineDevice9
*This
,
313 IDirect3DCubeTexture9
**ppCubeTexture
,
314 HANDLE
*pSharedHandle
);
317 NineDevice9_CreateVertexBuffer( struct NineDevice9
*This
,
322 IDirect3DVertexBuffer9
**ppVertexBuffer
,
323 HANDLE
*pSharedHandle
);
326 NineDevice9_CreateIndexBuffer( struct NineDevice9
*This
,
331 IDirect3DIndexBuffer9
**ppIndexBuffer
,
332 HANDLE
*pSharedHandle
);
335 NineDevice9_CreateRenderTarget( struct NineDevice9
*This
,
339 D3DMULTISAMPLE_TYPE MultiSample
,
340 DWORD MultisampleQuality
,
342 IDirect3DSurface9
**ppSurface
,
343 HANDLE
*pSharedHandle
);
346 NineDevice9_CreateDepthStencilSurface( struct NineDevice9
*This
,
350 D3DMULTISAMPLE_TYPE MultiSample
,
351 DWORD MultisampleQuality
,
353 IDirect3DSurface9
**ppSurface
,
354 HANDLE
*pSharedHandle
);
357 NineDevice9_UpdateSurface( struct NineDevice9
*This
,
358 IDirect3DSurface9
*pSourceSurface
,
359 const RECT
*pSourceRect
,
360 IDirect3DSurface9
*pDestinationSurface
,
361 const POINT
*pDestPoint
);
364 NineDevice9_UpdateTexture( struct NineDevice9
*This
,
365 IDirect3DBaseTexture9
*pSourceTexture
,
366 IDirect3DBaseTexture9
*pDestinationTexture
);
369 NineDevice9_GetRenderTargetData( struct NineDevice9
*This
,
370 IDirect3DSurface9
*pRenderTarget
,
371 IDirect3DSurface9
*pDestSurface
);
374 NineDevice9_GetFrontBufferData( struct NineDevice9
*This
,
376 IDirect3DSurface9
*pDestSurface
);
379 NineDevice9_StretchRect( struct NineDevice9
*This
,
380 IDirect3DSurface9
*pSourceSurface
,
381 const RECT
*pSourceRect
,
382 IDirect3DSurface9
*pDestSurface
,
383 const RECT
*pDestRect
,
384 D3DTEXTUREFILTERTYPE Filter
);
387 NineDevice9_ColorFill( struct NineDevice9
*This
,
388 IDirect3DSurface9
*pSurface
,
393 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9
*This
,
398 IDirect3DSurface9
**ppSurface
,
399 HANDLE
*pSharedHandle
);
402 NineDevice9_SetRenderTarget( struct NineDevice9
*This
,
403 DWORD RenderTargetIndex
,
404 IDirect3DSurface9
*pRenderTarget
);
407 NineDevice9_GetRenderTarget( struct NineDevice9
*This
,
408 DWORD RenderTargetIndex
,
409 IDirect3DSurface9
**ppRenderTarget
);
412 NineDevice9_SetDepthStencilSurface( struct NineDevice9
*This
,
413 IDirect3DSurface9
*pNewZStencil
);
416 NineDevice9_GetDepthStencilSurface( struct NineDevice9
*This
,
417 IDirect3DSurface9
**ppZStencilSurface
);
420 NineDevice9_BeginScene( struct NineDevice9
*This
);
423 NineDevice9_EndScene( struct NineDevice9
*This
);
426 NineDevice9_Clear( struct NineDevice9
*This
,
428 const D3DRECT
*pRects
,
435 NineDevice9_SetTransform( struct NineDevice9
*This
,
436 D3DTRANSFORMSTATETYPE State
,
437 const D3DMATRIX
*pMatrix
);
440 NineDevice9_GetTransform( struct NineDevice9
*This
,
441 D3DTRANSFORMSTATETYPE State
,
442 D3DMATRIX
*pMatrix
);
445 NineDevice9_MultiplyTransform( struct NineDevice9
*This
,
446 D3DTRANSFORMSTATETYPE State
,
447 const D3DMATRIX
*pMatrix
);
450 NineDevice9_SetViewport( struct NineDevice9
*This
,
451 const D3DVIEWPORT9
*pViewport
);
454 NineDevice9_GetViewport( struct NineDevice9
*This
,
455 D3DVIEWPORT9
*pViewport
);
458 NineDevice9_SetMaterial( struct NineDevice9
*This
,
459 const D3DMATERIAL9
*pMaterial
);
462 NineDevice9_GetMaterial( struct NineDevice9
*This
,
463 D3DMATERIAL9
*pMaterial
);
466 NineDevice9_SetLight( struct NineDevice9
*This
,
468 const D3DLIGHT9
*pLight
);
471 NineDevice9_GetLight( struct NineDevice9
*This
,
476 NineDevice9_LightEnable( struct NineDevice9
*This
,
481 NineDevice9_GetLightEnable( struct NineDevice9
*This
,
486 NineDevice9_SetClipPlane( struct NineDevice9
*This
,
488 const float *pPlane
);
491 NineDevice9_GetClipPlane( struct NineDevice9
*This
,
496 NineDevice9_SetRenderState( struct NineDevice9
*This
,
497 D3DRENDERSTATETYPE State
,
501 NineDevice9_GetRenderState( struct NineDevice9
*This
,
502 D3DRENDERSTATETYPE State
,
506 NineDevice9_CreateStateBlock( struct NineDevice9
*This
,
507 D3DSTATEBLOCKTYPE Type
,
508 IDirect3DStateBlock9
**ppSB
);
511 NineDevice9_BeginStateBlock( struct NineDevice9
*This
);
514 NineDevice9_EndStateBlock( struct NineDevice9
*This
,
515 IDirect3DStateBlock9
**ppSB
);
518 NineDevice9_SetClipStatus( struct NineDevice9
*This
,
519 const D3DCLIPSTATUS9
*pClipStatus
);
522 NineDevice9_GetClipStatus( struct NineDevice9
*This
,
523 D3DCLIPSTATUS9
*pClipStatus
);
526 NineDevice9_GetTexture( struct NineDevice9
*This
,
528 IDirect3DBaseTexture9
**ppTexture
);
531 NineDevice9_SetTexture( struct NineDevice9
*This
,
533 IDirect3DBaseTexture9
*pTexture
);
536 NineDevice9_GetTextureStageState( struct NineDevice9
*This
,
538 D3DTEXTURESTAGESTATETYPE Type
,
542 NineDevice9_SetTextureStageState( struct NineDevice9
*This
,
544 D3DTEXTURESTAGESTATETYPE Type
,
548 NineDevice9_GetSamplerState( struct NineDevice9
*This
,
550 D3DSAMPLERSTATETYPE Type
,
554 NineDevice9_SetSamplerState( struct NineDevice9
*This
,
556 D3DSAMPLERSTATETYPE Type
,
560 NineDevice9_ValidateDevice( struct NineDevice9
*This
,
564 NineDevice9_SetPaletteEntries( struct NineDevice9
*This
,
566 const PALETTEENTRY
*pEntries
);
569 NineDevice9_GetPaletteEntries( struct NineDevice9
*This
,
571 PALETTEENTRY
*pEntries
);
574 NineDevice9_SetCurrentTexturePalette( struct NineDevice9
*This
,
575 UINT PaletteNumber
);
578 NineDevice9_GetCurrentTexturePalette( struct NineDevice9
*This
,
579 UINT
*PaletteNumber
);
582 NineDevice9_SetScissorRect( struct NineDevice9
*This
,
586 NineDevice9_GetScissorRect( struct NineDevice9
*This
,
590 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9
*This
,
594 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9
*This
);
597 NineDevice9_SetNPatchMode( struct NineDevice9
*This
,
601 NineDevice9_GetNPatchMode( struct NineDevice9
*This
);
604 NineDevice9_DrawPrimitive( struct NineDevice9
*This
,
605 D3DPRIMITIVETYPE PrimitiveType
,
607 UINT PrimitiveCount
);
610 NineDevice9_DrawIndexedPrimitive( struct NineDevice9
*This
,
611 D3DPRIMITIVETYPE PrimitiveType
,
619 NineDevice9_DrawPrimitiveUP( struct NineDevice9
*This
,
620 D3DPRIMITIVETYPE PrimitiveType
,
622 const void *pVertexStreamZeroData
,
623 UINT VertexStreamZeroStride
);
626 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9
*This
,
627 D3DPRIMITIVETYPE PrimitiveType
,
631 const void *pIndexData
,
632 D3DFORMAT IndexDataFormat
,
633 const void *pVertexStreamZeroData
,
634 UINT VertexStreamZeroStride
);
637 NineDevice9_ProcessVertices( struct NineDevice9
*This
,
641 IDirect3DVertexBuffer9
*pDestBuffer
,
642 IDirect3DVertexDeclaration9
*pVertexDecl
,
646 NineDevice9_CreateVertexDeclaration( struct NineDevice9
*This
,
647 const D3DVERTEXELEMENT9
*pVertexElements
,
648 IDirect3DVertexDeclaration9
**ppDecl
);
651 NineDevice9_SetVertexDeclaration( struct NineDevice9
*This
,
652 IDirect3DVertexDeclaration9
*pDecl
);
655 NineDevice9_GetVertexDeclaration( struct NineDevice9
*This
,
656 IDirect3DVertexDeclaration9
**ppDecl
);
659 NineDevice9_SetFVF( struct NineDevice9
*This
,
663 NineDevice9_GetFVF( struct NineDevice9
*This
,
667 NineDevice9_CreateVertexShader( struct NineDevice9
*This
,
668 const DWORD
*pFunction
,
669 IDirect3DVertexShader9
**ppShader
);
672 NineDevice9_SetVertexShader( struct NineDevice9
*This
,
673 IDirect3DVertexShader9
*pShader
);
676 NineDevice9_GetVertexShader( struct NineDevice9
*This
,
677 IDirect3DVertexShader9
**ppShader
);
680 NineDevice9_SetVertexShaderConstantF( struct NineDevice9
*This
,
682 const float *pConstantData
,
683 UINT Vector4fCount
);
686 NineDevice9_GetVertexShaderConstantF( struct NineDevice9
*This
,
688 float *pConstantData
,
689 UINT Vector4fCount
);
692 NineDevice9_SetVertexShaderConstantI( struct NineDevice9
*This
,
694 const int *pConstantData
,
695 UINT Vector4iCount
);
698 NineDevice9_GetVertexShaderConstantI( struct NineDevice9
*This
,
701 UINT Vector4iCount
);
704 NineDevice9_SetVertexShaderConstantB( struct NineDevice9
*This
,
706 const BOOL
*pConstantData
,
710 NineDevice9_GetVertexShaderConstantB( struct NineDevice9
*This
,
716 NineDevice9_SetStreamSource( struct NineDevice9
*This
,
718 IDirect3DVertexBuffer9
*pStreamData
,
723 NineDevice9_GetStreamSource( struct NineDevice9
*This
,
725 IDirect3DVertexBuffer9
**ppStreamData
,
726 UINT
*pOffsetInBytes
,
730 NineDevice9_SetStreamSourceFreq( struct NineDevice9
*This
,
735 NineDevice9_GetStreamSourceFreq( struct NineDevice9
*This
,
740 NineDevice9_SetIndices( struct NineDevice9
*This
,
741 IDirect3DIndexBuffer9
*pIndexData
);
744 NineDevice9_GetIndices( struct NineDevice9
*This
,
745 IDirect3DIndexBuffer9
**ppIndexData
/*,
746 UINT *pBaseVertexIndex */ );
749 NineDevice9_CreatePixelShader( struct NineDevice9
*This
,
750 const DWORD
*pFunction
,
751 IDirect3DPixelShader9
**ppShader
);
754 NineDevice9_SetPixelShader( struct NineDevice9
*This
,
755 IDirect3DPixelShader9
*pShader
);
758 NineDevice9_GetPixelShader( struct NineDevice9
*This
,
759 IDirect3DPixelShader9
**ppShader
);
762 NineDevice9_SetPixelShaderConstantF( struct NineDevice9
*This
,
764 const float *pConstantData
,
765 UINT Vector4fCount
);
768 NineDevice9_GetPixelShaderConstantF( struct NineDevice9
*This
,
770 float *pConstantData
,
771 UINT Vector4fCount
);
774 NineDevice9_SetPixelShaderConstantI( struct NineDevice9
*This
,
776 const int *pConstantData
,
777 UINT Vector4iCount
);
780 NineDevice9_GetPixelShaderConstantI( struct NineDevice9
*This
,
783 UINT Vector4iCount
);
786 NineDevice9_SetPixelShaderConstantB( struct NineDevice9
*This
,
788 const BOOL
*pConstantData
,
792 NineDevice9_GetPixelShaderConstantB( struct NineDevice9
*This
,
798 NineDevice9_DrawRectPatch( struct NineDevice9
*This
,
800 const float *pNumSegs
,
801 const D3DRECTPATCH_INFO
*pRectPatchInfo
);
804 NineDevice9_DrawTriPatch( struct NineDevice9
*This
,
806 const float *pNumSegs
,
807 const D3DTRIPATCH_INFO
*pTriPatchInfo
);
810 NineDevice9_DeletePatch( struct NineDevice9
*This
,
814 NineDevice9_CreateQuery( struct NineDevice9
*This
,
816 IDirect3DQuery9
**ppQuery
);
818 #endif /* _NINE_DEVICE9_H_ */