d3d11-stagesurf.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "d3d11-subsystem.hpp"
  15. gs_stage_surface::gs_stage_surface(gs_device_t *device, uint32_t width,
  16. uint32_t height, gs_color_format colorFormat)
  17. : gs_obj(device, gs_type::gs_stage_surface),
  18. width(width),
  19. height(height),
  20. format(colorFormat),
  21. dxgiFormat(ConvertGSTextureFormatView(colorFormat))
  22. {
  23. HRESULT hr;
  24. memset(&td, 0, sizeof(td));
  25. td.Width = width;
  26. td.Height = height;
  27. td.MipLevels = 1;
  28. td.ArraySize = 1;
  29. td.Format = dxgiFormat;
  30. td.SampleDesc.Count = 1;
  31. td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
  32. td.Usage = D3D11_USAGE_STAGING;
  33. hr = device->device->CreateTexture2D(&td, NULL, texture.Assign());
  34. if (FAILED(hr))
  35. throw HRError("Failed to create staging surface", hr);
  36. }
  37. gs_stage_surface::gs_stage_surface(gs_device_t *device, uint32_t width,
  38. uint32_t height, bool p010)
  39. : gs_obj(device, gs_type::gs_stage_surface),
  40. width(width),
  41. height(height),
  42. format(GS_UNKNOWN),
  43. dxgiFormat(p010 ? DXGI_FORMAT_P010 : DXGI_FORMAT_NV12)
  44. {
  45. HRESULT hr;
  46. memset(&td, 0, sizeof(td));
  47. td.Width = width;
  48. td.Height = height;
  49. td.MipLevels = 1;
  50. td.ArraySize = 1;
  51. td.Format = dxgiFormat;
  52. td.SampleDesc.Count = 1;
  53. td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
  54. td.Usage = D3D11_USAGE_STAGING;
  55. hr = device->device->CreateTexture2D(&td, NULL, texture.Assign());
  56. if (FAILED(hr))
  57. throw HRError("Failed to create staging surface", hr);
  58. }