gfxD3D11TextureObject.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2015 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXD3D11TEXTUREOBJECT_H_
  23. #define _GFXD3D11TEXTUREOBJECT_H_
  24. #include "gfx/D3D11/gfxD3D11Device.h"
  25. #include "gfx/gfxTextureHandle.h"
  26. #include "gfx/gfxTextureManager.h"
  27. class GFXD3D11TextureObject : public GFXTextureObject
  28. {
  29. protected:
  30. static U32 mTexCount;
  31. GFXTexHandle mStagingTex;
  32. DXGI_MAPPED_RECT mLockRect;
  33. D3D11_BOX mLockBox;
  34. bool mLocked;
  35. U32 mLockedSubresource;
  36. ID3D11Resource *mD3DTexture;
  37. // used for z buffers...
  38. ID3D11Texture2D *mD3DSurface;
  39. ID3D11ShaderResourceView* mSRView; // for shader resource input
  40. ID3D11RenderTargetView* mRTView; // for render targets
  41. ID3D11DepthStencilView* mDSView; //render target view for depth stencil
  42. public:
  43. GFXD3D11TextureObject( GFXDevice * d, GFXTextureProfile *profile);
  44. ~GFXD3D11TextureObject();
  45. ID3D11Resource* getResource(){ return mD3DTexture; }
  46. ID3D11Texture2D* get2DTex(){ return (ID3D11Texture2D*) mD3DTexture; }
  47. ID3D11Texture2D** get2DTexPtr(){ return (ID3D11Texture2D**) &mD3DTexture; }
  48. ID3D11Texture3D* get3DTex(){ return (ID3D11Texture3D*) mD3DTexture; }
  49. ID3D11Texture3D** get3DTexPtr(){ return (ID3D11Texture3D**) &mD3DTexture; }
  50. ID3D11ShaderResourceView* getSRView();
  51. ID3D11RenderTargetView* getRTView();
  52. ID3D11DepthStencilView* getDSView();
  53. ID3D11ShaderResourceView** getSRViewPtr();
  54. ID3D11RenderTargetView** getRTViewPtr();
  55. ID3D11DepthStencilView** getDSViewPtr();
  56. void release();
  57. bool isManaged; //setting to true tells this texture not to be released from being zombify
  58. virtual GFXLockedRect * lock(U32 mipLevel = 0, RectI *inRect = NULL);
  59. virtual void unlock(U32 mipLevel = 0 );
  60. virtual bool copyToBmp(GBitmap* bmp);
  61. ID3D11Texture2D* getSurface() {return mD3DSurface;}
  62. ID3D11Texture2D** getSurfacePtr() {return &mD3DSurface;}
  63. // GFXResource
  64. void zombify();
  65. void resurrect();
  66. #ifdef TORQUE_DEBUG
  67. virtual void pureVirtualCrash() {};
  68. #endif
  69. };
  70. #endif