d3d11-stagesurf.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 (ConvertGSTextureFormat(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. }