AppRenderer.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "DeviceResources.h"
  26. #include "NVScaler.h"
  27. #include "NVSharpen.h"
  28. #include "UIRenderer.h"
  29. #include "Image.h"
  30. class AppRenderer
  31. {
  32. public:
  33. AppRenderer(DeviceResources& deviceResources, UIData& ui, const std::vector<std::string>& shaderPaths, bool glsl);
  34. bool update();
  35. void render();
  36. void present();
  37. void cleanUp();
  38. uint32_t width() { return m_outputWidth; }
  39. uint32_t height() { return m_outputHeight; }
  40. private:
  41. void blitInputToTemp();
  42. void blitCopyToRenderTarget();
  43. UIData& m_ui;
  44. DeviceResources& m_deviceResources;
  45. NVSharpen m_NVSharpen;
  46. NVScaler m_NVScaler;
  47. uint32_t m_inputWidth = 0;
  48. uint32_t m_inputHeight = 0;
  49. uint32_t m_outputWidth = 0;
  50. uint32_t m_outputHeight = 0;
  51. VkImage m_input = VK_NULL_HANDLE;
  52. VkDeviceMemory m_inputDeviceMemory;
  53. VkImageView m_inputSRV;
  54. std::vector<uint8_t> m_image;
  55. uint32_t m_rowPitch;
  56. std::filesystem::path m_currentFilePath;
  57. VkImage m_temp = VK_NULL_HANDLE;
  58. VkDeviceMemory m_tempDeviceMemory;
  59. VkImageView m_tempSRV;
  60. uint32_t m_currentOutputWidth;
  61. uint32_t m_currentOutputHeight;
  62. float m_currentScale = 100;
  63. float m_currentSharpness = 0;
  64. bool m_updateWindowSize = false;
  65. bool m_updateSharpness = false;
  66. bool m_uploadCoefficients = true;
  67. bool m_init = false;
  68. };