AppRenderer.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // The MIT License(MIT)
  2. //
  3. // Copyright(c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. // this software and associated documentation files(the "Software"), to deal in
  7. // the Software without restriction, including without limitation the rights to
  8. // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of
  9. // the Software, and to permit persons to whom the Software is furnished to do so,
  10. // subject to the following conditions :
  11. //
  12. // The above copyright notice and this permission notice shall be included in all
  13. // copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
  18. // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #pragma once
  22. #include <iostream>
  23. #include <sstream>
  24. #include <iomanip>
  25. #include <d3d11.h>
  26. #include <wrl.h>
  27. #include "DeviceResources.h"
  28. #include "NVScaler.h"
  29. #include "NVSharpen.h"
  30. #include "UIRenderer.h"
  31. #include "BilinearUpscale.h"
  32. #include "Image.h"
  33. using namespace Microsoft::WRL;
  34. class AppRenderer
  35. {
  36. public:
  37. AppRenderer(DeviceResources& deviceResources, UIData& ui, const std::vector<std::string>& shaderPaths);
  38. bool update();
  39. void render();
  40. uint32_t width() { return m_outputWidth; }
  41. uint32_t height() { return m_outputHeight; }
  42. void saveOutput(const std::string& filename);
  43. private:
  44. UIData& m_ui;
  45. DeviceResources& m_deviceResources;
  46. NVSharpen m_NVSharpen;
  47. NVScaler m_NVScaler;
  48. BilinearUpscale m_upscale;
  49. uint32_t m_inputWidth = 0;
  50. uint32_t m_inputHeight = 0;
  51. uint32_t m_outputWidth = 0;
  52. uint32_t m_outputHeight = 0;
  53. ComPtr<ID3D11Texture2D> m_input;
  54. ComPtr<ID3D11Texture2D> m_output;
  55. ComPtr<ID3D11ShaderResourceView> m_inputSRV;
  56. ComPtr<ID3D11UnorderedAccessView> m_outputUAV;
  57. std::filesystem::path m_currentFilePath;
  58. float m_currentScale = 100.f;
  59. float m_currentSharpness = 0.f;
  60. ComPtr<ID3D11Query> m_timeStampDis;
  61. ComPtr<ID3D11Query> m_timeStampStart;
  62. ComPtr<ID3D11Query> m_timeStampEnd;
  63. };