gfxD3D11TextureObject.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 mLockTex;
  32. DXGI_MAPPED_RECT mLockRect;
  33. bool mLocked;
  34. U32 mLockedSubresource;
  35. ID3D11Resource *mD3DTexture;
  36. // used for z buffers...
  37. ID3D11Texture2D *mD3DSurface;
  38. ID3D11ShaderResourceView* mSRView; // for shader resource input
  39. ID3D11RenderTargetView* mRTView; // for render targets
  40. ID3D11DepthStencilView* mDSView; //render target view for depth stencil
  41. public:
  42. GFXD3D11TextureObject( GFXDevice * d, GFXTextureProfile *profile);
  43. ~GFXD3D11TextureObject();
  44. ID3D11Resource* getResource(){ return mD3DTexture; }
  45. ID3D11Texture2D* get2DTex(){ return (ID3D11Texture2D*) mD3DTexture; }
  46. ID3D11Texture2D** get2DTexPtr(){ return (ID3D11Texture2D**) &mD3DTexture; }
  47. ID3D11Texture3D* get3DTex(){ return (ID3D11Texture3D*) mD3DTexture; }
  48. ID3D11Texture3D** get3DTexPtr(){ return (ID3D11Texture3D**) &mD3DTexture; }
  49. ID3D11ShaderResourceView* getSRView();
  50. ID3D11RenderTargetView* getRTView();
  51. ID3D11DepthStencilView* getDSView();
  52. ID3D11ShaderResourceView** getSRViewPtr();
  53. ID3D11RenderTargetView** getRTViewPtr();
  54. ID3D11DepthStencilView** getDSViewPtr();
  55. void release();
  56. bool isManaged; //setting to true tells this texture not to be released from being zombify
  57. virtual GFXLockedRect * lock(U32 mipLevel = 0, RectI *inRect = NULL);
  58. virtual void unlock(U32 mipLevel = 0 );
  59. virtual bool copyToBmp(GBitmap* bmp);
  60. ID3D11Texture2D* getSurface() {return mD3DSurface;}
  61. ID3D11Texture2D** getSurfacePtr() {return &mD3DSurface;}
  62. // GFXResource
  63. void zombify();
  64. void resurrect();
  65. #ifdef TORQUE_DEBUG
  66. virtual void pureVirtualCrash() {};
  67. #endif
  68. };
  69. #endif