v2.0.0
Loading...
Searching...
No Matches
brainrenderer.h
Go to the documentation of this file.
1//=============================================================================================================
36
37#ifndef BRAINRENDERER_H
38#define BRAINRENDERER_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "../disp3D_global.h"
45
46#include "../core/rendertypes.h"
47
48#include <QMatrix4x4>
49#include <QVector3D>
50#include <memory>
51
52//=============================================================================================================
53// FORWARD DECLARATIONS
54//=============================================================================================================
55
56class QRhi;
57class QRhiCommandBuffer;
58class QRhiRenderTarget;
59class QRhiRenderPassDescriptor;
60class QRhiResourceUpdateBatch;
61class QRhiTexture;
62class QRhiRenderBuffer;
63class QRhiTextureRenderTarget;
64class BrainSurface;
65class DipoleObject;
66class NetworkObject;
67
68//=============================================================================================================
75{
76public:
77 //=========================================================================================================
82
83 //=========================================================================================================
88
89 // ShaderMode is defined in core/rendertypes.h for lightweight inclusion.
90 // These aliases preserve backward compatibility.
92 static constexpr ShaderMode Standard = ::Standard;
95 static constexpr ShaderMode Dipole = ::Dipole;
96 static constexpr ShaderMode XRay = ::XRay;
98
107 struct SceneData {
108 QMatrix4x4 mvp;
109 QVector3D cameraPos;
110 QVector3D lightDir;
112 float overlayMode = 0.0f; // 0=FsSurface, 1=FsAnnotation, 2=Scientific, 3=STC
113
114 // Viewport rectangle (floating-point, pixels)
115 float viewportX = 0, viewportY = 0, viewportW = 0, viewportH = 0;
116 // Scissor rectangle (integer, pixels)
117 int scissorX = 0, scissorY = 0, scissorW = 0, scissorH = 0;
118 };
119
120 //=========================================================================================================
129 void initialize(QRhi *rhi, QRhiRenderPassDescriptor *rp, int sampleCount);
130
131 //=========================================================================================================
148 void ensureRenderTargets(QRhi *rhi, QRhiTexture *colorTex, const QSize &pixelSize);
149
150 //=========================================================================================================
154 QRhiRenderTarget *rtClear() const;
155
159 QRhiRenderTarget *rtPreserve() const;
160
161 //=========================================================================================================
167 void beginFrame(QRhiCommandBuffer *cb);
168
169 //=========================================================================================================
176 void beginPreservingPass(QRhiCommandBuffer *cb);
177
178 //=========================================================================================================
184 void updateSceneUniforms(QRhi *rhi, const SceneData &data);
185
186 //=========================================================================================================
196 void renderSurface(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, BrainSurface *surface, ShaderMode mode);
197
198 //=========================================================================================================
211 int prepareSurfaceDraw(QRhiResourceUpdateBatch *u, const SceneData &data, BrainSurface *surface);
212
225 void issueSurfaceDraw(QRhiCommandBuffer *cb, BrainSurface *surface, ShaderMode mode, int uniformOffset);
226
227 //=========================================================================================================
228 // ── WORKAROUND(QRhi-GLES2) ──────────────────────────────────────────
229 // The Qt QRhi GLES2/WebGL backend has a bug where only the first
230 // drawIndexed() per render pass produces visible output. On WASM we
231 // work around this by merging all brain surfaces into a single VBO/IBO
232 // and issuing one drawIndexed(). When the upstream bug is fixed these
233 // two methods (and the merged buffers in Impl) can be removed.
234 //
248 void prepareMergedSurfaces(QRhi *rhi, QRhiResourceUpdateBatch *u,
249 const QVector<BrainSurface*> &surfaces,
250 const QString &groupName = QStringLiteral("default"));
251
259 void invalidateMergedGroup(const QString &groupName = QStringLiteral("default"));
260
269 bool hasMergedContent(const QString &groupName) const;
270
280 void drawMergedSurfaces(QRhiCommandBuffer *cb, QRhi *rhi,
281 const SceneData &data, ShaderMode mode,
282 const QString &groupName = QStringLiteral("default"));
283
284 //=========================================================================================================
293 void renderDipoles(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, DipoleObject *dipoles);
294
295 //=========================================================================================================
305 void renderNetwork(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, NetworkObject *network);
306
307 //=========================================================================================================
313 void endPass(QRhiCommandBuffer *cb);
314
315private:
317 struct Impl;
318 std::unique_ptr<Impl> d;
319};
320
321#endif // BRAINRENDERER_H
Lightweight render-related enums shared across the disp3D library.
disp3D library export/import macros.
#define DISP3DSHARED_EXPORT
Renderable cortical surface mesh with per-vertex color, curvature data, and GPU buffer management.
Renderable dipole arrow set with instanced GPU rendering for QRhi.
Renderable network visualization for QRhi.
void endPass(QRhiCommandBuffer *cb)
static constexpr ShaderMode Anatomical
bool hasMergedContent(const QString &groupName) const
QRhiRenderTarget * rtClear() const
static constexpr ShaderMode Holographic
void renderNetwork(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, NetworkObject *network)
void beginPreservingPass(QRhiCommandBuffer *cb)
::ShaderMode ShaderMode
static constexpr ShaderMode ShowNormals
void issueSurfaceDraw(QRhiCommandBuffer *cb, BrainSurface *surface, ShaderMode mode, int uniformOffset)
QRhiRenderTarget * rtPreserve() const
void drawMergedSurfaces(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, ShaderMode mode, const QString &groupName=QStringLiteral("default"))
int prepareSurfaceDraw(QRhiResourceUpdateBatch *u, const SceneData &data, BrainSurface *surface)
void renderSurface(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, BrainSurface *surface, ShaderMode mode)
void updateSceneUniforms(QRhi *rhi, const SceneData &data)
static constexpr ShaderMode Dipole
void ensureRenderTargets(QRhi *rhi, QRhiTexture *colorTex, const QSize &pixelSize)
void initialize(QRhi *rhi, QRhiRenderPassDescriptor *rp, int sampleCount)
void beginFrame(QRhiCommandBuffer *cb)
static constexpr ShaderMode Standard
void invalidateMergedGroup(const QString &groupName=QStringLiteral("default"))
void prepareMergedSurfaces(QRhi *rhi, QRhiResourceUpdateBatch *u, const QVector< BrainSurface * > &surfaces, const QString &groupName=QStringLiteral("default"))
void renderDipoles(QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, DipoleObject *dipoles)
static constexpr ShaderMode XRay
Aggregated GPU resources and render state for the 3-D brain visualization scene.