Qt RHI-based 3-D renderer managing scene objects, lighting, camera, and render pipeline for brain visualization. More...
#include <brainrenderer.h>
Classes | |
| struct | SceneData |
| Aggregated GPU resources and render state for the 3-D brain visualization scene. More... | |
| struct | Impl |
Public Types | |
| using | ShaderMode = ::ShaderMode |
Public Member Functions | |
| BrainRenderer () | |
| ~BrainRenderer () | |
| void | initialize (QRhi *rhi, QRhiRenderPassDescriptor *rp, int sampleCount) |
| void | ensureRenderTargets (QRhi *rhi, QRhiTexture *colorTex, const QSize &pixelSize) |
| QRhiRenderTarget * | rtClear () const |
| QRhiRenderTarget * | rtPreserve () const |
| void | beginFrame (QRhiCommandBuffer *cb) |
| void | beginPreservingPass (QRhiCommandBuffer *cb) |
| void | updateSceneUniforms (QRhi *rhi, const SceneData &data) |
| void | renderSurface (QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, BrainSurface *surface, ShaderMode mode) |
| int | prepareSurfaceDraw (QRhiResourceUpdateBatch *u, const SceneData &data, BrainSurface *surface) |
| void | issueSurfaceDraw (QRhiCommandBuffer *cb, BrainSurface *surface, ShaderMode mode, int uniformOffset) |
| void | prepareMergedSurfaces (QRhi *rhi, QRhiResourceUpdateBatch *u, const QVector< BrainSurface * > &surfaces, const QString &groupName=QStringLiteral("default")) |
| void | invalidateMergedGroup (const QString &groupName=QStringLiteral("default")) |
| bool | hasMergedContent (const QString &groupName) const |
| void | drawMergedSurfaces (QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, ShaderMode mode, const QString &groupName=QStringLiteral("default")) |
| void | renderDipoles (QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, DipoleObject *dipoles) |
| void | renderNetwork (QRhiCommandBuffer *cb, QRhi *rhi, const SceneData &data, NetworkObject *network) |
| void | endPass (QRhiCommandBuffer *cb) |
Static Public Attributes | |
| static constexpr ShaderMode | Standard = ::Standard |
| static constexpr ShaderMode | Holographic = ::Holographic |
| static constexpr ShaderMode | Anatomical = ::Anatomical |
| static constexpr ShaderMode | Dipole = ::Dipole |
| static constexpr ShaderMode | XRay = ::XRay |
| static constexpr ShaderMode | ShowNormals = ::ShowNormals |
Qt RHI-based 3-D renderer managing scene objects, lighting, camera, and render pipeline for brain visualization.
BrainRenderer handles the low-level RHI rendering logic, managing pipelines, shaders, and draw calls for brain surfaces.
Definition at line 74 of file brainrenderer.h.
Definition at line 91 of file brainrenderer.h.
| BrainRenderer::BrainRenderer | ( | ) |
Default Constructor
Definition at line 151 of file brainrenderer.cpp.
|
default |
Destructor
| void BrainRenderer::beginFrame | ( | QRhiCommandBuffer * | cb | ) |
Begin the first render pass of a frame. Clears color and depth.
| [in] | cb | Command buffer to record to. |
Definition at line 368 of file brainrenderer.cpp.
| void BrainRenderer::beginPreservingPass | ( | QRhiCommandBuffer * | cb | ) |
Begin an additional render pass that preserves previous output. Uses the internal preserving render target (m_rtPreserve).
| [in] | cb | Command buffer. |
Definition at line 389 of file brainrenderer.cpp.
| void BrainRenderer::drawMergedSurfaces | ( | QRhiCommandBuffer * | cb, |
| QRhi * | rhi, | ||
| const SceneData & | data, | ||
| ShaderMode | mode, | ||
| const QString & | groupName = QStringLiteral("default") ) |
Draw previously prepared merged surfaces in a single drawIndexed. Call between beginFrame()/beginPreservingPass() and endPass().
| [in] | cb | Command buffer. |
| [in] | rhi | QRhi pointer. |
| [in] | data | Scene uniforms. |
| [in] | mode | Shader mode. |
Definition at line 887 of file brainrenderer.cpp.
| void BrainRenderer::endPass | ( | QRhiCommandBuffer * | cb | ) |
End any render pass (clearing or preserving).
| [in] | cb | Command buffer. |
Definition at line 401 of file brainrenderer.cpp.
| void BrainRenderer::ensureRenderTargets | ( | QRhi * | rhi, |
| QRhiTexture * | colorTex, | ||
| const QSize & | pixelSize ) |
Create the dual render-target pair for multi-pass rendering.
Both render targets share the same color texture and depth-stencil buffer but differ in their load/store flags:
Qt bakes these flags into native resources at create() time, so calling setFlags() dynamically does NOT work (especially on WebGL). This is the validated pattern from test_wasm_multi_pass.
| [in] | rhi | QRhi instance. |
| [in] | colorTex | Color texture (owned by QRhiWidget or caller). |
| [in] | pixelSize | Render target dimensions. |
Definition at line 321 of file brainrenderer.cpp.
| bool BrainRenderer::hasMergedContent | ( | const QString & | groupName | ) | const |
Check if a merged group has drawable geometry (indexCount > 0). Use before beginPreservingPass() to avoid empty render passes which can clear the framebuffer on some WebGL implementations.
| [in] | groupName | Category name to check. |
Definition at line 879 of file brainrenderer.cpp.
| void BrainRenderer::initialize | ( | QRhi * | rhi, |
| QRhiRenderPassDescriptor * | rp, | ||
| int | sampleCount ) |
Initialize resources (shaders, pipelines) for the given RHI and render pass. Ensures pipelines for all supported modes are created.
| [in] | rhi | Pointer to QRhi instance. |
| [in] | rp | Render pass descriptor. |
| [in] | sampleCount | MSAA sample count. |
Definition at line 162 of file brainrenderer.cpp.
| void BrainRenderer::invalidateMergedGroup | ( | const QString & | groupName = QStringLiteral("default") | ) |
Mark a merged group as dirty so it is rebuilt on the next prepareMergedSurfaces call. Call when surfaces are added/removed or visibility changes.
| [in] | groupName | Category name to invalidate. |
Definition at line 869 of file brainrenderer.cpp.
| void BrainRenderer::issueSurfaceDraw | ( | QRhiCommandBuffer * | cb, |
| BrainSurface * | surface, | ||
| ShaderMode | mode, | ||
| int | uniformOffset ) |
Issue draw commands for a surface using a pre-computed uniform offset.
Call after cb->resourceUpdate() has been submitted with the batch from prepareSurfaceDraw(). Does not create resource batches or modify viewport/scissor state.
| [in] | cb | Command buffer. |
| [in] | surface | Pointer to surface to draw. |
| [in] | mode | Shader mode. |
| [in] | uniformOffset | Offset returned by prepareSurfaceDraw(). |
Definition at line 536 of file brainrenderer.cpp.
| void BrainRenderer::prepareMergedSurfaces | ( | QRhi * | rhi, |
| QRhiResourceUpdateBatch * | u, | ||
| const QVector< BrainSurface * > & | surfaces, | ||
| const QString & | groupName = QStringLiteral("default") ) |
Prepare merged brain surface geometry for single-drawIndexed rendering. Call BEFORE beginFrame() with a pre-upload resource batch.
Uses dirty-flag caching: geometry is only rebuilt when the surface list changes (add/remove/visibility toggle). Per-vertex color updates (STC animation) only re-upload the color channel.
| [in] | rhi | QRhi pointer. |
| [in] | u | Resource update batch (pre-render uploads). |
| [in] | surfaces | Brain surfaces to merge. |
| [in] | groupName | Category name (e.g. "brain", "bem", "srcsp"). |
Definition at line 715 of file brainrenderer.cpp.
| int BrainRenderer::prepareSurfaceDraw | ( | QRhiResourceUpdateBatch * | u, |
| const SceneData & | data, | ||
| BrainSurface * | surface ) |
Upload uniform data for a surface into a shared resource batch.
This is the batched equivalent of the first half of renderSurface(). Call once per surface, then submit the batch with cb->resourceUpdate(), and finally call issueSurfaceDraw() for each surface.
| [in] | u | Shared resource update batch. |
| [in] | data | Scene uniforms (MVP, light, etc). |
| [in] | surface | Pointer to surface. |
Definition at line 492 of file brainrenderer.cpp.
| void BrainRenderer::renderDipoles | ( | QRhiCommandBuffer * | cb, |
| QRhi * | rhi, | ||
| const SceneData & | data, | ||
| DipoleObject * | dipoles ) |
Render dipoles using instanced rendering.
| [in] | cb | Command buffer. |
| [in] | rhi | QRhi pointer. |
| [in] | data | Scene uniforms. |
| [in] | dipoles | Pointer to DipoleObject. |
Definition at line 564 of file brainrenderer.cpp.
| void BrainRenderer::renderNetwork | ( | QRhiCommandBuffer * | cb, |
| QRhi * | rhi, | ||
| const SceneData & | data, | ||
| NetworkObject * | network ) |
Render a connectivity network using instanced rendering. Renders both node spheres and edge cylinders as two draw calls.
| [in] | cb | Command buffer. |
| [in] | rhi | QRhi pointer. |
| [in] | data | Scene uniforms. |
| [in] | network | Pointer to NetworkObject. |
Definition at line 622 of file brainrenderer.cpp.
| void BrainRenderer::renderSurface | ( | QRhiCommandBuffer * | cb, |
| QRhi * | rhi, | ||
| const SceneData & | data, | ||
| BrainSurface * | surface, | ||
| ShaderMode | mode ) |
Render a single surface. Must be called between beginFrame/beginPreservingPass and endPass.
| [in] | cb | Command buffer. |
| [in] | rhi | QRhi pointer. |
| [in] | data | Scene uniforms (MVP, light, etc). |
| [in] | surface | Pointer to surface to draw. |
| [in] | mode | Shader mode to use for this surface. |
Definition at line 408 of file brainrenderer.cpp.
| QRhiRenderTarget * BrainRenderer::rtClear | ( | ) | const |
Definition at line 356 of file brainrenderer.cpp.
| QRhiRenderTarget * BrainRenderer::rtPreserve | ( | ) | const |
Definition at line 361 of file brainrenderer.cpp.
| void BrainRenderer::updateSceneUniforms | ( | QRhi * | rhi, |
| const SceneData & | data ) |
Set uniforms that are shared for the entire frame.
| [in] | data | Scene uniforms (MVP, light, etc). |
Definition at line 382 of file brainrenderer.cpp.
|
staticconstexpr |
Definition at line 94 of file brainrenderer.h.
|
staticconstexpr |
Definition at line 95 of file brainrenderer.h.
|
staticconstexpr |
Definition at line 93 of file brainrenderer.h.
|
staticconstexpr |
Definition at line 97 of file brainrenderer.h.
|
staticconstexpr |
Definition at line 92 of file brainrenderer.h.
|
staticconstexpr |
Definition at line 96 of file brainrenderer.h.