架构大改之前

This commit is contained in:
2026-08-23 17:11:12 +08:00
parent 73a3152733
commit 3938e72bb7
34 changed files with 1111 additions and 327 deletions
+23
View File
@@ -495,6 +495,29 @@ DVZ_EXPORT DvzSceneFrameArtifact* dvz_figure_emit_frame(
const DvzFramePlanEmitConfig* cfg);
/**
* Emit an immutable frame artifact for one explicit retained emitter/runtime pair.
*
* Multiple independent DRP2 runtimes must never consume successive incremental streams from one
* emitter. Give every runtime its own emitter and set `replay_payloads` when another emitter may
* have committed the Scene's global dirty flags since this emitter last emitted.
*
* The caller owns `emitter`; this function neither stores nor destroys it.
*
* @param figure the figure
* @param emitter the persistent emitter paired with the destination runtime
* @param replay_payloads whether to replay current retained CPU payloads into this runtime
* @param caps the capability snapshot (nullable)
* @param report output diagnostic report (nullable)
* @param cfg the emission configuration (nullable)
* @return an owned frame artifact, or NULL on failure
*/
DVZ_EXPORT DvzSceneFrameArtifact* dvz_figure_emit_frame_with_emitter(
DvzFigure* figure, DvzFramePlanEmitter* emitter, bool replay_payloads,
const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg);
/**
* Destroy a frame artifact.
*
+2
View File
@@ -384,6 +384,8 @@ DvzId _scene_next_id(DvzScene* scene);
bool _scene_runtime_emitter_reset(DvzScene* scene);
void _scene_mark_runtime_payloads_dirty(DvzScene* scene);
struct DvzPanelView2DResolved
{
float view_extent[4];
+46 -5
View File
@@ -679,14 +679,13 @@ bool _scene_visual_mutation_allowed(const DvzScene* scene, const char* action)
}
DvzDrp2CommandStream* _scene_figure_emit_stream_ex(
DvzFigure* figure, const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg)
DvzDrp2CommandStream* _scene_figure_emit_stream_with_emitter_ex(
DvzFigure* figure, DvzFramePlanEmitter* emitter, const DvzCapabilitySnapshot* caps,
DvzDiagnosticReport* report, const DvzFramePlanEmitConfig* cfg)
{
ANN(figure);
ANN(figure->scene);
ANN(figure->scene->emitter);
DvzFramePlanEmitter* emitter = figure->scene->emitter;
ANN(emitter);
DvzCapabilitySnapshot default_caps;
DvzDiagnosticReport local_report;
@@ -794,6 +793,19 @@ DvzDrp2CommandStream* _scene_figure_emit_stream_ex(
DvzDrp2CommandStream* _scene_figure_emit_stream_ex(
DvzFigure* figure, const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg)
{
ANN(figure);
ANN(figure->scene);
ANN(figure->scene->emitter);
return _scene_figure_emit_stream_with_emitter_ex(
figure, figure->scene->emitter, caps, report, cfg);
}
DvzSceneFrameArtifact* dvz_figure_emit_frame(
DvzFigure* figure, const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg)
@@ -813,6 +825,35 @@ DvzSceneFrameArtifact* dvz_figure_emit_frame(
DvzSceneFrameArtifact* dvz_figure_emit_frame_with_emitter(
DvzFigure* figure, DvzFramePlanEmitter* emitter, bool replay_payloads,
const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg)
{
ANN(figure);
ANN(figure->scene);
ANN(emitter);
if (replay_payloads)
_scene_mark_runtime_payloads_dirty(figure->scene);
const uint64_t resource_version = figure->artifact_resource_version + 1;
const uint64_t frame_index = figure->artifact_frame_index + 1;
DvzDrp2CommandStream* stream = _scene_figure_emit_stream_with_emitter_ex(
figure, emitter, caps, report, cfg);
if (stream == NULL)
return NULL;
DvzSceneFrameArtifact* artifact =
_scene_frame_artifact(stream, resource_version, frame_index);
if (artifact != NULL)
{
figure->artifact_resource_version = resource_version;
figure->artifact_frame_index = frame_index;
}
return artifact;
}
void dvz_scene_frame_artifact_destroy(DvzSceneFrameArtifact* artifact)
{
_scene_frame_artifact_destroy(artifact);
@@ -19,3 +19,7 @@ bool _scene_figure_has_pending_render_work(const DvzFigure* figure);
DvzDrp2CommandStream* _scene_figure_emit_stream_ex(
DvzFigure* figure, const DvzCapabilitySnapshot* caps, DvzDiagnosticReport* report,
const DvzFramePlanEmitConfig* cfg);
DvzDrp2CommandStream* _scene_figure_emit_stream_with_emitter_ex(
DvzFigure* figure, DvzFramePlanEmitter* emitter, const DvzCapabilitySnapshot* caps,
DvzDiagnosticReport* report, const DvzFramePlanEmitConfig* cfg);
+1 -1
View File
@@ -218,7 +218,7 @@ static void _scene_mark_visual_runtime_dirty(DvzVisual* visual)
*
* @param scene the scene
*/
static void _scene_mark_runtime_payloads_dirty(DvzScene* scene)
void _scene_mark_runtime_payloads_dirty(DvzScene* scene)
{
ANN(scene);
for (uint32_t i = 0; i < scene->visual_count; i++)
@@ -59,6 +59,8 @@ bool _scene_visual_desc_finish_index(
bool _scene_visual_has_dense_attr(const DvzVisual* visual, const char* name);
bool _scene_visual_has_bound_attr(const DvzVisual* visual, const char* name);
bool _scene_visual_desc_is_primitive(DvzSceneVisualDescKind kind);
bool _scene_visual_desc_is_textured_mesh(DvzSceneVisualDescKind kind);
@@ -45,8 +45,8 @@ bool _scene_mesh_visual_lowering(const DvzVisual* visual, DvzVisualLowering* out
? _scene_visual_family_desc_kind(DVZ_VISUAL_TYPE_MESH)
: _scene_visual_family_desc_kind(DVZ_VISUAL_TYPE_PRIMITIVE);
out->needs_material_params =
_scene_visual_has_dense_attr(visual, "normal") ||
_scene_visual_has_dense_attr(visual, "item_state");
_scene_visual_has_bound_attr(visual, "normal") ||
_scene_visual_has_bound_attr(visual, "item_state");
return true;
}
@@ -41,7 +41,7 @@ bool _scene_primitive_visual_lowering(const DvzVisual* visual, DvzVisualLowering
out->draw_position_attr = "position";
out->renderable_kind = DVZ_RENDERABLE_INDEXED_MESH;
out->desc_kind = DVZ_SCENE_VISUAL_DESC_PRIMITIVE;
out->needs_material_params = _scene_visual_has_dense_attr(visual, "normal");
out->needs_material_params = _scene_visual_has_bound_attr(visual, "normal");
return true;
}
@@ -201,6 +201,26 @@ bool _scene_visual_has_dense_attr(const DvzVisual* visual, const char* name)
}
/**
* Return whether one retained visual has an attribute payload available to the render pipeline.
*
* Unlike dense-data consumers, pipeline capability resolution must also recognize Scene buffers:
* their payload is deliberately absent from host memory when the application owns the GPU buffer.
*
* @param visual the retained visual
* @param name the attribute name
* @return whether dense data or an external Scene buffer is bound
*/
bool _scene_visual_has_bound_attr(const DvzVisual* visual, const char* name)
{
ANN(visual);
ANN(name);
int attr_idx = _attr_index(visual, name);
return attr_idx >= 0 && visual->attrs[attr_idx].item_count > 0 &&
(visual->attrs[attr_idx].data != NULL || visual->attrs[attr_idx].buffer != NULL);
}
/**
* Return whether a visual descriptor uses the primitive pipeline family.
*
@@ -131,7 +131,7 @@ bool _scene_visual_default_pass_caps(
DvzSceneVisualDescKind kind = lowering->desc_kind;
bool has_normals =
(_scene_visual_desc_is_primitive(kind) || kind == DVZ_SCENE_VISUAL_DESC_TEXTURED_MESH) &&
_scene_visual_has_dense_attr(visual, "normal");
_scene_visual_has_bound_attr(visual, "normal");
bool point_like = kind == DVZ_SCENE_VISUAL_DESC_POINT || kind == DVZ_SCENE_VISUAL_DESC_PIXEL ||
kind == DVZ_SCENE_VISUAL_DESC_MARKER;