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
;
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
;
122 boolean buggy_barycentrics
;
125 struct u_upload_mgr
*upload
;
127 struct nine_range_pool range_pool
;
129 struct hud_context
*hud
; /* NULL if hud is disabled */
131 /* dummy vbo (containing 0 0 0 0) to bind if vertex shader input
132 * is not bound to anything by the vertex declaration */
133 struct pipe_resource
*dummy_vbo
;
135 static inline struct NineDevice9
*
136 NineDevice9( void *data
)
138 return (struct NineDevice9
*)data
;
142 NineDevice9_new( struct pipe_screen
*pScreen
,
143 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
145 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
147 ID3DPresentGroup
*pPresentationGroup
,
148 struct d3dadapter9_context
*pCTX
,
150 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
151 struct NineDevice9
**ppOut
);
154 NineDevice9_ctor( struct NineDevice9
*This
,
155 struct NineUnknownParams
*pParams
,
156 struct pipe_screen
*pScreen
,
157 D3DDEVICE_CREATION_PARAMETERS
*pCreationParameters
,
159 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
161 ID3DPresentGroup
*pPresentationGroup
,
162 struct d3dadapter9_context
*pCTX
,
164 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
);
167 NineDevice9_dtor( struct NineDevice9
*This
);
169 /*** Nine private ***/
172 NineDevice9_GetScreen( struct NineDevice9
*This
);
174 struct pipe_context
*
175 NineDevice9_GetPipe( struct NineDevice9
*This
);
178 NineDevice9_GetCSO( struct NineDevice9
*This
);
181 NineDevice9_GetCaps( struct NineDevice9
*This
);
183 /* Mask: 0x1 = constant buffers, 0x2 = stipple */
185 NineDevice9_RestoreNonCSOState( struct NineDevice9
*This
, unsigned mask
);
187 /*** Direct3D public ***/
190 NineDevice9_TestCooperativeLevel( struct NineDevice9
*This
);
193 NineDevice9_GetAvailableTextureMem( struct NineDevice9
*This
);
196 NineDevice9_EvictManagedResources( struct NineDevice9
*This
);
199 NineDevice9_GetDirect3D( struct NineDevice9
*This
,
200 IDirect3D9
**ppD3D9
);
203 NineDevice9_GetDeviceCaps( struct NineDevice9
*This
,
207 NineDevice9_GetDisplayMode( struct NineDevice9
*This
,
209 D3DDISPLAYMODE
*pMode
);
212 NineDevice9_GetCreationParameters( struct NineDevice9
*This
,
213 D3DDEVICE_CREATION_PARAMETERS
*pParameters
);
216 NineDevice9_SetCursorProperties( struct NineDevice9
*This
,
219 IDirect3DSurface9
*pCursorBitmap
);
222 NineDevice9_SetCursorPosition( struct NineDevice9
*This
,
228 NineDevice9_ShowCursor( struct NineDevice9
*This
,
232 NineDevice9_CreateAdditionalSwapChain( struct NineDevice9
*This
,
233 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
234 IDirect3DSwapChain9
**pSwapChain
);
237 NineDevice9_GetSwapChain( struct NineDevice9
*This
,
239 IDirect3DSwapChain9
**pSwapChain
);
242 NineDevice9_GetNumberOfSwapChains( struct NineDevice9
*This
);
245 NineDevice9_Reset( struct NineDevice9
*This
,
246 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
249 NineDevice9_Present( struct NineDevice9
*This
,
250 const RECT
*pSourceRect
,
251 const RECT
*pDestRect
,
252 HWND hDestWindowOverride
,
253 const RGNDATA
*pDirtyRegion
);
256 NineDevice9_GetBackBuffer( struct NineDevice9
*This
,
259 D3DBACKBUFFER_TYPE Type
,
260 IDirect3DSurface9
**ppBackBuffer
);
263 NineDevice9_GetRasterStatus( struct NineDevice9
*This
,
265 D3DRASTER_STATUS
*pRasterStatus
);
268 NineDevice9_SetDialogBoxMode( struct NineDevice9
*This
,
269 BOOL bEnableDialogs
);
272 NineDevice9_SetGammaRamp( struct NineDevice9
*This
,
275 const D3DGAMMARAMP
*pRamp
);
278 NineDevice9_GetGammaRamp( struct NineDevice9
*This
,
280 D3DGAMMARAMP
*pRamp
);
283 NineDevice9_CreateTexture( struct NineDevice9
*This
,
290 IDirect3DTexture9
**ppTexture
,
291 HANDLE
*pSharedHandle
);
294 NineDevice9_CreateVolumeTexture( struct NineDevice9
*This
,
302 IDirect3DVolumeTexture9
**ppVolumeTexture
,
303 HANDLE
*pSharedHandle
);
306 NineDevice9_CreateCubeTexture( struct NineDevice9
*This
,
312 IDirect3DCubeTexture9
**ppCubeTexture
,
313 HANDLE
*pSharedHandle
);
316 NineDevice9_CreateVertexBuffer( struct NineDevice9
*This
,
321 IDirect3DVertexBuffer9
**ppVertexBuffer
,
322 HANDLE
*pSharedHandle
);
325 NineDevice9_CreateIndexBuffer( struct NineDevice9
*This
,
330 IDirect3DIndexBuffer9
**ppIndexBuffer
,
331 HANDLE
*pSharedHandle
);
334 NineDevice9_CreateRenderTarget( struct NineDevice9
*This
,
338 D3DMULTISAMPLE_TYPE MultiSample
,
339 DWORD MultisampleQuality
,
341 IDirect3DSurface9
**ppSurface
,
342 HANDLE
*pSharedHandle
);
345 NineDevice9_CreateDepthStencilSurface( struct NineDevice9
*This
,
349 D3DMULTISAMPLE_TYPE MultiSample
,
350 DWORD MultisampleQuality
,
352 IDirect3DSurface9
**ppSurface
,
353 HANDLE
*pSharedHandle
);
356 NineDevice9_UpdateSurface( struct NineDevice9
*This
,
357 IDirect3DSurface9
*pSourceSurface
,
358 const RECT
*pSourceRect
,
359 IDirect3DSurface9
*pDestinationSurface
,
360 const POINT
*pDestPoint
);
363 NineDevice9_UpdateTexture( struct NineDevice9
*This
,
364 IDirect3DBaseTexture9
*pSourceTexture
,
365 IDirect3DBaseTexture9
*pDestinationTexture
);
368 NineDevice9_GetRenderTargetData( struct NineDevice9
*This
,
369 IDirect3DSurface9
*pRenderTarget
,
370 IDirect3DSurface9
*pDestSurface
);
373 NineDevice9_GetFrontBufferData( struct NineDevice9
*This
,
375 IDirect3DSurface9
*pDestSurface
);
378 NineDevice9_StretchRect( struct NineDevice9
*This
,
379 IDirect3DSurface9
*pSourceSurface
,
380 const RECT
*pSourceRect
,
381 IDirect3DSurface9
*pDestSurface
,
382 const RECT
*pDestRect
,
383 D3DTEXTUREFILTERTYPE Filter
);
386 NineDevice9_ColorFill( struct NineDevice9
*This
,
387 IDirect3DSurface9
*pSurface
,
392 NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9
*This
,
397 IDirect3DSurface9
**ppSurface
,
398 HANDLE
*pSharedHandle
);
401 NineDevice9_SetRenderTarget( struct NineDevice9
*This
,
402 DWORD RenderTargetIndex
,
403 IDirect3DSurface9
*pRenderTarget
);
406 NineDevice9_GetRenderTarget( struct NineDevice9
*This
,
407 DWORD RenderTargetIndex
,
408 IDirect3DSurface9
**ppRenderTarget
);
411 NineDevice9_SetDepthStencilSurface( struct NineDevice9
*This
,
412 IDirect3DSurface9
*pNewZStencil
);
415 NineDevice9_GetDepthStencilSurface( struct NineDevice9
*This
,
416 IDirect3DSurface9
**ppZStencilSurface
);
419 NineDevice9_BeginScene( struct NineDevice9
*This
);
422 NineDevice9_EndScene( struct NineDevice9
*This
);
425 NineDevice9_Clear( struct NineDevice9
*This
,
427 const D3DRECT
*pRects
,
434 NineDevice9_SetTransform( struct NineDevice9
*This
,
435 D3DTRANSFORMSTATETYPE State
,
436 const D3DMATRIX
*pMatrix
);
439 NineDevice9_GetTransform( struct NineDevice9
*This
,
440 D3DTRANSFORMSTATETYPE State
,
441 D3DMATRIX
*pMatrix
);
444 NineDevice9_MultiplyTransform( struct NineDevice9
*This
,
445 D3DTRANSFORMSTATETYPE State
,
446 const D3DMATRIX
*pMatrix
);
449 NineDevice9_SetViewport( struct NineDevice9
*This
,
450 const D3DVIEWPORT9
*pViewport
);
453 NineDevice9_GetViewport( struct NineDevice9
*This
,
454 D3DVIEWPORT9
*pViewport
);
457 NineDevice9_SetMaterial( struct NineDevice9
*This
,
458 const D3DMATERIAL9
*pMaterial
);
461 NineDevice9_GetMaterial( struct NineDevice9
*This
,
462 D3DMATERIAL9
*pMaterial
);
465 NineDevice9_SetLight( struct NineDevice9
*This
,
467 const D3DLIGHT9
*pLight
);
470 NineDevice9_GetLight( struct NineDevice9
*This
,
475 NineDevice9_LightEnable( struct NineDevice9
*This
,
480 NineDevice9_GetLightEnable( struct NineDevice9
*This
,
485 NineDevice9_SetClipPlane( struct NineDevice9
*This
,
487 const float *pPlane
);
490 NineDevice9_GetClipPlane( struct NineDevice9
*This
,
495 NineDevice9_SetRenderState( struct NineDevice9
*This
,
496 D3DRENDERSTATETYPE State
,
500 NineDevice9_GetRenderState( struct NineDevice9
*This
,
501 D3DRENDERSTATETYPE State
,
505 NineDevice9_CreateStateBlock( struct NineDevice9
*This
,
506 D3DSTATEBLOCKTYPE Type
,
507 IDirect3DStateBlock9
**ppSB
);
510 NineDevice9_BeginStateBlock( struct NineDevice9
*This
);
513 NineDevice9_EndStateBlock( struct NineDevice9
*This
,
514 IDirect3DStateBlock9
**ppSB
);
517 NineDevice9_SetClipStatus( struct NineDevice9
*This
,
518 const D3DCLIPSTATUS9
*pClipStatus
);
521 NineDevice9_GetClipStatus( struct NineDevice9
*This
,
522 D3DCLIPSTATUS9
*pClipStatus
);
525 NineDevice9_GetTexture( struct NineDevice9
*This
,
527 IDirect3DBaseTexture9
**ppTexture
);
530 NineDevice9_SetTexture( struct NineDevice9
*This
,
532 IDirect3DBaseTexture9
*pTexture
);
535 NineDevice9_GetTextureStageState( struct NineDevice9
*This
,
537 D3DTEXTURESTAGESTATETYPE Type
,
541 NineDevice9_SetTextureStageState( struct NineDevice9
*This
,
543 D3DTEXTURESTAGESTATETYPE Type
,
547 NineDevice9_GetSamplerState( struct NineDevice9
*This
,
549 D3DSAMPLERSTATETYPE Type
,
553 NineDevice9_SetSamplerState( struct NineDevice9
*This
,
555 D3DSAMPLERSTATETYPE Type
,
559 NineDevice9_ValidateDevice( struct NineDevice9
*This
,
563 NineDevice9_SetPaletteEntries( struct NineDevice9
*This
,
565 const PALETTEENTRY
*pEntries
);
568 NineDevice9_GetPaletteEntries( struct NineDevice9
*This
,
570 PALETTEENTRY
*pEntries
);
573 NineDevice9_SetCurrentTexturePalette( struct NineDevice9
*This
,
574 UINT PaletteNumber
);
577 NineDevice9_GetCurrentTexturePalette( struct NineDevice9
*This
,
578 UINT
*PaletteNumber
);
581 NineDevice9_SetScissorRect( struct NineDevice9
*This
,
585 NineDevice9_GetScissorRect( struct NineDevice9
*This
,
589 NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9
*This
,
593 NineDevice9_GetSoftwareVertexProcessing( struct NineDevice9
*This
);
596 NineDevice9_SetNPatchMode( struct NineDevice9
*This
,
600 NineDevice9_GetNPatchMode( struct NineDevice9
*This
);
603 NineDevice9_DrawPrimitive( struct NineDevice9
*This
,
604 D3DPRIMITIVETYPE PrimitiveType
,
606 UINT PrimitiveCount
);
609 NineDevice9_DrawIndexedPrimitive( struct NineDevice9
*This
,
610 D3DPRIMITIVETYPE PrimitiveType
,
618 NineDevice9_DrawPrimitiveUP( struct NineDevice9
*This
,
619 D3DPRIMITIVETYPE PrimitiveType
,
621 const void *pVertexStreamZeroData
,
622 UINT VertexStreamZeroStride
);
625 NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9
*This
,
626 D3DPRIMITIVETYPE PrimitiveType
,
630 const void *pIndexData
,
631 D3DFORMAT IndexDataFormat
,
632 const void *pVertexStreamZeroData
,
633 UINT VertexStreamZeroStride
);
636 NineDevice9_ProcessVertices( struct NineDevice9
*This
,
640 IDirect3DVertexBuffer9
*pDestBuffer
,
641 IDirect3DVertexDeclaration9
*pVertexDecl
,
645 NineDevice9_CreateVertexDeclaration( struct NineDevice9
*This
,
646 const D3DVERTEXELEMENT9
*pVertexElements
,
647 IDirect3DVertexDeclaration9
**ppDecl
);
650 NineDevice9_SetVertexDeclaration( struct NineDevice9
*This
,
651 IDirect3DVertexDeclaration9
*pDecl
);
654 NineDevice9_GetVertexDeclaration( struct NineDevice9
*This
,
655 IDirect3DVertexDeclaration9
**ppDecl
);
658 NineDevice9_SetFVF( struct NineDevice9
*This
,
662 NineDevice9_GetFVF( struct NineDevice9
*This
,
666 NineDevice9_CreateVertexShader( struct NineDevice9
*This
,
667 const DWORD
*pFunction
,
668 IDirect3DVertexShader9
**ppShader
);
671 NineDevice9_SetVertexShader( struct NineDevice9
*This
,
672 IDirect3DVertexShader9
*pShader
);
675 NineDevice9_GetVertexShader( struct NineDevice9
*This
,
676 IDirect3DVertexShader9
**ppShader
);
679 NineDevice9_SetVertexShaderConstantF( struct NineDevice9
*This
,
681 const float *pConstantData
,
682 UINT Vector4fCount
);
685 NineDevice9_GetVertexShaderConstantF( struct NineDevice9
*This
,
687 float *pConstantData
,
688 UINT Vector4fCount
);
691 NineDevice9_SetVertexShaderConstantI( struct NineDevice9
*This
,
693 const int *pConstantData
,
694 UINT Vector4iCount
);
697 NineDevice9_GetVertexShaderConstantI( struct NineDevice9
*This
,
700 UINT Vector4iCount
);
703 NineDevice9_SetVertexShaderConstantB( struct NineDevice9
*This
,
705 const BOOL
*pConstantData
,
709 NineDevice9_GetVertexShaderConstantB( struct NineDevice9
*This
,
715 NineDevice9_SetStreamSource( struct NineDevice9
*This
,
717 IDirect3DVertexBuffer9
*pStreamData
,
722 NineDevice9_GetStreamSource( struct NineDevice9
*This
,
724 IDirect3DVertexBuffer9
**ppStreamData
,
725 UINT
*pOffsetInBytes
,
729 NineDevice9_SetStreamSourceFreq( struct NineDevice9
*This
,
734 NineDevice9_GetStreamSourceFreq( struct NineDevice9
*This
,
739 NineDevice9_SetIndices( struct NineDevice9
*This
,
740 IDirect3DIndexBuffer9
*pIndexData
);
743 NineDevice9_GetIndices( struct NineDevice9
*This
,
744 IDirect3DIndexBuffer9
**ppIndexData
/*,
745 UINT *pBaseVertexIndex */ );
748 NineDevice9_CreatePixelShader( struct NineDevice9
*This
,
749 const DWORD
*pFunction
,
750 IDirect3DPixelShader9
**ppShader
);
753 NineDevice9_SetPixelShader( struct NineDevice9
*This
,
754 IDirect3DPixelShader9
*pShader
);
757 NineDevice9_GetPixelShader( struct NineDevice9
*This
,
758 IDirect3DPixelShader9
**ppShader
);
761 NineDevice9_SetPixelShaderConstantF( struct NineDevice9
*This
,
763 const float *pConstantData
,
764 UINT Vector4fCount
);
767 NineDevice9_GetPixelShaderConstantF( struct NineDevice9
*This
,
769 float *pConstantData
,
770 UINT Vector4fCount
);
773 NineDevice9_SetPixelShaderConstantI( struct NineDevice9
*This
,
775 const int *pConstantData
,
776 UINT Vector4iCount
);
779 NineDevice9_GetPixelShaderConstantI( struct NineDevice9
*This
,
782 UINT Vector4iCount
);
785 NineDevice9_SetPixelShaderConstantB( struct NineDevice9
*This
,
787 const BOOL
*pConstantData
,
791 NineDevice9_GetPixelShaderConstantB( struct NineDevice9
*This
,
797 NineDevice9_DrawRectPatch( struct NineDevice9
*This
,
799 const float *pNumSegs
,
800 const D3DRECTPATCH_INFO
*pRectPatchInfo
);
803 NineDevice9_DrawTriPatch( struct NineDevice9
*This
,
805 const float *pNumSegs
,
806 const D3DTRIPATCH_INFO
*pTriPatchInfo
);
809 NineDevice9_DeletePatch( struct NineDevice9
*This
,
813 NineDevice9_CreateQuery( struct NineDevice9
*This
,
815 IDirect3DQuery9
**ppQuery
);
817 #endif /* _NINE_DEVICE9_H_ */