gfxD3D11Target.h
Engine/source/gfx/D3D11/gfxD3D11Target.h
Classes:
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2015 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 24#ifndef _GFX_D3D_GFXD3D11TARGET_H_ 25#define _GFX_D3D_GFXD3D11TARGET_H_ 26 27#include "gfx/D3D11/gfxD3D11Device.h" 28#include "gfx/D3D11/gfxD3D11TextureObject.h" 29#include "gfx/gfxTarget.h" 30#include "math/mPoint3.h" 31#include "math/mPoint2.h" 32 33class GFXD3D11TextureTarget : public GFXTextureTarget 34{ 35 friend class GFXD3D11Device; 36 37 // Array of target surfaces, this is given to us by attachTexture 38 ID3D11Texture2D* mTargets[MaxRenderSlotId]; 39 40 // Array of shader resource views 41 ID3D11ShaderResourceView* mTargetSRViews[MaxRenderSlotId]; 42 43 //ID3D11DepthStencilView* mDepthTargetView; 44 ID3D11View* mTargetViews[MaxRenderSlotId]; 45 // Array of texture objects which correspond to the target surfaces above, 46 // needed for copy from RenderTarget to texture situations. Current only valid in those situations 47 GFXD3D11TextureObject* mResolveTargets[MaxRenderSlotId]; 48 49 Point2I mTargetSize; 50 51 GFXFormat mTargetFormat; 52 53public: 54 55 GFXD3D11TextureTarget(bool genMips); 56 ~GFXD3D11TextureTarget(); 57 58 // Public interface. 59 virtual const Point2I getSize() { return mTargetSize; } 60 virtual GFXFormat getFormat() { return mTargetFormat; } 61 virtual void attachTexture(RenderSlot slot, GFXTextureObject *tex, U32 mipLevel=0, U32 zOffset = 0); 62 virtual void attachTexture(RenderSlot slot, GFXCubemap *tex, U32 face, U32 mipLevel=0); 63 virtual void resolve(); 64 65 /// Note we always copy the Color0 RenderSlot. 66 virtual void resolveTo( GFXTextureObject *tex ); 67 68 virtual void activate(); 69 virtual void deactivate(); 70 71 void zombify(); 72 void resurrect(); 73}; 74 75class GFXD3D11WindowTarget : public GFXWindowTarget 76{ 77 friend class GFXD3D11Device; 78 79 /// Our backbuffer 80 ID3D11Texture2D* mBackBuffer; 81 ID3D11Texture2D* mDepthStencil; 82 ID3D11RenderTargetView* mBackBufferView; 83 ID3D11DepthStencilView* mDepthStencilView; 84 IDXGISwapChain* mSwapChain; 85 86 /// Maximum size we can render to. 87 Point2I mSize; 88 /// D3D presentation info. 89 DXGI_SWAP_CHAIN_DESC mPresentationParams; 90 /// Internal interface that notifies us we need to reset our video mode. 91 void resetMode(); 92 93 /// Is this a secondary window 94 bool mSecondaryWindow; 95 96public: 97 98 GFXD3D11WindowTarget(); 99 ~GFXD3D11WindowTarget(); 100 101 virtual const Point2I getSize(); 102 virtual GFXFormat getFormat(); 103 virtual bool present(); 104 105 void initPresentationParams(); 106 void createSwapChain(); 107 void createBuffersAndViews(); 108 void setBackBuffer(); 109 110 virtual void activate(); 111 112 void zombify(); 113 void resurrect(); 114 115 virtual void resolveTo( GFXTextureObject *tex ); 116 117 // These are all reference counted and must be released by whomever uses the get* function 118 IDXGISwapChain* getSwapChain(); 119 ID3D11Texture2D* getBackBuffer(); 120 ID3D11Texture2D* getDepthStencil(); 121 ID3D11RenderTargetView* getBackBufferView(); 122 ID3D11DepthStencilView* getDepthStencilView(); 123}; 124 125#endif 126