BsTexture.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsResource.h"
  6. #include "BsHardwareBuffer.h"
  7. #include "BsPixelUtil.h"
  8. #include "BsTextureView.h"
  9. namespace BansheeEngine
  10. {
  11. /** @addtogroup Resources
  12. * @{
  13. */
  14. /** Flags that describe how is a texture used. */
  15. enum TextureUsage
  16. {
  17. TU_STATIC = GBU_STATIC, /**< A regular texture that is not often or ever updated from the CPU. */
  18. TU_DYNAMIC = GBU_DYNAMIC, /**< A regular texture that is often updated by the CPU. */
  19. TU_RENDERTARGET = 0x200, /**< Texture that can be rendered to by the GPU. */
  20. TU_DEPTHSTENCIL = 0x400, /**< Texture used as a depth/stencil buffer by the GPU. */
  21. TU_LOADSTORE = 0x800, /**< Texture that allows load/store operations from the GPU program. */
  22. /** All mesh data will also be cached in CPU memory, making it available for fast read access from the CPU. */
  23. TU_CPUCACHED = 0x1000,
  24. TU_CPUREADABLE = 0x2000, /**< Allows the CPU to directly read the texture data buffers from the GPU. */
  25. TU_DEFAULT = TU_STATIC
  26. };
  27. /** Available texture types. */
  28. enum TextureType
  29. {
  30. TEX_TYPE_1D = 1, /**< One dimensional texture. Just a row of pixels. */
  31. TEX_TYPE_2D = 2, /**< Two dimensional texture. */
  32. TEX_TYPE_3D = 3, /**< Three dimensional texture. */
  33. TEX_TYPE_CUBE_MAP = 4 /**< Texture consisting out of six 2D textures describing an inside of a cube. Allows special sampling. */
  34. };
  35. /** Texture mipmap options. */
  36. enum TextureMipmap
  37. {
  38. MIP_UNLIMITED = 0x7FFFFFFF /**< Create all mip maps down to 1x1. */
  39. };
  40. /** Descriptor structure used for initialization of a Texture. */
  41. struct TEXTURE_DESC
  42. {
  43. /** Type of the texture. */
  44. TextureType type = TEX_TYPE_2D;
  45. /** Format of pixels in the texture. */
  46. PixelFormat format = PF_R8G8B8A8;
  47. /** Width of the texture in pixels. */
  48. UINT32 width = 1;
  49. /** Height of the texture in pixels. */
  50. UINT32 height = 1;
  51. /** Depth of the texture in pixels (Must be 1 for 2D textures). */
  52. UINT32 depth = 1;
  53. /** Number of mip-maps the texture has. This number excludes the full resolution map. */
  54. UINT32 numMips = 0;
  55. /** Describes how the caller plans on using the texture in the pipeline. */
  56. INT32 usage = TU_DEFAULT;
  57. /**
  58. * If true the texture data is assumed to have been gamma corrected and will be converted back to linear space when
  59. * sampled on GPU.
  60. */
  61. bool hwGamma = false;
  62. /** Number of samples per pixel. Set to 1 or 0 to use the default of a single sample per pixel. */
  63. UINT32 numSamples = 0;
  64. /** Number of texture slices to create if creating a texture array. Ignored for 3D textures. */
  65. UINT32 numArraySlices = 1;
  66. };
  67. /** Properties of a Texture. Shared between sim and core thread versions of a Texture. */
  68. class BS_CORE_EXPORT TextureProperties
  69. {
  70. public:
  71. TextureProperties();
  72. TextureProperties(const TEXTURE_DESC& desc);
  73. /** Gets the type of texture. */
  74. TextureType getTextureType() const { return mDesc.type; }
  75. /**
  76. * Gets the number of mipmaps to be used for this texture. This number excludes the top level map (which is always
  77. * assumed to be present).
  78. */
  79. UINT32 getNumMipmaps() const {return mDesc.numMips;}
  80. /** Gets whether this texture will be set up so that on sampling it, hardware gamma correction is applied. */
  81. bool isHardwareGammaEnabled() const { return mDesc.hwGamma; }
  82. /** Gets the number of samples used for multisampling (0 if multisampling is not used). */
  83. UINT32 getNumSamples() const { return mDesc.numSamples; }
  84. /** Returns the height of the texture. */
  85. UINT32 getHeight() const { return mDesc.height; }
  86. /** Returns the width of the texture. */
  87. UINT32 getWidth() const { return mDesc.width; }
  88. /** Returns the depth of the texture (only applicable for 3D textures). */
  89. UINT32 getDepth() const { return mDesc.depth; }
  90. /** Returns texture usage (TextureUsage) of this texture. */
  91. int getUsage() const { return mDesc.usage; }
  92. /** Returns the pixel format for the texture surface. */
  93. PixelFormat getFormat() const { return mDesc.format; }
  94. /** Returns true if the texture has an alpha layer. */
  95. bool hasAlpha() const;
  96. /**
  97. * Returns the number of faces this texture has. This includes array slices (if texture is an array texture),
  98. * as well as cube-map faces.
  99. */
  100. UINT32 getNumFaces() const;
  101. /** Returns the number of array slices of the texture (if the texture is an array texture). */
  102. UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
  103. /**
  104. * Maps a sub-resource index to an exact face and mip level. Sub-resource indexes are used when reading or writing
  105. * to the resource.
  106. *
  107. * @note
  108. * Sub-resource index is only valid for the instance it was created on. You cannot use a sub-resource index from a
  109. * different texture and expect to get valid result. Modifying the resource so the number of sub-resources changes
  110. * invalidates all sub-resource indexes.
  111. */
  112. void mapFromSubresourceIdx(UINT32 subresourceIdx, UINT32& face, UINT32& mip) const;
  113. /**
  114. * Map a face and a mip level to a sub-resource index you can use for updating or reading a specific sub-resource.
  115. *
  116. * @note
  117. * Generated sub-resource index is only valid for the instance it was created on. Modifying the resource so the
  118. * number of sub-resources changes, invalidates all sub-resource indexes.
  119. */
  120. UINT32 mapToSubresourceIdx(UINT32 face, UINT32 mip) const;
  121. /**
  122. * Allocates a buffer you may use for storage when reading or writing a sub-resource. You need to allocate such a
  123. * buffer if you are calling readSubresource().
  124. *
  125. * You can retrieve a sub-resource index by calling mapToSubresourceIdx().
  126. *
  127. * @note Thread safe.
  128. */
  129. SPtr<PixelData> allocateSubresourceBuffer(UINT32 subresourceIdx) const;
  130. protected:
  131. friend class TextureRTTI;
  132. friend class Texture;
  133. TEXTURE_DESC mDesc;
  134. };
  135. /**
  136. * Abstract class representing a texture. Specific render systems have their own Texture implementations. Internally
  137. * represented as one or more surfaces with pixels in a certain number of dimensions, backed by a hardware buffer.
  138. *
  139. * @note Sim thread.
  140. */
  141. class BS_CORE_EXPORT Texture : public Resource
  142. {
  143. public:
  144. /**
  145. * Updates the texture with new data. The actual write will be queued for later execution on the core thread.
  146. * Provided data buffer will be locked until the operation completes.
  147. *
  148. * @param[in] accessor Accessor to queue the operation on.
  149. * @param[in] subresourceIdx Index of the subresource to write. Retrieved from
  150. * TextureProperties::mapToSubresourceIdx().
  151. * @param[in] data Pixel data to write. User must ensure it is in format and size compatible with
  152. * the texture.
  153. * @param[in] discardEntireBuffer When true the existing contents of the resource you are updating will be
  154. * discarded. This can make the operation faster. Resources with certain buffer
  155. * types might require this flag to be in a specific state otherwise the operation
  156. * will fail.
  157. * @return Async operation object you can use to track operation completion.
  158. */
  159. AsyncOp writeSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const SPtr<PixelData>& data,
  160. bool discardEntireBuffer);
  161. /**
  162. * Reads internal texture data to the provided previously allocated buffer. The read is queued for execution on the
  163. * core thread and not executed immediately. Provided data buffer will be locked until the operation completes.
  164. *
  165. * @param[in] accessor Accessor to queue the operation on.
  166. * @param[in] subresourceIdx Index of the subresource to read. Retrieved from
  167. * TextureProperties::mapToSubresourceIdx().
  168. * @param[out] data Pre-allocated buffer of proper size and format where data will be read to. You
  169. * can use TextureProperties::allocateSubresourceBuffer() to allocate a valid
  170. * buffer.
  171. * @return Async operation object you can use to track operation completion.
  172. *
  173. * @see TextureCore::readSubresource
  174. */
  175. AsyncOp readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const SPtr<PixelData>& data);
  176. /**
  177. * Reads data from the cached system memory texture buffer into the provided buffer.
  178. *
  179. * @param[out] dest Previously allocated buffer to read data into.
  180. * @param[in] mipLevel (optional) Mipmap level to read from.
  181. * @param[in] face (optional) Texture face to read from.
  182. *
  183. * @note
  184. * The data read is the cached texture data. Any data written to the texture from the GPU or core thread will not
  185. * be reflected in this data. Use readSubresource() if you require those changes.
  186. * @note
  187. * The texture must have been created with TU_CPUCACHED usage otherwise this method will not return any data.
  188. */
  189. void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0);
  190. /** Returns properties that contain information about the texture. */
  191. const TextureProperties& getProperties() const { return mProperties; }
  192. /** Retrieves a core implementation of a texture usable only from the core thread. */
  193. SPtr<TextureCore> getCore() const;
  194. /************************************************************************/
  195. /* STATICS */
  196. /************************************************************************/
  197. /**
  198. * Creates a new empty texture.
  199. *
  200. * @param[in] desc Description of the texture to create.
  201. */
  202. static HTexture create(const TEXTURE_DESC& desc);
  203. /**
  204. * Creates a new 2D or 3D texture initialized using the provided pixel data. Texture will not have any mipmaps.
  205. *
  206. * @param[in] pixelData Data to initialize the texture width.
  207. * @param[in] usage Describes planned texture use.
  208. * @param[in] hwGammaCorrection If true the texture data is assumed to have been gamma corrected and will be
  209. * converted back to linear space when sampled on GPU.
  210. */
  211. static HTexture create(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
  212. /** @name Internal
  213. * @{
  214. */
  215. /**
  216. * @copydoc create(const TEXTURE_DESC&)
  217. *
  218. * @note Internal method. Creates a texture pointer without a handle. Use create() for normal usage.
  219. */
  220. static SPtr<Texture> _createPtr(const TEXTURE_DESC& desc);
  221. /**
  222. * @copydoc create(const SPtr<PixelData>&, int, bool)
  223. *
  224. * @note Internal method. Creates a texture pointer without a handle. Use create() for normal usage.
  225. */
  226. static SPtr<Texture> _createPtr(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT,
  227. bool hwGammaCorrection = false);
  228. /** @} */
  229. protected:
  230. friend class TextureManager;
  231. Texture(const TEXTURE_DESC& desc);
  232. Texture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData);
  233. /** @copydoc Resource::initialize */
  234. void initialize() override;
  235. /** @copydoc CoreObject::createCore */
  236. SPtr<CoreObjectCore> createCore() const override;
  237. /** Calculates the size of the texture, in bytes. */
  238. UINT32 calculateSize() const;
  239. /**
  240. * Creates buffers used for caching of CPU texture data.
  241. *
  242. * @note Make sure to initialize all texture properties before calling this.
  243. */
  244. void createCPUBuffers();
  245. /** Updates the cached CPU buffers with new data. */
  246. void updateCPUBuffers(UINT32 subresourceIdx, const PixelData& data);
  247. protected:
  248. Vector<SPtr<PixelData>> mCPUSubresourceData;
  249. TextureProperties mProperties;
  250. mutable SPtr<PixelData> mInitData;
  251. /************************************************************************/
  252. /* SERIALIZATION */
  253. /************************************************************************/
  254. public:
  255. Texture(); // Serialization only
  256. friend class TextureRTTI;
  257. static RTTITypeBase* getRTTIStatic();
  258. RTTITypeBase* getRTTI() const override;
  259. };
  260. /** @} */
  261. /** @addtogroup Resources-Internal
  262. * @{
  263. */
  264. /**
  265. * Core thread version of a Texture.
  266. *
  267. * @note Core thread.
  268. */
  269. class BS_CORE_EXPORT TextureCore : public CoreObjectCore
  270. {
  271. public:
  272. TextureCore(const TEXTURE_DESC& desc, const SPtr<PixelData>& initData, GpuDeviceFlags deviceMask);
  273. virtual ~TextureCore() {}
  274. /** @copydoc CoreObjectCore::initialize */
  275. void initialize() override;
  276. /**
  277. * Updates a part of the texture with the provided data.
  278. *
  279. * @param[in] subresourceIdx Index of the subresource to update, if the texture has more than one.
  280. * @param[in] data Data to update the texture with.
  281. * @param[in] discardEntireBuffer When true the existing contents of the resource you are updating will be
  282. * discarded. This can make the operation faster. Resources with certain buffer
  283. * types might require this flag to be in a specific state otherwise the operation
  284. * will fail.
  285. * @param[in] queueIdx Device queue to perform the write operation on. Using a non-default queue index
  286. * allows the GPU to perform write operations while executing rendering or compute
  287. * operations on the same time.
  288. *
  289. * This value is a global queue index which encodes both the queue type and queue
  290. * index. Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  291. */
  292. virtual void writeSubresource(UINT32 subresourceIdx, const PixelData& data, bool discardEntireBuffer,
  293. UINT32 queueIdx = 0);
  294. /**
  295. * Reads a part of the current resource into the provided @p data parameter. Data buffer needs to be pre-allocated.
  296. *
  297. * @param[in] subresourceIdx Index of the subresource to update, if the texture has more than one.
  298. * @param[out] data Buffer that will receive the data. Should be allocated with
  299. * allocateSubresourceBuffer() to ensure it is of valid type and size.
  300. * @param[in] deviceIdx Index of the device whose memory to read. If the buffer doesn't exist on this
  301. * device, no data will be read.
  302. * @param[in] queueIdx Device queue to perform the read operation on. Using a non-default queue index
  303. * allows the GPU to perform read operations while executing rendering or compute
  304. * operations on the same time.
  305. *
  306. * This value is a global queue index which encodes both the queue type and queue
  307. * index. Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  308. */
  309. virtual void readSubresource(UINT32 subresourceIdx, PixelData& data, UINT32 deviceIdx = 0, UINT32 queueIdx = 0);
  310. /**
  311. * Locks the buffer for reading or writing.
  312. *
  313. * @param[in] options Options for controlling what you may do with the locked data.
  314. * @param[in] mipLevel (optional) Mipmap level to lock.
  315. * @param[in] face (optional) Texture face to lock.
  316. * @param[in] deviceIdx Index of the device whose memory to map. If the buffer doesn't exist on this device,
  317. * the method returns null.
  318. * @param[in] queueIdx Device queue to perform any read/write operations on. Using a non-default queue index
  319. * allows the GPU to perform write or read operations while executing rendering or compute
  320. * operations on the same time.
  321. *
  322. * Note that when writing to a texture that is being used on a command buffer with a
  323. * different queue you must ensure to provide the command buffer with a valid sync mask
  324. * so it knows to wait before the write operation completes.
  325. *
  326. * This value is a global queue index which encodes both the queue type and queue index.
  327. * Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  328. * @return Pointer to the buffer data. Only valid until you call unlock().
  329. *
  330. * @note
  331. * If you are just reading or writing one block of data use readData()/writeData() methods as they can be much faster
  332. * in certain situations.
  333. */
  334. PixelData lock(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0, UINT32 deviceIdx = 0,
  335. UINT32 queueIdx = 0);
  336. /**
  337. * Unlocks a previously locked buffer. After the buffer is unlocked, any data returned by lock becomes invalid.
  338. *
  339. * @see lock()
  340. */
  341. void unlock();
  342. /**
  343. * Copies the contents a subresource in this texture to another texture. Texture format and size of the subresource
  344. * must match.
  345. *
  346. * You are allowed to copy from a multisampled to non-multisampled surface, which will resolve the multisampled
  347. * surface before copying.
  348. *
  349. * @param[in] srcSubresourceIdx Index of the subresource to copy from.
  350. * @param[in] destSubresourceIdx Index of the subresource to copy to.
  351. * @param[in] target Texture that contains the destination subresource.
  352. * @param[in] queueIdx Device queue to perform any read/write operations on. Using a non-default queue
  353. * index allows the GPU to perform write or read operations while executing
  354. * rendering or compute operations on the same time.
  355. *
  356. * Note that when writing to a texture that is being used on a command buffer with
  357. * a different queue you must ensure to provide the command buffer with a valid
  358. * sync mask so it knows to wait before the write operation completes.
  359. *
  360. * This value is a global queue index which encodes both the queue type and queue
  361. * index. Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  362. */
  363. void copy(UINT32 srcSubresourceIdx, UINT32 destSubresourceIdx, const SPtr<TextureCore>& target, UINT32 queueIdx = 0);
  364. /**
  365. * Reads data from the texture buffer into the provided buffer.
  366. *
  367. * @param[out] dest Previously allocated buffer to read data into.
  368. * @param[in] mipLevel (optional) Mipmap level to read from.
  369. * @param[in] face (optional) Texture face to read from.
  370. * @param[in] deviceIdx Index of the device whose memory to read. If the buffer doesn't exist on this device,
  371. * no data will be read.
  372. * @param[in] queueIdx Device queue to perform the read operation on. Using a non-default queue index
  373. * allows the GPU to perform read operations while executing rendering or compute
  374. * operations on the same time.
  375. *
  376. * This value is a global queue index which encodes both the queue type and queue index.
  377. * Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  378. */
  379. virtual void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0, UINT32 deviceIdx = 0,
  380. UINT32 queueIdx = 0) = 0;
  381. /**
  382. * Writes data from the provided buffer into the texture buffer.
  383. *
  384. * @param[in] src Buffer to retrieve the data from.
  385. * @param[in] mipLevel (optional) Mipmap level to write into.
  386. * @param[in] face (optional) Texture face to write into.
  387. * @param[in] discardWholeBuffer (optional) If true any existing texture data will be discard. This can improve
  388. * performance of the write operation.
  389. * @param[in] queueIdx Device queue to perform any write operations on. Using a non-default queue index
  390. * allows the GPU to perform write operations while executing rendering or compute
  391. * operations on the same time.
  392. *
  393. * Note that when writing to a texture that is being used on a command buffer with
  394. * a different queue you must ensure to provide the command buffer with a valid
  395. * sync mask so it knows to wait before the write operation completes.
  396. *
  397. * This value is a global queue index which encodes both the queue type and queue
  398. * index. Retrieve it from CommandSyncMask::getGlobalQueueIdx().
  399. */
  400. virtual void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false,
  401. UINT32 queueIdx = 0) = 0;
  402. /** Returns properties that contain information about the texture. */
  403. const TextureProperties& getProperties() const { return mProperties; }
  404. /************************************************************************/
  405. /* STATICS */
  406. /************************************************************************/
  407. /**
  408. * @copydoc Texture::create(const TEXTURE_DESC&)
  409. * @param[in] deviceMask Mask that determines on which GPU devices should the object be created on.
  410. */
  411. static SPtr<TextureCore> create(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT);
  412. /**
  413. * @copydoc Texture::create(const SPtr<PixelData>&, int, bool)
  414. * @param[in] deviceMask Mask that determines on which GPU devices should the object be created on.
  415. */
  416. static SPtr<TextureCore> create(const SPtr<PixelData>& pixelData, int usage = TU_DEFAULT,
  417. bool hwGammaCorrection = false, GpuDeviceFlags deviceMask = GDF_DEFAULT);
  418. /************************************************************************/
  419. /* TEXTURE VIEW */
  420. /************************************************************************/
  421. /**
  422. * Requests a texture view for the specified mip and array ranges. Returns an existing view of one for the specified
  423. * ranges already exists, otherwise creates a new one. You must release all views by calling releaseView() when done.
  424. *
  425. * @note Core thread only.
  426. */
  427. static SPtr<TextureView> requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips,
  428. UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage);
  429. /**
  430. * Releases the view. View won't actually get destroyed until all references to it are released.
  431. *
  432. * @note Core thread only.
  433. */
  434. static void releaseView(const SPtr<TextureView>& view);
  435. /** Returns a plain white texture. */
  436. static SPtr<TextureCore> WHITE;
  437. /** Returns a plain black texture. */
  438. static SPtr<TextureCore> BLACK;
  439. /** Returns a plain normal map texture with normal pointing up (in Y direction). */
  440. static SPtr<TextureCore> NORMAL;
  441. protected:
  442. /** @copydoc lock */
  443. virtual PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0, UINT32 deviceIdx = 0,
  444. UINT32 queueIdx = 0) = 0;
  445. /** @copydoc unlock */
  446. virtual void unlockImpl() = 0;
  447. /**
  448. * API specific implementation of copy().
  449. *
  450. * @param[in] srcFace Face index to copy from.
  451. * @param[in] srcMipLevel Mip level to copy from.
  452. * @param[in] destFace Face index to copy to.
  453. * @param[in] destMipLevel Mip level to copy to.
  454. * @param[in] target Texture to copy to.
  455. * @param[in] queueIdx Global queue index to perform the copy on.
  456. */
  457. virtual void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel,
  458. const SPtr<TextureCore>& target, UINT32 queueIdx = 0) = 0;
  459. /************************************************************************/
  460. /* TEXTURE VIEW */
  461. /************************************************************************/
  462. /** Creates a new empty/undefined texture view. */
  463. virtual SPtr<TextureView> createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
  464. /**
  465. * Releases all internal texture view references. Views won't get destroyed if there are external references still
  466. * held.
  467. */
  468. void clearBufferViews();
  469. /** Holds a single texture view with a usage reference count. */
  470. struct TextureViewReference
  471. {
  472. TextureViewReference(SPtr<TextureView> _view)
  473. :view(_view), refCount(0)
  474. { }
  475. SPtr<TextureView> view;
  476. UINT32 refCount;
  477. };
  478. UnorderedMap<TEXTURE_VIEW_DESC, TextureViewReference*, TextureView::HashFunction, TextureView::EqualFunction> mTextureViews;
  479. TextureProperties mProperties;
  480. SPtr<PixelData> mInitData;
  481. };
  482. /** @} */
  483. }