mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
refactored web profiler and native framebuffer (#14168)
This commit is contained in:
@@ -25,8 +25,8 @@
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Camera, CameraUsage } from '../../render-scene/scene';
|
||||
import { Pipeline, PipelineBuilder } from './pipeline';
|
||||
import { buildForwardPass, buildGBufferPass, buildLightingPass, buildPostprocessPass, buildProfilerPass,
|
||||
buildReflectionProbePasss, buildUIAndProfilerPass } from './define';
|
||||
import { buildForwardPass, buildGBufferPass, buildLightingPass, buildPostprocessPass,
|
||||
buildReflectionProbePasss, buildUIPass } from './define';
|
||||
import { isUICamera } from './utils';
|
||||
|
||||
export class ForwardPipelineBuilder implements PipelineBuilder {
|
||||
@@ -65,12 +65,10 @@ export class DeferredPipelineBuilder implements PipelineBuilder {
|
||||
const lightInfo = buildLightingPass(camera, ppl, gBufferInfo);
|
||||
// Postprocess
|
||||
buildPostprocessPass(camera, ppl, lightInfo.rtName);
|
||||
// Profiler
|
||||
buildProfilerPass(camera, ppl);
|
||||
continue;
|
||||
}
|
||||
// render ui and profiler
|
||||
buildUIAndProfilerPass(camera, ppl);
|
||||
// render ui
|
||||
buildUIPass(camera, ppl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
import { Camera, CameraUsage } from '../../render-scene/scene';
|
||||
import { buildFxaaPass, buildBloomPass as buildBloomPasses, buildForwardPass,
|
||||
buildNativeDeferredPipeline, buildNativeForwardPass, buildPostprocessPass,
|
||||
AntiAliasing, buildUIAndProfilerPass, buildProfilerPass } from './define';
|
||||
AntiAliasing, buildUIPass } from './define';
|
||||
import { Pipeline, PipelineBuilder } from './pipeline';
|
||||
import { isUICamera } from './utils';
|
||||
|
||||
@@ -53,12 +53,10 @@ export class CustomPipelineBuilder implements PipelineBuilder {
|
||||
const bloomInfo = buildBloomPasses(camera, ppl, fxaaInfo.rtName);
|
||||
// Present Pass
|
||||
buildPostprocessPass(camera, ppl, bloomInfo.rtName, AntiAliasing.NONE);
|
||||
// Profiler
|
||||
buildProfilerPass(camera, ppl);
|
||||
continue;
|
||||
}
|
||||
// render ui and profiler
|
||||
buildUIAndProfilerPass(camera, ppl);
|
||||
// render ui
|
||||
buildUIPass(camera, ppl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import { Pipeline } from './pipeline';
|
||||
import { AccessType, AttachmentType, ComputeView, LightInfo, QueueHint, RasterView, ResourceResidency, SceneFlags, UpdateFrequency } from './types';
|
||||
import { Vec4, macro, geometry, toRadian, cclegacy, assert } from '../../core';
|
||||
import { Material } from '../../asset/assets';
|
||||
import { SRGBToLinear } from '../pipeline-funcs';
|
||||
import { getProfilerCamera, SRGBToLinear } from '../pipeline-funcs';
|
||||
import { RenderWindow } from '../../render-scene/core/render-window';
|
||||
import { RenderData } from './render-graph';
|
||||
import { WebPipeline } from './web-pipeline';
|
||||
@@ -520,6 +520,9 @@ export function buildPostprocessPass (camera: Camera,
|
||||
);
|
||||
postprocessPass.addQueue(QueueHint.RENDER_TRANSPARENT).addSceneOfCamera(camera, new LightInfo(),
|
||||
SceneFlags.UI);
|
||||
if (getProfilerCamera() === camera) {
|
||||
postprocessPass.showStatistics = true;
|
||||
}
|
||||
return { rtName: postprocessPassRTName, dsName: postprocessPassDS };
|
||||
}
|
||||
|
||||
@@ -586,7 +589,8 @@ export function buildForwardPass (camera: Camera,
|
||||
| SceneFlags.DEFAULT_LIGHTING | SceneFlags.DRAW_INSTANCING);
|
||||
let sceneFlags = SceneFlags.TRANSPARENT_OBJECT | SceneFlags.GEOMETRY;
|
||||
if (!isOffScreen) {
|
||||
sceneFlags |= SceneFlags.UI | SceneFlags.PROFILER;
|
||||
sceneFlags |= SceneFlags.UI;
|
||||
forwardPass.showStatistics = true;
|
||||
}
|
||||
forwardPass
|
||||
.addQueue(QueueHint.RENDER_TRANSPARENT)
|
||||
@@ -944,46 +948,7 @@ function getClearFlags (attachment: AttachmentType, clearFlag: ClearFlagBit, loa
|
||||
}
|
||||
}
|
||||
|
||||
export function buildProfilerPass (camera: Camera,
|
||||
ppl: Pipeline) {
|
||||
const cameraID = getCameraUniqueID(camera);
|
||||
const cameraName = `Camera${cameraID}`;
|
||||
const area = getRenderArea(camera, camera.window.width, camera.window.height);
|
||||
const width = area.width;
|
||||
const height = area.height;
|
||||
|
||||
const dsProfilerPassRTName = `dsProfilerPassColor${cameraName}`;
|
||||
const dsProfilerPassDSName = `dsProfilerPassDS${cameraName}`;
|
||||
if (!ppl.containsResource(dsProfilerPassRTName)) {
|
||||
ppl.addRenderTexture(dsProfilerPassRTName, Format.BGRA8, width, height, camera.window);
|
||||
ppl.addDepthStencil(dsProfilerPassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
|
||||
}
|
||||
ppl.updateRenderWindow(dsProfilerPassRTName, camera.window);
|
||||
ppl.updateDepthStencil(dsProfilerPassDSName, width, height);
|
||||
const ProfilerPass = ppl.addRasterPass(width, height, 'default');
|
||||
ProfilerPass.name = `CameraProfilerPass${cameraID}`;
|
||||
ProfilerPass.setViewport(new Viewport(area.x, area.y, width, height));
|
||||
const passView = new RasterView('_',
|
||||
AccessType.WRITE, AttachmentType.RENDER_TARGET,
|
||||
getLoadOpOfClearFlag(ClearFlagBit.DEPTH_STENCIL, AttachmentType.RENDER_TARGET),
|
||||
StoreOp.STORE,
|
||||
ClearFlagBit.DEPTH_STENCIL,
|
||||
new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w));
|
||||
const passDSView = new RasterView('_',
|
||||
AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
|
||||
getLoadOpOfClearFlag(ClearFlagBit.DEPTH_STENCIL, AttachmentType.DEPTH_STENCIL),
|
||||
StoreOp.STORE,
|
||||
ClearFlagBit.DEPTH_STENCIL,
|
||||
new Color(camera.clearDepth, camera.clearStencil, 0, 0));
|
||||
ProfilerPass.addRasterView(dsProfilerPassRTName, passView);
|
||||
ProfilerPass.addRasterView(dsProfilerPassDSName, passDSView);
|
||||
const sceneFlags = SceneFlags.PROFILER;
|
||||
ProfilerPass
|
||||
.addQueue(QueueHint.RENDER_TRANSPARENT)
|
||||
.addSceneOfCamera(camera, new LightInfo(), sceneFlags);
|
||||
}
|
||||
|
||||
export function buildUIAndProfilerPass (camera: Camera,
|
||||
export function buildUIPass (camera: Camera,
|
||||
ppl: Pipeline) {
|
||||
const cameraID = getCameraUniqueID(camera);
|
||||
const cameraName = `Camera${cameraID}`;
|
||||
@@ -1016,10 +981,13 @@ export function buildUIAndProfilerPass (camera: Camera,
|
||||
new Color(camera.clearDepth, camera.clearStencil, 0, 0));
|
||||
uIAndProfilerPass.addRasterView(dsUIAndProfilerPassRTName, passView);
|
||||
uIAndProfilerPass.addRasterView(dsUIAndProfilerPassDSName, passDSView);
|
||||
const sceneFlags = SceneFlags.UI | SceneFlags.PROFILER;
|
||||
const sceneFlags = SceneFlags.UI;
|
||||
uIAndProfilerPass
|
||||
.addQueue(QueueHint.RENDER_TRANSPARENT)
|
||||
.addSceneOfCamera(camera, new LightInfo(), sceneFlags);
|
||||
if (getProfilerCamera() === camera) {
|
||||
uIAndProfilerPass.showStatistics = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function buildNativeForwardPass (camera: Camera, ppl: Pipeline) {
|
||||
@@ -1078,8 +1046,8 @@ export function buildNativeForwardPass (camera: Camera, ppl: Pipeline) {
|
||||
forwardPass
|
||||
.addQueue(QueueHint.RENDER_TRANSPARENT)
|
||||
.addSceneOfCamera(camera, new LightInfo(),
|
||||
SceneFlags.UI
|
||||
| SceneFlags.PROFILER);
|
||||
SceneFlags.UI);
|
||||
forwardPass.showStatistics = true;
|
||||
}
|
||||
|
||||
export function buildNativeDeferredPipeline (camera: Camera, ppl: Pipeline) {
|
||||
@@ -1281,6 +1249,13 @@ export function getDescriptorSetDataFromLayout (layoutName: string) {
|
||||
return layoutData;
|
||||
}
|
||||
|
||||
export function getDescriptorSetDataFromLayoutId (id: number) {
|
||||
const webPip = cclegacy.director.root.pipeline as WebPipeline;
|
||||
const layout = webPip.layoutGraph.getLayout(id);
|
||||
const layoutData = layout.descriptorSets.get(UpdateFrequency.PER_PASS);
|
||||
return layoutData;
|
||||
}
|
||||
|
||||
export function initGlobalDescBinding (data: RenderData, layoutName = 'default') {
|
||||
applyGlobalDescBinding(data, layoutName);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,10 @@ import { WebSceneVisitor } from './web-scene-visitor';
|
||||
import { stringify } from './utils';
|
||||
import { RenderAdditiveLightQueue } from '../render-additive-light-queue';
|
||||
import { RenderShadowMapBatchedQueue } from '../render-shadow-map-batched-queue';
|
||||
import { renderProfiler } from '../pipeline-funcs';
|
||||
import { PlanarShadowQueue } from '../planar-shadow-queue';
|
||||
import { DefaultVisitor, depthFirstSearch, ReferenceGraphView } from './graph';
|
||||
import { VectorGraphColorMap } from './effect';
|
||||
import { getDescBindingFromName, getDescriptorSetDataFromLayout, getRenderArea, mergeSrcToTargetDesc, updateGlobalDescBinding } from './define';
|
||||
import { getDescBindingFromName, getDescriptorSetDataFromLayout, getDescriptorSetDataFromLayoutId, getRenderArea, mergeSrcToTargetDesc, updateGlobalDescBinding } from './define';
|
||||
import { RenderReflectionProbeQueue } from '../render-reflection-probe-queue';
|
||||
import { ReflectionProbeManager } from '../reflection-probe-manager';
|
||||
import { builtinResMgr } from '../../asset/asset-manager/builtin-res-mgr';
|
||||
@@ -741,6 +740,36 @@ class DeviceRenderPass {
|
||||
this._viewport = viewport;
|
||||
}
|
||||
}
|
||||
|
||||
protected _showProfiler (rect: Rect) {
|
||||
const profiler = this.context.pipeline.profiler!;
|
||||
if (!profiler || !profiler.enabled) {
|
||||
return;
|
||||
}
|
||||
const context = this.context;
|
||||
const renderPass = this._renderPass;
|
||||
const cmdBuff = this.context.commandBuffer;
|
||||
const submodel = profiler.subModels[0];
|
||||
const pass = submodel.passes[0];
|
||||
const ia = submodel.inputAssembler;
|
||||
const device = this.context.device;
|
||||
const pso = PipelineStateManager.getOrCreatePipelineState(device, pass,
|
||||
submodel.shaders[0], renderPass, ia);
|
||||
const descData = getDescriptorSetDataFromLayoutId(pass.passID)!;
|
||||
mergeSrcToTargetDesc(descData.descriptorSet, context.pipeline.descriptorSet, true);
|
||||
const profilerViewport = new Viewport();
|
||||
profilerViewport.width = rect.width;
|
||||
profilerViewport.height = rect.height;
|
||||
|
||||
cmdBuff.setViewport(profilerViewport);
|
||||
cmdBuff.setScissor(rect);
|
||||
cmdBuff.bindPipelineState(pso);
|
||||
cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, pass.descriptorSet);
|
||||
cmdBuff.bindDescriptorSet(SetIndex.LOCAL, submodel.descriptorSet);
|
||||
cmdBuff.bindInputAssembler(ia);
|
||||
cmdBuff.draw(ia);
|
||||
}
|
||||
|
||||
// record common buffer
|
||||
record () {
|
||||
const tex = this.framebuffer.colorTextures[0]!;
|
||||
@@ -756,6 +785,9 @@ class DeviceRenderPass {
|
||||
for (const queue of this._deviceQueues) {
|
||||
queue.record();
|
||||
}
|
||||
if (this._rasterInfo.pass.showStatistics) {
|
||||
this._showProfiler(renderArea);
|
||||
}
|
||||
cmdBuff.endRenderPass();
|
||||
}
|
||||
|
||||
@@ -1349,10 +1381,6 @@ class DeviceSceneTask extends WebSceneTask {
|
||||
if (graphSceneData.flags & SceneFlags.UI) {
|
||||
this._recordUI();
|
||||
}
|
||||
if (graphSceneData.flags & SceneFlags.PROFILER) {
|
||||
renderProfiler(context.device, devicePass.renderPass,
|
||||
context.commandBuffer, context.pipeline.profiler, this.camera!);
|
||||
}
|
||||
if (graphSceneData.flags & SceneFlags.REFLECTION_PROBE) {
|
||||
this._recordReflectionProbe();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
import { AdjI, AdjacencyGraph, BidirectionalGraph, ComponentGraph, ED, InEI, MutableGraph, MutableReferenceGraph, NamedGraph, OutE, OutEI, PolymorphicGraph, PropertyGraph, PropertyMap, ReferenceGraph, UuidGraph, VertexListGraph, directional, parallel, reindexEdgeList, traversal } from './graph';
|
||||
import { Material } from '../../asset/assets';
|
||||
import { Camera } from '../../render-scene/scene/camera';
|
||||
import { AccessFlagBit, Buffer, ClearFlagBit, Color, Format, Framebuffer, SampleCount, Sampler, SamplerInfo, Swapchain, Texture, TextureFlagBit, Viewport } from '../../gfx';
|
||||
import { AccessFlagBit, Buffer, ClearFlagBit, Color, Format, Framebuffer, RenderPass, SampleCount, Sampler, SamplerInfo, Swapchain, Texture, TextureFlagBit, Viewport } from '../../gfx';
|
||||
import { ComputeView, CopyPair, LightInfo, MovePair, QueueHint, RasterView, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags } from './types';
|
||||
|
||||
export class ResourceDesc {
|
||||
@@ -61,6 +61,7 @@ export class RenderSwapchain {
|
||||
/*pointer*/ swapchain: Swapchain | null;
|
||||
currentID = 0;
|
||||
numBackBuffers = 0;
|
||||
generation = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
export class ResourceStates {
|
||||
@@ -87,6 +88,338 @@ export class ManagedResource {
|
||||
unused = 0;
|
||||
}
|
||||
|
||||
export class RasterSubpass {
|
||||
readonly rasterViews: Map<string, RasterView> = new Map<string, RasterView>();
|
||||
readonly computeViews: Map<string, ComputeView[]> = new Map<string, ComputeView[]>();
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// SubpassGraph
|
||||
//=================================================================
|
||||
// Graph Concept
|
||||
export class SubpassGraphVertex {
|
||||
constructor () {
|
||||
}
|
||||
readonly _outEdges: OutE[] = [];
|
||||
readonly _inEdges: OutE[] = [];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// PropertyGraph Concept
|
||||
export class SubpassGraphNameMap implements PropertyMap {
|
||||
constructor (readonly names: string[]) {
|
||||
this._names = names;
|
||||
}
|
||||
get (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
set (v: number, names: string): void {
|
||||
this._names[v] = names;
|
||||
}
|
||||
readonly _names: string[];
|
||||
}
|
||||
|
||||
export class SubpassGraphSubpassMap implements PropertyMap {
|
||||
constructor (readonly subpasses: RasterSubpass[]) {
|
||||
this._subpasses = subpasses;
|
||||
}
|
||||
get (v: number): RasterSubpass {
|
||||
return this._subpasses[v];
|
||||
}
|
||||
readonly _subpasses: RasterSubpass[];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// ComponentGraph Concept
|
||||
export const enum SubpassGraphComponent {
|
||||
Name,
|
||||
Subpass,
|
||||
}
|
||||
|
||||
export interface SubpassGraphComponentType {
|
||||
[SubpassGraphComponent.Name]: string;
|
||||
[SubpassGraphComponent.Subpass]: RasterSubpass;
|
||||
}
|
||||
|
||||
export interface SubpassGraphComponentPropertyMap {
|
||||
[SubpassGraphComponent.Name]: SubpassGraphNameMap;
|
||||
[SubpassGraphComponent.Subpass]: SubpassGraphSubpassMap;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// SubpassGraph Implementation
|
||||
export class SubpassGraph implements BidirectionalGraph
|
||||
, AdjacencyGraph
|
||||
, VertexListGraph
|
||||
, MutableGraph
|
||||
, PropertyGraph
|
||||
, NamedGraph
|
||||
, ComponentGraph {
|
||||
//-----------------------------------------------------------------
|
||||
// Graph
|
||||
// type vertex_descriptor = number;
|
||||
nullVertex (): number { return 0xFFFFFFFF; }
|
||||
// type edge_descriptor = ED;
|
||||
readonly directed_category: directional = directional.bidirectional;
|
||||
readonly edge_parallel_category: parallel = parallel.allow;
|
||||
readonly traversal_category: traversal = traversal.incidence
|
||||
| traversal.bidirectional
|
||||
| traversal.adjacency
|
||||
| traversal.vertex_list;
|
||||
//-----------------------------------------------------------------
|
||||
// IncidenceGraph
|
||||
// type out_edge_iterator = OutEI;
|
||||
// type degree_size_type = number;
|
||||
edge (u: number, v: number): boolean {
|
||||
for (const oe of this._vertices[u]._outEdges) {
|
||||
if (v === oe.target as number) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
source (e: ED): number {
|
||||
return e.source as number;
|
||||
}
|
||||
target (e: ED): number {
|
||||
return e.target as number;
|
||||
}
|
||||
outEdges (v: number): OutEI {
|
||||
return new OutEI(this._vertices[v]._outEdges.values(), v);
|
||||
}
|
||||
outDegree (v: number): number {
|
||||
return this._vertices[v]._outEdges.length;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// BidirectionalGraph
|
||||
// type in_edge_iterator = InEI;
|
||||
inEdges (v: number): InEI {
|
||||
return new InEI(this._vertices[v]._inEdges.values(), v);
|
||||
}
|
||||
inDegree (v: number): number {
|
||||
return this._vertices[v]._inEdges.length;
|
||||
}
|
||||
degree (v: number): number {
|
||||
return this.outDegree(v) + this.inDegree(v);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// AdjacencyGraph
|
||||
// type adjacency_iterator = AdjI;
|
||||
adjacentVertices (v: number): AdjI {
|
||||
return new AdjI(this, this.outEdges(v));
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// VertexListGraph
|
||||
vertices (): IterableIterator<number> {
|
||||
return this._vertices.keys();
|
||||
}
|
||||
numVertices (): number {
|
||||
return this._vertices.length;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// EdgeListGraph
|
||||
numEdges (): number {
|
||||
let numEdges = 0;
|
||||
for (const v of this.vertices()) {
|
||||
numEdges += this.outDegree(v);
|
||||
}
|
||||
return numEdges;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// MutableGraph
|
||||
clear (): void {
|
||||
// ComponentGraph
|
||||
this._names.length = 0;
|
||||
this._subpasses.length = 0;
|
||||
// Graph Vertices
|
||||
this._vertices.length = 0;
|
||||
}
|
||||
addVertex (
|
||||
name: string,
|
||||
subpass: RasterSubpass,
|
||||
): number {
|
||||
const vert = new SubpassGraphVertex();
|
||||
const v = this._vertices.length;
|
||||
this._vertices.push(vert);
|
||||
this._names.push(name);
|
||||
this._subpasses.push(subpass);
|
||||
return v;
|
||||
}
|
||||
clearVertex (v: number): void {
|
||||
const vert = this._vertices[v];
|
||||
// clear out edges
|
||||
for (const oe of vert._outEdges) {
|
||||
const target = this._vertices[oe.target as number];
|
||||
for (let i = 0; i !== target._inEdges.length;) { // remove all edges
|
||||
if (target._inEdges[i].target === v) {
|
||||
target._inEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
vert._outEdges.length = 0;
|
||||
|
||||
// clear in edges
|
||||
for (const ie of vert._inEdges) {
|
||||
const source = this._vertices[ie.target as number];
|
||||
for (let i = 0; i !== source._outEdges.length;) { // remove all edges
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
vert._inEdges.length = 0;
|
||||
}
|
||||
removeVertex (u: number): void {
|
||||
this._vertices.splice(u, 1);
|
||||
this._names.splice(u, 1);
|
||||
this._subpasses.splice(u, 1);
|
||||
|
||||
const sz = this._vertices.length;
|
||||
if (u === sz) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let v = 0; v !== sz; ++v) {
|
||||
const vert = this._vertices[v];
|
||||
reindexEdgeList(vert._outEdges, u);
|
||||
reindexEdgeList(vert._inEdges, u);
|
||||
}
|
||||
}
|
||||
addEdge (u: number, v: number): ED | null {
|
||||
// update in/out edge list
|
||||
this._vertices[u]._outEdges.push(new OutE(v));
|
||||
this._vertices[v]._inEdges.push(new OutE(u));
|
||||
return new ED(u, v);
|
||||
}
|
||||
removeEdges (u: number, v: number): void {
|
||||
const source = this._vertices[u];
|
||||
// remove out edges of u
|
||||
for (let i = 0; i !== source._outEdges.length;) { // remove all edges
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
// remove in edges of v
|
||||
const target = this._vertices[v];
|
||||
for (let i = 0; i !== target._inEdges.length;) { // remove all edges
|
||||
if (target._inEdges[i].target === u) {
|
||||
target._inEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeEdge (e: ED): void {
|
||||
const u = e.source as number;
|
||||
const v = e.target as number;
|
||||
const source = this._vertices[u];
|
||||
for (let i = 0; i !== source._outEdges.length;) {
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
break; // remove one edge
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
const target = this._vertices[v];
|
||||
for (let i = 0; i !== target._inEdges.length;) {
|
||||
if (target._inEdges[i].target === u) {
|
||||
target._inEdges.splice(i, 1);
|
||||
break; // remove one edge
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// NamedGraph
|
||||
vertexName (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
vertexNameMap (): SubpassGraphNameMap {
|
||||
return new SubpassGraphNameMap(this._names);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// PropertyGraph
|
||||
get (tag: string): SubpassGraphNameMap | SubpassGraphSubpassMap {
|
||||
switch (tag) {
|
||||
// Components
|
||||
case 'Name':
|
||||
return new SubpassGraphNameMap(this._names);
|
||||
case 'Subpass':
|
||||
return new SubpassGraphSubpassMap(this._subpasses);
|
||||
default:
|
||||
throw Error('property map not found');
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// ComponentGraph
|
||||
component<T extends SubpassGraphComponent> (id: T, v: number): SubpassGraphComponentType[T] {
|
||||
switch (id) {
|
||||
case SubpassGraphComponent.Name:
|
||||
return this._names[v] as SubpassGraphComponentType[T];
|
||||
case SubpassGraphComponent.Subpass:
|
||||
return this._subpasses[v] as SubpassGraphComponentType[T];
|
||||
default:
|
||||
throw Error('component not found');
|
||||
}
|
||||
}
|
||||
componentMap<T extends SubpassGraphComponent> (id: T): SubpassGraphComponentPropertyMap[T] {
|
||||
switch (id) {
|
||||
case SubpassGraphComponent.Name:
|
||||
return new SubpassGraphNameMap(this._names) as SubpassGraphComponentPropertyMap[T];
|
||||
case SubpassGraphComponent.Subpass:
|
||||
return new SubpassGraphSubpassMap(this._subpasses) as SubpassGraphComponentPropertyMap[T];
|
||||
default:
|
||||
throw Error('component map not found');
|
||||
}
|
||||
}
|
||||
getName (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
setName (v: number, value: string) {
|
||||
this._names[v] = value;
|
||||
}
|
||||
getSubpass (v: number): RasterSubpass {
|
||||
return this._subpasses[v];
|
||||
}
|
||||
|
||||
readonly components: string[] = ['Name', 'Subpass'];
|
||||
readonly _vertices: SubpassGraphVertex[] = [];
|
||||
readonly _names: string[] = [];
|
||||
readonly _subpasses: RasterSubpass[] = [];
|
||||
}
|
||||
|
||||
export class RasterPass {
|
||||
readonly rasterViews: Map<string, RasterView> = new Map<string, RasterView>();
|
||||
readonly computeViews: Map<string, ComputeView[]> = new Map<string, ComputeView[]>();
|
||||
readonly subpassGraph: SubpassGraph = new SubpassGraph();
|
||||
width = 0;
|
||||
height = 0;
|
||||
readonly viewport: Viewport = new Viewport();
|
||||
versionName = '';
|
||||
version = 0;
|
||||
showStatistics = false;
|
||||
}
|
||||
|
||||
export class PersistentRenderPassAndFramebuffer {
|
||||
constructor (renderPass: RenderPass, framebuffer: Framebuffer) {
|
||||
this.renderPass = renderPass;
|
||||
this.framebuffer = framebuffer;
|
||||
}
|
||||
/*refcount*/ renderPass: RenderPass;
|
||||
/*refcount*/ framebuffer: Framebuffer;
|
||||
readonly clearColors: Color[] = [];
|
||||
clearDepth = 0;
|
||||
clearStencil = 0;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// ResourceGraph
|
||||
//=================================================================
|
||||
@@ -324,6 +657,7 @@ export class ResourceGraph implements BidirectionalGraph
|
||||
// MutableGraph
|
||||
clear (): void {
|
||||
// Members
|
||||
this.renderPasses.clear();
|
||||
this.nextFenceValue = 0;
|
||||
this.version = 0;
|
||||
// UuidGraph
|
||||
@@ -705,330 +1039,11 @@ export class ResourceGraph implements BidirectionalGraph
|
||||
readonly _states: ResourceStates[] = [];
|
||||
readonly _samplerInfo: SamplerInfo[] = [];
|
||||
readonly _valueIndex: Map<string, number> = new Map<string, number>();
|
||||
readonly renderPasses: Map<string, PersistentRenderPassAndFramebuffer> = new Map<string, PersistentRenderPassAndFramebuffer>();
|
||||
nextFenceValue = 0;
|
||||
version = 0;
|
||||
}
|
||||
|
||||
export class RasterSubpass {
|
||||
readonly rasterViews: Map<string, RasterView> = new Map<string, RasterView>();
|
||||
readonly computeViews: Map<string, ComputeView[]> = new Map<string, ComputeView[]>();
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// SubpassGraph
|
||||
//=================================================================
|
||||
// Graph Concept
|
||||
export class SubpassGraphVertex {
|
||||
constructor () {
|
||||
}
|
||||
readonly _outEdges: OutE[] = [];
|
||||
readonly _inEdges: OutE[] = [];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// PropertyGraph Concept
|
||||
export class SubpassGraphNameMap implements PropertyMap {
|
||||
constructor (readonly names: string[]) {
|
||||
this._names = names;
|
||||
}
|
||||
get (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
set (v: number, names: string): void {
|
||||
this._names[v] = names;
|
||||
}
|
||||
readonly _names: string[];
|
||||
}
|
||||
|
||||
export class SubpassGraphSubpassMap implements PropertyMap {
|
||||
constructor (readonly subpasses: RasterSubpass[]) {
|
||||
this._subpasses = subpasses;
|
||||
}
|
||||
get (v: number): RasterSubpass {
|
||||
return this._subpasses[v];
|
||||
}
|
||||
readonly _subpasses: RasterSubpass[];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// ComponentGraph Concept
|
||||
export const enum SubpassGraphComponent {
|
||||
Name,
|
||||
Subpass,
|
||||
}
|
||||
|
||||
export interface SubpassGraphComponentType {
|
||||
[SubpassGraphComponent.Name]: string;
|
||||
[SubpassGraphComponent.Subpass]: RasterSubpass;
|
||||
}
|
||||
|
||||
export interface SubpassGraphComponentPropertyMap {
|
||||
[SubpassGraphComponent.Name]: SubpassGraphNameMap;
|
||||
[SubpassGraphComponent.Subpass]: SubpassGraphSubpassMap;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// SubpassGraph Implementation
|
||||
export class SubpassGraph implements BidirectionalGraph
|
||||
, AdjacencyGraph
|
||||
, VertexListGraph
|
||||
, MutableGraph
|
||||
, PropertyGraph
|
||||
, NamedGraph
|
||||
, ComponentGraph {
|
||||
//-----------------------------------------------------------------
|
||||
// Graph
|
||||
// type vertex_descriptor = number;
|
||||
nullVertex (): number { return 0xFFFFFFFF; }
|
||||
// type edge_descriptor = ED;
|
||||
readonly directed_category: directional = directional.bidirectional;
|
||||
readonly edge_parallel_category: parallel = parallel.allow;
|
||||
readonly traversal_category: traversal = traversal.incidence
|
||||
| traversal.bidirectional
|
||||
| traversal.adjacency
|
||||
| traversal.vertex_list;
|
||||
//-----------------------------------------------------------------
|
||||
// IncidenceGraph
|
||||
// type out_edge_iterator = OutEI;
|
||||
// type degree_size_type = number;
|
||||
edge (u: number, v: number): boolean {
|
||||
for (const oe of this._vertices[u]._outEdges) {
|
||||
if (v === oe.target as number) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
source (e: ED): number {
|
||||
return e.source as number;
|
||||
}
|
||||
target (e: ED): number {
|
||||
return e.target as number;
|
||||
}
|
||||
outEdges (v: number): OutEI {
|
||||
return new OutEI(this._vertices[v]._outEdges.values(), v);
|
||||
}
|
||||
outDegree (v: number): number {
|
||||
return this._vertices[v]._outEdges.length;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// BidirectionalGraph
|
||||
// type in_edge_iterator = InEI;
|
||||
inEdges (v: number): InEI {
|
||||
return new InEI(this._vertices[v]._inEdges.values(), v);
|
||||
}
|
||||
inDegree (v: number): number {
|
||||
return this._vertices[v]._inEdges.length;
|
||||
}
|
||||
degree (v: number): number {
|
||||
return this.outDegree(v) + this.inDegree(v);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// AdjacencyGraph
|
||||
// type adjacency_iterator = AdjI;
|
||||
adjacentVertices (v: number): AdjI {
|
||||
return new AdjI(this, this.outEdges(v));
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// VertexListGraph
|
||||
vertices (): IterableIterator<number> {
|
||||
return this._vertices.keys();
|
||||
}
|
||||
numVertices (): number {
|
||||
return this._vertices.length;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// EdgeListGraph
|
||||
numEdges (): number {
|
||||
let numEdges = 0;
|
||||
for (const v of this.vertices()) {
|
||||
numEdges += this.outDegree(v);
|
||||
}
|
||||
return numEdges;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// MutableGraph
|
||||
clear (): void {
|
||||
// ComponentGraph
|
||||
this._names.length = 0;
|
||||
this._subpasses.length = 0;
|
||||
// Graph Vertices
|
||||
this._vertices.length = 0;
|
||||
}
|
||||
addVertex (
|
||||
name: string,
|
||||
subpass: RasterSubpass,
|
||||
): number {
|
||||
const vert = new SubpassGraphVertex();
|
||||
const v = this._vertices.length;
|
||||
this._vertices.push(vert);
|
||||
this._names.push(name);
|
||||
this._subpasses.push(subpass);
|
||||
return v;
|
||||
}
|
||||
clearVertex (v: number): void {
|
||||
const vert = this._vertices[v];
|
||||
// clear out edges
|
||||
for (const oe of vert._outEdges) {
|
||||
const target = this._vertices[oe.target as number];
|
||||
for (let i = 0; i !== target._inEdges.length;) { // remove all edges
|
||||
if (target._inEdges[i].target === v) {
|
||||
target._inEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
vert._outEdges.length = 0;
|
||||
|
||||
// clear in edges
|
||||
for (const ie of vert._inEdges) {
|
||||
const source = this._vertices[ie.target as number];
|
||||
for (let i = 0; i !== source._outEdges.length;) { // remove all edges
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
vert._inEdges.length = 0;
|
||||
}
|
||||
removeVertex (u: number): void {
|
||||
this._vertices.splice(u, 1);
|
||||
this._names.splice(u, 1);
|
||||
this._subpasses.splice(u, 1);
|
||||
|
||||
const sz = this._vertices.length;
|
||||
if (u === sz) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let v = 0; v !== sz; ++v) {
|
||||
const vert = this._vertices[v];
|
||||
reindexEdgeList(vert._outEdges, u);
|
||||
reindexEdgeList(vert._inEdges, u);
|
||||
}
|
||||
}
|
||||
addEdge (u: number, v: number): ED | null {
|
||||
// update in/out edge list
|
||||
this._vertices[u]._outEdges.push(new OutE(v));
|
||||
this._vertices[v]._inEdges.push(new OutE(u));
|
||||
return new ED(u, v);
|
||||
}
|
||||
removeEdges (u: number, v: number): void {
|
||||
const source = this._vertices[u];
|
||||
// remove out edges of u
|
||||
for (let i = 0; i !== source._outEdges.length;) { // remove all edges
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
// remove in edges of v
|
||||
const target = this._vertices[v];
|
||||
for (let i = 0; i !== target._inEdges.length;) { // remove all edges
|
||||
if (target._inEdges[i].target === u) {
|
||||
target._inEdges.splice(i, 1);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeEdge (e: ED): void {
|
||||
const u = e.source as number;
|
||||
const v = e.target as number;
|
||||
const source = this._vertices[u];
|
||||
for (let i = 0; i !== source._outEdges.length;) {
|
||||
if (source._outEdges[i].target === v) {
|
||||
source._outEdges.splice(i, 1);
|
||||
break; // remove one edge
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
const target = this._vertices[v];
|
||||
for (let i = 0; i !== target._inEdges.length;) {
|
||||
if (target._inEdges[i].target === u) {
|
||||
target._inEdges.splice(i, 1);
|
||||
break; // remove one edge
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// NamedGraph
|
||||
vertexName (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
vertexNameMap (): SubpassGraphNameMap {
|
||||
return new SubpassGraphNameMap(this._names);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// PropertyGraph
|
||||
get (tag: string): SubpassGraphNameMap | SubpassGraphSubpassMap {
|
||||
switch (tag) {
|
||||
// Components
|
||||
case 'Name':
|
||||
return new SubpassGraphNameMap(this._names);
|
||||
case 'Subpass':
|
||||
return new SubpassGraphSubpassMap(this._subpasses);
|
||||
default:
|
||||
throw Error('property map not found');
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// ComponentGraph
|
||||
component<T extends SubpassGraphComponent> (id: T, v: number): SubpassGraphComponentType[T] {
|
||||
switch (id) {
|
||||
case SubpassGraphComponent.Name:
|
||||
return this._names[v] as SubpassGraphComponentType[T];
|
||||
case SubpassGraphComponent.Subpass:
|
||||
return this._subpasses[v] as SubpassGraphComponentType[T];
|
||||
default:
|
||||
throw Error('component not found');
|
||||
}
|
||||
}
|
||||
componentMap<T extends SubpassGraphComponent> (id: T): SubpassGraphComponentPropertyMap[T] {
|
||||
switch (id) {
|
||||
case SubpassGraphComponent.Name:
|
||||
return new SubpassGraphNameMap(this._names) as SubpassGraphComponentPropertyMap[T];
|
||||
case SubpassGraphComponent.Subpass:
|
||||
return new SubpassGraphSubpassMap(this._subpasses) as SubpassGraphComponentPropertyMap[T];
|
||||
default:
|
||||
throw Error('component map not found');
|
||||
}
|
||||
}
|
||||
getName (v: number): string {
|
||||
return this._names[v];
|
||||
}
|
||||
setName (v: number, value: string) {
|
||||
this._names[v] = value;
|
||||
}
|
||||
getSubpass (v: number): RasterSubpass {
|
||||
return this._subpasses[v];
|
||||
}
|
||||
|
||||
readonly components: string[] = ['Name', 'Subpass'];
|
||||
readonly _vertices: SubpassGraphVertex[] = [];
|
||||
readonly _names: string[] = [];
|
||||
readonly _subpasses: RasterSubpass[] = [];
|
||||
}
|
||||
|
||||
export class RasterPass {
|
||||
readonly rasterViews: Map<string, RasterView> = new Map<string, RasterView>();
|
||||
readonly computeViews: Map<string, ComputeView[]> = new Map<string, ComputeView[]>();
|
||||
readonly subpassGraph: SubpassGraph = new SubpassGraph();
|
||||
width = 0;
|
||||
height = 0;
|
||||
readonly viewport: Viewport = new Viewport();
|
||||
versionName = '';
|
||||
version = 0;
|
||||
showStatistics = false;
|
||||
}
|
||||
|
||||
export class ComputePass {
|
||||
readonly computeViews: Map<string, ComputeView[]> = new Map<string, ComputeView[]>();
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ export function LinearToSRGB (out: IVec4Like, linear: IVec4Like) {
|
||||
|
||||
let profilerCamera: Camera | null = null;
|
||||
|
||||
export function getProfilerCamera (): Camera | null {
|
||||
return profilerCamera;
|
||||
}
|
||||
|
||||
export function decideProfilerCamera (cameras: Camera[]) {
|
||||
for (let i = cameras.length - 1; i >= 0; --i) {
|
||||
const camera = cameras[i];
|
||||
|
||||
@@ -272,7 +272,6 @@ PersistentRenderPassAndFramebuffer createPersistentRenderPassAndFramebuffer(
|
||||
data.renderPass = ctx.device->createRenderPass(rpInfo);
|
||||
fbInfo.renderPass = data.renderPass;
|
||||
data.framebuffer = ctx.device->createFramebuffer(fbInfo);
|
||||
data.hash = gfx::Framebuffer::computeHash(fbInfo);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -280,23 +279,12 @@ PersistentRenderPassAndFramebuffer createPersistentRenderPassAndFramebuffer(
|
||||
PersistentRenderPassAndFramebuffer& fetchOrCreateFramebuffer(
|
||||
RenderGraphVisitorContext& ctx, const RasterPass& pass,
|
||||
boost::container::pmr::memory_resource* scratch) {
|
||||
auto iter = ctx.context.renderPasses.find(pass);
|
||||
if (iter == ctx.context.renderPasses.end()) {
|
||||
auto iter = ctx.resourceGraph.renderPasses.find(pass);
|
||||
if (iter == ctx.resourceGraph.renderPasses.end()) {
|
||||
bool added = false;
|
||||
std::tie(iter, added) = ctx.context.renderPasses.emplace(
|
||||
std::tie(iter, added) = ctx.resourceGraph.renderPasses.emplace(
|
||||
pass, createPersistentRenderPassAndFramebuffer(ctx, pass, scratch));
|
||||
CC_ENSURES(added);
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
gfx::FramebufferInfo fbInfo{};
|
||||
fbInfo.renderPass = iter->second.renderPass;
|
||||
fbInfo.colorTextures = iter->second.framebuffer->getColorTextures();
|
||||
fbInfo.depthStencilTexture = iter->second.framebuffer->getDepthStencilTexture();
|
||||
auto hash = gfx::Framebuffer::computeHash(fbInfo);
|
||||
if (iter->second.hash != hash) {
|
||||
iter->second.framebuffer = ctx.device->createFramebuffer(fbInfo);
|
||||
iter->second.hash = hash;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
@@ -966,7 +954,6 @@ struct RenderGraphVisitor : boost::dfs_visitor<> {
|
||||
const auto& layoutID = locate(LayoutGraphData::null_vertex(), layoutName, ctx.lg);
|
||||
{
|
||||
auto& res = fetchOrCreateFramebuffer(ctx, pass, ctx.scratch);
|
||||
++res.refCount;
|
||||
const auto& data = res;
|
||||
auto* cmdBuff = ctx.cmdBuff;
|
||||
|
||||
@@ -1393,15 +1380,7 @@ struct RenderGraphContextCleaner {
|
||||
}
|
||||
RenderGraphContextCleaner(const RenderGraphContextCleaner&) = delete;
|
||||
RenderGraphContextCleaner& operator=(const RenderGraphContextCleaner&) = delete;
|
||||
~RenderGraphContextCleaner() noexcept {
|
||||
for (auto iter = context.renderPasses.begin(); iter != context.renderPasses.end();) {
|
||||
if (--iter->second.refCount == 0) {
|
||||
iter = context.renderPasses.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
~RenderGraphContextCleaner() noexcept = default;
|
||||
NativeRenderContext& context;
|
||||
uint64_t prevFenceValue = 0;
|
||||
};
|
||||
@@ -1709,6 +1688,8 @@ void NativePipeline::executeRenderGraph(const RenderGraph& rg) {
|
||||
auto& ppl = *this;
|
||||
auto* scratch = &ppl.unsyncPool;
|
||||
|
||||
ppl.resourceGraph.validateSwapchains();
|
||||
|
||||
RenderGraphContextCleaner contextCleaner(ppl.nativeContext);
|
||||
ResourceCleaner cleaner(ppl.resourceGraph);
|
||||
|
||||
|
||||
@@ -217,6 +217,12 @@ void NativePipeline::updateRenderWindow(const ccstd::string &name, scene::Render
|
||||
},
|
||||
[&](RenderSwapchain &sc) {
|
||||
CC_EXPECTS(renderWindow->getSwapchain());
|
||||
auto* newSwapchain = renderWindow->getSwapchain();
|
||||
if (sc.generation != newSwapchain->getGeneration()) {
|
||||
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(
|
||||
sc.swapchain->getColorTexture());
|
||||
sc.generation = newSwapchain->getGeneration();
|
||||
}
|
||||
desc.width = renderWindow->getSwapchain()->getWidth();
|
||||
desc.height = renderWindow->getSwapchain()->getHeight();
|
||||
sc.swapchain = renderWindow->getSwapchain();
|
||||
@@ -232,13 +238,22 @@ void NativePipeline::updateRenderTarget(
|
||||
return;
|
||||
}
|
||||
auto &desc = get(ResourceGraph::Desc, resourceGraph, resID);
|
||||
|
||||
// update format
|
||||
if (format == gfx::Format::UNKNOWN) {
|
||||
format = desc.format;
|
||||
}
|
||||
visitObject(
|
||||
resID, resourceGraph,
|
||||
[&](ManagedTexture & /*tex*/) {
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
if (format != gfx::Format::UNKNOWN) {
|
||||
[&](ManagedTexture &tex) {
|
||||
bool invalidate =
|
||||
std::forward_as_tuple(desc.width, desc.height, desc.format) !=
|
||||
std::forward_as_tuple(width, height, format);
|
||||
if (invalidate) {
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
desc.format = format;
|
||||
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(tex.texture.get());
|
||||
}
|
||||
},
|
||||
[](const auto & /*res*/) {});
|
||||
|
||||
@@ -45,7 +45,6 @@ class NativeComputePassBuilder;
|
||||
class NativeMovePassBuilder;
|
||||
class NativeCopyPassBuilder;
|
||||
class NativeSceneTransversal;
|
||||
struct PersistentRenderPassAndFramebuffer;
|
||||
struct RenderInstancingQueue;
|
||||
struct DrawInstance;
|
||||
struct RenderDrawQueue;
|
||||
|
||||
@@ -34,27 +34,6 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept
|
||||
: clearColors(alloc) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc)
|
||||
: renderPass(std::move(rhs.renderPass)),
|
||||
framebuffer(std::move(rhs.framebuffer)),
|
||||
clearColors(std::move(rhs.clearColors), alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil),
|
||||
refCount(rhs.refCount),
|
||||
hash(rhs.hash) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc)
|
||||
: renderPass(rhs.renderPass),
|
||||
framebuffer(rhs.framebuffer),
|
||||
clearColors(rhs.clearColors, alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil),
|
||||
refCount(rhs.refCount),
|
||||
hash(rhs.hash) {}
|
||||
|
||||
RenderInstancingQueue::RenderInstancingQueue(const allocator_type& alloc) noexcept
|
||||
: batches(alloc),
|
||||
sortedBatches(alloc) {}
|
||||
@@ -175,7 +154,6 @@ LayoutGraphNodeResource::LayoutGraphNodeResource(LayoutGraphNodeResource&& rhs,
|
||||
|
||||
NativeRenderContext::NativeRenderContext(std::unique_ptr<gfx::DefaultResource> defaultResourceIn, const allocator_type& alloc) noexcept
|
||||
: defaultResource(std::move(defaultResourceIn)),
|
||||
renderPasses(alloc),
|
||||
resourceGroups(alloc),
|
||||
layoutGraphResources(alloc) {}
|
||||
|
||||
|
||||
@@ -231,30 +231,6 @@ public:
|
||||
const scene::RenderScene* scene{nullptr};
|
||||
};
|
||||
|
||||
struct PersistentRenderPassAndFramebuffer {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {clearColors.get_allocator().resource()};
|
||||
}
|
||||
|
||||
PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept; // NOLINT
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc);
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc);
|
||||
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs) noexcept = default;
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs) = delete;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer&& rhs) = default;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer const& rhs) = default;
|
||||
|
||||
IntrusivePtr<gfx::RenderPass> renderPass;
|
||||
IntrusivePtr<gfx::Framebuffer> framebuffer;
|
||||
ccstd::pmr::vector<gfx::Color> clearColors;
|
||||
float clearDepth{0};
|
||||
uint8_t clearStencil{0};
|
||||
int32_t refCount{1};
|
||||
uint32_t hash{0};
|
||||
};
|
||||
|
||||
struct RenderInstancingQueue {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
@@ -519,7 +495,7 @@ struct QuadResource {
|
||||
struct NativeRenderContext {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {renderPasses.get_allocator().resource()};
|
||||
return {resourceGroups.get_allocator().resource()};
|
||||
}
|
||||
|
||||
NativeRenderContext(std::unique_ptr<gfx::DefaultResource> defaultResourceIn, const allocator_type& alloc) noexcept;
|
||||
@@ -531,7 +507,6 @@ struct NativeRenderContext {
|
||||
void clearPreviousResources(uint64_t finishedFenceValue) noexcept;
|
||||
|
||||
std::unique_ptr<gfx::DefaultResource> defaultResource;
|
||||
ccstd::pmr::unordered_map<RasterPass, PersistentRenderPassAndFramebuffer> renderPasses;
|
||||
ccstd::pmr::map<uint64_t, ResourceGroup> resourceGroups;
|
||||
ccstd::pmr::vector<LayoutGraphNodeResource> layoutGraphResources;
|
||||
QuadResource fullscreenQuad;
|
||||
|
||||
@@ -166,6 +166,19 @@ bool ManagedTexture::checkResource(const ResourceDesc& desc) const {
|
||||
return desc.width == info.width && desc.height == info.height && desc.format == info.format;
|
||||
}
|
||||
|
||||
void ResourceGraph::validateSwapchains() {
|
||||
bool swapchainInvalidated = false;
|
||||
for (auto& sc : swapchains) {
|
||||
if (sc.generation != sc.swapchain->getGeneration()) {
|
||||
swapchainInvalidated = true;
|
||||
sc.generation = sc.swapchain->getGeneration();
|
||||
}
|
||||
}
|
||||
if (swapchainInvalidated) {
|
||||
renderPasses.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceGraph::mount(gfx::Device* device, vertex_descriptor vertID) {
|
||||
std::ignore = device;
|
||||
auto& resg = *this;
|
||||
@@ -212,37 +225,20 @@ void ResourceGraph::mount(gfx::Device* device, vertex_descriptor vertID) {
|
||||
void ResourceGraph::unmount(uint64_t completedFenceValue) {
|
||||
auto& resg = *this;
|
||||
for (const auto& vertID : makeRange(vertices(resg))) {
|
||||
visitObject(
|
||||
vertID, resg,
|
||||
[&](const ManagedResource& resource) {
|
||||
// to be removed
|
||||
},
|
||||
[&](ManagedBuffer& buffer) {
|
||||
if (buffer.fenceValue <= completedFenceValue) {
|
||||
buffer.buffer.reset();
|
||||
}
|
||||
},
|
||||
[&](ManagedTexture& texture) {
|
||||
if (texture.fenceValue <= completedFenceValue) {
|
||||
texture.texture.reset();
|
||||
}
|
||||
},
|
||||
[&](const IntrusivePtr<gfx::Buffer>& buffer) {
|
||||
CC_EXPECTS(buffer);
|
||||
std::ignore = buffer;
|
||||
},
|
||||
[&](const IntrusivePtr<gfx::Texture>& texture) {
|
||||
CC_EXPECTS(texture);
|
||||
std::ignore = texture;
|
||||
},
|
||||
[&](const IntrusivePtr<gfx::Framebuffer>& fb) {
|
||||
CC_EXPECTS(fb);
|
||||
std::ignore = fb;
|
||||
},
|
||||
[&](const RenderSwapchain& queue) {
|
||||
CC_EXPECTS(queue.swapchain);
|
||||
std::ignore = queue;
|
||||
});
|
||||
// here msvc has strange behaviour when using visitObject
|
||||
// we use if-else instead.
|
||||
if (holds<ManagedBufferTag>(vertID, resg)) {
|
||||
auto& buffer = get(ManagedBufferTag{}, vertID, resg);
|
||||
if (buffer.buffer && buffer.fenceValue <= completedFenceValue) {
|
||||
buffer.buffer.reset();
|
||||
}
|
||||
} else if (holds<ManagedTextureTag>(vertID, resg)) {
|
||||
auto& texture = get(ManagedTextureTag{}, vertID, resg);
|
||||
if (texture.texture && texture.fenceValue <= completedFenceValue) {
|
||||
invalidatePersistentRenderPassAndFramebuffer(texture.texture.get());
|
||||
texture.texture.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +268,30 @@ gfx::Texture* ResourceGraph::getTexture(vertex_descriptor resID) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
void ResourceGraph::invalidatePersistentRenderPassAndFramebuffer(gfx::Texture* pTexture) {
|
||||
if (!pTexture) {
|
||||
return;
|
||||
}
|
||||
for (auto iter = renderPasses.begin(); iter != renderPasses.end();) {
|
||||
const auto& pass = iter->second;
|
||||
bool bErase = false;
|
||||
for (const auto& color : pass.framebuffer->getColorTextures()) {
|
||||
if (color == pTexture) {
|
||||
bErase = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pass.framebuffer->getDepthStencilTexture() == pTexture) {
|
||||
bErase = true;
|
||||
}
|
||||
if (bErase) {
|
||||
iter = renderPasses.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
|
||||
@@ -45,6 +45,10 @@ struct ResourceStates;
|
||||
struct ManagedBuffer;
|
||||
struct ManagedTexture;
|
||||
struct ManagedResource;
|
||||
struct RasterSubpass;
|
||||
struct SubpassGraph;
|
||||
struct RasterPass;
|
||||
struct PersistentRenderPassAndFramebuffer;
|
||||
struct ManagedTag;
|
||||
struct ManagedBufferTag;
|
||||
struct ManagedTextureTag;
|
||||
@@ -54,9 +58,6 @@ struct FramebufferTag;
|
||||
struct SwapchainTag;
|
||||
struct SamplerTag;
|
||||
struct ResourceGraph;
|
||||
struct RasterSubpass;
|
||||
struct SubpassGraph;
|
||||
struct RasterPass;
|
||||
struct ComputePass;
|
||||
struct CopyPass;
|
||||
struct MovePass;
|
||||
|
||||
@@ -40,6 +40,212 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
// IncidenceGraph
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
source(const SubpassGraph::edge_descriptor& e, const SubpassGraph& /*g*/) noexcept {
|
||||
return e.source;
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
target(const SubpassGraph::edge_descriptor& e, const SubpassGraph& /*g*/) noexcept {
|
||||
return e.target;
|
||||
}
|
||||
|
||||
inline std::pair<SubpassGraph::out_edge_iterator, SubpassGraph::out_edge_iterator>
|
||||
out_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return std::make_pair(
|
||||
SubpassGraph::out_edge_iterator(const_cast<SubpassGraph&>(g).getOutEdgeList(u).begin(), u),
|
||||
SubpassGraph::out_edge_iterator(const_cast<SubpassGraph&>(g).getOutEdgeList(u).end(), u));
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
out_degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::degree_size_type>(g.getOutEdgeList(u).size());
|
||||
}
|
||||
|
||||
inline std::pair<SubpassGraph::edge_descriptor, bool>
|
||||
edge(SubpassGraph::vertex_descriptor u, SubpassGraph::vertex_descriptor v, const SubpassGraph& g) noexcept {
|
||||
const auto& outEdgeList = g.getOutEdgeList(u);
|
||||
auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), SubpassGraph::OutEdge(v));
|
||||
bool hasEdge = (iter != outEdgeList.end());
|
||||
return {SubpassGraph::edge_descriptor(u, v), hasEdge};
|
||||
}
|
||||
|
||||
// BidirectionalGraph(Directed)
|
||||
inline std::pair<SubpassGraph::in_edge_iterator, SubpassGraph::in_edge_iterator>
|
||||
in_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return std::make_pair(
|
||||
SubpassGraph::in_edge_iterator(const_cast<SubpassGraph&>(g).getInEdgeList(u).begin(), u),
|
||||
SubpassGraph::in_edge_iterator(const_cast<SubpassGraph&>(g).getInEdgeList(u).end(), u));
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
in_degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::degree_size_type>(g.getInEdgeList(u).size());
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept {
|
||||
return in_degree(u, g) + out_degree(u, g);
|
||||
}
|
||||
|
||||
// AdjacencyGraph
|
||||
inline std::pair<SubpassGraph::adjacency_iterator, SubpassGraph::adjacency_iterator>
|
||||
adjacent_vertices(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
auto edges = out_edges(u, g);
|
||||
return std::make_pair(SubpassGraph::adjacency_iterator(edges.first, &g), SubpassGraph::adjacency_iterator(edges.second, &g));
|
||||
}
|
||||
|
||||
// VertexListGraph
|
||||
inline std::pair<SubpassGraph::vertex_iterator, SubpassGraph::vertex_iterator>
|
||||
vertices(const SubpassGraph& g) noexcept {
|
||||
return std::make_pair(const_cast<SubpassGraph&>(g).getVertexList().begin(), const_cast<SubpassGraph&>(g).getVertexList().end());
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertices_size_type
|
||||
num_vertices(const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::vertices_size_type>(g.getVertexList().size());
|
||||
}
|
||||
|
||||
// EdgeListGraph
|
||||
inline std::pair<SubpassGraph::edge_iterator, SubpassGraph::edge_iterator>
|
||||
edges(const SubpassGraph& g0) noexcept {
|
||||
auto& g = const_cast<SubpassGraph&>(g0);
|
||||
return std::make_pair(
|
||||
SubpassGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g),
|
||||
SubpassGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g));
|
||||
}
|
||||
|
||||
inline SubpassGraph::edges_size_type
|
||||
num_edges(const SubpassGraph& g) noexcept { // NOLINT
|
||||
SubpassGraph::edges_size_type numEdges = 0;
|
||||
|
||||
auto range = vertices(g);
|
||||
for (auto iter = range.first; iter != range.second; ++iter) {
|
||||
numEdges += out_degree(*iter, g);
|
||||
}
|
||||
return numEdges;
|
||||
}
|
||||
|
||||
// MutableGraph(Edge)
|
||||
inline std::pair<SubpassGraph::edge_descriptor, bool>
|
||||
add_edge( // NOLINT
|
||||
SubpassGraph::vertex_descriptor u,
|
||||
SubpassGraph::vertex_descriptor v, SubpassGraph& g) {
|
||||
auto& outEdgeList = g.getOutEdgeList(u);
|
||||
outEdgeList.emplace_back(v);
|
||||
|
||||
auto& inEdgeList = g.getInEdgeList(v);
|
||||
inEdgeList.emplace_back(u);
|
||||
|
||||
return std::make_pair(SubpassGraph::edge_descriptor(u, v), true);
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::vertex_descriptor u, SubpassGraph::vertex_descriptor v, SubpassGraph& g) noexcept { // NOLINT
|
||||
auto& s = g._vertices[u];
|
||||
auto& t = g._vertices[v];
|
||||
s.outEdges.erase(std::remove(s.outEdges.begin(), s.outEdges.end(), SubpassGraph::OutEdge(v)), s.outEdges.end());
|
||||
t.inEdges.erase(std::remove(t.inEdges.begin(), t.inEdges.end(), SubpassGraph::InEdge(u)), t.inEdges.end());
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::out_edge_iterator outIter, SubpassGraph& g) noexcept { // NOLINT
|
||||
auto e = *outIter;
|
||||
const auto u = source(e, g);
|
||||
const auto v = target(e, g);
|
||||
auto& s = g._vertices[u];
|
||||
auto& t = g._vertices[v];
|
||||
auto inIter = std::find(t.inEdges.begin(), t.inEdges.end(), SubpassGraph::InEdge(u));
|
||||
CC_EXPECTS(inIter != t.inEdges.end());
|
||||
t.inEdges.erase(inIter);
|
||||
s.outEdges.erase(outIter.base());
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::edge_descriptor e, SubpassGraph& g) noexcept { // NOLINT
|
||||
const auto u = source(e, g);
|
||||
const auto v = target(e, g);
|
||||
auto& s = g._vertices[u];
|
||||
auto outIter = std::find(s.outEdges.begin(), s.outEdges.end(), SubpassGraph::OutEdge(v));
|
||||
CC_EXPECTS(outIter != s.outEdges.end());
|
||||
remove_edge(SubpassGraph::out_edge_iterator(outIter, u), g);
|
||||
}
|
||||
|
||||
// MutableGraph(Vertex)
|
||||
inline void clear_out_edges(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
// Bidirectional (OutEdges)
|
||||
auto& outEdgeList = g.getOutEdgeList(u);
|
||||
auto outEnd = outEdgeList.end();
|
||||
for (auto iter = outEdgeList.begin(); iter != outEnd; ++iter) {
|
||||
auto& inEdgeList = g.getInEdgeList((*iter).get_target());
|
||||
// eraseFromIncidenceList
|
||||
impl::sequenceEraseIf(inEdgeList, [u](const auto& e) {
|
||||
return e.get_target() == u;
|
||||
});
|
||||
}
|
||||
outEdgeList.clear();
|
||||
}
|
||||
|
||||
inline void clear_in_edges(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
// Bidirectional (InEdges)
|
||||
auto& inEdgeList = g.getInEdgeList(u);
|
||||
auto inEnd = inEdgeList.end();
|
||||
for (auto iter = inEdgeList.begin(); iter != inEnd; ++iter) {
|
||||
auto& outEdgeList = g.getOutEdgeList((*iter).get_target());
|
||||
// eraseFromIncidenceList
|
||||
impl::sequenceEraseIf(outEdgeList, [u](const auto& e) {
|
||||
return e.get_target() == u;
|
||||
});
|
||||
}
|
||||
inEdgeList.clear();
|
||||
}
|
||||
|
||||
inline void clear_vertex(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
clear_out_edges(u, g);
|
||||
clear_in_edges(u, g);
|
||||
}
|
||||
|
||||
inline void remove_vertex(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
impl::removeVectorVertex(const_cast<SubpassGraph&>(g), u, SubpassGraph::directed_category{});
|
||||
|
||||
// remove components
|
||||
g.names.erase(g.names.begin() + static_cast<std::ptrdiff_t>(u));
|
||||
g.subpasses.erase(g.subpasses.begin() + static_cast<std::ptrdiff_t>(u));
|
||||
}
|
||||
|
||||
// MutablePropertyGraph(Vertex)
|
||||
template <class Component0, class Component1>
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
addVertex(Component0&& c0, Component1&& c1, SubpassGraph& g) {
|
||||
auto v = gsl::narrow_cast<SubpassGraph::vertex_descriptor>(g._vertices.size());
|
||||
|
||||
g._vertices.emplace_back();
|
||||
g.names.emplace_back(std::forward<Component0>(c0));
|
||||
g.subpasses.emplace_back(std::forward<Component1>(c1));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class Component0, class Component1>
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
addVertex(std::piecewise_construct_t /*tag*/, Component0&& c0, Component1&& c1, SubpassGraph& g) {
|
||||
auto v = gsl::narrow_cast<SubpassGraph::vertex_descriptor>(g._vertices.size());
|
||||
|
||||
g._vertices.emplace_back();
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... args) {
|
||||
g.names.emplace_back(std::forward<decltype(args)>(args)...);
|
||||
},
|
||||
std::forward<Component0>(c0));
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... args) {
|
||||
g.subpasses.emplace_back(std::forward<decltype(args)>(args)...);
|
||||
},
|
||||
std::forward<Component1>(c1));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
// IncidenceGraph
|
||||
inline ResourceGraph::vertex_descriptor
|
||||
source(const ResourceGraph::edge_descriptor& e, const ResourceGraph& /*g*/) noexcept {
|
||||
@@ -505,212 +711,6 @@ addVertex(Tag tag, Component0&& c0, Component1&& c1, Component2&& c2, Component3
|
||||
return v;
|
||||
}
|
||||
|
||||
// IncidenceGraph
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
source(const SubpassGraph::edge_descriptor& e, const SubpassGraph& /*g*/) noexcept {
|
||||
return e.source;
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
target(const SubpassGraph::edge_descriptor& e, const SubpassGraph& /*g*/) noexcept {
|
||||
return e.target;
|
||||
}
|
||||
|
||||
inline std::pair<SubpassGraph::out_edge_iterator, SubpassGraph::out_edge_iterator>
|
||||
out_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return std::make_pair(
|
||||
SubpassGraph::out_edge_iterator(const_cast<SubpassGraph&>(g).getOutEdgeList(u).begin(), u),
|
||||
SubpassGraph::out_edge_iterator(const_cast<SubpassGraph&>(g).getOutEdgeList(u).end(), u));
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
out_degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::degree_size_type>(g.getOutEdgeList(u).size());
|
||||
}
|
||||
|
||||
inline std::pair<SubpassGraph::edge_descriptor, bool>
|
||||
edge(SubpassGraph::vertex_descriptor u, SubpassGraph::vertex_descriptor v, const SubpassGraph& g) noexcept {
|
||||
const auto& outEdgeList = g.getOutEdgeList(u);
|
||||
auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), SubpassGraph::OutEdge(v));
|
||||
bool hasEdge = (iter != outEdgeList.end());
|
||||
return {SubpassGraph::edge_descriptor(u, v), hasEdge};
|
||||
}
|
||||
|
||||
// BidirectionalGraph(Directed)
|
||||
inline std::pair<SubpassGraph::in_edge_iterator, SubpassGraph::in_edge_iterator>
|
||||
in_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return std::make_pair(
|
||||
SubpassGraph::in_edge_iterator(const_cast<SubpassGraph&>(g).getInEdgeList(u).begin(), u),
|
||||
SubpassGraph::in_edge_iterator(const_cast<SubpassGraph&>(g).getInEdgeList(u).end(), u));
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
in_degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::degree_size_type>(g.getInEdgeList(u).size());
|
||||
}
|
||||
|
||||
inline SubpassGraph::degree_size_type
|
||||
degree(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept {
|
||||
return in_degree(u, g) + out_degree(u, g);
|
||||
}
|
||||
|
||||
// AdjacencyGraph
|
||||
inline std::pair<SubpassGraph::adjacency_iterator, SubpassGraph::adjacency_iterator>
|
||||
adjacent_vertices(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT
|
||||
auto edges = out_edges(u, g);
|
||||
return std::make_pair(SubpassGraph::adjacency_iterator(edges.first, &g), SubpassGraph::adjacency_iterator(edges.second, &g));
|
||||
}
|
||||
|
||||
// VertexListGraph
|
||||
inline std::pair<SubpassGraph::vertex_iterator, SubpassGraph::vertex_iterator>
|
||||
vertices(const SubpassGraph& g) noexcept {
|
||||
return std::make_pair(const_cast<SubpassGraph&>(g).getVertexList().begin(), const_cast<SubpassGraph&>(g).getVertexList().end());
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertices_size_type
|
||||
num_vertices(const SubpassGraph& g) noexcept { // NOLINT
|
||||
return gsl::narrow_cast<SubpassGraph::vertices_size_type>(g.getVertexList().size());
|
||||
}
|
||||
|
||||
// EdgeListGraph
|
||||
inline std::pair<SubpassGraph::edge_iterator, SubpassGraph::edge_iterator>
|
||||
edges(const SubpassGraph& g0) noexcept {
|
||||
auto& g = const_cast<SubpassGraph&>(g0);
|
||||
return std::make_pair(
|
||||
SubpassGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g),
|
||||
SubpassGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g));
|
||||
}
|
||||
|
||||
inline SubpassGraph::edges_size_type
|
||||
num_edges(const SubpassGraph& g) noexcept { // NOLINT
|
||||
SubpassGraph::edges_size_type numEdges = 0;
|
||||
|
||||
auto range = vertices(g);
|
||||
for (auto iter = range.first; iter != range.second; ++iter) {
|
||||
numEdges += out_degree(*iter, g);
|
||||
}
|
||||
return numEdges;
|
||||
}
|
||||
|
||||
// MutableGraph(Edge)
|
||||
inline std::pair<SubpassGraph::edge_descriptor, bool>
|
||||
add_edge( // NOLINT
|
||||
SubpassGraph::vertex_descriptor u,
|
||||
SubpassGraph::vertex_descriptor v, SubpassGraph& g) {
|
||||
auto& outEdgeList = g.getOutEdgeList(u);
|
||||
outEdgeList.emplace_back(v);
|
||||
|
||||
auto& inEdgeList = g.getInEdgeList(v);
|
||||
inEdgeList.emplace_back(u);
|
||||
|
||||
return std::make_pair(SubpassGraph::edge_descriptor(u, v), true);
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::vertex_descriptor u, SubpassGraph::vertex_descriptor v, SubpassGraph& g) noexcept { // NOLINT
|
||||
auto& s = g._vertices[u];
|
||||
auto& t = g._vertices[v];
|
||||
s.outEdges.erase(std::remove(s.outEdges.begin(), s.outEdges.end(), SubpassGraph::OutEdge(v)), s.outEdges.end());
|
||||
t.inEdges.erase(std::remove(t.inEdges.begin(), t.inEdges.end(), SubpassGraph::InEdge(u)), t.inEdges.end());
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::out_edge_iterator outIter, SubpassGraph& g) noexcept { // NOLINT
|
||||
auto e = *outIter;
|
||||
const auto u = source(e, g);
|
||||
const auto v = target(e, g);
|
||||
auto& s = g._vertices[u];
|
||||
auto& t = g._vertices[v];
|
||||
auto inIter = std::find(t.inEdges.begin(), t.inEdges.end(), SubpassGraph::InEdge(u));
|
||||
CC_EXPECTS(inIter != t.inEdges.end());
|
||||
t.inEdges.erase(inIter);
|
||||
s.outEdges.erase(outIter.base());
|
||||
}
|
||||
|
||||
inline void remove_edge(SubpassGraph::edge_descriptor e, SubpassGraph& g) noexcept { // NOLINT
|
||||
const auto u = source(e, g);
|
||||
const auto v = target(e, g);
|
||||
auto& s = g._vertices[u];
|
||||
auto outIter = std::find(s.outEdges.begin(), s.outEdges.end(), SubpassGraph::OutEdge(v));
|
||||
CC_EXPECTS(outIter != s.outEdges.end());
|
||||
remove_edge(SubpassGraph::out_edge_iterator(outIter, u), g);
|
||||
}
|
||||
|
||||
// MutableGraph(Vertex)
|
||||
inline void clear_out_edges(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
// Bidirectional (OutEdges)
|
||||
auto& outEdgeList = g.getOutEdgeList(u);
|
||||
auto outEnd = outEdgeList.end();
|
||||
for (auto iter = outEdgeList.begin(); iter != outEnd; ++iter) {
|
||||
auto& inEdgeList = g.getInEdgeList((*iter).get_target());
|
||||
// eraseFromIncidenceList
|
||||
impl::sequenceEraseIf(inEdgeList, [u](const auto& e) {
|
||||
return e.get_target() == u;
|
||||
});
|
||||
}
|
||||
outEdgeList.clear();
|
||||
}
|
||||
|
||||
inline void clear_in_edges(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
// Bidirectional (InEdges)
|
||||
auto& inEdgeList = g.getInEdgeList(u);
|
||||
auto inEnd = inEdgeList.end();
|
||||
for (auto iter = inEdgeList.begin(); iter != inEnd; ++iter) {
|
||||
auto& outEdgeList = g.getOutEdgeList((*iter).get_target());
|
||||
// eraseFromIncidenceList
|
||||
impl::sequenceEraseIf(outEdgeList, [u](const auto& e) {
|
||||
return e.get_target() == u;
|
||||
});
|
||||
}
|
||||
inEdgeList.clear();
|
||||
}
|
||||
|
||||
inline void clear_vertex(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
clear_out_edges(u, g);
|
||||
clear_in_edges(u, g);
|
||||
}
|
||||
|
||||
inline void remove_vertex(SubpassGraph::vertex_descriptor u, SubpassGraph& g) noexcept { // NOLINT
|
||||
impl::removeVectorVertex(const_cast<SubpassGraph&>(g), u, SubpassGraph::directed_category{});
|
||||
|
||||
// remove components
|
||||
g.names.erase(g.names.begin() + static_cast<std::ptrdiff_t>(u));
|
||||
g.subpasses.erase(g.subpasses.begin() + static_cast<std::ptrdiff_t>(u));
|
||||
}
|
||||
|
||||
// MutablePropertyGraph(Vertex)
|
||||
template <class Component0, class Component1>
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
addVertex(Component0&& c0, Component1&& c1, SubpassGraph& g) {
|
||||
auto v = gsl::narrow_cast<SubpassGraph::vertex_descriptor>(g._vertices.size());
|
||||
|
||||
g._vertices.emplace_back();
|
||||
g.names.emplace_back(std::forward<Component0>(c0));
|
||||
g.subpasses.emplace_back(std::forward<Component1>(c1));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class Component0, class Component1>
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
addVertex(std::piecewise_construct_t /*tag*/, Component0&& c0, Component1&& c1, SubpassGraph& g) {
|
||||
auto v = gsl::narrow_cast<SubpassGraph::vertex_descriptor>(g._vertices.size());
|
||||
|
||||
g._vertices.emplace_back();
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... args) {
|
||||
g.names.emplace_back(std::forward<decltype(args)>(args)...);
|
||||
},
|
||||
std::forward<Component0>(c0));
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... args) {
|
||||
g.subpasses.emplace_back(std::forward<decltype(args)>(args)...);
|
||||
},
|
||||
std::forward<Component1>(c1));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
// IncidenceGraph
|
||||
inline RenderGraph::vertex_descriptor
|
||||
source(const RenderGraph::edge_descriptor& e, const RenderGraph& /*g*/) noexcept {
|
||||
@@ -932,6 +932,83 @@ numReferences(const RenderGraph& g) noexcept {
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Vertex Index
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, vertex_index_t> {
|
||||
using const_type = identity_property_map;
|
||||
using type = identity_property_map;
|
||||
};
|
||||
|
||||
// Vertex Component
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, cc::render::SubpassGraph::NameTag> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
const ccstd::pmr::string&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
ccstd::pmr::string&>;
|
||||
};
|
||||
|
||||
// Vertex Name
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, vertex_name_t> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
const ccstd::pmr::string&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
ccstd::pmr::string&>;
|
||||
};
|
||||
|
||||
// Vertex Component
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, cc::render::SubpassGraph::SubpassTag> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
cc::render::RasterSubpass,
|
||||
const cc::render::RasterSubpass&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
cc::render::RasterSubpass,
|
||||
cc::render::RasterSubpass&>;
|
||||
};
|
||||
|
||||
// Vertex ComponentMember
|
||||
template <class T>
|
||||
struct property_map<cc::render::SubpassGraph, T cc::render::RasterSubpass::*> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
T,
|
||||
const T&,
|
||||
T cc::render::RasterSubpass::*>;
|
||||
using type = cc::render::impl::VectorVertexComponentMemberPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
T,
|
||||
T&,
|
||||
T cc::render::RasterSubpass::*>;
|
||||
};
|
||||
|
||||
// Vertex Index
|
||||
template <>
|
||||
struct property_map<cc::render::ResourceGraph, vertex_index_t> {
|
||||
@@ -1098,83 +1175,6 @@ struct property_map<cc::render::ResourceGraph, cc::render::ResourceGraph::Sample
|
||||
cc::gfx::SamplerInfo&>;
|
||||
};
|
||||
|
||||
// Vertex Index
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, vertex_index_t> {
|
||||
using const_type = identity_property_map;
|
||||
using type = identity_property_map;
|
||||
};
|
||||
|
||||
// Vertex Component
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, cc::render::SubpassGraph::NameTag> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
const ccstd::pmr::string&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
ccstd::pmr::string&>;
|
||||
};
|
||||
|
||||
// Vertex Name
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, vertex_name_t> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
const ccstd::pmr::string&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
read_write_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<ccstd::pmr::string>,
|
||||
std::string_view,
|
||||
ccstd::pmr::string&>;
|
||||
};
|
||||
|
||||
// Vertex Component
|
||||
template <>
|
||||
struct property_map<cc::render::SubpassGraph, cc::render::SubpassGraph::SubpassTag> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
cc::render::RasterSubpass,
|
||||
const cc::render::RasterSubpass&>;
|
||||
using type = cc::render::impl::VectorVertexComponentPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
cc::render::RasterSubpass,
|
||||
cc::render::RasterSubpass&>;
|
||||
};
|
||||
|
||||
// Vertex ComponentMember
|
||||
template <class T>
|
||||
struct property_map<cc::render::SubpassGraph, T cc::render::RasterSubpass::*> {
|
||||
using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
const cc::render::SubpassGraph,
|
||||
const ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
T,
|
||||
const T&,
|
||||
T cc::render::RasterSubpass::*>;
|
||||
using type = cc::render::impl::VectorVertexComponentMemberPropertyMap<
|
||||
lvalue_property_map_tag,
|
||||
cc::render::SubpassGraph,
|
||||
ccstd::pmr::vector<cc::render::RasterSubpass>,
|
||||
T,
|
||||
T&,
|
||||
T cc::render::RasterSubpass::*>;
|
||||
};
|
||||
|
||||
// Vertex Index
|
||||
template <>
|
||||
struct property_map<cc::render::RenderGraph, vertex_index_t> {
|
||||
@@ -1292,6 +1292,105 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
// Vertex Index
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_index_t>::const_type
|
||||
get(boost::vertex_index_t /*tag*/, const SubpassGraph& /*g*/) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_index_t>::type
|
||||
get(boost::vertex_index_t /*tag*/, SubpassGraph& /*g*/) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
inline impl::ColorMap<SubpassGraph::vertex_descriptor>
|
||||
get(ccstd::pmr::vector<boost::default_color_type>& colors, const SubpassGraph& /*g*/) noexcept {
|
||||
return {colors};
|
||||
}
|
||||
|
||||
// Vertex Component
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::NameTag>::const_type
|
||||
get(SubpassGraph::NameTag /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::NameTag>::type
|
||||
get(SubpassGraph::NameTag /*tag*/, SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
// Vertex Name
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_name_t>::const_type
|
||||
get(boost::vertex_name_t /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
// Vertex Component
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::SubpassTag>::const_type
|
||||
get(SubpassGraph::SubpassTag /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.subpasses};
|
||||
}
|
||||
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::SubpassTag>::type
|
||||
get(SubpassGraph::SubpassTag /*tag*/, SubpassGraph& g) noexcept {
|
||||
return {g.subpasses};
|
||||
}
|
||||
|
||||
// Vertex ComponentMember
|
||||
template <class T>
|
||||
inline typename boost::property_map<SubpassGraph, T RasterSubpass::*>::const_type
|
||||
get(T RasterSubpass::*memberPointer, const SubpassGraph& g) noexcept {
|
||||
return {g.subpasses, memberPointer};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename boost::property_map<SubpassGraph, T RasterSubpass::*>::type
|
||||
get(T RasterSubpass::*memberPointer, SubpassGraph& g) noexcept {
|
||||
return {g.subpasses, memberPointer};
|
||||
}
|
||||
|
||||
// Vertex Constant Getter
|
||||
template <class Tag>
|
||||
inline decltype(auto)
|
||||
get(Tag tag, const SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept {
|
||||
return get(get(tag, g), v);
|
||||
}
|
||||
|
||||
// Vertex Mutable Getter
|
||||
template <class Tag>
|
||||
inline decltype(auto)
|
||||
get(Tag tag, SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept {
|
||||
return get(get(tag, g), v);
|
||||
}
|
||||
|
||||
// Vertex Setter
|
||||
template <class Tag, class... Args>
|
||||
inline void put(
|
||||
Tag tag, SubpassGraph& g,
|
||||
SubpassGraph::vertex_descriptor v,
|
||||
Args&&... args) {
|
||||
put(get(tag, g), v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// MutableGraph(Vertex)
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
add_vertex(SubpassGraph& g, ccstd::pmr::string&& name) { // NOLINT
|
||||
return addVertex(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(std::move(name)), // names
|
||||
std::forward_as_tuple(), // subpasses
|
||||
g);
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
add_vertex(SubpassGraph& g, const char* name) { // NOLINT
|
||||
return addVertex(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(name), // names
|
||||
std::forward_as_tuple(), // subpasses
|
||||
g);
|
||||
}
|
||||
|
||||
// Vertex Index
|
||||
inline boost::property_map<ResourceGraph, boost::vertex_index_t>::const_type
|
||||
get(boost::vertex_index_t /*tag*/, const ResourceGraph& /*g*/) noexcept {
|
||||
@@ -2230,105 +2329,6 @@ add_vertex(ResourceGraph& g, Tag t, const char* name) { // NOLINT
|
||||
g);
|
||||
}
|
||||
|
||||
// Vertex Index
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_index_t>::const_type
|
||||
get(boost::vertex_index_t /*tag*/, const SubpassGraph& /*g*/) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_index_t>::type
|
||||
get(boost::vertex_index_t /*tag*/, SubpassGraph& /*g*/) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
inline impl::ColorMap<SubpassGraph::vertex_descriptor>
|
||||
get(ccstd::pmr::vector<boost::default_color_type>& colors, const SubpassGraph& /*g*/) noexcept {
|
||||
return {colors};
|
||||
}
|
||||
|
||||
// Vertex Component
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::NameTag>::const_type
|
||||
get(SubpassGraph::NameTag /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::NameTag>::type
|
||||
get(SubpassGraph::NameTag /*tag*/, SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
// Vertex Name
|
||||
inline boost::property_map<SubpassGraph, boost::vertex_name_t>::const_type
|
||||
get(boost::vertex_name_t /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.names};
|
||||
}
|
||||
|
||||
// Vertex Component
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::SubpassTag>::const_type
|
||||
get(SubpassGraph::SubpassTag /*tag*/, const SubpassGraph& g) noexcept {
|
||||
return {g.subpasses};
|
||||
}
|
||||
|
||||
inline typename boost::property_map<SubpassGraph, SubpassGraph::SubpassTag>::type
|
||||
get(SubpassGraph::SubpassTag /*tag*/, SubpassGraph& g) noexcept {
|
||||
return {g.subpasses};
|
||||
}
|
||||
|
||||
// Vertex ComponentMember
|
||||
template <class T>
|
||||
inline typename boost::property_map<SubpassGraph, T RasterSubpass::*>::const_type
|
||||
get(T RasterSubpass::*memberPointer, const SubpassGraph& g) noexcept {
|
||||
return {g.subpasses, memberPointer};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline typename boost::property_map<SubpassGraph, T RasterSubpass::*>::type
|
||||
get(T RasterSubpass::*memberPointer, SubpassGraph& g) noexcept {
|
||||
return {g.subpasses, memberPointer};
|
||||
}
|
||||
|
||||
// Vertex Constant Getter
|
||||
template <class Tag>
|
||||
inline decltype(auto)
|
||||
get(Tag tag, const SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept {
|
||||
return get(get(tag, g), v);
|
||||
}
|
||||
|
||||
// Vertex Mutable Getter
|
||||
template <class Tag>
|
||||
inline decltype(auto)
|
||||
get(Tag tag, SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept {
|
||||
return get(get(tag, g), v);
|
||||
}
|
||||
|
||||
// Vertex Setter
|
||||
template <class Tag, class... Args>
|
||||
inline void put(
|
||||
Tag tag, SubpassGraph& g,
|
||||
SubpassGraph::vertex_descriptor v,
|
||||
Args&&... args) {
|
||||
put(get(tag, g), v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// MutableGraph(Vertex)
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
add_vertex(SubpassGraph& g, ccstd::pmr::string&& name) { // NOLINT
|
||||
return addVertex(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(std::move(name)), // names
|
||||
std::forward_as_tuple(), // subpasses
|
||||
g);
|
||||
}
|
||||
|
||||
inline SubpassGraph::vertex_descriptor
|
||||
add_vertex(SubpassGraph& g, const char* name) { // NOLINT
|
||||
return addVertex(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(name), // names
|
||||
std::forward_as_tuple(), // subpasses
|
||||
g);
|
||||
}
|
||||
|
||||
// Vertex Index
|
||||
inline boost::property_map<RenderGraph, boost::vertex_index_t>::const_type
|
||||
get(boost::vertex_index_t /*tag*/, const RenderGraph& /*g*/) noexcept {
|
||||
|
||||
@@ -34,82 +34,6 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
ResourceGraph::ResourceGraph(const allocator_type& alloc) noexcept
|
||||
: _vertices(alloc),
|
||||
names(alloc),
|
||||
descs(alloc),
|
||||
traits(alloc),
|
||||
states(alloc),
|
||||
samplerInfo(alloc),
|
||||
resources(alloc),
|
||||
managedBuffers(alloc),
|
||||
managedTextures(alloc),
|
||||
buffers(alloc),
|
||||
textures(alloc),
|
||||
framebuffers(alloc),
|
||||
swapchains(alloc),
|
||||
valueIndex(alloc) {}
|
||||
|
||||
ResourceGraph::ResourceGraph(ResourceGraph&& rhs, const allocator_type& alloc)
|
||||
: _vertices(std::move(rhs._vertices), alloc),
|
||||
names(std::move(rhs.names), alloc),
|
||||
descs(std::move(rhs.descs), alloc),
|
||||
traits(std::move(rhs.traits), alloc),
|
||||
states(std::move(rhs.states), alloc),
|
||||
samplerInfo(std::move(rhs.samplerInfo), alloc),
|
||||
resources(std::move(rhs.resources), alloc),
|
||||
managedBuffers(std::move(rhs.managedBuffers), alloc),
|
||||
managedTextures(std::move(rhs.managedTextures), alloc),
|
||||
buffers(std::move(rhs.buffers), alloc),
|
||||
textures(std::move(rhs.textures), alloc),
|
||||
framebuffers(std::move(rhs.framebuffers), alloc),
|
||||
swapchains(std::move(rhs.swapchains), alloc),
|
||||
valueIndex(std::move(rhs.valueIndex), alloc),
|
||||
nextFenceValue(rhs.nextFenceValue),
|
||||
version(rhs.version) {}
|
||||
|
||||
ResourceGraph::ResourceGraph(ResourceGraph const& rhs, const allocator_type& alloc)
|
||||
: _vertices(rhs._vertices, alloc),
|
||||
names(rhs.names, alloc),
|
||||
descs(rhs.descs, alloc),
|
||||
traits(rhs.traits, alloc),
|
||||
states(rhs.states, alloc),
|
||||
samplerInfo(rhs.samplerInfo, alloc),
|
||||
resources(rhs.resources, alloc),
|
||||
managedBuffers(rhs.managedBuffers, alloc),
|
||||
managedTextures(rhs.managedTextures, alloc),
|
||||
buffers(rhs.buffers, alloc),
|
||||
textures(rhs.textures, alloc),
|
||||
framebuffers(rhs.framebuffers, alloc),
|
||||
swapchains(rhs.swapchains, alloc),
|
||||
valueIndex(rhs.valueIndex, alloc),
|
||||
nextFenceValue(rhs.nextFenceValue),
|
||||
version(rhs.version) {}
|
||||
|
||||
// ContinuousContainer
|
||||
void ResourceGraph::reserve(vertices_size_type sz) {
|
||||
_vertices.reserve(sz);
|
||||
names.reserve(sz);
|
||||
descs.reserve(sz);
|
||||
traits.reserve(sz);
|
||||
states.reserve(sz);
|
||||
samplerInfo.reserve(sz);
|
||||
}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(const allocator_type& alloc) noexcept
|
||||
: outEdges(alloc),
|
||||
inEdges(alloc) {}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(Vertex&& rhs, const allocator_type& alloc)
|
||||
: outEdges(std::move(rhs.outEdges), alloc),
|
||||
inEdges(std::move(rhs.inEdges), alloc),
|
||||
handle(std::move(rhs.handle)) {}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(Vertex const& rhs, const allocator_type& alloc)
|
||||
: outEdges(rhs.outEdges, alloc),
|
||||
inEdges(rhs.inEdges, alloc),
|
||||
handle(rhs.handle) {}
|
||||
|
||||
RasterSubpass::RasterSubpass(const allocator_type& alloc) noexcept
|
||||
: rasterViews(alloc),
|
||||
computeViews(alloc) {}
|
||||
@@ -184,6 +108,69 @@ RasterPass::RasterPass(RasterPass const& rhs, const allocator_type& alloc)
|
||||
version(rhs.version),
|
||||
showStatistics(rhs.showStatistics) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept
|
||||
: clearColors(alloc) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(IntrusivePtr<gfx::RenderPass> renderPassIn, IntrusivePtr<gfx::Framebuffer> framebufferIn, const allocator_type& alloc) noexcept
|
||||
: renderPass(std::move(renderPassIn)),
|
||||
framebuffer(std::move(framebufferIn)),
|
||||
clearColors(alloc) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc)
|
||||
: renderPass(std::move(rhs.renderPass)),
|
||||
framebuffer(std::move(rhs.framebuffer)),
|
||||
clearColors(std::move(rhs.clearColors), alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc)
|
||||
: renderPass(rhs.renderPass),
|
||||
framebuffer(rhs.framebuffer),
|
||||
clearColors(rhs.clearColors, alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil) {}
|
||||
|
||||
ResourceGraph::ResourceGraph(const allocator_type& alloc) noexcept
|
||||
: _vertices(alloc),
|
||||
names(alloc),
|
||||
descs(alloc),
|
||||
traits(alloc),
|
||||
states(alloc),
|
||||
samplerInfo(alloc),
|
||||
resources(alloc),
|
||||
managedBuffers(alloc),
|
||||
managedTextures(alloc),
|
||||
buffers(alloc),
|
||||
textures(alloc),
|
||||
framebuffers(alloc),
|
||||
swapchains(alloc),
|
||||
valueIndex(alloc),
|
||||
renderPasses(alloc) {}
|
||||
|
||||
// ContinuousContainer
|
||||
void ResourceGraph::reserve(vertices_size_type sz) {
|
||||
_vertices.reserve(sz);
|
||||
names.reserve(sz);
|
||||
descs.reserve(sz);
|
||||
traits.reserve(sz);
|
||||
states.reserve(sz);
|
||||
samplerInfo.reserve(sz);
|
||||
}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(const allocator_type& alloc) noexcept
|
||||
: outEdges(alloc),
|
||||
inEdges(alloc) {}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(Vertex&& rhs, const allocator_type& alloc)
|
||||
: outEdges(std::move(rhs.outEdges), alloc),
|
||||
inEdges(std::move(rhs.inEdges), alloc),
|
||||
handle(std::move(rhs.handle)) {}
|
||||
|
||||
ResourceGraph::Vertex::Vertex(Vertex const& rhs, const allocator_type& alloc)
|
||||
: outEdges(rhs.outEdges, alloc),
|
||||
inEdges(rhs.inEdges, alloc),
|
||||
handle(rhs.handle) {}
|
||||
|
||||
ComputePass::ComputePass(const allocator_type& alloc) noexcept
|
||||
: computeViews(alloc) {}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "cocos/math/Geometry.h"
|
||||
#include "cocos/renderer/gfx-base/GFXBuffer.h"
|
||||
#include "cocos/renderer/gfx-base/GFXFramebuffer.h"
|
||||
#include "cocos/renderer/gfx-base/GFXRenderPass.h"
|
||||
#include "cocos/renderer/gfx-base/GFXSwapchain.h"
|
||||
#include "cocos/renderer/gfx-base/GFXTexture.h"
|
||||
#include "cocos/renderer/gfx-base/states/GFXSampler.h"
|
||||
@@ -89,6 +90,7 @@ struct RenderSwapchain {
|
||||
gfx::Swapchain* swapchain{nullptr};
|
||||
uint32_t currentID{0};
|
||||
uint32_t numBackBuffers{0};
|
||||
uint32_t generation{0xFFFFFFFF};
|
||||
};
|
||||
|
||||
struct ResourceStates {
|
||||
@@ -119,177 +121,6 @@ struct ManagedResource {
|
||||
uint32_t unused{0};
|
||||
};
|
||||
|
||||
struct ManagedTag {};
|
||||
struct ManagedBufferTag {};
|
||||
struct ManagedTextureTag {};
|
||||
struct PersistentBufferTag {};
|
||||
struct PersistentTextureTag {};
|
||||
struct FramebufferTag {};
|
||||
struct SwapchainTag {};
|
||||
struct SamplerTag {};
|
||||
|
||||
struct ResourceGraph {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {_vertices.get_allocator().resource()};
|
||||
}
|
||||
|
||||
inline boost::container::pmr::memory_resource* resource() const noexcept {
|
||||
return get_allocator().resource();
|
||||
}
|
||||
|
||||
ResourceGraph(const allocator_type& alloc) noexcept; // NOLINT
|
||||
ResourceGraph(ResourceGraph&& rhs, const allocator_type& alloc);
|
||||
ResourceGraph(ResourceGraph const& rhs, const allocator_type& alloc);
|
||||
|
||||
ResourceGraph(ResourceGraph&& rhs) noexcept = default;
|
||||
ResourceGraph(ResourceGraph const& rhs) = delete;
|
||||
ResourceGraph& operator=(ResourceGraph&& rhs) = default;
|
||||
ResourceGraph& operator=(ResourceGraph const& rhs) = default;
|
||||
|
||||
// Graph
|
||||
using directed_category = boost::bidirectional_tag;
|
||||
using vertex_descriptor = uint32_t;
|
||||
using edge_descriptor = impl::EdgeDescriptor<directed_category, vertex_descriptor>;
|
||||
using edge_parallel_category = boost::allow_parallel_edge_tag;
|
||||
struct traversal_category // NOLINT
|
||||
: virtual boost::incidence_graph_tag,
|
||||
virtual boost::bidirectional_graph_tag,
|
||||
virtual boost::adjacency_graph_tag,
|
||||
virtual boost::vertex_list_graph_tag,
|
||||
virtual boost::edge_list_graph_tag {};
|
||||
|
||||
constexpr static vertex_descriptor null_vertex() noexcept { // NOLINT
|
||||
return std::numeric_limits<vertex_descriptor>::max();
|
||||
}
|
||||
|
||||
// IncidenceGraph
|
||||
using OutEdge = impl::StoredEdge<vertex_descriptor>;
|
||||
using out_edge_iterator = impl::OutEdgeIter<
|
||||
ccstd::pmr::vector<OutEdge>::iterator,
|
||||
vertex_descriptor, edge_descriptor, int32_t>;
|
||||
using degree_size_type = uint32_t;
|
||||
|
||||
// BidirectionalGraph
|
||||
using InEdge = impl::StoredEdge<vertex_descriptor>;
|
||||
using in_edge_iterator = impl::InEdgeIter<
|
||||
ccstd::pmr::vector<InEdge>::iterator,
|
||||
vertex_descriptor, edge_descriptor, int32_t>;
|
||||
|
||||
// AdjacencyGraph
|
||||
using adjacency_iterator = boost::adjacency_iterator_generator<
|
||||
ResourceGraph, vertex_descriptor, out_edge_iterator>::type;
|
||||
|
||||
// VertexListGraph
|
||||
using vertex_iterator = boost::integer_range<vertex_descriptor>::iterator;
|
||||
using vertices_size_type = uint32_t;
|
||||
|
||||
// VertexList help functions
|
||||
inline ccstd::pmr::vector<OutEdge>& getOutEdgeList(vertex_descriptor v) noexcept {
|
||||
return _vertices[v].outEdges;
|
||||
}
|
||||
inline const ccstd::pmr::vector<OutEdge>& getOutEdgeList(vertex_descriptor v) const noexcept {
|
||||
return _vertices[v].outEdges;
|
||||
}
|
||||
|
||||
inline ccstd::pmr::vector<InEdge>& getInEdgeList(vertex_descriptor v) noexcept {
|
||||
return _vertices[v].inEdges;
|
||||
}
|
||||
inline const ccstd::pmr::vector<InEdge>& getInEdgeList(vertex_descriptor v) const noexcept {
|
||||
return _vertices[v].inEdges;
|
||||
}
|
||||
|
||||
inline boost::integer_range<vertex_descriptor> getVertexList() const noexcept {
|
||||
return {0, static_cast<vertices_size_type>(_vertices.size())};
|
||||
}
|
||||
|
||||
inline vertex_descriptor getCurrentID() const noexcept {
|
||||
return static_cast<vertex_descriptor>(_vertices.size());
|
||||
}
|
||||
|
||||
inline ccstd::pmr::vector<boost::default_color_type> colors(boost::container::pmr::memory_resource* mr) const {
|
||||
return ccstd::pmr::vector<boost::default_color_type>(_vertices.size(), mr);
|
||||
}
|
||||
|
||||
// EdgeListGraph
|
||||
using edge_iterator = impl::DirectedEdgeIterator<vertex_iterator, out_edge_iterator, ResourceGraph>;
|
||||
using edges_size_type = uint32_t;
|
||||
|
||||
// PolymorphicGraph
|
||||
using VertexTag = ccstd::variant<ManagedTag, ManagedBufferTag, ManagedTextureTag, PersistentBufferTag, PersistentTextureTag, FramebufferTag, SwapchainTag>;
|
||||
using VertexValue = ccstd::variant<ManagedResource*, ManagedBuffer*, ManagedTexture*, IntrusivePtr<gfx::Buffer>*, IntrusivePtr<gfx::Texture>*, IntrusivePtr<gfx::Framebuffer>*, RenderSwapchain*>;
|
||||
using VertexConstValue = ccstd::variant<const ManagedResource*, const ManagedBuffer*, const ManagedTexture*, const IntrusivePtr<gfx::Buffer>*, const IntrusivePtr<gfx::Texture>*, const IntrusivePtr<gfx::Framebuffer>*, const RenderSwapchain*>;
|
||||
using VertexHandle = ccstd::variant<
|
||||
impl::ValueHandle<ManagedTag, vertex_descriptor>,
|
||||
impl::ValueHandle<ManagedBufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<ManagedTextureTag, vertex_descriptor>,
|
||||
impl::ValueHandle<PersistentBufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<PersistentTextureTag, vertex_descriptor>,
|
||||
impl::ValueHandle<FramebufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<SwapchainTag, vertex_descriptor>>;
|
||||
|
||||
void mount(gfx::Device* device, vertex_descriptor vertID);
|
||||
void unmount(uint64_t completedFenceValue);
|
||||
gfx::Texture* getTexture(vertex_descriptor resID);
|
||||
|
||||
// ContinuousContainer
|
||||
void reserve(vertices_size_type sz);
|
||||
|
||||
// Members
|
||||
struct Vertex {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {outEdges.get_allocator().resource()};
|
||||
}
|
||||
|
||||
Vertex(const allocator_type& alloc) noexcept; // NOLINT
|
||||
Vertex(Vertex&& rhs, const allocator_type& alloc);
|
||||
Vertex(Vertex const& rhs, const allocator_type& alloc);
|
||||
|
||||
Vertex(Vertex&& rhs) noexcept = default;
|
||||
Vertex(Vertex const& rhs) = delete;
|
||||
Vertex& operator=(Vertex&& rhs) = default;
|
||||
Vertex& operator=(Vertex const& rhs) = default;
|
||||
|
||||
ccstd::pmr::vector<OutEdge> outEdges;
|
||||
ccstd::pmr::vector<InEdge> inEdges;
|
||||
VertexHandle handle;
|
||||
};
|
||||
|
||||
struct NameTag {
|
||||
} static constexpr Name{}; // NOLINT
|
||||
struct DescTag {
|
||||
} static constexpr Desc{}; // NOLINT
|
||||
struct TraitsTag {
|
||||
} static constexpr Traits{}; // NOLINT
|
||||
struct StatesTag {
|
||||
} static constexpr States{}; // NOLINT
|
||||
struct SamplerTag {
|
||||
} static constexpr Sampler{}; // NOLINT
|
||||
|
||||
// Vertices
|
||||
ccstd::pmr::vector<Vertex> _vertices;
|
||||
// Components
|
||||
ccstd::pmr::vector<ccstd::pmr::string> names;
|
||||
ccstd::pmr::vector<ResourceDesc> descs;
|
||||
ccstd::pmr::vector<ResourceTraits> traits;
|
||||
ccstd::pmr::vector<ResourceStates> states;
|
||||
ccstd::pmr::vector<gfx::SamplerInfo> samplerInfo;
|
||||
// PolymorphicGraph
|
||||
ccstd::pmr::vector<ManagedResource> resources;
|
||||
ccstd::pmr::vector<ManagedBuffer> managedBuffers;
|
||||
ccstd::pmr::vector<ManagedTexture> managedTextures;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> buffers;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Texture>> textures;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Framebuffer>> framebuffers;
|
||||
ccstd::pmr::vector<RenderSwapchain> swapchains;
|
||||
// UuidGraph
|
||||
PmrUnorderedStringMap<ccstd::pmr::string, vertex_descriptor> valueIndex;
|
||||
// Members
|
||||
uint64_t nextFenceValue{0};
|
||||
uint64_t version{0};
|
||||
};
|
||||
|
||||
struct RasterSubpass {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
@@ -476,14 +307,208 @@ struct RasterPass {
|
||||
};
|
||||
|
||||
inline bool operator==(const RasterPass& lhs, const RasterPass& rhs) noexcept {
|
||||
return std::forward_as_tuple(lhs.rasterViews, lhs.computeViews, lhs.subpassGraph, lhs.width, lhs.height, lhs.versionName, lhs.version) ==
|
||||
std::forward_as_tuple(rhs.rasterViews, rhs.computeViews, rhs.subpassGraph, rhs.width, rhs.height, rhs.versionName, rhs.version);
|
||||
return std::forward_as_tuple(lhs.rasterViews, lhs.computeViews, lhs.subpassGraph, lhs.width, lhs.height) ==
|
||||
std::forward_as_tuple(rhs.rasterViews, rhs.computeViews, rhs.subpassGraph, rhs.width, rhs.height);
|
||||
}
|
||||
|
||||
inline bool operator!=(const RasterPass& lhs, const RasterPass& rhs) noexcept {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
struct PersistentRenderPassAndFramebuffer {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {clearColors.get_allocator().resource()};
|
||||
}
|
||||
|
||||
PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept; // NOLINT
|
||||
PersistentRenderPassAndFramebuffer(IntrusivePtr<gfx::RenderPass> renderPassIn, IntrusivePtr<gfx::Framebuffer> framebufferIn, const allocator_type& alloc) noexcept;
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc);
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc);
|
||||
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs) noexcept = default;
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs) = delete;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer&& rhs) = default;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer const& rhs) = default;
|
||||
|
||||
IntrusivePtr<gfx::RenderPass> renderPass;
|
||||
IntrusivePtr<gfx::Framebuffer> framebuffer;
|
||||
ccstd::pmr::vector<gfx::Color> clearColors;
|
||||
float clearDepth{0};
|
||||
uint8_t clearStencil{0};
|
||||
};
|
||||
|
||||
struct ManagedTag {};
|
||||
struct ManagedBufferTag {};
|
||||
struct ManagedTextureTag {};
|
||||
struct PersistentBufferTag {};
|
||||
struct PersistentTextureTag {};
|
||||
struct FramebufferTag {};
|
||||
struct SwapchainTag {};
|
||||
struct SamplerTag {};
|
||||
|
||||
struct ResourceGraph {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {_vertices.get_allocator().resource()};
|
||||
}
|
||||
|
||||
inline boost::container::pmr::memory_resource* resource() const noexcept {
|
||||
return get_allocator().resource();
|
||||
}
|
||||
|
||||
ResourceGraph(const allocator_type& alloc) noexcept; // NOLINT
|
||||
ResourceGraph(ResourceGraph&& rhs) = delete;
|
||||
ResourceGraph(ResourceGraph const& rhs) = delete;
|
||||
ResourceGraph& operator=(ResourceGraph&& rhs) = delete;
|
||||
ResourceGraph& operator=(ResourceGraph const& rhs) = delete;
|
||||
|
||||
// Graph
|
||||
using directed_category = boost::bidirectional_tag;
|
||||
using vertex_descriptor = uint32_t;
|
||||
using edge_descriptor = impl::EdgeDescriptor<directed_category, vertex_descriptor>;
|
||||
using edge_parallel_category = boost::allow_parallel_edge_tag;
|
||||
struct traversal_category // NOLINT
|
||||
: virtual boost::incidence_graph_tag,
|
||||
virtual boost::bidirectional_graph_tag,
|
||||
virtual boost::adjacency_graph_tag,
|
||||
virtual boost::vertex_list_graph_tag,
|
||||
virtual boost::edge_list_graph_tag {};
|
||||
|
||||
constexpr static vertex_descriptor null_vertex() noexcept { // NOLINT
|
||||
return std::numeric_limits<vertex_descriptor>::max();
|
||||
}
|
||||
|
||||
// IncidenceGraph
|
||||
using OutEdge = impl::StoredEdge<vertex_descriptor>;
|
||||
using out_edge_iterator = impl::OutEdgeIter<
|
||||
ccstd::pmr::vector<OutEdge>::iterator,
|
||||
vertex_descriptor, edge_descriptor, int32_t>;
|
||||
using degree_size_type = uint32_t;
|
||||
|
||||
// BidirectionalGraph
|
||||
using InEdge = impl::StoredEdge<vertex_descriptor>;
|
||||
using in_edge_iterator = impl::InEdgeIter<
|
||||
ccstd::pmr::vector<InEdge>::iterator,
|
||||
vertex_descriptor, edge_descriptor, int32_t>;
|
||||
|
||||
// AdjacencyGraph
|
||||
using adjacency_iterator = boost::adjacency_iterator_generator<
|
||||
ResourceGraph, vertex_descriptor, out_edge_iterator>::type;
|
||||
|
||||
// VertexListGraph
|
||||
using vertex_iterator = boost::integer_range<vertex_descriptor>::iterator;
|
||||
using vertices_size_type = uint32_t;
|
||||
|
||||
// VertexList help functions
|
||||
inline ccstd::pmr::vector<OutEdge>& getOutEdgeList(vertex_descriptor v) noexcept {
|
||||
return _vertices[v].outEdges;
|
||||
}
|
||||
inline const ccstd::pmr::vector<OutEdge>& getOutEdgeList(vertex_descriptor v) const noexcept {
|
||||
return _vertices[v].outEdges;
|
||||
}
|
||||
|
||||
inline ccstd::pmr::vector<InEdge>& getInEdgeList(vertex_descriptor v) noexcept {
|
||||
return _vertices[v].inEdges;
|
||||
}
|
||||
inline const ccstd::pmr::vector<InEdge>& getInEdgeList(vertex_descriptor v) const noexcept {
|
||||
return _vertices[v].inEdges;
|
||||
}
|
||||
|
||||
inline boost::integer_range<vertex_descriptor> getVertexList() const noexcept {
|
||||
return {0, static_cast<vertices_size_type>(_vertices.size())};
|
||||
}
|
||||
|
||||
inline vertex_descriptor getCurrentID() const noexcept {
|
||||
return static_cast<vertex_descriptor>(_vertices.size());
|
||||
}
|
||||
|
||||
inline ccstd::pmr::vector<boost::default_color_type> colors(boost::container::pmr::memory_resource* mr) const {
|
||||
return ccstd::pmr::vector<boost::default_color_type>(_vertices.size(), mr);
|
||||
}
|
||||
|
||||
// EdgeListGraph
|
||||
using edge_iterator = impl::DirectedEdgeIterator<vertex_iterator, out_edge_iterator, ResourceGraph>;
|
||||
using edges_size_type = uint32_t;
|
||||
|
||||
// PolymorphicGraph
|
||||
using VertexTag = ccstd::variant<ManagedTag, ManagedBufferTag, ManagedTextureTag, PersistentBufferTag, PersistentTextureTag, FramebufferTag, SwapchainTag>;
|
||||
using VertexValue = ccstd::variant<ManagedResource*, ManagedBuffer*, ManagedTexture*, IntrusivePtr<gfx::Buffer>*, IntrusivePtr<gfx::Texture>*, IntrusivePtr<gfx::Framebuffer>*, RenderSwapchain*>;
|
||||
using VertexConstValue = ccstd::variant<const ManagedResource*, const ManagedBuffer*, const ManagedTexture*, const IntrusivePtr<gfx::Buffer>*, const IntrusivePtr<gfx::Texture>*, const IntrusivePtr<gfx::Framebuffer>*, const RenderSwapchain*>;
|
||||
using VertexHandle = ccstd::variant<
|
||||
impl::ValueHandle<ManagedTag, vertex_descriptor>,
|
||||
impl::ValueHandle<ManagedBufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<ManagedTextureTag, vertex_descriptor>,
|
||||
impl::ValueHandle<PersistentBufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<PersistentTextureTag, vertex_descriptor>,
|
||||
impl::ValueHandle<FramebufferTag, vertex_descriptor>,
|
||||
impl::ValueHandle<SwapchainTag, vertex_descriptor>>;
|
||||
|
||||
void validateSwapchains();
|
||||
void mount(gfx::Device* device, vertex_descriptor vertID);
|
||||
void unmount(uint64_t completedFenceValue);
|
||||
gfx::Texture* getTexture(vertex_descriptor resID);
|
||||
void invalidatePersistentRenderPassAndFramebuffer(gfx::Texture* pTexture);
|
||||
|
||||
// ContinuousContainer
|
||||
void reserve(vertices_size_type sz);
|
||||
|
||||
// Members
|
||||
struct Vertex {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {outEdges.get_allocator().resource()};
|
||||
}
|
||||
|
||||
Vertex(const allocator_type& alloc) noexcept; // NOLINT
|
||||
Vertex(Vertex&& rhs, const allocator_type& alloc);
|
||||
Vertex(Vertex const& rhs, const allocator_type& alloc);
|
||||
|
||||
Vertex(Vertex&& rhs) noexcept = default;
|
||||
Vertex(Vertex const& rhs) = delete;
|
||||
Vertex& operator=(Vertex&& rhs) = default;
|
||||
Vertex& operator=(Vertex const& rhs) = default;
|
||||
|
||||
ccstd::pmr::vector<OutEdge> outEdges;
|
||||
ccstd::pmr::vector<InEdge> inEdges;
|
||||
VertexHandle handle;
|
||||
};
|
||||
|
||||
struct NameTag {
|
||||
} static constexpr Name{}; // NOLINT
|
||||
struct DescTag {
|
||||
} static constexpr Desc{}; // NOLINT
|
||||
struct TraitsTag {
|
||||
} static constexpr Traits{}; // NOLINT
|
||||
struct StatesTag {
|
||||
} static constexpr States{}; // NOLINT
|
||||
struct SamplerTag {
|
||||
} static constexpr Sampler{}; // NOLINT
|
||||
|
||||
// Vertices
|
||||
ccstd::pmr::vector<Vertex> _vertices;
|
||||
// Components
|
||||
ccstd::pmr::vector<ccstd::pmr::string> names;
|
||||
ccstd::pmr::vector<ResourceDesc> descs;
|
||||
ccstd::pmr::vector<ResourceTraits> traits;
|
||||
ccstd::pmr::vector<ResourceStates> states;
|
||||
ccstd::pmr::vector<gfx::SamplerInfo> samplerInfo;
|
||||
// PolymorphicGraph
|
||||
ccstd::pmr::vector<ManagedResource> resources;
|
||||
ccstd::pmr::vector<ManagedBuffer> managedBuffers;
|
||||
ccstd::pmr::vector<ManagedTexture> managedTextures;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> buffers;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Texture>> textures;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Framebuffer>> framebuffers;
|
||||
ccstd::pmr::vector<RenderSwapchain> swapchains;
|
||||
// UuidGraph
|
||||
PmrUnorderedStringMap<ccstd::pmr::string, vertex_descriptor> valueIndex;
|
||||
// Members
|
||||
ccstd::pmr::unordered_map<RasterPass, PersistentRenderPassAndFramebuffer> renderPasses;
|
||||
uint64_t nextFenceValue{0};
|
||||
uint64_t version{0};
|
||||
};
|
||||
|
||||
struct ComputePass {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
@@ -943,8 +968,6 @@ inline hash_t hash<cc::render::RasterPass>::operator()(const cc::render::RasterP
|
||||
hash_combine(seed, val.subpassGraph);
|
||||
hash_combine(seed, val.width);
|
||||
hash_combine(seed, val.height);
|
||||
hash_combine(seed, val.versionName);
|
||||
hash_combine(seed, val.version);
|
||||
return seed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user