gfxPCD3D9Target.h
Engine/source/gfx/D3D9/pc/gfxPCD3D9Target.h
Classes:
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 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 NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23#ifndef _GFX_D3D_GFXD3D9TARGET_H_ 24#define _GFX_D3D_GFXD3D9TARGET_H_ 25 26#ifndef _GFXTARGET_H_ 27#include "gfx/gfxTarget.h" 28#endif 29#ifndef _MPOINT3_H_ 30#include "math/mPoint3.h" 31#endif 32#ifndef _MPOINT2_H_ 33#include "math/mPoint2.h" 34#endif 35#include <d3d9.h> 36 37struct IDirect3DSurface9; 38struct IDirect3DSwapChain9; 39class GFXD3D9TextureObject; 40 41 42class GFXPCD3D9TextureTarget : public GFXTextureTarget 43{ 44 friend class GFXPCD3D9Device; 45 46 // Array of target surfaces, this is given to us by attachTexture 47 IDirect3DSurface9 * mTargets[MaxRenderSlotId]; 48 49 // Array of texture objects which correspond to the target surfaces above, 50 // needed for copy from RenderTarget to texture situations. Current only valid in those situations 51 GFXD3D9TextureObject* mResolveTargets[MaxRenderSlotId]; 52 53 /// Owning d3d device. 54 GFXD3D9Device *mDevice; 55 56 Point2I mTargetSize; 57 58 GFXFormat mTargetFormat; 59 60public: 61 62 GFXPCD3D9TextureTarget(); 63 ~GFXPCD3D9TextureTarget(); 64 65 // Public interface. 66 virtual const Point2I getSize() { return mTargetSize; } 67 virtual GFXFormat getFormat() { return mTargetFormat; } 68 virtual void attachTexture(RenderSlot slot, GFXTextureObject *tex, U32 mipLevel=0, U32 zOffset = 0); 69 virtual void attachTexture(RenderSlot slot, GFXCubemap *tex, U32 face, U32 mipLevel=0); 70 virtual void resolve(); 71 72 /// Note we always copy the Color0 RenderSlot. 73 virtual void resolveTo( GFXTextureObject *tex ); 74 75 virtual void activate(); 76 virtual void deactivate(); 77 78 void zombify(); 79 void resurrect(); 80}; 81 82class GFXPCD3D9WindowTarget : public GFXWindowTarget 83{ 84 friend class GFXPCD3D9Device; 85 86 /// Our depth stencil buffer, if any. 87 IDirect3DSurface9 *mDepthStencil; 88 89 /// Our backbuffer 90 IDirect3DSurface9 *mBackbuffer; 91 92 /// Maximum size we can render to. 93 Point2I mSize; 94 95 /// Our swap chain, potentially the implicit device swap chain. 96 IDirect3DSwapChain9 *mSwapChain; 97 98 /// D3D presentation info. 99 D3DPRESENT_PARAMETERS mPresentationParams; 100 101 /// Owning d3d device. 102 GFXD3D9Device *mDevice; 103 104 /// Is this the implicit swap chain? 105 bool mImplicit; 106 107 /// Internal interface that notifies us we need to reset our video mode. 108 void resetMode(); 109 110public: 111 112 GFXPCD3D9WindowTarget(); 113 ~GFXPCD3D9WindowTarget(); 114 115 virtual const Point2I getSize(); 116 virtual GFXFormat getFormat(); 117 virtual bool present(); 118 119 void initPresentationParams(); 120 void setImplicitSwapChain(); 121 void createAdditionalSwapChain(); 122 123 virtual void activate(); 124 125 void zombify(); 126 void resurrect(); 127 128 virtual void resolveTo( GFXTextureObject *tex ); 129}; 130 131#endif // _GFX_D3D_GFXD3D9TARGET_H_ 132
