BsD3D11RenderTexture.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. D3D11RenderTexture::D3D11RenderTexture(const RENDER_TEXTURE_DESC& desc)
  8. :RenderTexture(desc), mProperties(desc, false)
  9. {
  10. }
  11. namespace ct
  12. {
  13. D3D11RenderTexture::D3D11RenderTexture(const RENDER_TEXTURE_DESC& desc, UINT32 deviceIdx)
  14. :RenderTexture(desc, deviceIdx), mProperties(desc, false)
  15. {
  16. assert(deviceIdx == 0 && "Multiple GPUs not supported natively on DirectX 11.");
  17. }
  18. void D3D11RenderTexture::getCustomAttribute(const String& name, void* data) const
  19. {
  20. if(name == "RTV")
  21. {
  22. ID3D11RenderTargetView** rtvs = (ID3D11RenderTargetView**)data;
  23. for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; ++i)
  24. {
  25. if (mColorSurfaces[i] == nullptr)
  26. continue;
  27. D3D11TextureView* textureView = static_cast<D3D11TextureView*>(mColorSurfaces[i].get());
  28. rtvs[i] = textureView->getRTV();
  29. }
  30. }
  31. else if(name == "DSV")
  32. {
  33. if (mDepthStencilSurface == nullptr)
  34. return;
  35. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  36. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  37. *dsv = depthStencilView->getDSV(false, false);
  38. }
  39. else if (name == "RODSV")
  40. {
  41. if (mDepthStencilSurface == nullptr)
  42. return;
  43. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  44. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  45. *dsv = depthStencilView->getDSV(true, true);
  46. }
  47. else if (name == "RODWSV")
  48. {
  49. if (mDepthStencilSurface == nullptr)
  50. return;
  51. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  52. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  53. *dsv = depthStencilView->getDSV(true, false);
  54. }
  55. else if (name == "WDROSV")
  56. {
  57. if (mDepthStencilSurface == nullptr)
  58. return;
  59. ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
  60. D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
  61. *dsv = depthStencilView->getDSV(false, true);
  62. }
  63. }
  64. }}