BsD3D11RenderTexture.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsD3D11RenderTexture.h"
  4. #include "BsD3D11TextureView.h"
  5. namespace bs
  6. {
  7. D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
  8. :RenderTextureCore(desc, deviceIdx), mProperties(desc, false)
  9. {
  10. assert(deviceIdx == 0 && "Multiple GPUs not supported natively on DirectX 11.");
  11. }
  12. void D3D11RenderTextureCore::getCustomAttribute(const String& name, void* data) const
  13. {
  14. if(name == "RTV")
  15. {
  16. ID3D11RenderTargetView** rtvs = (ID3D11RenderTargetView**)data;
  17. for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; ++i)
  18. {
  19. if (mColorSurfaces[i] == nullptr)
  20. continue;
  21. D3D11TextureView* textureView = static_cast<D3D11TextureView*>(mColorSurfaces[i].get());
  22. rtvs[i] = textureView->getRTV();
  23. }
  24. }
  25. else if(name == "DSV")
  26. {
  27. if (mDepthStencilSurface == nullptr)
  28. return;
  29. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  30. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  31. *dsv = depthStencilView->getDSV(false);
  32. }
  33. else if (name == "RODSV")
  34. {
  35. if (mDepthStencilSurface == nullptr)
  36. return;
  37. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  38. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  39. *dsv = depthStencilView->getDSV(true);
  40. }
  41. }
  42. D3D11RenderTexture::D3D11RenderTexture(const RENDER_TEXTURE_DESC& desc)
  43. :RenderTexture(desc), mProperties(desc, false)
  44. {
  45. }
  46. }