CmD3D11Texture.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. #include "CmD3D11Texture.h"
  2. #include "CmD3D11Mappings.h"
  3. #include "CmD3D11Device.h"
  4. #include "CmD3D11RenderSystem.h"
  5. #include "CmException.h"
  6. #include "CmAsyncOp.h"
  7. #if CM_DEBUG_MODE
  8. #define THROW_IF_NOT_RENDER_THREAD throwIfNotRenderThread();
  9. #else
  10. #define THROW_IF_NOT_RENDER_THREAD
  11. #endif
  12. namespace CamelotEngine
  13. {
  14. D3D11Texture::D3D11Texture()
  15. : m1DTex(nullptr)
  16. , m2DTex(nullptr)
  17. , m3DTex(nullptr)
  18. , mTex(nullptr)
  19. , mShaderResourceView(nullptr)
  20. , mStagingBuffer(nullptr)
  21. , mLockedSubresourceIdx(-1)
  22. , mLockedForReading(false)
  23. , mStaticBuffer(nullptr)
  24. {
  25. }
  26. D3D11Texture::~D3D11Texture()
  27. {
  28. THROW_IF_NOT_RENDER_THREAD;
  29. freeInternalResources();
  30. }
  31. void D3D11Texture::copyImpl(TexturePtr& target)
  32. {
  33. D3D11Texture* other = static_cast<D3D11Texture*>(target.get());
  34. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  35. device.getImmediateContext()->CopyResource(other->getDX11Resource(), mTex);
  36. if (device.hasError())
  37. {
  38. String errorDescription = device.getErrorDescription();
  39. CM_EXCEPT(RenderingAPIException, "D3D11 device cannot copy resource\nError Description:" + errorDescription);
  40. }
  41. }
  42. PixelData D3D11Texture::lockImpl(LockOptions options, UINT32 mipLevel, UINT32 face)
  43. {
  44. UINT32 mipWidth = mipLevel >> mWidth;
  45. UINT32 mipHeight = mipLevel >> mHeight;
  46. UINT32 mipDepth = mipLevel >> mDepth;
  47. PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
  48. D3D11_MAP flags = D3D11Mappings::_getLockOptions(options);
  49. switch(options)
  50. {
  51. case HBL_WRITE_ONLY_NO_OVERWRITE:
  52. flags = D3D11_MAP_WRITE_NO_OVERWRITE;
  53. break;
  54. case HBL_READ_WRITE:
  55. flags = D3D11_MAP_READ_WRITE;
  56. break;
  57. case HBL_WRITE_ONLY_DISCARD:
  58. flags = D3D11_MAP_WRITE_DISCARD;
  59. break;
  60. case HBL_READ_ONLY:
  61. flags = D3D11_MAP_READ;
  62. break;
  63. case HBL_WRITE_ONLY:
  64. flags = D3D11_MAP_WRITE;
  65. break;
  66. default:
  67. break;
  68. };
  69. if(flags == D3D11_MAP_READ || flags == D3D11_MAP_READ_WRITE)
  70. {
  71. lockedArea.data = _mapstagingbuffer(flags, face, mipLevel);
  72. mLockedForReading = true;
  73. }
  74. else
  75. {
  76. if(mUsage == TU_DYNAMIC)
  77. lockedArea.data = _map(mTex, flags, face, mipLevel);
  78. else
  79. lockedArea.data = _mapstaticbuffer(lockedArea, mipLevel, face);
  80. mLockedForReading = false;
  81. }
  82. return lockedArea;
  83. }
  84. void D3D11Texture::unlockImpl()
  85. {
  86. if(mLockedForReading)
  87. _unmapstagingbuffer();
  88. else
  89. {
  90. if(mUsage == TU_DYNAMIC)
  91. _unmap(mTex);
  92. else
  93. _unmapstaticbuffer();
  94. }
  95. }
  96. void D3D11Texture::initialize_internal()
  97. {
  98. THROW_IF_NOT_RENDER_THREAD
  99. createInternalResources();
  100. Resource::initialize_internal();
  101. }
  102. void D3D11Texture::createInternalResourcesImpl()
  103. {
  104. // load based on tex.type
  105. switch (getTextureType())
  106. {
  107. case TEX_TYPE_1D:
  108. _create1DTex();
  109. break;
  110. case TEX_TYPE_2D:
  111. case TEX_TYPE_CUBE_MAP:
  112. _create2DTex();
  113. break;
  114. case TEX_TYPE_3D:
  115. _create3DTex();
  116. break;
  117. default:
  118. freeInternalResources();
  119. CM_EXCEPT(RenderingAPIException, "Unknown texture type");
  120. }
  121. }
  122. void D3D11Texture::freeInternalResourcesImpl()
  123. {
  124. SAFE_RELEASE(mTex);
  125. SAFE_RELEASE(mShaderResourceView);
  126. SAFE_RELEASE(m1DTex);
  127. SAFE_RELEASE(m2DTex);
  128. SAFE_RELEASE(m3DTex);
  129. SAFE_RELEASE(mStagingBuffer);
  130. }
  131. void D3D11Texture::_create1DTex()
  132. {
  133. // We must have those defined here
  134. assert(mWidth > 0);
  135. // Determine which D3D11 pixel format we'll use
  136. HRESULT hr;
  137. DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat));
  138. D3D11_TEXTURE1D_DESC desc;
  139. desc.Width = static_cast<UINT32>(mWidth);
  140. desc.ArraySize = 1;
  141. desc.Format = d3dPF;
  142. desc.MiscFlags = 0;
  143. if((mUsage & TU_RENDERTARGET) != 0)
  144. {
  145. desc.Usage = D3D11_USAGE_DEFAULT;
  146. desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
  147. desc.CPUAccessFlags = (mUsage & TU_RENDERTARGET) != 0 ? 0 : D3D11Mappings::_getAccessFlags(mUsage);
  148. desc.MipLevels = 1;
  149. }
  150. else
  151. {
  152. desc.Usage = D3D11Mappings::_getUsage(mUsage);
  153. desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  154. desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
  155. // Determine total number of mipmaps including main one (d3d11 convention)
  156. UINT32 numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > mWidth) ? 0 : mNumMipmaps + 1;
  157. desc.MipLevels = numMips;
  158. }
  159. // Create the texture
  160. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  161. hr = device.getD3D11Device()->CreateTexture1D(&desc, nullptr, &m1DTex);
  162. // Check result and except if failed
  163. if (FAILED(hr) || device.hasError())
  164. {
  165. freeInternalResources();
  166. String errorDescription = device.getErrorDescription();
  167. CM_EXCEPT(RenderingAPIException, "Error creating texture\nError Description:" + errorDescription);
  168. }
  169. hr = m1DTex->QueryInterface(__uuidof(ID3D11Resource), (void **)mTex);
  170. if(FAILED(hr) || device.hasError())
  171. {
  172. freeInternalResources();
  173. String errorDescription = device.getErrorDescription();
  174. CM_EXCEPT(RenderingAPIException, "Can't get base texture\nError Description:" + errorDescription);
  175. }
  176. m1DTex->GetDesc(&desc);
  177. mNumMipmaps = desc.MipLevels - 1;
  178. // Create texture view
  179. ZeroMemory(&mSRVDesc, sizeof(mSRVDesc));
  180. mSRVDesc.Format = desc.Format;
  181. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
  182. mSRVDesc.Texture1D.MipLevels = desc.MipLevels;
  183. hr = device.getD3D11Device()->CreateShaderResourceView(m1DTex, &mSRVDesc, &mShaderResourceView);
  184. if (FAILED(hr) || device.hasError())
  185. {
  186. String errorDescription = device.getErrorDescription();
  187. CM_EXCEPT(RenderingAPIException, "D3D11 device can't create shader resource view.\nError Description:" + errorDescription);
  188. }
  189. }
  190. void D3D11Texture::_create2DTex()
  191. {
  192. // We must have those defined here
  193. assert(mWidth > 0 || mHeight > 0);
  194. // Determine which D3D11 pixel format we'll use
  195. HRESULT hr;
  196. DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat));
  197. D3D11_TEXTURE2D_DESC desc;
  198. desc.Width = static_cast<UINT32>(mWidth);
  199. desc.Height = static_cast<UINT32>(mHeight);
  200. desc.ArraySize = 1;
  201. desc.Format = d3dPF;
  202. desc.MiscFlags = 0;
  203. if((mUsage & TU_RENDERTARGET) != 0)
  204. {
  205. desc.Usage = D3D11_USAGE_DEFAULT;
  206. desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
  207. desc.CPUAccessFlags = (mUsage & TU_RENDERTARGET) != 0 ? 0 : D3D11Mappings::_getAccessFlags(mUsage);
  208. desc.MipLevels = 1;
  209. DXGI_SAMPLE_DESC sampleDesc;
  210. D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
  211. rs->determineFSAASettings(mFSAA, mFSAAHint, d3dPF, &sampleDesc);
  212. desc.SampleDesc = sampleDesc;
  213. if(getTextureType() == TEX_TYPE_CUBE_MAP)
  214. {
  215. CM_EXCEPT(NotImplementedException, "Cube map not yet supported as a render target."); // TODO: Will be once I add proper texture array support
  216. }
  217. }
  218. else
  219. {
  220. desc.Usage = D3D11Mappings::_getUsage(mUsage);
  221. desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  222. desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
  223. // Determine total number of mipmaps including main one (d3d11 convention)
  224. UINT32 numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > mWidth) ? 0 : mNumMipmaps + 1;
  225. desc.MipLevels = numMips;
  226. DXGI_SAMPLE_DESC sampleDesc;
  227. sampleDesc.Count = 1;
  228. sampleDesc.Quality = 0;
  229. desc.SampleDesc = sampleDesc;
  230. }
  231. if (getTextureType() == TEX_TYPE_CUBE_MAP)
  232. {
  233. desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
  234. desc.ArraySize = 6;
  235. }
  236. // Create the texture
  237. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  238. hr = device.getD3D11Device()->CreateTexture2D(&desc, nullptr, &m2DTex);
  239. // Check result and except if failed
  240. if (FAILED(hr) || device.hasError())
  241. {
  242. freeInternalResources();
  243. String errorDescription = device.getErrorDescription();
  244. CM_EXCEPT(RenderingAPIException, "Error creating texture\nError Description:" + errorDescription);
  245. }
  246. hr = m2DTex->QueryInterface(__uuidof(ID3D11Resource), (void **)mTex);
  247. if(FAILED(hr) || device.hasError())
  248. {
  249. freeInternalResources();
  250. String errorDescription = device.getErrorDescription();
  251. CM_EXCEPT(RenderingAPIException, "Can't get base texture\nError Description:" + errorDescription);
  252. }
  253. m2DTex->GetDesc(&desc);
  254. mNumMipmaps = desc.MipLevels - 1;
  255. // Create shader texture view
  256. ZeroMemory(&mSRVDesc, sizeof(mSRVDesc));
  257. mSRVDesc.Format = desc.Format;
  258. if((mUsage & TU_RENDERTARGET) != 0)
  259. {
  260. if(mFSAA > 0)
  261. {
  262. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
  263. mSRVDesc.Texture2D.MostDetailedMip = 0;
  264. mSRVDesc.Texture2D.MipLevels = desc.MipLevels;
  265. }
  266. else
  267. {
  268. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
  269. mSRVDesc.Texture2D.MostDetailedMip = 0;
  270. mSRVDesc.Texture2D.MipLevels = desc.MipLevels;
  271. }
  272. }
  273. else
  274. {
  275. switch(getTextureType())
  276. {
  277. case TEX_TYPE_CUBE_MAP:
  278. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
  279. mSRVDesc.TextureCube.MipLevels = desc.MipLevels;
  280. mSRVDesc.TextureCube.MostDetailedMip = 0;
  281. break;
  282. case TEX_TYPE_2D:
  283. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
  284. mSRVDesc.Texture2D.MostDetailedMip = 0;
  285. mSRVDesc.Texture2D.MipLevels = desc.MipLevels;
  286. break;
  287. }
  288. }
  289. hr = device.getD3D11Device()->CreateShaderResourceView(m2DTex, &mSRVDesc, &mShaderResourceView);
  290. if (FAILED(hr) || device.hasError())
  291. {
  292. String errorDescription = device.getErrorDescription();
  293. CM_EXCEPT(RenderingAPIException, "D3D11 device can't create shader resource view.\nError Description:" + errorDescription);
  294. }
  295. }
  296. void D3D11Texture::_create3DTex()
  297. {
  298. // We must have those defined here
  299. assert(mWidth > 0 && mHeight > 0 && mDepth > 0);
  300. // Determine which D3D11 pixel format we'll use
  301. HRESULT hr;
  302. DXGI_FORMAT d3dPF = D3D11Mappings::_getPF(D3D11Mappings::_getClosestSupportedPF(mFormat));
  303. D3D11_TEXTURE3D_DESC desc;
  304. desc.Width = static_cast<UINT32>(mWidth);
  305. desc.Height = static_cast<UINT32>(mHeight);
  306. desc.Depth = static_cast<UINT32>(mDepth);
  307. desc.Format = d3dPF;
  308. desc.MiscFlags = 0;
  309. if((mUsage & TU_RENDERTARGET) != 0)
  310. {
  311. desc.Usage = D3D11_USAGE_DEFAULT;
  312. desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
  313. desc.CPUAccessFlags = (mUsage & TU_RENDERTARGET) != 0 ? 0 : D3D11Mappings::_getAccessFlags(mUsage);
  314. desc.MipLevels = 1;
  315. }
  316. else
  317. {
  318. desc.Usage = D3D11Mappings::_getUsage(mUsage);
  319. desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  320. desc.CPUAccessFlags = D3D11Mappings::_getAccessFlags(mUsage);
  321. // Determine total number of mipmaps including main one (d3d11 convention)
  322. UINT numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > std::max(std::max(mWidth, mHeight), mDepth)) ? 0 : mNumMipmaps + 1;
  323. desc.MipLevels = numMips;
  324. }
  325. // Create the texture
  326. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  327. hr = device.getD3D11Device()->CreateTexture3D(&desc, nullptr, &m3DTex);
  328. // Check result and except if failed
  329. if (FAILED(hr) || device.hasError())
  330. {
  331. freeInternalResources();
  332. String errorDescription = device.getErrorDescription();
  333. CM_EXCEPT(RenderingAPIException, "Error creating texture\nError Description:" + errorDescription);
  334. }
  335. hr = m3DTex->QueryInterface(__uuidof(ID3D11Resource), (void **)mTex);
  336. if(FAILED(hr) || device.hasError())
  337. {
  338. freeInternalResources();
  339. String errorDescription = device.getErrorDescription();
  340. CM_EXCEPT(RenderingAPIException, "Can't get base texture\nError Description:" + errorDescription);
  341. }
  342. // Create texture view
  343. m3DTex->GetDesc(&desc);
  344. mNumMipmaps = desc.MipLevels - 1;
  345. ZeroMemory(&mSRVDesc, sizeof(mSRVDesc));
  346. mSRVDesc.Format = desc.Format;
  347. mSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
  348. mSRVDesc.Texture3D.MostDetailedMip = 0;
  349. mSRVDesc.Texture3D.MipLevels = desc.MipLevels;
  350. hr = device.getD3D11Device()->CreateShaderResourceView(m2DTex, &mSRVDesc, &mShaderResourceView);
  351. if (FAILED(hr) || device.hasError())
  352. {
  353. String errorDescription = device.getErrorDescription();
  354. CM_EXCEPT(RenderingAPIException, "D3D11 device can't create shader resource view.\nError Description:" + errorDescription);
  355. }
  356. }
  357. void* D3D11Texture::_map(ID3D11Resource* res, D3D11_MAP flags, UINT32 mipLevel, UINT32 face)
  358. {
  359. D3D11_MAPPED_SUBRESOURCE pMappedResource;
  360. pMappedResource.pData = nullptr;
  361. mipLevel = Math::Clamp(mipLevel, (UINT32)mipLevel, getNumMipmaps());
  362. face = Math::Clamp(face, (UINT32)0, mDepth - 1);
  363. if(getTextureType() == TEX_TYPE_3D)
  364. face = 0;
  365. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  366. mLockedSubresourceIdx = D3D11CalcSubresource(mipLevel, face, getNumMipmaps()+1);
  367. device.getImmediateContext()->Map(res, mLockedSubresourceIdx, flags, 0, &pMappedResource);
  368. if (device.hasError())
  369. {
  370. String errorDescription = device.getErrorDescription();
  371. CM_EXCEPT(RenderingAPIException, "D3D11 device cannot map texture\nError Description:" + errorDescription);
  372. }
  373. return pMappedResource.pData;
  374. }
  375. void D3D11Texture::_unmap(ID3D11Resource* res)
  376. {
  377. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  378. device.getImmediateContext()->Unmap(res, mLockedSubresourceIdx);
  379. if (device.hasError())
  380. {
  381. String errorDescription = device.getErrorDescription();
  382. CM_EXCEPT(RenderingAPIException, "D3D11 device unmap resource\nError Description:" + errorDescription);
  383. }
  384. }
  385. void* D3D11Texture::_mapstagingbuffer(D3D11_MAP flags, UINT32 mipLevel, UINT32 face)
  386. {
  387. if(!mStagingBuffer)
  388. _createStagingBuffer();
  389. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  390. device.getImmediateContext()->CopyResource(mStagingBuffer, mTex);
  391. return _map(mStagingBuffer, flags, face, mipLevel);
  392. }
  393. void D3D11Texture::_unmapstagingbuffer()
  394. {
  395. _unmap(mStagingBuffer);
  396. }
  397. void* D3D11Texture::_mapstaticbuffer(PixelData lock, UINT32 mipLevel, UINT32 face)
  398. {
  399. UINT32 sizeOfImage = lock.getConsecutiveSize();
  400. mLockedSubresourceIdx = D3D11CalcSubresource(mipLevel, face, getNumMipmaps()+1);
  401. UINT8* bufferData = new UINT8[sizeOfImage];
  402. mStaticBuffer = new PixelData(lock.getWidth(), lock.getHeight(), lock.getDepth(), lock.getFormat(), bufferData, true);
  403. return bufferData;
  404. }
  405. void D3D11Texture::_unmapstaticbuffer()
  406. {
  407. UINT32 rowWidth = D3D11Mappings::_getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth());
  408. UINT32 sliceWidth = D3D11Mappings::_getSizeInBytes(mStaticBuffer->getFormat(), mStaticBuffer->getWidth(), mStaticBuffer->getHeight());
  409. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  410. device.getImmediateContext()->UpdateSubresource(mTex, mLockedSubresourceIdx, nullptr, mStaticBuffer->data, rowWidth, sliceWidth);
  411. if (device.hasError())
  412. {
  413. String errorDescription = device.getErrorDescription();
  414. CM_EXCEPT(RenderingAPIException, "D3D11 device cannot map texture\nError Description:" + errorDescription);
  415. }
  416. SAFE_DELETE(mStaticBuffer);
  417. }
  418. void D3D11Texture::_createStagingBuffer()
  419. {
  420. D3D11Device& device = D3D11RenderSystem::getPrimaryDevice();
  421. switch (getTextureType())
  422. {
  423. case TEX_TYPE_1D:
  424. {
  425. D3D11_TEXTURE1D_DESC desc;
  426. m1DTex->GetDesc(&desc);
  427. desc.BindFlags = 0;
  428. desc.MiscFlags = 0;
  429. desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
  430. desc.Usage = D3D11_USAGE_STAGING;
  431. device.getD3D11Device()->CreateTexture1D(&desc, NULL, (ID3D11Texture1D**)(&mStagingBuffer));
  432. }
  433. break;
  434. case TEX_TYPE_2D:
  435. case TEX_TYPE_CUBE_MAP:
  436. case TEX_TYPE_2D_ARRAY:
  437. {
  438. D3D11_TEXTURE2D_DESC desc;
  439. m2DTex->GetDesc(&desc);
  440. desc.BindFlags = 0;
  441. desc.MiscFlags = 0;
  442. desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
  443. desc.Usage = D3D11_USAGE_STAGING;
  444. device.getD3D11Device()->CreateTexture2D(&desc, NULL, (ID3D11Texture2D**)(&mStagingBuffer));
  445. }
  446. break;
  447. case TEX_TYPE_3D:
  448. {
  449. D3D11_TEXTURE3D_DESC desc;
  450. m3DTex->GetDesc(&desc);
  451. desc.BindFlags = 0;
  452. desc.MiscFlags = 0;
  453. desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
  454. desc.Usage = D3D11_USAGE_STAGING;
  455. device.getD3D11Device()->CreateTexture3D(&desc, NULL, (ID3D11Texture3D**)(&mStagingBuffer));
  456. }
  457. break;
  458. }
  459. }
  460. }
  461. #undef THROW_IF_NOT_RENDER_THREAD