GS_D3D11StageSurf.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 3 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 "GS_D3D11SubSystem.hpp"
  15. gs_stage_surface::gs_stage_surface(device_t device, uint32_t width,
  16. uint32_t height, gs_color_format colorFormat)
  17. : device (device),
  18. width (width),
  19. height (height),
  20. format (colorFormat),
  21. dxgiFormat (ConvertGSTextureFormat(colorFormat))
  22. {
  23. D3D11_TEXTURE2D_DESC td;
  24. HRESULT hr;
  25. memset(&td, 0, sizeof(td));
  26. td.Width = width;
  27. td.Height = height;
  28. td.MipLevels = 1;
  29. td.ArraySize = 1;
  30. td.Format = dxgiFormat;
  31. td.SampleDesc.Count = 1;
  32. td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
  33. td.Usage = D3D11_USAGE_STAGING;
  34. hr = device->device->CreateTexture2D(&td, NULL, texture.Assign());
  35. if (FAILED(hr))
  36. throw HRError("Failed to create 2D texture", hr);
  37. }