1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QSGRENDERERINTERFACE_H |
5 | #define QSGRENDERERINTERFACE_H |
6 | |
7 | #include <QtQuick/qsgnode.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | class QQuickWindow; |
12 | |
13 | class Q_QUICK_EXPORT QSGRendererInterface |
14 | { |
15 | public: |
16 | enum GraphicsApi { |
17 | Unknown, |
18 | Software, |
19 | OpenVG, |
20 | OpenGL, |
21 | Direct3D11, |
22 | Vulkan, |
23 | Metal, |
24 | Null, |
25 | Direct3D12, |
26 | |
27 | OpenGLRhi = OpenGL, |
28 | Direct3D11Rhi = Direct3D11, |
29 | VulkanRhi = Vulkan, |
30 | MetalRhi = Metal, |
31 | NullRhi = Null |
32 | }; |
33 | |
34 | enum Resource { |
35 | DeviceResource, |
36 | CommandQueueResource, |
37 | CommandListResource, |
38 | PainterResource, |
39 | RhiResource, |
40 | RhiSwapchainResource, |
41 | RhiRedirectCommandBuffer, |
42 | RhiRedirectRenderTarget, |
43 | PhysicalDeviceResource, |
44 | OpenGLContextResource, |
45 | DeviceContextResource, |
46 | CommandEncoderResource, |
47 | VulkanInstanceResource, |
48 | RenderPassResource, |
49 | RedirectPaintDevice, |
50 | GraphicsQueueFamilyIndexResource, |
51 | GraphicsQueueIndexResource, |
52 | }; |
53 | |
54 | enum ShaderType { |
55 | UnknownShadingLanguage, |
56 | GLSL, |
57 | HLSL, |
58 | RhiShader |
59 | }; |
60 | |
61 | enum ShaderCompilationType { |
62 | RuntimeCompilation = 0x01, |
63 | OfflineCompilation = 0x02 |
64 | }; |
65 | Q_DECLARE_FLAGS(ShaderCompilationTypes, ShaderCompilationType) |
66 | |
67 | enum ShaderSourceType { |
68 | ShaderSourceString = 0x01, |
69 | ShaderSourceFile = 0x02, |
70 | ShaderByteCode = 0x04 |
71 | }; |
72 | Q_DECLARE_FLAGS(ShaderSourceTypes, ShaderSourceType) |
73 | |
74 | enum RenderMode { |
75 | RenderMode2D, |
76 | RenderMode2DNoDepthBuffer, |
77 | RenderMode3D |
78 | }; |
79 | |
80 | virtual ~QSGRendererInterface(); |
81 | |
82 | virtual GraphicsApi graphicsApi() const = 0; |
83 | |
84 | virtual void *getResource(QQuickWindow *window, Resource resource) const; |
85 | virtual void *getResource(QQuickWindow *window, const char *resource) const; |
86 | |
87 | virtual ShaderType shaderType() const = 0; |
88 | virtual ShaderCompilationTypes shaderCompilationType() const = 0; |
89 | virtual ShaderSourceTypes shaderSourceType() const = 0; |
90 | |
91 | static bool isApiRhiBased(GraphicsApi api); |
92 | }; |
93 | |
94 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRendererInterface::ShaderCompilationTypes) |
95 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRendererInterface::ShaderSourceTypes) |
96 | |
97 | QT_END_NAMESPACE |
98 | |
99 | #endif |
100 | |