CmD3D11Texture.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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::lock
  31. */
  32. PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
  33. /**
  34. * @copydoc Texture::unlock
  35. */
  36. void unlockImpl();
  37. /**
  38. * @copydoc Texture::copy
  39. */
  40. void copyImpl(TexturePtr& target);
  41. /**
  42. * @copydoc Texture::readData
  43. */
  44. void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0);
  45. /**
  46. * @copydoc Texture::writeData
  47. */
  48. void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false);
  49. /// internal method, create a blank normal 1D Dtexture
  50. void create1DTex();
  51. /// internal method, create a blank normal 2D texture
  52. void create2DTex();
  53. /// internal method, create a blank cube texture
  54. void create3DTex();
  55. void createStagingBuffer();
  56. void* map(ID3D11Resource* res, D3D11_MAP flags, UINT32 mipLevel, UINT32 face, UINT32& rowPitch, UINT32& slicePitch);
  57. void unmap(ID3D11Resource* res);
  58. void* mapstagingbuffer(D3D11_MAP flags, UINT32 mipLevel, UINT32 face, UINT32& rowPitch, UINT32& slicePitch);
  59. void unmapstagingbuffer();
  60. void* mapstaticbuffer(PixelData lock, UINT32 mipLevel, UINT32 slice);
  61. void unmapstaticbuffer();
  62. /**
  63. * @copydoc Texture::initialize_internal()
  64. */
  65. void initialize_internal();
  66. /**
  67. * @copydoc Texture::destroy_internal()
  68. */
  69. void destroy_internal();
  70. TextureViewPtr createView();
  71. };
  72. }