CmD3D11Texture.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmTexture.h"
  4. namespace CamelotFramework
  5. {
  6. class D3D11Texture : public Texture
  7. {
  8. public:
  9. ~D3D11Texture();
  10. ID3D11Resource* getDX11Resource() const { return mTex; }
  11. ID3D11ShaderResourceView* getSRV() const { return mShaderResourceView; }
  12. D3D11_SRV_DIMENSION getDimension() const { return mDimension; }
  13. DXGI_FORMAT getDXGIFormat() const { return mDXGIFormat; }
  14. protected:
  15. friend class D3D11TextureManager;
  16. D3D11Texture();
  17. ID3D11Texture1D* m1DTex;
  18. ID3D11Texture2D* m2DTex;
  19. ID3D11Texture3D* m3DTex;
  20. ID3D11Resource* mTex;
  21. ID3D11ShaderResourceView* mShaderResourceView;
  22. D3D11_SHADER_RESOURCE_VIEW_DESC mSRVDesc;
  23. D3D11_SRV_DIMENSION mDimension;
  24. DXGI_FORMAT mDXGIFormat;
  25. ID3D11Resource* mStagingBuffer;
  26. PixelData* mStaticBuffer;
  27. UINT32 mLockedSubresourceIdx;
  28. bool mLockedForReading;
  29. /**
  30. * @copydoc Texture::lockImpl
  31. */
  32. PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
  33. /**
  34. * @copydoc Texture::unlockImpl
  35. */
  36. void unlockImpl();
  37. /**
  38. * @copydoc Texture::copy_internal
  39. */
  40. void copyImpl(TexturePtr& target);
  41. /// internal method, create a blank normal 1D Dtexture
  42. void _create1DTex();
  43. /// internal method, create a blank normal 2D texture
  44. void _create2DTex();
  45. /// internal method, create a blank cube texture
  46. void _create3DTex();
  47. void _createStagingBuffer();
  48. void* _map(ID3D11Resource* res, D3D11_MAP flags, UINT32 mipLevel, UINT32 face, UINT32& rowPitch, UINT32& slicePitch);
  49. void _unmap(ID3D11Resource* res);
  50. void* _mapstagingbuffer(D3D11_MAP flags, UINT32 mipLevel, UINT32 face, UINT32& rowPitch, UINT32& slicePitch);
  51. void _unmapstagingbuffer();
  52. void* _mapstaticbuffer(PixelData lock, UINT32 mipLevel, UINT32 slice);
  53. void _unmapstaticbuffer();
  54. /**
  55. * @copydoc Texture::initialize_internal()
  56. */
  57. void initialize_internal();
  58. /**
  59. * @copydoc Texture::destroy_internal()
  60. */
  61. void destroy_internal();
  62. TextureViewPtr createView();
  63. };
  64. }