BsTexture.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Image/BsTexture.h"
  4. #include "RTTI/BsTextureRTTI.h"
  5. #include "FileSystem/BsDataStream.h"
  6. #include "Error/BsException.h"
  7. #include "Debug/BsDebug.h"
  8. #include "CoreThread/BsCoreThread.h"
  9. #include "Threading/BsAsyncOp.h"
  10. #include "Resources/BsResources.h"
  11. #include "Image/BsPixelUtil.h"
  12. namespace bs
  13. {
  14. TEXTURE_COPY_DESC TEXTURE_COPY_DESC::DEFAULT = TEXTURE_COPY_DESC();
  15. TextureProperties::TextureProperties()
  16. { }
  17. TextureProperties::TextureProperties(const TEXTURE_DESC& desc)
  18. :mDesc(desc)
  19. {
  20. }
  21. bool TextureProperties::hasAlpha() const
  22. {
  23. return PixelUtil::hasAlpha(mDesc.format);
  24. }
  25. UINT32 TextureProperties::getNumFaces() const
  26. {
  27. UINT32 facesPerSlice = getTextureType() == TEX_TYPE_CUBE_MAP ? 6 : 1;
  28. return facesPerSlice * mDesc.numArraySlices;
  29. }
  30. void TextureProperties::mapFromSubresourceIdx(UINT32 subresourceIdx, UINT32& face, UINT32& mip) const
  31. {
  32. UINT32 numMipmaps = getNumMipmaps() + 1;
  33. face = Math::floorToInt((subresourceIdx) / (float)numMipmaps);
  34. mip = subresourceIdx % numMipmaps;
  35. }
  36. UINT32 TextureProperties::mapToSubresourceIdx(UINT32 face, UINT32 mip) const
  37. {
  38. return face * (getNumMipmaps() + 1) + mip;
  39. }
  40. SPtr<PixelData> TextureProperties::allocBuffer(UINT32 face, UINT32 mipLevel) const
  41. {
  42. UINT32 width = getWidth();
  43. UINT32 height = getHeight();
  44. UINT32 depth = getDepth();
  45. for (UINT32 j = 0; j < mipLevel; j++)
  46. {
  47. if (width != 1) width /= 2;
  48. if (height != 1) height /= 2;
  49. if (depth != 1) depth /= 2;
  50. }
  51. SPtr<PixelData> dst = bs_shared_ptr_new<PixelData>(width, height, depth, getFormat());
  52. dst->allocateInternalBuffer();
  53. return dst;
  54. }
  55. Texture::Texture()
  56. {
  57. }
  58. Texture::Texture(const TEXTURE_DESC& desc)
  59. :mProperties(desc)
  60. {
  61. }
  62. Texture::Texture(const TEXTURE_DESC& desc, const SPtr<PixelData>& pixelData)
  63. : mProperties(desc), mInitData(pixelData)
  64. {
  65. if (mInitData != nullptr)
  66. mInitData->_lock();
  67. }
  68. void Texture::initialize()
  69. {
  70. mSize = calculateSize();
  71. // Allocate CPU buffers if needed
  72. if ((mProperties.getUsage() & TU_CPUCACHED) != 0)
  73. {
  74. createCPUBuffers();
  75. if (mInitData != nullptr)
  76. updateCPUBuffers(0, *mInitData);
  77. }
  78. Resource::initialize();
  79. }
  80. SPtr<ct::CoreObject> Texture::createCore() const
  81. {
  82. const TextureProperties& props = getProperties();
  83. SPtr<ct::CoreObject> coreObj = ct::TextureManager::instance().createTextureInternal(props.mDesc, mInitData);
  84. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  85. mInitData = nullptr;
  86. return coreObj;
  87. }
  88. AsyncOp Texture::writeData(const SPtr<PixelData>& data, UINT32 face, UINT32 mipLevel, bool discardEntireBuffer)
  89. {
  90. UINT32 subresourceIdx = mProperties.mapToSubresourceIdx(face, mipLevel);
  91. updateCPUBuffers(subresourceIdx, *data);
  92. data->_lock();
  93. std::function<void(const SPtr<ct::Texture>&, UINT32, UINT32, const SPtr<PixelData>&, bool, AsyncOp&)> func =
  94. [&](const SPtr<ct::Texture>& texture, UINT32 _face, UINT32 _mipLevel, const SPtr<PixelData>& _pixData,
  95. bool _discardEntireBuffer, AsyncOp& asyncOp)
  96. {
  97. texture->writeData(*_pixData, _mipLevel, _face, _discardEntireBuffer);
  98. _pixData->_unlock();
  99. asyncOp._completeOperation();
  100. };
  101. return gCoreThread().queueReturnCommand(std::bind(func, getCore(), face, mipLevel,
  102. data, discardEntireBuffer, std::placeholders::_1));
  103. }
  104. AsyncOp Texture::readData(const SPtr<PixelData>& data, UINT32 face, UINT32 mipLevel)
  105. {
  106. data->_lock();
  107. std::function<void(const SPtr<ct::Texture>&, UINT32, UINT32, const SPtr<PixelData>&, AsyncOp&)> func =
  108. [&](const SPtr<ct::Texture>& texture, UINT32 _face, UINT32 _mipLevel, const SPtr<PixelData>& _pixData,
  109. AsyncOp& asyncOp)
  110. {
  111. // Make sure any queued command start executing before reading
  112. ct::RenderAPI::instance().submitCommandBuffer(nullptr);
  113. texture->readData(*_pixData, _mipLevel, _face);
  114. _pixData->_unlock();
  115. asyncOp._completeOperation();
  116. };
  117. return gCoreThread().queueReturnCommand(std::bind(func, getCore(), face, mipLevel,
  118. data, std::placeholders::_1));
  119. }
  120. UINT32 Texture::calculateSize() const
  121. {
  122. return mProperties.getNumFaces() * PixelUtil::getMemorySize(mProperties.getWidth(),
  123. mProperties.getHeight(), mProperties.getDepth(), mProperties.getFormat());
  124. }
  125. void Texture::updateCPUBuffers(UINT32 subresourceIdx, const PixelData& pixelData)
  126. {
  127. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  128. return;
  129. if (subresourceIdx >= (UINT32)mCPUSubresourceData.size())
  130. {
  131. LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. " + toString((UINT32)mCPUSubresourceData.size()));
  132. return;
  133. }
  134. UINT32 mipLevel;
  135. UINT32 face;
  136. mProperties.mapFromSubresourceIdx(subresourceIdx, face, mipLevel);
  137. UINT32 mipWidth, mipHeight, mipDepth;
  138. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  139. mipLevel, mipWidth, mipHeight, mipDepth);
  140. if (pixelData.getWidth() != mipWidth || pixelData.getHeight() != mipHeight ||
  141. pixelData.getDepth() != mipDepth || pixelData.getFormat() != mProperties.getFormat())
  142. {
  143. LOGERR("Provided buffer is not of valid dimensions or format in order to update this texture.");
  144. return;
  145. }
  146. if (mCPUSubresourceData[subresourceIdx]->getSize() != pixelData.getSize())
  147. BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
  148. UINT8* dest = mCPUSubresourceData[subresourceIdx]->getData();
  149. UINT8* src = pixelData.getData();
  150. memcpy(dest, src, pixelData.getSize());
  151. }
  152. void Texture::readCachedData(PixelData& dest, UINT32 face, UINT32 mipLevel)
  153. {
  154. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  155. {
  156. LOGERR("Attempting to read CPU data from a texture that is created without CPU caching.");
  157. return;
  158. }
  159. UINT32 mipWidth, mipHeight, mipDepth;
  160. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  161. mipLevel, mipWidth, mipHeight, mipDepth);
  162. if (dest.getWidth() != mipWidth || dest.getHeight() != mipHeight ||
  163. dest.getDepth() != mipDepth || dest.getFormat() != mProperties.getFormat())
  164. {
  165. LOGERR("Provided buffer is not of valid dimensions or format in order to read from this texture.");
  166. return;
  167. }
  168. UINT32 subresourceIdx = mProperties.mapToSubresourceIdx(face, mipLevel);
  169. if (subresourceIdx >= (UINT32)mCPUSubresourceData.size())
  170. {
  171. LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. " + toString((UINT32)mCPUSubresourceData.size()));
  172. return;
  173. }
  174. if (mCPUSubresourceData[subresourceIdx]->getSize() != dest.getSize())
  175. BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
  176. UINT8* srcPtr = mCPUSubresourceData[subresourceIdx]->getData();
  177. UINT8* destPtr = dest.getData();
  178. memcpy(destPtr, srcPtr, dest.getSize());
  179. }
  180. void Texture::createCPUBuffers()
  181. {
  182. UINT32 numFaces = mProperties.getNumFaces();
  183. UINT32 numMips = mProperties.getNumMipmaps() + 1;
  184. UINT32 numSubresources = numFaces * numMips;
  185. mCPUSubresourceData.resize(numSubresources);
  186. for (UINT32 i = 0; i < numFaces; i++)
  187. {
  188. UINT32 curWidth = mProperties.getWidth();
  189. UINT32 curHeight = mProperties.getHeight();
  190. UINT32 curDepth = mProperties.getDepth();
  191. for (UINT32 j = 0; j < numMips; j++)
  192. {
  193. UINT32 subresourceIdx = mProperties.mapToSubresourceIdx(i, j);
  194. mCPUSubresourceData[subresourceIdx] = bs_shared_ptr_new<PixelData>(curWidth, curHeight, curDepth, mProperties.getFormat());
  195. mCPUSubresourceData[subresourceIdx]->allocateInternalBuffer();
  196. if (curWidth > 1)
  197. curWidth = curWidth / 2;
  198. if (curHeight > 1)
  199. curHeight = curHeight / 2;
  200. if (curDepth > 1)
  201. curDepth = curDepth / 2;
  202. }
  203. }
  204. }
  205. SPtr<ct::Texture> Texture::getCore() const
  206. {
  207. return std::static_pointer_cast<ct::Texture>(mCoreSpecific);
  208. }
  209. /************************************************************************/
  210. /* SERIALIZATION */
  211. /************************************************************************/
  212. RTTITypeBase* Texture::getRTTIStatic()
  213. {
  214. return TextureRTTI::instance();
  215. }
  216. RTTITypeBase* Texture::getRTTI() const
  217. {
  218. return Texture::getRTTIStatic();
  219. }
  220. /************************************************************************/
  221. /* STATICS */
  222. /************************************************************************/
  223. HTexture Texture::create(const TEXTURE_DESC& desc)
  224. {
  225. SPtr<Texture> texturePtr = _createPtr(desc);
  226. return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
  227. }
  228. HTexture Texture::create(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection)
  229. {
  230. SPtr<Texture> texturePtr = _createPtr(pixelData, usage, hwGammaCorrection);
  231. return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
  232. }
  233. SPtr<Texture> Texture::_createPtr(const TEXTURE_DESC& desc)
  234. {
  235. return TextureManager::instance().createTexture(desc);
  236. }
  237. SPtr<Texture> Texture::_createPtr(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection)
  238. {
  239. TEXTURE_DESC desc;
  240. desc.type = pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D;
  241. desc.width = pixelData->getWidth();
  242. desc.height = pixelData->getHeight();
  243. desc.depth = pixelData->getDepth();
  244. desc.format = pixelData->getFormat();
  245. desc.usage = usage;
  246. desc.hwGamma = hwGammaCorrection;
  247. return TextureManager::instance().createTexture(desc, pixelData);
  248. }
  249. namespace ct
  250. {
  251. SPtr<Texture> Texture::WHITE;
  252. SPtr<Texture> Texture::BLACK;
  253. SPtr<Texture> Texture::NORMAL;
  254. Texture::Texture(const TEXTURE_DESC& desc, const SPtr<PixelData>& initData, GpuDeviceFlags deviceMask)
  255. :mProperties(desc), mInitData(initData)
  256. { }
  257. void Texture::initialize()
  258. {
  259. if (mInitData != nullptr)
  260. {
  261. writeData(*mInitData, 0, 0, true);
  262. mInitData->_unlock();
  263. mInitData = nullptr;
  264. }
  265. CoreObject::initialize();
  266. }
  267. void Texture::writeData(const PixelData& src, UINT32 mipLevel, UINT32 face, bool discardEntireBuffer,
  268. UINT32 queueIdx)
  269. {
  270. THROW_IF_NOT_CORE_THREAD;
  271. if(discardEntireBuffer)
  272. {
  273. if((mProperties.getUsage() & TU_DYNAMIC) == 0)
  274. {
  275. // Buffer discard is enabled but buffer was not created as dynamic. Disabling discard.
  276. discardEntireBuffer = false;
  277. }
  278. }
  279. writeDataImpl(src, mipLevel, face, discardEntireBuffer, queueIdx);
  280. }
  281. void Texture::readData(PixelData& dest, UINT32 mipLevel, UINT32 face, UINT32 deviceIdx, UINT32 queueIdx)
  282. {
  283. THROW_IF_NOT_CORE_THREAD;
  284. PixelData& pixelData = static_cast<PixelData&>(dest);
  285. UINT32 mipWidth, mipHeight, mipDepth;
  286. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  287. mipLevel, mipWidth, mipHeight, mipDepth);
  288. if (pixelData.getWidth() != mipWidth || pixelData.getHeight() != mipHeight ||
  289. pixelData.getDepth() != mipDepth || pixelData.getFormat() != mProperties.getFormat())
  290. {
  291. LOGERR("Provided buffer is not of valid dimensions or format in order to read from this texture.");
  292. return;
  293. }
  294. readDataImpl(pixelData, mipLevel, face, deviceIdx, queueIdx);
  295. }
  296. PixelData Texture::lock(GpuLockOptions options, UINT32 mipLevel, UINT32 face, UINT32 deviceIdx, UINT32 queueIdx)
  297. {
  298. THROW_IF_NOT_CORE_THREAD;
  299. if (mipLevel > mProperties.getNumMipmaps())
  300. {
  301. LOGERR("Invalid mip level: " + toString(mipLevel) + ". Min is 0, max is " + toString(mProperties.getNumMipmaps()));
  302. return PixelData(0, 0, 0, PF_UNKNOWN);
  303. }
  304. if (face >= mProperties.getNumFaces())
  305. {
  306. LOGERR("Invalid face index: " + toString(face) + ". Min is 0, max is " + toString(mProperties.getNumFaces()));
  307. return PixelData(0, 0, 0, PF_UNKNOWN);
  308. }
  309. return lockImpl(options, mipLevel, face, deviceIdx, queueIdx);
  310. }
  311. void Texture::unlock()
  312. {
  313. THROW_IF_NOT_CORE_THREAD;
  314. unlockImpl();
  315. }
  316. void Texture::copy(const SPtr<Texture>& target, const TEXTURE_COPY_DESC& desc, const SPtr<CommandBuffer>& commandBuffer)
  317. {
  318. THROW_IF_NOT_CORE_THREAD;
  319. if (target->mProperties.getTextureType() != mProperties.getTextureType())
  320. {
  321. LOGERR("Source and destination textures must be of same type.");
  322. return;
  323. }
  324. if (mProperties.getFormat() != target->mProperties.getFormat()) // Note: It might be okay to use different formats of the same size
  325. {
  326. LOGERR("Source and destination texture formats must match.");
  327. return;
  328. }
  329. if (target->mProperties.getNumSamples() > 1 && mProperties.getNumSamples() != target->mProperties.getNumSamples())
  330. {
  331. LOGERR("When copying to a multisampled texture, source texture must have the same number of samples.");
  332. return;
  333. }
  334. if (desc.srcFace >= mProperties.getNumFaces())
  335. {
  336. LOGERR("Invalid source face index.");
  337. return;
  338. }
  339. if (desc.dstFace >= target->mProperties.getNumFaces())
  340. {
  341. LOGERR("Invalid destination face index.");
  342. return;
  343. }
  344. if (desc.srcMip > mProperties.getNumMipmaps())
  345. {
  346. LOGERR("Source mip level out of range. Valid range is [0, " + toString(mProperties.getNumMipmaps()) + "].");
  347. return;
  348. }
  349. if (desc.dstMip > target->mProperties.getNumMipmaps())
  350. {
  351. LOGERR("Destination mip level out of range. Valid range is [0, " + toString(target->mProperties.getNumMipmaps()) + "].");
  352. return;
  353. }
  354. UINT32 srcWidth, srcHeight, srcDepth;
  355. PixelUtil::getSizeForMipLevel(
  356. mProperties.getWidth(),
  357. mProperties.getHeight(),
  358. mProperties.getDepth(),
  359. desc.srcMip,
  360. srcWidth,
  361. srcHeight,
  362. srcDepth);
  363. UINT32 dstWidth, dstHeight, dstDepth;
  364. PixelUtil::getSizeForMipLevel(
  365. target->mProperties.getWidth(),
  366. target->mProperties.getHeight(),
  367. target->mProperties.getDepth(),
  368. desc.dstMip,
  369. dstWidth,
  370. dstHeight,
  371. dstDepth);
  372. if(desc.dstPosition.x < 0 || desc.dstPosition.x >= (INT32)dstWidth ||
  373. desc.dstPosition.y < 0 || desc.dstPosition.y >= (INT32)dstHeight ||
  374. desc.dstPosition.z < 0 || desc.dstPosition.z >= (INT32)dstDepth)
  375. {
  376. LOGERR("Destination position falls outside the destination texture.");
  377. return;
  378. }
  379. bool entireSurface = desc.srcVolume.getWidth() == 0 ||
  380. desc.srcVolume.getHeight() == 0 ||
  381. desc.srcVolume.getDepth() == 0;
  382. UINT32 dstRight = (UINT32)desc.dstPosition.x;
  383. UINT32 dstBottom = (UINT32)desc.dstPosition.y;
  384. UINT32 dstBack = (UINT32)desc.dstPosition.z;
  385. if(!entireSurface)
  386. {
  387. if(desc.srcVolume.left >= srcWidth || desc.srcVolume.right > srcWidth ||
  388. desc.srcVolume.top >= srcHeight || desc.srcVolume.bottom > srcHeight ||
  389. desc.srcVolume.front >= srcDepth || desc.srcVolume.back > srcDepth)
  390. {
  391. LOGERR("Source volume falls outside the source texture.");
  392. return;
  393. }
  394. dstRight += desc.srcVolume.getWidth();
  395. dstBottom += desc.srcVolume.getHeight();
  396. dstBack += desc.srcVolume.getDepth();
  397. }
  398. else
  399. {
  400. dstRight += srcWidth;
  401. dstBottom += srcHeight;
  402. dstBack += srcDepth;
  403. }
  404. if(dstRight > dstWidth || dstBottom > dstHeight || dstBack > dstDepth)
  405. {
  406. LOGERR("Destination volume falls outside the destination texture.");
  407. return;
  408. }
  409. copyImpl(target, desc, commandBuffer);
  410. }
  411. void Texture::clear(const Color& value, UINT32 mipLevel, UINT32 face, UINT32 queueIdx)
  412. {
  413. THROW_IF_NOT_CORE_THREAD;
  414. if (face >= mProperties.getNumFaces())
  415. {
  416. LOGERR("Invalid face index.");
  417. return;
  418. }
  419. if (mipLevel > mProperties.getNumMipmaps())
  420. {
  421. LOGERR("Mip level out of range. Valid range is [0, " + toString(mProperties.getNumMipmaps()) + "].");
  422. return;
  423. }
  424. clearImpl(value, mipLevel, face, queueIdx);
  425. }
  426. void Texture::clearImpl(const Color& value, UINT32 mipLevel, UINT32 face, UINT32 queueIdx)
  427. {
  428. SPtr<PixelData> data = mProperties.allocBuffer(face, mipLevel);
  429. data->setColors(value);
  430. writeData(*data, mipLevel, face, true, queueIdx);
  431. }
  432. /************************************************************************/
  433. /* TEXTURE VIEW */
  434. /************************************************************************/
  435. SPtr<TextureView> Texture::createView(const TEXTURE_VIEW_DESC& desc)
  436. {
  437. return bs_shared_ptr<TextureView>(new (bs_alloc<TextureView>()) TextureView(desc));
  438. }
  439. void Texture::clearBufferViews()
  440. {
  441. mTextureViews.clear();
  442. }
  443. SPtr<TextureView> Texture::requestView(UINT32 mostDetailMip, UINT32 numMips, UINT32 firstArraySlice,
  444. UINT32 numArraySlices, GpuViewUsage usage)
  445. {
  446. THROW_IF_NOT_CORE_THREAD;
  447. const TextureProperties& texProps = getProperties();
  448. TEXTURE_VIEW_DESC key;
  449. key.mostDetailMip = mostDetailMip;
  450. key.numMips = numMips == 0 ? (texProps.getNumMipmaps() + 1) : numMips;
  451. key.firstArraySlice = firstArraySlice;
  452. key.numArraySlices = numArraySlices == 0 ? texProps.getNumFaces() : numArraySlices;
  453. key.usage = usage;
  454. auto iterFind = mTextureViews.find(key);
  455. if (iterFind == mTextureViews.end())
  456. {
  457. mTextureViews[key] = createView(key);
  458. iterFind = mTextureViews.find(key);
  459. }
  460. return iterFind->second;
  461. }
  462. /************************************************************************/
  463. /* STATICS */
  464. /************************************************************************/
  465. SPtr<Texture> Texture::create(const TEXTURE_DESC& desc, GpuDeviceFlags deviceMask)
  466. {
  467. return TextureManager::instance().createTexture(desc, deviceMask);
  468. }
  469. SPtr<Texture> Texture::create(const SPtr<PixelData>& pixelData, int usage, bool hwGammaCorrection,
  470. GpuDeviceFlags deviceMask)
  471. {
  472. TEXTURE_DESC desc;
  473. desc.type = pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D;
  474. desc.width = pixelData->getWidth();
  475. desc.height = pixelData->getHeight();
  476. desc.depth = pixelData->getDepth();
  477. desc.format = pixelData->getFormat();
  478. desc.usage = usage;
  479. desc.hwGamma = hwGammaCorrection;
  480. SPtr<Texture> newTex = TextureManager::instance().createTextureInternal(desc, pixelData, deviceMask);
  481. newTex->initialize();
  482. return newTex;
  483. }
  484. }
  485. }