Loading...
Searching...
No Matches
RenderState.hpp
1#pragma once
2#include <QOffscreenSurface>
3#include <QtGui/private/qrhi_p.h>
4
5#include <score_plugin_gfx_export.h>
6
7#include <functional>
8
9#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
10using QRhiBufferReadbackResult = QRhiReadbackResult;
11#endif
12
13class QOffscreenSurface;
14class QWindow;
15namespace score::gfx
16{
17class RenderList;
22{
23 Null,
24 OpenGL,
25 Vulkan,
26 D3D11,
27 Metal,
28 D3D12
29};
30
31class Window;
32
37{
38 RenderState() = default;
39 RenderState(const RenderState&) = delete;
40 RenderState(RenderState&&) = delete;
41 RenderState& operator=(const RenderState&) = delete;
42 RenderState& operator=(RenderState&&) = delete;
43
44 QRhi* rhi{};
45 QRhiRenderPassDescriptor* renderPassDescriptor{};
46 std::weak_ptr<RenderList> renderer{};
47
48 QOffscreenSurface* surface{};
49 std::weak_ptr<score::gfx::Window>
50 window{}; // Not always set, only used to get mouse events & such.
51 QSize renderSize{};
52 QSize outputSize{};
53 int samples{1};
54 QRhiTexture::Format renderFormat{QRhiTexture::RGBA8};
55 GraphicsApi api{};
56 QShaderVersion version{};
57
58#if QT_VERSION >= QT_VERSION_CHECK(6, 12, 0)
59 struct
60 {
61 bool drawIndirect{false};
62 bool drawIndirectMulti{false};
63 } caps;
64#endif
65
66 // Called after QRhi is destroyed to clean up an imported VkDevice
67 std::function<void()> customDeviceCleanup;
68
69 void destroy()
70 {
71 window.reset();
72
73 delete rhi;
74 rhi = nullptr;
75
76 // Destroy imported VkDevice AFTER QRhi (which still references it during shutdown)
77 if(customDeviceCleanup)
78 {
79 customDeviceCleanup();
80 customDeviceCleanup = nullptr;
81 }
82
83 delete surface;
84 surface = nullptr;
85 }
86};
87
88SCORE_PLUGIN_GFX_EXPORT
89std::shared_ptr<RenderState>
90createRenderState(GraphicsApi graphicsApi, QSize sz, QWindow* window);
91
92static const constexpr int32_t invalid_node_index = -1;
93}
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
GraphicsApi
Available graphics APIs to use.
Definition RenderState.hpp:22
Global state associated to a rendering context.
Definition RenderState.hpp:37