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 max_vs_const_f
;
81 uint16_t max_ps_const_f
;
82 uint32_t vs_bool_true
;
83 uint32_t ps_bool_true
;
85 struct gen_mipmap_state
*gen_mipmap
;
88 struct util_hash_table
*ht_vs
;
89 struct util_hash_table
*ht_ps
;
90 struct NineVertexShader9
*vs
;
91 struct NinePixelShader9
*ps
;
97 struct util_hash_table
*ht_fvf
;
101 struct pipe_resource
*image
;
104 POINT hotspot
; /* -1, -1 if no cursor image set */
113 boolean window_space_position_support
;
116 struct u_upload_mgr
*upload
;
118 struct nine_range_pool range_pool
;
120 struct hud_context
*hud
; /* NULL if hud is disabled */
122 static INLINE
struct NineDevice9
*
123 NineDevice9( void *data
)
125 return (struct NineDevice9
*)data
;
129 NineDevice9_new( struct pipe_screen
*pScreen
,
130 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
132 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
134 ID3DPresentGroup
*pPresentationGroup
,
135 struct d3dadapter9_context
*pCTX
,
137 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
138 struct NineDevice9
**ppOut
);
141 NineDevice9_ctor( struct NineDevice9
*This
,
142 struct NineUnknownParams
*pParams
,
143 struct pipe_screen
*pScreen
,
144 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
146 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
148 ID3DPresentGroup
*pPresentationGroup
,
149 struct d3dadapter9_context
*pCTX
,
151 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
154 NineDevice9_dtor( struct NineDevice9
*This
);
156 /*** Nine private ***/
159 NineDevice9_GetScreen( struct NineDevice9
*This
);
161 struct pipe_context
*
162 NineDevice9_GetPipe( struct NineDevice9
*This
);
165 NineDevice9_GetCSO( struct NineDevice9
*This
);
168 NineDevice9_GetCaps( struct NineDevice9
*This
);
170 /* Mask: 0x1 = constant buffers, 0x2 = stipple */
172 NineDevice9_RestoreNonCSOState( struct NineDevice9
*This
, unsigned mask
);
174 /*** Direct3D public ***/
177 NineDevice9_TestCooperativeLevel( struct NineDevice9
*This
);
180 NineDevice9_GetAvailableTextureMem( struct NineDevice9
*This
);
183 NineDevice9_EvictManagedResources( struct NineDevice9
*This
);
186 NineDevice9_GetDirect3D( struct NineDevice9
*This
,
187 IDirect3D9
**ppD3D9
);
190 NineDevice9_GetDeviceCaps( struct NineDevice9
*This
,
194 NineDevice9_GetDisplayMode( struct NineDevice9
*This
,
196 D3DDISPLAYMODE
*pMode
);
199 NineDevice9_GetCreationParameters( struct NineDevice9
*This
,
200 D3DDEVICE_CREATION_PARAMETERS
*pParameters
);
203 NineDevice9_SetCursorProperties( struct NineDevice9
*This
,
206 IDirect3DSurface9
*pCursorBitmap
);
209 NineDevice9_SetCursorPosition( struct NineDevice9
*This
,
215 NineDevice9_ShowCursor( struct NineDevice9
*This
,
219 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9
*This
,
220 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
221 IDirect3DSwapChain9
**pSwapChain
);
224 NineDevice9_GetSwapChain( struct NineDevice9
*This
,
226 IDirect3DSwapChain9
**pSwapChain
);
229 NineDevice9_GetNumberOfSwapChains( struct NineDevice9
*This
);
232 NineDevice9_Reset( struct NineDevice9
*This
,
233 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
236 NineDevice9_Present( struct NineDevice9
*This
,
237 const RECT
*pSourceRect
,
238 const RECT
*pDestRect
,
239 HWND hDestWindowOverride
,
240 const RGNDATA
*pDirtyRegion
);
243 NineDevice9_GetBackBuffer( struct NineDevice9
*This
,
246 D3DBACKBUFFER_TYPE Type
,
247 IDirect3DSurface9
**ppBackBuffer
);
250 NineDevice9_GetRasterStatus( struct NineDevice9
*This
,
252 D3DRASTER_STATUS
*pRasterStatus
);
255 NineDevice9_SetDialogBoxMode( struct NineDevice9
*This
,
256 BOOL bEnableDialogs
);
259 NineDevice9_SetGammaRamp( struct NineDevice9
*This
,
262 const D3DGAMMARAMP
*pRamp
);
265 NineDevice9_GetGammaRamp( struct NineDevice9
*This
,
267 D3DGAMMARAMP
*pRamp
);
270 NineDevice9_CreateTexture( struct NineDevice9
*This
,
277 IDirect3DTexture9
**ppTexture
,
278 HANDLE
*pSharedHandle
);
281 NineDevice9_CreateVolumeTexture( struct NineDevice9
*This
,
289 IDirect3DVolumeTexture9
**ppVolumeTexture
,
290 HANDLE
*pSharedHandle
);
293 NineDevice9_CreateCubeTexture( struct NineDevice9
*This
,
299 IDirect3DCubeTexture9
**ppCubeTexture
,
300 HANDLE
*pSharedHandle
);
303 NineDevice9_CreateVertexBuffer( struct NineDevice9
*This
,
308 IDirect3DVertexBuffer9
**ppVertexBuffer
,
309 HANDLE
*pSharedHandle
);
312 NineDevice9_CreateIndexBuffer( struct NineDevice9
*This
,
317 IDirect3DIndexBuffer9
**ppIndexBuffer
,
318 HANDLE
*pSharedHandle
);
321 NineDevice9_CreateRenderTarget( struct NineDevice9
*This
,
325 D3DMULTISAMPLE_TYPE MultiSample
,
326 DWORD MultisampleQuality
,
328 IDirect3DSurface9
**ppSurface
,
329 HANDLE
*pSharedHandle
);
332 NineDevice9_CreateDepthStencilSurface( struct NineDevice9
*This
,
336 D3DMULTISAMPLE_TYPE MultiSample
,
337 DWORD MultisampleQuality
,
339 IDirect3DSurface9
**ppSurface
,
340 HANDLE
*pSharedHandle
);
343 NineDevice9_UpdateSurface( struct NineDevice9
*This
,
344 IDirect3DSurface9
*pSourceSurface
,
345 const RECT
*pSourceRect
,
346 IDirect3DSurface9
*pDestinationSurface
,
347 const POINT
*pDestPoint
);
350 NineDevice9_UpdateTexture( struct NineDevice9
*This
,
351 IDirect3DBaseTexture9
*pSourceTexture
,
352 IDirect3DBaseTexture9
*pDestinationTexture
);
355 NineDevice9_GetRenderTargetData( struct NineDevice9
*This
,
356 IDirect3DSurface9
*pRenderTarget
,
357 IDirect3DSurface9
*pDestSurface
);
360 NineDevice9_GetFrontBufferData( struct NineDevice9
*This
,
362 IDirect3DSurface9
*pDestSurface
);
365 NineDevice9_StretchRect( struct NineDevice9
*This
,
366 IDirect3DSurface9
*pSourceSurface
,
367 const RECT
*pSourceRect
,
368 IDirect3DSurface9
*pDestSurface
,
369 const RECT
*pDestRect
,
370 D3DTEXTUREFILTERTYPE Filter
);
373 NineDevice9_ColorFill( struct NineDevice9
*This
,
374 IDirect3DSurface9
*pSurface
,
379 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9
*This
,
384 IDirect3DSurface9
**ppSurface
,
385 HANDLE
*pSharedHandle
);
388 NineDevice9_SetRenderTarget( struct NineDevice9
*This
,
389 DWORD RenderTargetIndex
,
390 IDirect3DSurface9
*pRenderTarget
);
393 NineDevice9_GetRenderTarget( struct NineDevice9
*This
,
394 DWORD RenderTargetIndex
,
395 IDirect3DSurface9
**ppRenderTarget
);
398 NineDevice9_SetDepthStencilSurface( struct NineDevice9
*This
,
399 IDirect3DSurface9
*pNewZStencil
);
402 NineDevice9_GetDepthStencilSurface( struct NineDevice9
*This
,
403 IDirect3DSurface9
**ppZStencilSurface
);
406 NineDevice9_BeginScene( struct NineDevice9
*This
);
409 NineDevice9_EndScene( struct NineDevice9
*This
);
412 NineDevice9_Clear( struct NineDevice9
*This
,
414 const D3DRECT
*pRects
,
421 NineDevice9_SetTransform( struct NineDevice9
*This
,
422 D3DTRANSFORMSTATETYPE State
,
423 const D3DMATRIX
*pMatrix
);
426 NineDevice9_GetTransform( struct NineDevice9
*This
,
427 D3DTRANSFORMSTATETYPE State
,
428 D3DMATRIX
*pMatrix
);
431 NineDevice9_MultiplyTransform( struct NineDevice9
*This
,
432 D3DTRANSFORMSTATETYPE State
,
433 const D3DMATRIX
*pMatrix
);
436 NineDevice9_SetViewport( struct NineDevice9
*This
,
437 const D3DVIEWPORT9
*pViewport
);
440 NineDevice9_GetViewport( struct NineDevice9
*This
,
441 D3DVIEWPORT9
*pViewport
);
444 NineDevice9_SetMaterial( struct NineDevice9
*This
,
445 const D3DMATERIAL9
*pMaterial
);
448 NineDevice9_GetMaterial( struct NineDevice9
*This
,
449 D3DMATERIAL9
*pMaterial
);
452 NineDevice9_SetLight( struct NineDevice9
*This
,
454 const D3DLIGHT9
*pLight
);
457 NineDevice9_GetLight( struct NineDevice9
*This
,
462 NineDevice9_LightEnable( struct NineDevice9
*This
,
467 NineDevice9_GetLightEnable( struct NineDevice9
*This
,
472 NineDevice9_SetClipPlane( struct NineDevice9
*This
,
474 const float *pPlane
);
477 NineDevice9_GetClipPlane( struct NineDevice9
*This
,
482 NineDevice9_SetRenderState( struct NineDevice9
*This
,
483 D3DRENDERSTATETYPE State
,
487 NineDevice9_GetRenderState( struct NineDevice9
*This
,
488 D3DRENDERSTATETYPE State
,
492 NineDevice9_CreateStateBlock( struct NineDevice9
*This
,
493 D3DSTATEBLOCKTYPE Type
,
494 IDirect3DStateBlock9
**ppSB
);
497 NineDevice9_BeginStateBlock( struct NineDevice9
*This
);
500 NineDevice9_EndStateBlock( struct NineDevice9
*This
,
501 IDirect3DStateBlock9
**ppSB
);
504 NineDevice9_SetClipStatus( struct NineDevice9
*This
,
505 const D3DCLIPSTATUS9
*pClipStatus
);
508 NineDevice9_GetClipStatus( struct NineDevice9
*This
,
509 D3DCLIPSTATUS9
*pClipStatus
);
512 NineDevice9_GetTexture( struct NineDevice9
*This
,
514 IDirect3DBaseTexture9
**ppTexture
);
517 NineDevice9_SetTexture( struct NineDevice9
*This
,
519 IDirect3DBaseTexture9
*pTexture
);
522 NineDevice9_GetTextureStageState( struct NineDevice9
*This
,
524 D3DTEXTURESTAGESTATETYPE Type
,
528 NineDevice9_SetTextureStageState( struct NineDevice9
*This
,
530 D3DTEXTURESTAGESTATETYPE Type
,
534 NineDevice9_GetSamplerState( struct NineDevice9
*This
,
536 D3DSAMPLERSTATETYPE Type
,
540 NineDevice9_SetSamplerState( struct NineDevice9
*This
,
542 D3DSAMPLERSTATETYPE Type
,
546 NineDevice9_ValidateDevice( struct NineDevice9
*This
,
550 NineDevice9_SetPaletteEntries( struct NineDevice9
*This
,
552 const PALETTEENTRY
*pEntries
);
555 NineDevice9_GetPaletteEntries( struct NineDevice9
*This
,
557 PALETTEENTRY
*pEntries
);
560 NineDevice9_SetCurrentTexturePalette( struct NineDevice9
*This
,
561 UINT PaletteNumber
);
564 NineDevice9_GetCurrentTexturePalette( struct NineDevice9
*This
,
565 UINT
*PaletteNumber
);
568 NineDevice9_SetScissorRect( struct NineDevice9
*This
,
572 NineDevice9_GetScissorRect( struct NineDevice9
*This
,
576 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9
*This
,
580 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9
*This
);
583 NineDevice9_SetNPatchMode( struct NineDevice9
*This
,
587 NineDevice9_GetNPatchMode( struct NineDevice9
*This
);
590 NineDevice9_DrawPrimitive( struct NineDevice9
*This
,
591 D3DPRIMITIVETYPE PrimitiveType
,
593 UINT PrimitiveCount
);
596 NineDevice9_DrawIndexedPrimitive( struct NineDevice9
*This
,
597 D3DPRIMITIVETYPE PrimitiveType
,
605 NineDevice9_DrawPrimitiveUP( struct NineDevice9
*This
,
606 D3DPRIMITIVETYPE PrimitiveType
,
608 const void *pVertexStreamZeroData
,
609 UINT VertexStreamZeroStride
);
612 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9
*This
,
613 D3DPRIMITIVETYPE PrimitiveType
,
617 const void *pIndexData
,
618 D3DFORMAT IndexDataFormat
,
619 const void *pVertexStreamZeroData
,
620 UINT VertexStreamZeroStride
);
623 NineDevice9_ProcessVertices( struct NineDevice9
*This
,
627 IDirect3DVertexBuffer9
*pDestBuffer
,
628 IDirect3DVertexDeclaration9
*pVertexDecl
,
632 NineDevice9_CreateVertexDeclaration( struct NineDevice9
*This
,
633 const D3DVERTEXELEMENT9
*pVertexElements
,
634 IDirect3DVertexDeclaration9
**ppDecl
);
637 NineDevice9_SetVertexDeclaration( struct NineDevice9
*This
,
638 IDirect3DVertexDeclaration9
*pDecl
);
641 NineDevice9_GetVertexDeclaration( struct NineDevice9
*This
,
642 IDirect3DVertexDeclaration9
**ppDecl
);
645 NineDevice9_SetFVF( struct NineDevice9
*This
,
649 NineDevice9_GetFVF( struct NineDevice9
*This
,
653 NineDevice9_CreateVertexShader( struct NineDevice9
*This
,
654 const DWORD
*pFunction
,
655 IDirect3DVertexShader9
**ppShader
);
658 NineDevice9_SetVertexShader( struct NineDevice9
*This
,
659 IDirect3DVertexShader9
*pShader
);
662 NineDevice9_GetVertexShader( struct NineDevice9
*This
,
663 IDirect3DVertexShader9
**ppShader
);
666 NineDevice9_SetVertexShaderConstantF( struct NineDevice9
*This
,
668 const float *pConstantData
,
669 UINT Vector4fCount
);
672 NineDevice9_GetVertexShaderConstantF( struct NineDevice9
*This
,
674 float *pConstantData
,
675 UINT Vector4fCount
);
678 NineDevice9_SetVertexShaderConstantI( struct NineDevice9
*This
,
680 const int *pConstantData
,
681 UINT Vector4iCount
);
684 NineDevice9_GetVertexShaderConstantI( struct NineDevice9
*This
,
687 UINT Vector4iCount
);
690 NineDevice9_SetVertexShaderConstantB( struct NineDevice9
*This
,
692 const BOOL
*pConstantData
,
696 NineDevice9_GetVertexShaderConstantB( struct NineDevice9
*This
,
702 NineDevice9_SetStreamSource( struct NineDevice9
*This
,
704 IDirect3DVertexBuffer9
*pStreamData
,
709 NineDevice9_GetStreamSource( struct NineDevice9
*This
,
711 IDirect3DVertexBuffer9
**ppStreamData
,
712 UINT
*pOffsetInBytes
,
716 NineDevice9_SetStreamSourceFreq( struct NineDevice9
*This
,
721 NineDevice9_GetStreamSourceFreq( struct NineDevice9
*This
,
726 NineDevice9_SetIndices( struct NineDevice9
*This
,
727 IDirect3DIndexBuffer9
*pIndexData
);
730 NineDevice9_GetIndices( struct NineDevice9
*This
,
731 IDirect3DIndexBuffer9
**ppIndexData
/*,
732 UINT *pBaseVertexIndex */ );
735 NineDevice9_CreatePixelShader( struct NineDevice9
*This
,
736 const DWORD
*pFunction
,
737 IDirect3DPixelShader9
**ppShader
);
740 NineDevice9_SetPixelShader( struct NineDevice9
*This
,
741 IDirect3DPixelShader9
*pShader
);
744 NineDevice9_GetPixelShader( struct NineDevice9
*This
,
745 IDirect3DPixelShader9
**ppShader
);
748 NineDevice9_SetPixelShaderConstantF( struct NineDevice9
*This
,
750 const float *pConstantData
,
751 UINT Vector4fCount
);
754 NineDevice9_GetPixelShaderConstantF( struct NineDevice9
*This
,
756 float *pConstantData
,
757 UINT Vector4fCount
);
760 NineDevice9_SetPixelShaderConstantI( struct NineDevice9
*This
,
762 const int *pConstantData
,
763 UINT Vector4iCount
);
766 NineDevice9_GetPixelShaderConstantI( struct NineDevice9
*This
,
769 UINT Vector4iCount
);
772 NineDevice9_SetPixelShaderConstantB( struct NineDevice9
*This
,
774 const BOOL
*pConstantData
,
778 NineDevice9_GetPixelShaderConstantB( struct NineDevice9
*This
,
784 NineDevice9_DrawRectPatch( struct NineDevice9
*This
,
786 const float *pNumSegs
,
787 const D3DRECTPATCH_INFO
*pRectPatchInfo
);
790 NineDevice9_DrawTriPatch( struct NineDevice9
*This
,
792 const float *pNumSegs
,
793 const D3DTRIPATCH_INFO
*pTriPatchInfo
);
796 NineDevice9_DeletePatch( struct NineDevice9
*This
,
800 NineDevice9_CreateQuery( struct NineDevice9
*This
,
802 IDirect3DQuery9
**ppQuery
);
804 #endif /* _NINE_DEVICE9_H_ */