renderer_compositor_rd.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*************************************************************************/
  2. /* renderer_compositor_rd.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef RENDERING_SERVER_COMPOSITOR_RD_H
  31. #define RENDERING_SERVER_COMPOSITOR_RD_H
  32. #include "core/os/os.h"
  33. #include "core/templates/thread_work_pool.h"
  34. #include "servers/rendering/renderer_compositor.h"
  35. #include "servers/rendering/renderer_rd/renderer_canvas_render_rd.h"
  36. #include "servers/rendering/renderer_rd/renderer_scene_render_forward.h"
  37. #include "servers/rendering/renderer_rd/renderer_storage_rd.h"
  38. class RendererCompositorRD : public RendererCompositor {
  39. protected:
  40. RendererCanvasRenderRD *canvas;
  41. RendererStorageRD *storage;
  42. RendererSceneRenderForward *scene;
  43. RID copy_viewports_rd_shader;
  44. RID copy_viewports_rd_pipeline;
  45. RID copy_viewports_rd_index_buffer;
  46. RID copy_viewports_rd_array;
  47. RID copy_viewports_sampler;
  48. Map<RID, RID> render_target_descriptors;
  49. double time;
  50. float delta;
  51. static uint64_t frame;
  52. public:
  53. RendererStorage *get_storage() { return storage; }
  54. RendererCanvasRender *get_canvas() { return canvas; }
  55. RendererSceneRender *get_scene() { return scene; }
  56. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {}
  57. void initialize();
  58. void begin_frame(double frame_step);
  59. void prepare_for_blitting_render_targets();
  60. void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
  61. void end_frame(bool p_swap_buffers);
  62. void finalize();
  63. _ALWAYS_INLINE_ uint64_t get_frame_number() const { return frame; }
  64. _ALWAYS_INLINE_ float get_frame_delta_time() const { return delta; }
  65. _ALWAYS_INLINE_ double get_total_time() const { return time; }
  66. static Error is_viable() {
  67. return OK;
  68. }
  69. static RendererCompositor *_create_current() {
  70. return memnew(RendererCompositorRD);
  71. }
  72. static void make_current() {
  73. _create_func = _create_current;
  74. }
  75. virtual bool is_low_end() const { return false; }
  76. static RendererCompositorRD *singleton;
  77. RendererCompositorRD();
  78. ~RendererCompositorRD() {}
  79. };
  80. #endif // RASTERIZER_RD_H