BsTexture.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. #include "BsPixelBuffer.h"
  2. #include "BsTexture.h"
  3. #include "BsTextureRTTI.h"
  4. #include "BsDataStream.h"
  5. #include "BsException.h"
  6. #include "BsDebug.h"
  7. #include "BsCoreThread.h"
  8. #include "BsAsyncOp.h"
  9. #include "BsResources.h"
  10. #include "BsPixelUtil.h"
  11. namespace BansheeEngine
  12. {
  13. TextureProperties::TextureProperties()
  14. :mHeight(32), mWidth(32), mDepth(1), mNumMipmaps(0),
  15. mHwGamma(false), mMultisampleCount(0), mTextureType(TEX_TYPE_2D),
  16. mFormat(PF_UNKNOWN), mUsage(TU_DEFAULT)
  17. {
  18. mFormat = TextureManager::instance().getNativeFormat(mTextureType, mFormat, mUsage, mHwGamma);
  19. }
  20. TextureProperties::TextureProperties(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
  21. PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
  22. :mHeight(height), mWidth(width), mDepth(depth), mNumMipmaps(numMipmaps),
  23. mHwGamma(hwGamma), mMultisampleCount(multisampleCount), mTextureType(textureType),
  24. mFormat(format), mUsage(usage)
  25. {
  26. mFormat = TextureManager::instance().getNativeFormat(mTextureType, mFormat, mUsage, mHwGamma);
  27. }
  28. bool TextureProperties::hasAlpha() const
  29. {
  30. return PixelUtil::hasAlpha(mFormat);
  31. }
  32. UINT32 TextureProperties::getNumFaces() const
  33. {
  34. return getTextureType() == TEX_TYPE_CUBE_MAP ? 6 : 1;
  35. }
  36. void TextureProperties::mapFromSubresourceIdx(UINT32 subresourceIdx, UINT32& face, UINT32& mip) const
  37. {
  38. UINT32 numMipmaps = getNumMipmaps() + 1;
  39. face = Math::floorToInt((subresourceIdx) / (float)numMipmaps);
  40. mip = subresourceIdx % numMipmaps;
  41. }
  42. UINT32 TextureProperties::mapToSubresourceIdx(UINT32 face, UINT32 mip) const
  43. {
  44. return face * (getNumMipmaps() + 1) + mip;
  45. }
  46. PixelDataPtr TextureProperties::allocateSubresourceBuffer(UINT32 subresourceIdx) const
  47. {
  48. UINT32 face = 0;
  49. UINT32 mip = 0;
  50. mapFromSubresourceIdx(subresourceIdx, face, mip);
  51. UINT32 numMips = getNumMipmaps();
  52. UINT32 width = getWidth();
  53. UINT32 height = getHeight();
  54. UINT32 depth = getDepth();
  55. UINT32 totalSize = PixelUtil::getMemorySize(width, height, depth, getFormat());
  56. for (UINT32 j = 0; j < mip; j++)
  57. {
  58. totalSize = PixelUtil::getMemorySize(width, height, depth, getFormat());
  59. if (width != 1) width /= 2;
  60. if (height != 1) height /= 2;
  61. if (depth != 1) depth /= 2;
  62. }
  63. PixelDataPtr dst = bs_shared_ptr_new<PixelData>(width, height, depth, getFormat());
  64. dst->allocateInternalBuffer();
  65. return dst;
  66. }
  67. TextureCore::TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
  68. PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initData)
  69. :mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount),
  70. mInitData(initData)
  71. { }
  72. void TextureCore::initialize()
  73. {
  74. if (mInitData != nullptr)
  75. {
  76. writeSubresource(0, *mInitData, true);
  77. mInitData->_unlock();
  78. mInitData = nullptr;
  79. }
  80. }
  81. void TextureCore::writeSubresource(UINT32 subresourceIdx, const PixelData& pixelData, bool discardEntireBuffer)
  82. {
  83. THROW_IF_NOT_CORE_THREAD;
  84. if(discardEntireBuffer)
  85. {
  86. if(mProperties.getUsage() != TU_DYNAMIC)
  87. {
  88. // Buffer discard is enabled but buffer was not created as dynamic. Disabling discard.
  89. discardEntireBuffer = false;
  90. }
  91. }
  92. else
  93. {
  94. if (mProperties.getUsage() == TU_DYNAMIC)
  95. {
  96. LOGWRN("Buffer discard is not enabled but buffer was not created as dynamic. Enabling discard.");
  97. discardEntireBuffer = true;
  98. }
  99. }
  100. UINT32 face = 0;
  101. UINT32 mip = 0;
  102. mProperties.mapFromSubresourceIdx(subresourceIdx, face, mip);
  103. writeData(pixelData, mip, face, discardEntireBuffer);
  104. }
  105. void TextureCore::readSubresource(UINT32 subresourceIdx, PixelData& data)
  106. {
  107. THROW_IF_NOT_CORE_THREAD;
  108. UINT32 face = 0;
  109. UINT32 mip = 0;
  110. mProperties.mapFromSubresourceIdx(subresourceIdx, face, mip);
  111. PixelData& pixelData = static_cast<PixelData&>(data);
  112. UINT32 mipWidth, mipHeight, mipDepth;
  113. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  114. mip, mipWidth, mipHeight, mipDepth);
  115. if (pixelData.getWidth() != mipWidth || pixelData.getHeight() != mipHeight ||
  116. pixelData.getDepth() != mipDepth || pixelData.getFormat() != mProperties.getFormat())
  117. {
  118. BS_EXCEPT(RenderingAPIException, "Provided buffer is not of valid dimensions or format in order to read from this texture.");
  119. }
  120. readData(pixelData, mip, face);
  121. }
  122. PixelData TextureCore::lock(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
  123. {
  124. THROW_IF_NOT_CORE_THREAD;
  125. if (mipLevel < 0 || mipLevel > mProperties.getNumMipmaps())
  126. BS_EXCEPT(InvalidParametersException, "Invalid mip level: " + toString(mipLevel) + ". Min is 0, max is " + toString(mProperties.getNumMipmaps()));
  127. if (face < 0 || face >= mProperties.getNumFaces())
  128. BS_EXCEPT(InvalidParametersException, "Invalid face index: " + toString(face) + ". Min is 0, max is " + toString(mProperties.getNumFaces()));
  129. return lockImpl(options, mipLevel, face);
  130. }
  131. void TextureCore::unlock()
  132. {
  133. THROW_IF_NOT_CORE_THREAD;
  134. unlockImpl();
  135. }
  136. void TextureCore::copy(UINT32 srcSubresourceIdx, UINT32 destSubresourceIdx, const SPtr<TextureCore>& target)
  137. {
  138. THROW_IF_NOT_CORE_THREAD;
  139. if (target->mProperties.getTextureType() != mProperties.getTextureType())
  140. BS_EXCEPT(InvalidParametersException, "Source and destination textures must be of same type and must have the same usage and type.");
  141. if (mProperties.getFormat() != target->mProperties.getFormat()) // Note: It might be okay to use different formats of the same size
  142. BS_EXCEPT(InvalidParametersException, "Source and destination texture formats must match.");
  143. if (target->mProperties.getMultisampleCount() > 0 && mProperties.getMultisampleCount() != target->mProperties.getMultisampleCount())
  144. BS_EXCEPT(InvalidParametersException, "When copying to a multisampled texture, source texture must have the same number of samples.");
  145. UINT32 srcFace = 0;
  146. UINT32 srcMipLevel = 0;
  147. UINT32 destFace = 0;
  148. UINT32 destMipLevel = 0;
  149. mProperties.mapFromSubresourceIdx(srcSubresourceIdx, srcFace, srcMipLevel);
  150. target->mProperties.mapFromSubresourceIdx(destSubresourceIdx, destFace, destMipLevel);
  151. if (destFace >= mProperties.getNumFaces())
  152. BS_EXCEPT(InvalidParametersException, "Invalid destination face index");
  153. if (srcFace >= target->mProperties.getNumFaces())
  154. BS_EXCEPT(InvalidParametersException, "Invalid destination face index");
  155. if (srcMipLevel > mProperties.getNumMipmaps())
  156. BS_EXCEPT(InvalidParametersException, "Source mip level out of range. Valid range is [0, " + toString(mProperties.getNumMipmaps()) + "]");
  157. if (destMipLevel > target->mProperties.getNumMipmaps())
  158. BS_EXCEPT(InvalidParametersException, "Destination mip level out of range. Valid range is [0, " + toString(target->mProperties.getNumMipmaps()) + "]");
  159. UINT32 srcMipWidth = mProperties.getWidth() >> srcMipLevel;
  160. UINT32 srcMipHeight = mProperties.getHeight() >> srcMipLevel;
  161. UINT32 srcMipDepth = mProperties.getDepth() >> srcMipLevel;
  162. UINT32 dstMipWidth = target->mProperties.getWidth() >> destMipLevel;
  163. UINT32 dstMipHeight = target->mProperties.getHeight() >> destMipLevel;
  164. UINT32 dstMipDepth = target->mProperties.getDepth() >> destMipLevel;
  165. if (srcMipWidth != dstMipWidth || srcMipHeight != dstMipHeight || srcMipDepth != dstMipDepth)
  166. BS_EXCEPT(InvalidParametersException, "Source and destination sizes must match");
  167. copyImpl(srcFace, srcMipLevel, destFace, destMipLevel, target);
  168. }
  169. /************************************************************************/
  170. /* TEXTURE VIEW */
  171. /************************************************************************/
  172. TextureViewPtr TextureCore::createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
  173. {
  174. return bs_shared_ptr<TextureView>(new (bs_alloc<TextureView>()) TextureView(texture, desc));
  175. }
  176. void TextureCore::clearBufferViews()
  177. {
  178. mTextureViews.clear();
  179. }
  180. TextureViewPtr TextureCore::requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips, UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage)
  181. {
  182. THROW_IF_NOT_CORE_THREAD;
  183. assert(texture != nullptr);
  184. TEXTURE_VIEW_DESC key;
  185. key.mostDetailMip = mostDetailMip;
  186. key.numMips = numMips;
  187. key.firstArraySlice = firstArraySlice;
  188. key.numArraySlices = numArraySlices;
  189. key.usage = usage;
  190. auto iterFind = texture->mTextureViews.find(key);
  191. if (iterFind == texture->mTextureViews.end())
  192. {
  193. TextureViewPtr newView = texture->createView(texture, key);
  194. texture->mTextureViews[key] = new (bs_alloc<TextureViewReference>()) TextureViewReference(newView);
  195. iterFind = texture->mTextureViews.find(key);
  196. }
  197. iterFind->second->refCount++;
  198. return iterFind->second->view;
  199. }
  200. void TextureCore::releaseView(const TextureViewPtr& view)
  201. {
  202. THROW_IF_NOT_CORE_THREAD;
  203. assert(view != nullptr);
  204. SPtr<TextureCore> texture = view->getTexture();
  205. auto iterFind = texture->mTextureViews.find(view->getDesc());
  206. if (iterFind == texture->mTextureViews.end())
  207. {
  208. BS_EXCEPT(InternalErrorException, "Trying to release a texture view that doesn't exist!");
  209. }
  210. iterFind->second->refCount--;
  211. if (iterFind->second->refCount == 0)
  212. {
  213. TextureViewReference* toRemove = iterFind->second;
  214. texture->mTextureViews.erase(iterFind);
  215. bs_delete(toRemove);
  216. }
  217. }
  218. Texture::Texture()
  219. {
  220. }
  221. Texture::Texture(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
  222. PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
  223. :mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount)
  224. {
  225. }
  226. Texture::Texture(const PixelDataPtr& pixelData, int usage, bool hwGamma)
  227. : mProperties(pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D, pixelData->getWidth(), pixelData->getHeight(),
  228. pixelData->getDepth(), 0, pixelData->getFormat(), usage, hwGamma, 0), mInitData(pixelData)
  229. {
  230. if (mInitData != nullptr)
  231. mInitData->_lock();
  232. }
  233. void Texture::initialize()
  234. {
  235. mSize = calculateSize();
  236. // Allocate CPU buffers if needed
  237. if ((mProperties.getUsage() & TU_CPUCACHED) != 0)
  238. {
  239. createCPUBuffers();
  240. if (mInitData != nullptr)
  241. updateCPUBuffers(0, *mInitData);
  242. }
  243. Resource::initialize();
  244. }
  245. SPtr<CoreObjectCore> Texture::createCore() const
  246. {
  247. const TextureProperties& props = getProperties();
  248. SPtr<CoreObjectCore> coreObj = TextureCoreManager::instance().createTextureInternal(props.getTextureType(), props.getWidth(), props.getHeight(),
  249. props.getDepth(), props.getNumMipmaps(), props.getFormat(), props.getUsage(), props.isHardwareGammaEnabled(), props.getMultisampleCount(), mInitData);
  250. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  251. mInitData = nullptr;
  252. return coreObj;
  253. }
  254. AsyncOp Texture::writeSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const PixelDataPtr& data, bool discardEntireBuffer)
  255. {
  256. updateCPUBuffers(subresourceIdx, *data);
  257. data->_lock();
  258. std::function<void(const SPtr<TextureCore>&, UINT32, const PixelDataPtr&, bool, AsyncOp&)> func =
  259. [&](const SPtr<TextureCore>& texture, UINT32 _subresourceIdx, const PixelDataPtr& _pixData, bool _discardEntireBuffer, AsyncOp& asyncOp)
  260. {
  261. texture->writeSubresource(_subresourceIdx, *_pixData, _discardEntireBuffer);
  262. _pixData->_unlock();
  263. asyncOp._completeOperation();
  264. };
  265. return accessor.queueReturnCommand(std::bind(func, getCore(), subresourceIdx,
  266. data, discardEntireBuffer, std::placeholders::_1));
  267. }
  268. AsyncOp Texture::readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const PixelDataPtr& data)
  269. {
  270. data->_lock();
  271. std::function<void(const SPtr<TextureCore>&, UINT32, const PixelDataPtr&, AsyncOp&)> func =
  272. [&](const SPtr<TextureCore>& texture, UINT32 _subresourceIdx, const PixelDataPtr& _pixData, AsyncOp& asyncOp)
  273. {
  274. texture->readSubresource(_subresourceIdx, *_pixData);
  275. _pixData->_unlock();
  276. asyncOp._completeOperation();
  277. };
  278. return accessor.queueReturnCommand(std::bind(func, getCore(), subresourceIdx,
  279. data, std::placeholders::_1));
  280. }
  281. UINT32 Texture::calculateSize() const
  282. {
  283. return mProperties.getNumFaces() * PixelUtil::getMemorySize(mProperties.getWidth(),
  284. mProperties.getHeight(), mProperties.getDepth(), mProperties.getFormat());
  285. }
  286. void Texture::updateCPUBuffers(UINT32 subresourceIdx, const PixelData& pixelData)
  287. {
  288. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  289. return;
  290. if (subresourceIdx >= (UINT32)mCPUSubresourceData.size())
  291. {
  292. LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. " + toString(mCPUSubresourceData.size()));
  293. return;
  294. }
  295. UINT32 mipLevel;
  296. UINT32 face;
  297. mProperties.mapFromSubresourceIdx(subresourceIdx, face, mipLevel);
  298. UINT32 mipWidth, mipHeight, mipDepth;
  299. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  300. mipLevel, mipWidth, mipHeight, mipDepth);
  301. if (pixelData.getWidth() != mipWidth || pixelData.getHeight() != mipHeight ||
  302. pixelData.getDepth() != mipDepth || pixelData.getFormat() != mProperties.getFormat())
  303. {
  304. LOGERR("Provided buffer is not of valid dimensions or format in order to update this texture.");
  305. return;
  306. }
  307. if (mCPUSubresourceData[subresourceIdx]->getSize() != pixelData.getSize())
  308. BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
  309. UINT8* dest = mCPUSubresourceData[subresourceIdx]->getData();
  310. UINT8* src = pixelData.getData();
  311. memcpy(dest, src, pixelData.getSize());
  312. }
  313. void Texture::readData(PixelData& dest, UINT32 mipLevel, UINT32 face)
  314. {
  315. if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
  316. {
  317. LOGERR("Attempting to read CPU data from a texture that is created without CPU caching.");
  318. return;
  319. }
  320. UINT32 mipWidth, mipHeight, mipDepth;
  321. PixelUtil::getSizeForMipLevel(mProperties.getWidth(), mProperties.getHeight(), mProperties.getDepth(),
  322. mipLevel, mipWidth, mipHeight, mipDepth);
  323. if (dest.getWidth() != mipWidth || dest.getHeight() != mipHeight ||
  324. dest.getDepth() != mipDepth || dest.getFormat() != mProperties.getFormat())
  325. {
  326. LOGERR("Provided buffer is not of valid dimensions or format in order to read from this texture.");
  327. return;
  328. }
  329. UINT32 subresourceIdx = mProperties.mapToSubresourceIdx(face, mipLevel);
  330. if (subresourceIdx >= (UINT32)mCPUSubresourceData.size())
  331. {
  332. LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. " + toString(mCPUSubresourceData.size()));
  333. return;
  334. }
  335. if (mCPUSubresourceData[subresourceIdx]->getSize() != dest.getSize())
  336. BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
  337. UINT8* srcPtr = mCPUSubresourceData[subresourceIdx]->getData();
  338. UINT8* destPtr = dest.getData();
  339. memcpy(destPtr, srcPtr, dest.getSize());
  340. }
  341. void Texture::createCPUBuffers()
  342. {
  343. UINT32 numFaces = mProperties.getNumFaces();
  344. UINT32 numMips = mProperties.getNumMipmaps() + 1;
  345. UINT32 numSubresources = numFaces * numMips;
  346. mCPUSubresourceData.resize(numSubresources);
  347. for (UINT32 i = 0; i < numFaces; i++)
  348. {
  349. UINT32 curWidth = mProperties.getWidth();
  350. UINT32 curHeight = mProperties.getHeight();
  351. UINT32 curDepth = mProperties.getDepth();
  352. for (UINT32 j = 0; j < numMips; j++)
  353. {
  354. UINT32 subresourceIdx = mProperties.mapToSubresourceIdx(i, j);
  355. mCPUSubresourceData[subresourceIdx] = bs_shared_ptr_new<PixelData>(curWidth, curHeight, curDepth, mProperties.getFormat());
  356. mCPUSubresourceData[subresourceIdx]->allocateInternalBuffer();
  357. if (curWidth > 1)
  358. curWidth = curWidth / 2;
  359. if (curHeight > 1)
  360. curHeight = curHeight / 2;
  361. if (curDepth > 1)
  362. curDepth = curDepth / 2;
  363. }
  364. }
  365. }
  366. SPtr<TextureCore> Texture::getCore() const
  367. {
  368. return std::static_pointer_cast<TextureCore>(mCoreSpecific);
  369. }
  370. /************************************************************************/
  371. /* SERIALIZATION */
  372. /************************************************************************/
  373. RTTITypeBase* Texture::getRTTIStatic()
  374. {
  375. return TextureRTTI::instance();
  376. }
  377. RTTITypeBase* Texture::getRTTI() const
  378. {
  379. return Texture::getRTTIStatic();
  380. }
  381. /************************************************************************/
  382. /* STATICS */
  383. /************************************************************************/
  384. HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
  385. int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
  386. {
  387. TexturePtr texturePtr = _createPtr(texType,
  388. width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount);
  389. return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
  390. }
  391. HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height,
  392. int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
  393. {
  394. TexturePtr texturePtr = _createPtr(texType,
  395. width, height, numMips, format, usage, hwGammaCorrection, multisampleCount);
  396. return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
  397. }
  398. HTexture Texture::create(const PixelDataPtr& pixelData, int usage, bool hwGammaCorrection)
  399. {
  400. TexturePtr texturePtr = TextureManager::instance().createTexture(pixelData, usage, hwGammaCorrection);
  401. return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
  402. }
  403. TexturePtr Texture::_createPtr(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
  404. int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
  405. {
  406. return TextureManager::instance().createTexture(texType,
  407. width, height, depth, num_mips, format, usage, hwGammaCorrection, multisampleCount);
  408. }
  409. TexturePtr Texture::_createPtr(TextureType texType, UINT32 width, UINT32 height,
  410. int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
  411. {
  412. return TextureManager::instance().createTexture(texType,
  413. width, height, num_mips, format, usage, hwGammaCorrection, multisampleCount);
  414. }
  415. const HTexture& Texture::dummy()
  416. {
  417. static HTexture dummyTexture;
  418. if (!dummyTexture)
  419. {
  420. PixelDataPtr pixelData = PixelData::create(2, 2, 1, PF_R8G8B8A8);
  421. pixelData->setColorAt(Color::Red, 0, 0);
  422. pixelData->setColorAt(Color::Red, 0, 1);
  423. pixelData->setColorAt(Color::Red, 1, 0);
  424. pixelData->setColorAt(Color::Red, 1, 1);
  425. dummyTexture = create(pixelData);
  426. }
  427. return dummyTexture;
  428. }
  429. }