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
;
131 unsigned constbuf_alignment
;
133 struct nine_range_pool range_pool
;
135 struct hud_context
*hud
; /* NULL if hud is disabled */
137 /* dummy vbo (containing 0 0 0 0) to bind if vertex shader input
138 * is not bound to anything by the vertex declaration */
139 struct pipe_resource
*dummy_vbo
;
141 static inline struct NineDevice9
*
142 NineDevice9( void *data
)
144 return (struct NineDevice9
*)data
;
148 NineDevice9_new( struct pipe_screen
*pScreen
,
149 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
151 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
153 ID3DPresentGroup
*pPresentationGroup
,
154 struct d3dadapter9_context
*pCTX
,
156 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
157 struct NineDevice9
**ppOut
);
160 NineDevice9_ctor( struct NineDevice9
*This
,
161 struct NineUnknownParams
*pParams
,
162 struct pipe_screen
*pScreen
,
163 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
165 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
167 ID3DPresentGroup
*pPresentationGroup
,
168 struct d3dadapter9_context
*pCTX
,
170 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
173 NineDevice9_dtor( struct NineDevice9
*This
);
175 /*** Nine private ***/
178 NineDevice9_GetScreen( struct NineDevice9
*This
);
180 struct pipe_context
*
181 NineDevice9_GetPipe( struct NineDevice9
*This
);
184 NineDevice9_GetCSO( struct NineDevice9
*This
);
187 NineDevice9_GetCaps( struct NineDevice9
*This
);
189 /*** Direct3D public ***/
192 NineDevice9_TestCooperativeLevel( struct NineDevice9
*This
);
195 NineDevice9_GetAvailableTextureMem( struct NineDevice9
*This
);
198 NineDevice9_EvictManagedResources( struct NineDevice9
*This
);
201 NineDevice9_GetDirect3D( struct NineDevice9
*This
,
202 IDirect3D9
**ppD3D9
);
205 NineDevice9_GetDeviceCaps( struct NineDevice9
*This
,
209 NineDevice9_GetDisplayMode( struct NineDevice9
*This
,
211 D3DDISPLAYMODE
*pMode
);
214 NineDevice9_GetCreationParameters( struct NineDevice9
*This
,
215 D3DDEVICE_CREATION_PARAMETERS
*pParameters
);
218 NineDevice9_SetCursorProperties( struct NineDevice9
*This
,
221 IDirect3DSurface9
*pCursorBitmap
);
224 NineDevice9_SetCursorPosition( struct NineDevice9
*This
,
230 NineDevice9_ShowCursor( struct NineDevice9
*This
,
234 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9
*This
,
235 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
236 IDirect3DSwapChain9
**pSwapChain
);
239 NineDevice9_GetSwapChain( struct NineDevice9
*This
,
241 IDirect3DSwapChain9
**pSwapChain
);
244 NineDevice9_GetNumberOfSwapChains( struct NineDevice9
*This
);
247 NineDevice9_Reset( struct NineDevice9
*This
,
248 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
251 NineDevice9_Present( struct NineDevice9
*This
,
252 const RECT
*pSourceRect
,
253 const RECT
*pDestRect
,
254 HWND hDestWindowOverride
,
255 const RGNDATA
*pDirtyRegion
);
258 NineDevice9_GetBackBuffer( struct NineDevice9
*This
,
261 D3DBACKBUFFER_TYPE Type
,
262 IDirect3DSurface9
**ppBackBuffer
);
265 NineDevice9_GetRasterStatus( struct NineDevice9
*This
,
267 D3DRASTER_STATUS
*pRasterStatus
);
270 NineDevice9_SetDialogBoxMode( struct NineDevice9
*This
,
271 BOOL bEnableDialogs
);
274 NineDevice9_SetGammaRamp( struct NineDevice9
*This
,
277 const D3DGAMMARAMP
*pRamp
);
280 NineDevice9_GetGammaRamp( struct NineDevice9
*This
,
282 D3DGAMMARAMP
*pRamp
);
285 NineDevice9_CreateTexture( struct NineDevice9
*This
,
292 IDirect3DTexture9
**ppTexture
,
293 HANDLE
*pSharedHandle
);
296 NineDevice9_CreateVolumeTexture( struct NineDevice9
*This
,
304 IDirect3DVolumeTexture9
**ppVolumeTexture
,
305 HANDLE
*pSharedHandle
);
308 NineDevice9_CreateCubeTexture( struct NineDevice9
*This
,
314 IDirect3DCubeTexture9
**ppCubeTexture
,
315 HANDLE
*pSharedHandle
);
318 NineDevice9_CreateVertexBuffer( struct NineDevice9
*This
,
323 IDirect3DVertexBuffer9
**ppVertexBuffer
,
324 HANDLE
*pSharedHandle
);
327 NineDevice9_CreateIndexBuffer( struct NineDevice9
*This
,
332 IDirect3DIndexBuffer9
**ppIndexBuffer
,
333 HANDLE
*pSharedHandle
);
336 NineDevice9_CreateRenderTarget( struct NineDevice9
*This
,
340 D3DMULTISAMPLE_TYPE MultiSample
,
341 DWORD MultisampleQuality
,
343 IDirect3DSurface9
**ppSurface
,
344 HANDLE
*pSharedHandle
);
347 NineDevice9_CreateDepthStencilSurface( struct NineDevice9
*This
,
351 D3DMULTISAMPLE_TYPE MultiSample
,
352 DWORD MultisampleQuality
,
354 IDirect3DSurface9
**ppSurface
,
355 HANDLE
*pSharedHandle
);
358 NineDevice9_UpdateSurface( struct NineDevice9
*This
,
359 IDirect3DSurface9
*pSourceSurface
,
360 const RECT
*pSourceRect
,
361 IDirect3DSurface9
*pDestinationSurface
,
362 const POINT
*pDestPoint
);
365 NineDevice9_UpdateTexture( struct NineDevice9
*This
,
366 IDirect3DBaseTexture9
*pSourceTexture
,
367 IDirect3DBaseTexture9
*pDestinationTexture
);
370 NineDevice9_GetRenderTargetData( struct NineDevice9
*This
,
371 IDirect3DSurface9
*pRenderTarget
,
372 IDirect3DSurface9
*pDestSurface
);
375 NineDevice9_GetFrontBufferData( struct NineDevice9
*This
,
377 IDirect3DSurface9
*pDestSurface
);
380 NineDevice9_StretchRect( struct NineDevice9
*This
,
381 IDirect3DSurface9
*pSourceSurface
,
382 const RECT
*pSourceRect
,
383 IDirect3DSurface9
*pDestSurface
,
384 const RECT
*pDestRect
,
385 D3DTEXTUREFILTERTYPE Filter
);
388 NineDevice9_ColorFill( struct NineDevice9
*This
,
389 IDirect3DSurface9
*pSurface
,
394 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9
*This
,
399 IDirect3DSurface9
**ppSurface
,
400 HANDLE
*pSharedHandle
);
403 NineDevice9_SetRenderTarget( struct NineDevice9
*This
,
404 DWORD RenderTargetIndex
,
405 IDirect3DSurface9
*pRenderTarget
);
408 NineDevice9_GetRenderTarget( struct NineDevice9
*This
,
409 DWORD RenderTargetIndex
,
410 IDirect3DSurface9
**ppRenderTarget
);
413 NineDevice9_SetDepthStencilSurface( struct NineDevice9
*This
,
414 IDirect3DSurface9
*pNewZStencil
);
417 NineDevice9_GetDepthStencilSurface( struct NineDevice9
*This
,
418 IDirect3DSurface9
**ppZStencilSurface
);
421 NineDevice9_BeginScene( struct NineDevice9
*This
);
424 NineDevice9_EndScene( struct NineDevice9
*This
);
427 NineDevice9_Clear( struct NineDevice9
*This
,
429 const D3DRECT
*pRects
,
436 NineDevice9_SetTransform( struct NineDevice9
*This
,
437 D3DTRANSFORMSTATETYPE State
,
438 const D3DMATRIX
*pMatrix
);
441 NineDevice9_GetTransform( struct NineDevice9
*This
,
442 D3DTRANSFORMSTATETYPE State
,
443 D3DMATRIX
*pMatrix
);
446 NineDevice9_MultiplyTransform( struct NineDevice9
*This
,
447 D3DTRANSFORMSTATETYPE State
,
448 const D3DMATRIX
*pMatrix
);
451 NineDevice9_SetViewport( struct NineDevice9
*This
,
452 const D3DVIEWPORT9
*pViewport
);
455 NineDevice9_GetViewport( struct NineDevice9
*This
,
456 D3DVIEWPORT9
*pViewport
);
459 NineDevice9_SetMaterial( struct NineDevice9
*This
,
460 const D3DMATERIAL9
*pMaterial
);
463 NineDevice9_GetMaterial( struct NineDevice9
*This
,
464 D3DMATERIAL9
*pMaterial
);
467 NineDevice9_SetLight( struct NineDevice9
*This
,
469 const D3DLIGHT9
*pLight
);
472 NineDevice9_GetLight( struct NineDevice9
*This
,
477 NineDevice9_LightEnable( struct NineDevice9
*This
,
482 NineDevice9_GetLightEnable( struct NineDevice9
*This
,
487 NineDevice9_SetClipPlane( struct NineDevice9
*This
,
489 const float *pPlane
);
492 NineDevice9_GetClipPlane( struct NineDevice9
*This
,
497 NineDevice9_SetRenderState( struct NineDevice9
*This
,
498 D3DRENDERSTATETYPE State
,
502 NineDevice9_GetRenderState( struct NineDevice9
*This
,
503 D3DRENDERSTATETYPE State
,
507 NineDevice9_CreateStateBlock( struct NineDevice9
*This
,
508 D3DSTATEBLOCKTYPE Type
,
509 IDirect3DStateBlock9
**ppSB
);
512 NineDevice9_BeginStateBlock( struct NineDevice9
*This
);
515 NineDevice9_EndStateBlock( struct NineDevice9
*This
,
516 IDirect3DStateBlock9
**ppSB
);
519 NineDevice9_SetClipStatus( struct NineDevice9
*This
,
520 const D3DCLIPSTATUS9
*pClipStatus
);
523 NineDevice9_GetClipStatus( struct NineDevice9
*This
,
524 D3DCLIPSTATUS9
*pClipStatus
);
527 NineDevice9_GetTexture( struct NineDevice9
*This
,
529 IDirect3DBaseTexture9
**ppTexture
);
532 NineDevice9_SetTexture( struct NineDevice9
*This
,
534 IDirect3DBaseTexture9
*pTexture
);
537 NineDevice9_GetTextureStageState( struct NineDevice9
*This
,
539 D3DTEXTURESTAGESTATETYPE Type
,
543 NineDevice9_SetTextureStageState( struct NineDevice9
*This
,
545 D3DTEXTURESTAGESTATETYPE Type
,
549 NineDevice9_GetSamplerState( struct NineDevice9
*This
,
551 D3DSAMPLERSTATETYPE Type
,
555 NineDevice9_SetSamplerState( struct NineDevice9
*This
,
557 D3DSAMPLERSTATETYPE Type
,
561 NineDevice9_ValidateDevice( struct NineDevice9
*This
,
565 NineDevice9_SetPaletteEntries( struct NineDevice9
*This
,
567 const PALETTEENTRY
*pEntries
);
570 NineDevice9_GetPaletteEntries( struct NineDevice9
*This
,
572 PALETTEENTRY
*pEntries
);
575 NineDevice9_SetCurrentTexturePalette( struct NineDevice9
*This
,
576 UINT PaletteNumber
);
579 NineDevice9_GetCurrentTexturePalette( struct NineDevice9
*This
,
580 UINT
*PaletteNumber
);
583 NineDevice9_SetScissorRect( struct NineDevice9
*This
,
587 NineDevice9_GetScissorRect( struct NineDevice9
*This
,
591 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9
*This
,
595 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9
*This
);
598 NineDevice9_SetNPatchMode( struct NineDevice9
*This
,
602 NineDevice9_GetNPatchMode( struct NineDevice9
*This
);
605 NineDevice9_DrawPrimitive( struct NineDevice9
*This
,
606 D3DPRIMITIVETYPE PrimitiveType
,
608 UINT PrimitiveCount
);
611 NineDevice9_DrawIndexedPrimitive( struct NineDevice9
*This
,
612 D3DPRIMITIVETYPE PrimitiveType
,
620 NineDevice9_DrawPrimitiveUP( struct NineDevice9
*This
,
621 D3DPRIMITIVETYPE PrimitiveType
,
623 const void *pVertexStreamZeroData
,
624 UINT VertexStreamZeroStride
);
627 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9
*This
,
628 D3DPRIMITIVETYPE PrimitiveType
,
632 const void *pIndexData
,
633 D3DFORMAT IndexDataFormat
,
634 const void *pVertexStreamZeroData
,
635 UINT VertexStreamZeroStride
);
638 NineDevice9_ProcessVertices( struct NineDevice9
*This
,
642 IDirect3DVertexBuffer9
*pDestBuffer
,
643 IDirect3DVertexDeclaration9
*pVertexDecl
,
647 NineDevice9_CreateVertexDeclaration( struct NineDevice9
*This
,
648 const D3DVERTEXELEMENT9
*pVertexElements
,
649 IDirect3DVertexDeclaration9
**ppDecl
);
652 NineDevice9_SetVertexDeclaration( struct NineDevice9
*This
,
653 IDirect3DVertexDeclaration9
*pDecl
);
656 NineDevice9_GetVertexDeclaration( struct NineDevice9
*This
,
657 IDirect3DVertexDeclaration9
**ppDecl
);
660 NineDevice9_SetFVF( struct NineDevice9
*This
,
664 NineDevice9_GetFVF( struct NineDevice9
*This
,
668 NineDevice9_CreateVertexShader( struct NineDevice9
*This
,
669 const DWORD
*pFunction
,
670 IDirect3DVertexShader9
**ppShader
);
673 NineDevice9_SetVertexShader( struct NineDevice9
*This
,
674 IDirect3DVertexShader9
*pShader
);
677 NineDevice9_GetVertexShader( struct NineDevice9
*This
,
678 IDirect3DVertexShader9
**ppShader
);
681 NineDevice9_SetVertexShaderConstantF( struct NineDevice9
*This
,
683 const float *pConstantData
,
684 UINT Vector4fCount
);
687 NineDevice9_GetVertexShaderConstantF( struct NineDevice9
*This
,
689 float *pConstantData
,
690 UINT Vector4fCount
);
693 NineDevice9_SetVertexShaderConstantI( struct NineDevice9
*This
,
695 const int *pConstantData
,
696 UINT Vector4iCount
);
699 NineDevice9_GetVertexShaderConstantI( struct NineDevice9
*This
,
702 UINT Vector4iCount
);
705 NineDevice9_SetVertexShaderConstantB( struct NineDevice9
*This
,
707 const BOOL
*pConstantData
,
711 NineDevice9_GetVertexShaderConstantB( struct NineDevice9
*This
,
717 NineDevice9_SetStreamSource( struct NineDevice9
*This
,
719 IDirect3DVertexBuffer9
*pStreamData
,
724 NineDevice9_GetStreamSource( struct NineDevice9
*This
,
726 IDirect3DVertexBuffer9
**ppStreamData
,
727 UINT
*pOffsetInBytes
,
731 NineDevice9_SetStreamSourceFreq( struct NineDevice9
*This
,
736 NineDevice9_GetStreamSourceFreq( struct NineDevice9
*This
,
741 NineDevice9_SetIndices( struct NineDevice9
*This
,
742 IDirect3DIndexBuffer9
*pIndexData
);
745 NineDevice9_GetIndices( struct NineDevice9
*This
,
746 IDirect3DIndexBuffer9
**ppIndexData
/*,
747 UINT *pBaseVertexIndex */ );
750 NineDevice9_CreatePixelShader( struct NineDevice9
*This
,
751 const DWORD
*pFunction
,
752 IDirect3DPixelShader9
**ppShader
);
755 NineDevice9_SetPixelShader( struct NineDevice9
*This
,
756 IDirect3DPixelShader9
*pShader
);
759 NineDevice9_GetPixelShader( struct NineDevice9
*This
,
760 IDirect3DPixelShader9
**ppShader
);
763 NineDevice9_SetPixelShaderConstantF( struct NineDevice9
*This
,
765 const float *pConstantData
,
766 UINT Vector4fCount
);
769 NineDevice9_GetPixelShaderConstantF( struct NineDevice9
*This
,
771 float *pConstantData
,
772 UINT Vector4fCount
);
775 NineDevice9_SetPixelShaderConstantI( struct NineDevice9
*This
,
777 const int *pConstantData
,
778 UINT Vector4iCount
);
781 NineDevice9_GetPixelShaderConstantI( struct NineDevice9
*This
,
784 UINT Vector4iCount
);
787 NineDevice9_SetPixelShaderConstantB( struct NineDevice9
*This
,
789 const BOOL
*pConstantData
,
793 NineDevice9_GetPixelShaderConstantB( struct NineDevice9
*This
,
799 NineDevice9_DrawRectPatch( struct NineDevice9
*This
,
801 const float *pNumSegs
,
802 const D3DRECTPATCH_INFO
*pRectPatchInfo
);
805 NineDevice9_DrawTriPatch( struct NineDevice9
*This
,
807 const float *pNumSegs
,
808 const D3DTRIPATCH_INFO
*pTriPatchInfo
);
811 NineDevice9_DeletePatch( struct NineDevice9
*This
,
815 NineDevice9_CreateQuery( struct NineDevice9
*This
,
817 IDirect3DQuery9
**ppQuery
);
819 #endif /* _NINE_DEVICE9_H_ */