mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 21:02:28 +00:00
ifcviewer: move render pipelines into ViewportCore (#84-b)
Move the 15 pipeline + bind-group-layout + shader-module handles
that buildPipelines / buildEdgePipeline / buildPickPipeline write to.
Same pattern as #84-a: storage lives in ViewportCore, ViewportWindow
keeps reference aliases so existing builder-method bodies don't
have to acquire a `core_.` prefix at every touch point.
Moved fields:
Main render group:
main_shader_module_, frame_bgl_ (group 0), model_bgl_ (group 1),
pipeline_layout_, main_pipeline_, main_pipeline_transparent_
HiZ occlusion-cull group:
hiz_shader_module_, hiz_bgl_, hiz_pipeline_layout_, hiz_pipeline_
Edge silhouette group:
edge_shader_module_, edge_bgl_, edge_pipeline_layout_, edge_pipeline_
Pick pass:
pick_pipeline_ (reuses pipeline_layout_ — same set of bindings)
ViewportWindow's constructor binds 16 new alias references after
the 7 lifecycle ones from #84-a; member-init order matches
declaration order so core_ is constructed before any alias binds.
Builds: desktop / bonsai / web all green. Tests 100/100.
This commit is contained in:
@@ -69,6 +69,39 @@ private:
|
|||||||
WGPUSurface surface_ = nullptr;
|
WGPUSurface surface_ = nullptr;
|
||||||
WGPUTextureFormat surface_format_ = WGPUTextureFormat_Undefined;
|
WGPUTextureFormat surface_format_ = WGPUTextureFormat_Undefined;
|
||||||
bool surface_configured_ = false;
|
bool surface_configured_ = false;
|
||||||
|
|
||||||
|
// ---- Pipelines + bind-group layouts (built once after init) -------------
|
||||||
|
//
|
||||||
|
// Main render pipeline group: one shader module + two bind group
|
||||||
|
// layouts (frame uniforms at group=0, per-model storages at
|
||||||
|
// group=1) feeding both the opaque-pass pipeline and the
|
||||||
|
// transparent-pass variant. The transparent pipeline shares the
|
||||||
|
// shader and layout; it differs only in depthWriteEnabled=False
|
||||||
|
// and the SrcAlpha / OneMinusSrcAlpha blend on the color target.
|
||||||
|
WGPUShaderModule main_shader_module_ = nullptr;
|
||||||
|
WGPUBindGroupLayout frame_bgl_ = nullptr; // group 0
|
||||||
|
WGPUBindGroupLayout model_bgl_ = nullptr; // group 1
|
||||||
|
WGPUPipelineLayout pipeline_layout_ = nullptr;
|
||||||
|
WGPURenderPipeline main_pipeline_ = nullptr;
|
||||||
|
WGPURenderPipeline main_pipeline_transparent_ = nullptr;
|
||||||
|
|
||||||
|
// HiZ occlusion-cull pipeline group. Downsamples MSAA depth into a
|
||||||
|
// mip pyramid; consumed by next-frame cull.
|
||||||
|
WGPUShaderModule hiz_shader_module_ = nullptr;
|
||||||
|
WGPUBindGroupLayout hiz_bgl_ = nullptr;
|
||||||
|
WGPUPipelineLayout hiz_pipeline_layout_ = nullptr;
|
||||||
|
WGPURenderPipeline hiz_pipeline_ = nullptr;
|
||||||
|
|
||||||
|
// Edge-silhouette pipeline group. Drawn after the main pass; reads
|
||||||
|
// the depth/normal attachments to emit dark outlines.
|
||||||
|
WGPUShaderModule edge_shader_module_ = nullptr;
|
||||||
|
WGPUBindGroupLayout edge_bgl_ = nullptr;
|
||||||
|
WGPUPipelineLayout edge_pipeline_layout_ = nullptr;
|
||||||
|
WGPURenderPipeline edge_pipeline_ = nullptr;
|
||||||
|
|
||||||
|
// Pick pass. Reuses pipeline_layout_ — same set of bindings as the
|
||||||
|
// main pass since the pick fragment also vertex-pulls instance data.
|
||||||
|
WGPURenderPipeline pick_pipeline_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIEWPORTCORE_H
|
#endif // VIEWPORTCORE_H
|
||||||
|
|||||||
@@ -618,7 +618,22 @@ ViewportWindow::ViewportWindow(QWindow* parent)
|
|||||||
queue_ (core_.queue_),
|
queue_ (core_.queue_),
|
||||||
surface_ (core_.surface_),
|
surface_ (core_.surface_),
|
||||||
surface_format_ (core_.surface_format_),
|
surface_format_ (core_.surface_format_),
|
||||||
surface_configured_(core_.surface_configured_) {
|
surface_configured_(core_.surface_configured_),
|
||||||
|
main_shader_module_ (core_.main_shader_module_),
|
||||||
|
frame_bgl_ (core_.frame_bgl_),
|
||||||
|
model_bgl_ (core_.model_bgl_),
|
||||||
|
pipeline_layout_ (core_.pipeline_layout_),
|
||||||
|
main_pipeline_ (core_.main_pipeline_),
|
||||||
|
main_pipeline_transparent_(core_.main_pipeline_transparent_),
|
||||||
|
hiz_shader_module_ (core_.hiz_shader_module_),
|
||||||
|
hiz_bgl_ (core_.hiz_bgl_),
|
||||||
|
hiz_pipeline_layout_ (core_.hiz_pipeline_layout_),
|
||||||
|
hiz_pipeline_ (core_.hiz_pipeline_),
|
||||||
|
edge_shader_module_ (core_.edge_shader_module_),
|
||||||
|
edge_bgl_ (core_.edge_bgl_),
|
||||||
|
edge_pipeline_layout_ (core_.edge_pipeline_layout_),
|
||||||
|
edge_pipeline_ (core_.edge_pipeline_),
|
||||||
|
pick_pipeline_(core_.pick_pipeline_) {
|
||||||
// wgpu doesn't need a GL context; we just need a real native window
|
// wgpu doesn't need a GL context; we just need a real native window
|
||||||
// whose backing layer matches the GPU API wgpu will drive.
|
// whose backing layer matches the GPU API wgpu will drive.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -654,18 +654,16 @@ private:
|
|||||||
WGPUTextureFormat& surface_format_;
|
WGPUTextureFormat& surface_format_;
|
||||||
bool& surface_configured_;
|
bool& surface_configured_;
|
||||||
|
|
||||||
// Render pipeline + bind group layouts (built once after init).
|
// Pipeline + bind-group-layout alias references — actual storage
|
||||||
WGPUShaderModule main_shader_module_ = nullptr;
|
// lives in core_ (see ViewportCore.h). Each goes away as the
|
||||||
WGPUBindGroupLayout frame_bgl_ = nullptr; // group 0
|
// building method (buildPipelines / buildEdgePipeline /
|
||||||
WGPUBindGroupLayout model_bgl_ = nullptr; // group 1
|
// buildPickPipeline) migrates into ViewportCore.
|
||||||
WGPUPipelineLayout pipeline_layout_ = nullptr;
|
WGPUShaderModule& main_shader_module_;
|
||||||
WGPURenderPipeline main_pipeline_ = nullptr;
|
WGPUBindGroupLayout& frame_bgl_; // group 0
|
||||||
// Transparent-pass pipeline. Same shader / layout / vertex-pulling as
|
WGPUBindGroupLayout& model_bgl_; // group 1
|
||||||
// main_pipeline_; differs only in depthWriteEnabled=False and a
|
WGPUPipelineLayout& pipeline_layout_;
|
||||||
// SrcAlpha / OneMinusSrcAlpha blend on the color target. render()
|
WGPURenderPipeline& main_pipeline_;
|
||||||
// does the opaque pass with main_pipeline_ first, then this one
|
WGPURenderPipeline& main_pipeline_transparent_;
|
||||||
// over the transparent partition of each chunk's visible_draws.
|
|
||||||
WGPURenderPipeline main_pipeline_transparent_ = nullptr;
|
|
||||||
|
|
||||||
// Per-frame uniform (view-proj + lighting), bound at group 0.
|
// Per-frame uniform (view-proj + lighting), bound at group 0.
|
||||||
WGPUBuffer frame_uniform_buffer_ = nullptr;
|
WGPUBuffer frame_uniform_buffer_ = nullptr;
|
||||||
@@ -712,10 +710,11 @@ private:
|
|||||||
// GL's HiZ default is 256 wide; we match. Height tracks viewport aspect.
|
// GL's HiZ default is 256 wide; we match. Height tracks viewport aspect.
|
||||||
static constexpr uint32_t HIZ_BASE_W = 256;
|
static constexpr uint32_t HIZ_BASE_W = 256;
|
||||||
|
|
||||||
WGPUShaderModule hiz_shader_module_ = nullptr;
|
// HiZ pipeline aliases (storage in core_).
|
||||||
WGPUBindGroupLayout hiz_bgl_ = nullptr;
|
WGPUShaderModule& hiz_shader_module_;
|
||||||
WGPUPipelineLayout hiz_pipeline_layout_ = nullptr;
|
WGPUBindGroupLayout& hiz_bgl_;
|
||||||
WGPURenderPipeline hiz_pipeline_ = nullptr;
|
WGPUPipelineLayout& hiz_pipeline_layout_;
|
||||||
|
WGPURenderPipeline& hiz_pipeline_;
|
||||||
WGPUBuffer hiz_uniform_buffer_ = nullptr;
|
WGPUBuffer hiz_uniform_buffer_ = nullptr;
|
||||||
WGPUBindGroup hiz_bind_group_ = nullptr;
|
WGPUBindGroup hiz_bind_group_ = nullptr;
|
||||||
|
|
||||||
@@ -736,10 +735,11 @@ private:
|
|||||||
// texture in a fullscreen pass, computes a depth Laplacian, blends
|
// texture in a fullscreen pass, computes a depth Laplacian, blends
|
||||||
// dark lines into the resolved surface colour. Matches GL's
|
// dark lines into the resolved surface colour. Matches GL's
|
||||||
// renderEdgePass() visually.
|
// renderEdgePass() visually.
|
||||||
WGPUShaderModule edge_shader_module_ = nullptr;
|
// Edge silhouette pipeline aliases (storage in core_).
|
||||||
WGPUBindGroupLayout edge_bgl_ = nullptr;
|
WGPUShaderModule& edge_shader_module_;
|
||||||
WGPUPipelineLayout edge_pipeline_layout_ = nullptr;
|
WGPUBindGroupLayout& edge_bgl_;
|
||||||
WGPURenderPipeline edge_pipeline_ = nullptr;
|
WGPUPipelineLayout& edge_pipeline_layout_;
|
||||||
|
WGPURenderPipeline& edge_pipeline_;
|
||||||
WGPUBindGroup edge_bind_group_ = nullptr;
|
WGPUBindGroup edge_bind_group_ = nullptr;
|
||||||
bool edges_enabled_ = true;
|
bool edges_enabled_ = true;
|
||||||
|
|
||||||
@@ -783,7 +783,8 @@ private:
|
|||||||
// pass — pick fragment outputs the instance's object_id. The pick
|
// pass — pick fragment outputs the instance's object_id. The pick
|
||||||
// pipeline reuses pipeline_layout_ because it needs the same set of
|
// pipeline reuses pipeline_layout_ because it needs the same set of
|
||||||
// bindings (frame uniform at group=0, per-model storages at group=1).
|
// bindings (frame uniform at group=0, per-model storages at group=1).
|
||||||
WGPURenderPipeline pick_pipeline_ = nullptr;
|
// Pick pipeline alias (storage in core_).
|
||||||
|
WGPURenderPipeline& pick_pipeline_;
|
||||||
WGPUTexture pick_color_texture_ = nullptr;
|
WGPUTexture pick_color_texture_ = nullptr;
|
||||||
WGPUTextureView pick_color_view_ = nullptr;
|
WGPUTextureView pick_color_view_ = nullptr;
|
||||||
// Second pick MRT: RGBA16F packed world-space normal. Sampled by
|
// Second pick MRT: RGBA16F packed world-space normal. Sampled by
|
||||||
|
|||||||
Reference in New Issue
Block a user