From 94516f53434809082dac2eb70b38f97bf10efeda Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Tue, 22 Feb 2022 09:58:51 +0800 Subject: [PATCH] V3.6.0 pipeline (#10131) --- cocos/core/pipeline/custom/executor.ts | 407 +++ cocos/core/pipeline/custom/graph.ts | 512 ++++ cocos/core/pipeline/custom/layout-graph.ts | 621 ++++ cocos/core/pipeline/custom/pipeline.ts | 113 + cocos/core/pipeline/custom/render-graph.ts | 1574 ++++++++++ cocos/core/pipeline/custom/types.ts | 129 + .../custom/web-descriptor-hierarchy.ts | 39 + cocos/core/pipeline/custom/web-pipeline.ts | 386 +++ .../core/pipeline/forward/forward-pipeline.ts | 6 + native/CMakeLists.txt | 56 + .../cocos/bindings/auto/jsb_render_auto.cpp | 1267 ++++++++ native/cocos/bindings/auto/jsb_render_auto.h | 109 + .../renderer/pipeline/custom/GraphImpl.h | 679 +++++ .../renderer/pipeline/custom/GraphTypes.h | 625 ++++ .../cocos/renderer/pipeline/custom/GslUtils.h | 46 + .../renderer/pipeline/custom/JsbConversion.h | 98 + .../renderer/pipeline/custom/LayoutGraphFwd.h | 62 + .../pipeline/custom/LayoutGraphGraphs.h | 1130 ++++++++ .../pipeline/custom/LayoutGraphJsb.cpp | 36 + .../renderer/pipeline/custom/LayoutGraphJsb.h | 37 + .../pipeline/custom/LayoutGraphNames.h | 59 + .../pipeline/custom/LayoutGraphReflection.cpp | 35 + .../pipeline/custom/LayoutGraphReflection.h | 36 + .../pipeline/custom/LayoutGraphTypes.cpp | 186 ++ .../pipeline/custom/LayoutGraphTypes.h | 411 +++ native/cocos/renderer/pipeline/custom/Map.h | 102 + .../cocos/renderer/pipeline/custom/Overload.h | 65 + .../renderer/pipeline/custom/PathUtils.h | 89 + native/cocos/renderer/pipeline/custom/Range.h | 37 + .../pipeline/custom/RenderCommonFwd.h | 132 + .../pipeline/custom/RenderCommonJsb.cpp | 36 + .../pipeline/custom/RenderCommonJsb.h | 36 + .../pipeline/custom/RenderCommonNames.h | 146 + .../custom/RenderCommonReflection.cpp | 35 + .../pipeline/custom/RenderCommonReflection.h | 35 + .../pipeline/custom/RenderCommonTypes.cpp | 34 + .../pipeline/custom/RenderCommonTypes.h | 180 ++ .../pipeline/custom/RenderCompilerFwd.h | 47 + .../pipeline/custom/RenderCompilerGraphs.h | 41 + .../pipeline/custom/RenderCompilerImpl.cpp | 41 + .../pipeline/custom/RenderCompilerNames.h | 47 + .../custom/RenderCompilerReflection.cpp | 35 + .../custom/RenderCompilerReflection.h | 37 + .../pipeline/custom/RenderCompilerTypes.cpp | 34 + .../pipeline/custom/RenderCompilerTypes.h | 65 + .../pipeline/custom/RenderExampleFwd.h | 68 + .../pipeline/custom/RenderExampleGraphs.h | 1198 ++++++++ .../pipeline/custom/RenderExampleImpl.cpp | 505 ++++ .../pipeline/custom/RenderExampleNames.h | 63 + .../custom/RenderExampleReflection.cpp | 35 + .../pipeline/custom/RenderExampleReflection.h | 37 + .../pipeline/custom/RenderExampleTypes.cpp | 114 + .../pipeline/custom/RenderExampleTypes.h | 407 +++ .../pipeline/custom/RenderExecutorFwd.h | 47 + .../pipeline/custom/RenderExecutorGraphs.h | 791 +++++ .../pipeline/custom/RenderExecutorJsb.cpp | 36 + .../pipeline/custom/RenderExecutorJsb.h | 37 + .../pipeline/custom/RenderExecutorNames.h | 46 + .../custom/RenderExecutorReflection.cpp | 35 + .../custom/RenderExecutorReflection.h | 36 + .../pipeline/custom/RenderExecutorTypes.cpp | 70 + .../pipeline/custom/RenderExecutorTypes.h | 184 ++ .../renderer/pipeline/custom/RenderGraphFwd.h | 84 + .../pipeline/custom/RenderGraphGraphs.h | 2563 +++++++++++++++++ .../pipeline/custom/RenderGraphJsb.cpp | 312 ++ .../renderer/pipeline/custom/RenderGraphJsb.h | 58 + .../pipeline/custom/RenderGraphNames.h | 102 + .../pipeline/custom/RenderGraphReflection.cpp | 35 + .../pipeline/custom/RenderGraphReflection.h | 36 + .../pipeline/custom/RenderGraphTypes.cpp | 450 +++ .../pipeline/custom/RenderGraphTypes.h | 933 ++++++ .../pipeline/custom/RenderInterfaceFwd.h | 55 + .../pipeline/custom/RenderInterfaceTypes.cpp | 42 + .../pipeline/custom/RenderInterfaceTypes.h | 243 ++ native/cocos/renderer/pipeline/custom/Set.h | 102 + .../cocos/renderer/pipeline/custom/String.h | 36 + .../cocos/renderer/pipeline/custom/Utility.h | 52 + .../cocos/renderer/pipeline/custom/invoke.hpp | 305 ++ .../targets/spidermonkey/conversions.yaml | 1 + native/tools/tojs/genbindings.py | 1 + native/tools/tojs/render.ini | 78 + 81 files changed, 19130 insertions(+) create mode 100644 cocos/core/pipeline/custom/executor.ts create mode 100644 cocos/core/pipeline/custom/graph.ts create mode 100644 cocos/core/pipeline/custom/layout-graph.ts create mode 100644 cocos/core/pipeline/custom/pipeline.ts create mode 100644 cocos/core/pipeline/custom/render-graph.ts create mode 100644 cocos/core/pipeline/custom/types.ts create mode 100644 cocos/core/pipeline/custom/web-descriptor-hierarchy.ts create mode 100644 cocos/core/pipeline/custom/web-pipeline.ts create mode 100644 native/cocos/bindings/auto/jsb_render_auto.cpp create mode 100644 native/cocos/bindings/auto/jsb_render_auto.h create mode 100644 native/cocos/renderer/pipeline/custom/GraphImpl.h create mode 100644 native/cocos/renderer/pipeline/custom/GraphTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/GslUtils.h create mode 100644 native/cocos/renderer/pipeline/custom/JsbConversion.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphJsb.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphNames.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/Map.h create mode 100644 native/cocos/renderer/pipeline/custom/Overload.h create mode 100644 native/cocos/renderer/pipeline/custom/PathUtils.h create mode 100644 native/cocos/renderer/pipeline/custom/Range.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonJsb.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonNames.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCommonTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerGraphs.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerImpl.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerNames.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderCompilerTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleGraphs.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleImpl.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleNames.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExampleTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorGraphs.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorJsb.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorJsb.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorNames.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderExecutorTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphJsb.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphJsb.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphNames.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphReflection.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphReflection.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderGraphTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderInterfaceFwd.h create mode 100644 native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp create mode 100644 native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h create mode 100644 native/cocos/renderer/pipeline/custom/Set.h create mode 100644 native/cocos/renderer/pipeline/custom/String.h create mode 100644 native/cocos/renderer/pipeline/custom/Utility.h create mode 100644 native/cocos/renderer/pipeline/custom/invoke.hpp create mode 100644 native/tools/tojs/render.ini diff --git a/cocos/core/pipeline/custom/executor.ts b/cocos/core/pipeline/custom/executor.ts new file mode 100644 index 0000000000..407c75a849 --- /dev/null +++ b/cocos/core/pipeline/custom/executor.ts @@ -0,0 +1,407 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +/* eslint-disable max-len */ +import * as impl from './graph'; +import { Buffer, Texture } from '../../gfx/index'; + +//================================================================= +// DeviceResourceGraph +//================================================================= +// PolymorphicGraph Concept +export const enum DeviceResourceGraphValue { + Buffer, + Texture, +} + +interface DeviceResourceGraphValueType { + [DeviceResourceGraphValue.Buffer]: Buffer + [DeviceResourceGraphValue.Texture]: Texture +} + +export interface DeviceResourceGraphVisitor { + buffer(value: Buffer): unknown; + texture(value: Texture): unknown; +} + +type DeviceResourceGraphObject = Buffer | Texture; + +//----------------------------------------------------------------- +// Graph Concept +export class DeviceResourceGraphVertex { + constructor ( + readonly id: DeviceResourceGraphValue, + readonly object: DeviceResourceGraphObject, + ) { + this._id = id; + this._object = object; + } + readonly _outEdges: impl.OutE[] = []; + readonly _inEdges: impl.OutE[] = []; + readonly _id: DeviceResourceGraphValue; + readonly _object: DeviceResourceGraphObject; +} + +//----------------------------------------------------------------- +// PropertyGraph Concept +export class DeviceResourceGraphNameMap implements impl.PropertyMap { + constructor (readonly names: string[]) { + this._names = names; + } + get (v: number): string { + return this._names[v]; + } + readonly _names: string[]; +} + +export class DeviceResourceGraphRefCountMap implements impl.PropertyMap { + constructor (readonly refCounts: number[]) { + this._refCounts = refCounts; + } + get (v: number): number { + return this._refCounts[v]; + } + readonly _refCounts: number[]; +} + +//----------------------------------------------------------------- +// ComponentGraph Concept +export const enum DeviceResourceGraphComponent { + Name, + RefCount, +} + +interface DeviceResourceGraphComponentType { + [DeviceResourceGraphComponent.Name]: string; + [DeviceResourceGraphComponent.RefCount]: number; +} + +interface DeviceResourceGraphComponentPropertyMap { + [DeviceResourceGraphComponent.Name]: DeviceResourceGraphNameMap; + [DeviceResourceGraphComponent.RefCount]: DeviceResourceGraphRefCountMap; +} + +//----------------------------------------------------------------- +// DeviceResourceGraph Implementation +export class DeviceResourceGraph implements impl.BidirectionalGraph +, impl.AdjacencyGraph +, impl.VertexListGraph +, impl.MutableGraph +, impl.PropertyGraph +, impl.NamedGraph +, impl.ComponentGraph +, impl.PolymorphicGraph { + //----------------------------------------------------------------- + // Graph + // type vertex_descriptor = number; + nullVertex (): number { return 0xFFFFFFFF; } + // type edge_descriptor = impl.ED; + readonly directed_category: impl.directional = impl.directional.bidirectional; + readonly edge_parallel_category: impl.parallel = impl.parallel.allow; + readonly traversal_category: impl.traversal = impl.traversal.incidence + | impl.traversal.bidirectional + | impl.traversal.adjacency + | impl.traversal.vertex_list; + //----------------------------------------------------------------- + // IncidenceGraph + // type out_edge_iterator = impl.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: impl.ED): number { + return e.source as number; + } + target (e: impl.ED): number { + return e.target as number; + } + outEdges (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + outDegree (v: number): number { + return this._vertices[v]._outEdges.length; + } + //----------------------------------------------------------------- + // BidirectionalGraph + // type in_edge_iterator = impl.InEI; + inEdges (v: number): impl.InEI { + return new impl.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 = impl.AdjI; + adjacentVertices (v: number): impl.AdjI { + return new impl.AdjI(this, this.outEdges(v)); + } + //----------------------------------------------------------------- + // VertexListGraph + vertices (): IterableIterator { + return this._vertices.keys(); + } + numVertices (): number { + return this._vertices.length; + } + //----------------------------------------------------------------- + // MutableGraph + addVertex ( + id: DeviceResourceGraphValue, + object: DeviceResourceGraphValueType[T], + name: string, + refCount: number, + ): number { + const vert = new DeviceResourceGraphVertex(id, object); + const v = this._vertices.length; + this._vertices.push(vert); + this._names.push(name); + this._refCounts.push(refCount); + 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._refCounts.splice(u, 1); + + const sz = this._vertices.length; + if (u === sz) { + return; + } + + for (let v = 0; v !== sz; ++v) { + const vert = this._vertices[v]; + impl.reindexEdgeList(vert._outEdges, u); + impl.reindexEdgeList(vert._inEdges, u); + } + } + addEdge (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._outEdges.push(new impl.OutE(v)); + this._vertices[v]._inEdges.push(new impl.OutE(u)); + return new impl.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: impl.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 (): DeviceResourceGraphNameMap { + return new DeviceResourceGraphNameMap(this._names); + } + //----------------------------------------------------------------- + // PropertyGraph + get (tag: string): DeviceResourceGraphNameMap | DeviceResourceGraphRefCountMap { + switch (tag) { + // Components + case 'Name': + return new DeviceResourceGraphNameMap(this._names); + case 'RefCount': + return new DeviceResourceGraphRefCountMap(this._refCounts); + default: + throw Error('property map not found'); + } + } + //----------------------------------------------------------------- + // ComponentGraph + component (id: T, v: number): DeviceResourceGraphComponentType[T] { + switch (id) { + case DeviceResourceGraphComponent.Name: + return this._names[v] as DeviceResourceGraphComponentType[T]; + case DeviceResourceGraphComponent.RefCount: + return this._refCounts[v] as DeviceResourceGraphComponentType[T]; + default: + throw Error('component not found'); + } + } + componentMap (id: T): DeviceResourceGraphComponentPropertyMap[T] { + switch (id) { + case DeviceResourceGraphComponent.Name: + return new DeviceResourceGraphNameMap(this._names) as DeviceResourceGraphComponentPropertyMap[T]; + case DeviceResourceGraphComponent.RefCount: + return new DeviceResourceGraphRefCountMap(this._refCounts) as DeviceResourceGraphComponentPropertyMap[T]; + default: + throw Error('component map not found'); + } + } + getName (v: number): string { + return this._names[v]; + } + getRefCount (v: number): number { + return this._refCounts[v]; + } + //----------------------------------------------------------------- + // PolymorphicGraph + holds (id: DeviceResourceGraphValue, v: number): boolean { + return this._vertices[v]._id === id; + } + id (v: number): DeviceResourceGraphValue { + return this._vertices[v]._id; + } + object (v: number): DeviceResourceGraphObject { + return this._vertices[v]._object; + } + value (id: T, v: number): DeviceResourceGraphValueType[T] { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as DeviceResourceGraphValueType[T]; + } else { + throw Error('value id not match'); + } + } + tryValue (id: T, v: number): DeviceResourceGraphValueType[T] | null { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as DeviceResourceGraphValueType[T]; + } else { + return null; + } + } + visitVertex (visitor: DeviceResourceGraphVisitor, v: number): unknown { + const vert = this._vertices[v]; + switch (vert._id) { + case DeviceResourceGraphValue.Buffer: + return visitor.buffer(vert._object as Buffer); + case DeviceResourceGraphValue.Texture: + return visitor.texture(vert._object as Texture); + default: + throw Error('polymorphic type not found'); + } + } + getBuffer (v: number): Buffer { + if (this._vertices[v]._id === DeviceResourceGraphValue.Buffer) { + return this._vertices[v]._object as Buffer; + } else { + throw Error('value id not match'); + } + } + getTexture (v: number): Texture { + if (this._vertices[v]._id === DeviceResourceGraphValue.Texture) { + return this._vertices[v]._object as Texture; + } else { + throw Error('value id not match'); + } + } + tryGetBuffer (v: number): Buffer | null { + if (this._vertices[v]._id === DeviceResourceGraphValue.Buffer) { + return this._vertices[v]._object as Buffer; + } else { + return null; + } + } + tryGetTexture (v: number): Texture | null { + if (this._vertices[v]._id === DeviceResourceGraphValue.Texture) { + return this._vertices[v]._object as Texture; + } else { + return null; + } + } + + readonly components: string[] = ['Name', 'RefCount']; + readonly _vertices: DeviceResourceGraphVertex[] = []; + readonly _names: string[] = []; + readonly _refCounts: number[] = []; +} diff --git a/cocos/core/pipeline/custom/graph.ts b/cocos/core/pipeline/custom/graph.ts new file mode 100644 index 0000000000..ecde48f198 --- /dev/null +++ b/cocos/core/pipeline/custom/graph.ts @@ -0,0 +1,512 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +export const enum directional { + undirected = 0, + directed = 1, + bidirectional = 2, +} + +export const enum parallel { + disallow = 0, + allow = 1, +} + +export const enum traversal { + none = 0, + incidence = 1 << 0, + bidirectional = 1 << 1, + adjacency = 1 << 2, + vertex_list = 1 << 3, + edge_list = 1 << 4, +} + +//-------------------------------------------------------------------------- +// Vertex +//-------------------------------------------------------------------------- +export interface Vertex { + nullVertex (): Vertex | null; +} + +//-------------------------------------------------------------------------- +// Vertex Descriptor +//-------------------------------------------------------------------------- +export type vertex_descriptor = number | Vertex; + +//-------------------------------------------------------------------------- +// Edge +//-------------------------------------------------------------------------- +export interface Edge { + getProperty (): unknown; + source: vertex_descriptor; + target: vertex_descriptor; +} + +//-------------------------------------------------------------------------- +// Edge Descriptor +//-------------------------------------------------------------------------- +export class ED { + constructor (source: vertex_descriptor, target: vertex_descriptor) { + this.source = source; + this.target = target; + } + equals (rhs: ED): boolean { + return this.source === rhs.source + && this.target === rhs.target; + } + source: vertex_descriptor; + target: vertex_descriptor; +} + +// Edge Descriptor with Property +export class EPD { + constructor (source: vertex_descriptor, target: vertex_descriptor, edge: Edge) { + this.source = source; + this.target = target; + this.edge = edge; + } + equals (rhs: EPD): boolean { + return this.edge === rhs.edge; + } + source: vertex_descriptor; + target: vertex_descriptor; + readonly edge: Edge; +} + +// Edge Descriptor +export type edge_descriptor = ED | EPD; + +//-------------------------------------------------------------------------- +// OutEdge +//-------------------------------------------------------------------------- +// OutEdge +export class OutE { + constructor (target: vertex_descriptor) { + this.target = target; + } + equals (rhs: OutE): boolean { + return this.target === rhs.target; + } + target: vertex_descriptor; +} + +// OutEdge(Property) +export class OutEP { + constructor (target: vertex_descriptor, edge: Edge) { + this.target = target; + this.edge = edge; + } + equals (rhs: OutEP): boolean { + return this.target === rhs.target; + } + getProperty (): unknown { + return this.edge.getProperty(); + } + target: vertex_descriptor; + readonly edge: Edge; +} + +//-------------------------------------------------------------------------- +// OutEdge Iterator +//-------------------------------------------------------------------------- +export class OutEI implements IterableIterator { + constructor (iterator: IterableIterator, source: vertex_descriptor) { + this.iterator = iterator; + this.source = source; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: new ED(this.source, res.value.target), done: false }; + } + } + readonly iterator: IterableIterator; + readonly source: vertex_descriptor; +} + +// OutEdge(Property) Iterator +export class OutEPI implements IterableIterator { + constructor (iterator: IterableIterator, source: vertex_descriptor) { + this.iterator = iterator; + this.source = source; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: new EPD(this.source, res.value.target, res.value.edge), done: false }; + } + } + readonly iterator: IterableIterator; + readonly source: vertex_descriptor; +} + +// OutEdge Iterator +export type out_edge_iterator = OutEI | OutEPI; + +//-------------------------------------------------------------------------- +// InEdge Iterator +//-------------------------------------------------------------------------- +// InEdge Iterator +export class InEI implements IterableIterator { + constructor (iterator: IterableIterator, source: vertex_descriptor) { + this.iterator = iterator; + this.source = source; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: new ED(res.value.target, this.source), done: false }; + } + } + readonly iterator: IterableIterator; + readonly source: vertex_descriptor; +} + +// InEdge(Property) Iterator +export class InEPI implements IterableIterator { + constructor (iterator: IterableIterator, source: vertex_descriptor) { + this.iterator = iterator; + this.source = source; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: new EPD(res.value.target, this.source, res.value.edge), done: false }; + } + } + readonly iterator: IterableIterator; + readonly source: vertex_descriptor; +} + +// InEdge Iterator +export type in_edge_iterator = InEI | InEPI; + +//-------------------------------------------------------------------------- +// Graph +//-------------------------------------------------------------------------- +export interface Graph { + readonly directed_category: directional; + readonly edge_parallel_category: parallel; + readonly traversal_category: traversal; + + nullVertex (): vertex_descriptor | null; +} + +//-------------------------------------------------------------------------- +// IncidenceGraph +//-------------------------------------------------------------------------- +export interface IncidenceGraph extends Graph { + edge (u: vertex_descriptor, v: vertex_descriptor): boolean; + source (e: edge_descriptor): vertex_descriptor; + target (e: edge_descriptor): vertex_descriptor; + outEdges (v: vertex_descriptor): out_edge_iterator; + outDegree (v: vertex_descriptor): number; +} + +//-------------------------------------------------------------------------- +// BidirectionalGraph +//-------------------------------------------------------------------------- +export interface BidirectionalGraph extends IncidenceGraph { + inEdges (v: vertex_descriptor): in_edge_iterator; + inDegree (v: vertex_descriptor): number; + degree (v: vertex_descriptor) : number; +} + +//-------------------------------------------------------------------------- +// AdjacencyGraph +//-------------------------------------------------------------------------- +// Adjacency Iterator +export class AdjI implements IterableIterator { + constructor (graph: IncidenceGraph, iterator: OutEI) { + this.graph = graph; + this.iterator = iterator; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: this.graph.target(res.value), done: false }; + } + } + readonly graph: IncidenceGraph; + readonly iterator: OutEI; +} + +export class AdjPI implements IterableIterator { + constructor (graph: IncidenceGraph, iterator: OutEPI) { + this.graph = graph; + this.iterator = iterator; + } + [Symbol.iterator] () { + return this; + } + next (): IteratorResult { + const res = this.iterator.next(); + if (res.done) { + return { value: undefined, done: true }; + } else { + return { value: this.graph.target(res.value), done: false }; + } + } + readonly graph: IncidenceGraph; + readonly iterator: OutEPI; +} + +// Adjacency Iterator +export type adjacency_iterator = AdjI | AdjPI; + +// AdjacencyGraph +export interface AdjacencyGraph extends Graph { + adjacentVertices (v: vertex_descriptor): adjacency_iterator; +} + +//-------------------------------------------------------------------------- +// VertexListGraph +//-------------------------------------------------------------------------- +export interface VertexListGraph extends Graph { + vertices (): IterableIterator; + numVertices (): number; +} + +//-------------------------------------------------------------------------- +// EdgeListGraph +//-------------------------------------------------------------------------- +export interface EdgeListGraph extends Graph { + edges (): IterableIterator; + numEdges (): number; + source (e: edge_descriptor): vertex_descriptor; + target (e: edge_descriptor): vertex_descriptor; +} + +//-------------------------------------------------------------------------- +// MutableGraph +//-------------------------------------------------------------------------- +export interface MutableGraph extends Graph { + addVertex (...args): vertex_descriptor; + clearVertex (v: vertex_descriptor): void; + removeVertex (v: vertex_descriptor): void; + addEdge (u: vertex_descriptor, v: vertex_descriptor, p?: unknown): edge_descriptor | null; + removeEdges (u: vertex_descriptor, v: vertex_descriptor): void; + removeEdge (e: edge_descriptor): void; +} + +//-------------------------------------------------------------------------- +// PropertyMap +//-------------------------------------------------------------------------- +export interface PropertyMap { + get (x: vertex_descriptor | edge_descriptor): unknown; +} + +//-------------------------------------------------------------------------- +// PropertyGraph +//-------------------------------------------------------------------------- +export interface PropertyGraph extends Graph { + get (tag: string): PropertyMap; +} + +//-------------------------------------------------------------------------- +// NamedGraph +//-------------------------------------------------------------------------- +export interface NamedGraph extends Graph { + vertexName (v: vertex_descriptor): string; + vertexNameMap (): PropertyMap; +} + +//-------------------------------------------------------------------------- +// ComponentGraph +//-------------------------------------------------------------------------- +export interface ComponentGraph extends Graph { + readonly components: string[]; + component (id: number, v: vertex_descriptor): unknown; + componentMap (id: number): unknown; // should be PropertyMap +} + +//-------------------------------------------------------------------------- +// PolymorphicGraph +//-------------------------------------------------------------------------- +export interface PolymorphicGraph extends Graph { + holds (id: number, v: vertex_descriptor): boolean; + id (v: vertex_descriptor): number; + object (v: vertex_descriptor): unknown; + value (id: number, v: vertex_descriptor): unknown; + tryValue(id: number, v: vertex_descriptor): unknown; + visitVertex (visitor: unknown, v: vertex_descriptor): void; +} + +//-------------------------------------------------------------------------- +// ReferenceGraph +//-------------------------------------------------------------------------- +export type reference_descriptor = ED | EPD; +export type child_iterator = OutEI | OutEPI; +export type parent_iterator = InEI | InEPI; + +export interface ReferenceGraph extends Graph { + reference (u: vertex_descriptor, v: vertex_descriptor): boolean; + parent (e: reference_descriptor): vertex_descriptor; + child (e: reference_descriptor): vertex_descriptor; + parents (v: vertex_descriptor): parent_iterator; + children (v: vertex_descriptor): child_iterator; + numParents (v: vertex_descriptor): number; + numChildren (v: vertex_descriptor): number; + getParent (v: vertex_descriptor): vertex_descriptor | null; + isAncestor (ancestor: vertex_descriptor, descendent: vertex_descriptor): boolean; +} + +//-------------------------------------------------------------------------- +// MutableReferenceGraph +//-------------------------------------------------------------------------- +export interface MutableReferenceGraph extends ReferenceGraph { + addReference (u: vertex_descriptor, v: vertex_descriptor, p?: unknown): reference_descriptor | null; + removeReference (e: reference_descriptor): void; + removeReferences (u: vertex_descriptor, v: vertex_descriptor): void; +} + +//-------------------------------------------------------------------------- +// ParentGraph +//-------------------------------------------------------------------------- +export interface ParentGraph extends ReferenceGraph, NamedGraph { + locateChild (v: vertex_descriptor | null, name: string): vertex_descriptor | null; +} + +//-------------------------------------------------------------------------- +// AddressableGraph +//-------------------------------------------------------------------------- +export interface AddressableGraph extends ParentGraph { + contains (absPath: string): boolean; + locate (absPath: string): vertex_descriptor | null; + locateRelative (path: string, start?: vertex_descriptor | null): vertex_descriptor | null; + path (v: vertex_descriptor) : string; +} + +//-------------------------------------------------------------------------- +// Help Functions +//-------------------------------------------------------------------------- +export function reindexEdgeList (el: (OutE|OutEP)[], u: number): void { + for (const e of el) { + if (e.target as number > u) { + --(e.target as number); + } + } +} + +export function removeAllEdgesFromList (edges: Set, el: OutEP[], v: vertex_descriptor): void { + const sz = el.length; + for (let i = 0; i !== sz; ++i) { + const oe = el[i]; + if (oe.target === v) { + // NOTE: Wihtout this skip, this loop will double-delete + // properties of loop edges. This solution is based on the + // observation that the incidence edges of a vertex with a loop + // are adjacent in the out edge list. This *may* actually hold + // for multisets also. + const skip = (i + 1 !== sz && oe.edge === el[i + 1].edge); + edges.delete(oe.edge); + if (skip) { + ++i; + } + } + } +} + +export function getPath (g: ReferenceGraph & NamedGraph, v: vertex_descriptor | null): string { + if (v === g.nullVertex()) { + return ''; + } + const paths: string[] = []; + for (; v !== g.nullVertex(); v = g.getParent(v as vertex_descriptor)) { + paths.push(g.vertexName(v as vertex_descriptor)); + } + let path = ''; + for (let i = paths.length; i-- > 0;) { + path += '/'; + path += paths[i]; + } + return path; +} + +export function findRelative (g: ParentGraph, v: vertex_descriptor | null, path: string): vertex_descriptor | null { + const pseudo = g.nullVertex(); + const names = path.split('/'); + + if (names.length === 0) { // empty string + return v; + } + + let curr = v; + let start = 0; + if (names[0] === '') { // absolute path + // reset v to pseudo root + curr = pseudo; + // skip pseudo root + ++start; + } + // locating begins + for (let i = start; i !== names.length; ++i) { + const name = names[i]; + if (name === '') { // empty name, do nothing + continue; + } + if (name === '.') { // current node, do nothing + continue; + } + if (name === '..') { // parent node + if (curr === pseudo) { + // current node is pseudo already, return not found + return pseudo; + } + curr = g.getParent(curr as vertex_descriptor); + continue; + } + curr = g.locateChild(curr, name); + if (curr === pseudo) { // child not found + return pseudo; + } + } + return curr; +} diff --git a/cocos/core/pipeline/custom/layout-graph.ts b/cocos/core/pipeline/custom/layout-graph.ts new file mode 100644 index 0000000000..e42065cd1c --- /dev/null +++ b/cocos/core/pipeline/custom/layout-graph.ts @@ -0,0 +1,621 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +/* eslint-disable max-len */ +import * as impl from './graph'; +import { NodeType, ParameterType, UpdateFrequency, ValueType } from './types'; + +export class Constant { + type: ValueType = ValueType.Typeless; + valueID = 0xFFFFFFFF; +} + +export class ConstantBuffer { + size = 0; + constants: Constant[] = []; +} + +export const enum DescriptorType { + CBuffer, + RWBuffer, + RWTexture, + Buffer, + Texture, + Sampler, +} + +export class DescriptorBlock { + type: DescriptorType = DescriptorType.CBuffer; + capacity = 0; + attributeIDs: Uint32Array = new Uint32Array(0); +} + +export class DescriptorArray { + capacity = 0; + attributeID = 0xFFFFFFFF; +} + +export class UnboundedDescriptor { + type: DescriptorType = DescriptorType.CBuffer; + descriptors: DescriptorArray[] = []; +} + +export class DescriptorTable { + slot = 0; + capacity = 0; + blocks: DescriptorBlock[] = []; +} + +export class DescriptorSet { + tables: DescriptorTable[] = []; + unbounded: UnboundedDescriptor = new UnboundedDescriptor(); +} + +export class LayoutData { + constantBuffers: Map = new Map(); + descriptorSets: Map = new Map(); +} + +export class ShaderProgramData { + layouts: Map = new Map(); +} + +export class GroupNodeData { + constructor (nodeType: NodeType = NodeType.INTERNAL) { + this.nodeType = nodeType; + } + nodeType: NodeType; +} + +export class ShaderNodeData { + rootSignature = ''; + shaderPrograms: ShaderProgramData[] = []; + shaderIndex: Map = new Map(); +} + +//================================================================= +// LayoutGraphData +//================================================================= +// PolymorphicGraph Concept +export const enum LayoutGraphDataValue { + Group, + Shader, +} + +interface LayoutGraphDataValueType { + [LayoutGraphDataValue.Group]: GroupNodeData + [LayoutGraphDataValue.Shader]: ShaderNodeData +} + +export interface LayoutGraphDataVisitor { + group(value: GroupNodeData): unknown; + shader(value: ShaderNodeData): unknown; +} + +type LayoutGraphDataObject = GroupNodeData | ShaderNodeData; + +//----------------------------------------------------------------- +// Graph Concept +export class LayoutGraphDataVertex { + constructor ( + readonly id: LayoutGraphDataValue, + readonly object: LayoutGraphDataObject, + ) { + this._id = id; + this._object = object; + } + readonly _outEdges: impl.OutE[] = []; + readonly _inEdges: impl.OutE[] = []; + readonly _id: LayoutGraphDataValue; + readonly _object: LayoutGraphDataObject; +} + +//----------------------------------------------------------------- +// PropertyGraph Concept +export class LayoutGraphDataNameMap implements impl.PropertyMap { + constructor (readonly names: string[]) { + this._names = names; + } + get (v: number): string { + return this._names[v]; + } + readonly _names: string[]; +} + +export class LayoutGraphDataUpdateMap implements impl.PropertyMap { + constructor (readonly updateFrequencies: UpdateFrequency[]) { + this._updateFrequencies = updateFrequencies; + } + get (v: number): UpdateFrequency { + return this._updateFrequencies[v]; + } + readonly _updateFrequencies: UpdateFrequency[]; +} + +export class LayoutGraphDataLayoutMap implements impl.PropertyMap { + constructor (readonly layouts: LayoutData[]) { + this._layouts = layouts; + } + get (v: number): LayoutData { + return this._layouts[v]; + } + readonly _layouts: LayoutData[]; +} + +//----------------------------------------------------------------- +// ComponentGraph Concept +export const enum LayoutGraphDataComponent { + Name, + Update, + Layout, +} + +interface LayoutGraphDataComponentType { + [LayoutGraphDataComponent.Name]: string; + [LayoutGraphDataComponent.Update]: UpdateFrequency; + [LayoutGraphDataComponent.Layout]: LayoutData; +} + +interface LayoutGraphDataComponentPropertyMap { + [LayoutGraphDataComponent.Name]: LayoutGraphDataNameMap; + [LayoutGraphDataComponent.Update]: LayoutGraphDataUpdateMap; + [LayoutGraphDataComponent.Layout]: LayoutGraphDataLayoutMap; +} + +//----------------------------------------------------------------- +// LayoutGraphData Implementation +export class LayoutGraphData implements impl.BidirectionalGraph +, impl.AdjacencyGraph +, impl.VertexListGraph +, impl.MutableGraph +, impl.PropertyGraph +, impl.NamedGraph +, impl.ComponentGraph +, impl.PolymorphicGraph +, impl.ReferenceGraph +, impl.MutableReferenceGraph +, impl.AddressableGraph { + //----------------------------------------------------------------- + // Graph + // type vertex_descriptor = number; + nullVertex (): number { return 0xFFFFFFFF; } + // type edge_descriptor = impl.ED; + readonly directed_category: impl.directional = impl.directional.bidirectional; + readonly edge_parallel_category: impl.parallel = impl.parallel.allow; + readonly traversal_category: impl.traversal = impl.traversal.incidence + | impl.traversal.bidirectional + | impl.traversal.adjacency + | impl.traversal.vertex_list; + //----------------------------------------------------------------- + // IncidenceGraph + // type out_edge_iterator = impl.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: impl.ED): number { + return e.source as number; + } + target (e: impl.ED): number { + return e.target as number; + } + outEdges (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + outDegree (v: number): number { + return this._vertices[v]._outEdges.length; + } + //----------------------------------------------------------------- + // BidirectionalGraph + // type in_edge_iterator = impl.InEI; + inEdges (v: number): impl.InEI { + return new impl.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 = impl.AdjI; + adjacentVertices (v: number): impl.AdjI { + return new impl.AdjI(this, this.outEdges(v)); + } + //----------------------------------------------------------------- + // VertexListGraph + vertices (): IterableIterator { + return this._vertices.keys(); + } + numVertices (): number { + return this._vertices.length; + } + //----------------------------------------------------------------- + // MutableGraph + addVertex ( + id: LayoutGraphDataValue, + object: LayoutGraphDataValueType[T], + name: string, + update: UpdateFrequency, + layout: LayoutData, + u = 0xFFFFFFFF, + ): number { + const vert = new LayoutGraphDataVertex(id, object); + const v = this._vertices.length; + this._vertices.push(vert); + this._names.push(name); + this._updateFrequencies.push(update); + this._layouts.push(layout); + + // ReferenceGraph + if (u !== 0xFFFFFFFF) { + this.addEdge(u, v); + } + + return v; + } + clearVertex (v: number): void { + // ReferenceGraph(Alias) + 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._updateFrequencies.splice(u, 1); + this._layouts.splice(u, 1); + + const sz = this._vertices.length; + if (u === sz) { + return; + } + + for (let v = 0; v !== sz; ++v) { + const vert = this._vertices[v]; + impl.reindexEdgeList(vert._outEdges, u); + impl.reindexEdgeList(vert._inEdges, u); + } + } + addEdge (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._outEdges.push(new impl.OutE(v)); + this._vertices[v]._inEdges.push(new impl.OutE(u)); + return new impl.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: impl.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 (): LayoutGraphDataNameMap { + return new LayoutGraphDataNameMap(this._names); + } + //----------------------------------------------------------------- + // PropertyGraph + get (tag: string): LayoutGraphDataNameMap | LayoutGraphDataUpdateMap | LayoutGraphDataLayoutMap { + switch (tag) { + // Components + case 'Name': + return new LayoutGraphDataNameMap(this._names); + case 'Update': + return new LayoutGraphDataUpdateMap(this._updateFrequencies); + case 'Layout': + return new LayoutGraphDataLayoutMap(this._layouts); + default: + throw Error('property map not found'); + } + } + //----------------------------------------------------------------- + // ComponentGraph + component (id: T, v: number): LayoutGraphDataComponentType[T] { + switch (id) { + case LayoutGraphDataComponent.Name: + return this._names[v] as LayoutGraphDataComponentType[T]; + case LayoutGraphDataComponent.Update: + return this._updateFrequencies[v] as LayoutGraphDataComponentType[T]; + case LayoutGraphDataComponent.Layout: + return this._layouts[v] as LayoutGraphDataComponentType[T]; + default: + throw Error('component not found'); + } + } + componentMap (id: T): LayoutGraphDataComponentPropertyMap[T] { + switch (id) { + case LayoutGraphDataComponent.Name: + return new LayoutGraphDataNameMap(this._names) as LayoutGraphDataComponentPropertyMap[T]; + case LayoutGraphDataComponent.Update: + return new LayoutGraphDataUpdateMap(this._updateFrequencies) as LayoutGraphDataComponentPropertyMap[T]; + case LayoutGraphDataComponent.Layout: + return new LayoutGraphDataLayoutMap(this._layouts) as LayoutGraphDataComponentPropertyMap[T]; + default: + throw Error('component map not found'); + } + } + getName (v: number): string { + return this._names[v]; + } + getUpdate (v: number): UpdateFrequency { + return this._updateFrequencies[v]; + } + getLayout (v: number): LayoutData { + return this._layouts[v]; + } + //----------------------------------------------------------------- + // PolymorphicGraph + holds (id: LayoutGraphDataValue, v: number): boolean { + return this._vertices[v]._id === id; + } + id (v: number): LayoutGraphDataValue { + return this._vertices[v]._id; + } + object (v: number): LayoutGraphDataObject { + return this._vertices[v]._object; + } + value (id: T, v: number): LayoutGraphDataValueType[T] { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as LayoutGraphDataValueType[T]; + } else { + throw Error('value id not match'); + } + } + tryValue (id: T, v: number): LayoutGraphDataValueType[T] | null { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as LayoutGraphDataValueType[T]; + } else { + return null; + } + } + visitVertex (visitor: LayoutGraphDataVisitor, v: number): unknown { + const vert = this._vertices[v]; + switch (vert._id) { + case LayoutGraphDataValue.Group: + return visitor.group(vert._object as GroupNodeData); + case LayoutGraphDataValue.Shader: + return visitor.shader(vert._object as ShaderNodeData); + default: + throw Error('polymorphic type not found'); + } + } + getGroup (v: number): GroupNodeData { + if (this._vertices[v]._id === LayoutGraphDataValue.Group) { + return this._vertices[v]._object as GroupNodeData; + } else { + throw Error('value id not match'); + } + } + getShader (v: number): ShaderNodeData { + if (this._vertices[v]._id === LayoutGraphDataValue.Shader) { + return this._vertices[v]._object as ShaderNodeData; + } else { + throw Error('value id not match'); + } + } + tryGetGroup (v: number): GroupNodeData | null { + if (this._vertices[v]._id === LayoutGraphDataValue.Group) { + return this._vertices[v]._object as GroupNodeData; + } else { + return null; + } + } + tryGetShader (v: number): ShaderNodeData | null { + if (this._vertices[v]._id === LayoutGraphDataValue.Shader) { + return this._vertices[v]._object as ShaderNodeData; + } else { + return null; + } + } + //----------------------------------------------------------------- + // ReferenceGraph + // type reference_descriptor = impl.ED; + // type child_iterator = impl.OutEI; + // type parent_iterator = impl.InEI; + reference (u: number, v: number): boolean { + for (const oe of this._vertices[u]._outEdges) { + if (v === oe.target as number) { + return true; + } + } + return false; + } + parent (e: impl.ED): number { + return e.source as number; + } + child (e: impl.ED): number { + return e.target as number; + } + parents (v: number): impl.InEI { + return new impl.InEI(this._vertices[v]._inEdges.values(), v); + } + children (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + numParents (v: number): number { + return this._vertices[v]._inEdges.length; + } + numChildren (v: number): number { + return this._vertices[v]._outEdges.length; + } + getParent (v: number): number { + if (v === 0xFFFFFFFF) { + return 0xFFFFFFFF; + } + const list = this._vertices[v]._inEdges; + if (list.length === 0) { + return 0xFFFFFFFF; + } else { + return list[0].target as number; + } + } + isAncestor (ancestor: number, descendent: number): boolean { + const pseudo = 0xFFFFFFFF; + if (ancestor === descendent) { + // when ancestor === descendent, is_ancestor is defined as false + return false; + } + if (ancestor === pseudo) { + // special case: pseudo root is always ancestor + return true; + } + if (descendent === pseudo) { + // special case: pseudo root is never descendent + return false; + } + for (let parent = this.getParent(descendent); parent !== pseudo;) { + if (ancestor === parent) { + return true; + } + parent = this.getParent(parent); + } + return false; + } + //----------------------------------------------------------------- + // MutableReferenceGraph + addReference (u: number, v: number): impl.ED | null { + return this.addEdge(u, v); + } + removeReference (e: impl.ED): void { + return this.removeEdge(e); + } + removeReferences (u: number, v: number): void { + return this.removeEdges(u, v); + } + //----------------------------------------------------------------- + // ParentGraph + locateChild (u: number, name: string): number { + if (u === 0xFFFFFFFF) { + for (const v of this._vertices.keys()) { + const vert = this._vertices[v]; + if (vert._inEdges.length === 0 && this._names[v] === name) { + return v; + } + } + return 0xFFFFFFFF; + } + for (const oe of this._vertices[u]._outEdges) { + const child = oe.target as number; + if (name === this._names[child]) { + return child; + } + } + return 0xFFFFFFFF; + } + //----------------------------------------------------------------- + // AddressableGraph + contains (absPath: string): boolean { + return impl.findRelative(this, 0xFFFFFFFF, absPath) as number !== 0xFFFFFFFF; + } + locate (absPath: string): number { + return impl.findRelative(this, 0xFFFFFFFF, absPath) as number; + } + locateRelative (path: string, start = 0xFFFFFFFF): number { + return impl.findRelative(this, start, path) as number; + } + path (v: number): string { + return impl.getPath(this, v); + } + + readonly components: string[] = ['Name', 'Update', 'Layout']; + readonly _vertices: LayoutGraphDataVertex[] = []; + readonly _names: string[] = []; + readonly _updateFrequencies: UpdateFrequency[] = []; + readonly _layouts: LayoutData[] = []; +} diff --git a/cocos/core/pipeline/custom/pipeline.ts b/cocos/core/pipeline/custom/pipeline.ts new file mode 100644 index 0000000000..dc51da61ef --- /dev/null +++ b/cocos/core/pipeline/custom/pipeline.ts @@ -0,0 +1,113 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +/* eslint-disable max-len */ +import { EffectAsset } from '../../assets'; +import { Camera } from '../../renderer/scene/camera'; +import { Buffer, Format, Sampler, Texture } from '../../gfx/index'; +import { Color, Mat4, Quat, Vec2, Vec4 } from '../../math'; +import { PipelineSceneData } from '../pipeline-scene-data'; +import { QueueHint } from './types'; +import { ComputeView, CopyPair, MovePair, RasterView } from './render-graph'; + +export abstract class DescriptorHierarchy { + public abstract addEffect(asset: EffectAsset): void; +} + +export abstract class Setter { + public abstract setMat4(name: string, mat: Mat4): void; + public abstract setQuaternion(name: string, quat: Quat): void; + public abstract setColor(name: string, color: Color): void; + public abstract setVec4(name: string, vec: Vec4): void; + public abstract setVec2(name: string, vec: Vec2): void; + public abstract setFloat(name: string, v: number): void; + public abstract setBuffer(name: string, buffer: Buffer): void; + public abstract setTexture(name: string, texture: Texture): void; + public abstract setReadWriteBuffer(name: string, buffer: Buffer): void; + public abstract setReadWriteTexture(name: string, texture: Texture): void; + public abstract setSampler(name: string, sampler: Sampler): void; +} + +export abstract class RasterQueueBuilder { + public abstract addSceneOfCamera(camera: Camera, name: string): void; + public abstract addSceneOfCamera(camera: Camera): void; + public abstract addScene(name: string): void; + public abstract addFullscreenQuad(shader: string, name: string): void; + public abstract addFullscreenQuad(shader: string): void; +} + +export abstract class RasterPassBuilder { + public abstract addRasterView(name: string, view: RasterView): void; + public abstract addComputeView(name: string, view: ComputeView): void; + public abstract addQueue(hint: QueueHint, layoutName: string, name: string): RasterQueueBuilder; + public abstract addQueue(hint: QueueHint, layoutName: string): RasterQueueBuilder; + public abstract addQueue(hint: QueueHint): RasterQueueBuilder; + public abstract addFullscreenQuad(shader: string, layoutName: string, name: string): void; + public abstract addFullscreenQuad(shader: string, layoutName: string): void; + public abstract addFullscreenQuad(shader: string): void; +} + +export abstract class ComputeQueueBuilder { + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number, layoutName: string, name: string): void; + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number, layoutName: string): void; + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number): void; +} + +export abstract class ComputePassBuilder { + public abstract addComputeView(name: string, view: ComputeView): void; + public abstract addQueue(layoutName: string, name: string): ComputeQueueBuilder; + public abstract addQueue(layoutName: string): ComputeQueueBuilder; + public abstract addQueue(): ComputeQueueBuilder; + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number, layoutName: string, name: string): void; + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number, layoutName: string): void; + public abstract addDispatch(shader: string, threadGroupCountX: number, threadGroupCountY: number, threadGroupCountZ: number): void; +} + +export abstract class MovePassBuilder { + public abstract addPair(pair: MovePair): void; +} + +export abstract class CopyPassBuilder { + public abstract addPair(pair: CopyPair): void; +} + +export abstract class Pipeline { + public abstract addRenderTexture(name: string, format: Format, width: number, height: number): number; + public abstract addRenderTarget(name: string, format: Format, width: number, height: number): number; + public abstract addDepthStencil(name: string, format: Format, width: number, height: number): number; + public abstract beginFrame(pplScene: PipelineSceneData): void; + public abstract endFrame(): void; + public abstract addRasterPass(width: number, height: number, layoutName: string, name: string): RasterPassBuilder; + public abstract addRasterPass(width: number, height: number, layoutName: string): RasterPassBuilder; + public abstract addComputePass(layoutName: string, name: string): ComputePassBuilder; + public abstract addComputePass(layoutName: string): ComputePassBuilder; + public abstract addMovePass(name: string): MovePassBuilder; + public abstract addCopyPass(name: string): CopyPassBuilder; +} diff --git a/cocos/core/pipeline/custom/render-graph.ts b/cocos/core/pipeline/custom/render-graph.ts new file mode 100644 index 0000000000..232ca50b00 --- /dev/null +++ b/cocos/core/pipeline/custom/render-graph.ts @@ -0,0 +1,1574 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +/* eslint-disable max-len */ +import * as impl from './graph'; +import { Camera } from '../../renderer/scene/camera'; +import { Buffer, ClearFlagBit, Color, Format, LoadOp, SampleCount, Sampler, StoreOp, Texture } from '../../gfx/index'; +import { QueueHint, ResourceDimension, ResourceResidency } from './types'; + +export const enum ResourceFlags { + NONE = 0, + ALLOW_RENDER_TARGET = 0x1, + ALLOW_DEPTH_STENCIL = 0x2, + ALLOW_UNORDERED_ACCESS = 0x4, + DENY_SHADER_RESOURCE = 0x8, + ALLOW_CROSS_ADAPTER = 0x10, + ALLOW_SIMULTANEOUS_ACCESS = 0x20, + VIDEO_DECODE_REFERENCE_ONLY = 0x40, +} + +export const enum TextureLayout { + UNKNOWN, + ROW_MAJOR, + UNDEFINED_SWIZZLE, + STANDARD_SWIZZLE, +} + +export class ResourceDesc { + dimension: ResourceDimension = ResourceDimension.BUFFER; + alignment = 0; + width = 0; + height = 0; + depthOrArraySize = 0; + mipLevels = 0; + format: Format = Format.UNKNOWN; + sampleCount: SampleCount = SampleCount.ONE; + layout: TextureLayout = TextureLayout.UNKNOWN; + flags: ResourceFlags = ResourceFlags.NONE; +} + +export class ResourceTraits { + constructor (residency: ResourceResidency = ResourceResidency.Managed) { + this.residency = residency; + } + residency: ResourceResidency; +} + +//================================================================= +// ResourceGraph +//================================================================= +// Graph Concept +export class ResourceGraphVertex { + constructor () { + } + readonly _outEdges: impl.OutE[] = []; + readonly _inEdges: impl.OutE[] = []; +} + +//----------------------------------------------------------------- +// PropertyGraph Concept +export class ResourceGraphNameMap implements impl.PropertyMap { + constructor (readonly names: string[]) { + this._names = names; + } + get (v: number): string { + return this._names[v]; + } + readonly _names: string[]; +} + +export class ResourceGraphDescMap implements impl.PropertyMap { + constructor (readonly descs: ResourceDesc[]) { + this._descs = descs; + } + get (v: number): ResourceDesc { + return this._descs[v]; + } + readonly _descs: ResourceDesc[]; +} + +export class ResourceGraphTraitsMap implements impl.PropertyMap { + constructor (readonly traits: ResourceTraits[]) { + this._traits = traits; + } + get (v: number): ResourceTraits { + return this._traits[v]; + } + readonly _traits: ResourceTraits[]; +} + +//----------------------------------------------------------------- +// ComponentGraph Concept +export const enum ResourceGraphComponent { + Name, + Desc, + Traits, +} + +interface ResourceGraphComponentType { + [ResourceGraphComponent.Name]: string; + [ResourceGraphComponent.Desc]: ResourceDesc; + [ResourceGraphComponent.Traits]: ResourceTraits; +} + +interface ResourceGraphComponentPropertyMap { + [ResourceGraphComponent.Name]: ResourceGraphNameMap; + [ResourceGraphComponent.Desc]: ResourceGraphDescMap; + [ResourceGraphComponent.Traits]: ResourceGraphTraitsMap; +} + +//----------------------------------------------------------------- +// ResourceGraph Implementation +export class ResourceGraph implements impl.BidirectionalGraph +, impl.AdjacencyGraph +, impl.VertexListGraph +, impl.MutableGraph +, impl.PropertyGraph +, impl.NamedGraph +, impl.ComponentGraph { + //----------------------------------------------------------------- + // Graph + // type vertex_descriptor = number; + nullVertex (): number { return 0xFFFFFFFF; } + // type edge_descriptor = impl.ED; + readonly directed_category: impl.directional = impl.directional.bidirectional; + readonly edge_parallel_category: impl.parallel = impl.parallel.allow; + readonly traversal_category: impl.traversal = impl.traversal.incidence + | impl.traversal.bidirectional + | impl.traversal.adjacency + | impl.traversal.vertex_list; + //----------------------------------------------------------------- + // IncidenceGraph + // type out_edge_iterator = impl.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: impl.ED): number { + return e.source as number; + } + target (e: impl.ED): number { + return e.target as number; + } + outEdges (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + outDegree (v: number): number { + return this._vertices[v]._outEdges.length; + } + //----------------------------------------------------------------- + // BidirectionalGraph + // type in_edge_iterator = impl.InEI; + inEdges (v: number): impl.InEI { + return new impl.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 = impl.AdjI; + adjacentVertices (v: number): impl.AdjI { + return new impl.AdjI(this, this.outEdges(v)); + } + //----------------------------------------------------------------- + // VertexListGraph + vertices (): IterableIterator { + return this._vertices.keys(); + } + numVertices (): number { + return this._vertices.length; + } + //----------------------------------------------------------------- + // MutableGraph + addVertex ( + name: string, + desc: ResourceDesc, + traits: ResourceTraits, + ): number { + const vert = new ResourceGraphVertex(); + const v = this._vertices.length; + this._vertices.push(vert); + this._names.push(name); + this._descs.push(desc); + this._traits.push(traits); + 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._descs.splice(u, 1); + this._traits.splice(u, 1); + + const sz = this._vertices.length; + if (u === sz) { + return; + } + + for (let v = 0; v !== sz; ++v) { + const vert = this._vertices[v]; + impl.reindexEdgeList(vert._outEdges, u); + impl.reindexEdgeList(vert._inEdges, u); + } + } + addEdge (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._outEdges.push(new impl.OutE(v)); + this._vertices[v]._inEdges.push(new impl.OutE(u)); + return new impl.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: impl.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 (): ResourceGraphNameMap { + return new ResourceGraphNameMap(this._names); + } + //----------------------------------------------------------------- + // PropertyGraph + get (tag: string): ResourceGraphNameMap | ResourceGraphDescMap | ResourceGraphTraitsMap { + switch (tag) { + // Components + case 'Name': + return new ResourceGraphNameMap(this._names); + case 'Desc': + return new ResourceGraphDescMap(this._descs); + case 'Traits': + return new ResourceGraphTraitsMap(this._traits); + default: + throw Error('property map not found'); + } + } + //----------------------------------------------------------------- + // ComponentGraph + component (id: T, v: number): ResourceGraphComponentType[T] { + switch (id) { + case ResourceGraphComponent.Name: + return this._names[v] as ResourceGraphComponentType[T]; + case ResourceGraphComponent.Desc: + return this._descs[v] as ResourceGraphComponentType[T]; + case ResourceGraphComponent.Traits: + return this._traits[v] as ResourceGraphComponentType[T]; + default: + throw Error('component not found'); + } + } + componentMap (id: T): ResourceGraphComponentPropertyMap[T] { + switch (id) { + case ResourceGraphComponent.Name: + return new ResourceGraphNameMap(this._names) as ResourceGraphComponentPropertyMap[T]; + case ResourceGraphComponent.Desc: + return new ResourceGraphDescMap(this._descs) as ResourceGraphComponentPropertyMap[T]; + case ResourceGraphComponent.Traits: + return new ResourceGraphTraitsMap(this._traits) as ResourceGraphComponentPropertyMap[T]; + default: + throw Error('component map not found'); + } + } + getName (v: number): string { + return this._names[v]; + } + getDesc (v: number): ResourceDesc { + return this._descs[v]; + } + getTraits (v: number): ResourceTraits { + return this._traits[v]; + } + + readonly components: string[] = ['Name', 'Desc', 'Traits']; + readonly _vertices: ResourceGraphVertex[] = []; + readonly _names: string[] = []; + readonly _descs: ResourceDesc[] = []; + readonly _traits: ResourceTraits[] = []; +} + +export const enum AttachmentType { + RENDER_TARGET, + DEPTH_STENCIL, +} + +export const enum AccessType { + READ, + READ_WRITE, + WRITE, +} + +export class RasterView { + constructor ( + slotName = '', + accessType: AccessType = AccessType.WRITE, + attachmentType: AttachmentType = AttachmentType.RENDER_TARGET, + loadOp: LoadOp = LoadOp.LOAD, + storeOp: StoreOp = StoreOp.STORE, + clearFlags: ClearFlagBit = ClearFlagBit.ALL, + clearColor: Color = new Color(), + ) { + this.slotName = slotName; + this.accessType = accessType; + this.attachmentType = attachmentType; + this.loadOp = loadOp; + this.storeOp = storeOp; + this.clearFlags = clearFlags; + this.clearColor = clearColor; + } + slotName: string; + accessType: AccessType; + attachmentType: AttachmentType; + loadOp: LoadOp; + storeOp: StoreOp; + clearFlags: ClearFlagBit; + clearColor: Color; +} + +export const enum ClearValueType { + FLOAT_TYPE, + INT_TYPE, +} + +export class ComputeView { + name = ''; + accessType: AccessType = AccessType.READ; + clearFlags: ClearFlagBit = ClearFlagBit.NONE; + clearColor: Color = new Color(); + clearValueType: ClearValueType = ClearValueType.FLOAT_TYPE; +} + +export class RasterSubpass { + rasterViews: Map = new Map(); + computeViews: Map = new Map(); +} + +//================================================================= +// SubpassGraph +//================================================================= +// Graph Concept +export class SubpassGraphVertex { + constructor () { + } + readonly _outEdges: impl.OutE[] = []; + readonly _inEdges: impl.OutE[] = []; +} + +//----------------------------------------------------------------- +// PropertyGraph Concept +export class SubpassGraphNameMap implements impl.PropertyMap { + constructor (readonly names: string[]) { + this._names = names; + } + get (v: number): string { + return this._names[v]; + } + readonly _names: string[]; +} + +export class SubpassGraphSubpassMap implements impl.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, +} + +interface SubpassGraphComponentType { + [SubpassGraphComponent.Name]: string; + [SubpassGraphComponent.Subpass]: RasterSubpass; +} + +interface SubpassGraphComponentPropertyMap { + [SubpassGraphComponent.Name]: SubpassGraphNameMap; + [SubpassGraphComponent.Subpass]: SubpassGraphSubpassMap; +} + +//----------------------------------------------------------------- +// SubpassGraph Implementation +export class SubpassGraph implements impl.BidirectionalGraph +, impl.AdjacencyGraph +, impl.VertexListGraph +, impl.MutableGraph +, impl.PropertyGraph +, impl.NamedGraph +, impl.ComponentGraph { + //----------------------------------------------------------------- + // Graph + // type vertex_descriptor = number; + nullVertex (): number { return 0xFFFFFFFF; } + // type edge_descriptor = impl.ED; + readonly directed_category: impl.directional = impl.directional.bidirectional; + readonly edge_parallel_category: impl.parallel = impl.parallel.allow; + readonly traversal_category: impl.traversal = impl.traversal.incidence + | impl.traversal.bidirectional + | impl.traversal.adjacency + | impl.traversal.vertex_list; + //----------------------------------------------------------------- + // IncidenceGraph + // type out_edge_iterator = impl.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: impl.ED): number { + return e.source as number; + } + target (e: impl.ED): number { + return e.target as number; + } + outEdges (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + outDegree (v: number): number { + return this._vertices[v]._outEdges.length; + } + //----------------------------------------------------------------- + // BidirectionalGraph + // type in_edge_iterator = impl.InEI; + inEdges (v: number): impl.InEI { + return new impl.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 = impl.AdjI; + adjacentVertices (v: number): impl.AdjI { + return new impl.AdjI(this, this.outEdges(v)); + } + //----------------------------------------------------------------- + // VertexListGraph + vertices (): IterableIterator { + return this._vertices.keys(); + } + numVertices (): number { + return this._vertices.length; + } + //----------------------------------------------------------------- + // MutableGraph + 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]; + impl.reindexEdgeList(vert._outEdges, u); + impl.reindexEdgeList(vert._inEdges, u); + } + } + addEdge (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._outEdges.push(new impl.OutE(v)); + this._vertices[v]._inEdges.push(new impl.OutE(u)); + return new impl.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: impl.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 (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 (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]; + } + 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 { + rasterViews: Map = new Map(); + computeViews: Map = new Map(); + subpassGraph: SubpassGraph = new SubpassGraph(); +} + +export class ComputePass { + computeViews: Map = new Map(); +} + +export class CopyPair { + constructor ( + source = '', + target = '', + mipLevels = 0xFFFFFFFF, + numSlices = 0xFFFFFFFF, + sourceMostDetailedMip = 0, + sourceFirstSlice = 0, + sourcePlaneSlice = 0, + targetMostDetailedMip = 0, + targetFirstSlice = 0, + targetPlaneSlice = 0, + ) { + this.source = source; + this.target = target; + this.mipLevels = mipLevels; + this.numSlices = numSlices; + this.sourceMostDetailedMip = sourceMostDetailedMip; + this.sourceFirstSlice = sourceFirstSlice; + this.sourcePlaneSlice = sourcePlaneSlice; + this.targetMostDetailedMip = targetMostDetailedMip; + this.targetFirstSlice = targetFirstSlice; + this.targetPlaneSlice = targetPlaneSlice; + } + source: string; + target: string; + mipLevels: number; + numSlices: number; + sourceMostDetailedMip: number; + sourceFirstSlice: number; + sourcePlaneSlice: number; + targetMostDetailedMip: number; + targetFirstSlice: number; + targetPlaneSlice: number; +} + +export class CopyPass { + copyPairs: CopyPair[] = []; +} + +export class MovePair { + constructor ( + source = '', + target = '', + mipLevels = 0xFFFFFFFF, + numSlices = 0xFFFFFFFF, + targetMostDetailedMip = 0, + targetFirstSlice = 0, + targetPlaneSlice = 0, + ) { + this.source = source; + this.target = target; + this.mipLevels = mipLevels; + this.numSlices = numSlices; + this.targetMostDetailedMip = targetMostDetailedMip; + this.targetFirstSlice = targetFirstSlice; + this.targetPlaneSlice = targetPlaneSlice; + } + source: string; + target: string; + mipLevels: number; + numSlices: number; + targetMostDetailedMip: number; + targetFirstSlice: number; + targetPlaneSlice: number; +} + +export class MovePass { + movePairs: MovePair[] = []; +} + +export class RaytracePass { + computeViews: Map = new Map(); +} + +export class RenderQueue { + constructor (hint: QueueHint = QueueHint.RENDER_OPAQUE) { + this.hint = hint; + } + hint: QueueHint; +} + +export class SceneData { + constructor (name = '') { + this.name = name; + } + name: string; + camera: Camera | null = null; + scenes: string[] = []; +} + +export class Dispatch { + constructor (shader = '', threadGroupCountX = 0, threadGroupCountY = 0, threadGroupCountZ = 0) { + this.shader = shader; + this.threadGroupCountX = threadGroupCountX; + this.threadGroupCountY = threadGroupCountY; + this.threadGroupCountZ = threadGroupCountZ; + } + shader: string; + threadGroupCountX: number; + threadGroupCountY: number; + threadGroupCountZ: number; +} + +export class Blit { + constructor (shader = '') { + this.shader = shader; + } + shader: string; +} + +export class PresentPass { + constructor (resourceName = '', syncInterval = 0, flags = 0) { + this.resourceName = resourceName; + this.syncInterval = syncInterval; + this.flags = flags; + } + resourceName: string; + syncInterval: number; + flags: number; +} + +export class RenderData { + constants: Map = new Map(); + buffers: Map = new Map(); + textures: Map = new Map(); + samplers: Map = new Map(); +} + +//================================================================= +// RenderGraph +//================================================================= +// PolymorphicGraph Concept +export const enum RenderGraphValue { + Raster, + Compute, + Copy, + Move, + Present, + Raytrace, + Queue, + Scene, + Blit, + Dispatch, +} + +interface RenderGraphValueType { + [RenderGraphValue.Raster]: RasterPass + [RenderGraphValue.Compute]: ComputePass + [RenderGraphValue.Copy]: CopyPass + [RenderGraphValue.Move]: MovePass + [RenderGraphValue.Present]: PresentPass + [RenderGraphValue.Raytrace]: RaytracePass + [RenderGraphValue.Queue]: RenderQueue + [RenderGraphValue.Scene]: SceneData + [RenderGraphValue.Blit]: Blit + [RenderGraphValue.Dispatch]: Dispatch +} + +export interface RenderGraphVisitor { + raster(value: RasterPass): unknown; + compute(value: ComputePass): unknown; + copy(value: CopyPass): unknown; + move(value: MovePass): unknown; + present(value: PresentPass): unknown; + raytrace(value: RaytracePass): unknown; + queue(value: RenderQueue): unknown; + scene(value: SceneData): unknown; + blit(value: Blit): unknown; + dispatch(value: Dispatch): unknown; +} + +type RenderGraphObject = RasterPass +| ComputePass +| CopyPass +| MovePass +| PresentPass +| RaytracePass +| RenderQueue +| SceneData +| Blit +| Dispatch; + +//----------------------------------------------------------------- +// Graph Concept +export class RenderGraphVertex { + constructor ( + readonly id: RenderGraphValue, + readonly object: RenderGraphObject, + ) { + this._id = id; + this._object = object; + } + readonly _outEdges: impl.OutE[] = []; + readonly _inEdges: impl.OutE[] = []; + readonly _children: impl.OutE[] = []; + readonly _parents: impl.OutE[] = []; + readonly _id: RenderGraphValue; + readonly _object: RenderGraphObject; +} + +//----------------------------------------------------------------- +// PropertyGraph Concept +export class RenderGraphNameMap implements impl.PropertyMap { + constructor (readonly names: string[]) { + this._names = names; + } + get (v: number): string { + return this._names[v]; + } + readonly _names: string[]; +} + +export class RenderGraphLayoutMap implements impl.PropertyMap { + constructor (readonly layoutNodes: string[]) { + this._layoutNodes = layoutNodes; + } + get (v: number): string { + return this._layoutNodes[v]; + } + readonly _layoutNodes: string[]; +} + +export class RenderGraphDataMap implements impl.PropertyMap { + constructor (readonly data: RenderData[]) { + this._data = data; + } + get (v: number): RenderData { + return this._data[v]; + } + readonly _data: RenderData[]; +} + +//----------------------------------------------------------------- +// ComponentGraph Concept +export const enum RenderGraphComponent { + Name, + Layout, + Data, +} + +interface RenderGraphComponentType { + [RenderGraphComponent.Name]: string; + [RenderGraphComponent.Layout]: string; + [RenderGraphComponent.Data]: RenderData; +} + +interface RenderGraphComponentPropertyMap { + [RenderGraphComponent.Name]: RenderGraphNameMap; + [RenderGraphComponent.Layout]: RenderGraphLayoutMap; + [RenderGraphComponent.Data]: RenderGraphDataMap; +} + +//----------------------------------------------------------------- +// RenderGraph Implementation +export class RenderGraph implements impl.BidirectionalGraph +, impl.AdjacencyGraph +, impl.VertexListGraph +, impl.MutableGraph +, impl.PropertyGraph +, impl.NamedGraph +, impl.ComponentGraph +, impl.PolymorphicGraph +, impl.ReferenceGraph +, impl.MutableReferenceGraph { + //----------------------------------------------------------------- + // Graph + // type vertex_descriptor = number; + nullVertex (): number { return 0xFFFFFFFF; } + // type edge_descriptor = impl.ED; + readonly directed_category: impl.directional = impl.directional.bidirectional; + readonly edge_parallel_category: impl.parallel = impl.parallel.allow; + readonly traversal_category: impl.traversal = impl.traversal.incidence + | impl.traversal.bidirectional + | impl.traversal.adjacency + | impl.traversal.vertex_list; + //----------------------------------------------------------------- + // IncidenceGraph + // type out_edge_iterator = impl.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: impl.ED): number { + return e.source as number; + } + target (e: impl.ED): number { + return e.target as number; + } + outEdges (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._outEdges.values(), v); + } + outDegree (v: number): number { + return this._vertices[v]._outEdges.length; + } + //----------------------------------------------------------------- + // BidirectionalGraph + // type in_edge_iterator = impl.InEI; + inEdges (v: number): impl.InEI { + return new impl.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 = impl.AdjI; + adjacentVertices (v: number): impl.AdjI { + return new impl.AdjI(this, this.outEdges(v)); + } + //----------------------------------------------------------------- + // VertexListGraph + vertices (): IterableIterator { + return this._vertices.keys(); + } + numVertices (): number { + return this._vertices.length; + } + //----------------------------------------------------------------- + // MutableGraph + addVertex ( + id: RenderGraphValue, + object: RenderGraphValueType[T], + name: string, + layout: string, + data: RenderData, + u = 0xFFFFFFFF, + ): number { + const vert = new RenderGraphVertex(id, object); + const v = this._vertices.length; + this._vertices.push(vert); + this._names.push(name); + this._layoutNodes.push(layout); + this._data.push(data); + + // ReferenceGraph + if (u !== 0xFFFFFFFF) { + this._vertices[u]._children.push(new impl.OutE(v)); + vert._parents.push(new impl.OutE(u)); + } + + return v; + } + clearVertex (v: number): void { + // ReferenceGraph(Separated) + 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; + + // clear child edges + for (const oe of vert._children) { + const target = this._vertices[oe.target as number]; + for (let i = 0; i !== target._parents.length;) { // remove all edges + if (target._parents[i].target === v) { + target._parents.splice(i, 1); + } else { + ++i; + } + } + } + vert._children.length = 0; + + // clear parent edges + for (const ie of vert._parents) { + const source = this._vertices[ie.target as number]; + for (let i = 0; i !== source._children.length;) { // remove all edges + if (source._children[i].target === v) { + source._children.splice(i, 1); + } else { + ++i; + } + } + } + vert._parents.length = 0; + } + removeVertex (u: number): void { + this._vertices.splice(u, 1); + this._names.splice(u, 1); + this._layoutNodes.splice(u, 1); + this._data.splice(u, 1); + + const sz = this._vertices.length; + if (u === sz) { + return; + } + + for (let v = 0; v !== sz; ++v) { + const vert = this._vertices[v]; + impl.reindexEdgeList(vert._outEdges, u); + impl.reindexEdgeList(vert._inEdges, u); + // ReferenceGraph (Separated) + impl.reindexEdgeList(vert._children, u); + impl.reindexEdgeList(vert._parents, u); + } + } + addEdge (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._outEdges.push(new impl.OutE(v)); + this._vertices[v]._inEdges.push(new impl.OutE(u)); + return new impl.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: impl.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 (): RenderGraphNameMap { + return new RenderGraphNameMap(this._names); + } + //----------------------------------------------------------------- + // PropertyGraph + get (tag: string): RenderGraphNameMap | RenderGraphLayoutMap | RenderGraphDataMap { + switch (tag) { + // Components + case 'Name': + return new RenderGraphNameMap(this._names); + case 'Layout': + return new RenderGraphLayoutMap(this._layoutNodes); + case 'Data': + return new RenderGraphDataMap(this._data); + default: + throw Error('property map not found'); + } + } + //----------------------------------------------------------------- + // ComponentGraph + component (id: T, v: number): RenderGraphComponentType[T] { + switch (id) { + case RenderGraphComponent.Name: + return this._names[v] as RenderGraphComponentType[T]; + case RenderGraphComponent.Layout: + return this._layoutNodes[v] as RenderGraphComponentType[T]; + case RenderGraphComponent.Data: + return this._data[v] as RenderGraphComponentType[T]; + default: + throw Error('component not found'); + } + } + componentMap (id: T): RenderGraphComponentPropertyMap[T] { + switch (id) { + case RenderGraphComponent.Name: + return new RenderGraphNameMap(this._names) as RenderGraphComponentPropertyMap[T]; + case RenderGraphComponent.Layout: + return new RenderGraphLayoutMap(this._layoutNodes) as RenderGraphComponentPropertyMap[T]; + case RenderGraphComponent.Data: + return new RenderGraphDataMap(this._data) as RenderGraphComponentPropertyMap[T]; + default: + throw Error('component map not found'); + } + } + getName (v: number): string { + return this._names[v]; + } + getLayout (v: number): string { + return this._layoutNodes[v]; + } + getData (v: number): RenderData { + return this._data[v]; + } + //----------------------------------------------------------------- + // PolymorphicGraph + holds (id: RenderGraphValue, v: number): boolean { + return this._vertices[v]._id === id; + } + id (v: number): RenderGraphValue { + return this._vertices[v]._id; + } + object (v: number): RenderGraphObject { + return this._vertices[v]._object; + } + value (id: T, v: number): RenderGraphValueType[T] { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as RenderGraphValueType[T]; + } else { + throw Error('value id not match'); + } + } + tryValue (id: T, v: number): RenderGraphValueType[T] | null { + if (this._vertices[v]._id === id) { + return this._vertices[v]._object as RenderGraphValueType[T]; + } else { + return null; + } + } + visitVertex (visitor: RenderGraphVisitor, v: number): unknown { + const vert = this._vertices[v]; + switch (vert._id) { + case RenderGraphValue.Raster: + return visitor.raster(vert._object as RasterPass); + case RenderGraphValue.Compute: + return visitor.compute(vert._object as ComputePass); + case RenderGraphValue.Copy: + return visitor.copy(vert._object as CopyPass); + case RenderGraphValue.Move: + return visitor.move(vert._object as MovePass); + case RenderGraphValue.Present: + return visitor.present(vert._object as PresentPass); + case RenderGraphValue.Raytrace: + return visitor.raytrace(vert._object as RaytracePass); + case RenderGraphValue.Queue: + return visitor.queue(vert._object as RenderQueue); + case RenderGraphValue.Scene: + return visitor.scene(vert._object as SceneData); + case RenderGraphValue.Blit: + return visitor.blit(vert._object as Blit); + case RenderGraphValue.Dispatch: + return visitor.dispatch(vert._object as Dispatch); + default: + throw Error('polymorphic type not found'); + } + } + getRaster (v: number): RasterPass { + if (this._vertices[v]._id === RenderGraphValue.Raster) { + return this._vertices[v]._object as RasterPass; + } else { + throw Error('value id not match'); + } + } + getCompute (v: number): ComputePass { + if (this._vertices[v]._id === RenderGraphValue.Compute) { + return this._vertices[v]._object as ComputePass; + } else { + throw Error('value id not match'); + } + } + getCopy (v: number): CopyPass { + if (this._vertices[v]._id === RenderGraphValue.Copy) { + return this._vertices[v]._object as CopyPass; + } else { + throw Error('value id not match'); + } + } + getMove (v: number): MovePass { + if (this._vertices[v]._id === RenderGraphValue.Move) { + return this._vertices[v]._object as MovePass; + } else { + throw Error('value id not match'); + } + } + getPresent (v: number): PresentPass { + if (this._vertices[v]._id === RenderGraphValue.Present) { + return this._vertices[v]._object as PresentPass; + } else { + throw Error('value id not match'); + } + } + getRaytrace (v: number): RaytracePass { + if (this._vertices[v]._id === RenderGraphValue.Raytrace) { + return this._vertices[v]._object as RaytracePass; + } else { + throw Error('value id not match'); + } + } + getQueue (v: number): RenderQueue { + if (this._vertices[v]._id === RenderGraphValue.Queue) { + return this._vertices[v]._object as RenderQueue; + } else { + throw Error('value id not match'); + } + } + getScene (v: number): SceneData { + if (this._vertices[v]._id === RenderGraphValue.Scene) { + return this._vertices[v]._object as SceneData; + } else { + throw Error('value id not match'); + } + } + getBlit (v: number): Blit { + if (this._vertices[v]._id === RenderGraphValue.Blit) { + return this._vertices[v]._object as Blit; + } else { + throw Error('value id not match'); + } + } + getDispatch (v: number): Dispatch { + if (this._vertices[v]._id === RenderGraphValue.Dispatch) { + return this._vertices[v]._object as Dispatch; + } else { + throw Error('value id not match'); + } + } + tryGetRaster (v: number): RasterPass | null { + if (this._vertices[v]._id === RenderGraphValue.Raster) { + return this._vertices[v]._object as RasterPass; + } else { + return null; + } + } + tryGetCompute (v: number): ComputePass | null { + if (this._vertices[v]._id === RenderGraphValue.Compute) { + return this._vertices[v]._object as ComputePass; + } else { + return null; + } + } + tryGetCopy (v: number): CopyPass | null { + if (this._vertices[v]._id === RenderGraphValue.Copy) { + return this._vertices[v]._object as CopyPass; + } else { + return null; + } + } + tryGetMove (v: number): MovePass | null { + if (this._vertices[v]._id === RenderGraphValue.Move) { + return this._vertices[v]._object as MovePass; + } else { + return null; + } + } + tryGetPresent (v: number): PresentPass | null { + if (this._vertices[v]._id === RenderGraphValue.Present) { + return this._vertices[v]._object as PresentPass; + } else { + return null; + } + } + tryGetRaytrace (v: number): RaytracePass | null { + if (this._vertices[v]._id === RenderGraphValue.Raytrace) { + return this._vertices[v]._object as RaytracePass; + } else { + return null; + } + } + tryGetQueue (v: number): RenderQueue | null { + if (this._vertices[v]._id === RenderGraphValue.Queue) { + return this._vertices[v]._object as RenderQueue; + } else { + return null; + } + } + tryGetScene (v: number): SceneData | null { + if (this._vertices[v]._id === RenderGraphValue.Scene) { + return this._vertices[v]._object as SceneData; + } else { + return null; + } + } + tryGetBlit (v: number): Blit | null { + if (this._vertices[v]._id === RenderGraphValue.Blit) { + return this._vertices[v]._object as Blit; + } else { + return null; + } + } + tryGetDispatch (v: number): Dispatch | null { + if (this._vertices[v]._id === RenderGraphValue.Dispatch) { + return this._vertices[v]._object as Dispatch; + } else { + return null; + } + } + //----------------------------------------------------------------- + // ReferenceGraph + // type reference_descriptor = impl.ED; + // type child_iterator = impl.OutEI; + // type parent_iterator = impl.InEI; + reference (u: number, v: number): boolean { + for (const oe of this._vertices[u]._children) { + if (v === oe.target as number) { + return true; + } + } + return false; + } + parent (e: impl.ED): number { + return e.source as number; + } + child (e: impl.ED): number { + return e.target as number; + } + parents (v: number): impl.InEI { + return new impl.InEI(this._vertices[v]._parents.values(), v); + } + children (v: number): impl.OutEI { + return new impl.OutEI(this._vertices[v]._children.values(), v); + } + numParents (v: number): number { + return this._vertices[v]._parents.length; + } + numChildren (v: number): number { + return this._vertices[v]._children.length; + } + getParent (v: number): number { + if (v === 0xFFFFFFFF) { + return 0xFFFFFFFF; + } + const list = this._vertices[v]._parents; + if (list.length === 0) { + return 0xFFFFFFFF; + } else { + return list[0].target as number; + } + } + isAncestor (ancestor: number, descendent: number): boolean { + const pseudo = 0xFFFFFFFF; + if (ancestor === descendent) { + // when ancestor === descendent, is_ancestor is defined as false + return false; + } + if (ancestor === pseudo) { + // special case: pseudo root is always ancestor + return true; + } + if (descendent === pseudo) { + // special case: pseudo root is never descendent + return false; + } + for (let parent = this.getParent(descendent); parent !== pseudo;) { + if (ancestor === parent) { + return true; + } + parent = this.getParent(parent); + } + return false; + } + //----------------------------------------------------------------- + // MutableReferenceGraph + addReference (u: number, v: number): impl.ED | null { + // update in/out edge list + this._vertices[u]._children.push(new impl.OutE(v)); + this._vertices[v]._parents.push(new impl.OutE(u)); + return new impl.ED(u, v); + } + removeReference (e: impl.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._children.length;) { + if (source._children[i].target === v) { + source._children.splice(i, 1); + break; // remove one edge + } else { + ++i; + } + } + const target = this._vertices[v]; + for (let i = 0; i !== target._parents.length;) { + if (target._parents[i].target === u) { + target._parents.splice(i, 1); + break; // remove one edge + } else { + ++i; + } + } + } + removeReferences (u: number, v: number): void { + const source = this._vertices[u]; + // remove out edges of u + for (let i = 0; i !== source._children.length;) { // remove all edges + if (source._children[i].target === v) { + source._children.splice(i, 1); + } else { + ++i; + } + } + // remove in edges of v + const target = this._vertices[v]; + for (let i = 0; i !== target._parents.length;) { // remove all edges + if (target._parents[i].target === u) { + target._parents.splice(i, 1); + } else { + ++i; + } + } + } + + readonly components: string[] = ['Name', 'Layout', 'Data']; + readonly _vertices: RenderGraphVertex[] = []; + readonly _names: string[] = []; + readonly _layoutNodes: string[] = []; + readonly _data: RenderData[] = []; + index: Map = new Map(); +} diff --git a/cocos/core/pipeline/custom/types.ts b/cocos/core/pipeline/custom/types.ts new file mode 100644 index 0000000000..3f85063735 --- /dev/null +++ b/cocos/core/pipeline/custom/types.ts @@ -0,0 +1,129 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +/* eslint-disable max-len */ +export const enum UpdateFrequency { + PER_INSTANCE, + PER_BATCH, + PER_QUEUE, + PER_PASS, + COUNT, +} + +export const enum ParameterType { + Constants, + CBV, + UAV, + SRV, + Table, + SSV, +} + +export const enum Boundedness { + Bounded, + Unbounded, +} + +export const enum ResourceType { + Constants, + Buffer, + Texture1D, + Texture1DArray, + Texture2D, + Texture2DArray, + Texture2DMS, + Texture2DMSArray, + Texture3D, + TextureCube, + TextureCubeArray, + RaytracingAccelerationStructure, + SamplerState, + SamplerComparisonState, +} + +export const enum ValueType { + Typeless, + Float4, + Float3, + Float2, + Float1, + Half4, + Half3, + Half2, + Half1, + Fixed4, + Fixed3, + Fixed2, + Fixed1, + Uint4, + Uint3, + Uint2, + Uint1, + Int4, + Int3, + Int2, + Int1, + Bool4, + Bool3, + Bool2, + Bool1, +} + +export const enum ResourceResidency { + Managed, + Persistent, + Backbuffer, + Memoryless, +} + +export const enum QueueHint { + NONE, + RENDER_OPAQUE, + RENDER_CUTOUT, + RENDER_TRANSPARENT, + COUNT, +} + +export const enum ResourceDimension { + BUFFER, + TEXTURE1D, + TEXTURE2D, + TEXTURE3D, +} + +export class SampleDesc { + count = 1; + quality = 0; +} + +export const enum NodeType { + INTERNAL, + LEAF, +} diff --git a/cocos/core/pipeline/custom/web-descriptor-hierarchy.ts b/cocos/core/pipeline/custom/web-descriptor-hierarchy.ts new file mode 100644 index 0000000000..dd5671c097 --- /dev/null +++ b/cocos/core/pipeline/custom/web-descriptor-hierarchy.ts @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +import { EffectAsset } from '../../assets'; +import { DescriptorHierarchy } from './pipeline'; + +export class WebDescriptorHierarchy extends DescriptorHierarchy { + constructor () { + super(); + } + public addEffect (asset: EffectAsset): void { + const sz = asset.shaders.length; + for (let i = 0; i !== sz; ++i) { + const shader = asset.shaders[i]; + } + } +} diff --git a/cocos/core/pipeline/custom/web-pipeline.ts b/cocos/core/pipeline/custom/web-pipeline.ts new file mode 100644 index 0000000000..8fd49c6796 --- /dev/null +++ b/cocos/core/pipeline/custom/web-pipeline.ts @@ -0,0 +1,386 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/* eslint-disable max-len */ +import { Camera } from '../../renderer/scene/camera'; +import { Buffer, Format, Sampler, Texture } from '../../gfx/index'; +import { Color, Mat4, Quat, Vec2, Vec4 } from '../../math'; +import { QueueHint, ResourceDimension, ResourceResidency } from './types'; +import { Blit, ComputePass, ComputeView, CopyPair, CopyPass, Dispatch, MovePair, MovePass, RasterPass, RasterView, RenderData, RenderGraph, RenderGraphValue, RenderQueue, ResourceDesc, ResourceFlags, ResourceGraph, ResourceTraits, SceneData } from './render-graph'; +import { ComputePassBuilder, ComputeQueueBuilder, CopyPassBuilder, MovePassBuilder, Pipeline, RasterPassBuilder, RasterQueueBuilder, Setter } from './pipeline'; +import { PipelineSceneData } from '../pipeline-scene-data'; +import { RenderScene } from '../../renderer/scene'; +import { legacyCC } from '../../global-exports'; +import { LayoutGraphData } from './layout-graph'; + +export class WebSetter extends Setter { + constructor (data: RenderData) { + super(); + this._data = data; + } + public setMat4 (name: string, mat: Mat4): void {} + public setQuaternion (name: string, quat: Quat): void {} + public setColor (name: string, color: Color): void {} + public setVec4 (name: string, vec: Vec4): void {} + public setVec2 (name: string, vec: Vec2): void {} + public setFloat (name: string, v: number): void {} + public setBuffer (name: string, buffer: Buffer): void {} + public setTexture (name: string, texture: Texture): void {} + public setReadWriteBuffer (name: string, buffer: Buffer): void {} + public setReadWriteTexture (name: string, texture: Texture): void {} + public setSampler (name: string, sampler: Sampler): void {} + + // protected + private readonly _data: RenderData; +} + +function setCameraValues (setter: Setter, + camera: Readonly, cfg: Readonly, + scene: Readonly) { + setter.setMat4('cc_matView', camera.matView); + setter.setMat4('cc_matViewInv', camera.node.worldMatrix); + setter.setMat4('cc_matProj', camera.matProj); + setter.setMat4('cc_matProjInv', camera.matProjInv); + setter.setMat4('cc_matViewProj', camera.matViewProj); + setter.setMat4('cc_matViewProjInv', camera.matViewProjInv); + setter.setVec4('cc_cameraPos', new Vec4(camera.position.x, camera.position.y, camera.position.z, 0.0)); + setter.setVec4('cc_screenScale', new Vec4(cfg.shadingScale, cfg.shadingScale, 1.0 / cfg.shadingScale, 1.0 / cfg.shadingScale)); + setter.setVec4('cc_exposure', new Vec4(camera.exposure, 1.0 / camera.exposure, cfg.isHDR ? 1.0 : 0.0, 0.0)); + + const mainLight = scene.mainLight; + if (mainLight) { + setter.setVec4('cc_mainLitDir', new Vec4(mainLight.direction.x, mainLight.direction.y, mainLight.direction.z, 0.0)); + let r = mainLight.color.x; + let g = mainLight.color.y; + let b = mainLight.color.z; + if (mainLight.useColorTemperature) { + r *= mainLight.colorTemperatureRGB.x; + g *= mainLight.colorTemperatureRGB.y; + b *= mainLight.colorTemperatureRGB.z; + } + let w = mainLight.illuminance; + if (cfg.isHDR) { + w *= camera.exposure; + } + setter.setVec4('cc_mainLitColor', new Vec4(r, g, b, w)); + } else { + setter.setVec4('cc_mainLitDir', new Vec4(0, 0, 1, 0)); + setter.setVec4('cc_mainLitColor', new Vec4(0, 0, 0, 0)); + } + + const ambient = cfg.ambient; + const skyColor = ambient.skyColor; + if (cfg.isHDR) { + skyColor.w = ambient.skyIllum * camera.exposure; + } else { + skyColor.w = ambient.skyIllum; + } + setter.setVec4('cc_ambientSky', new Vec4(skyColor.x, skyColor.y, skyColor.z, skyColor.w)); + setter.setVec4('cc_ambientGround', new Vec4(ambient.groundAlbedo.x, ambient.groundAlbedo.y, ambient.groundAlbedo.z, ambient.groundAlbedo.w)); + + const fog = cfg.fog; + const colorTempRGB = fog.colorArray; + setter.setVec4('cc_fogColor', new Vec4(colorTempRGB.x, colorTempRGB.y, colorTempRGB.z, colorTempRGB.w)); + setter.setVec4('cc_fogBase', new Vec4(fog.fogStart, fog.fogEnd, fog.fogDensity, 0.0)); + setter.setVec4('cc_fogAdd', new Vec4(fog.fogTop, fog.fogRange, fog.fogAtten, 0.0)); + setter.setVec4('cc_nearFar', new Vec4(camera.nearClip, camera.farClip, 0.0, 0.0)); + setter.setVec4('cc_viewPort', new Vec4(camera.viewport.x, camera.viewport.y, camera.viewport.z, camera.viewport.w)); +} + +export class WebRasterQueueBuilder extends WebSetter implements RasterQueueBuilder { + constructor (data: RenderData, renderGraph: RenderGraph, vertID: number, queue: RenderQueue, pipeline: PipelineSceneData) { + super(data); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._queue = queue; + this._pipeline = pipeline; + } + addSceneOfCamera (camera: Camera, name = 'Camera'): void { + const sceneData = new SceneData(name); + sceneData.camera = camera; + this._renderGraph.addVertex( + RenderGraphValue.Scene, sceneData, name, '', new RenderData(), this._vertID, + ); + setCameraValues(this, camera, this._pipeline, + camera.scene ? camera.scene : legacyCC.director.getScene().renderScene); + } + addScene (sceneName: string): void { + const sceneData = new SceneData(sceneName); + this._renderGraph.addVertex( + RenderGraphValue.Scene, sceneData, sceneName, '', new RenderData(), this._vertID, + ); + } + addFullscreenQuad (shader: string, layoutName = '', name = 'Quad'): void { + this._renderGraph.addVertex( + RenderGraphValue.Blit, new Blit(shader), name, '', new RenderData(), this._vertID, + ); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _queue: RenderQueue; + private readonly _pipeline: PipelineSceneData; +} + +export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder { + constructor (data: RenderData, renderGraph: RenderGraph, vertID: number, pass: RasterPass, pipeline: PipelineSceneData) { + super(data); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._pass = pass; + this._pipeline = pipeline; + } + addRasterView (name: string, view: RasterView) { + this._pass.rasterViews.set(name, view); + } + addComputeView (name: string, view: ComputeView) { + if (this._pass.computeViews.has(name)) { + this._pass.computeViews.get(name)?.push(view); + } else { + this._pass.computeViews.set(name, [view]); + } + } + addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = '', name = 'Queue') { + if (layoutName === '') { + switch (hint) { + case QueueHint.RENDER_OPAQUE: + layoutName = 'Opaque'; + break; + case QueueHint.RENDER_CUTOUT: + layoutName = 'Cutout'; + break; + case QueueHint.RENDER_TRANSPARENT: + layoutName = 'Transparent'; + break; + default: + throw Error('cannot infer layoutName from QueueHint'); + } + } + const queue = new RenderQueue(hint); + const data = new RenderData(); + const queueID = this._renderGraph.addVertex( + RenderGraphValue.Queue, queue, name, layoutName, data, this._vertID, + ); + return new WebRasterQueueBuilder(data, this._renderGraph, queueID, queue, this._pipeline); + } + addFullscreenQuad (shader: string, layoutName = '', name = 'Quad') { + this._renderGraph.addVertex( + RenderGraphValue.Blit, + new Blit(shader), + name, layoutName, new RenderData(), this._vertID, + ); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _pass: RasterPass; + private readonly _pipeline: PipelineSceneData; +} + +export class WebComputeQueueBuilder extends WebSetter implements ComputeQueueBuilder { + constructor (data: RenderData, renderGraph: RenderGraph, vertID: number, queue: RenderQueue, pipeline: PipelineSceneData) { + super(data); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._queue = queue; + this._pipeline = pipeline; + } + addDispatch (shader: string, + threadGroupCountX: number, + threadGroupCountY: number, + threadGroupCountZ: number, + layoutName = '', + name = 'Dispatch') { + this._renderGraph.addVertex( + RenderGraphValue.Dispatch, + new Dispatch(shader, threadGroupCountX, threadGroupCountY, threadGroupCountZ), + name, layoutName, new RenderData(), this._vertID, + ); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _queue: RenderQueue; + private readonly _pipeline: PipelineSceneData; +} + +export class WebComputePassBuilder extends WebSetter implements ComputePassBuilder { + constructor (data: RenderData, renderGraph: RenderGraph, vertID: number, pass: ComputePass, pipeline: PipelineSceneData) { + super(data); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._pass = pass; + this._pipeline = pipeline; + } + addComputeView (name: string, view: ComputeView) { + if (this._pass.computeViews.has(name)) { + this._pass.computeViews.get(name)?.push(view); + } else { + this._pass.computeViews.set(name, [view]); + } + } + addQueue (layoutName = '', name = 'Queue') { + const queue = new RenderQueue(); + const data = new RenderData(); + const queueID = this._renderGraph.addVertex( + RenderGraphValue.Queue, queue, name, layoutName, data, this._vertID, + ); + return new WebComputeQueueBuilder(data, this._renderGraph, queueID, queue, this._pipeline); + } + addDispatch (shader: string, + threadGroupCountX: number, + threadGroupCountY: number, + threadGroupCountZ: number, + layoutName = '', + name = 'Dispatch') { + this._renderGraph.addVertex( + RenderGraphValue.Dispatch, + new Dispatch(shader, threadGroupCountX, threadGroupCountY, threadGroupCountZ), + name, layoutName, new RenderData(), this._vertID, + ); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _pass: ComputePass; + private readonly _pipeline: PipelineSceneData; +} + +export class WebMovePassBuilder extends MovePassBuilder { + constructor (renderGraph: RenderGraph, vertID: number, pass: MovePass) { + super(); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._pass = pass; + } + addPair (pair: MovePair) { + this._pass.movePairs.push(pair); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _pass: MovePass; +} + +export class WebCopyPassBuilder extends CopyPassBuilder { + constructor (renderGraph: RenderGraph, vertID: number, pass: CopyPass) { + super(); + this._renderGraph = renderGraph; + this._vertID = vertID; + this._pass = pass; + } + addPair (pair: CopyPair) { + this._pass.copyPairs.push(pair); + } + private readonly _renderGraph: RenderGraph; + private readonly _vertID: number; + private readonly _pass: CopyPass; +} + +export class WebPipeline extends Pipeline { + addRenderTexture (name: string, format: Format, width: number, height: number) { + const desc = new ResourceDesc(); + desc.dimension = ResourceDimension.TEXTURE2D; + desc.width = width; + desc.height = height; + desc.depthOrArraySize = 1; + desc.mipLevels = 1; + desc.format = format; + desc.flags = ResourceFlags.ALLOW_RENDER_TARGET | ResourceFlags.ALLOW_UNORDERED_ACCESS; + + return this._resourceGraph.addVertex(name, desc, new ResourceTraits(ResourceResidency.Persistent)); + } + addRenderTarget (name: string, format: Format, width: number, height: number) { + const desc = new ResourceDesc(); + desc.dimension = ResourceDimension.TEXTURE2D; + desc.width = width; + desc.height = height; + desc.depthOrArraySize = 1; + desc.mipLevels = 1; + desc.format = format; + desc.flags = ResourceFlags.ALLOW_RENDER_TARGET | ResourceFlags.ALLOW_UNORDERED_ACCESS; + return this._resourceGraph.addVertex(name, desc, new ResourceTraits()); + } + addDepthStencil (name: string, format: Format, width: number, height: number) { + const desc = new ResourceDesc(); + desc.dimension = ResourceDimension.TEXTURE2D; + desc.width = width; + desc.height = height; + desc.depthOrArraySize = 1; + desc.mipLevels = 1; + desc.format = format; + desc.flags = ResourceFlags.ALLOW_DEPTH_STENCIL; + return this._resourceGraph.addVertex(name, desc, new ResourceTraits()); + } + beginFrame (pplScene: PipelineSceneData) { + this._renderGraph = new RenderGraph(); + this._pipelineSceneData = pplScene; + } + endFrame () { + this._renderGraph = null; + this._pipelineSceneData = null; + } + addRasterPass (width: number, height: number, layoutName: string, name = 'Raster'): RasterPassBuilder { + const pass = new RasterPass(); + const data = new RenderData(); + const vertID = this._renderGraph!.addVertex( + RenderGraphValue.Raster, pass, name, layoutName, data, + ); + const result = new WebRasterPassBuilder(data, this._renderGraph!, vertID, pass, this._pipelineSceneData!); + this._updateRasterPassConstants(result, width, height); + return result; + } + addComputePass (layoutName: string, name = 'Compute'): ComputePassBuilder { + const pass = new ComputePass(); + const data = new RenderData(); + const vertID = this._renderGraph!.addVertex( + RenderGraphValue.Compute, pass, name, layoutName, new RenderData(), + ); + return new WebComputePassBuilder(data, this._renderGraph!, vertID, pass, this._pipelineSceneData!); + } + addMovePass (name = 'Move'): MovePassBuilder { + const pass = new MovePass(); + const vertID = this._renderGraph!.addVertex(RenderGraphValue.Move, pass, name, '', new RenderData()); + return new WebMovePassBuilder(this._renderGraph!, vertID, pass); + } + addCopyPass (name = 'Copy'): CopyPassBuilder { + const pass = new CopyPass(); + const vertID = this._renderGraph!.addVertex(RenderGraphValue.Copy, pass, name, '', new RenderData()); + return new WebCopyPassBuilder(this._renderGraph!, vertID, pass); + } + get renderGraph () { + return this._renderGraph; + } + protected _updateRasterPassConstants (pass: Setter, width: number, height: number) { + const shadingWidth = width; + const shadingHeight = height; + const root = legacyCC.director.root; + pass.setVec4('cc_time', + new Vec4(root.cumulativeTime, root.frameTime, legacyCC.director.getTotalFrames(), 0.0)); + pass.setVec4('cc_screenSize', + new Vec4(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight)); + pass.setVec4('cc_nativeSize', + new Vec4(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight)); + } + private readonly _layoutGraph: LayoutGraphData = new LayoutGraphData(); + private readonly _resourceGraph: ResourceGraph = new ResourceGraph(); + private _renderGraph: RenderGraph | null = null; + private _pipelineSceneData: PipelineSceneData | null = null; +} diff --git a/cocos/core/pipeline/forward/forward-pipeline.ts b/cocos/core/pipeline/forward/forward-pipeline.ts index b91d4e3a7e..8fb63ec16f 100644 --- a/cocos/core/pipeline/forward/forward-pipeline.ts +++ b/cocos/core/pipeline/forward/forward-pipeline.ts @@ -41,6 +41,12 @@ import { Texture2D } from '../../assets/texture-2d'; import { Camera } from '../../renderer/scene'; import { errorID } from '../../platform/debug'; import { PipelineSceneData } from '../pipeline-scene-data'; +import { RenderGraph } from '../custom/render-graph'; +import { LayoutGraphData } from '../custom/layout-graph'; +import { DeviceResourceGraph } from '../custom/executor'; +import { Pipeline } from '../custom/pipeline'; +import { WebPipeline } from '../custom/web-pipeline'; +import { WebDescriptorHierarchy } from '../custom/web-descriptor-hierarchy'; const PIPELINE_TYPE = 0; diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 062680e51f..9050d4896a 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -1147,6 +1147,60 @@ cocos_source_files( cocos/renderer/pipeline/GeometryRenderer.cpp cocos/renderer/pipeline/helper/Utils.h cocos/renderer/pipeline/helper/Utils.cpp + cocos/renderer/pipeline/custom/LayoutGraphFwd.h + cocos/renderer/pipeline/custom/LayoutGraphGraphs.h + cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp + cocos/renderer/pipeline/custom/LayoutGraphJsb.h + cocos/renderer/pipeline/custom/LayoutGraphNames.h + cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp + cocos/renderer/pipeline/custom/LayoutGraphReflection.h + cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp + cocos/renderer/pipeline/custom/LayoutGraphTypes.h + cocos/renderer/pipeline/custom/RenderCommonFwd.h + cocos/renderer/pipeline/custom/RenderCommonJsb.cpp + cocos/renderer/pipeline/custom/RenderCommonJsb.h + cocos/renderer/pipeline/custom/RenderCommonNames.h + cocos/renderer/pipeline/custom/RenderCommonReflection.cpp + cocos/renderer/pipeline/custom/RenderCommonReflection.h + cocos/renderer/pipeline/custom/RenderCommonTypes.cpp + cocos/renderer/pipeline/custom/RenderCommonTypes.h + cocos/renderer/pipeline/custom/RenderCompilerFwd.h + cocos/renderer/pipeline/custom/RenderCompilerGraphs.h + cocos/renderer/pipeline/custom/RenderCompilerImpl.cpp + cocos/renderer/pipeline/custom/RenderCompilerNames.h + cocos/renderer/pipeline/custom/RenderCompilerReflection.cpp + cocos/renderer/pipeline/custom/RenderCompilerReflection.h + cocos/renderer/pipeline/custom/RenderCompilerTypes.cpp + cocos/renderer/pipeline/custom/RenderCompilerTypes.h + cocos/renderer/pipeline/custom/RenderExampleFwd.h + cocos/renderer/pipeline/custom/RenderExampleGraphs.h + cocos/renderer/pipeline/custom/RenderExampleImpl.cpp + cocos/renderer/pipeline/custom/RenderExampleNames.h + cocos/renderer/pipeline/custom/RenderExampleReflection.cpp + cocos/renderer/pipeline/custom/RenderExampleReflection.h + cocos/renderer/pipeline/custom/RenderExampleTypes.cpp + cocos/renderer/pipeline/custom/RenderExampleTypes.h + cocos/renderer/pipeline/custom/RenderExecutorFwd.h + cocos/renderer/pipeline/custom/RenderExecutorGraphs.h + cocos/renderer/pipeline/custom/RenderExecutorJsb.cpp + cocos/renderer/pipeline/custom/RenderExecutorJsb.h + cocos/renderer/pipeline/custom/RenderExecutorNames.h + cocos/renderer/pipeline/custom/RenderExecutorReflection.cpp + cocos/renderer/pipeline/custom/RenderExecutorReflection.h + cocos/renderer/pipeline/custom/RenderExecutorTypes.cpp + cocos/renderer/pipeline/custom/RenderExecutorTypes.h + cocos/renderer/pipeline/custom/RenderGraphFwd.h + cocos/renderer/pipeline/custom/RenderGraphGraphs.h + cocos/renderer/pipeline/custom/RenderGraphJsb.cpp + cocos/renderer/pipeline/custom/RenderGraphJsb.h + cocos/renderer/pipeline/custom/RenderGraphNames.h + cocos/renderer/pipeline/custom/RenderGraphReflection.cpp + cocos/renderer/pipeline/custom/RenderGraphReflection.h + cocos/renderer/pipeline/custom/RenderGraphTypes.cpp + cocos/renderer/pipeline/custom/RenderGraphTypes.h + cocos/renderer/pipeline/custom/RenderInterfaceFwd.h + cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp + cocos/renderer/pipeline/custom/RenderInterfaceTypes.h ) ##### terrain @@ -1894,6 +1948,8 @@ cocos_source_files( cocos/bindings/auto/jsb_assets_auto.h NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_geometry_auto.cpp cocos/bindings/auto/jsb_geometry_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_render_auto.cpp + cocos/bindings/auto/jsb_render_auto.h ) if(USE_AUDIO) diff --git a/native/cocos/bindings/auto/jsb_render_auto.cpp b/native/cocos/bindings/auto/jsb_render_auto.cpp new file mode 100644 index 0000000000..7c44b14ce7 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_render_auto.cpp @@ -0,0 +1,1267 @@ + +// clang-format off +#include "cocos/bindings/auto/jsb_render_auto.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/manual/jsb_global.h" +#include "renderer/pipeline/custom/RenderInterfaceTypes.h" +#include "cocos/bindings/auto/jsb_gfx_auto.h" +#include "cocos/bindings/auto/jsb_scene_auto.h" +#include "cocos/renderer/pipeline/custom/RenderCommonJsb.h" +#include "cocos/renderer/pipeline/custom/RenderGraphJsb.h" + +#ifndef JSB_ALLOC +#define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) +#endif + +#ifndef JSB_FREE +#define JSB_FREE(ptr) delete ptr +#endif +se::Object* __jsb_cc_render_DescriptorHierarchy_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_DescriptorHierarchy_class = nullptr; // NOLINT + +static bool js_render_DescriptorHierarchy_addEffect(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_DescriptorHierarchy_addEffect : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_DescriptorHierarchy_addEffect : Error processing arguments"); + cobj->addEffect(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_DescriptorHierarchy_addEffect) + +bool js_register_render_DescriptorHierarchy(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("DescriptorHierarchy", obj, nullptr, nullptr); + + cls->defineFunction("addEffect", _SE(js_render_DescriptorHierarchy_addEffect)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_DescriptorHierarchy_proto = cls->getProto(); + __jsb_cc_render_DescriptorHierarchy_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_Setter_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_Setter_class = nullptr; // NOLINT + +static bool js_render_Setter_setBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setBuffer : Error processing arguments"); + cobj->setBuffer(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setBuffer) + +static bool js_render_Setter_setColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setColor : Error processing arguments"); + cobj->setColor(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setColor) + +static bool js_render_Setter_setFloat(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setFloat : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setFloat : Error processing arguments"); + cobj->setFloat(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setFloat) + +static bool js_render_Setter_setMat4(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setMat4 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setMat4 : Error processing arguments"); + cobj->setMat4(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setMat4) + +static bool js_render_Setter_setQuaternion(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setQuaternion : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setQuaternion : Error processing arguments"); + cobj->setQuaternion(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setQuaternion) + +static bool js_render_Setter_setReadWriteBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setReadWriteBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setReadWriteBuffer : Error processing arguments"); + cobj->setReadWriteBuffer(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setReadWriteBuffer) + +static bool js_render_Setter_setReadWriteTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setReadWriteTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setReadWriteTexture : Error processing arguments"); + cobj->setReadWriteTexture(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setReadWriteTexture) + +static bool js_render_Setter_setSampler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setSampler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setSampler : Error processing arguments"); + cobj->setSampler(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setSampler) + +static bool js_render_Setter_setTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setTexture : Error processing arguments"); + cobj->setTexture(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setTexture) + +static bool js_render_Setter_setVec2(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setVec2 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setVec2 : Error processing arguments"); + cobj->setVec2(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setVec2) + +static bool js_render_Setter_setVec4(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Setter_setVec4 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Setter_setVec4 : Error processing arguments"); + cobj->setVec4(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_Setter_setVec4) + +bool js_register_render_Setter(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Setter", obj, nullptr, nullptr); + + cls->defineFunction("setBuffer", _SE(js_render_Setter_setBuffer)); + cls->defineFunction("setColor", _SE(js_render_Setter_setColor)); + cls->defineFunction("setFloat", _SE(js_render_Setter_setFloat)); + cls->defineFunction("setMat4", _SE(js_render_Setter_setMat4)); + cls->defineFunction("setQuaternion", _SE(js_render_Setter_setQuaternion)); + cls->defineFunction("setReadWriteBuffer", _SE(js_render_Setter_setReadWriteBuffer)); + cls->defineFunction("setReadWriteTexture", _SE(js_render_Setter_setReadWriteTexture)); + cls->defineFunction("setSampler", _SE(js_render_Setter_setSampler)); + cls->defineFunction("setTexture", _SE(js_render_Setter_setTexture)); + cls->defineFunction("setVec2", _SE(js_render_Setter_setVec2)); + cls->defineFunction("setVec4", _SE(js_render_Setter_setVec4)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_Setter_proto = cls->getProto(); + __jsb_cc_render_Setter_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_RasterQueueBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_RasterQueueBuilder_class = nullptr; // NOLINT + +static bool js_render_RasterQueueBuilder_addFullscreenQuad(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_RasterQueueBuilder_addFullscreenQuad : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addFullscreenQuad(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addFullscreenQuad(arg0.value(), arg1.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_RasterQueueBuilder_addFullscreenQuad) + +static bool js_render_RasterQueueBuilder_addScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_RasterQueueBuilder_addScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_RasterQueueBuilder_addScene : Error processing arguments"); + cobj->addScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_RasterQueueBuilder_addScene) + +static bool js_render_RasterQueueBuilder_addSceneOfCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_RasterQueueBuilder_addSceneOfCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addSceneOfCamera(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addSceneOfCamera(arg0.value(), arg1.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_RasterQueueBuilder_addSceneOfCamera) + +bool js_register_render_RasterQueueBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RasterQueueBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addFullscreenQuad", _SE(js_render_RasterQueueBuilder_addFullscreenQuad)); + cls->defineFunction("addScene", _SE(js_render_RasterQueueBuilder_addScene)); + cls->defineFunction("addSceneOfCamera", _SE(js_render_RasterQueueBuilder_addSceneOfCamera)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_RasterQueueBuilder_proto = cls->getProto(); + __jsb_cc_render_RasterQueueBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_RasterPassBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_RasterPassBuilder_class = nullptr; // NOLINT + +static bool js_render_RasterPassBuilder_addComputeView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_RasterPassBuilder_addComputeView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_RasterPassBuilder_addComputeView : Error processing arguments"); + cobj->addComputeView(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_RasterPassBuilder_addComputeView) + +static bool js_render_RasterPassBuilder_addFullscreenQuad(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_RasterPassBuilder_addFullscreenQuad : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addFullscreenQuad(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addFullscreenQuad(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addFullscreenQuad(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_RasterPassBuilder_addFullscreenQuad) + +static bool js_render_RasterPassBuilder_addQueue(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_RasterPassBuilder_addQueue : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::RasterQueueBuilder* result = cobj->addQueue(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_RasterPassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::RasterQueueBuilder* result = cobj->addQueue(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_RasterPassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::RasterQueueBuilder* result = cobj->addQueue(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_RasterPassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_RasterPassBuilder_addQueue) + +static bool js_render_RasterPassBuilder_addRasterView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_RasterPassBuilder_addRasterView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_RasterPassBuilder_addRasterView : Error processing arguments"); + cobj->addRasterView(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_RasterPassBuilder_addRasterView) + +bool js_register_render_RasterPassBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RasterPassBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addComputeView", _SE(js_render_RasterPassBuilder_addComputeView)); + cls->defineFunction("addFullscreenQuad", _SE(js_render_RasterPassBuilder_addFullscreenQuad)); + cls->defineFunction("addQueue", _SE(js_render_RasterPassBuilder_addQueue)); + cls->defineFunction("addRasterView", _SE(js_render_RasterPassBuilder_addRasterView)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_RasterPassBuilder_proto = cls->getProto(); + __jsb_cc_render_RasterPassBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_ComputeQueueBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_ComputeQueueBuilder_class = nullptr; // NOLINT + +static bool js_render_ComputeQueueBuilder_addDispatch(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_ComputeQueueBuilder_addDispatch : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + } while(false); + + do { + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + return true; + } + } while(false); + + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_ComputeQueueBuilder_addDispatch) + +bool js_register_render_ComputeQueueBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ComputeQueueBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addDispatch", _SE(js_render_ComputeQueueBuilder_addDispatch)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_ComputeQueueBuilder_proto = cls->getProto(); + __jsb_cc_render_ComputeQueueBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_ComputePassBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_ComputePassBuilder_class = nullptr; // NOLINT + +static bool js_render_ComputePassBuilder_addComputeView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_ComputePassBuilder_addComputeView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_ComputePassBuilder_addComputeView : Error processing arguments"); + cobj->addComputeView(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_render_ComputePassBuilder_addComputeView) + +static bool js_render_ComputePassBuilder_addDispatch(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_ComputePassBuilder_addDispatch : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + } while(false); + + do { + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + return true; + } + } while(false); + + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->addDispatch(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_ComputePassBuilder_addDispatch) + +static bool js_render_ComputePassBuilder_addQueue(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_ComputePassBuilder_addQueue : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::ComputeQueueBuilder* result = cobj->addQueue(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_ComputePassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::ComputeQueueBuilder* result = cobj->addQueue(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_ComputePassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 0) { + + cc::render::ComputeQueueBuilder* result = cobj->addQueue(); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_ComputePassBuilder_addQueue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_ComputePassBuilder_addQueue) + +bool js_register_render_ComputePassBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ComputePassBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addComputeView", _SE(js_render_ComputePassBuilder_addComputeView)); + cls->defineFunction("addDispatch", _SE(js_render_ComputePassBuilder_addDispatch)); + cls->defineFunction("addQueue", _SE(js_render_ComputePassBuilder_addQueue)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_ComputePassBuilder_proto = cls->getProto(); + __jsb_cc_render_ComputePassBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_MovePassBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_MovePassBuilder_class = nullptr; // NOLINT + +static bool js_render_MovePassBuilder_addPair(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_MovePassBuilder_addPair : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_MovePassBuilder_addPair : Error processing arguments"); + cobj->addPair(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_MovePassBuilder_addPair) + +bool js_register_render_MovePassBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MovePassBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addPair", _SE(js_render_MovePassBuilder_addPair)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_MovePassBuilder_proto = cls->getProto(); + __jsb_cc_render_MovePassBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_CopyPassBuilder_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_CopyPassBuilder_class = nullptr; // NOLINT + +static bool js_render_CopyPassBuilder_addPair(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_CopyPassBuilder_addPair : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_CopyPassBuilder_addPair : Error processing arguments"); + cobj->addPair(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_CopyPassBuilder_addPair) + +bool js_register_render_CopyPassBuilder(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("CopyPassBuilder", obj, nullptr, nullptr); + + cls->defineFunction("addPair", _SE(js_render_CopyPassBuilder_addPair)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_CopyPassBuilder_proto = cls->getProto(); + __jsb_cc_render_CopyPassBuilder_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_render_Pipeline_proto = nullptr; // NOLINT +se::Class* __jsb_cc_render_Pipeline_class = nullptr; // NOLINT + +static bool js_render_Pipeline_addComputePass(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_Pipeline_addComputePass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::ComputePassBuilder* result = cobj->addComputePass(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addComputePass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::ComputePassBuilder* result = cobj->addComputePass(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addComputePass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addComputePass) + +static bool js_render_Pipeline_addCopyPass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_addCopyPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addCopyPass : Error processing arguments"); + cc::render::CopyPassBuilder* result = cobj->addCopyPass(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addCopyPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addCopyPass) + +static bool js_render_Pipeline_addDepthStencil(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_addDepthStencil : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addDepthStencil : Error processing arguments"); + unsigned int result = cobj->addDepthStencil(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addDepthStencil : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addDepthStencil) + +static bool js_render_Pipeline_addMovePass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_addMovePass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addMovePass : Error processing arguments"); + cc::render::MovePassBuilder* result = cobj->addMovePass(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addMovePass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addMovePass) + +static bool js_render_Pipeline_addRasterPass(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_render_Pipeline_addRasterPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::RasterPassBuilder* result = cobj->addRasterPass(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRasterPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + cc::render::RasterPassBuilder* result = cobj->addRasterPass(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRasterPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addRasterPass) + +static bool js_render_Pipeline_addRenderTarget(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_addRenderTarget : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRenderTarget : Error processing arguments"); + unsigned int result = cobj->addRenderTarget(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRenderTarget : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addRenderTarget) + +static bool js_render_Pipeline_addRenderTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_addRenderTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRenderTexture : Error processing arguments"); + unsigned int result = cobj->addRenderTexture(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_addRenderTexture : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_addRenderTexture) + +static bool js_render_Pipeline_beginFrame(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_beginFrame : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_render_Pipeline_beginFrame : Error processing arguments"); + cobj->beginFrame(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_beginFrame) + +static bool js_render_Pipeline_endFrame(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_render_Pipeline_endFrame : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->endFrame(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_render_Pipeline_endFrame) + +bool js_register_render_Pipeline(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Pipeline", obj, nullptr, nullptr); + + cls->defineFunction("addComputePass", _SE(js_render_Pipeline_addComputePass)); + cls->defineFunction("addCopyPass", _SE(js_render_Pipeline_addCopyPass)); + cls->defineFunction("addDepthStencil", _SE(js_render_Pipeline_addDepthStencil)); + cls->defineFunction("addMovePass", _SE(js_render_Pipeline_addMovePass)); + cls->defineFunction("addRasterPass", _SE(js_render_Pipeline_addRasterPass)); + cls->defineFunction("addRenderTarget", _SE(js_render_Pipeline_addRenderTarget)); + cls->defineFunction("addRenderTexture", _SE(js_render_Pipeline_addRenderTexture)); + cls->defineFunction("beginFrame", _SE(js_render_Pipeline_beginFrame)); + cls->defineFunction("endFrame", _SE(js_render_Pipeline_endFrame)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_render_Pipeline_proto = cls->getProto(); + __jsb_cc_render_Pipeline_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +bool register_all_render(se::Object* obj) // NOLINT +{ + // Get the ns + se::Value nsVal; + if (!obj->getProperty("render", &nsVal, true)) + { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("render", nsVal); + } + se::Object* ns = nsVal.toObject(); + + js_register_render_ComputePassBuilder(ns); + js_register_render_ComputeQueueBuilder(ns); + js_register_render_CopyPassBuilder(ns); + js_register_render_DescriptorHierarchy(ns); + js_register_render_MovePassBuilder(ns); + js_register_render_Pipeline(ns); + js_register_render_RasterPassBuilder(ns); + js_register_render_RasterQueueBuilder(ns); + js_register_render_Setter(ns); + return true; +} + +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_render_auto.h b/native/cocos/bindings/auto/jsb_render_auto.h new file mode 100644 index 0000000000..cf438c78c1 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_render_auto.h @@ -0,0 +1,109 @@ +// clang-format off +#pragma once +#include "base/Config.h" +#include +#include "cocos/bindings/jswrapper/SeApi.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/renderer/pipeline/custom/RenderInterfaceTypes.h" + +bool register_all_render(se::Object *obj); // NOLINT + +JSB_REGISTER_OBJECT_TYPE(cc::render::DescriptorHierarchy); +JSB_REGISTER_OBJECT_TYPE(cc::render::Setter); +JSB_REGISTER_OBJECT_TYPE(cc::render::RasterQueueBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::RasterPassBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::ComputeQueueBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::ComputePassBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::MovePassBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::CopyPassBuilder); +JSB_REGISTER_OBJECT_TYPE(cc::render::Pipeline); + + +extern se::Object *__jsb_cc_render_DescriptorHierarchy_proto; // NOLINT +extern se::Class * __jsb_cc_render_DescriptorHierarchy_class; // NOLINT + +bool js_register_cc_render_DescriptorHierarchy(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_DescriptorHierarchy_addEffect); + +extern se::Object *__jsb_cc_render_Setter_proto; // NOLINT +extern se::Class * __jsb_cc_render_Setter_class; // NOLINT + +bool js_register_cc_render_Setter(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_Setter_setBuffer); +SE_DECLARE_FUNC(js_render_Setter_setColor); +SE_DECLARE_FUNC(js_render_Setter_setFloat); +SE_DECLARE_FUNC(js_render_Setter_setMat4); +SE_DECLARE_FUNC(js_render_Setter_setQuaternion); +SE_DECLARE_FUNC(js_render_Setter_setReadWriteBuffer); +SE_DECLARE_FUNC(js_render_Setter_setReadWriteTexture); +SE_DECLARE_FUNC(js_render_Setter_setSampler); +SE_DECLARE_FUNC(js_render_Setter_setTexture); +SE_DECLARE_FUNC(js_render_Setter_setVec2); +SE_DECLARE_FUNC(js_render_Setter_setVec4); + +extern se::Object *__jsb_cc_render_RasterQueueBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_RasterQueueBuilder_class; // NOLINT + +bool js_register_cc_render_RasterQueueBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_RasterQueueBuilder_addFullscreenQuad); +SE_DECLARE_FUNC(js_render_RasterQueueBuilder_addScene); +SE_DECLARE_FUNC(js_render_RasterQueueBuilder_addSceneOfCamera); + +extern se::Object *__jsb_cc_render_RasterPassBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_RasterPassBuilder_class; // NOLINT + +bool js_register_cc_render_RasterPassBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_RasterPassBuilder_addComputeView); +SE_DECLARE_FUNC(js_render_RasterPassBuilder_addFullscreenQuad); +SE_DECLARE_FUNC(js_render_RasterPassBuilder_addQueue); +SE_DECLARE_FUNC(js_render_RasterPassBuilder_addRasterView); + +extern se::Object *__jsb_cc_render_ComputeQueueBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_ComputeQueueBuilder_class; // NOLINT + +bool js_register_cc_render_ComputeQueueBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_ComputeQueueBuilder_addDispatch); + +extern se::Object *__jsb_cc_render_ComputePassBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_ComputePassBuilder_class; // NOLINT + +bool js_register_cc_render_ComputePassBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_ComputePassBuilder_addComputeView); +SE_DECLARE_FUNC(js_render_ComputePassBuilder_addDispatch); +SE_DECLARE_FUNC(js_render_ComputePassBuilder_addQueue); + +extern se::Object *__jsb_cc_render_MovePassBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_MovePassBuilder_class; // NOLINT + +bool js_register_cc_render_MovePassBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_MovePassBuilder_addPair); + +extern se::Object *__jsb_cc_render_CopyPassBuilder_proto; // NOLINT +extern se::Class * __jsb_cc_render_CopyPassBuilder_class; // NOLINT + +bool js_register_cc_render_CopyPassBuilder(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_CopyPassBuilder_addPair); + +extern se::Object *__jsb_cc_render_Pipeline_proto; // NOLINT +extern se::Class * __jsb_cc_render_Pipeline_class; // NOLINT + +bool js_register_cc_render_Pipeline(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_render_Pipeline_addComputePass); +SE_DECLARE_FUNC(js_render_Pipeline_addCopyPass); +SE_DECLARE_FUNC(js_render_Pipeline_addDepthStencil); +SE_DECLARE_FUNC(js_render_Pipeline_addMovePass); +SE_DECLARE_FUNC(js_render_Pipeline_addRasterPass); +SE_DECLARE_FUNC(js_render_Pipeline_addRenderTarget); +SE_DECLARE_FUNC(js_render_Pipeline_addRenderTexture); +SE_DECLARE_FUNC(js_render_Pipeline_beginFrame); +SE_DECLARE_FUNC(js_render_Pipeline_endFrame); + // clang-format on \ No newline at end of file diff --git a/native/cocos/renderer/pipeline/custom/GraphImpl.h b/native/cocos/renderer/pipeline/custom/GraphImpl.h new file mode 100644 index 0000000000..4200d3cbf4 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/GraphImpl.h @@ -0,0 +1,679 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cc { + +namespace render { + +namespace impl { + +//-------------------------------------------------------------------- +// PropertyMap +//-------------------------------------------------------------------- +template +struct VectorVertexBundlePropertyMap +: public boost::put_get_helper< + Reference, VectorVertexBundlePropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexBundlePropertyMap(Graph &g) noexcept // NOLINT(google-explicit-constructor) + : graph(&g) {} + + inline reference operator[](const key_type &v) const noexcept { + return graph->mVertices[v].property; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; +}; + +template +struct PointerVertexBundlePropertyMap +: public boost::put_get_helper< + Reference, PointerVertexBundlePropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + PointerVertexBundlePropertyMap(Graph &g) noexcept // NOLINT(google-explicit-constructor) + : graph(&g) {} + + inline reference operator[](const key_type &v) const noexcept { + auto *sv = static_cast(v); + return sv->property; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; +}; + +template +struct VectorVertexBundleMemberPropertyMap +: public boost::put_get_helper< + Reference, VectorVertexBundleMemberPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexBundleMemberPropertyMap(Graph &g, MemberPointer ptr) noexcept + : graph(&g), memberPointer(ptr) {} + + inline reference operator[](const key_type &v) const noexcept { + return graph->mVertices[v].property.*memberPointer; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; + MemberPointer memberPointer{}; +}; + +template +struct PointerVertexBundleMemberPropertyMap +: public boost::put_get_helper< + Reference, PointerVertexBundleMemberPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + PointerVertexBundleMemberPropertyMap(Graph &g, MemberPointer ptr) noexcept + : graph(&g), memberPointer(ptr) {} + + inline reference operator[](const key_type &v) const noexcept { + auto *sv = static_cast(v); + return sv->property.*memberPointer; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; + MemberPointer memberPointer{}; +}; + +template +struct VectorVertexComponentPropertyMap +: public boost::put_get_helper< + Reference, VectorVertexComponentPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexComponentPropertyMap(Container &c) noexcept // NOLINT(google-explicit-constructor) + : container(&c) {} + + inline reference operator[](const key_type &v) const noexcept { + return (*container)[v]; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Container *container{}; +}; + +template +struct VectorVertexComponentMemberPropertyMap +: public boost::put_get_helper< + Reference, VectorVertexComponentMemberPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexComponentMemberPropertyMap(Container &c, MemberPointer ptr) noexcept + : container(&c), memberPointer(ptr) {} + + inline reference operator[](const key_type &v) const noexcept { + return (*container)[v].*memberPointer; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Container *container{}; + MemberPointer memberPointer{}; +}; + +template +struct VectorVertexIteratorComponentPropertyMap +: public boost::put_get_helper< + Reference, VectorVertexIteratorComponentPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexIteratorComponentPropertyMap(Graph &g, ComponentPointer component) noexcept + : graph(&g), componentPointer(component) {} + + inline reference operator[](const key_type &v) const noexcept { + return *(graph->mVertices[v].*componentPointer); + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; + ComponentPointer componentPointer{}; +}; + +template +struct VectorVertexIteratorComponentMemberPropertyMap +: public boost::put_get_helper< + Reference, VectorVertexIteratorComponentMemberPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::vertex_descriptor; + using category = Category; + + VectorVertexIteratorComponentMemberPropertyMap(Graph &g, ComponentPointer component, MemberPointer ptr) noexcept + : graph(&g), componentPointer(component), memberPointer(ptr) {} + + inline reference operator[](const key_type &v) const noexcept { + return (*(graph->mVertices[v].*componentPointer)).*memberPointer; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Graph *graph{}; + ComponentPointer componentPointer{}; + MemberPointer memberPointer{}; +}; + +template +struct VectorPathPropertyMap +: public boost::put_get_helper< + Reference, VectorPathPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = VertexDescriptor; + using category = Category; + + VectorPathPropertyMap(Container &c) noexcept // NOLINT(google-explicit-constructor) + : container(&c) {} + + inline reference operator[](const key_type &v) const noexcept { + return (*container)[v].mPathIterator->first; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + Container *container{}; +}; + +template +struct EdgeBundlePropertyMap +: public boost::put_get_helper< + Reference, EdgeBundlePropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::edge_descriptor; + using category = Category; + + EdgeBundlePropertyMap(Graph &g) noexcept // NOLINT(google-explicit-constructor) + : graph(&g) {} + + inline reference operator[](const key_type &e) const noexcept { + return *static_cast(e.get_property()); + } + inline reference operator()(const key_type &e) const noexcept { + return operator[](e); + } + + Graph *graph{}; +}; + +template +struct EdgeBundleMemberPropertyMap +: public boost::put_get_helper< + Reference, EdgeBundleMemberPropertyMap> { + using value_type = Value; + using reference = Reference; + using key_type = typename Graph::edge_descriptor; + using category = Category; + + EdgeBundleMemberPropertyMap(Graph &g, MemberPointer ptr) noexcept + : graph(&g), memberPointer(ptr) {} + + inline reference operator[](const key_type &e) const noexcept { + auto &p = *static_cast(e.get_property()); + return p.*memberPointer; + } + inline reference operator()(const key_type &e) const noexcept { + return operator[](e); + } + + Graph *graph{}; + MemberPointer memberPointer{}; +}; + +template +void sequenceEraseIf(Sequence &c, Predicate &&p) noexcept { + if (!c.empty()) { + c.erase(std::remove_if(c.begin(), c.end(), p), c.end()); + } +} + +// notice: Predicate might be different from associative key +// when Predicate is associative key, it is slower than erase [lower_bound, upper_bound) +template +void associativeEraseIf(AssociativeContainer &c, Predicate &&p) noexcept { + auto next = c.begin(); + for (auto i = next; next != c.end(); i = next) { + ++next; + if (p(*i)) { + c.erase(i); + } + } +} + +// notice: Predicate might be different from associative key +// when Predicate is associative key, it is slower than erase [lower_bound, upper_bound) +template +void unstableAssociativeEraseIf(AssociativeContainer &c, Predicate &&p) noexcept { + auto n = c.size(); + while (n--) { + for (auto i = c.begin(); i != c.end(); ++i) { + if (p(*i)) { + c.erase(i); + break; + } + } + } +} + +template +inline void removeIncidenceEdge(EdgeDescriptor e, IncidenceList &el) noexcept { + e.expectsNoProperty(); + for (auto i = el.begin(); i != el.end(); ++i) { + if ((*i).get_target() == e.target) { + el.erase(i); + return; + } + } +} + +template +inline void removeIncidenceEdge( + EdgeDescriptorWithProperty e, IncidenceList &el) noexcept { + for (auto i = el.begin(); i != el.end(); ++i) { + if (static_cast(&(*i).get_property()) == e.get_property()) { + el.erase(i); + return; + } + } +} + +template +inline void removeDirectedAllEdgeProperties(Graph &g, IncidenceList &el, VertexDescriptor v) noexcept { + auto i = el.begin(); + auto end = el.end(); + for (; i != end; ++i) { + if ((*i).get_target() == v) { + // NOTE: Wihtout this skip, this loop will double-delete + // properties of loop edges. This solution is based on the + // observation that the incidence edges of a vertex with a loop + // are adjacent in the out edge list. This *may* actually hold + // for multisets also. + bool skip = (std::next(i) != end && i->get_iter() == std::next(i)->get_iter()); + g.edges.erase((*i).get_iter()); + if (skip) { + ++i; + } + } + } +} + +template +inline void sequenceRemoveIncidenceEdgeIf(IncidenceIterator first, IncidenceIterator last, + IncidenceList &el, Predicate &&pred) noexcept { + // remove_if + while (first != last && !pred(*first)) { + ++first; + } + auto i = first; + if (first != last) { + for (++i; i != last; ++i) { + if (!pred(*i)) { + *first.base() = std::move(*i.base()); + ++first; + } + } + } + el.erase(first.base(), el.end()); +} + +template +inline void associativeRemoveIncidenceEdgeIf(IncidenceIterator first, IncidenceIterator last, + IncidenceList &el, Predicate &&pred) noexcept { + for (auto next = first; first != last; first = next) { + ++next; + if (pred(*first)) { + el.erase(first.base()); + } + } +} + +template +inline void removeUndirectedEdge(Graph &g, EdgeDescriptor e, EdgeProperty &p) noexcept { + auto &outEdgeList = g.getOutEdgeList(source(e, g)); + auto outEdgeIter = outEdgeList.begin(); + decltype((*outEdgeIter).get_iter()) edgeIterToErase; + for (; outEdgeIter != outEdgeList.end(); ++outEdgeIter) { + if (&(*outEdgeIter).get_property() == &p) { + edgeIterToErase = (*outEdgeIter).get_iter(); + outEdgeList.erase(outEdgeIter); + break; + } + } + auto &inEdgeList = g.getOutEdgeList(target(e, g)); + auto inEdgeIter = inEdgeList.begin(); + for (; inEdgeIter != inEdgeList.end(); ++inEdgeIter) { + if (&(*inEdgeIter).get_property() == &p) { + inEdgeList.erase(inEdgeIter); + break; + } + } + g.edges.erase(edgeIterToErase); +} + +template +inline void sequenceRemoveUndirectedOutEdgeIf(Graph &g, + IncidenceIterator first, IncidenceIterator last, IncidenceList &el, + Predicate &&pred) noexcept { + // remove_if + while (first != last && !pred(*first)) { + ++first; + } + auto i = first; + bool selfLoopRemoved = false; + if (first != last) { + for (; i != last; ++i) { + if (selfLoopRemoved) { + /* With self loops, the descriptor will show up + * twice. The first time it will be removed, and now it + * will be skipped. + */ + selfLoopRemoved = false; + } else if (!pred(*i)) { + *first.base() = std::move(*i.base()); + ++first; + } else { + if (source(*i, g) == target(*i, g)) { + selfLoopRemoved = true; + } else { + // Remove the edge from the target + removeIncidenceEdge(*i, g.getOutEdgeList(target(*i, g))); + } + + // Erase the edge property + g.edges.erase((*i.base()).get_iter()); + } + } + } + el.erase(first.base(), el.end()); +} + +template +inline void associativeRemoveUndirectedOutEdgeIf(Graph &g, + IncidenceIterator first, IncidenceIterator last, IncidenceList &el, + Predicate &&pred) noexcept { + for (auto next = first; first != last; first = next) { + ++next; + if (pred(*first)) { + if (source(*first, g) != target(*first, g)) { + // Remove the edge from the target + removeIncidenceEdge(*first, g.getOutEdgeList(target(*first, g))); + } + + // Erase the edge property + g.edges.erase((*first.base()).get_iter()); + + // Erase the edge in the source + el.erase(first.base()); + } + } +} + +// list/vector out_edge_list +template +inline void reindexEdgeList(IncidenceList &el, VertexDescriptor u) { + auto ei = el.begin(); + auto eEnd = el.end(); + for (; ei != eEnd; ++ei) { + if ((*ei).get_target() > u) { + --(*ei).get_target(); + } + } +} + +template +inline void reindexVectorHandle(Container &container, HandleDescriptor u) { + static_assert(std::is_arithmetic::value, "reindexVectorHandle"); + + using handle_type = ValueHandle; + for (auto &vert : container) { + if (boost::variant2::holds_alternative(vert.handle)) { + auto &v = boost::variant2::get(vert.handle).value; + if (v > u) { + --v; + } + } + } +} + +template +inline void removeVectorVertex(Graph &g, VertexDescriptor u, boost::directed_tag /*tag*/) { + g.vertices.erase(g.vertices.begin() + u); + auto numV = num_vertices(g); + if (u != numV) { + for (VertexDescriptor v = 0; v < numV; ++v) { + reindexEdgeList(g.getOutEdgeList(v), u); + } + } +} + +template +inline void removeVectorVertex(Graph &g, VertexDescriptor u, boost::undirected_tag /*tag*/) { + g.vertices.erase(g.vertices.begin() + u); + VertexDescriptor numV = num_vertices(g); + for (VertexDescriptor v = 0; v < numV; ++v) { + reindexEdgeList(g.getOutEdgeList(v), u); + } + + auto ei = g.edges.begin(); + auto eiEnd = g.edges.end(); + for (; ei != eiEnd; ++ei) { + if (ei->source > u) { + --ei->source; + } + if (ei->target > u) { + --ei->target; + } + } +} + +template +inline void removeVectorVertex(Graph &g, VertexDescriptor u, boost::bidirectional_tag /*tag*/) { + g.vertices.erase(g.vertices.begin() + u); + VertexDescriptor numV = num_vertices(g); + VertexDescriptor v; + if (u != numV) { + for (v = 0; v < numV; ++v) { + reindexEdgeList(g.getOutEdgeList(v), u); + } + + for (v = 0; v < numV; ++v) { + reindexEdgeList(g.getInEdgeList(v), u); + } + } +} + +template +inline void removeVectorVertex(Graph &g, EdgeList &/*edges*/, + VertexDescriptor u, boost::bidirectional_tag /*tag*/) { + g.vertices.erase(g.vertices.begin() + u); + VertexDescriptor numV = num_vertices(g); + VertexDescriptor v; + if (u != numV) { + for (v = 0; v < numV; ++v) { + reindexEdgeList(g.getOutEdgeList(v), u); + } + + for (v = 0; v < numV; ++v) { + reindexEdgeList(g.getInEdgeList(v), u); + } + + auto ei = g.edges.begin(); + auto eiEnd = g.edges.end(); + for (; ei != eiEnd; ++ei) { + if (ei->source > u) { + --ei->source; + } + if (ei->target > u) { + --ei->target; + } + } + } +} + +template +inline void removeVectorOwner(Graph &g, typename Graph::vertex_descriptor u) { + // might make children detached + g.mObjects.erase(g.mObjects.begin() + u); + auto numV = num_vertices(g); + if (u != numV) { + for (typename Graph::vertex_descriptor v = 0; v < numV; ++v) { + reindexEdgeList(g.getChildrenList(v), u); + } + + for (typename Graph::vertex_descriptor v = 0; v < numV; ++v) { + reindexEdgeList(g.getParentsList(v), u); + } + } +} + +// AddressableGraph +template +inline std::ptrdiff_t pathLength(typename AddressableGraph::vertex_descriptor u, const AddressableGraph &g, + typename AddressableGraph::vertex_descriptor parentID = AddressableGraph::null_vertex()) noexcept { + if (u == parentID) { + return 0; + } + + const auto &pmap = get(boost::vertex_name, g); + + std::ptrdiff_t sz = 0; + while (u != parentID) { + sz += static_cast(get(pmap, u).size()) + 1; + u = parent(u, g); + } + + return sz; +} + +template +inline void pathComposite( + std::basic_string, Allocator> &str, + std::ptrdiff_t &sz, + typename AddressableGraph::vertex_descriptor u, const AddressableGraph &g, + typename AddressableGraph::vertex_descriptor parentID = AddressableGraph::null_vertex()) noexcept { + const auto &pmap = get(boost::vertex_name, g); + + while (u != parentID) { + CC_EXPECTS(sz <= static_cast(str.size())); + + const auto &name = get(pmap, u); + sz -= static_cast(name.size()) + 1; + CC_ENSURES(sz >= 0); + str[sz] = '/'; + std::copy(name.begin(), name.end(), str.begin() + sz + 1); + + u = parent(u, g); + } + CC_ENSURES(sz == 0); +} + +template +struct ColorMap : public boost::put_get_helper> { + using value_type = boost::default_color_type; + using reference = boost::default_color_type &; + using key_type = Key; + using category = boost::lvalue_property_map_tag; + + ColorMap(boost::container::pmr::vector &vec) noexcept // NOLINT(google-explicit-constructor) + : container{&vec} {} + + inline reference operator[](const key_type &v) const noexcept { + return (*container)[v]; + } + inline reference operator()(const key_type &v) const noexcept { + return operator[](v); + } + + boost::container::pmr::vector *container{}; +}; + +} // namespace impl + +} // namespace render + +} // namespace cc + +namespace std { + +template +struct hash> { + size_t operator()(const cc::render::impl::EdgeDescriptor &e) const noexcept { + return boost::hash_value(e.get_property()); + } +}; + +} // namespace std diff --git a/native/cocos/renderer/pipeline/custom/GraphTypes.h b/native/cocos/renderer/pipeline/custom/GraphTypes.h new file mode 100644 index 0000000000..f18da5de69 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/GraphTypes.h @@ -0,0 +1,625 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { + +struct use_default; + +struct directed_tag; +struct undirected_tag; +struct bidirectional_tag; + +struct no_property; + +} // namespace boost + +namespace cc { + +template +using PmrList = std::list>; + +namespace render { + +template +struct VertexOverloaded : Overloaded { + VertexOverloaded(Ts... ts) // NOLINT + : Overloaded(std::move(ts)...) {} + template + auto operator()(T* ptr) { + return this->Overloaded::operator()(*ptr); + } +}; + +template +auto visitObject(typename GraphT::vertex_descriptor v, GraphT& g, Ts... args) { + return cc::visit(VertexOverloaded{ std::move(args)... }, value(v, g)); +} + +namespace impl { + +//-------------------------------------------------------------------- +// EdgeDescriptor +//-------------------------------------------------------------------- +template +struct EdgeDescriptor { + EdgeDescriptor() = default; + EdgeDescriptor(VertexDescriptor s, VertexDescriptor t) noexcept // NOLINT + : source(s), target(t) {} + + void expectsNoProperty() const noexcept { + // CC_EXPECTS(false); + } + VertexDescriptor source{static_cast(-1)}; + VertexDescriptor target{static_cast(-1)}; +}; + +template +inline bool operator==( + const EdgeDescriptor &lhs, + const EdgeDescriptor &rhs) noexcept { + return lhs.source == rhs.source && + lhs.target == rhs.target; +} + +template +inline bool operator==( + const EdgeDescriptor &lhs, + const EdgeDescriptor &rhs) noexcept { + return lhs.source == rhs.source && + lhs.target == rhs.target; +} + +template +inline bool operator!=( + const EdgeDescriptor &lhs, + const EdgeDescriptor &rhs) noexcept { + return !(lhs == rhs); +} + +template +inline bool operator!=( + const EdgeDescriptor &lhs, + const EdgeDescriptor &rhs) noexcept { + return !(lhs == rhs); +} + +template +struct EdgeDescriptorWithProperty : EdgeDescriptor { + using property_type = void; + + EdgeDescriptorWithProperty() = default; + EdgeDescriptorWithProperty(VertexDescriptor s, VertexDescriptor t, const property_type *p) noexcept + : EdgeDescriptor(s, t), edgeProperty(const_cast(p)) {} + + property_type *get_property() const noexcept { // NOLINT + return edgeProperty; + } + + property_type *edgeProperty{}; +}; + +template +inline bool operator==( + const EdgeDescriptorWithProperty &lhs, + const EdgeDescriptorWithProperty &rhs) noexcept { + return lhs.edgeProperty == rhs.edgeProperty; +} + +template +inline bool operator!=( + const EdgeDescriptorWithProperty &lhs, + const EdgeDescriptorWithProperty &rhs) noexcept { + return !(lhs == rhs); +} + +template +inline bool operator<( + const EdgeDescriptorWithProperty &lhs, + const EdgeDescriptorWithProperty &rhs) noexcept { + return lhs.edgeProperty < rhs.edgeProperty; +} + +//-------------------------------------------------------------------- +// StoredEdge +//-------------------------------------------------------------------- +template +class StoredEdge { +public: + StoredEdge(VertexDescriptor target) noexcept // NOLINT(google-explicit-constructor) + : target(target) {} + const VertexDescriptor &get_target() const noexcept { // NOLINT + return target; + } + VertexDescriptor &get_target() noexcept { // NOLINT + return target; + } + // auto operator<=>(const StoredEdge&) const noexcept = default; + + VertexDescriptor target; +}; + +template +inline bool operator==( + const StoredEdge &lhs, + const StoredEdge &rhs) noexcept { + return lhs.target == rhs.target; +} + +template +inline bool operator!=( + const StoredEdge &lhs, + const StoredEdge &rhs) noexcept { + return !(lhs == rhs); +} + +template +inline bool operator<( + const StoredEdge &lhs, + const StoredEdge &rhs) noexcept { + return lhs.target < rhs.target; +} + +template +class StoredEdgeWithProperty : public StoredEdge { +public: + StoredEdgeWithProperty(VertexDescriptor target, const EdgeProperty &p) + : StoredEdge(target), property(new EdgeProperty(p)) {} + StoredEdgeWithProperty(VertexDescriptor target, std::unique_ptr &&ptr) + : StoredEdge(target), property(std::move(ptr)) {} + StoredEdgeWithProperty(VertexDescriptor target) // NOLINT(google-explicit-constructor) + : StoredEdge(target) {} + + StoredEdgeWithProperty(StoredEdgeWithProperty &&) noexcept = default; + StoredEdgeWithProperty &operator=(StoredEdgeWithProperty &&) noexcept = default; + + EdgeProperty &get_property() noexcept { // NOLINT + CC_EXPECTS(property); + return *property; + } + const EdgeProperty &get_property() const noexcept { // NOLINT + CC_EXPECTS(property); + return *property; + } + std::unique_ptr property; +}; + +template +class StoredEdgeWithEdgeIter : public StoredEdge { +public: + StoredEdgeWithEdgeIter(VertexDescriptor v, EdgeListIter iter) noexcept + : StoredEdge(v), _edgeListIter(iter) {} + StoredEdgeWithEdgeIter(VertexDescriptor v) noexcept // NOLINT(google-explicit-constructor) + : StoredEdge(v) {} + + EdgeListIter get_iter() const noexcept { // NOLINT + return _edgeListIter; + } + EdgeProperty &get_property() noexcept { // NOLINT + return _edgeListIter->get_property(); + } + const EdgeProperty &get_property() const noexcept { // NOLINT + return _edgeListIter->get_property(); + } + +protected: + EdgeListIter _edgeListIter{}; +}; + +template +class StoredEdgeWithRandomAccessEdgeIter : public StoredEdge { +public: + StoredEdgeWithRandomAccessEdgeIter( + VertexDescriptor v, typename EdgeVec::iterator i, EdgeVec *edgeVec) noexcept + : StoredEdge(v), _id(i - edgeVec->begin()), _vector(edgeVec) {} + + typename EdgeVec::iterator get_iter() const noexcept { // NOLINT + CC_EXPECTS(_vector); + return _vector->begin() + _id; + } + EdgeProperty &get_property() noexcept { // NOLINT + CC_EXPECTS(_vector); + return (*_vector)[_id].get_property(); + } + const EdgeProperty &get_property() const noexcept { // NOLINT + CC_EXPECTS(_vector); + return (*_vector)[_id].get_property(); + } + +protected: + size_t _id{static_cast(-1)}; + EdgeVec *_vector{}; +}; + +//-------------------------------------------------------------------- +// VertexIterator +//-------------------------------------------------------------------- +template +struct VertexIter : boost::iterator_adaptor< + VertexIter, + BaseIter, VertexDescriptor, boost::use_default, VertexDescriptor, Difference> { + using Base = boost::iterator_adaptor< + VertexIter, + BaseIter, VertexDescriptor, boost::use_default, VertexDescriptor, Difference>; + + VertexIter() = default; + VertexIter(const BaseIter &i) noexcept // NOLINT(google-explicit-constructor) + : Base(i) {} + + VertexDescriptor dereference() const noexcept { + return VertexDescriptor{&(*this->base())}; + } +}; + +template +struct VertexMapPtrIter : boost::iterator_adaptor< + VertexMapPtrIter, + BaseIter, VertexDescriptor, boost::use_default, VertexDescriptor, Difference> { + using Base = boost::iterator_adaptor< + VertexMapPtrIter, + BaseIter, VertexDescriptor, boost::use_default, VertexDescriptor, Difference>; + + VertexMapPtrIter() = default; + VertexMapPtrIter(const BaseIter &i) noexcept // NOLINT(google-explicit-constructor) + : Base(i) {} + + VertexDescriptor dereference() const noexcept { + return VertexDescriptor{this->base()->second.get()}; + } +}; + +//-------------------------------------------------------------------- +// OutEdgeIterator +//-------------------------------------------------------------------- +template +struct OutEdgeIter : boost::iterator_adaptor< + OutEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference> { + using Base = boost::iterator_adaptor< + OutEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference>; + + OutEdgeIter() = default; + OutEdgeIter(const BaseIter &i, const VertexDescriptor &src) noexcept + : Base(i), source(src) {} + + EdgeDescriptor dereference() const noexcept { + // this->base() return out edge list iterator + return EdgeDescriptor{ + source, (*this->base()).get_target()}; + } + VertexDescriptor source{}; +}; + +template +struct OutPropertyEdgeIter : boost::iterator_adaptor< + OutPropertyEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference> { + using Base = boost::iterator_adaptor< + OutPropertyEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference>; + + OutPropertyEdgeIter() = default; + OutPropertyEdgeIter(const BaseIter &i, const VertexDescriptor &src) noexcept + : Base(i), source(src) {} + + EdgeDescriptor dereference() const noexcept { + // this->base() return out edge list iterator + return EdgeDescriptor{ + source, (*this->base()).get_target(), &(*this->base()).get_property()}; + } + VertexDescriptor source{}; +}; + +//-------------------------------------------------------------------- +// InEdgeIterator +//-------------------------------------------------------------------- +template +struct InEdgeIter : boost::iterator_adaptor< + InEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference> { + using Base = boost::iterator_adaptor< + InEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference>; + + InEdgeIter() = default; + InEdgeIter(const BaseIter &i, const VertexDescriptor &src) noexcept + : Base(i), source(src) {} + + EdgeDescriptor dereference() const noexcept { + return EdgeDescriptor{ + (*this->base()).get_target(), source}; + } + VertexDescriptor source{}; +}; + +template +struct InPropertyEdgeIter : boost::iterator_adaptor< + InPropertyEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference> { + using Base = boost::iterator_adaptor< + InPropertyEdgeIter, + BaseIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference>; + + InPropertyEdgeIter() = default; + InPropertyEdgeIter(const BaseIter &i, const VertexDescriptor &src) noexcept + : Base(i), source(src) {} + + EdgeDescriptor dereference() const noexcept { + return EdgeDescriptor{ + (*this->base()).get_target(), source, &this->base()->get_property()}; + } + VertexDescriptor source{}; +}; + +//-------------------------------------------------------------------- +// EdgeIterator +//-------------------------------------------------------------------- +// UndirectedEdgeIter (Bidirectional || Undirected) +template +struct UndirectedEdgeIter : boost::iterator_adaptor< + UndirectedEdgeIter, + EdgeIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference> { + using Base = boost::iterator_adaptor< + UndirectedEdgeIter, + EdgeIter, EdgeDescriptor, boost::use_default, EdgeDescriptor, Difference>; + + UndirectedEdgeIter() = default; + explicit UndirectedEdgeIter(EdgeIter i) noexcept : Base(i) {} + + EdgeDescriptor dereference() const noexcept { + return EdgeDescriptor{ + (*this->base()).source, (*this->base()).target, &this->base()->get_property()}; + } +}; + +// DirectedEdgeIterator +template +class DirectedEdgeIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = typename OutEdgeIterator::value_type; + using reference = typename OutEdgeIterator::reference; + using pointer = typename OutEdgeIterator::pointer; + using difference_type = typename OutEdgeIterator::difference_type; + using distance_type = difference_type; + + DirectedEdgeIterator() = default; + template + DirectedEdgeIterator(VertexIterator b, VertexIterator c, VertexIterator e, const G &g) noexcept + : _begin(b), _curr(c), _end(e), _g(&g) { + if (_curr != _end) { + while (_curr != _end && out_degree(*_curr, *_g) == 0) { + ++_curr; + } + if (_curr != _end) { + _edges = out_edges(*_curr, *_g); + } + } + } + + DirectedEdgeIterator &operator++() noexcept { + ++_edges->first; + if (_edges->first == _edges->second) { + ++_curr; + while (_curr != _end && out_degree(*_curr, *_g) == 0) { + ++_curr; + } + if (_curr != _end) { + _edges = out_edges(*_curr, *_g); + } + } + return *this; + } + DirectedEdgeIterator operator++(int) noexcept { + DirectedEdgeIterator tmp = *this; + ++(*this); + return tmp; + } + value_type operator*() const noexcept { + return *_edges->first; + } + bool operator==(const DirectedEdgeIterator &x) const noexcept { + return _curr == x._curr && (_curr == _end || _edges->first == x._edges->first); + } + bool operator!=(const DirectedEdgeIterator &x) const noexcept { + return _curr != x._curr || (_curr != _end && _edges->first != x._edges->first); + } + +protected: + VertexIterator _begin{}; + VertexIterator _curr{}; + VertexIterator _end{}; + boost::optional> _edges; + const Graph *_g{}; +}; + +//-------------------------------------------------------------------- +// EdgeListGraph +//-------------------------------------------------------------------- +template +struct ListEdge { + ListEdge(VertexDescriptor s, VertexDescriptor t) // NOLINT + : source(s), target(t) {} + + ListEdge(VertexDescriptor s, VertexDescriptor t, EdgeProperty &&p) // NOLINT + : source(s), target(t), property(std::move(p)) {} + + ListEdge(VertexDescriptor s, VertexDescriptor t, const EdgeProperty &p) // NOLINT + : source(s), target(t), property(p) {} + + template + ListEdge(VertexDescriptor s, VertexDescriptor t, T &&...args) // NOLINT + : source(s), target(t), property(std::forward(args)...) {} + + EdgeProperty &get_property() noexcept { return property; } // NOLINT + const EdgeProperty &get_property() const noexcept { return property; } // NOLINT + + VertexDescriptor source{}; + VertexDescriptor target{}; + EdgeProperty property; +}; + +// template +template +struct PmrListEdge { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return allocator_type{property.get_allocator().resource()}; + } + // cntrs + PmrListEdge(VertexDescriptor s, VertexDescriptor t, const allocator_type &alloc) // NOLINT + : source(s), target(t), property(alloc) {} + + PmrListEdge(VertexDescriptor s, VertexDescriptor t, EdgeProperty &&p, const allocator_type &alloc) // NOLINT + : source(s), target(t), property(std::move(p), alloc) {} + + PmrListEdge(VertexDescriptor s, VertexDescriptor t, const EdgeProperty &p, const allocator_type &alloc) // NOLINT + : source(s), target(t), property(p, alloc) {} + + template + PmrListEdge(VertexDescriptor s, VertexDescriptor t, T &&...args) // NOLINT + : source(s), target(t), property(std::forward(args)...) {} + + // move/copy cntrs + PmrListEdge(PmrListEdge &&rhs, const allocator_type &alloc) + : source(std::move(rhs.source)), target(std::move(rhs.target)), property(std::move(rhs.property), alloc) {} + PmrListEdge(const PmrListEdge &rhs, const allocator_type &alloc) + : source(rhs.source), target(rhs.target), property(rhs.property, alloc) {} + + PmrListEdge(const PmrListEdge &) = delete; + + EdgeProperty &get_property() noexcept { return property; } // NOLINT + const EdgeProperty &get_property() const noexcept { return property; } // NOLINT + + VertexDescriptor source{}; + VertexDescriptor target{}; + EdgeProperty property; +}; + +// Polymorphic Graph +template +struct ValueHandle : Tag { + ValueHandle() noexcept = default; + ValueHandle(ValueHandle &&rhs) noexcept + : value(std::move(rhs.value)) {} + ValueHandle(const ValueHandle &rhs) noexcept + : value(rhs.value) {} + ValueHandle &operator=(ValueHandle &&rhs) noexcept { + value = std::move(rhs.value); + return *this; + } + ValueHandle &operator=(const ValueHandle &rhs) noexcept { + value = rhs.value; + return *this; + } + + ValueHandle(const Handle &handle) noexcept // NOLINT(google-explicit-constructor) + : value(handle) {} + ValueHandle(Handle &&handle) noexcept // NOLINT(google-explicit-constructor) + : value(std::move(handle)) {} + template + ValueHandle(Args &&...args) noexcept // NOLINT(google-explicit-constructor) + : value(std::forward(args)...) {} + + Handle value{}; +}; + +// Reference Graph +// OwnershipIterator (Bidirectional, !EdgeProperty) +template +class OwnershipIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = typename OutEdgeIterator::value_type; + using reference = typename OutEdgeIterator::reference; + using pointer = typename OutEdgeIterator::pointer; + using difference_type = typename OutEdgeIterator::difference_type; + using distance_type = difference_type; + + OwnershipIterator() = default; + template + OwnershipIterator(VertexIterator b, VertexIterator c, VertexIterator e, const G &g) noexcept + : _begin(b), _curr(c), _end(e), _g(&g) { + if (_curr != _end) { + while (_curr != _end && num_children(*_curr, *_g) == 0) { + ++_curr; + } + if (_curr != _end) { + _edges = children(*_curr, *_g); + } + } + } + + OwnershipIterator &operator++() noexcept { + ++_edges->first; + if (_edges->first == _edges->second) { + ++_curr; + while (_curr != _end && num_children(*_curr, *_g) == 0) { + ++_curr; + } + if (_curr != _end) { + _edges = children(*_curr, *_g); + } + } + return *this; + } + OwnershipIterator operator++(int) noexcept { + OwnershipIterator tmp = *this; + ++(*this); + return tmp; + } + value_type operator*() const noexcept { + return *_edges->first; + } + bool operator==(const OwnershipIterator &x) const noexcept { + return _curr == x._curr && (_curr == _end || _edges->first == x._edges->first); + } + bool operator!=(const OwnershipIterator &x) const noexcept { + return _curr != x._curr || (_curr != _end && _edges->first != x._edges->first); + } + +protected: + VertexIterator _begin{}; + VertexIterator _curr{}; + VertexIterator _end{}; + boost::optional> _edges; + const Graph *_g{}; +}; + +} // namespace impl + +} // namespace render + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/GslUtils.h b/native/cocos/renderer/pipeline/custom/GslUtils.h new file mode 100644 index 0000000000..ed43ca9428 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/GslUtils.h @@ -0,0 +1,46 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include + +namespace cc { + +namespace gsl { + +// narrow_cast(): a searchable way to do narrowing casts of values +template +constexpr T narrow_cast(U &&u) noexcept { // NOLINT + return static_cast(std::forward(u)); +} + +#define CC_EXPECTS(cond) CC_ASSERT(cond) // NOLINT + +#define CC_ENSURES(cond) CC_ASSERT(cond) // NOLINT + +} // namespace gsl + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/JsbConversion.h b/native/cocos/renderer/pipeline/custom/JsbConversion.h new file mode 100644 index 0000000000..7c405db2ea --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/JsbConversion.h @@ -0,0 +1,98 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include + +template +inline bool nativevalue_to_se( // NOLINT(readability-identifier-naming) + const boost::container::vector& from, + se::Value& to, se::Object* ctx) { + se::Object* array = se::Object::createArrayObject(from.size()); + se::Value tmp; + for (size_t i = 0; i < from.size(); i++) { + nativevalue_to_se(from[i], tmp, ctx); + array->setArrayElement(static_cast(i), tmp); + } + to.setObject(array); + array->decRef(); + return true; +} + +inline bool nativevalue_to_se( // NOLINT(readability-identifier-naming) + const cc::PmrString& from, se::Value& to, se::Object* /*ctx*/) { + to.setString(from.c_str()); + return true; +} + +template +bool sevalue_to_native(const se::Value& from, boost::container::vector* to, se::Object* ctx) { // NOLINT(readability-identifier-naming) + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + + assert(from.toObject()); + se::Object *array = from.toObject(); + + if (array->isArray()) { + uint32_t len = 0; + array->getArrayLength(&len); + to->resize(len); + se::Value tmp; + for (uint32_t i = 0; i < len; i++) { + array->getArrayElement(i, &tmp); + if (!sevalue_to_native(tmp, to->data() + i, ctx)) { + SE_LOGE("vector %s convert error at %d\n", typeid(T).name(), i); + } + } + return true; + } + + if (array->isTypedArray()) { + assert(std::is_arithmetic::value); + uint8_t *data = nullptr; + size_t dataLen = 0; + array->getTypedArrayData(&data, &dataLen); + to->assign(reinterpret_cast(data), reinterpret_cast(data + dataLen)); + return true; + } + + SE_LOGE("[warn] failed to convert to boost::container::vector\n"); + return false; +} + +inline bool sevalue_to_native(const se::Value& from, cc::PmrString* to, se::Object* /*ctx*/) { // NOLINT(readability-identifier-naming) + if (!from.isNullOrUndefined()) { + const auto& str = from.toString(); + to->assign(str.begin(), str.end()); + } else { + to->clear(); + } + return true; +} diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h b/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h new file mode 100644 index 0000000000..af00014024 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h @@ -0,0 +1,62 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" + +namespace cc { + +namespace render { + +struct Constant; +struct ConstantBuffer; + +using DescriptorType = boost::variant2::variant; + +struct DescriptorBlock; +struct DescriptorArray; +struct UnboundedDescriptor; +struct DescriptorTable; +struct DescriptorSet; +struct LayoutData; +struct ShaderProgramData; +struct GroupNodeData; +struct ShaderNodeData; +struct GroupTag; +struct ShaderTag; +struct LayoutGraphData; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h new file mode 100644 index 0000000000..84644c88bb --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h @@ -0,0 +1,1130 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/GraphImpl.h" +#include "cocos/renderer/pipeline/custom/GslUtils.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" +#include "cocos/renderer/pipeline/custom/Overload.h" +#include "cocos/renderer/pipeline/custom/PathUtils.h" +#include "cocos/renderer/pipeline/custom/invoke.hpp" + +namespace cc { + +namespace render { + +// IncidenceGraph +inline LayoutGraphData::vertex_descriptor +source(const LayoutGraphData::edge_descriptor& e, const LayoutGraphData& /*g*/) noexcept { + return e.source; +} + +inline LayoutGraphData::vertex_descriptor +target(const LayoutGraphData::edge_descriptor& e, const LayoutGraphData& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return std::make_pair( + LayoutGraphData::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + LayoutGraphData::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline LayoutGraphData::degree_size_type +out_degree(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(LayoutGraphData::vertex_descriptor u, LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), LayoutGraphData::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {LayoutGraphData::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return std::make_pair( + LayoutGraphData::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + LayoutGraphData::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline LayoutGraphData::degree_size_type +in_degree(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline LayoutGraphData::degree_size_type +degree(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(LayoutGraphData::adjacency_iterator(edges.first, &g), LayoutGraphData::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const LayoutGraphData& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline LayoutGraphData::vertices_size_type +num_vertices(const LayoutGraphData& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const LayoutGraphData& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + LayoutGraphData::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + LayoutGraphData::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline LayoutGraphData::edges_size_type +num_edges(const LayoutGraphData& g) noexcept { // NOLINT + LayoutGraphData::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 +add_edge( // NOLINT + LayoutGraphData::vertex_descriptor u, + LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u); + + return std::make_pair(LayoutGraphData::edge_descriptor(u, v), true); +} + +inline void remove_edge(LayoutGraphData::vertex_descriptor u, LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) noexcept { // NOLINT + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(LayoutGraphData::edge_descriptor e, LayoutGraphData& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(LayoutGraphData::out_edge_iterator iter, LayoutGraphData& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(LayoutGraphData::vertex_descriptor u, Predicate&& pred, LayoutGraphData& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(LayoutGraphData::vertex_descriptor v, Predicate&& pred, LayoutGraphData& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, LayoutGraphData& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// AddressableGraph +inline LayoutGraphData::vertex_descriptor +parent(const LayoutGraphData::ownership_descriptor& e, const LayoutGraphData& /*g*/) noexcept { + return e.source; +} + +inline LayoutGraphData::vertex_descriptor +child(const LayoutGraphData::ownership_descriptor& e, const LayoutGraphData& /*g*/) noexcept { + return e.target; +} + +inline std::pair +children(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + return std::make_pair( + LayoutGraphData::children_iterator(const_cast(g).getChildrenList(u).begin(), u), + LayoutGraphData::children_iterator(const_cast(g).getChildrenList(u).end(), u)); +} + +inline LayoutGraphData::children_size_type +num_children(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getChildrenList(u).size()); +} + +inline std::pair +ownership(LayoutGraphData::vertex_descriptor u, LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) noexcept { + auto& outEdgeList = g.getChildrenList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), LayoutGraphData::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {LayoutGraphData::ownership_descriptor(u, v), hasEdge}; +} + +inline std::pair +parents(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + return std::make_pair( + LayoutGraphData::parent_iterator(const_cast(g).getParentsList(u).begin(), u), + LayoutGraphData::parent_iterator(const_cast(g).getParentsList(u).end(), u)); +} + +inline LayoutGraphData::children_size_type +num_parents(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getParentsList(u).size()); +} + +inline LayoutGraphData::vertex_descriptor +parent(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + auto r = parents(u, g); + if (r.first == r.second) { + return LayoutGraphData::null_vertex(); + } + return parent(*r.first, g); +} + +inline bool +ancestor(LayoutGraphData::vertex_descriptor u, LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { + CC_EXPECTS(u != v); + bool isAncestor = false; + auto r = parents(v, g); + while (r.first != r.second) { + v = parent(*r.first, g); + if (u == v) { + isAncestor = true; + break; + } + r = parents(v, g); + } + return isAncestor; +} + +inline std::pair +ownerships(const LayoutGraphData& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + LayoutGraphData::ownership_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + LayoutGraphData::ownership_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline LayoutGraphData::ownerships_size_type +num_ownerships(const LayoutGraphData& g) noexcept { // NOLINT + LayoutGraphData::ownerships_size_type numEdges = 0; + auto range = vertices(g); + for (auto iter = range.first; iter != range.second; ++iter) { + numEdges += num_children(*iter, g); + } + return numEdges; +} + +} // namespace render + +} // namespace cc + +namespace boost { + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::LayoutGraphData, + const container::pmr::vector, + boost::string_view, + const std::string&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::LayoutGraphData, + container::pmr::vector, + boost::string_view, + std::string&>; +}; + +// Vertex Name +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::LayoutGraphData, + const container::pmr::vector, + boost::string_view, + const std::string&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::LayoutGraphData, + container::pmr::vector, + boost::string_view, + std::string&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::LayoutGraphData, + const container::pmr::vector, + cc::render::UpdateFrequency, + const cc::render::UpdateFrequency&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::LayoutGraphData, + container::pmr::vector, + cc::render::UpdateFrequency, + cc::render::UpdateFrequency&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::LayoutGraphData, + const container::pmr::vector, + cc::render::LayoutData, + const cc::render::LayoutData&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::LayoutGraphData, + container::pmr::vector, + cc::render::LayoutData, + cc::render::LayoutData&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::LayoutGraphData, + const container::pmr::vector, + T, + const T&, + T cc::render::LayoutData::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::LayoutGraphData, + container::pmr::vector, + T, + T&, + T cc::render::LayoutData::*>; +}; + +} // namespace boost + +namespace cc { + +namespace render { + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const LayoutGraphData& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, LayoutGraphData& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const LayoutGraphData& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(LayoutGraphData::NameTag /*tag*/, const LayoutGraphData& g) noexcept { + return {g.names}; +} + +inline typename boost::property_map::type +get(LayoutGraphData::NameTag /*tag*/, LayoutGraphData& g) noexcept { + return {g.names}; +} + +// Vertex Name +inline boost::property_map::const_type +get(boost::vertex_name_t /*tag*/, const LayoutGraphData& g) noexcept { + return {g.names}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(LayoutGraphData::UpdateTag /*tag*/, const LayoutGraphData& g) noexcept { + return {g.updateFrequencies}; +} + +inline typename boost::property_map::type +get(LayoutGraphData::UpdateTag /*tag*/, LayoutGraphData& g) noexcept { + return {g.updateFrequencies}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(LayoutGraphData::LayoutTag /*tag*/, const LayoutGraphData& g) noexcept { + return {g.layouts}; +} + +inline typename boost::property_map::type +get(LayoutGraphData::LayoutTag /*tag*/, LayoutGraphData& g) noexcept { + return {g.layouts}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T LayoutData::*memberPointer, const LayoutGraphData& g) noexcept { + return {g.layouts, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T LayoutData::*memberPointer, LayoutGraphData& g) noexcept { + return {g.layouts, memberPointer}; +} + +// PolymorphicGraph +inline LayoutGraphData::vertices_size_type +value_id(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + using vertex_descriptor = LayoutGraphData::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }), + g.vertices[u].handle); +} + +inline LayoutGraphData::vertex_tag_type +tag(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + using vertex_descriptor = LayoutGraphData::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle&) { + return LayoutGraphData::vertex_tag_type{GroupTag{}}; + }, + [](const impl::ValueHandle&) { + return LayoutGraphData::vertex_tag_type{ShaderTag{}}; + }), + g.vertices[u].handle); +} + +inline LayoutGraphData::vertex_value_type +value(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { + using vertex_descriptor = LayoutGraphData::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return LayoutGraphData::vertex_value_type{&g.groupNodes[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return LayoutGraphData::vertex_value_type{&g.shaderNodes[h.value]}; + }), + g.vertices[u].handle); +} + +inline LayoutGraphData::vertex_const_value_type +value(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { + using vertex_descriptor = LayoutGraphData::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return LayoutGraphData::vertex_const_value_type{&g.groupNodes[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return LayoutGraphData::vertex_const_value_type{&g.shaderNodes[h.value]}; + }), + g.vertices[u].handle); +} + +template +inline bool +holds_tag(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept; // NOLINT + +template <> +inline bool +holds_tag(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline bool +holds_alternative(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept; // NOLINT + +template <> +inline bool +holds_alternative(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline ValueT& +get(LayoutGraphData::vertex_descriptor /*v*/, LayoutGraphData& /*g*/); + +template <> +inline GroupNodeData& +get(LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.groupNodes[handle.value]; +} + +template <> +inline ShaderNodeData& +get(LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.shaderNodes[handle.value]; +} + +template +inline const ValueT& +get(LayoutGraphData::vertex_descriptor /*v*/, const LayoutGraphData& /*g*/); + +template <> +inline const GroupNodeData& +get(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.groupNodes[handle.value]; +} + +template <> +inline const ShaderNodeData& +get(LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.shaderNodes[handle.value]; +} + +inline GroupNodeData& +get(GroupTag /*tag*/, LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.groupNodes[handle.value]; +} + +inline ShaderNodeData& +get(ShaderTag /*tag*/, LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.shaderNodes[handle.value]; +} + +inline const GroupNodeData& +get(GroupTag /*tag*/, LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.groupNodes[handle.value]; +} + +inline const ShaderNodeData& +get(ShaderTag /*tag*/, LayoutGraphData::vertex_descriptor v, const LayoutGraphData& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.shaderNodes[handle.value]; +} + +template +inline ValueT* +get_if(LayoutGraphData::vertex_descriptor v, LayoutGraphData* pGraph) noexcept; // NOLINT + +template <> +inline GroupNodeData* +get_if(LayoutGraphData::vertex_descriptor v, LayoutGraphData* pGraph) noexcept { // NOLINT + GroupNodeData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.groupNodes[pHandle->value]; + } + return ptr; +} + +template <> +inline ShaderNodeData* +get_if(LayoutGraphData::vertex_descriptor v, LayoutGraphData* pGraph) noexcept { // NOLINT + ShaderNodeData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.shaderNodes[pHandle->value]; + } + return ptr; +} + +template +inline const ValueT* +get_if(LayoutGraphData::vertex_descriptor v, const LayoutGraphData* pGraph) noexcept; // NOLINT + +template <> +inline const GroupNodeData* +get_if(LayoutGraphData::vertex_descriptor v, const LayoutGraphData* pGraph) noexcept { // NOLINT + const GroupNodeData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.groupNodes[pHandle->value]; + } + return ptr; +} + +template <> +inline const ShaderNodeData* +get_if(LayoutGraphData::vertex_descriptor v, const LayoutGraphData* pGraph) noexcept { // NOLINT + const ShaderNodeData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.shaderNodes[pHandle->value]; + } + return ptr; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const LayoutGraphData& g, LayoutGraphData::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, LayoutGraphData& g, LayoutGraphData::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, LayoutGraphData& g, + LayoutGraphData::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// AddressableGraph +inline std::ptrdiff_t +path_length(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { // NOLINT + return impl::pathLength(u, g); +} + +template +inline void +path_composite( // NOLINT + std::basic_string, Allocator>& str, + std::ptrdiff_t& sz, LayoutGraphData::vertex_descriptor u, + const LayoutGraphData& g) noexcept { + impl::pathComposite(str, sz, u, g); +} + +template +inline const std::basic_string, Allocator>& +get_path( // NOLINT + std::basic_string, Allocator>& output, + LayoutGraphData::vertex_descriptor u0, const LayoutGraphData& g, + boost::string_view prefix = {}, LayoutGraphData::vertex_descriptor parent = LayoutGraphData::null_vertex()) { + output.clear(); + const auto sz0 = static_cast(prefix.size()); + auto sz = sz0; + + const auto& layoutGraphData = g; + sz += impl::pathLength(u0, layoutGraphData, parent); + + output.resize(sz); + + impl::pathComposite(output, sz, u0, layoutGraphData, parent); + CC_ENSURES(sz >= sz0); + + CC_ENSURES(sz == sz0); + std::copy(prefix.begin(), prefix.end(), output.begin()); + + return output; +} + +inline std::string +get_path( // NOLINT + LayoutGraphData::vertex_descriptor u0, const LayoutGraphData& g, + boost::string_view prefix = {}, LayoutGraphData::vertex_descriptor parent = LayoutGraphData::null_vertex()) { + std::string output; + get_path(output, u0, g, prefix, parent); + return output; +} + +template +inline const std::basic_string, Allocator>& +get_path( // NOLINT + std::basic_string, Allocator>& output, + LayoutGraphData::vertex_descriptor parent, boost::string_view name, const LayoutGraphData& g) { // NOLINT + output.clear(); + auto sz = path_length(parent, g); + output.resize(sz + name.size() + 1); + output[sz] = '/'; + std::copy(name.begin(), name.end(), output.begin() + sz + 1); + path_composite(output, sz, parent, g); + CC_ENSURES(sz == 0); + return output; +} + +inline std::string +get_path(LayoutGraphData::vertex_descriptor parent, boost::string_view name, const LayoutGraphData& g) { // NOLINT + std::string output; + get_path(output, parent, name, g); + return output; +} + +inline LayoutGraphData::vertex_descriptor +locate(boost::string_view absolute, const LayoutGraphData& g) noexcept { + auto iter = g.pathIndex.find(absolute); + if (iter != g.pathIndex.end()) { + return iter->second; + } + return LayoutGraphData::null_vertex(); +}; + +inline LayoutGraphData::vertex_descriptor +locate(LayoutGraphData::vertex_descriptor u, boost::string_view relative, const LayoutGraphData& g) { + CC_EXPECTS(!relative.starts_with('/')); + CC_EXPECTS(!relative.ends_with('/')); + auto key = get_path(u, relative, g); + impl::cleanPath(key); + return locate(key, g); +}; + +inline bool +contains(boost::string_view absolute, const LayoutGraphData& g) noexcept { + return locate(absolute, g) != LayoutGraphData::null_vertex(); +} + +template +inline ValueT& +get(boost::string_view pt, LayoutGraphData& g) { + auto v = locate(pt, g); + if (v == LayoutGraphData::null_vertex()) { + throw std::out_of_range("at LayoutGraphData"); + } + return get(v, g); +} + +template +inline const ValueT& +get(boost::string_view pt, const LayoutGraphData& g) { + auto v = locate(pt, g); + if (v == LayoutGraphData::null_vertex()) { + throw std::out_of_range("at LayoutGraphData"); + } + return get(v, g); +} + +template +inline ValueT* +get_if(boost::string_view pt, LayoutGraphData* pGraph) noexcept { // NOLINT + if (pGraph) { + auto v = locate(pt, *pGraph); + if (v != LayoutGraphData::null_vertex()) { + return get_if(v, pGraph); + } + } + return nullptr; +} + +template +inline const ValueT* +get_if(boost::string_view pt, const LayoutGraphData* pGraph) noexcept { // NOLINT + if (pGraph) { + auto v = locate(pt, *pGraph); + if (v != LayoutGraphData::null_vertex()) { + return get_if(v, pGraph); + } + } + return nullptr; +} + +// MutableGraph(Vertex) +inline void add_path_impl(LayoutGraphData::vertex_descriptor u, LayoutGraphData::vertex_descriptor v, LayoutGraphData& g) { // NOLINT + // add to parent + if (u != LayoutGraphData::null_vertex()) { + auto& outEdgeList = g.getChildrenList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getParentsList(v); + inEdgeList.emplace_back(u); + } + + // add to external path index + auto pathName = get_path(v, g); + auto res = g.pathIndex.emplace(std::move(pathName), v); + CC_ENSURES(res.second); +} + +inline void remove_path_impl(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { // NOLINT + // notice: here we use std::string, not std::pmr::string + // we do not want to increase the memory of g + auto pathName = get_path(u, g); + auto iter = g.pathIndex.find(boost::string_view(pathName)); + CC_EXPECTS(iter != g.pathIndex.end()); + g.pathIndex.erase(iter); + for (auto&& nvp : g.pathIndex) { + auto& v = nvp.second; + if (v > u) { + --v; + } + } +} + +inline void clear_out_edges(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { // NOLINT + // AddressableGraph (Alias) + // only leaf node can be cleared. + // clear internal node will broke tree structure. + CC_EXPECTS(out_degree(u, g) == 0); + + // 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(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { // NOLINT + // AddressableGraph (Alias) + CC_EXPECTS(out_degree(u, g) == 0); + remove_path_impl(u, g); + + // 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(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { // NOLINT + clear_out_edges(u, g); + clear_in_edges(u, g); +} + +inline void remove_vertex_value_impl(const LayoutGraphData::vertex_handle_type& h, LayoutGraphData& g) noexcept { // NOLINT + using vertex_descriptor = LayoutGraphData::vertex_descriptor; + cc::visit( + overload( + [&](const impl::ValueHandle& h) { + g.groupNodes.erase(g.groupNodes.begin() + std::ptrdiff_t(h.value)); + if (h.value == g.groupNodes.size()) { + return; + } + impl::reindexVectorHandle(g.vertices, h.value); + }, + [&](const impl::ValueHandle& h) { + g.shaderNodes.erase(g.shaderNodes.begin() + std::ptrdiff_t(h.value)); + if (h.value == g.shaderNodes.size()) { + return; + } + impl::reindexVectorHandle(g.vertices, h.value); + }), + h); +} + +inline void remove_vertex(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { // NOLINT + // preserve vertex' iterators + auto& vert = g.vertices[u]; + remove_vertex_value_impl(vert.handle, g); + impl::removeVectorVertex(const_cast(g), u, LayoutGraphData::directed_category{}); + + // remove components + g.names.erase(g.names.begin() + std::ptrdiff_t(u)); + g.updateFrequencies.erase(g.updateFrequencies.begin() + std::ptrdiff_t(u)); + g.layouts.erase(g.layouts.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Vertex) +template +void add_vertex_impl( // NOLINT + ValueT &&val, LayoutGraphData &g, LayoutGraphData::vertex_type &vert, // NOLINT + std::enable_if_t, GroupNodeData>::value>* dummy = nullptr) { // NOLINT + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.groupNodes.size())}; + g.groupNodes.emplace_back(std::forward(val)); +} + +template +void add_vertex_impl( // NOLINT + ValueT &&val, LayoutGraphData &g, LayoutGraphData::vertex_type &vert, // NOLINT + std::enable_if_t, ShaderNodeData>::value>* dummy = nullptr) { // NOLINT + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.shaderNodes.size())}; + g.shaderNodes.emplace_back(std::forward(val)); +} + +template +inline LayoutGraphData::vertex_descriptor +add_vertex(Component0&& c0, Component1&& c1, Component2&& c2, ValueT&& val, LayoutGraphData& g, LayoutGraphData::vertex_descriptor u = LayoutGraphData::null_vertex()) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + auto& vert = g.vertices.back(); + g.names.emplace_back(std::forward(c0)); + g.updateFrequencies.emplace_back(std::forward(c1)); + g.layouts.emplace_back(std::forward(c2)); + + // PolymorphicGraph + // if no matching overloaded function is found, Type is not supported by PolymorphicGraph + add_vertex_impl(std::forward(val), g, vert); + + // AddressableGraph + add_path_impl(u, v, g); + + return v; +} + +template +void add_vertex_impl(GroupTag /*tag*/, Tuple &&val, LayoutGraphData &g, LayoutGraphData::vertex_type &vert) { // NOLINT + invoke_hpp::apply( + [&](auto&&... args) { + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.groupNodes.size())}; + g.groupNodes.emplace_back(std::forward(args)...); + }, + std::forward(val)); +} + +template +void add_vertex_impl(ShaderTag /*tag*/, Tuple &&val, LayoutGraphData &g, LayoutGraphData::vertex_type &vert) { // NOLINT + invoke_hpp::apply( + [&](auto&&... args) { + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.shaderNodes.size())}; + g.shaderNodes.emplace_back(std::forward(args)...); + }, + std::forward(val)); +} + +template +inline LayoutGraphData::vertex_descriptor +add_vertex(Tag tag, Component0&& c0, Component1&& c1, Component2&& c2, ValueT&& val, LayoutGraphData& g, LayoutGraphData::vertex_descriptor u = LayoutGraphData::null_vertex()) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + auto& vert = g.vertices.back(); + + invoke_hpp::apply( + [&](auto&&... args) { + g.names.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.updateFrequencies.emplace_back(std::forward(args)...); + }, + std::forward(c1)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.layouts.emplace_back(std::forward(args)...); + }, + std::forward(c2)); + + // PolymorphicGraph + // if no matching overloaded function is found, Type is not supported by PolymorphicGraph + add_vertex_impl(tag, std::forward(val), g, vert); + + // AddressableGraph + add_path_impl(u, v, g); + + return v; +} + +// MutableGraph(Vertex) +template +inline LayoutGraphData::vertex_descriptor +add_vertex(LayoutGraphData& g, Tag t, std::string&& name, LayoutGraphData::vertex_descriptor parentID = LayoutGraphData::null_vertex()) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(std::move(name)), // names + std::forward_as_tuple(), // updateFrequencies + std::forward_as_tuple(), // layouts + std::forward_as_tuple(), // PolymorphicType + g, parentID); +} + +template +inline LayoutGraphData::vertex_descriptor +add_vertex(LayoutGraphData& g, Tag t, const char* name, LayoutGraphData::vertex_descriptor parentID = LayoutGraphData::null_vertex()) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(name), // names + std::forward_as_tuple(), // updateFrequencies + std::forward_as_tuple(), // layouts + std::forward_as_tuple(), // PolymorphicType + g, parentID); +} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp b/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp new file mode 100644 index 0000000000..ba32e38986 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "cocos/renderer/pipeline/custom/JsbConversion.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphJsb.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.h b/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.h new file mode 100644 index 0000000000..f61ae9043f --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphJsb.h @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h" +#include "cocos/renderer/pipeline/custom/RenderCommonJsb.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h b/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h new file mode 100644 index 0000000000..7ff878bf96 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h @@ -0,0 +1,59 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" +#include "cocos/renderer/pipeline/custom/RenderCommonNames.h" + +namespace cc { + +namespace render { + +inline const char* getName(const Constant& /*v*/) noexcept { return "Constant"; } +inline const char* getName(const ConstantBuffer& /*v*/) noexcept { return "ConstantBuffer"; } +inline const char* getName(const DescriptorBlock& /*v*/) noexcept { return "DescriptorBlock"; } +inline const char* getName(const DescriptorArray& /*v*/) noexcept { return "DescriptorArray"; } +inline const char* getName(const UnboundedDescriptor& /*v*/) noexcept { return "UnboundedDescriptor"; } +inline const char* getName(const DescriptorTable& /*v*/) noexcept { return "DescriptorTable"; } +inline const char* getName(const DescriptorSet& /*v*/) noexcept { return "DescriptorSet"; } +inline const char* getName(const LayoutData& /*v*/) noexcept { return "LayoutData"; } +inline const char* getName(const ShaderProgramData& /*v*/) noexcept { return "ShaderProgramData"; } +inline const char* getName(const GroupNodeData& /*v*/) noexcept { return "GroupNodeData"; } +inline const char* getName(const ShaderNodeData& /*v*/) noexcept { return "ShaderNodeData"; } +inline const char* getName(const GroupTag& /*v*/) noexcept { return "Group"; } +inline const char* getName(const ShaderTag& /*v*/) noexcept { return "Shader"; } +inline const char* getName(const LayoutGraphData& /*v*/) noexcept { return "LayoutGraphData"; } + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp b/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp new file mode 100644 index 0000000000..7fad571b80 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "LayoutGraphReflection.h" +#include "LayoutGraphTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.h b/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.h new file mode 100644 index 0000000000..ce99723f6a --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphReflection.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h" +#include "cocos/renderer/pipeline/custom/RenderCommonReflection.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp new file mode 100644 index 0000000000..c284c0b4d3 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "LayoutGraphTypes.h" + +namespace cc { + +namespace render { + +ConstantBuffer::ConstantBuffer(const allocator_type& alloc) noexcept +: constants(alloc) {} + +ConstantBuffer::ConstantBuffer(ConstantBuffer&& rhs, const allocator_type& alloc) +: size(rhs.size), + constants(std::move(rhs.constants), alloc) {} + +ConstantBuffer::ConstantBuffer(ConstantBuffer const& rhs, const allocator_type& alloc) +: size(rhs.size), + constants(rhs.constants, alloc) {} + +DescriptorBlock::DescriptorBlock(const allocator_type& alloc) noexcept +: attributeIDs(alloc) {} + +DescriptorBlock::DescriptorBlock(DescriptorBlock&& rhs, const allocator_type& alloc) +: type(rhs.type), + capacity(rhs.capacity), + attributeIDs(std::move(rhs.attributeIDs), alloc) {} + +DescriptorBlock::DescriptorBlock(DescriptorBlock const& rhs, const allocator_type& alloc) +: type(rhs.type), + capacity(rhs.capacity), + attributeIDs(rhs.attributeIDs, alloc) {} + +UnboundedDescriptor::UnboundedDescriptor(const allocator_type& alloc) noexcept +: descriptors(alloc) {} + +UnboundedDescriptor::UnboundedDescriptor(UnboundedDescriptor&& rhs, const allocator_type& alloc) +: type(rhs.type), + descriptors(std::move(rhs.descriptors), alloc) {} + +UnboundedDescriptor::UnboundedDescriptor(UnboundedDescriptor const& rhs, const allocator_type& alloc) +: type(rhs.type), + descriptors(rhs.descriptors, alloc) {} + +DescriptorTable::DescriptorTable(const allocator_type& alloc) noexcept +: blocks(alloc) {} + +DescriptorTable::DescriptorTable(DescriptorTable&& rhs, const allocator_type& alloc) +: slot(rhs.slot), + capacity(rhs.capacity), + blocks(std::move(rhs.blocks), alloc) {} + +DescriptorTable::DescriptorTable(DescriptorTable const& rhs, const allocator_type& alloc) +: slot(rhs.slot), + capacity(rhs.capacity), + blocks(rhs.blocks, alloc) {} + +DescriptorSet::DescriptorSet(const allocator_type& alloc) noexcept +: tables(alloc), + unbounded(alloc) {} + +DescriptorSet::DescriptorSet(DescriptorSet&& rhs, const allocator_type& alloc) +: tables(std::move(rhs.tables), alloc), + unbounded(std::move(rhs.unbounded), alloc) {} + +DescriptorSet::DescriptorSet(DescriptorSet const& rhs, const allocator_type& alloc) +: tables(rhs.tables, alloc), + unbounded(rhs.unbounded, alloc) {} + +LayoutData::LayoutData(const allocator_type& alloc) noexcept +: constantBuffers(alloc), + descriptorSets(alloc) {} + +LayoutData::LayoutData(LayoutData&& rhs, const allocator_type& alloc) +: constantBuffers(std::move(rhs.constantBuffers), alloc), + descriptorSets(std::move(rhs.descriptorSets), alloc) {} + +LayoutData::LayoutData(LayoutData const& rhs, const allocator_type& alloc) +: constantBuffers(rhs.constantBuffers, alloc), + descriptorSets(rhs.descriptorSets, alloc) {} + +ShaderProgramData::ShaderProgramData(const allocator_type& alloc) noexcept +: layouts(alloc) {} + +ShaderProgramData::ShaderProgramData(ShaderProgramData&& rhs, const allocator_type& alloc) +: layouts(std::move(rhs.layouts), alloc) {} + +ShaderProgramData::ShaderProgramData(ShaderProgramData const& rhs, const allocator_type& alloc) +: layouts(rhs.layouts, alloc) {} + +ShaderNodeData::ShaderNodeData(const allocator_type& alloc) noexcept +: shaderPrograms(alloc), + shaderIndex(alloc) {} + +ShaderNodeData::ShaderNodeData(ShaderNodeData&& rhs, const allocator_type& alloc) +: rootSignature(std::move(rhs.rootSignature)), + shaderPrograms(std::move(rhs.shaderPrograms), alloc), + shaderIndex(std::move(rhs.shaderIndex), alloc) {} + +ShaderNodeData::ShaderNodeData(ShaderNodeData const& rhs, const allocator_type& alloc) +: rootSignature(rhs.rootSignature), + shaderPrograms(rhs.shaderPrograms, alloc), + shaderIndex(rhs.shaderIndex, alloc) {} + +LayoutGraphData::LayoutGraphData(const allocator_type& alloc) noexcept +: vertices(alloc), + names(alloc), + updateFrequencies(alloc), + layouts(alloc), + groupNodes(alloc), + shaderNodes(alloc), + pathIndex(alloc) {} + +LayoutGraphData::LayoutGraphData(LayoutGraphData&& rhs, const allocator_type& alloc) +: vertices(std::move(rhs.vertices), alloc), + names(std::move(rhs.names), alloc), + updateFrequencies(std::move(rhs.updateFrequencies), alloc), + layouts(std::move(rhs.layouts), alloc), + groupNodes(std::move(rhs.groupNodes), alloc), + shaderNodes(std::move(rhs.shaderNodes), alloc), + pathIndex(std::move(rhs.pathIndex), alloc) {} + +LayoutGraphData::LayoutGraphData(LayoutGraphData const& rhs, const allocator_type& alloc) +: vertices(rhs.vertices, alloc), + names(rhs.names, alloc), + updateFrequencies(rhs.updateFrequencies, alloc), + layouts(rhs.layouts, alloc), + groupNodes(rhs.groupNodes, alloc), + shaderNodes(rhs.shaderNodes, alloc), + pathIndex(rhs.pathIndex, alloc) {} + +// ContinuousContainer +void LayoutGraphData::reserve(vertices_size_type sz) { + vertices.reserve(sz); + names.reserve(sz); + updateFrequencies.reserve(sz); + layouts.reserve(sz); +} + +LayoutGraphData::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +LayoutGraphData::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc), + handle(std::move(rhs.handle)) {} + +LayoutGraphData::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc), + handle(rhs.handle) {} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h new file mode 100644 index 0000000000..ec3645f90a --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h @@ -0,0 +1,411 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include +#include +#include +#include +#include "cocos/renderer/pipeline/custom/GraphTypes.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h" +#include "cocos/renderer/pipeline/custom/Map.h" +#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h" + +namespace cc { + +namespace render { + +struct Constant { + ValueType type; + uint32_t valueID{0xFFFFFFFF}; +}; + +struct ConstantBuffer { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {constants.get_allocator().resource()}; + } + + ConstantBuffer(const allocator_type& alloc) noexcept; // NOLINT + ConstantBuffer(ConstantBuffer&& rhs, const allocator_type& alloc); + ConstantBuffer(ConstantBuffer const& rhs, const allocator_type& alloc); + + ConstantBuffer(ConstantBuffer&& rhs) noexcept = default; + ConstantBuffer(ConstantBuffer const& rhs) = delete; + ConstantBuffer& operator=(ConstantBuffer&& rhs) = default; + ConstantBuffer& operator=(ConstantBuffer const& rhs) = default; + + uint32_t size{0}; + boost::container::pmr::vector constants; +}; + +using DescriptorType = boost::variant2::variant; + +inline bool operator<(const DescriptorType& lhs, const DescriptorType& rhs) noexcept { + return lhs.index() < rhs.index(); +} + +inline bool operator==(const DescriptorType& lhs, const DescriptorType& rhs) noexcept { + return lhs.index() == rhs.index(); +} + +inline bool operator!=(const DescriptorType& lhs, const DescriptorType& rhs) noexcept { + return !(lhs == rhs); +} + +struct DescriptorBlock { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {attributeIDs.get_allocator().resource()}; + } + + DescriptorBlock(const allocator_type& alloc) noexcept; // NOLINT + DescriptorBlock(DescriptorBlock&& rhs, const allocator_type& alloc); + DescriptorBlock(DescriptorBlock const& rhs, const allocator_type& alloc); + + DescriptorBlock(DescriptorBlock&& rhs) noexcept = default; + DescriptorBlock(DescriptorBlock const& rhs) = delete; + DescriptorBlock& operator=(DescriptorBlock&& rhs) = default; + DescriptorBlock& operator=(DescriptorBlock const& rhs) = default; + + DescriptorType type; + uint32_t capacity{0}; + boost::container::pmr::vector attributeIDs; +}; + +struct DescriptorArray { + uint32_t capacity{0}; + uint32_t attributeID{0xFFFFFFFF}; +}; + +struct UnboundedDescriptor { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {descriptors.get_allocator().resource()}; + } + + UnboundedDescriptor(const allocator_type& alloc) noexcept; // NOLINT + UnboundedDescriptor(UnboundedDescriptor&& rhs, const allocator_type& alloc); + UnboundedDescriptor(UnboundedDescriptor const& rhs, const allocator_type& alloc); + + UnboundedDescriptor(UnboundedDescriptor&& rhs) noexcept = default; + UnboundedDescriptor(UnboundedDescriptor const& rhs) = delete; + UnboundedDescriptor& operator=(UnboundedDescriptor&& rhs) = default; + UnboundedDescriptor& operator=(UnboundedDescriptor const& rhs) = default; + + DescriptorType type; + boost::container::pmr::vector descriptors; +}; + +struct DescriptorTable { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {blocks.get_allocator().resource()}; + } + + DescriptorTable(const allocator_type& alloc) noexcept; // NOLINT + DescriptorTable(DescriptorTable&& rhs, const allocator_type& alloc); + DescriptorTable(DescriptorTable const& rhs, const allocator_type& alloc); + + DescriptorTable(DescriptorTable&& rhs) noexcept = default; + DescriptorTable(DescriptorTable const& rhs) = delete; + DescriptorTable& operator=(DescriptorTable&& rhs) = default; + DescriptorTable& operator=(DescriptorTable const& rhs) = default; + + uint32_t slot{0}; + uint32_t capacity{0}; + boost::container::pmr::vector blocks; +}; + +struct DescriptorSet { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {tables.get_allocator().resource()}; + } + + DescriptorSet(const allocator_type& alloc) noexcept; // NOLINT + DescriptorSet(DescriptorSet&& rhs, const allocator_type& alloc); + DescriptorSet(DescriptorSet const& rhs, const allocator_type& alloc); + + DescriptorSet(DescriptorSet&& rhs) noexcept = default; + DescriptorSet(DescriptorSet const& rhs) = delete; + DescriptorSet& operator=(DescriptorSet&& rhs) = default; + DescriptorSet& operator=(DescriptorSet const& rhs) = default; + + boost::container::pmr::vector tables; + UnboundedDescriptor unbounded; +}; + +struct LayoutData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {constantBuffers.get_allocator().resource()}; + } + + LayoutData(const allocator_type& alloc) noexcept; // NOLINT + LayoutData(LayoutData&& rhs, const allocator_type& alloc); + LayoutData(LayoutData const& rhs, const allocator_type& alloc); + + LayoutData(LayoutData&& rhs) noexcept = default; + LayoutData(LayoutData const& rhs) = delete; + LayoutData& operator=(LayoutData&& rhs) = default; + LayoutData& operator=(LayoutData const& rhs) = default; + + PmrTransparentMap constantBuffers; + PmrTransparentMap descriptorSets; +}; + +struct ShaderProgramData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {layouts.get_allocator().resource()}; + } + + ShaderProgramData(const allocator_type& alloc) noexcept; // NOLINT + ShaderProgramData(ShaderProgramData&& rhs, const allocator_type& alloc); + ShaderProgramData(ShaderProgramData const& rhs, const allocator_type& alloc); + + ShaderProgramData(ShaderProgramData&& rhs) noexcept = default; + ShaderProgramData(ShaderProgramData const& rhs) = delete; + ShaderProgramData& operator=(ShaderProgramData&& rhs) = default; + ShaderProgramData& operator=(ShaderProgramData const& rhs) = default; + + PmrTransparentMap layouts; +}; + +struct GroupNodeData { + GroupNodeData() = default; + GroupNodeData(NodeType nodeTypeIn) noexcept // NOLINT + : nodeType(nodeTypeIn) {} + + NodeType nodeType{NodeType::INTERNAL}; +}; + +struct ShaderNodeData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {shaderPrograms.get_allocator().resource()}; + } + + ShaderNodeData(const allocator_type& alloc) noexcept; // NOLINT + ShaderNodeData(ShaderNodeData&& rhs, const allocator_type& alloc); + ShaderNodeData(ShaderNodeData const& rhs, const allocator_type& alloc); + + ShaderNodeData(ShaderNodeData&& rhs) noexcept = default; + ShaderNodeData(ShaderNodeData const& rhs) = delete; + ShaderNodeData& operator=(ShaderNodeData&& rhs) = default; + ShaderNodeData& operator=(ShaderNodeData const& rhs) = default; + + std::string rootSignature; + boost::container::pmr::vector shaderPrograms; + PmrTransparentMap shaderIndex; +}; + +struct GroupTag {}; +struct ShaderTag {}; + +struct LayoutGraphData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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(); + } + + LayoutGraphData(const allocator_type& alloc) noexcept; // NOLINT + LayoutGraphData(LayoutGraphData&& rhs, const allocator_type& alloc); + LayoutGraphData(LayoutGraphData const& rhs, const allocator_type& alloc); + + LayoutGraphData(LayoutGraphData&& rhs) noexcept = default; + LayoutGraphData(LayoutGraphData const& rhs) = delete; + LayoutGraphData& operator=(LayoutGraphData&& rhs) = default; + LayoutGraphData& operator=(LayoutGraphData const& rhs) = default; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptor; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + LayoutGraphData, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // AddressableGraph (Alias) + using ownership_descriptor = impl::EdgeDescriptor; + + using children_edge_type = out_edge_type; + using children_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, ownership_descriptor, int32_t>; + using children_size_type = uint32_t; + + using parent_edge_type = in_edge_type; + using parent_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, ownership_descriptor, int32_t>; + + using ownership_iterator = impl::DirectedEdgeIterator; + using ownerships_size_type = edges_size_type; + + // AddressableGraph help functions + inline boost::container::pmr::vector& getChildrenList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getChildrenList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getParentsList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getParentsList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + // PolymorphicGraph + using vertex_tag_type = boost::variant2::variant; + using vertex_value_type = boost::variant2::variant; + using vertex_const_value_type = boost::variant2::variant; + using vertex_handle_type = boost::variant2::variant< + impl::ValueHandle, + impl::ValueHandle>; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + vertex_handle_type handle; + }; + + struct NameTag { + } static constexpr Name{}; // NOLINT + struct UpdateTag { + } static constexpr Update{}; // NOLINT + struct LayoutTag { + } static constexpr Layout{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector names; + boost::container::pmr::vector updateFrequencies; + boost::container::pmr::vector layouts; + // PolymorphicGraph + boost::container::pmr::vector groupNodes; + boost::container::pmr::vector shaderNodes; + // Path + PmrTransparentMap pathIndex; +}; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/Map.h b/native/cocos/renderer/pipeline/custom/Map.h new file mode 100644 index 0000000000..d05355dff8 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/Map.h @@ -0,0 +1,102 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include +#include + +// for std::less<> the transparent comparator +// see https://stackoverflow.com/questions/20317413/what-are-transparent-comparators + +namespace cc { + +// map +template +using TransparentMap = std::map>; + +template +using TransparentMultiMap = std::multimap>; + +template +using PmrTransparentMap = std::map< + Key, Value, std::less<>, + boost::container::pmr::polymorphic_allocator>>; + +template +using PmrTransparentMultiMap = std::multimap< + Key, Value, std::less<>, + boost::container::pmr::polymorphic_allocator>>; + +// flat_map +template +using FlatMap = boost::container::flat_map>; + +template +using FlatMultiMap = boost::container::flat_multimap>; + +template +using PmrFlatMap = boost::container::pmr::flat_map>; + +template +using PmrFlatMultiMap = boost::container::pmr::flat_multimap>; + +// unordered_map +template +using PmrUnorderedMap = std::unordered_map< + Key, Value, std::hash, std::equal_to, + boost::container::pmr::polymorphic_allocator>>; + +template +using PmrUnorderedMultiMap = std::unordered_multimap< + Key, Value, std::hash, std::equal_to, + boost::container::pmr::polymorphic_allocator>>; + +// transparent string unordered_map +template +using UnorderedStringMap = std::unordered_map< + Key, Value, + TransparentStringHash, std::equal_to<>>; + +template +using UnorderedStringMultiMap = std::unordered_multimap< + Key, Value, + TransparentStringHash, std::equal_to<>>; + +template +using PmrUnorderedStringMap = std::unordered_map< + Key, Value, + TransparentStringHash, std::equal_to<>, + boost::container::pmr::polymorphic_allocator>>; + +template +using PmrUnorderedStringMultiMap = std::unordered_multimap< + Key, Value, + TransparentStringHash, std::equal_to<>, + boost::container::pmr::polymorphic_allocator>>; + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/Overload.h b/native/cocos/renderer/pipeline/custom/Overload.h new file mode 100644 index 0000000000..5a1f731526 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/Overload.h @@ -0,0 +1,65 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include + +namespace cc { + +// https://stackoverflow.com/questions/50510122/stdvariant-with-overloaded-lambdas-alternative-with-msvc + +template +struct Overloaded {}; // NOLINT + +template +struct Overloaded : T0 { + using T0::operator(); + Overloaded(T0 t0) // NOLINT + : T0(std::move(t0)) {} +}; + +template +struct Overloaded : T0, Overloaded { + using T0:: operator(); + using Overloaded::operator(); + Overloaded(T0 t0, T1 t1, Ts... ts) + : T0(std::move(t0)), Overloaded(std::move(t1), std::move(ts)...) {} +}; + +template +Overloaded overload(Ts... ts) { + return {std::move(ts)...}; +} + +template +auto variantFromIndex(size_t index) -> V { // NOLINT + return boost::mp11::mp_with_index>(index, + [](auto i) { return V(boost::variant2::in_place_index); }); +} + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/PathUtils.h b/native/cocos/renderer/pipeline/custom/PathUtils.h new file mode 100644 index 0000000000..c7d6b3eaae --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/PathUtils.h @@ -0,0 +1,89 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include + +namespace cc { + +namespace render { + +namespace impl { + +template +inline void cleanPath(std::basic_string, Allocator> &str) noexcept { + using string_t = std::basic_string, Allocator>; + constexpr CharT slash[] = {'/', '\0'}; + constexpr CharT doubleSlash[] = {'/', '/', '\0'}; + + CC_EXPECTS(!str.empty()); + CC_EXPECTS(boost::algorithm::starts_with(str, boost::string_view(slash))); + CC_EXPECTS(str.find(doubleSlash) == string_t::npos); + CC_EXPECTS([&]() { // NOLINT + bool valid = true; + for (uint8_t c : str) { + if (c < uint8_t('.')) + valid = false; + } + return valid; + }()); + + { // remove all /./ + constexpr CharT current[] = {'/', '.', '/', '\0'}; + + auto pos = str.rfind(current); + while (pos != string_t::npos) { + str.erase(pos, 2); + pos = str.rfind(current); + } + // remove tailing /. + constexpr CharT ending[] = {'/', '.', '\0'}; + if (boost::algorithm::ends_with(str, boost::string_view(ending))) { + str.resize(str.size() - 2); + } + } + + // try remove /.. + constexpr std::array previous = {CharT('/'), CharT('.'), CharT('.'), CharT('\0')}; + auto pos = str.find(previous.data()); + while (pos != string_t::npos) { + if (pos == 0) { + // root element has not parent path + str = {}; // slash; + return; + } + auto beg = str.rfind(slash, pos - 1); + CC_EXPECTS(beg != string_t::npos); + str.erase(beg, pos - beg + previous.size() - 1); + } +} + +} // namespace impl + +} // namespace render + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/Range.h b/native/cocos/renderer/pipeline/custom/Range.h new file mode 100644 index 0000000000..6d0960449d --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/Range.h @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include + +namespace cc { + +template +inline boost::iterator_range +makeRange(const std::pair &p) noexcept { // NOLINT + return boost::make_iterator_range(p.first, p.second); +} + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h b/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h new file mode 100644 index 0000000000..717ea9ab50 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h @@ -0,0 +1,132 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include + +namespace cc { + +namespace render { + +enum class UpdateFrequency; + +struct CBVTag; +struct UAVTag; +struct SRVTag; +struct SSVTag; +struct RTVTag; +struct DSVTag; +struct IBVTag; +struct VBVTag; +struct SOVTag; +struct ConstantsTag; +struct TableTag; + +using ParameterType = boost::variant2::variant; + +struct BoundedTag; +struct UnboundedTag; + +using Boundedness = boost::variant2::variant; + +struct CBufferTag; +struct BufferTag; +struct TextureTag; +struct RWBufferTag; +struct RWTextureTag; +struct SamplerTag; +struct Texture1DTag; +struct Texture1DArrayTag; +struct Texture2DTag; +struct Texture2DArrayTag; +struct Texture2DMSTag; +struct Texture2DMSArrayTag; +struct Texture3DTag; +struct TextureCubeTag; +struct TextureCubeArrayTag; +struct RaytracingAccelerationStructureTag; +struct SamplerStateTag; +struct SamplerComparisonStateTag; + +using ResourceType = boost::variant2::variant; + +struct TypelessTag; +struct Float4Tag; +struct Float3Tag; +struct Float2Tag; +struct Float1Tag; +struct Half4Tag; +struct Half3Tag; +struct Half2Tag; +struct Half1Tag; +struct Fixed4Tag; +struct Fixed3Tag; +struct Fixed2Tag; +struct Fixed1Tag; +struct Uint4Tag; +struct Uint3Tag; +struct Uint2Tag; +struct Uint1Tag; +struct Int4Tag; +struct Int3Tag; +struct Int2Tag; +struct Int1Tag; +struct Bool4Tag; +struct Bool3Tag; +struct Bool2Tag; +struct Bool1Tag; + +using ValueType = boost::variant2::variant; + +struct RasterTag; +struct ComputeTag; +struct CopyTag; +struct MoveTag; +struct RaytraceTag; +struct ManagedTag; +struct PersistentTag; +struct BackbufferTag; +struct MemorylessTag; + +using ResourceResidency = boost::variant2::variant; + +enum class QueueHint; +enum class ResourceDimension; + +struct SampleDesc; + +enum class NodeType; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp new file mode 100644 index 0000000000..eda6387a5b --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "cocos/renderer/pipeline/custom/JsbConversion.h" +#include "cocos/renderer/pipeline/custom/RenderCommonJsb.h" +#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h new file mode 100644 index 0000000000..288bd6d01f --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonNames.h b/native/cocos/renderer/pipeline/custom/RenderCommonNames.h new file mode 100644 index 0000000000..125e28ee02 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonNames.h @@ -0,0 +1,146 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h" + +namespace cc { + +namespace render { + +inline const char* getName(UpdateFrequency e) noexcept { + switch (e) { + case UpdateFrequency::PER_INSTANCE: return "PER_INSTANCE"; + case UpdateFrequency::PER_BATCH: return "PER_BATCH"; + case UpdateFrequency::PER_QUEUE: return "PER_QUEUE"; + case UpdateFrequency::PER_PASS: return "PER_PASS"; + case UpdateFrequency::COUNT: return "COUNT"; + } + return ""; +} +inline const char* getName(const CBVTag& /*v*/) noexcept { return "CBV"; } +inline const char* getName(const UAVTag& /*v*/) noexcept { return "UAV"; } +inline const char* getName(const SRVTag& /*v*/) noexcept { return "SRV"; } +inline const char* getName(const SSVTag& /*v*/) noexcept { return "SSV"; } +inline const char* getName(const RTVTag& /*v*/) noexcept { return "RTV"; } +inline const char* getName(const DSVTag& /*v*/) noexcept { return "DSV"; } +inline const char* getName(const IBVTag& /*v*/) noexcept { return "IBV"; } +inline const char* getName(const VBVTag& /*v*/) noexcept { return "VBV"; } +inline const char* getName(const SOVTag& /*v*/) noexcept { return "SOV"; } +inline const char* getName(const ConstantsTag& /*v*/) noexcept { return "Constants"; } +inline const char* getName(const TableTag& /*v*/) noexcept { return "Table"; } +inline const char* getName(const BoundedTag& /*v*/) noexcept { return "Bounded"; } +inline const char* getName(const UnboundedTag& /*v*/) noexcept { return "Unbounded"; } +inline const char* getName(const CBufferTag& /*v*/) noexcept { return "CBuffer"; } +inline const char* getName(const BufferTag& /*v*/) noexcept { return "Buffer"; } +inline const char* getName(const TextureTag& /*v*/) noexcept { return "Texture"; } +inline const char* getName(const RWBufferTag& /*v*/) noexcept { return "RWBuffer"; } +inline const char* getName(const RWTextureTag& /*v*/) noexcept { return "RWTexture"; } +inline const char* getName(const SamplerTag& /*v*/) noexcept { return "Sampler"; } +inline const char* getName(const Texture1DTag& /*v*/) noexcept { return "Texture1D"; } +inline const char* getName(const Texture1DArrayTag& /*v*/) noexcept { return "Texture1DArray"; } +inline const char* getName(const Texture2DTag& /*v*/) noexcept { return "Texture2D"; } +inline const char* getName(const Texture2DArrayTag& /*v*/) noexcept { return "Texture2DArray"; } +inline const char* getName(const Texture2DMSTag& /*v*/) noexcept { return "Texture2DMS"; } +inline const char* getName(const Texture2DMSArrayTag& /*v*/) noexcept { return "Texture2DMSArray"; } +inline const char* getName(const Texture3DTag& /*v*/) noexcept { return "Texture3D"; } +inline const char* getName(const TextureCubeTag& /*v*/) noexcept { return "TextureCube"; } +inline const char* getName(const TextureCubeArrayTag& /*v*/) noexcept { return "TextureCubeArray"; } +inline const char* getName(const RaytracingAccelerationStructureTag& /*v*/) noexcept { return "RaytracingAccelerationStructure"; } +inline const char* getName(const SamplerStateTag& /*v*/) noexcept { return "SamplerState"; } +inline const char* getName(const SamplerComparisonStateTag& /*v*/) noexcept { return "SamplerComparisonState"; } +inline const char* getName(const TypelessTag& /*v*/) noexcept { return "Typeless"; } +inline const char* getName(const Float4Tag& /*v*/) noexcept { return "Float4"; } +inline const char* getName(const Float3Tag& /*v*/) noexcept { return "Float3"; } +inline const char* getName(const Float2Tag& /*v*/) noexcept { return "Float2"; } +inline const char* getName(const Float1Tag& /*v*/) noexcept { return "Float1"; } +inline const char* getName(const Half4Tag& /*v*/) noexcept { return "Half4"; } +inline const char* getName(const Half3Tag& /*v*/) noexcept { return "Half3"; } +inline const char* getName(const Half2Tag& /*v*/) noexcept { return "Half2"; } +inline const char* getName(const Half1Tag& /*v*/) noexcept { return "Half1"; } +inline const char* getName(const Fixed4Tag& /*v*/) noexcept { return "Fixed4"; } +inline const char* getName(const Fixed3Tag& /*v*/) noexcept { return "Fixed3"; } +inline const char* getName(const Fixed2Tag& /*v*/) noexcept { return "Fixed2"; } +inline const char* getName(const Fixed1Tag& /*v*/) noexcept { return "Fixed1"; } +inline const char* getName(const Uint4Tag& /*v*/) noexcept { return "Uint4"; } +inline const char* getName(const Uint3Tag& /*v*/) noexcept { return "Uint3"; } +inline const char* getName(const Uint2Tag& /*v*/) noexcept { return "Uint2"; } +inline const char* getName(const Uint1Tag& /*v*/) noexcept { return "Uint1"; } +inline const char* getName(const Int4Tag& /*v*/) noexcept { return "Int4"; } +inline const char* getName(const Int3Tag& /*v*/) noexcept { return "Int3"; } +inline const char* getName(const Int2Tag& /*v*/) noexcept { return "Int2"; } +inline const char* getName(const Int1Tag& /*v*/) noexcept { return "Int1"; } +inline const char* getName(const Bool4Tag& /*v*/) noexcept { return "Bool4"; } +inline const char* getName(const Bool3Tag& /*v*/) noexcept { return "Bool3"; } +inline const char* getName(const Bool2Tag& /*v*/) noexcept { return "Bool2"; } +inline const char* getName(const Bool1Tag& /*v*/) noexcept { return "Bool1"; } +inline const char* getName(const RasterTag& /*v*/) noexcept { return "Raster"; } +inline const char* getName(const ComputeTag& /*v*/) noexcept { return "Compute"; } +inline const char* getName(const CopyTag& /*v*/) noexcept { return "Copy"; } +inline const char* getName(const MoveTag& /*v*/) noexcept { return "Move"; } +inline const char* getName(const RaytraceTag& /*v*/) noexcept { return "Raytrace"; } +inline const char* getName(const ManagedTag& /*v*/) noexcept { return "Managed"; } +inline const char* getName(const PersistentTag& /*v*/) noexcept { return "Persistent"; } +inline const char* getName(const BackbufferTag& /*v*/) noexcept { return "Backbuffer"; } +inline const char* getName(const MemorylessTag& /*v*/) noexcept { return "Memoryless"; } +inline const char* getName(QueueHint e) noexcept { + switch (e) { + case QueueHint::NONE: return "NONE"; + case QueueHint::RENDER_OPAQUE: return "RENDER_OPAQUE"; + case QueueHint::RENDER_CUTOUT: return "RENDER_CUTOUT"; + case QueueHint::RENDER_TRANSPARENT: return "RENDER_TRANSPARENT"; + case QueueHint::COUNT: return "COUNT"; + } + return ""; +} +inline const char* getName(ResourceDimension e) noexcept { + switch (e) { + case ResourceDimension::BUFFER: return "BUFFER"; + case ResourceDimension::TEXTURE1D: return "TEXTURE1D"; + case ResourceDimension::TEXTURE2D: return "TEXTURE2D"; + case ResourceDimension::TEXTURE3D: return "TEXTURE3D"; + } + return ""; +} +inline const char* getName(const SampleDesc& /*v*/) noexcept { return "SampleDesc"; } +inline const char* getName(NodeType e) noexcept { + switch (e) { + case NodeType::INTERNAL: return "INTERNAL"; + case NodeType::LEAF: return "LEAF"; + } + return ""; +} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonReflection.cpp b/native/cocos/renderer/pipeline/custom/RenderCommonReflection.cpp new file mode 100644 index 0000000000..607451c174 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderCommonReflection.h" +#include "RenderCommonTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonReflection.h b/native/cocos/renderer/pipeline/custom/RenderCommonReflection.h new file mode 100644 index 0000000000..752de77c98 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonReflection.h @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.cpp new file mode 100644 index 0000000000..b6d8880543 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderCommonTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h new file mode 100644 index 0000000000..b1bbcc6719 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h @@ -0,0 +1,180 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" + +namespace cc { + +namespace render { + +enum class UpdateFrequency { + PER_INSTANCE, + PER_BATCH, + PER_QUEUE, + PER_PASS, + COUNT, +}; + +struct CBVTag {}; +struct UAVTag {}; +struct SRVTag {}; +struct SSVTag {}; +struct RTVTag {}; +struct DSVTag {}; +struct IBVTag {}; +struct VBVTag {}; +struct SOVTag {}; +struct ConstantsTag {}; +struct TableTag {}; + +using ParameterType = boost::variant2::variant; + +inline bool operator<(const ParameterType& lhs, const ParameterType& rhs) noexcept { + return lhs.index() < rhs.index(); +} + +inline bool operator==(const ParameterType& lhs, const ParameterType& rhs) noexcept { + return lhs.index() == rhs.index(); +} + +inline bool operator!=(const ParameterType& lhs, const ParameterType& rhs) noexcept { + return !(lhs == rhs); +} + +struct BoundedTag {}; +struct UnboundedTag {}; + +using Boundedness = boost::variant2::variant; + +inline bool operator<(const Boundedness& lhs, const Boundedness& rhs) noexcept { + return lhs.index() < rhs.index(); +} + +inline bool operator==(const Boundedness& lhs, const Boundedness& rhs) noexcept { + return lhs.index() == rhs.index(); +} + +inline bool operator!=(const Boundedness& lhs, const Boundedness& rhs) noexcept { + return !(lhs == rhs); +} + +struct CBufferTag {}; +struct BufferTag {}; +struct TextureTag {}; +struct RWBufferTag {}; +struct RWTextureTag {}; +struct SamplerTag {}; +struct Texture1DTag {}; +struct Texture1DArrayTag {}; +struct Texture2DTag {}; +struct Texture2DArrayTag {}; +struct Texture2DMSTag {}; +struct Texture2DMSArrayTag {}; +struct Texture3DTag {}; +struct TextureCubeTag {}; +struct TextureCubeArrayTag {}; +struct RaytracingAccelerationStructureTag {}; +struct SamplerStateTag {}; +struct SamplerComparisonStateTag {}; + +using ResourceType = boost::variant2::variant; + +struct TypelessTag {}; +struct Float4Tag {}; +struct Float3Tag {}; +struct Float2Tag {}; +struct Float1Tag {}; +struct Half4Tag {}; +struct Half3Tag {}; +struct Half2Tag {}; +struct Half1Tag {}; +struct Fixed4Tag {}; +struct Fixed3Tag {}; +struct Fixed2Tag {}; +struct Fixed1Tag {}; +struct Uint4Tag {}; +struct Uint3Tag {}; +struct Uint2Tag {}; +struct Uint1Tag {}; +struct Int4Tag {}; +struct Int3Tag {}; +struct Int2Tag {}; +struct Int1Tag {}; +struct Bool4Tag {}; +struct Bool3Tag {}; +struct Bool2Tag {}; +struct Bool1Tag {}; + +using ValueType = boost::variant2::variant; + +struct RasterTag {}; +struct ComputeTag {}; +struct CopyTag {}; +struct MoveTag {}; +struct RaytraceTag {}; +struct ManagedTag {}; +struct PersistentTag {}; +struct BackbufferTag {}; +struct MemorylessTag {}; + +using ResourceResidency = boost::variant2::variant; + +enum class QueueHint { + NONE, + RENDER_OPAQUE, + RENDER_CUTOUT, + RENDER_TRANSPARENT, + COUNT, +}; + +enum class ResourceDimension { + BUFFER, + TEXTURE1D, + TEXTURE2D, + TEXTURE3D, +}; + +struct SampleDesc { + uint32_t count{1}; + uint32_t quality{0}; +}; + +enum class NodeType { + INTERNAL, + LEAF, +}; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerFwd.h b/native/cocos/renderer/pipeline/custom/RenderCompilerFwd.h new file mode 100644 index 0000000000..af1545f4e0 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerFwd.h @@ -0,0 +1,47 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" + +namespace cc { + +namespace render { + +struct RenderCompiler; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerGraphs.h b/native/cocos/renderer/pipeline/custom/RenderCompilerGraphs.h new file mode 100644 index 0000000000..90a0f1f775 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerGraphs.h @@ -0,0 +1,41 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/GraphImpl.h" +#include "cocos/renderer/pipeline/custom/GslUtils.h" +#include "cocos/renderer/pipeline/custom/Overload.h" +#include "cocos/renderer/pipeline/custom/PathUtils.h" +#include "cocos/renderer/pipeline/custom/RenderCompilerTypes.h" +#include "cocos/renderer/pipeline/custom/invoke.hpp" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerImpl.cpp b/native/cocos/renderer/pipeline/custom/RenderCompilerImpl.cpp new file mode 100644 index 0000000000..0c0ea757ab --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerImpl.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "RenderCompilerGraphs.h" + +namespace cc { + +namespace render { + +int RenderCompiler::compile() { + auto& rg = graph; + const auto& resg = resourceGraph; + + return 0; +} + +} // namespace render + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerNames.h b/native/cocos/renderer/pipeline/custom/RenderCompilerNames.h new file mode 100644 index 0000000000..8a0ad9dd59 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerNames.h @@ -0,0 +1,47 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphNames.h" +#include "cocos/renderer/pipeline/custom/RenderCompilerTypes.h" +#include "cocos/renderer/pipeline/custom/RenderGraphNames.h" + +namespace cc { + +namespace render { + +inline const char* getName(const RenderCompiler& /*v*/) noexcept { return "RenderCompiler"; } + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.cpp b/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.cpp new file mode 100644 index 0000000000..973f2e14b1 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderCompilerReflection.h" +#include "RenderCompilerTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.h b/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.h new file mode 100644 index 0000000000..df95cfba8a --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerReflection.h @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphReflection.h" +#include "cocos/renderer/pipeline/custom/RenderCompilerFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphReflection.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.cpp new file mode 100644 index 0000000000..435c9de26d --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderCompilerTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.h b/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.h new file mode 100644 index 0000000000..2b172f9065 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderCompilerTypes.h @@ -0,0 +1,65 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" +#include "cocos/renderer/pipeline/custom/RenderCompilerFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" +#include "cocos/renderer/pipeline/custom/String.h" + +namespace cc { + +namespace render { + +struct RenderCompiler { + RenderCompiler(ResourceGraph& resourceGraphIn, RenderGraph& graphIn, LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn) noexcept + : resourceGraph(resourceGraphIn), + graph(graphIn), + layoutGraph(layoutGraphIn), + scratch(scratchIn) {} + RenderCompiler(RenderCompiler&& rhs) = delete; + RenderCompiler(RenderCompiler const& rhs) = delete; + RenderCompiler& operator=(RenderCompiler&& rhs) = delete; + RenderCompiler& operator=(RenderCompiler const& rhs) = delete; + + int compile(); + + ResourceGraph& resourceGraph; + RenderGraph& graph; + LayoutGraphData& layoutGraph; + boost::container::pmr::memory_resource* scratch{nullptr}; +}; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleFwd.h b/native/cocos/renderer/pipeline/custom/RenderExampleFwd.h new file mode 100644 index 0000000000..484515cca4 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleFwd.h @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" +#include + +namespace cc { + +namespace render { + +namespace example { + +enum class DependencyType; + +struct RenderPassNode; +struct RenderPassTraits; +struct RenderDependencyGraph; +struct RenderValueNode; +struct RenderValueGraph; +struct RenderCompiler; + +} // namespace example + +} // namespace render + +} // namespace cc + +namespace std { + +template <> +struct hash { + size_t operator()(const cc::render::example::RenderValueNode& v) const noexcept; +}; + +} + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleGraphs.h b/native/cocos/renderer/pipeline/custom/RenderExampleGraphs.h new file mode 100644 index 0000000000..cd79324597 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleGraphs.h @@ -0,0 +1,1198 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/GraphImpl.h" +#include "cocos/renderer/pipeline/custom/GslUtils.h" +#include "cocos/renderer/pipeline/custom/Overload.h" +#include "cocos/renderer/pipeline/custom/PathUtils.h" +#include "cocos/renderer/pipeline/custom/RenderExampleTypes.h" +#include "cocos/renderer/pipeline/custom/invoke.hpp" + +namespace cc { + +namespace render { + +namespace example { + +// IncidenceGraph +inline RenderDependencyGraph::vertex_descriptor +source(const RenderDependencyGraph::edge_descriptor& e, const RenderDependencyGraph& /*g*/) noexcept { + return e.source; +} + +inline RenderDependencyGraph::vertex_descriptor +target(const RenderDependencyGraph::edge_descriptor& e, const RenderDependencyGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderDependencyGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + RenderDependencyGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline RenderDependencyGraph::degree_size_type +out_degree(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph::vertex_descriptor v, const RenderDependencyGraph& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), RenderDependencyGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {RenderDependencyGraph::edge_descriptor(u, v, (hasEdge ? &(*iter).get_property() : nullptr)), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderDependencyGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + RenderDependencyGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline RenderDependencyGraph::degree_size_type +in_degree(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline RenderDependencyGraph::degree_size_type +degree(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(RenderDependencyGraph::vertex_descriptor u, const RenderDependencyGraph& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(RenderDependencyGraph::adjacency_iterator(edges.first, &g), RenderDependencyGraph::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const RenderDependencyGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline RenderDependencyGraph::vertices_size_type +num_vertices(const RenderDependencyGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const RenderDependencyGraph& g) noexcept { + return std::make_pair( + RenderDependencyGraph::edge_iterator(const_cast(g).edges.begin()), + RenderDependencyGraph::edge_iterator(const_cast(g).edges.end())); +} + +inline RenderDependencyGraph::edges_size_type +num_edges(const RenderDependencyGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.edges.size()); +} + +// MutableGraph(Edge) +inline std::pair +add_edge( // NOLINT + RenderDependencyGraph::vertex_descriptor u, + RenderDependencyGraph::vertex_descriptor v, RenderDependencyGraph& g) { + auto edgeIter = g.edges.emplace(g.edges.end(), u, v); + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v, edgeIter); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u, edgeIter); + + return std::make_pair(RenderDependencyGraph::edge_descriptor(u, v, &edgeIter->get_property()), true); +} + +inline void remove_edge(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph::vertex_descriptor v, RenderDependencyGraph& g) noexcept { // NOLINT + auto& outEdgeList = g.getOutEdgeList(u); + + impl::removeDirectedAllEdgeProperties(g, outEdgeList, v); + + // remove out-edges + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +void remove_edge(RenderDependencyGraph::out_edge_iterator iter, RenderDependencyGraph& g) noexcept; // NOLINT + +inline void remove_edge(RenderDependencyGraph::edge_descriptor e, RenderDependencyGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto range = out_edges(source(e, g), g); + range.first = std::find(range.first, range.second, e); + CC_ENSURES(range.first != range.second); + remove_edge(range.first, g); +} + +inline void remove_edge(RenderDependencyGraph::out_edge_iterator iter, RenderDependencyGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + g.edges.erase(iter.base()->get_iter()); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(RenderDependencyGraph::vertex_descriptor u, Predicate&& pred, RenderDependencyGraph& g) { // NOLINT + std::vector::iterator> garbage; + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + garbage.emplace_back((*outIter.base()).get_iter()); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); + for (const auto& v : garbage) { + g.edges.erase(v); + } +} + +template +inline void remove_in_edge_if(RenderDependencyGraph::vertex_descriptor v, Predicate&& pred, RenderDependencyGraph& g) { // NOLINT + std::vector::iterator> garbage; + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + garbage.emplace_back((*inIter.base()).get_iter()); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); + for (const auto& v : garbage) { + g.edges.erase(v); + } +} + +template +inline void remove_edge_if(Predicate&& pred, RenderDependencyGraph& g) { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// MutableGraph(Vertex) +inline void clear_out_edges(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph& 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; + }); + g.edges.erase((*iter).get_iter()); + } + outEdgeList.clear(); +} + +inline void clear_in_edges(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph& 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; + }); + g.edges.erase((*iter).get_iter()); + } + inEdgeList.clear(); +} + +inline void clear_vertex(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph& g) noexcept { // NOLINT + clear_out_edges(u, g); + clear_in_edges(u, g); +} + +inline void remove_vertex(RenderDependencyGraph::vertex_descriptor u, RenderDependencyGraph& g) noexcept { // NOLINT + { // UuidGraph + const auto& key = g.passIDs[u]; + auto num = g.passIndex.erase(key); + CC_ENSURES(num == 1); + for (auto&& pair : g.passIndex) { + auto& v = pair.second; + if (v > u) { + --v; + } + } + } + impl::removeVectorVertex(const_cast(g), u, RenderDependencyGraph::directed_category{}); + + // remove components + g.passes.erase(g.passes.begin() + std::ptrdiff_t(u)); + g.valueIDs.erase(g.valueIDs.begin() + std::ptrdiff_t(u)); + g.passIDs.erase(g.passIDs.begin() + std::ptrdiff_t(u)); + g.traits.erase(g.traits.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Edge) +template +inline std::pair +add_edge( // NOLINT + RenderDependencyGraph::vertex_descriptor u, + RenderDependencyGraph::vertex_descriptor v, + EdgeProperty&& p, RenderDependencyGraph& g) { + auto edgeIter = g.edges.emplace(g.edges.end(), u, v, std::forward(p)); + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v, edgeIter); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u, edgeIter); + + return std::make_pair(RenderDependencyGraph::edge_descriptor(u, v, &edgeIter->get_property()), true); +} + +template +inline std::pair +add_edge( // NOLINT + RenderDependencyGraph::vertex_descriptor u, + RenderDependencyGraph::vertex_descriptor v, + RenderDependencyGraph& g, T&&... args) { + auto edgeIter = g.edges.emplace(g.edges.end(), u, v, std::forward(args)...); + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v, edgeIter); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u, edgeIter); + + return std::make_pair(RenderDependencyGraph::edge_descriptor(u, v, &edgeIter->get_property()), true); +} + +// MutablePropertyGraph(Vertex) +template +inline RenderDependencyGraph::vertex_descriptor +add_vertex(Component0&& c0, Component1&& c1, Component2&& c2, Component3&& c3, RenderDependencyGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + const auto& uuid = c2; + auto res = g.passIndex.emplace(uuid, v); + CC_ENSURES(res.second); + } + g.passes.emplace_back(std::forward(c0)); + g.valueIDs.emplace_back(std::forward(c1)); + g.passIDs.emplace_back(std::forward(c2)); + g.traits.emplace_back(std::forward(c3)); + + return v; +} + +template +inline RenderDependencyGraph::vertex_descriptor +add_vertex(std::piecewise_construct_t, Component0&& c0, Component1&& c1, Component2&& c2, Component3&& c3, RenderDependencyGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + invoke_hpp::apply( + [&](const auto&... args) { + auto res = g.passIndex.emplace(std::piecewise_construct, std::forward_as_tuple(args...), std::forward_as_tuple(v)); + CC_ENSURES(res.second); + }, + c2); + } + + invoke_hpp::apply( + [&](auto&&... args) { + g.passes.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.valueIDs.emplace_back(std::forward(args)...); + }, + std::forward(c1)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.passIDs.emplace_back(std::forward(args)...); + }, + std::forward(c2)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.traits.emplace_back(std::forward(args)...); + }, + std::forward(c3)); + + return v; +} + +// IncidenceGraph +inline RenderValueGraph::vertex_descriptor +source(const RenderValueGraph::edge_descriptor& e, const RenderValueGraph& /*g*/) noexcept { + return e.source; +} + +inline RenderValueGraph::vertex_descriptor +target(const RenderValueGraph::edge_descriptor& e, const RenderValueGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderValueGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + RenderValueGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline RenderValueGraph::degree_size_type +out_degree(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(RenderValueGraph::vertex_descriptor u, RenderValueGraph::vertex_descriptor v, const RenderValueGraph& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), RenderValueGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {RenderValueGraph::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderValueGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + RenderValueGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline RenderValueGraph::degree_size_type +in_degree(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline RenderValueGraph::degree_size_type +degree(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(RenderValueGraph::vertex_descriptor u, const RenderValueGraph& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(RenderValueGraph::adjacency_iterator(edges.first, &g), RenderValueGraph::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const RenderValueGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline RenderValueGraph::vertices_size_type +num_vertices(const RenderValueGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const RenderValueGraph& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + RenderValueGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + RenderValueGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline RenderValueGraph::edges_size_type +num_edges(const RenderValueGraph& g) noexcept { // NOLINT + RenderValueGraph::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 +add_edge( // NOLINT + RenderValueGraph::vertex_descriptor u, + RenderValueGraph::vertex_descriptor v, RenderValueGraph& g) { + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u); + + return std::make_pair(RenderValueGraph::edge_descriptor(u, v), true); +} + +inline void remove_edge(RenderValueGraph::vertex_descriptor u, RenderValueGraph::vertex_descriptor v, RenderValueGraph& g) noexcept { // NOLINT + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(RenderValueGraph::edge_descriptor e, RenderValueGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(RenderValueGraph::out_edge_iterator iter, RenderValueGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(RenderValueGraph::vertex_descriptor u, Predicate&& pred, RenderValueGraph& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(RenderValueGraph::vertex_descriptor v, Predicate&& pred, RenderValueGraph& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, RenderValueGraph& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// MutableGraph(Vertex) +inline void clear_out_edges(RenderValueGraph::vertex_descriptor u, RenderValueGraph& 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(RenderValueGraph::vertex_descriptor u, RenderValueGraph& 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(RenderValueGraph::vertex_descriptor u, RenderValueGraph& g) noexcept { // NOLINT + clear_out_edges(u, g); + clear_in_edges(u, g); +} + +inline void remove_vertex(RenderValueGraph::vertex_descriptor u, RenderValueGraph& g) noexcept { // NOLINT + { // UuidGraph + const auto& key = g.nodes[u]; + auto num = g.index.erase(key); + CC_ENSURES(num == 1); + for (auto&& pair : g.index) { + auto& v = pair.second; + if (v > u) { + --v; + } + } + } + impl::removeVectorVertex(const_cast(g), u, RenderValueGraph::directed_category{}); + + // remove components + g.nodes.erase(g.nodes.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Vertex) +template +inline RenderValueGraph::vertex_descriptor +add_vertex(Component0&& c0, RenderValueGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + const auto& uuid = c0; + auto res = g.index.emplace(uuid, v); + CC_ENSURES(res.second); + } + g.nodes.emplace_back(std::forward(c0)); + + return v; +} + +template +inline RenderValueGraph::vertex_descriptor +add_vertex(std::piecewise_construct_t, Component0&& c0, RenderValueGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + invoke_hpp::apply( + [&](const auto&... args) { + auto res = g.index.emplace(std::piecewise_construct, std::forward_as_tuple(args...), std::forward_as_tuple(v)); + CC_ENSURES(res.second); + }, + c0); + } + + invoke_hpp::apply( + [&](auto&&... args) { + g.nodes.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + return v; +} + +} // namespace example + +} // namespace render + +} // namespace cc + +namespace boost { + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector, + cc::render::example::RenderPassNode, + const cc::render::example::RenderPassNode&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector, + cc::render::example::RenderPassNode, + cc::render::example::RenderPassNode&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::example::RenderPassNode::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector, + T, + T&, + T cc::render::example::RenderPassNode::*>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector>, + cc::PmrFlatSet, + const cc::PmrFlatSet&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector>, + cc::PmrFlatSet, + cc::PmrFlatSet&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector, + cc::render::RenderGraph::vertex_descriptor, + const cc::render::RenderGraph::vertex_descriptor&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector, + cc::render::RenderGraph::vertex_descriptor, + cc::render::RenderGraph::vertex_descriptor&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector, + cc::render::example::RenderPassTraits, + const cc::render::example::RenderPassTraits&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector, + cc::render::example::RenderPassTraits, + cc::render::example::RenderPassTraits&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::example::RenderPassTraits::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + container::pmr::vector, + T, + T&, + T cc::render::example::RenderPassTraits::*>; +}; + +// Edge All +template <> +struct property_map { + using const_type = cc::render::impl::EdgeBundlePropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + cc::render::example::DependencyType, + const cc::render::example::DependencyType&>; + using type = cc::render::impl::EdgeBundlePropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + cc::render::example::DependencyType, + cc::render::example::DependencyType&>; +}; + +// Edge Bundle +template <> +struct property_map { + using const_type = cc::render::impl::EdgeBundlePropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderDependencyGraph, + cc::render::example::DependencyType, + const cc::render::example::DependencyType&>; + using type = cc::render::impl::EdgeBundlePropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderDependencyGraph, + cc::render::example::DependencyType, + cc::render::example::DependencyType&>; +}; + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderValueGraph, + const container::pmr::vector, + cc::render::example::RenderValueNode, + const cc::render::example::RenderValueNode&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderValueGraph, + container::pmr::vector, + cc::render::example::RenderValueNode, + cc::render::example::RenderValueNode&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::example::RenderValueGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::example::RenderValueNode::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::example::RenderValueGraph, + container::pmr::vector, + T, + T&, + T cc::render::example::RenderValueNode::*>; +}; + +} // namespace boost + +namespace cc { + +namespace render { + +namespace example { + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const RenderDependencyGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, RenderDependencyGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const RenderDependencyGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderDependencyGraph::PassTag /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g.passes}; +} + +inline typename boost::property_map::type +get(RenderDependencyGraph::PassTag /*tag*/, RenderDependencyGraph& g) noexcept { + return {g.passes}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T RenderPassNode::*memberPointer, const RenderDependencyGraph& g) noexcept { + return {g.passes, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T RenderPassNode::*memberPointer, RenderDependencyGraph& g) noexcept { + return {g.passes, memberPointer}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderDependencyGraph::ValueIDTag /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g.valueIDs}; +} + +inline typename boost::property_map::type +get(RenderDependencyGraph::ValueIDTag /*tag*/, RenderDependencyGraph& g) noexcept { + return {g.valueIDs}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderDependencyGraph::PassIDTag /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g.passIDs}; +} + +inline typename boost::property_map::type +get(RenderDependencyGraph::PassIDTag /*tag*/, RenderDependencyGraph& g) noexcept { + return {g.passIDs}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderDependencyGraph::TraitsTag /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g.traits}; +} + +inline typename boost::property_map::type +get(RenderDependencyGraph::TraitsTag /*tag*/, RenderDependencyGraph& g) noexcept { + return {g.traits}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T RenderPassTraits::*memberPointer, const RenderDependencyGraph& g) noexcept { + return {g.traits, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T RenderPassTraits::*memberPointer, RenderDependencyGraph& g) noexcept { + return {g.traits, memberPointer}; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const RenderDependencyGraph& g, RenderDependencyGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, RenderDependencyGraph& g, RenderDependencyGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, RenderDependencyGraph& g, + RenderDependencyGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// Edge All +inline boost::property_map::const_type +get(boost::edge_all_t /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g}; +} + +inline boost::property_map::type +get(boost::edge_all_t /*tag*/, RenderDependencyGraph& g) noexcept { + return {g}; +} + +// Edge Bundle +inline boost::property_map::const_type +get(boost::edge_bundle_t /*tag*/, const RenderDependencyGraph& g) noexcept { + return {g}; +} + +inline boost::property_map::type +get(boost::edge_bundle_t /*tag*/, RenderDependencyGraph& g) noexcept { + return {g}; +} + +// Edge Constant Getter +template +inline decltype(auto) +get(Tag tag, const RenderDependencyGraph& g, RenderDependencyGraph::edge_descriptor e) noexcept { + return get(get(tag, g), e); +} + +// Edge Mutable Getter +template +inline decltype(auto) +get(Tag tag, RenderDependencyGraph& g, RenderDependencyGraph::edge_descriptor e) noexcept { + return get(get(tag, g), e); +} + +// Edge Setter +template +inline void put( + Tag tag, RenderDependencyGraph& g, + RenderDependencyGraph::edge_descriptor e, + Args&&... args) { + put(get(tag, g), e, std::forward(args)...); +} + +// UuidGraph +inline RenderDependencyGraph::vertex_descriptor +vertex(const RenderGraph::vertex_descriptor& key, const RenderDependencyGraph& g) { + return g.passIndex.at(key); +} + +template +inline RenderDependencyGraph::vertex_descriptor +vertex(const KeyLike& key, const RenderDependencyGraph& g) { + const auto& index = g.passIndex; + auto iter = index.find(key); + if (iter == index.end()) { + throw std::out_of_range("at(key, RenderDependencyGraph) out of range"); + } + return iter->second; +} + +template +inline RenderDependencyGraph::vertex_descriptor +find_vertex(const KeyLike& key, const RenderDependencyGraph& g) noexcept { // NOLINT + const auto& index = g.passIndex; + auto iter = index.find(key); + if (iter == index.end()) { + return RenderDependencyGraph::null_vertex(); + } + return iter->second; +} + +inline bool +contains(const RenderGraph::vertex_descriptor& key, const RenderDependencyGraph& g) noexcept { + auto iter = g.passIndex.find(key); + return iter != g.passIndex.end(); +} + +template +inline bool +contains(const KeyLike& key, const RenderDependencyGraph& g) noexcept { + auto iter = g.passIndex.find(key); + return iter != g.passIndex.end(); +} + +// MutableGraph(Vertex) +inline RenderDependencyGraph::vertex_descriptor +add_vertex(RenderDependencyGraph& g, const RenderGraph::vertex_descriptor& key) { // NOLINT + return add_vertex( + std::piecewise_construct, + std::forward_as_tuple(), // passes + std::forward_as_tuple(), // valueIDs + std::forward_as_tuple(key), // passIDs + std::forward_as_tuple(), // traits + g); +} + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const RenderValueGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, RenderValueGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const RenderValueGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderValueGraph::NodeTag /*tag*/, const RenderValueGraph& g) noexcept { + return {g.nodes}; +} + +inline typename boost::property_map::type +get(RenderValueGraph::NodeTag /*tag*/, RenderValueGraph& g) noexcept { + return {g.nodes}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T RenderValueNode::*memberPointer, const RenderValueGraph& g) noexcept { + return {g.nodes, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T RenderValueNode::*memberPointer, RenderValueGraph& g) noexcept { + return {g.nodes, memberPointer}; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const RenderValueGraph& g, RenderValueGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, RenderValueGraph& g, RenderValueGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, RenderValueGraph& g, + RenderValueGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// UuidGraph +inline RenderValueGraph::vertex_descriptor +vertex(const RenderValueNode& key, const RenderValueGraph& g) { + return g.index.at(key); +} + +template +inline RenderValueGraph::vertex_descriptor +vertex(const KeyLike& key, const RenderValueGraph& g) { + const auto& index = g.index; + auto iter = index.find(key); + if (iter == index.end()) { + throw std::out_of_range("at(key, RenderValueGraph) out of range"); + } + return iter->second; +} + +template +inline RenderValueGraph::vertex_descriptor +find_vertex(const KeyLike& key, const RenderValueGraph& g) noexcept { // NOLINT + const auto& index = g.index; + auto iter = index.find(key); + if (iter == index.end()) { + return RenderValueGraph::null_vertex(); + } + return iter->second; +} + +inline bool +contains(const RenderValueNode& key, const RenderValueGraph& g) noexcept { + auto iter = g.index.find(key); + return iter != g.index.end(); +} + +template +inline bool +contains(const KeyLike& key, const RenderValueGraph& g) noexcept { + auto iter = g.index.find(key); + return iter != g.index.end(); +} + +// MutableGraph(Vertex) +inline RenderValueGraph::vertex_descriptor +add_vertex(RenderValueGraph& g, const RenderValueNode& key) { // NOLINT + return add_vertex( + std::piecewise_construct, + std::forward_as_tuple(key), // nodes + g); +} + +} // namespace example + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleImpl.cpp b/native/cocos/renderer/pipeline/custom/RenderExampleImpl.cpp new file mode 100644 index 0000000000..790260e1c8 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleImpl.cpp @@ -0,0 +1,505 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include +#include +#include +#include +#include "RenderExampleGraphs.h" +#include "RenderGraphGraphs.h" +#include "LayoutGraphGraphs.h" +#include "LayoutGraphTypes.h" +#include "RenderCommonTypes.h" +#include "RenderExampleTypes.h" +#include "RenderGraphFwd.h" + +namespace cc { + +namespace render { + +namespace example { + +using RDG = RenderDependencyGraph; +using RESG = ResourceGraph; + +namespace { + +// validation +void checkComputeValue(const PmrTransparentMap>& values0) { + for (const auto& pair : values0) { + const auto& name = pair.first; + const auto& values = pair.second; + bool bWrite = false; + int count = 0; + for (const auto& v : values) { + if (v.clearFlags != gfx::ClearFlagBit::NONE) { + if (!v.isWrite()) { + throw std::invalid_argument("only write state support uav clear"); + } + } + if (count++ == 0) { + bWrite = v.isWrite(); + } else { + if (v.isWrite() != bWrite) { + throw std::invalid_argument("compute value read/write state inconsistent"); + } + } + } + } +}; + +} // namespace + +int RenderCompiler::validate() const { + const auto& rg = graph; + const auto& lg = layoutGraph; + try { + for (const auto& vertID : makeRange(vertices(rg))) { + visitObject( + vertID, rg, + [&](const RasterPass& pass) { + checkComputeValue(pass.computeViews); + }, + [&](const ComputePass& pass) { + checkComputeValue(pass.computeViews); + }, + [&](const auto& /*pass*/) { + }); + } + } catch (const std::invalid_argument&) { + return 1; + } + + return 0; +} + +int RenderCompiler::audit(std::ostream& oss) const { // NOLINT + return 0; +} + +namespace { + +void addPassNodeValue(RenderPassNode& node, PmrFlatSet& values, + const uint32_t valueID, AccessType type) { + // add to values + values.emplace(valueID); + // add to inputs and outputs + // inputs and outputs may overlap + switch (type) { + case AccessType::READ: + node.inputs.emplace(valueID); + break; + case AccessType::READ_WRITE: + node.outputs.emplace(valueID); + node.inputs.emplace(valueID); + break; + case AccessType::WRITE: + node.outputs.emplace(valueID); + break; + default: + break; + } +} + +void addPassNodeValue(RenderDependencyGraph& rdg, + RenderPassNode& node, PmrFlatSet& values, + const PmrString& valueName, AccessType type) { + auto iter = rdg.valueIndex.find(valueName); + if (iter == rdg.valueIndex.end()) { + rdg.valueIndex.emplace(valueName, uint32_t(rdg.valueNames.size())); + rdg.valueNames.emplace_back(valueName); + CC_ENSURES(rdg.valueIndex.size() == rdg.valueNames.size()); + } + addPassNodeValue(node, values, iter->second, type); +} + +void buildRenderDependencyGraph(const RenderGraph& rg, RenderDependencyGraph& rdg) { + size_t numPasses = 1; // additional init pass is the first pass + numPasses += rg.rasterPasses.size(); + numPasses += rg.computePasses.size(); + numPasses += rg.copyPasses.size(); + numPasses += rg.movePasses.size(); + numPasses += rg.raytracePasses.size(); + rdg.passIDs.reserve(numPasses); + rdg.valueIndex.reserve(128); + rdg.valueNames.reserve(128); + + // add initial pass, whose id must be 0 + auto startID = add_vertex(rdg, 0xFFFFFFFF); + CC_EXPECTS(startID == 0); + + auto makeAccessType = [](const boost::container::pmr::vector& values) { + CC_EXPECTS(!values.empty()); + AccessType type = values[0].accessType; + for (uint32_t i = 1; i != values.size(); ++i) { + const auto& value = values[i]; + if (value.isRead()) { + if (type == AccessType::WRITE) { + type = AccessType::READ_WRITE; + } + } + if (value.isWrite()) { + if (type == AccessType::READ) { + type = AccessType::READ_WRITE; + } + } + } + return type; + }; + + for (const auto passID : makeRange(vertices(rg))) { + visitObject( + passID, rg, + [&](const RasterPass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + for (const auto& pair : pass.rasterViews) { + const auto& valueName = pair.first; + const auto& value = pair.second; + addPassNodeValue(rdg, node, valueIDs, valueName, value.accessType); + } + for (const auto& pair : pass.computeViews) { + const auto& valueName = pair.first; + const auto& values = pair.second; + addPassNodeValue(rdg, node, valueIDs, valueName, makeAccessType(values)); + } + }, + [&](const ComputePass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + for (const auto& pair : pass.computeViews) { + const auto& valueName = pair.first; + const auto& values = pair.second; + addPassNodeValue(rdg, node, valueIDs, valueName, makeAccessType(values)); + } + }, + [&](const CopyPass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + + for (const auto& pair : pass.copyPairs) { + addPassNodeValue(rdg, node, valueIDs, pair.source, AccessType::READ); + addPassNodeValue(rdg, node, valueIDs, pair.target, AccessType::WRITE); + } + }, + [&](const MovePass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + + for (const auto& pair : pass.movePairs) { + addPassNodeValue(rdg, node, valueIDs, pair.source, AccessType::READ); + addPassNodeValue(rdg, node, valueIDs, pair.target, AccessType::WRITE); + } + }, + [&](const RaytracePass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + for (const auto& pair : pass.computeViews) { + const auto& valueName = pair.first; + const auto& values = pair.second; + addPassNodeValue(rdg, node, valueIDs, valueName, makeAccessType(values)); + } + }, + [&](const PresentPass& pass) { + auto vertID = add_vertex(rdg, passID); + auto& node = get(RDG::Pass, rdg, vertID); + auto& valueIDs = get(RDG::ValueID, rdg, vertID); + + addPassNodeValue(rdg, node, valueIDs, pass.resourceName, AccessType::READ); + }, + [&](const auto& /*pass*/) { + // do nothing + }); + } + CC_ENSURES(num_vertices(rdg) == numPasses); +} + +void buildRenderValueGraphAndInitialPass(RenderDependencyGraph& rdg, RenderValueGraph& rvg) { + // add value graph nodes + uint32_t numValues = 0; + for (const auto& valueIDs : rdg.valueIDs) { + numValues += gsl::narrow_cast(valueIDs.size()); + } + rvg.reserve(numValues); + + for (const auto passID : makeRange(vertices(rdg))) { + const auto& valueIDs = get(RDG::ValueID, rdg, passID); + for (const auto& valueID : valueIDs) { + CC_EXPECTS(!contains(RenderValueNode(passID, valueID), rvg)); + add_vertex(std::piecewise_construct, + std::forward_as_tuple(passID, valueID), rvg); + } + } + + // build value graph edges + auto initPassID = vertex(0xFFFFFFFF, rdg); + CC_EXPECTS(initPassID == 0); + auto& initPass = get(RDG::Pass, rdg, initPassID); + auto& initValueIDs = get(RDG::ValueID, rdg, initPassID); + + for (uint32_t dstPassID = num_vertices(rdg); dstPassID-- > 0;) { + auto& dstPass = get(RDG::Pass, rdg, dstPassID); + for (const auto valueID : dstPass.inputs) { + auto dstVertID = vertex(RenderValueNode(dstPassID, valueID), rvg); + CC_EXPECTS(in_degree(dstVertID, rvg) == 0); + // add value edge func + auto addValueEdge = [&rdg, &rvg, dstVertID, valueID]( + RenderDependencyGraph::vertex_descriptor srcPassID, + RenderDependencyGraph::vertex_descriptor dstPassID) { + // get value node in value graph + auto srcVertID = vertex(RenderValueNode(srcPassID, valueID), rvg); + CC_EXPECTS(!edge(srcVertID, dstVertID, rvg).second); // edge shouldn't have been added + // add value edge + auto res = add_edge(srcVertID, dstVertID, rvg); + CC_ENSURES(res.second); // edge must have been added + // try get pass dependency edge + auto e = edge(srcPassID, dstPassID, rdg); + if (!e.second) { // no pass dependency edge, add one + add_edge(srcPassID, dstPassID, rdg, DependencyType::DATA); + } else { + // upgrade dependency type to DependencyType::Value + put(boost::edge_bundle, rdg, e.first, DependencyType::DATA); + } + }; + + // try finding matching value in upstream render passes + bool found = false; + for (uint32_t srcPassID = dstPassID; srcPassID-- > 0;) { + auto& srcPass = get(RDG::Pass, rdg, srcPassID); + // value not found in source pass + if (!srcPass.outputs.contains(valueID)) { + continue; + } + // value is in source pass + addValueEdge(srcPassID, dstPassID); + found = true; + break; + } + if (!found) { // input value not found, add it to initial pass + // add init value nodes + addPassNodeValue(initPass, initValueIDs, valueID, AccessType::WRITE); + addValueEdge(initPassID, dstPassID); + } + } + } +} + +void buildRenderDependencyGraphResourceIndex(const ResourceGraph& resg, RenderDependencyGraph& rdg) { + CC_EXPECTS(rdg.valueNames.size() == rdg.valueIndex.size()); + + rdg.resourceHandles.resize(rdg.valueNames.size()); + + uint32_t valueID = 0; + for (const auto& valueName : rdg.valueNames) { + auto handleID = vertex(valueName, resg); + rdg.resourceHandles[valueID] = handleID; + ++valueID; + } +} + +struct CullingVisitor : boost::dfs_visitor<> { + CullingVisitor( + const ResourceGraph& resg0, + const RenderGraph& rg0, + const RenderDependencyGraph& rdg0, + + boost::property_map::const_type passes, + boost::property_map::const_type valueIDs, + boost::property_map::const_type passIDs, + boost::property_map::type traits, + boost::property_map::const_type resourceTraits) + : resg(resg0), + rg(rg0), + rdg(rdg0), + mPasses(passes), + valueIDs(valueIDs), + passIDs(passIDs), + traits(traits), + mResourceTraits(resourceTraits) {} + + // WARNING!!! + // dfs visitor must NOT contain any state, it is copied every where + using Graph = boost::reverse_graph; + + void markVertex(Graph::edge_descriptor e, const Graph& g) const { + auto sourceID = source(e, g); + auto targetID = target(e, g); + auto keep = get(traits, sourceID).keep; + get(traits, targetID).keep |= keep; + } + + void start_vertex(Graph::vertex_descriptor u, const Graph& g) { + // currently, do nothing + } + + void discover_vertex(Graph::vertex_descriptor u, const Graph& /*g*/) { + auto& keep = get(traits, u).keep; + if (keep) { + return; + } + + auto passID = rdg.passIDs.at(u); + if (holds_tag(passID, rg)) { + keep = true; + return; + } + + const auto& pass = get(mPasses, u); + // output values has side effects + for (const auto valueID : pass.outputs) { + auto handleID = rdg.resourceHandles[valueID]; + if (get(mResourceTraits, handleID).hasSideEffects()) { + keep = true; + break; + } + } + } + + void tree_edge(Graph::edge_descriptor e, const Graph& g) { // NOLINT + markVertex(e, g); + } + + void back_edge(Graph::edge_descriptor e, const Graph& g) { // NOLINT + throw std::invalid_argument("rdg is not DAG"); + } + + void forward_or_cross_edge(Graph::edge_descriptor e, const Graph& g) { // NOLINT + markVertex(e, g); + } + + void finish_vertex(Graph::vertex_descriptor v, const Graph& g) { // NOLINT + // currently, do nothing + } + + const ResourceGraph& resg; + const RenderGraph& rg; + const RenderDependencyGraph& rdg; + + boost::property_map::const_type mPasses; + boost::property_map::const_type valueIDs; + boost::property_map::const_type passIDs; + boost::property_map::type traits; + + boost::property_map::const_type mResourceTraits; +}; + +} // namespace + +int RenderCompiler::compile() { + auto& rg = graph; + const auto& resg = resourceGraph; + + try { + // per-condition: + // 1. render graph is already sorted, which is ensured by the building rule. + // 2. every render value can be found in resource graph + // 3. every render value in a pass can be found in the corresponding layout graph node + // 4. render value in a pass is read/write consistent, either read-only or readwrite/write + // a) a render value can be bound to multiple shader input parameters, + // so it might be read/write inconsistent. + + // convert render graph to render dependency graph + // rdg is a sub-graph of rg, it only contains render passes + // rdg implementation doesn't contain any string, so it's relatively faster. + RenderDependencyGraph rdg(scratch); + buildRenderDependencyGraph(rg, rdg); + + // try connect all render values, which are stored in RenderValueGraph (rvg) + // compute inter-pass dependencies of rdg + // if an input of render pass doesn't have any sources, + // add this input value to the initial render pass + RenderValueGraph rvg(scratch); + buildRenderValueGraphAndInitialPass(rdg, rvg); + + // build resource handle index + buildRenderDependencyGraphResourceIndex(resg, rdg); + + // rdg and rvg are now complete, we can do culling now + // if an output of a pass has no out-edge, this output is called general rg-output + // if a general rg-output is persistent or marked as output, + // we call it rg-output. it's containing pass is called rg-output-pass + // culling rules: + // 1. if a pass is not culled, its upstream passes should not be culled + // 2. rg-output-pass should not be culled + // 3. any pass contains readwrite/write persistent value, should not be culled + // 4. any pass contains side-effects not described here, should not be culled + // algorithm: + // 1. reversely search rdg + // 2. do depth-first search + // a) pass has rg-output, keep + // b) pass has persistent write values, keep + // c) any downstream pass is kept, keep + // d) found back-edge, rdg is not DAG, abort + // 3. any pass is not marked as keep, is culled + { + const auto& crdg = rdg; + const auto& cresg = resg; + + CullingVisitor visitor( + resg, rg, rdg, + get(RDG::Pass, crdg), + get(RDG::ValueID, crdg), + get(RDG::PassID, crdg), + get(RDG::Traits, rdg), + get(RESG::Traits, cresg)); + + auto colors = rdg.colors(scratch); + auto reverseGraph = boost::make_reverse_graph(crdg); + boost::depth_first_search( + reverseGraph, + visitor, + get(colors, rdg)); + } + } catch (const std::invalid_argument& /*e*/) { + return 1; + } + + add_vertex( + "name", + UpdateFrequency::PER_INSTANCE, + LayoutData(scratch), + GroupNodeData{}, + layoutGraph); + + add_vertex(ShaderTag{}, + std::forward_as_tuple("name"), + std::forward_as_tuple(UpdateFrequency::PER_INSTANCE), + std::forward_as_tuple(), + std::forward_as_tuple(), + layoutGraph); + + return 0; +} + +} // namespace example + +} // namespace render + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleNames.h b/native/cocos/renderer/pipeline/custom/RenderExampleNames.h new file mode 100644 index 0000000000..226ac66ee0 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleNames.h @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphNames.h" +#include "cocos/renderer/pipeline/custom/RenderExampleTypes.h" +#include "cocos/renderer/pipeline/custom/RenderGraphNames.h" + +namespace cc { + +namespace render { + +namespace example { + +inline const char* getName(DependencyType e) noexcept { + switch (e) { + case DependencyType::ORDER: return "ORDER"; + case DependencyType::DATA: return "DATA"; + } + return ""; +} +inline const char* getName(const RenderPassNode& /*v*/) noexcept { return "RenderPassNode"; } +inline const char* getName(const RenderPassTraits& /*v*/) noexcept { return "RenderPassTraits"; } +inline const char* getName(const RenderDependencyGraph& /*v*/) noexcept { return "RenderDependencyGraph"; } +inline const char* getName(const RenderValueNode& /*v*/) noexcept { return "RenderValueNode"; } +inline const char* getName(const RenderValueGraph& /*v*/) noexcept { return "RenderValueGraph"; } +inline const char* getName(const RenderCompiler& /*v*/) noexcept { return "RenderCompiler"; } + +} // namespace example + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleReflection.cpp b/native/cocos/renderer/pipeline/custom/RenderExampleReflection.cpp new file mode 100644 index 0000000000..507d62b1ef --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderExampleReflection.h" +#include "RenderExampleTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleReflection.h b/native/cocos/renderer/pipeline/custom/RenderExampleReflection.h new file mode 100644 index 0000000000..79271bf790 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleReflection.h @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/LayoutGraphReflection.h" +#include "cocos/renderer/pipeline/custom/RenderExampleFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphReflection.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderExampleTypes.cpp new file mode 100644 index 0000000000..78a5d527c3 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleTypes.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderExampleTypes.h" + +namespace cc { + +namespace render { + +namespace example { + +RenderPassNode::RenderPassNode(const allocator_type& alloc) noexcept +: outputs(alloc), + inputs(alloc) {} + +RenderPassNode::RenderPassNode(RenderPassNode&& rhs, const allocator_type& alloc) +: outputs(std::move(rhs.outputs), alloc), + inputs(std::move(rhs.inputs), alloc) {} + +RenderPassNode::RenderPassNode(RenderPassNode const& rhs, const allocator_type& alloc) +: outputs(rhs.outputs, alloc), + inputs(rhs.inputs, alloc) {} + +RenderDependencyGraph::RenderDependencyGraph(const allocator_type& alloc) noexcept +: vertices(alloc), + passes(alloc), + valueIDs(alloc), + passIDs(alloc), + traits(alloc), + edges(alloc), + passIndex(alloc), + valueIndex(alloc), + valueNames(alloc), + resourceHandles(alloc) {} + +// ContinuousContainer +void RenderDependencyGraph::reserve(vertices_size_type sz) { + vertices.reserve(sz); + passes.reserve(sz); + valueIDs.reserve(sz); + passIDs.reserve(sz); + traits.reserve(sz); +} + +RenderDependencyGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +RenderDependencyGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc) {} + +RenderDependencyGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc) {} + +RenderValueGraph::RenderValueGraph(const allocator_type& alloc) noexcept +: vertices(alloc), + nodes(alloc), + index(alloc) {} + +// ContinuousContainer +void RenderValueGraph::reserve(vertices_size_type sz) { + vertices.reserve(sz); + nodes.reserve(sz); +} + +RenderValueGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +RenderValueGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc) {} + +RenderValueGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc) {} + +} // namespace example + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExampleTypes.h b/native/cocos/renderer/pipeline/custom/RenderExampleTypes.h new file mode 100644 index 0000000000..1c806b5648 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExampleTypes.h @@ -0,0 +1,407 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include +#include +#include +#include +#include "cocos/renderer/pipeline/custom/GraphTypes.h" +#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" +#include "cocos/renderer/pipeline/custom/Map.h" +#include "cocos/renderer/pipeline/custom/RenderExampleFwd.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" +#include "cocos/renderer/pipeline/custom/Set.h" +#include "cocos/renderer/pipeline/custom/String.h" + +namespace cc { + +namespace render { + +namespace example { + +enum class DependencyType { + ORDER, + DATA, +}; + +struct RenderPassNode { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outputs.get_allocator().resource()}; + } + + RenderPassNode(const allocator_type& alloc) noexcept; // NOLINT + RenderPassNode(RenderPassNode&& rhs, const allocator_type& alloc); + RenderPassNode(RenderPassNode const& rhs, const allocator_type& alloc); + + RenderPassNode(RenderPassNode&& rhs) noexcept = default; + RenderPassNode(RenderPassNode const& rhs) = delete; + RenderPassNode& operator=(RenderPassNode&& rhs) = default; + RenderPassNode& operator=(RenderPassNode const& rhs) = default; + + PmrFlatSet outputs; + PmrFlatSet inputs; +}; + +struct RenderPassTraits { + bool keep{false}; +}; + +struct RenderDependencyGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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(); + } + + RenderDependencyGraph(const allocator_type& alloc) noexcept; // NOLINT + RenderDependencyGraph(RenderDependencyGraph&& rhs) = delete; + RenderDependencyGraph(RenderDependencyGraph const& rhs) = delete; + RenderDependencyGraph& operator=(RenderDependencyGraph&& rhs) = delete; + RenderDependencyGraph& operator=(RenderDependencyGraph const& rhs) = delete; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptorWithProperty; + 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::max(); + } + using edge_type = impl::ListEdge; + + // IncidenceGraph + using out_edge_type = impl::StoredEdgeWithEdgeIter< + vertex_descriptor, + PmrList::iterator, + DependencyType>; + using out_edge_iterator = impl::OutPropertyEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdgeWithEdgeIter< + vertex_descriptor, + PmrList::iterator, + DependencyType>; + using in_edge_iterator = impl::InPropertyEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + RenderDependencyGraph, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::UndirectedEdgeIter< + PmrList::iterator, + edge_descriptor, int32_t>; + using edges_size_type = uint32_t; + + using edge_property_type = DependencyType; + + // PropertyGraph (Edge) + const edge_property_type& operator[](const edge_descriptor& e) const noexcept { + return *static_cast(e.get_property()); + } + edge_property_type& operator[](const edge_descriptor& e) noexcept { + return *static_cast(e.get_property()); + } + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + }; + + struct PassTag { + } static constexpr Pass{}; // NOLINT + struct ValueIDTag { + } static constexpr ValueID{}; // NOLINT + struct PassIDTag { + } static constexpr PassID{}; // NOLINT + struct TraitsTag { + } static constexpr Traits{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector passes; + boost::container::pmr::vector> valueIDs; + boost::container::pmr::vector passIDs; + boost::container::pmr::vector traits; + // Edges + PmrList edges; + // UuidGraph + PmrUnorderedMap passIndex; + // Members + PmrUnorderedMap valueIndex; + boost::container::pmr::vector valueNames; + boost::container::pmr::vector resourceHandles; +}; + +struct RenderValueNode { + RenderValueNode() = default; + RenderValueNode(uint32_t passIDIn, uint32_t valueIDIn) noexcept // NOLINT + : passID(passIDIn), + valueID(valueIDIn) {} + + uint32_t passID{0xFFFFFFFF}; + uint32_t valueID{0xFFFFFFFF}; +}; + +inline bool operator==(const RenderValueNode& lhs, const RenderValueNode& rhs) noexcept { + return std::forward_as_tuple(lhs.passID, lhs.valueID) == + std::forward_as_tuple(rhs.passID, rhs.valueID); +} + +inline bool operator!=(const RenderValueNode& lhs, const RenderValueNode& rhs) noexcept { + return !(lhs == rhs); +} + +struct RenderValueGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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(); + } + + RenderValueGraph(const allocator_type& alloc) noexcept; // NOLINT + RenderValueGraph(RenderValueGraph&& rhs) = delete; + RenderValueGraph(RenderValueGraph const& rhs) = delete; + RenderValueGraph& operator=(RenderValueGraph&& rhs) = delete; + RenderValueGraph& operator=(RenderValueGraph const& rhs) = delete; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptor; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + RenderValueGraph, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + }; + + struct NodeTag { + } static constexpr Node{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector nodes; + // UuidGraph + PmrUnorderedMap index; +}; + +struct RenderCompiler { + RenderCompiler(ResourceGraph& resourceGraphIn, RenderGraph& graphIn, LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn) noexcept + : resourceGraph(resourceGraphIn), + graph(graphIn), + layoutGraph(layoutGraphIn), + scratch(scratchIn) {} + RenderCompiler(RenderCompiler&& rhs) = delete; + RenderCompiler(RenderCompiler const& rhs) = delete; + RenderCompiler& operator=(RenderCompiler&& rhs) = delete; + RenderCompiler& operator=(RenderCompiler const& rhs) = delete; + + int validate() const; + int audit(std::ostream& oss) const; + int compile(); + + ResourceGraph& resourceGraph; + RenderGraph& graph; + LayoutGraphData& layoutGraph; + boost::container::pmr::memory_resource* scratch{nullptr}; +}; + +} // namespace example + +} // namespace render + +} // namespace cc + +namespace std { + +inline size_t hash::operator()(const cc::render::example::RenderValueNode& v) const noexcept { + size_t seed = 0; + boost::hash_combine(seed, v.passID); + boost::hash_combine(seed, v.valueID); + return seed; +} + +} // namespace std + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorFwd.h b/native/cocos/renderer/pipeline/custom/RenderExecutorFwd.h new file mode 100644 index 0000000000..2bd0ed79f4 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorFwd.h @@ -0,0 +1,47 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/gfx-base/GFXDef-common.h" +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" + +namespace cc { + +namespace render { + +struct DeviceResourceGraph; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorGraphs.h b/native/cocos/renderer/pipeline/custom/RenderExecutorGraphs.h new file mode 100644 index 0000000000..eebe1a3078 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorGraphs.h @@ -0,0 +1,791 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/GraphImpl.h" +#include "cocos/renderer/pipeline/custom/GslUtils.h" +#include "cocos/renderer/pipeline/custom/Overload.h" +#include "cocos/renderer/pipeline/custom/PathUtils.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorTypes.h" +#include "cocos/renderer/pipeline/custom/invoke.hpp" + +namespace cc { + +namespace render { + +// IncidenceGraph +inline DeviceResourceGraph::vertex_descriptor +source(const DeviceResourceGraph::edge_descriptor& e, const DeviceResourceGraph& /*g*/) noexcept { + return e.source; +} + +inline DeviceResourceGraph::vertex_descriptor +target(const DeviceResourceGraph::edge_descriptor& e, const DeviceResourceGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + return std::make_pair( + DeviceResourceGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + DeviceResourceGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline DeviceResourceGraph::degree_size_type +out_degree(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), DeviceResourceGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {DeviceResourceGraph::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + return std::make_pair( + DeviceResourceGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + DeviceResourceGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline DeviceResourceGraph::degree_size_type +in_degree(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline DeviceResourceGraph::degree_size_type +degree(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(DeviceResourceGraph::adjacency_iterator(edges.first, &g), DeviceResourceGraph::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const DeviceResourceGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline DeviceResourceGraph::vertices_size_type +num_vertices(const DeviceResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const DeviceResourceGraph& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + DeviceResourceGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + DeviceResourceGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline DeviceResourceGraph::edges_size_type +num_edges(const DeviceResourceGraph& g) noexcept { // NOLINT + DeviceResourceGraph::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 +add_edge( // NOLINT + DeviceResourceGraph::vertex_descriptor u, + DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) { + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u); + + return std::make_pair(DeviceResourceGraph::edge_descriptor(u, v), true); +} + +inline void remove_edge(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) noexcept { // NOLINT + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(DeviceResourceGraph::edge_descriptor e, DeviceResourceGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(DeviceResourceGraph::out_edge_iterator iter, DeviceResourceGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(DeviceResourceGraph::vertex_descriptor u, Predicate&& pred, DeviceResourceGraph& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(DeviceResourceGraph::vertex_descriptor v, Predicate&& pred, DeviceResourceGraph& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, DeviceResourceGraph& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// MutableGraph(Vertex) +inline void clear_out_edges(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph& 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(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph& 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(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph& g) noexcept { // NOLINT + clear_out_edges(u, g); + clear_in_edges(u, g); +} + +inline void remove_vertex_value_impl(const DeviceResourceGraph::vertex_handle_type& h, DeviceResourceGraph& g) noexcept { // NOLINT + using vertex_descriptor = DeviceResourceGraph::vertex_descriptor; + cc::visit( + overload( + [&](const impl::ValueHandle& h) { + g.buffers.erase(g.buffers.begin() + std::ptrdiff_t(h.value)); + if (h.value == g.buffers.size()) { + return; + } + impl::reindexVectorHandle(g.vertices, h.value); + }, + [&](const impl::ValueHandle& h) { + g.textures.erase(g.textures.begin() + std::ptrdiff_t(h.value)); + if (h.value == g.textures.size()) { + return; + } + impl::reindexVectorHandle(g.vertices, h.value); + }), + h); +} + +inline void remove_vertex(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph& g) noexcept { // NOLINT + // preserve vertex' iterators + auto& vert = g.vertices[u]; + remove_vertex_value_impl(vert.handle, g); + impl::removeVectorVertex(const_cast(g), u, DeviceResourceGraph::directed_category{}); + + // remove components + g.names.erase(g.names.begin() + std::ptrdiff_t(u)); + g.refCounts.erase(g.refCounts.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Vertex) +template +void add_vertex_impl( // NOLINT + ValueT &&val, DeviceResourceGraph &g, DeviceResourceGraph::vertex_type &vert, // NOLINT + std::enable_if_t, std::unique_ptr>::value>* dummy = nullptr) { // NOLINT + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.buffers.size())}; + g.buffers.emplace_back(std::forward(val)); +} + +template +void add_vertex_impl( // NOLINT + ValueT &&val, DeviceResourceGraph &g, DeviceResourceGraph::vertex_type &vert, // NOLINT + std::enable_if_t, std::unique_ptr>::value>* dummy = nullptr) { // NOLINT + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.textures.size())}; + g.textures.emplace_back(std::forward(val)); +} + +template +inline DeviceResourceGraph::vertex_descriptor +add_vertex(Component0&& c0, Component1&& c1, ValueT&& val, DeviceResourceGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + auto& vert = g.vertices.back(); + g.names.emplace_back(std::forward(c0)); + g.refCounts.emplace_back(std::forward(c1)); + + // PolymorphicGraph + // if no matching overloaded function is found, Type is not supported by PolymorphicGraph + add_vertex_impl(std::forward(val), g, vert); + + return v; +} + +template +void add_vertex_impl(BufferTag /*tag*/, Tuple &&val, DeviceResourceGraph &g, DeviceResourceGraph::vertex_type &vert) { // NOLINT + invoke_hpp::apply( + [&](auto&&... args) { + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.buffers.size())}; + g.buffers.emplace_back(std::forward(args)...); + }, + std::forward(val)); +} + +template +void add_vertex_impl(TextureTag /*tag*/, Tuple &&val, DeviceResourceGraph &g, DeviceResourceGraph::vertex_type &vert) { // NOLINT + invoke_hpp::apply( + [&](auto&&... args) { + vert.handle = impl::ValueHandle{ + gsl::narrow_cast(g.textures.size())}; + g.textures.emplace_back(std::forward(args)...); + }, + std::forward(val)); +} + +template +inline DeviceResourceGraph::vertex_descriptor +add_vertex(Tag tag, Component0&& c0, Component1&& c1, ValueT&& val, DeviceResourceGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + auto& vert = g.vertices.back(); + + invoke_hpp::apply( + [&](auto&&... args) { + g.names.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.refCounts.emplace_back(std::forward(args)...); + }, + std::forward(c1)); + + // PolymorphicGraph + // if no matching overloaded function is found, Type is not supported by PolymorphicGraph + add_vertex_impl(tag, std::forward(val), g, vert); + + return v; +} + +} // namespace render + +} // namespace cc + +namespace boost { + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::DeviceResourceGraph, + const container::pmr::vector, + boost::string_view, + const std::string&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::DeviceResourceGraph, + container::pmr::vector, + boost::string_view, + std::string&>; +}; + +// Vertex Name +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::DeviceResourceGraph, + const container::pmr::vector, + boost::string_view, + const std::string&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::DeviceResourceGraph, + container::pmr::vector, + boost::string_view, + std::string&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::DeviceResourceGraph, + const container::pmr::vector, + int32_t, + const int32_t&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::DeviceResourceGraph, + container::pmr::vector, + int32_t, + int32_t&>; +}; + +} // namespace boost + +namespace cc { + +namespace render { + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const DeviceResourceGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, DeviceResourceGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const DeviceResourceGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(DeviceResourceGraph::NameTag /*tag*/, const DeviceResourceGraph& g) noexcept { + return {g.names}; +} + +inline typename boost::property_map::type +get(DeviceResourceGraph::NameTag /*tag*/, DeviceResourceGraph& g) noexcept { + return {g.names}; +} + +// Vertex Name +inline boost::property_map::const_type +get(boost::vertex_name_t /*tag*/, const DeviceResourceGraph& g) noexcept { + return {g.names}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(DeviceResourceGraph::RefCountTag /*tag*/, const DeviceResourceGraph& g) noexcept { + return {g.refCounts}; +} + +inline typename boost::property_map::type +get(DeviceResourceGraph::RefCountTag /*tag*/, DeviceResourceGraph& g) noexcept { + return {g.refCounts}; +} + +// PolymorphicGraph +inline DeviceResourceGraph::vertices_size_type +value_id(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { // NOLINT + using vertex_descriptor = DeviceResourceGraph::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }), + g.vertices[u].handle); +} + +inline DeviceResourceGraph::vertex_tag_type +tag(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { + using vertex_descriptor = DeviceResourceGraph::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle&) { + return DeviceResourceGraph::vertex_tag_type{BufferTag{}}; + }, + [](const impl::ValueHandle&) { + return DeviceResourceGraph::vertex_tag_type{TextureTag{}}; + }), + g.vertices[u].handle); +} + +inline DeviceResourceGraph::vertex_value_type +value(DeviceResourceGraph::vertex_descriptor u, DeviceResourceGraph& g) noexcept { + using vertex_descriptor = DeviceResourceGraph::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return DeviceResourceGraph::vertex_value_type{&g.buffers[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return DeviceResourceGraph::vertex_value_type{&g.textures[h.value]}; + }), + g.vertices[u].handle); +} + +inline DeviceResourceGraph::vertex_const_value_type +value(DeviceResourceGraph::vertex_descriptor u, const DeviceResourceGraph& g) noexcept { + using vertex_descriptor = DeviceResourceGraph::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return DeviceResourceGraph::vertex_const_value_type{&g.buffers[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return DeviceResourceGraph::vertex_const_value_type{&g.textures[h.value]}; + }), + g.vertices[u].handle); +} + +template +inline bool +holds_tag(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept; // NOLINT + +template <> +inline bool +holds_tag(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline bool +holds_alternative(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept; // NOLINT + +template <> +inline bool +holds_alternative>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline ValueT& +get(DeviceResourceGraph::vertex_descriptor /*v*/, DeviceResourceGraph& /*g*/); + +template <> +inline std::unique_ptr& +get>(DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.buffers[handle.value]; +} + +template <> +inline std::unique_ptr& +get>(DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.textures[handle.value]; +} + +template +inline const ValueT& +get(DeviceResourceGraph::vertex_descriptor /*v*/, const DeviceResourceGraph& /*g*/); + +template <> +inline const std::unique_ptr& +get>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.buffers[handle.value]; +} + +template <> +inline const std::unique_ptr& +get>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.textures[handle.value]; +} + +inline std::unique_ptr& +get(BufferTag /*tag*/, DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.buffers[handle.value]; +} + +inline std::unique_ptr& +get(TextureTag /*tag*/, DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.textures[handle.value]; +} + +inline const std::unique_ptr& +get(BufferTag /*tag*/, DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.buffers[handle.value]; +} + +inline const std::unique_ptr& +get(TextureTag /*tag*/, DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.textures[handle.value]; +} + +template +inline ValueT* +get_if(DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph* pGraph) noexcept; // NOLINT + +template <> +inline std::unique_ptr* +get_if>(DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph* pGraph) noexcept { // NOLINT + std::unique_ptr* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.buffers[pHandle->value]; + } + return ptr; +} + +template <> +inline std::unique_ptr* +get_if>(DeviceResourceGraph::vertex_descriptor v, DeviceResourceGraph* pGraph) noexcept { // NOLINT + std::unique_ptr* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.textures[pHandle->value]; + } + return ptr; +} + +template +inline const ValueT* +get_if(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph* pGraph) noexcept; // NOLINT + +template <> +inline const std::unique_ptr* +get_if>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph* pGraph) noexcept { // NOLINT + const std::unique_ptr* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.buffers[pHandle->value]; + } + return ptr; +} + +template <> +inline const std::unique_ptr* +get_if>(DeviceResourceGraph::vertex_descriptor v, const DeviceResourceGraph* pGraph) noexcept { // NOLINT + const std::unique_ptr* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.textures[pHandle->value]; + } + return ptr; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const DeviceResourceGraph& g, DeviceResourceGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, DeviceResourceGraph& g, DeviceResourceGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, DeviceResourceGraph& g, + DeviceResourceGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// MutableGraph(Vertex) +template +inline DeviceResourceGraph::vertex_descriptor +add_vertex(DeviceResourceGraph& g, Tag t, std::string&& name) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(std::move(name)), // names + std::forward_as_tuple(), // refCounts + std::forward_as_tuple(), // PolymorphicType + g); +} + +template +inline DeviceResourceGraph::vertex_descriptor +add_vertex(DeviceResourceGraph& g, Tag t, const char* name) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(name), // names + std::forward_as_tuple(), // refCounts + std::forward_as_tuple(), // PolymorphicType + g); +} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.cpp b/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.cpp new file mode 100644 index 0000000000..1316f59682 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "cocos/renderer/pipeline/custom/JsbConversion.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorJsb.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.h b/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.h new file mode 100644 index 0000000000..b85bf998ad --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorJsb.h @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/renderer/pipeline/custom/RenderCommonJsb.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorFwd.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorNames.h b/native/cocos/renderer/pipeline/custom/RenderExecutorNames.h new file mode 100644 index 0000000000..434f88ab9e --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorNames.h @@ -0,0 +1,46 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonNames.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorTypes.h" + +namespace cc { + +namespace render { + +inline const char* getName(const DeviceResourceGraph& /*v*/) noexcept { return "DeviceResourceGraph"; } + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.cpp b/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.cpp new file mode 100644 index 0000000000..9eb0b14228 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderExecutorReflection.h" +#include "RenderExecutorTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.h b/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.h new file mode 100644 index 0000000000..85410ffa8a --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorReflection.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonReflection.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorFwd.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.cpp new file mode 100644 index 0000000000..0d3c4bc9d4 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderExecutorTypes.h" + +namespace cc { + +namespace render { + +DeviceResourceGraph::DeviceResourceGraph(const allocator_type& alloc) noexcept +: vertices(alloc), + names(alloc), + refCounts(alloc), + buffers(alloc), + textures(alloc) {} + +// ContinuousContainer +void DeviceResourceGraph::reserve(vertices_size_type sz) { + vertices.reserve(sz); + names.reserve(sz); + refCounts.reserve(sz); +} + +DeviceResourceGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +DeviceResourceGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc), + handle(std::move(rhs.handle)) {} + +DeviceResourceGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc), + handle(rhs.handle) {} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.h b/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.h new file mode 100644 index 0000000000..5d2d6f7082 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderExecutorTypes.h @@ -0,0 +1,184 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include +#include +#include +#include +#include "cocos/renderer/gfx-base/GFXBuffer.h" +#include "cocos/renderer/gfx-base/GFXDef-common.h" +#include "cocos/renderer/gfx-base/GFXTexture.h" +#include "cocos/renderer/pipeline/custom/GraphTypes.h" +#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h" +#include "cocos/renderer/pipeline/custom/RenderExecutorFwd.h" + +namespace cc { + +namespace render { + +struct DeviceResourceGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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(); + } + + DeviceResourceGraph(const allocator_type& alloc) noexcept; // NOLINT + DeviceResourceGraph(DeviceResourceGraph&& rhs) = delete; + DeviceResourceGraph(DeviceResourceGraph const& rhs) = delete; + DeviceResourceGraph& operator=(DeviceResourceGraph&& rhs) = delete; + DeviceResourceGraph& operator=(DeviceResourceGraph const& rhs) = delete; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptor; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + DeviceResourceGraph, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // PolymorphicGraph + using vertex_tag_type = boost::variant2::variant; + using vertex_value_type = boost::variant2::variant*, std::unique_ptr*>; + using vertex_const_value_type = boost::variant2::variant*, const std::unique_ptr*>; + using vertex_handle_type = boost::variant2::variant< + impl::ValueHandle, + impl::ValueHandle>; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + vertex_handle_type handle; + }; + + struct NameTag { + } static constexpr Name{}; // NOLINT + struct RefCountTag { + } static constexpr RefCount{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector names; + boost::container::pmr::vector refCounts; + // PolymorphicGraph + boost::container::pmr::vector> buffers; + boost::container::pmr::vector> textures; +}; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphFwd.h b/native/cocos/renderer/pipeline/custom/RenderGraphFwd.h new file mode 100644 index 0000000000..5df44a131c --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphFwd.h @@ -0,0 +1,84 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/gfx-base/GFXDef-common.h" +#include "cocos/renderer/pipeline/PipelineSceneData.h" +#include "cocos/renderer/pipeline/custom/RenderCommonFwd.h" +#include "cocos/scene/Camera.h" + +namespace cc { + +namespace render { + +enum class ResourceFlags : uint32_t; +enum class TextureLayout; + +struct ResourceDesc; +struct ResourceTraits; +struct ResourceGraph; + +enum class AttachmentType; +enum class AccessType; + +struct RasterView; + +enum class ClearValueType; + +struct ComputeView; +struct RasterSubpass; +struct SubpassGraph; +struct RasterPass; +struct ComputePass; +struct CopyPair; +struct CopyPass; +struct MovePair; +struct MovePass; +struct RaytracePass; +struct QueueTag; +struct SceneTag; +struct DispatchTag; +struct BlitTag; +struct PresentTag; +struct RenderQueue; +struct SceneData; +struct Dispatch; +struct Blit; +struct PresentPass; +struct RenderData; +struct RenderGraph; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h new file mode 100644 index 0000000000..4c472041db --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h @@ -0,0 +1,2563 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/renderer/pipeline/custom/GraphImpl.h" +#include "cocos/renderer/pipeline/custom/GslUtils.h" +#include "cocos/renderer/pipeline/custom/Overload.h" +#include "cocos/renderer/pipeline/custom/PathUtils.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" +#include "cocos/renderer/pipeline/custom/invoke.hpp" + +namespace cc { + +namespace render { + +// IncidenceGraph +inline ResourceGraph::vertex_descriptor +source(const ResourceGraph::edge_descriptor& e, const ResourceGraph& /*g*/) noexcept { + return e.source; +} + +inline ResourceGraph::vertex_descriptor +target(const ResourceGraph::edge_descriptor& e, const ResourceGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { // NOLINT + return std::make_pair( + ResourceGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + ResourceGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline ResourceGraph::degree_size_type +out_degree(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(ResourceGraph::vertex_descriptor u, ResourceGraph::vertex_descriptor v, const ResourceGraph& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), ResourceGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {ResourceGraph::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { // NOLINT + return std::make_pair( + ResourceGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + ResourceGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline ResourceGraph::degree_size_type +in_degree(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline ResourceGraph::degree_size_type +degree(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(ResourceGraph::adjacency_iterator(edges.first, &g), ResourceGraph::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const ResourceGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline ResourceGraph::vertices_size_type +num_vertices(const ResourceGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const ResourceGraph& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + ResourceGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + ResourceGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline ResourceGraph::edges_size_type +num_edges(const ResourceGraph& g) noexcept { // NOLINT + ResourceGraph::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 +add_edge( // NOLINT + ResourceGraph::vertex_descriptor u, + ResourceGraph::vertex_descriptor v, ResourceGraph& g) { + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u); + + return std::make_pair(ResourceGraph::edge_descriptor(u, v), true); +} + +inline void remove_edge(ResourceGraph::vertex_descriptor u, ResourceGraph::vertex_descriptor v, ResourceGraph& g) noexcept { // NOLINT + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(ResourceGraph::edge_descriptor e, ResourceGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(ResourceGraph::out_edge_iterator iter, ResourceGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(ResourceGraph::vertex_descriptor u, Predicate&& pred, ResourceGraph& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(ResourceGraph::vertex_descriptor v, Predicate&& pred, ResourceGraph& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, ResourceGraph& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// MutableGraph(Vertex) +inline void clear_out_edges(ResourceGraph::vertex_descriptor u, ResourceGraph& 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(ResourceGraph::vertex_descriptor u, ResourceGraph& 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(ResourceGraph::vertex_descriptor u, ResourceGraph& g) noexcept { // NOLINT + clear_out_edges(u, g); + clear_in_edges(u, g); +} + +inline void remove_vertex(ResourceGraph::vertex_descriptor u, ResourceGraph& g) noexcept { // NOLINT + { // UuidGraph + const auto& key = g.names[u]; + auto num = g.valueIndex.erase(key); + CC_ENSURES(num == 1); + for (auto&& pair : g.valueIndex) { + auto& v = pair.second; + if (v > u) { + --v; + } + } + } + impl::removeVectorVertex(const_cast(g), u, ResourceGraph::directed_category{}); + + // remove components + g.names.erase(g.names.begin() + std::ptrdiff_t(u)); + g.descs.erase(g.descs.begin() + std::ptrdiff_t(u)); + g.traits.erase(g.traits.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Vertex) +template +inline ResourceGraph::vertex_descriptor +add_vertex(Component0&& c0, Component1&& c1, Component2&& c2, ResourceGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + const auto& uuid = c0; + auto res = g.valueIndex.emplace(uuid, v); + CC_ENSURES(res.second); + } + g.names.emplace_back(std::forward(c0)); + g.descs.emplace_back(std::forward(c1)); + g.traits.emplace_back(std::forward(c2)); + + return v; +} + +template +inline ResourceGraph::vertex_descriptor +add_vertex(std::piecewise_construct_t, Component0&& c0, Component1&& c1, Component2&& c2, ResourceGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + { // UuidGraph + invoke_hpp::apply( + [&](const auto&... args) { + auto res = g.valueIndex.emplace(std::piecewise_construct, std::forward_as_tuple(args...), std::forward_as_tuple(v)); + CC_ENSURES(res.second); + }, + c0); + } + + invoke_hpp::apply( + [&](auto&&... args) { + g.names.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.descs.emplace_back(std::forward(args)...); + }, + std::forward(c1)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.traits.emplace_back(std::forward(args)...); + }, + std::forward(c2)); + + 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 +out_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT + return std::make_pair( + SubpassGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + SubpassGraph::out_edge_iterator(const_cast(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(g.getOutEdgeList(u).size()); +} + +inline std::pair +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::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {SubpassGraph::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(SubpassGraph::vertex_descriptor u, const SubpassGraph& g) noexcept { // NOLINT + return std::make_pair( + SubpassGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + SubpassGraph::in_edge_iterator(const_cast(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(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 +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 +vertices(const SubpassGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline SubpassGraph::vertices_size_type +num_vertices(const SubpassGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const SubpassGraph& g0) noexcept { + auto& g = const_cast(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 +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 + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(SubpassGraph::edge_descriptor e, SubpassGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(SubpassGraph::out_edge_iterator iter, SubpassGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(SubpassGraph::vertex_descriptor u, Predicate&& pred, SubpassGraph& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(SubpassGraph::vertex_descriptor v, Predicate&& pred, SubpassGraph& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, SubpassGraph& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, 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(g), u, SubpassGraph::directed_category{}); + + // remove components + g.names.erase(g.names.begin() + std::ptrdiff_t(u)); + g.subpasses.erase(g.subpasses.begin() + std::ptrdiff_t(u)); +} + +// MutablePropertyGraph(Vertex) +template +inline SubpassGraph::vertex_descriptor +add_vertex(Component0&& c0, Component1&& c1, SubpassGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + g.names.emplace_back(std::forward(c0)); + g.subpasses.emplace_back(std::forward(c1)); + + return v; +} + +template +inline SubpassGraph::vertex_descriptor +add_vertex(std::piecewise_construct_t, Component0&& c0, Component1&& c1, SubpassGraph& g) { // NOLINT + auto v = gsl::narrow_cast(g.vertices.size()); + + g.vertices.emplace_back(); + + invoke_hpp::apply( + [&](auto&&... args) { + g.names.emplace_back(std::forward(args)...); + }, + std::forward(c0)); + + invoke_hpp::apply( + [&](auto&&... args) { + g.subpasses.emplace_back(std::forward(args)...); + }, + std::forward(c1)); + + return v; +} + +// IncidenceGraph +inline RenderGraph::vertex_descriptor +source(const RenderGraph::edge_descriptor& e, const RenderGraph& /*g*/) noexcept { + return e.source; +} + +inline RenderGraph::vertex_descriptor +target(const RenderGraph::edge_descriptor& e, const RenderGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +out_edges(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).begin(), u), + RenderGraph::out_edge_iterator(const_cast(g).getOutEdgeList(u).end(), u)); +} + +inline RenderGraph::degree_size_type +out_degree(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getOutEdgeList(u).size()); +} + +inline std::pair +edge(RenderGraph::vertex_descriptor u, RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { + const auto& outEdgeList = g.getOutEdgeList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), RenderGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {RenderGraph::edge_descriptor(u, v), hasEdge}; +} + +// BidirectionalGraph(Directed) +inline std::pair +in_edges(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return std::make_pair( + RenderGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).begin(), u), + RenderGraph::in_edge_iterator(const_cast(g).getInEdgeList(u).end(), u)); +} + +inline RenderGraph::degree_size_type +in_degree(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getInEdgeList(u).size()); +} + +inline RenderGraph::degree_size_type +degree(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + return in_degree(u, g) + out_degree(u, g); +} + +// AdjacencyGraph +inline std::pair +adjacent_vertices(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + auto edges = out_edges(u, g); + return std::make_pair(RenderGraph::adjacency_iterator(edges.first, &g), RenderGraph::adjacency_iterator(edges.second, &g)); +} + +// VertexListGraph +inline std::pair +vertices(const RenderGraph& g) noexcept { + return std::make_pair(const_cast(g).getVertexList().begin(), const_cast(g).getVertexList().end()); +} + +inline RenderGraph::vertices_size_type +num_vertices(const RenderGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getVertexList().size()); +} + +// EdgeListGraph +inline std::pair +edges(const RenderGraph& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + RenderGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + RenderGraph::edge_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline RenderGraph::edges_size_type +num_edges(const RenderGraph& g) noexcept { // NOLINT + RenderGraph::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 +add_edge( // NOLINT + RenderGraph::vertex_descriptor u, + RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& outEdgeList = g.getOutEdgeList(u); + outEdgeList.emplace_back(v); + + auto& inEdgeList = g.getInEdgeList(v); + inEdgeList.emplace_back(u); + + return std::make_pair(RenderGraph::edge_descriptor(u, v), true); +} + +inline void remove_edge(RenderGraph::vertex_descriptor u, RenderGraph::vertex_descriptor v, RenderGraph& g) noexcept { // NOLINT + // remove out-edges + auto& outEdgeList = g.getOutEdgeList(u); + // eraseFromIncidenceList + impl::sequenceEraseIf(outEdgeList, [v](const auto& e) { + return e.get_target() == v; + }); + + // remove reciprocal (bidirectional) in-edges + auto& inEdgeList = g.getInEdgeList(v); + // eraseFromIncidenceList + impl::sequenceEraseIf(inEdgeList, [u](const auto& e) { + return e.get_target() == u; + }); +} + +inline void remove_edge(RenderGraph::edge_descriptor e, RenderGraph& g) noexcept { // NOLINT + // remove_edge need rewrite + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + impl::removeIncidenceEdge(e, outEdgeList); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); +} + +inline void remove_edge(RenderGraph::out_edge_iterator iter, RenderGraph& g) noexcept { // NOLINT + auto e = *iter; + auto& outEdgeList = g.getOutEdgeList(source(e, g)); + auto& inEdgeList = g.getInEdgeList(target(e, g)); + impl::removeIncidenceEdge(e, inEdgeList); + outEdgeList.erase(iter.base()); +} + +template +inline void remove_out_edge_if(RenderGraph::vertex_descriptor u, Predicate&& pred, RenderGraph& g) noexcept { // NOLINT + for (auto pair = out_edges(u, g); pair.first != pair.second; ++pair.first) { + auto& outIter = pair.first; + auto& outEnd = pair.second; + if (pred(*outIter)) { + auto& inEdgeList = g.getInEdgeList(target(*outIter, g)); + auto e = *outIter; + impl::removeIncidenceEdge(e, inEdgeList); + } + } + auto pair = out_edges(u, g); + auto& first = pair.first; + auto& last = pair.second; + auto& outEdgeList = g.getOutEdgeList(u); + impl::sequenceRemoveIncidenceEdgeIf(first, last, outEdgeList, std::forward(pred)); +} + +template +inline void remove_in_edge_if(RenderGraph::vertex_descriptor v, Predicate&& pred, RenderGraph& g) noexcept { // NOLINT + for (auto pair = in_edges(v, g); pair.first != pair.second; ++pair.first) { + auto& inIter = pair.first; + auto& inEnd = pair.second; + if (pred(*inIter)) { + auto& outEdgeList = g.getOutEdgeList(source(*inIter, g)); + auto e = *inIter; + impl::removeIncidenceEdge(e, outEdgeList); + } + } + auto pair = in_edges(v, g); + auto& first = pair.first; + auto& last = pair.second; + auto& inEdgeList = g.getInEdgeList(v); + impl::sequenceRemoveIncidenceEdgeIf(first, last, inEdgeList, std::forward(pred)); +} + +template +inline void remove_edge_if(Predicate&& pred, RenderGraph& g) noexcept { // NOLINT + auto pair = edges(g); + auto& ei = pair.first; + auto& eiEnd = pair.second; + for (auto next = ei; ei != eiEnd; ei = next) { + ++next; + if (pred(*ei)) { + remove_edge(*ei, g); + } + } +} + +// AddressableGraph +inline RenderGraph::vertex_descriptor +parent(const RenderGraph::ownership_descriptor& e, const RenderGraph& /*g*/) noexcept { + return e.source; +} + +inline RenderGraph::vertex_descriptor +child(const RenderGraph::ownership_descriptor& e, const RenderGraph& /*g*/) noexcept { + return e.target; +} + +inline std::pair +children(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + return std::make_pair( + RenderGraph::children_iterator(const_cast(g).getChildrenList(u).begin(), u), + RenderGraph::children_iterator(const_cast(g).getChildrenList(u).end(), u)); +} + +inline RenderGraph::children_size_type +num_children(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getChildrenList(u).size()); +} + +inline std::pair +ownership(RenderGraph::vertex_descriptor u, RenderGraph::vertex_descriptor v, RenderGraph& g) noexcept { + auto& outEdgeList = g.getChildrenList(u); + auto iter = std::find(outEdgeList.begin(), outEdgeList.end(), RenderGraph::out_edge_type(v)); + bool hasEdge = (iter != outEdgeList.end()); + return {RenderGraph::ownership_descriptor(u, v), hasEdge}; +} + +inline std::pair +parents(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + return std::make_pair( + RenderGraph::parent_iterator(const_cast(g).getParentsList(u).begin(), u), + RenderGraph::parent_iterator(const_cast(g).getParentsList(u).end(), u)); +} + +inline RenderGraph::children_size_type +num_parents(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + return gsl::narrow_cast(g.getParentsList(u).size()); +} + +inline RenderGraph::vertex_descriptor +parent(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + auto r = parents(u, g); + if (r.first == r.second) { + return RenderGraph::null_vertex(); + } + return parent(*r.first, g); +} + +inline bool +ancestor(RenderGraph::vertex_descriptor u, RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { + CC_EXPECTS(u != v); + bool isAncestor = false; + auto r = parents(v, g); + while (r.first != r.second) { + v = parent(*r.first, g); + if (u == v) { + isAncestor = true; + break; + } + r = parents(v, g); + } + return isAncestor; +} + +inline std::pair +ownerships(const RenderGraph& g0) noexcept { + auto& g = const_cast(g0); + return std::make_pair( + RenderGraph::ownership_iterator(g.getVertexList().begin(), g.getVertexList().begin(), g.getVertexList().end(), g), + RenderGraph::ownership_iterator(g.getVertexList().begin(), g.getVertexList().end(), g.getVertexList().end(), g)); +} + +inline RenderGraph::ownerships_size_type +num_ownerships(const RenderGraph& g) noexcept { // NOLINT + RenderGraph::ownerships_size_type numEdges = 0; + auto range = vertices(g); + for (auto iter = range.first; iter != range.second; ++iter) { + numEdges += num_children(*iter, g); + } + return numEdges; +} + +} // namespace render + +} // namespace cc + +namespace boost { + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Name +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + cc::render::ResourceDesc, + const cc::render::ResourceDesc&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + cc::render::ResourceDesc, + cc::render::ResourceDesc&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::ResourceDesc::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + T, + T&, + T cc::render::ResourceDesc::*>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + cc::render::ResourceTraits, + const cc::render::ResourceTraits&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + cc::render::ResourceTraits, + cc::render::ResourceTraits&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::ResourceGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::ResourceTraits::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::ResourceGraph, + container::pmr::vector, + T, + T&, + T cc::render::ResourceTraits::*>; +}; + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::SubpassGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::SubpassGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Name +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::SubpassGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::SubpassGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::SubpassGraph, + const container::pmr::vector, + cc::render::RasterSubpass, + const cc::render::RasterSubpass&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::SubpassGraph, + container::pmr::vector, + cc::render::RasterSubpass, + cc::render::RasterSubpass&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::SubpassGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::RasterSubpass::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::SubpassGraph, + container::pmr::vector, + T, + T&, + T cc::render::RasterSubpass::*>; +}; + +// Vertex Index +template <> +struct property_map { + using const_type = identity_property_map; + using type = identity_property_map; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::RenderGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::RenderGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Name +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::RenderGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::RenderGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + const cc::render::RenderGraph, + const container::pmr::vector, + boost::string_view, + const cc::PmrString&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + read_write_property_map_tag, + cc::render::RenderGraph, + container::pmr::vector, + boost::string_view, + cc::PmrString&>; +}; + +// Vertex Component +template <> +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + const cc::render::RenderGraph, + const container::pmr::vector, + cc::render::RenderData, + const cc::render::RenderData&>; + using type = cc::render::impl::VectorVertexComponentPropertyMap< + lvalue_property_map_tag, + cc::render::RenderGraph, + container::pmr::vector, + cc::render::RenderData, + cc::render::RenderData&>; +}; + +// Vertex ComponentMember +template +struct property_map { + using const_type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + const cc::render::RenderGraph, + const container::pmr::vector, + T, + const T&, + T cc::render::RenderData::*>; + using type = cc::render::impl::VectorVertexComponentMemberPropertyMap< + lvalue_property_map_tag, + cc::render::RenderGraph, + container::pmr::vector, + T, + T&, + T cc::render::RenderData::*>; +}; + +} // namespace boost + +namespace cc { + +namespace render { + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const ResourceGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, ResourceGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const ResourceGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(ResourceGraph::NameTag /*tag*/, const ResourceGraph& g) noexcept { + return {g.names}; +} + +inline typename boost::property_map::type +get(ResourceGraph::NameTag /*tag*/, ResourceGraph& g) noexcept { + return {g.names}; +} + +// Vertex Name +inline boost::property_map::const_type +get(boost::vertex_name_t /*tag*/, const ResourceGraph& g) noexcept { + return {g.names}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(ResourceGraph::DescTag /*tag*/, const ResourceGraph& g) noexcept { + return {g.descs}; +} + +inline typename boost::property_map::type +get(ResourceGraph::DescTag /*tag*/, ResourceGraph& g) noexcept { + return {g.descs}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T ResourceDesc::*memberPointer, const ResourceGraph& g) noexcept { + return {g.descs, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T ResourceDesc::*memberPointer, ResourceGraph& g) noexcept { + return {g.descs, memberPointer}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(ResourceGraph::TraitsTag /*tag*/, const ResourceGraph& g) noexcept { + return {g.traits}; +} + +inline typename boost::property_map::type +get(ResourceGraph::TraitsTag /*tag*/, ResourceGraph& g) noexcept { + return {g.traits}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T ResourceTraits::*memberPointer, const ResourceGraph& g) noexcept { + return {g.traits, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T ResourceTraits::*memberPointer, ResourceGraph& g) noexcept { + return {g.traits, memberPointer}; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const ResourceGraph& g, ResourceGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, ResourceGraph& g, ResourceGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, ResourceGraph& g, + ResourceGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// UuidGraph +inline ResourceGraph::vertex_descriptor +vertex(const PmrString& key, const ResourceGraph& g) { + return g.valueIndex.at(key); +} + +template +inline ResourceGraph::vertex_descriptor +vertex(const KeyLike& key, const ResourceGraph& g) { + const auto& index = g.valueIndex; + auto iter = index.find(key); + if (iter == index.end()) { + throw std::out_of_range("at(key, ResourceGraph) out of range"); + } + return iter->second; +} + +template +inline ResourceGraph::vertex_descriptor +find_vertex(const KeyLike& key, const ResourceGraph& g) noexcept { // NOLINT + const auto& index = g.valueIndex; + auto iter = index.find(key); + if (iter == index.end()) { + return ResourceGraph::null_vertex(); + } + return iter->second; +} + +inline bool +contains(const PmrString& key, const ResourceGraph& g) noexcept { + auto iter = g.valueIndex.find(key); + return iter != g.valueIndex.end(); +} + +template +inline bool +contains(const KeyLike& key, const ResourceGraph& g) noexcept { + auto iter = g.valueIndex.find(key); + return iter != g.valueIndex.end(); +} + +// MutableGraph(Vertex) +inline ResourceGraph::vertex_descriptor +add_vertex(ResourceGraph& g, PmrString&& name) { // NOLINT + return add_vertex( + std::piecewise_construct, + std::forward_as_tuple(std::move(name)), // names + std::forward_as_tuple(), // descs + std::forward_as_tuple(), // traits + g); +} + +inline ResourceGraph::vertex_descriptor +add_vertex(ResourceGraph& g, const char* name) { // NOLINT + return add_vertex( + std::piecewise_construct, + std::forward_as_tuple(name), // names + std::forward_as_tuple(), // descs + std::forward_as_tuple(), // traits + g); +} + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const SubpassGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, SubpassGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const SubpassGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(SubpassGraph::NameTag /*tag*/, const SubpassGraph& g) noexcept { + return {g.names}; +} + +inline typename boost::property_map::type +get(SubpassGraph::NameTag /*tag*/, SubpassGraph& g) noexcept { + return {g.names}; +} + +// Vertex Name +inline boost::property_map::const_type +get(boost::vertex_name_t /*tag*/, const SubpassGraph& g) noexcept { + return {g.names}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(SubpassGraph::SubpassTag /*tag*/, const SubpassGraph& g) noexcept { + return {g.subpasses}; +} + +inline typename boost::property_map::type +get(SubpassGraph::SubpassTag /*tag*/, SubpassGraph& g) noexcept { + return {g.subpasses}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T RasterSubpass::*memberPointer, const SubpassGraph& g) noexcept { + return {g.subpasses, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T RasterSubpass::*memberPointer, SubpassGraph& g) noexcept { + return {g.subpasses, memberPointer}; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, SubpassGraph& g, SubpassGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, SubpassGraph& g, + SubpassGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// MutableGraph(Vertex) +inline SubpassGraph::vertex_descriptor +add_vertex(SubpassGraph& g, PmrString&& name) { // NOLINT + return add_vertex( + 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 add_vertex( + std::piecewise_construct, + std::forward_as_tuple(name), // names + std::forward_as_tuple(), // subpasses + g); +} + +// Vertex Index +inline boost::property_map::const_type +get(boost::vertex_index_t /*tag*/, const RenderGraph& /*g*/) noexcept { + return {}; +} + +inline boost::property_map::type +get(boost::vertex_index_t /*tag*/, RenderGraph& /*g*/) noexcept { + return {}; +} + +inline impl::ColorMap +get(boost::container::pmr::vector& colors, const RenderGraph& /*g*/) noexcept { + return {colors}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderGraph::NameTag /*tag*/, const RenderGraph& g) noexcept { + return {g.names}; +} + +inline typename boost::property_map::type +get(RenderGraph::NameTag /*tag*/, RenderGraph& g) noexcept { + return {g.names}; +} + +// Vertex Name +inline boost::property_map::const_type +get(boost::vertex_name_t /*tag*/, const RenderGraph& g) noexcept { + return {g.names}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderGraph::LayoutTag /*tag*/, const RenderGraph& g) noexcept { + return {g.layoutNodes}; +} + +inline typename boost::property_map::type +get(RenderGraph::LayoutTag /*tag*/, RenderGraph& g) noexcept { + return {g.layoutNodes}; +} + +// Vertex Component +inline typename boost::property_map::const_type +get(RenderGraph::DataTag /*tag*/, const RenderGraph& g) noexcept { + return {g.data}; +} + +inline typename boost::property_map::type +get(RenderGraph::DataTag /*tag*/, RenderGraph& g) noexcept { + return {g.data}; +} + +// Vertex ComponentMember +template +inline typename boost::property_map::const_type +get(T RenderData::*memberPointer, const RenderGraph& g) noexcept { + return {g.data, memberPointer}; +} + +template +inline typename boost::property_map::type +get(T RenderData::*memberPointer, RenderGraph& g) noexcept { + return {g.data, memberPointer}; +} + +// PolymorphicGraph +inline RenderGraph::vertices_size_type +value_id(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { // NOLINT + using vertex_descriptor = RenderGraph::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }, + [](const impl::ValueHandle& h) { + return h.value; + }), + g.vertices[u].handle); +} + +inline RenderGraph::vertex_tag_type +tag(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + using vertex_descriptor = RenderGraph::vertex_descriptor; + return cc::visit( + overload( + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{RasterTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{ComputeTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{CopyTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{MoveTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{PresentTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{RaytraceTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{QueueTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{SceneTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{BlitTag{}}; + }, + [](const impl::ValueHandle&) { + return RenderGraph::vertex_tag_type{DispatchTag{}}; + }), + g.vertices[u].handle); +} + +inline RenderGraph::vertex_value_type +value(RenderGraph::vertex_descriptor u, RenderGraph& g) noexcept { + using vertex_descriptor = RenderGraph::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.rasterPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.computePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.copyPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.movePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.presentPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.raytracePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.renderQueues[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.scenes[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.blits[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_value_type{&g.dispatches[h.value]}; + }), + g.vertices[u].handle); +} + +inline RenderGraph::vertex_const_value_type +value(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { + using vertex_descriptor = RenderGraph::vertex_descriptor; + return cc::visit( + overload( + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.rasterPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.computePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.copyPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.movePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.presentPasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.raytracePasses[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.renderQueues[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.scenes[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.blits[h.value]}; + }, + [&](const impl::ValueHandle& h) { + return RenderGraph::vertex_const_value_type{&g.dispatches[h.value]}; + }), + g.vertices[u].handle); +} + +template +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept; // NOLINT + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_tag(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept; // NOLINT + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template <> +inline bool +holds_alternative(RenderGraph::vertex_descriptor v, const RenderGraph& g) noexcept { // NOLINT + return boost::variant2::holds_alternative< + impl::ValueHandle>( + g.vertices[v].handle); +} + +template +inline ValueT& +get(RenderGraph::vertex_descriptor /*v*/, RenderGraph& /*g*/); + +template <> +inline RasterPass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.rasterPasses[handle.value]; +} + +template <> +inline ComputePass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.computePasses[handle.value]; +} + +template <> +inline CopyPass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.copyPasses[handle.value]; +} + +template <> +inline MovePass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.movePasses[handle.value]; +} + +template <> +inline PresentPass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.presentPasses[handle.value]; +} + +template <> +inline RaytracePass& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.raytracePasses[handle.value]; +} + +template <> +inline RenderQueue& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.renderQueues[handle.value]; +} + +template <> +inline SceneData& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.scenes[handle.value]; +} + +template <> +inline Blit& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.blits[handle.value]; +} + +template <> +inline Dispatch& +get(RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.dispatches[handle.value]; +} + +template +inline const ValueT& +get(RenderGraph::vertex_descriptor /*v*/, const RenderGraph& /*g*/); + +template <> +inline const RasterPass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.rasterPasses[handle.value]; +} + +template <> +inline const ComputePass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.computePasses[handle.value]; +} + +template <> +inline const CopyPass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.copyPasses[handle.value]; +} + +template <> +inline const MovePass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.movePasses[handle.value]; +} + +template <> +inline const PresentPass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.presentPasses[handle.value]; +} + +template <> +inline const RaytracePass& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.raytracePasses[handle.value]; +} + +template <> +inline const RenderQueue& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.renderQueues[handle.value]; +} + +template <> +inline const SceneData& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.scenes[handle.value]; +} + +template <> +inline const Blit& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.blits[handle.value]; +} + +template <> +inline const Dispatch& +get(RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.dispatches[handle.value]; +} + +inline RasterPass& +get(RasterTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.rasterPasses[handle.value]; +} + +inline ComputePass& +get(ComputeTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.computePasses[handle.value]; +} + +inline CopyPass& +get(CopyTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.copyPasses[handle.value]; +} + +inline MovePass& +get(MoveTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.movePasses[handle.value]; +} + +inline PresentPass& +get(PresentTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.presentPasses[handle.value]; +} + +inline RaytracePass& +get(RaytraceTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.raytracePasses[handle.value]; +} + +inline RenderQueue& +get(QueueTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.renderQueues[handle.value]; +} + +inline SceneData& +get(SceneTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.scenes[handle.value]; +} + +inline Blit& +get(BlitTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.blits[handle.value]; +} + +inline Dispatch& +get(DispatchTag /*tag*/, RenderGraph::vertex_descriptor v, RenderGraph& g) { + auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.dispatches[handle.value]; +} + +inline const RasterPass& +get(RasterTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.rasterPasses[handle.value]; +} + +inline const ComputePass& +get(ComputeTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.computePasses[handle.value]; +} + +inline const CopyPass& +get(CopyTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.copyPasses[handle.value]; +} + +inline const MovePass& +get(MoveTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.movePasses[handle.value]; +} + +inline const PresentPass& +get(PresentTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.presentPasses[handle.value]; +} + +inline const RaytracePass& +get(RaytraceTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.raytracePasses[handle.value]; +} + +inline const RenderQueue& +get(QueueTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.renderQueues[handle.value]; +} + +inline const SceneData& +get(SceneTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.scenes[handle.value]; +} + +inline const Blit& +get(BlitTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.blits[handle.value]; +} + +inline const Dispatch& +get(DispatchTag /*tag*/, RenderGraph::vertex_descriptor v, const RenderGraph& g) { + const auto& handle = boost::variant2::get< + impl::ValueHandle>( + g.vertices[v].handle); + return g.dispatches[handle.value]; +} + +template +inline ValueT* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept; // NOLINT + +template <> +inline RasterPass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + RasterPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.rasterPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline ComputePass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + ComputePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.computePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline CopyPass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + CopyPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.copyPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline MovePass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + MovePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.movePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline PresentPass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + PresentPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.presentPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline RaytracePass* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + RaytracePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.raytracePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline RenderQueue* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + RenderQueue* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.renderQueues[pHandle->value]; + } + return ptr; +} + +template <> +inline SceneData* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + SceneData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.scenes[pHandle->value]; + } + return ptr; +} + +template <> +inline Blit* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + Blit* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.blits[pHandle->value]; + } + return ptr; +} + +template <> +inline Dispatch* +get_if(RenderGraph::vertex_descriptor v, RenderGraph* pGraph) noexcept { // NOLINT + Dispatch* ptr = nullptr; + if (!pGraph) { + return ptr; + } + auto& g = *pGraph; + auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.dispatches[pHandle->value]; + } + return ptr; +} + +template +inline const ValueT* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept; // NOLINT + +template <> +inline const RasterPass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const RasterPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.rasterPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const ComputePass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const ComputePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.computePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const CopyPass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const CopyPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.copyPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const MovePass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const MovePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.movePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const PresentPass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const PresentPass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.presentPasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const RaytracePass* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const RaytracePass* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.raytracePasses[pHandle->value]; + } + return ptr; +} + +template <> +inline const RenderQueue* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const RenderQueue* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.renderQueues[pHandle->value]; + } + return ptr; +} + +template <> +inline const SceneData* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const SceneData* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.scenes[pHandle->value]; + } + return ptr; +} + +template <> +inline const Blit* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const Blit* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.blits[pHandle->value]; + } + return ptr; +} + +template <> +inline const Dispatch* +get_if(RenderGraph::vertex_descriptor v, const RenderGraph* pGraph) noexcept { // NOLINT + const Dispatch* ptr = nullptr; + if (!pGraph) { + return ptr; + } + const auto& g = *pGraph; + const auto* pHandle = boost::variant2::get_if< + impl::ValueHandle>( + &g.vertices[v].handle); + if (pHandle) { + ptr = &g.dispatches[pHandle->value]; + } + return ptr; +} + +// Vertex Constant Getter +template +inline decltype(auto) +get(Tag tag, const RenderGraph& g, RenderGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Mutable Getter +template +inline decltype(auto) +get(Tag tag, RenderGraph& g, RenderGraph::vertex_descriptor v) noexcept { + return get(get(tag, g), v); +} + +// Vertex Setter +template +inline void put( + Tag tag, RenderGraph& g, + RenderGraph::vertex_descriptor v, + Args&&... args) { + put(get(tag, g), v, std::forward(args)...); +} + +// MutableGraph(Vertex) +template +inline RenderGraph::vertex_descriptor +add_vertex(RenderGraph& g, Tag t, PmrString&& name) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(std::move(name)), // names + std::forward_as_tuple(), // layoutNodes + std::forward_as_tuple(), // data + std::forward_as_tuple(), // PolymorphicType + g); +} + +template +inline RenderGraph::vertex_descriptor +add_vertex(RenderGraph& g, Tag t, const char* name) { // NOLINT + return add_vertex( + t, + std::forward_as_tuple(name), // names + std::forward_as_tuple(), // layoutNodes + std::forward_as_tuple(), // data + std::forward_as_tuple(), // PolymorphicType + g); +} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphJsb.cpp b/native/cocos/renderer/pipeline/custom/RenderGraphJsb.cpp new file mode 100644 index 0000000000..b1628fd247 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphJsb.cpp @@ -0,0 +1,312 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "cocos/bindings/auto/jsb_gfx_auto.h" +#include "cocos/renderer/pipeline/custom/JsbConversion.h" +#include "cocos/renderer/pipeline/custom/RenderGraphJsb.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" + +bool nativevalue_to_se(const cc::render::RasterView &from, se::Value &to, se::Object *ctx) { // NOLINT + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp; + + nativevalue_to_se(from.slotName, tmp, ctx); + obj->setProperty("slotName", tmp); + + nativevalue_to_se(from.accessType, tmp, ctx); + obj->setProperty("accessType", tmp); + + nativevalue_to_se(from.attachmentType, tmp, ctx); + obj->setProperty("attachmentType", tmp); + + nativevalue_to_se(from.loadOp, tmp, ctx); + obj->setProperty("loadOp", tmp); + + nativevalue_to_se(from.storeOp, tmp, ctx); + obj->setProperty("storeOp", tmp); + + nativevalue_to_se(from.clearFlags, tmp, ctx); + obj->setProperty("clearFlags", tmp); + + nativevalue_to_se(from.clearColor, tmp, ctx); + obj->setProperty("clearColor", tmp); + + to.setObject(obj); + return true; +} + +bool nativevalue_to_se(const cc::render::ComputeView &from, se::Value &to, se::Object *ctx) { // NOLINT + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp; + + nativevalue_to_se(from.name, tmp, ctx); + obj->setProperty("name", tmp); + + nativevalue_to_se(from.accessType, tmp, ctx); + obj->setProperty("accessType", tmp); + + nativevalue_to_se(from.clearFlags, tmp, ctx); + obj->setProperty("clearFlags", tmp); + + nativevalue_to_se(from.clearColor, tmp, ctx); + obj->setProperty("clearColor", tmp); + + nativevalue_to_se(from.clearValueType, tmp, ctx); + obj->setProperty("clearValueType", tmp); + + to.setObject(obj); + return true; +} + +bool nativevalue_to_se(const cc::render::CopyPair &from, se::Value &to, se::Object *ctx) { // NOLINT + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp; + + nativevalue_to_se(from.source, tmp, ctx); + obj->setProperty("source", tmp); + + nativevalue_to_se(from.target, tmp, ctx); + obj->setProperty("target", tmp); + + nativevalue_to_se(from.mipLevels, tmp, ctx); + obj->setProperty("mipLevels", tmp); + + nativevalue_to_se(from.numSlices, tmp, ctx); + obj->setProperty("numSlices", tmp); + + nativevalue_to_se(from.sourceMostDetailedMip, tmp, ctx); + obj->setProperty("sourceMostDetailedMip", tmp); + + nativevalue_to_se(from.sourceFirstSlice, tmp, ctx); + obj->setProperty("sourceFirstSlice", tmp); + + nativevalue_to_se(from.sourcePlaneSlice, tmp, ctx); + obj->setProperty("sourcePlaneSlice", tmp); + + nativevalue_to_se(from.targetMostDetailedMip, tmp, ctx); + obj->setProperty("targetMostDetailedMip", tmp); + + nativevalue_to_se(from.targetFirstSlice, tmp, ctx); + obj->setProperty("targetFirstSlice", tmp); + + nativevalue_to_se(from.targetPlaneSlice, tmp, ctx); + obj->setProperty("targetPlaneSlice", tmp); + + to.setObject(obj); + return true; +} + +bool nativevalue_to_se(const cc::render::MovePair &from, se::Value &to, se::Object *ctx) { // NOLINT + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp; + + nativevalue_to_se(from.source, tmp, ctx); + obj->setProperty("source", tmp); + + nativevalue_to_se(from.target, tmp, ctx); + obj->setProperty("target", tmp); + + nativevalue_to_se(from.mipLevels, tmp, ctx); + obj->setProperty("mipLevels", tmp); + + nativevalue_to_se(from.numSlices, tmp, ctx); + obj->setProperty("numSlices", tmp); + + nativevalue_to_se(from.targetMostDetailedMip, tmp, ctx); + obj->setProperty("targetMostDetailedMip", tmp); + + nativevalue_to_se(from.targetFirstSlice, tmp, ctx); + obj->setProperty("targetFirstSlice", tmp); + + nativevalue_to_se(from.targetPlaneSlice, tmp, ctx); + obj->setProperty("targetPlaneSlice", tmp); + + to.setObject(obj); + return true; +} + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::RasterView *to, se::Object *ctx) { // NOLINT + SE_PRECONDITION2(from.isObject(), false, " Convert parameter to RasterView failed !"); + + auto *obj = const_cast(from.toObject()); + bool ok = true; + se::Value field; + obj->getProperty("slotName", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->slotName), ctx); + } + obj->getProperty("accessType", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->accessType), ctx); + } + obj->getProperty("attachmentType", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->attachmentType), ctx); + } + obj->getProperty("loadOp", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->loadOp), ctx); + } + obj->getProperty("storeOp", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->storeOp), ctx); + } + obj->getProperty("clearFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->clearFlags), ctx); + } + obj->getProperty("clearColor", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->clearColor), ctx); + } + return ok; +} + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::ComputeView *to, se::Object *ctx) { // NOLINT + SE_PRECONDITION2(from.isObject(), false, " Convert parameter to ComputeView failed !"); + + auto *obj = const_cast(from.toObject()); + bool ok = true; + se::Value field; + obj->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + obj->getProperty("accessType", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->accessType), ctx); + } + obj->getProperty("clearFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->clearFlags), ctx); + } + obj->getProperty("clearColor", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->clearColor), ctx); + } + obj->getProperty("clearValueType", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->clearValueType), ctx); + } + return ok; +} + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::CopyPair *to, se::Object *ctx) { // NOLINT + SE_PRECONDITION2(from.isObject(), false, " Convert parameter to CopyPair failed !"); + + auto *obj = const_cast(from.toObject()); + bool ok = true; + se::Value field; + obj->getProperty("source", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->source), ctx); + } + obj->getProperty("target", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->target), ctx); + } + obj->getProperty("mipLevels", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mipLevels), ctx); + } + obj->getProperty("numSlices", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->numSlices), ctx); + } + obj->getProperty("sourceMostDetailedMip", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->sourceMostDetailedMip), ctx); + } + obj->getProperty("sourceFirstSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->sourceFirstSlice), ctx); + } + obj->getProperty("sourcePlaneSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->sourcePlaneSlice), ctx); + } + obj->getProperty("targetMostDetailedMip", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetMostDetailedMip), ctx); + } + obj->getProperty("targetFirstSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetFirstSlice), ctx); + } + obj->getProperty("targetPlaneSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetPlaneSlice), ctx); + } + return ok; +} + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::MovePair *to, se::Object *ctx) { // NOLINT + SE_PRECONDITION2(from.isObject(), false, " Convert parameter to MovePair failed !"); + + auto *obj = const_cast(from.toObject()); + bool ok = true; + se::Value field; + obj->getProperty("source", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->source), ctx); + } + obj->getProperty("target", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->target), ctx); + } + obj->getProperty("mipLevels", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mipLevels), ctx); + } + obj->getProperty("numSlices", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->numSlices), ctx); + } + obj->getProperty("targetMostDetailedMip", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetMostDetailedMip), ctx); + } + obj->getProperty("targetFirstSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetFirstSlice), ctx); + } + obj->getProperty("targetPlaneSlice", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetPlaneSlice), ctx); + } + return ok; +} + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphJsb.h b/native/cocos/renderer/pipeline/custom/RenderGraphJsb.h new file mode 100644 index 0000000000..6aeb8715d9 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphJsb.h @@ -0,0 +1,58 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/renderer/pipeline/custom/RenderCommonJsb.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" + +bool nativevalue_to_se(const cc::render::RasterView &from, se::Value &to, se::Object *ctx); // NOLINT + +bool nativevalue_to_se(const cc::render::ComputeView &from, se::Value &to, se::Object *ctx); // NOLINT + +bool nativevalue_to_se(const cc::render::CopyPair &from, se::Value &to, se::Object *ctx); // NOLINT + +bool nativevalue_to_se(const cc::render::MovePair &from, se::Value &to, se::Object *ctx); // NOLINT + +// if function overload is used, android build fails +template <> +bool sevalue_to_native(const se::Value &from, cc::render::RasterView *to, se::Object *ctx); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::ComputeView *to, se::Object *ctx); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::CopyPair *to, se::Object *ctx); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &from, cc::render::MovePair *to, se::Object *ctx); // NOLINT + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphNames.h b/native/cocos/renderer/pipeline/custom/RenderGraphNames.h new file mode 100644 index 0000000000..59941da595 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphNames.h @@ -0,0 +1,102 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonNames.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" + +namespace cc { + +namespace render { + +inline const char* getName(TextureLayout e) noexcept { + switch (e) { + case TextureLayout::UNKNOWN: return "UNKNOWN"; + case TextureLayout::ROW_MAJOR: return "ROW_MAJOR"; + case TextureLayout::UNDEFINED_SWIZZLE: return "UNDEFINED_SWIZZLE"; + case TextureLayout::STANDARD_SWIZZLE: return "STANDARD_SWIZZLE"; + } + return ""; +} +inline const char* getName(const ResourceDesc& /*v*/) noexcept { return "ResourceDesc"; } +inline const char* getName(const ResourceTraits& /*v*/) noexcept { return "ResourceTraits"; } +inline const char* getName(const ResourceGraph& /*v*/) noexcept { return "ResourceGraph"; } +inline const char* getName(AttachmentType e) noexcept { + switch (e) { + case AttachmentType::RENDER_TARGET: return "RENDER_TARGET"; + case AttachmentType::DEPTH_STENCIL: return "DEPTH_STENCIL"; + } + return ""; +} +inline const char* getName(AccessType e) noexcept { + switch (e) { + case AccessType::READ: return "READ"; + case AccessType::READ_WRITE: return "READ_WRITE"; + case AccessType::WRITE: return "WRITE"; + } + return ""; +} +inline const char* getName(const RasterView& /*v*/) noexcept { return "RasterView"; } +inline const char* getName(ClearValueType e) noexcept { + switch (e) { + case ClearValueType::FLOAT_TYPE: return "FLOAT_TYPE"; + case ClearValueType::INT_TYPE: return "INT_TYPE"; + } + return ""; +} +inline const char* getName(const ComputeView& /*v*/) noexcept { return "ComputeView"; } +inline const char* getName(const RasterSubpass& /*v*/) noexcept { return "RasterSubpass"; } +inline const char* getName(const SubpassGraph& /*v*/) noexcept { return "SubpassGraph"; } +inline const char* getName(const RasterPass& /*v*/) noexcept { return "RasterPass"; } +inline const char* getName(const ComputePass& /*v*/) noexcept { return "ComputePass"; } +inline const char* getName(const CopyPair& /*v*/) noexcept { return "CopyPair"; } +inline const char* getName(const CopyPass& /*v*/) noexcept { return "CopyPass"; } +inline const char* getName(const MovePair& /*v*/) noexcept { return "MovePair"; } +inline const char* getName(const MovePass& /*v*/) noexcept { return "MovePass"; } +inline const char* getName(const RaytracePass& /*v*/) noexcept { return "RaytracePass"; } +inline const char* getName(const QueueTag& /*v*/) noexcept { return "Queue"; } +inline const char* getName(const SceneTag& /*v*/) noexcept { return "Scene"; } +inline const char* getName(const DispatchTag& /*v*/) noexcept { return "Dispatch"; } +inline const char* getName(const BlitTag& /*v*/) noexcept { return "Blit"; } +inline const char* getName(const PresentTag& /*v*/) noexcept { return "Present"; } +inline const char* getName(const RenderQueue& /*v*/) noexcept { return "RenderQueue"; } +inline const char* getName(const SceneData& /*v*/) noexcept { return "SceneData"; } +inline const char* getName(const Dispatch& /*v*/) noexcept { return "Dispatch"; } +inline const char* getName(const Blit& /*v*/) noexcept { return "Blit"; } +inline const char* getName(const PresentPass& /*v*/) noexcept { return "PresentPass"; } +inline const char* getName(const RenderData& /*v*/) noexcept { return "RenderData"; } +inline const char* getName(const RenderGraph& /*v*/) noexcept { return "RenderGraph"; } + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphReflection.cpp b/native/cocos/renderer/pipeline/custom/RenderGraphReflection.cpp new file mode 100644 index 0000000000..a5942f291e --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphReflection.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderGraphReflection.h" +#include "RenderGraphTypes.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphReflection.h b/native/cocos/renderer/pipeline/custom/RenderGraphReflection.h new file mode 100644 index 0000000000..a945a96460 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphReflection.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/renderer/pipeline/custom/RenderCommonReflection.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp new file mode 100644 index 0000000000..f4f06fb63f --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp @@ -0,0 +1,450 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderGraphTypes.h" + +namespace cc { + +namespace render { + +ResourceGraph::ResourceGraph(const allocator_type& alloc) noexcept +: vertices(alloc), + names(alloc), + descs(alloc), + traits(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), + valueIndex(std::move(rhs.valueIndex), alloc) {} + +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), + valueIndex(rhs.valueIndex, alloc) {} + +// ContinuousContainer +void ResourceGraph::reserve(vertices_size_type sz) { + vertices.reserve(sz); + names.reserve(sz); + descs.reserve(sz); + traits.reserve(sz); +} + +ResourceGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +ResourceGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc) {} + +ResourceGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc) {} + +RasterView::RasterView(const allocator_type& alloc) noexcept +: slotName(alloc) {} + +RasterView::RasterView(PmrString slotNameIn, AccessType accessTypeIn, AttachmentType attachmentTypeIn, gfx::LoadOp loadOpIn, gfx::StoreOp storeOpIn, gfx::ClearFlagBit clearFlagsIn, gfx::Color clearColorIn, const allocator_type& alloc) noexcept +: slotName(std::move(slotNameIn), alloc), + accessType(accessTypeIn), + attachmentType(attachmentTypeIn), + loadOp(loadOpIn), + storeOp(storeOpIn), + clearFlags(clearFlagsIn), + clearColor(clearColorIn) {} + +RasterView::RasterView(RasterView&& rhs, const allocator_type& alloc) +: slotName(std::move(rhs.slotName), alloc), + accessType(rhs.accessType), + attachmentType(rhs.attachmentType), + loadOp(rhs.loadOp), + storeOp(rhs.storeOp), + clearFlags(rhs.clearFlags), + clearColor(rhs.clearColor) {} + +RasterView::RasterView(RasterView const& rhs, const allocator_type& alloc) +: slotName(rhs.slotName, alloc), + accessType(rhs.accessType), + attachmentType(rhs.attachmentType), + loadOp(rhs.loadOp), + storeOp(rhs.storeOp), + clearFlags(rhs.clearFlags), + clearColor(rhs.clearColor) {} + +ComputeView::ComputeView(const allocator_type& alloc) noexcept +: name(alloc) {} + +ComputeView::ComputeView(ComputeView&& rhs, const allocator_type& alloc) +: name(std::move(rhs.name), alloc), + accessType(rhs.accessType), + clearFlags(rhs.clearFlags), + clearColor(rhs.clearColor), + clearValueType(rhs.clearValueType) {} + +ComputeView::ComputeView(ComputeView const& rhs, const allocator_type& alloc) +: name(rhs.name, alloc), + accessType(rhs.accessType), + clearFlags(rhs.clearFlags), + clearColor(rhs.clearColor), + clearValueType(rhs.clearValueType) {} + +RasterSubpass::RasterSubpass(const allocator_type& alloc) noexcept +: rasterViews(alloc), + computeViews(alloc) {} + +RasterSubpass::RasterSubpass(RasterSubpass&& rhs, const allocator_type& alloc) +: rasterViews(std::move(rhs.rasterViews), alloc), + computeViews(std::move(rhs.computeViews), alloc) {} + +RasterSubpass::RasterSubpass(RasterSubpass const& rhs, const allocator_type& alloc) +: rasterViews(rhs.rasterViews, alloc), + computeViews(rhs.computeViews, alloc) {} + +SubpassGraph::SubpassGraph(const allocator_type& alloc) noexcept +: vertices(alloc), + names(alloc), + subpasses(alloc) {} + +SubpassGraph::SubpassGraph(SubpassGraph&& rhs, const allocator_type& alloc) +: vertices(std::move(rhs.vertices), alloc), + names(std::move(rhs.names), alloc), + subpasses(std::move(rhs.subpasses), alloc) {} + +SubpassGraph::SubpassGraph(SubpassGraph const& rhs, const allocator_type& alloc) +: vertices(rhs.vertices, alloc), + names(rhs.names, alloc), + subpasses(rhs.subpasses, alloc) {} + +// ContinuousContainer +void SubpassGraph::reserve(vertices_size_type sz) { + vertices.reserve(sz); + names.reserve(sz); + subpasses.reserve(sz); +} + +SubpassGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +SubpassGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc) {} + +SubpassGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc) {} + +RasterPass::RasterPass(const allocator_type& alloc) noexcept +: rasterViews(alloc), + computeViews(alloc), + subpassGraph(alloc) {} + +RasterPass::RasterPass(RasterPass&& rhs, const allocator_type& alloc) +: rasterViews(std::move(rhs.rasterViews), alloc), + computeViews(std::move(rhs.computeViews), alloc), + subpassGraph(std::move(rhs.subpassGraph), alloc) {} + +RasterPass::RasterPass(RasterPass const& rhs, const allocator_type& alloc) +: rasterViews(rhs.rasterViews, alloc), + computeViews(rhs.computeViews, alloc), + subpassGraph(rhs.subpassGraph, alloc) {} + +ComputePass::ComputePass(const allocator_type& alloc) noexcept +: computeViews(alloc) {} + +ComputePass::ComputePass(ComputePass&& rhs, const allocator_type& alloc) +: computeViews(std::move(rhs.computeViews), alloc) {} + +ComputePass::ComputePass(ComputePass const& rhs, const allocator_type& alloc) +: computeViews(rhs.computeViews, alloc) {} + +CopyPair::CopyPair(const allocator_type& alloc) noexcept +: source(alloc), + target(alloc) {} + +CopyPair::CopyPair(PmrString sourceIn, PmrString targetIn, uint32_t mipLevelsIn, uint32_t numSlicesIn, uint32_t sourceMostDetailedMipIn, uint32_t sourceFirstSliceIn, uint32_t sourcePlaneSliceIn, uint32_t targetMostDetailedMipIn, uint32_t targetFirstSliceIn, uint32_t targetPlaneSliceIn, const allocator_type& alloc) noexcept // NOLINT +: source(std::move(sourceIn), alloc), + target(std::move(targetIn), alloc), + mipLevels(mipLevelsIn), + numSlices(numSlicesIn), + sourceMostDetailedMip(sourceMostDetailedMipIn), + sourceFirstSlice(sourceFirstSliceIn), + sourcePlaneSlice(sourcePlaneSliceIn), + targetMostDetailedMip(targetMostDetailedMipIn), + targetFirstSlice(targetFirstSliceIn), + targetPlaneSlice(targetPlaneSliceIn) {} + +CopyPair::CopyPair(CopyPair&& rhs, const allocator_type& alloc) +: source(std::move(rhs.source), alloc), + target(std::move(rhs.target), alloc), + mipLevels(rhs.mipLevels), + numSlices(rhs.numSlices), + sourceMostDetailedMip(rhs.sourceMostDetailedMip), + sourceFirstSlice(rhs.sourceFirstSlice), + sourcePlaneSlice(rhs.sourcePlaneSlice), + targetMostDetailedMip(rhs.targetMostDetailedMip), + targetFirstSlice(rhs.targetFirstSlice), + targetPlaneSlice(rhs.targetPlaneSlice) {} + +CopyPair::CopyPair(CopyPair const& rhs, const allocator_type& alloc) +: source(rhs.source, alloc), + target(rhs.target, alloc), + mipLevels(rhs.mipLevels), + numSlices(rhs.numSlices), + sourceMostDetailedMip(rhs.sourceMostDetailedMip), + sourceFirstSlice(rhs.sourceFirstSlice), + sourcePlaneSlice(rhs.sourcePlaneSlice), + targetMostDetailedMip(rhs.targetMostDetailedMip), + targetFirstSlice(rhs.targetFirstSlice), + targetPlaneSlice(rhs.targetPlaneSlice) {} + +CopyPass::CopyPass(const allocator_type& alloc) noexcept +: copyPairs(alloc) {} + +CopyPass::CopyPass(CopyPass&& rhs, const allocator_type& alloc) +: copyPairs(std::move(rhs.copyPairs), alloc) {} + +CopyPass::CopyPass(CopyPass const& rhs, const allocator_type& alloc) +: copyPairs(rhs.copyPairs, alloc) {} + +MovePair::MovePair(const allocator_type& alloc) noexcept +: source(alloc), + target(alloc) {} + +MovePair::MovePair(PmrString sourceIn, PmrString targetIn, uint32_t mipLevelsIn, uint32_t numSlicesIn, uint32_t targetMostDetailedMipIn, uint32_t targetFirstSliceIn, uint32_t targetPlaneSliceIn, const allocator_type& alloc) noexcept // NOLINT +: source(std::move(sourceIn), alloc), + target(std::move(targetIn), alloc), + mipLevels(mipLevelsIn), + numSlices(numSlicesIn), + targetMostDetailedMip(targetMostDetailedMipIn), + targetFirstSlice(targetFirstSliceIn), + targetPlaneSlice(targetPlaneSliceIn) {} + +MovePair::MovePair(MovePair&& rhs, const allocator_type& alloc) +: source(std::move(rhs.source), alloc), + target(std::move(rhs.target), alloc), + mipLevels(rhs.mipLevels), + numSlices(rhs.numSlices), + targetMostDetailedMip(rhs.targetMostDetailedMip), + targetFirstSlice(rhs.targetFirstSlice), + targetPlaneSlice(rhs.targetPlaneSlice) {} + +MovePair::MovePair(MovePair const& rhs, const allocator_type& alloc) +: source(rhs.source, alloc), + target(rhs.target, alloc), + mipLevels(rhs.mipLevels), + numSlices(rhs.numSlices), + targetMostDetailedMip(rhs.targetMostDetailedMip), + targetFirstSlice(rhs.targetFirstSlice), + targetPlaneSlice(rhs.targetPlaneSlice) {} + +MovePass::MovePass(const allocator_type& alloc) noexcept +: movePairs(alloc) {} + +MovePass::MovePass(MovePass&& rhs, const allocator_type& alloc) +: movePairs(std::move(rhs.movePairs), alloc) {} + +MovePass::MovePass(MovePass const& rhs, const allocator_type& alloc) +: movePairs(rhs.movePairs, alloc) {} + +RaytracePass::RaytracePass(const allocator_type& alloc) noexcept +: computeViews(alloc) {} + +RaytracePass::RaytracePass(RaytracePass&& rhs, const allocator_type& alloc) +: computeViews(std::move(rhs.computeViews), alloc) {} + +RaytracePass::RaytracePass(RaytracePass const& rhs, const allocator_type& alloc) +: computeViews(rhs.computeViews, alloc) {} + +SceneData::SceneData(const allocator_type& alloc) noexcept +: name(alloc), + scenes(alloc) {} + +SceneData::SceneData(PmrString nameIn, const allocator_type& alloc) noexcept +: name(std::move(nameIn), alloc), + scenes(alloc) {} + +SceneData::SceneData(SceneData&& rhs, const allocator_type& alloc) +: name(std::move(rhs.name), alloc), + camera(rhs.camera), + scenes(std::move(rhs.scenes), alloc) {} + +SceneData::SceneData(SceneData const& rhs, const allocator_type& alloc) +: name(rhs.name, alloc), + camera(rhs.camera), + scenes(rhs.scenes, alloc) {} + +Dispatch::Dispatch(const allocator_type& alloc) noexcept +: shader(alloc) {} + +Dispatch::Dispatch(PmrString shaderIn, uint32_t threadGroupCountXIn, uint32_t threadGroupCountYIn, uint32_t threadGroupCountZIn, const allocator_type& alloc) noexcept // NOLINT +: shader(std::move(shaderIn), alloc), + threadGroupCountX(threadGroupCountXIn), + threadGroupCountY(threadGroupCountYIn), + threadGroupCountZ(threadGroupCountZIn) {} + +Dispatch::Dispatch(Dispatch&& rhs, const allocator_type& alloc) +: shader(std::move(rhs.shader), alloc), + threadGroupCountX(rhs.threadGroupCountX), + threadGroupCountY(rhs.threadGroupCountY), + threadGroupCountZ(rhs.threadGroupCountZ) {} + +Dispatch::Dispatch(Dispatch const& rhs, const allocator_type& alloc) +: shader(rhs.shader, alloc), + threadGroupCountX(rhs.threadGroupCountX), + threadGroupCountY(rhs.threadGroupCountY), + threadGroupCountZ(rhs.threadGroupCountZ) {} + +Blit::Blit(const allocator_type& alloc) noexcept +: shader(alloc) {} + +Blit::Blit(PmrString shaderIn, const allocator_type& alloc) noexcept +: shader(std::move(shaderIn), alloc) {} + +Blit::Blit(Blit&& rhs, const allocator_type& alloc) +: shader(std::move(rhs.shader), alloc) {} + +Blit::Blit(Blit const& rhs, const allocator_type& alloc) +: shader(rhs.shader, alloc) {} + +PresentPass::PresentPass(const allocator_type& alloc) noexcept +: resourceName(alloc) {} + +PresentPass::PresentPass(PmrString resourceNameIn, uint32_t syncIntervalIn, uint32_t flagsIn, const allocator_type& alloc) noexcept // NOLINT +: resourceName(std::move(resourceNameIn), alloc), + syncInterval(syncIntervalIn), + flags(flagsIn) {} + +PresentPass::PresentPass(PresentPass&& rhs, const allocator_type& alloc) +: resourceName(std::move(rhs.resourceName), alloc), + syncInterval(rhs.syncInterval), + flags(rhs.flags) {} + +PresentPass::PresentPass(PresentPass const& rhs, const allocator_type& alloc) +: resourceName(rhs.resourceName, alloc), + syncInterval(rhs.syncInterval), + flags(rhs.flags) {} + +RenderData::RenderData(const allocator_type& alloc) noexcept +: constants(alloc), + buffers(alloc), + textures(alloc), + samplers(alloc) {} + +RenderData::RenderData(RenderData&& rhs, const allocator_type& alloc) +: constants(std::move(rhs.constants), alloc), + buffers(std::move(rhs.buffers), alloc), + textures(std::move(rhs.textures), alloc), + samplers(std::move(rhs.samplers), alloc) {} + +RenderGraph::RenderGraph(const allocator_type& alloc) noexcept +: objects(alloc), + vertices(alloc), + names(alloc), + layoutNodes(alloc), + data(alloc), + rasterPasses(alloc), + computePasses(alloc), + copyPasses(alloc), + movePasses(alloc), + presentPasses(alloc), + raytracePasses(alloc), + renderQueues(alloc), + scenes(alloc), + blits(alloc), + dispatches(alloc), + index(alloc) {} + +RenderGraph::RenderGraph(RenderGraph&& rhs, const allocator_type& alloc) +: objects(std::move(rhs.objects), alloc), + vertices(std::move(rhs.vertices), alloc), + names(std::move(rhs.names), alloc), + layoutNodes(std::move(rhs.layoutNodes), alloc), + data(std::move(rhs.data), alloc), + rasterPasses(std::move(rhs.rasterPasses), alloc), + computePasses(std::move(rhs.computePasses), alloc), + copyPasses(std::move(rhs.copyPasses), alloc), + movePasses(std::move(rhs.movePasses), alloc), + presentPasses(std::move(rhs.presentPasses), alloc), + raytracePasses(std::move(rhs.raytracePasses), alloc), + renderQueues(std::move(rhs.renderQueues), alloc), + scenes(std::move(rhs.scenes), alloc), + blits(std::move(rhs.blits), alloc), + dispatches(std::move(rhs.dispatches), alloc), + index(std::move(rhs.index), alloc) {} + +// ContinuousContainer +void RenderGraph::reserve(vertices_size_type sz) { + objects.reserve(sz); + vertices.reserve(sz); + names.reserve(sz); + layoutNodes.reserve(sz); + data.reserve(sz); +} + +RenderGraph::object_type::object_type(const allocator_type& alloc) noexcept +: children(alloc), + parents(alloc) {} + +RenderGraph::object_type::object_type(object_type&& rhs, const allocator_type& alloc) +: children(std::move(rhs.children), alloc), + parents(std::move(rhs.parents), alloc) {} + +RenderGraph::object_type::object_type(object_type const& rhs, const allocator_type& alloc) +: children(rhs.children, alloc), + parents(rhs.parents, alloc) {} + +RenderGraph::vertex_type::vertex_type(const allocator_type& alloc) noexcept +: outEdges(alloc), + inEdges(alloc) {} + +RenderGraph::vertex_type::vertex_type(vertex_type&& rhs, const allocator_type& alloc) +: outEdges(std::move(rhs.outEdges), alloc), + inEdges(std::move(rhs.inEdges), alloc), + handle(std::move(rhs.handle)) {} + +RenderGraph::vertex_type::vertex_type(vertex_type const& rhs, const allocator_type& alloc) +: outEdges(rhs.outEdges, alloc), + inEdges(rhs.inEdges, alloc), + handle(rhs.handle) {} + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h new file mode 100644 index 0000000000..d0936d9930 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h @@ -0,0 +1,933 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include +#include +#include +#include +#include "cocos/renderer/gfx-base/GFXBuffer.h" +#include "cocos/renderer/gfx-base/GFXDef-common.h" +#include "cocos/renderer/gfx-base/GFXTexture.h" +#include "cocos/renderer/gfx-base/states/GFXSampler.h" +#include "cocos/renderer/pipeline/PipelineSceneData.h" +#include "cocos/renderer/pipeline/custom/GraphTypes.h" +#include "cocos/renderer/pipeline/custom/Map.h" +#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" +#include "cocos/renderer/pipeline/custom/String.h" +#include "cocos/scene/Camera.h" + +namespace cc { + +namespace render { + +enum class ResourceFlags : uint32_t { + NONE = 0, + ALLOW_RENDER_TARGET = 0x1, + ALLOW_DEPTH_STENCIL = 0x2, + ALLOW_UNORDERED_ACCESS = 0x4, + DENY_SHADER_RESOURCE = 0x8, + ALLOW_CROSS_ADAPTER = 0x10, + ALLOW_SIMULTANEOUS_ACCESS = 0x20, + VIDEO_DECODE_REFERENCE_ONLY = 0x40, +}; + +constexpr ResourceFlags operator|(const ResourceFlags lhs, const ResourceFlags rhs) noexcept { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +constexpr ResourceFlags operator&(const ResourceFlags lhs, const ResourceFlags rhs) noexcept { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +constexpr ResourceFlags& operator|=(ResourceFlags& lhs, const ResourceFlags rhs) noexcept { + return lhs = lhs | rhs; +} + +constexpr ResourceFlags& operator&=(ResourceFlags& lhs, const ResourceFlags rhs) noexcept { + return lhs = lhs & rhs; +} + +constexpr bool operator!(ResourceFlags e) noexcept { + return e == static_cast(0); +} + +constexpr bool any(ResourceFlags e) noexcept { + return !!e; +} + +enum class TextureLayout { + UNKNOWN, + ROW_MAJOR, + UNDEFINED_SWIZZLE, + STANDARD_SWIZZLE, +}; + +struct ResourceDesc { + ResourceDimension dimension{ResourceDimension::BUFFER}; + uint32_t alignment{0}; + uint32_t width{0}; + uint32_t height{0}; + uint16_t depthOrArraySize{0}; + uint16_t mipLevels{0}; + gfx::Format format{gfx::Format::UNKNOWN}; + gfx::SampleCount sampleCount{gfx::SampleCount::ONE}; + TextureLayout layout{TextureLayout::UNKNOWN}; + ResourceFlags flags{ResourceFlags::NONE}; +}; + +struct ResourceTraits { + ResourceTraits() = default; + ResourceTraits(ResourceResidency residencyIn) noexcept // NOLINT + : residency(residencyIn) {} + + bool hasSideEffects() const noexcept { + return boost::variant2::holds_alternative(residency) || + boost::variant2::holds_alternative(residency); + } + + ResourceResidency residency; +}; + +struct ResourceGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::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::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + }; + + struct NameTag { + } static constexpr Name{}; // NOLINT + struct DescTag { + } static constexpr Desc{}; // NOLINT + struct TraitsTag { + } static constexpr Traits{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector names; + boost::container::pmr::vector descs; + boost::container::pmr::vector traits; + // UuidGraph + PmrUnorderedMap valueIndex; +}; + +enum class AttachmentType { + RENDER_TARGET, + DEPTH_STENCIL, +}; + +enum class AccessType { + READ, + READ_WRITE, + WRITE, +}; + +struct RasterView { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {slotName.get_allocator().resource()}; + } + + RasterView(const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; // NOLINT + RasterView(PmrString slotNameIn, AccessType accessTypeIn, AttachmentType attachmentTypeIn, gfx::LoadOp loadOpIn, gfx::StoreOp storeOpIn, gfx::ClearFlagBit clearFlagsIn, gfx::Color clearColorIn, const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; + RasterView(RasterView&& rhs, const allocator_type& alloc); + RasterView(RasterView const& rhs, const allocator_type& alloc); + + RasterView(RasterView&& rhs) noexcept = default; + RasterView(RasterView const& rhs) = delete; + RasterView& operator=(RasterView&& rhs) = default; + RasterView& operator=(RasterView const& rhs) = default; + + PmrString slotName; + AccessType accessType{AccessType::WRITE}; + AttachmentType attachmentType{AttachmentType::RENDER_TARGET}; + gfx::LoadOp loadOp{gfx::LoadOp::LOAD}; + gfx::StoreOp storeOp{gfx::StoreOp::STORE}; + gfx::ClearFlagBit clearFlags{gfx::ClearFlagBit::ALL}; + gfx::Color clearColor; +}; + +enum class ClearValueType { + FLOAT_TYPE, + INT_TYPE, +}; + +struct ComputeView { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {name.get_allocator().resource()}; + } + + ComputeView(const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; // NOLINT + ComputeView(ComputeView&& rhs, const allocator_type& alloc); + ComputeView(ComputeView const& rhs, const allocator_type& alloc); + + ComputeView(ComputeView&& rhs) noexcept = default; + ComputeView(ComputeView const& rhs) = delete; + ComputeView& operator=(ComputeView&& rhs) = default; + ComputeView& operator=(ComputeView const& rhs) = default; + + bool isRead() const { + return accessType != AccessType::WRITE; + } + bool isWrite() const { + return accessType != AccessType::READ; + } + + PmrString name; + AccessType accessType{AccessType::READ}; + gfx::ClearFlagBit clearFlags{gfx::ClearFlagBit::NONE}; + gfx::Color clearColor; + ClearValueType clearValueType{ClearValueType::FLOAT_TYPE}; +}; + +struct RasterSubpass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {rasterViews.get_allocator().resource()}; + } + + RasterSubpass(const allocator_type& alloc) noexcept; // NOLINT + RasterSubpass(RasterSubpass&& rhs, const allocator_type& alloc); + RasterSubpass(RasterSubpass const& rhs, const allocator_type& alloc); + + RasterSubpass(RasterSubpass&& rhs) noexcept = default; + RasterSubpass(RasterSubpass const& rhs) = delete; + RasterSubpass& operator=(RasterSubpass&& rhs) = default; + RasterSubpass& operator=(RasterSubpass const& rhs) = default; + + PmrTransparentMap rasterViews; + PmrTransparentMap> computeViews; +}; + +struct SubpassGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + 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(); + } + + SubpassGraph(const allocator_type& alloc) noexcept; // NOLINT + SubpassGraph(SubpassGraph&& rhs, const allocator_type& alloc); + SubpassGraph(SubpassGraph const& rhs, const allocator_type& alloc); + + SubpassGraph(SubpassGraph&& rhs) noexcept = default; + SubpassGraph(SubpassGraph const& rhs) = delete; + SubpassGraph& operator=(SubpassGraph&& rhs) = default; + SubpassGraph& operator=(SubpassGraph const& rhs) = default; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptor; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + SubpassGraph, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + }; + + struct NameTag { + } static constexpr Name{}; // NOLINT + struct SubpassTag { + } static constexpr Subpass{}; // NOLINT + + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector names; + boost::container::pmr::vector subpasses; +}; + +struct RasterPass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {rasterViews.get_allocator().resource()}; + } + + RasterPass(const allocator_type& alloc) noexcept; // NOLINT + RasterPass(RasterPass&& rhs, const allocator_type& alloc); + RasterPass(RasterPass const& rhs, const allocator_type& alloc); + + RasterPass(RasterPass&& rhs) noexcept = default; + RasterPass(RasterPass const& rhs) = delete; + RasterPass& operator=(RasterPass&& rhs) = default; + RasterPass& operator=(RasterPass const& rhs) = default; + + PmrTransparentMap rasterViews; + PmrTransparentMap> computeViews; + SubpassGraph subpassGraph; +}; + +struct ComputePass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {computeViews.get_allocator().resource()}; + } + + ComputePass(const allocator_type& alloc) noexcept; // NOLINT + ComputePass(ComputePass&& rhs, const allocator_type& alloc); + ComputePass(ComputePass const& rhs, const allocator_type& alloc); + + ComputePass(ComputePass&& rhs) noexcept = default; + ComputePass(ComputePass const& rhs) = delete; + ComputePass& operator=(ComputePass&& rhs) = default; + ComputePass& operator=(ComputePass const& rhs) = default; + + PmrTransparentMap> computeViews; +}; + +struct CopyPair { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {source.get_allocator().resource()}; + } + + CopyPair(const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; // NOLINT + CopyPair(PmrString sourceIn, PmrString targetIn, uint32_t mipLevelsIn, uint32_t numSlicesIn, uint32_t sourceMostDetailedMipIn, uint32_t sourceFirstSliceIn, uint32_t sourcePlaneSliceIn, uint32_t targetMostDetailedMipIn, uint32_t targetFirstSliceIn, uint32_t targetPlaneSliceIn, const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; + CopyPair(CopyPair&& rhs, const allocator_type& alloc); + CopyPair(CopyPair const& rhs, const allocator_type& alloc); + + CopyPair(CopyPair&& rhs) noexcept = default; + CopyPair(CopyPair const& rhs) = delete; + CopyPair& operator=(CopyPair&& rhs) = default; + CopyPair& operator=(CopyPair const& rhs) = default; + + PmrString source; + PmrString target; + uint32_t mipLevels{0xFFFFFFFF}; + uint32_t numSlices{0xFFFFFFFF}; + uint32_t sourceMostDetailedMip{0}; + uint32_t sourceFirstSlice{0}; + uint32_t sourcePlaneSlice{0}; + uint32_t targetMostDetailedMip{0}; + uint32_t targetFirstSlice{0}; + uint32_t targetPlaneSlice{0}; +}; + +struct CopyPass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {copyPairs.get_allocator().resource()}; + } + + CopyPass(const allocator_type& alloc) noexcept; // NOLINT + CopyPass(CopyPass&& rhs, const allocator_type& alloc); + CopyPass(CopyPass const& rhs, const allocator_type& alloc); + + CopyPass(CopyPass&& rhs) noexcept = default; + CopyPass(CopyPass const& rhs) = delete; + CopyPass& operator=(CopyPass&& rhs) = default; + CopyPass& operator=(CopyPass const& rhs) = default; + + boost::container::pmr::vector copyPairs; +}; + +struct MovePair { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {source.get_allocator().resource()}; + } + + MovePair(const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; // NOLINT + MovePair(PmrString sourceIn, PmrString targetIn, uint32_t mipLevelsIn, uint32_t numSlicesIn, uint32_t targetMostDetailedMipIn, uint32_t targetFirstSliceIn, uint32_t targetPlaneSliceIn, const allocator_type& alloc = boost::container::pmr::get_default_resource()) noexcept; + MovePair(MovePair&& rhs, const allocator_type& alloc); + MovePair(MovePair const& rhs, const allocator_type& alloc); + + MovePair(MovePair&& rhs) noexcept = default; + MovePair(MovePair const& rhs) = delete; + MovePair& operator=(MovePair&& rhs) = default; + MovePair& operator=(MovePair const& rhs) = default; + + PmrString source; + PmrString target; + uint32_t mipLevels{0xFFFFFFFF}; + uint32_t numSlices{0xFFFFFFFF}; + uint32_t targetMostDetailedMip{0}; + uint32_t targetFirstSlice{0}; + uint32_t targetPlaneSlice{0}; +}; + +struct MovePass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {movePairs.get_allocator().resource()}; + } + + MovePass(const allocator_type& alloc) noexcept; // NOLINT + MovePass(MovePass&& rhs, const allocator_type& alloc); + MovePass(MovePass const& rhs, const allocator_type& alloc); + + MovePass(MovePass&& rhs) noexcept = default; + MovePass(MovePass const& rhs) = delete; + MovePass& operator=(MovePass&& rhs) = default; + MovePass& operator=(MovePass const& rhs) = default; + + boost::container::pmr::vector movePairs; +}; + +struct RaytracePass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {computeViews.get_allocator().resource()}; + } + + RaytracePass(const allocator_type& alloc) noexcept; // NOLINT + RaytracePass(RaytracePass&& rhs, const allocator_type& alloc); + RaytracePass(RaytracePass const& rhs, const allocator_type& alloc); + + RaytracePass(RaytracePass&& rhs) noexcept = default; + RaytracePass(RaytracePass const& rhs) = delete; + RaytracePass& operator=(RaytracePass&& rhs) = default; + RaytracePass& operator=(RaytracePass const& rhs) = default; + + PmrTransparentMap> computeViews; +}; + +struct QueueTag {}; +struct SceneTag {}; +struct DispatchTag {}; +struct BlitTag {}; +struct PresentTag {}; + +struct RenderQueue { + RenderQueue() = default; + RenderQueue(QueueHint hintIn) noexcept // NOLINT + : hint(hintIn) {} + + QueueHint hint{QueueHint::RENDER_OPAQUE}; +}; + +struct SceneData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {name.get_allocator().resource()}; + } + + SceneData(const allocator_type& alloc) noexcept; // NOLINT + SceneData(PmrString nameIn, const allocator_type& alloc) noexcept; + SceneData(SceneData&& rhs, const allocator_type& alloc); + SceneData(SceneData const& rhs, const allocator_type& alloc); + + SceneData(SceneData&& rhs) noexcept = default; + SceneData(SceneData const& rhs) = delete; + SceneData& operator=(SceneData&& rhs) = default; + SceneData& operator=(SceneData const& rhs) = default; + + PmrString name; + scene::Camera* camera{nullptr}; + boost::container::pmr::vector scenes; +}; + +struct Dispatch { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {shader.get_allocator().resource()}; + } + + Dispatch(const allocator_type& alloc) noexcept; // NOLINT + Dispatch(PmrString shaderIn, uint32_t threadGroupCountXIn, uint32_t threadGroupCountYIn, uint32_t threadGroupCountZIn, const allocator_type& alloc) noexcept; + Dispatch(Dispatch&& rhs, const allocator_type& alloc); + Dispatch(Dispatch const& rhs, const allocator_type& alloc); + + Dispatch(Dispatch&& rhs) noexcept = default; + Dispatch(Dispatch const& rhs) = delete; + Dispatch& operator=(Dispatch&& rhs) = default; + Dispatch& operator=(Dispatch const& rhs) = default; + + PmrString shader; + uint32_t threadGroupCountX{0}; + uint32_t threadGroupCountY{0}; + uint32_t threadGroupCountZ{0}; +}; + +struct Blit { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {shader.get_allocator().resource()}; + } + + Blit(const allocator_type& alloc) noexcept; // NOLINT + Blit(PmrString shaderIn, const allocator_type& alloc) noexcept; + Blit(Blit&& rhs, const allocator_type& alloc); + Blit(Blit const& rhs, const allocator_type& alloc); + + Blit(Blit&& rhs) noexcept = default; + Blit(Blit const& rhs) = delete; + Blit& operator=(Blit&& rhs) = default; + Blit& operator=(Blit const& rhs) = default; + + PmrString shader; +}; + +struct PresentPass { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {resourceName.get_allocator().resource()}; + } + + PresentPass(const allocator_type& alloc) noexcept; // NOLINT + PresentPass(PmrString resourceNameIn, uint32_t syncIntervalIn, uint32_t flagsIn, const allocator_type& alloc) noexcept; + PresentPass(PresentPass&& rhs, const allocator_type& alloc); + PresentPass(PresentPass const& rhs, const allocator_type& alloc); + + PresentPass(PresentPass&& rhs) noexcept = default; + PresentPass(PresentPass const& rhs) = delete; + PresentPass& operator=(PresentPass&& rhs) = default; + PresentPass& operator=(PresentPass const& rhs) = default; + + PmrString resourceName; + uint32_t syncInterval{0}; + uint32_t flags{0}; +}; + +struct RenderData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {constants.get_allocator().resource()}; + } + + RenderData(const allocator_type& alloc) noexcept; // NOLINT + RenderData(RenderData&& rhs, const allocator_type& alloc); + + RenderData(RenderData&& rhs) noexcept = default; + RenderData(RenderData const& rhs) = delete; + RenderData& operator=(RenderData&& rhs) = default; + RenderData& operator=(RenderData const& rhs) = delete; + + PmrUnorderedMap> constants; + PmrUnorderedMap> buffers; + PmrUnorderedMap> textures; + PmrUnorderedMap> samplers; +}; + +struct RenderGraph { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {objects.get_allocator().resource()}; + } + + inline boost::container::pmr::memory_resource* resource() const noexcept { + return get_allocator().resource(); + } + + RenderGraph(const allocator_type& alloc) noexcept; // NOLINT + RenderGraph(RenderGraph&& rhs, const allocator_type& alloc); + + RenderGraph(RenderGraph&& rhs) noexcept = default; + RenderGraph(RenderGraph const& rhs) = delete; + RenderGraph& operator=(RenderGraph&& rhs) = default; + RenderGraph& operator=(RenderGraph const& rhs) = delete; + + // Graph + using directed_category = boost::bidirectional_tag; + using vertex_descriptor = uint32_t; + using edge_descriptor = impl::EdgeDescriptor; + 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::max(); + } + + // IncidenceGraph + using out_edge_type = impl::StoredEdge; + using out_edge_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + using degree_size_type = uint32_t; + + // BidirectionalGraph + using in_edge_type = impl::StoredEdge; + using in_edge_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, edge_descriptor, int32_t>; + + // AdjacencyGraph + using adjacency_iterator = boost::adjacency_iterator_generator< + RenderGraph, vertex_descriptor, out_edge_iterator>::type; + + // VertexListGraph + using vertex_iterator = boost::integer_range::iterator; + using vertices_size_type = uint32_t; + + // VertexList help functions + inline boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) noexcept { + return vertices[v].outEdges; + } + inline const boost::container::pmr::vector& getOutEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].outEdges; + } + + inline boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) noexcept { + return vertices[v].inEdges; + } + inline const boost::container::pmr::vector& getInEdgeList(vertex_descriptor v) const noexcept { + return vertices[v].inEdges; + } + + inline boost::integer_range getVertexList() const noexcept { + return {0, static_cast(vertices.size())}; + } + + inline vertex_descriptor getCurrentID() const noexcept { + return static_cast(vertices.size()); + } + + inline boost::container::pmr::vector colors(boost::container::pmr::memory_resource* mr) const { + return boost::container::pmr::vector(vertices.size(), mr); + } + + // EdgeListGraph + using edge_iterator = impl::DirectedEdgeIterator; + using edges_size_type = uint32_t; + + // AddressableGraph (Separated) + using ownership_descriptor = impl::EdgeDescriptor; + + using children_edge_type = impl::StoredEdge; + using children_iterator = impl::OutEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, ownership_descriptor, int32_t>; + using children_size_type = uint32_t; + + using parent_edge_type = impl::StoredEdge; + using parent_iterator = impl::InEdgeIter< + boost::container::pmr::vector::iterator, + vertex_descriptor, ownership_descriptor, int32_t>; + + using ownership_iterator = impl::OwnershipIterator; + using ownerships_size_type = edges_size_type; + + // AddressableGraph help functions + inline boost::container::pmr::vector& getChildrenList(vertex_descriptor v) noexcept { + return objects[v].children; + } + inline const boost::container::pmr::vector& getChildrenList(vertex_descriptor v) const noexcept { + return objects[v].children; + } + + inline boost::container::pmr::vector& getParentsList(vertex_descriptor v) noexcept { + return objects[v].parents; + } + inline const boost::container::pmr::vector& getParentsList(vertex_descriptor v) const noexcept { + return objects[v].parents; + } + + // PolymorphicGraph + using vertex_tag_type = boost::variant2::variant; + using vertex_value_type = boost::variant2::variant; + using vertex_const_value_type = boost::variant2::variant; + using vertex_handle_type = boost::variant2::variant< + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle, + impl::ValueHandle>; + + // ContinuousContainer + void reserve(vertices_size_type sz); + + // Members + struct object_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {children.get_allocator().resource()}; + } + + object_type(const allocator_type& alloc) noexcept; // NOLINT + object_type(object_type&& rhs, const allocator_type& alloc); + object_type(object_type const& rhs, const allocator_type& alloc); + + object_type(object_type&& rhs) noexcept = default; + object_type(object_type const& rhs) = delete; + object_type& operator=(object_type&& rhs) = default; + object_type& operator=(object_type const& rhs) = default; + + boost::container::pmr::vector children; + boost::container::pmr::vector parents; + }; + + struct vertex_type { // NOLINT + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {outEdges.get_allocator().resource()}; + } + + vertex_type(const allocator_type& alloc) noexcept; // NOLINT + vertex_type(vertex_type&& rhs, const allocator_type& alloc); + vertex_type(vertex_type const& rhs, const allocator_type& alloc); + + vertex_type(vertex_type&& rhs) noexcept = default; + vertex_type(vertex_type const& rhs) = delete; + vertex_type& operator=(vertex_type&& rhs) = default; + vertex_type& operator=(vertex_type const& rhs) = default; + + boost::container::pmr::vector outEdges; + boost::container::pmr::vector inEdges; + vertex_handle_type handle; + }; + + struct NameTag { + } static constexpr Name{}; // NOLINT + struct LayoutTag { + } static constexpr Layout{}; // NOLINT + struct DataTag { + } static constexpr Data{}; // NOLINT + + // Owners + boost::container::pmr::vector objects; + // Vertices + boost::container::pmr::vector vertices; + // Components + boost::container::pmr::vector names; + boost::container::pmr::vector layoutNodes; + boost::container::pmr::vector data; + // PolymorphicGraph + boost::container::pmr::vector rasterPasses; + boost::container::pmr::vector computePasses; + boost::container::pmr::vector copyPasses; + boost::container::pmr::vector movePasses; + boost::container::pmr::vector presentPasses; + boost::container::pmr::vector raytracePasses; + boost::container::pmr::vector renderQueues; + boost::container::pmr::vector scenes; + boost::container::pmr::vector blits; + boost::container::pmr::vector dispatches; + // Members + PmrUnorderedMap index; +}; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderInterfaceFwd.h b/native/cocos/renderer/pipeline/custom/RenderInterfaceFwd.h new file mode 100644 index 0000000000..1b25c60fd2 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderInterfaceFwd.h @@ -0,0 +1,55 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include +#include "cocos/core/assets/EffectAsset.h" +#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h" + +namespace cc { + +namespace render { + +class DescriptorHierarchy; +class Setter; +class RasterQueueBuilder; +class RasterPassBuilder; +class ComputeQueueBuilder; +class ComputePassBuilder; +class MovePassBuilder; +class CopyPassBuilder; +class Pipeline; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp new file mode 100644 index 0000000000..d5031b75fa --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#include "RenderInterfaceTypes.h" + +namespace cc { + +namespace render { + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h b/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h new file mode 100644 index 0000000000..ed985934af --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h @@ -0,0 +1,243 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/** + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + * The following section is auto-generated. + * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= + */ +// clang-format off +#pragma once +#include "cocos/core/assets/EffectAsset.h" +#include "cocos/renderer/gfx-base/GFXDef-common.h" +#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" +#include "cocos/renderer/pipeline/custom/RenderInterfaceFwd.h" + +namespace cc { + +class Mat4; +class Mat4; +class Quaternion; +class Color; +class Vec4; +class Vec3; +class Vec2; + +class EffectAsset; + +namespace pipeline { + +class PipelineSceneData; + +} // namespace pipeline + +} // namespace cc + +namespace cc { + +namespace render { + +class DescriptorHierarchy { +public: + DescriptorHierarchy() noexcept = default; + DescriptorHierarchy(DescriptorHierarchy&& rhs) = delete; + DescriptorHierarchy(DescriptorHierarchy const& rhs) = delete; + DescriptorHierarchy& operator=(DescriptorHierarchy&& rhs) = delete; + DescriptorHierarchy& operator=(DescriptorHierarchy const& rhs) = delete; + + virtual ~DescriptorHierarchy() noexcept = 0; + + virtual void addEffect(EffectAsset* asset) = 0; +}; + +inline DescriptorHierarchy::~DescriptorHierarchy() noexcept = default; + +class Setter { +public: + Setter() noexcept = default; + Setter(Setter&& rhs) = delete; + Setter(Setter const& rhs) = delete; + Setter& operator=(Setter&& rhs) = delete; + Setter& operator=(Setter const& rhs) = delete; + + virtual ~Setter() noexcept = 0; + + virtual void setMat4(const std::string& name, const cc::Mat4& mat) = 0; + virtual void setQuaternion(const std::string& name, const cc::Quaternion& quat) = 0; + virtual void setColor(const std::string& name, const cc::Color& color) = 0; + virtual void setVec4(const std::string& name, const cc::Vec4& vec) = 0; + virtual void setVec2(const std::string& name, const cc::Vec2& vec) = 0; + virtual void setFloat(const std::string& name, float v) = 0; + + virtual void setBuffer(const std::string& name, gfx::Buffer* buffer) = 0; + virtual void setTexture(const std::string& name, gfx::Texture* texture) = 0; + virtual void setReadWriteBuffer(const std::string& name, gfx::Buffer* buffer) = 0; + virtual void setReadWriteTexture(const std::string& name, gfx::Texture* texture) = 0; + virtual void setSampler(const std::string& name, gfx::Sampler* sampler) = 0; +}; + +inline Setter::~Setter() noexcept = default; + +class RasterQueueBuilder { +public: + RasterQueueBuilder() noexcept = default; + RasterQueueBuilder(RasterQueueBuilder&& rhs) = delete; + RasterQueueBuilder(RasterQueueBuilder const& rhs) = delete; + RasterQueueBuilder& operator=(RasterQueueBuilder&& rhs) = delete; + RasterQueueBuilder& operator=(RasterQueueBuilder const& rhs) = delete; + + virtual ~RasterQueueBuilder() noexcept = 0; + + virtual void addSceneOfCamera(scene::Camera* camera, const std::string& name) = 0; + virtual void addSceneOfCamera(scene::Camera* camera) = 0; + virtual void addScene(const std::string& name) = 0; + virtual void addFullscreenQuad(const std::string& shader, const std::string& name) = 0; + virtual void addFullscreenQuad(const std::string& shader) = 0; +}; + +inline RasterQueueBuilder::~RasterQueueBuilder() noexcept = default; + +class RasterPassBuilder { +public: + RasterPassBuilder() noexcept = default; + RasterPassBuilder(RasterPassBuilder&& rhs) = delete; + RasterPassBuilder(RasterPassBuilder const& rhs) = delete; + RasterPassBuilder& operator=(RasterPassBuilder&& rhs) = delete; + RasterPassBuilder& operator=(RasterPassBuilder const& rhs) = delete; + + virtual ~RasterPassBuilder() noexcept = 0; + + virtual void addRasterView(const std::string& name, const RasterView& view) = 0; + virtual void addComputeView(const std::string& name, const ComputeView& view) = 0; + virtual RasterQueueBuilder* addQueue(QueueHint hint, const std::string& layoutName, const std::string& name) = 0; + virtual RasterQueueBuilder* addQueue(QueueHint hint, const std::string& layoutName) = 0; + virtual RasterQueueBuilder* addQueue(QueueHint hint) = 0; + virtual void addFullscreenQuad(const std::string& shader, const std::string& layoutName, const std::string& name) = 0; + virtual void addFullscreenQuad(const std::string& shader, const std::string& layoutName) = 0; + virtual void addFullscreenQuad(const std::string& shader) = 0; +}; + +inline RasterPassBuilder::~RasterPassBuilder() noexcept = default; + +class ComputeQueueBuilder { +public: + ComputeQueueBuilder() noexcept = default; + ComputeQueueBuilder(ComputeQueueBuilder&& rhs) = delete; + ComputeQueueBuilder(ComputeQueueBuilder const& rhs) = delete; + ComputeQueueBuilder& operator=(ComputeQueueBuilder&& rhs) = delete; + ComputeQueueBuilder& operator=(ComputeQueueBuilder const& rhs) = delete; + + virtual ~ComputeQueueBuilder() noexcept = 0; + + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ, const std::string& layoutName, const std::string& name) = 0; + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ, const std::string& layoutName) = 0; + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ) = 0; +}; + +inline ComputeQueueBuilder::~ComputeQueueBuilder() noexcept = default; + +class ComputePassBuilder { +public: + ComputePassBuilder() noexcept = default; + ComputePassBuilder(ComputePassBuilder&& rhs) = delete; + ComputePassBuilder(ComputePassBuilder const& rhs) = delete; + ComputePassBuilder& operator=(ComputePassBuilder&& rhs) = delete; + ComputePassBuilder& operator=(ComputePassBuilder const& rhs) = delete; + + virtual ~ComputePassBuilder() noexcept = 0; + + virtual void addComputeView(const std::string& name, const ComputeView& view) = 0; + + virtual ComputeQueueBuilder* addQueue(const std::string& layoutName, const std::string& name) = 0; + virtual ComputeQueueBuilder* addQueue(const std::string& layoutName) = 0; + virtual ComputeQueueBuilder* addQueue() = 0; + + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ, const std::string& layoutName, const std::string& name) = 0; + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ, const std::string& layoutName) = 0; + virtual void addDispatch(const std::string& shader, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ) = 0; +}; + +inline ComputePassBuilder::~ComputePassBuilder() noexcept = default; + +class MovePassBuilder { +public: + MovePassBuilder() noexcept = default; + MovePassBuilder(MovePassBuilder&& rhs) = delete; + MovePassBuilder(MovePassBuilder const& rhs) = delete; + MovePassBuilder& operator=(MovePassBuilder&& rhs) = delete; + MovePassBuilder& operator=(MovePassBuilder const& rhs) = delete; + + virtual ~MovePassBuilder() noexcept = 0; + + virtual void addPair(const MovePair& pair) = 0; +}; + +inline MovePassBuilder::~MovePassBuilder() noexcept = default; + +class CopyPassBuilder { +public: + CopyPassBuilder() noexcept = default; + CopyPassBuilder(CopyPassBuilder&& rhs) = delete; + CopyPassBuilder(CopyPassBuilder const& rhs) = delete; + CopyPassBuilder& operator=(CopyPassBuilder&& rhs) = delete; + CopyPassBuilder& operator=(CopyPassBuilder const& rhs) = delete; + + virtual ~CopyPassBuilder() noexcept = 0; + + virtual void addPair(const CopyPair& pair) = 0; +}; + +inline CopyPassBuilder::~CopyPassBuilder() noexcept = default; + +class Pipeline { +public: + Pipeline() noexcept = default; + Pipeline(Pipeline&& rhs) = delete; + Pipeline(Pipeline const& rhs) = delete; + Pipeline& operator=(Pipeline&& rhs) = delete; + Pipeline& operator=(Pipeline const& rhs) = delete; + + virtual ~Pipeline() noexcept = 0; + + virtual uint32_t addRenderTexture(const std::string& name, gfx::Format format, uint32_t width, uint32_t height) = 0; + virtual uint32_t addRenderTarget(const std::string& name, gfx::Format format, uint32_t width, uint32_t height) = 0; + virtual uint32_t addDepthStencil(const std::string& name, gfx::Format format, uint32_t width, uint32_t height) = 0; + virtual void beginFrame(pipeline::PipelineSceneData* pplScene) = 0; + virtual void endFrame() = 0; + virtual RasterPassBuilder* addRasterPass(uint32_t width, uint32_t height, const std::string& layoutName, const std::string& name) = 0; + virtual RasterPassBuilder* addRasterPass(uint32_t width, uint32_t height, const std::string& layoutName) = 0; + virtual ComputePassBuilder* addComputePass(const std::string& layoutName, const std::string& name) = 0; + virtual ComputePassBuilder* addComputePass(const std::string& layoutName) = 0; + virtual MovePassBuilder* addMovePass(const std::string& name) = 0; + virtual CopyPassBuilder* addCopyPass(const std::string& name) = 0; +}; + +inline Pipeline::~Pipeline() noexcept = default; + +} // namespace render + +} // namespace cc + +// clang-format on diff --git a/native/cocos/renderer/pipeline/custom/Set.h b/native/cocos/renderer/pipeline/custom/Set.h new file mode 100644 index 0000000000..02e9e08bd9 --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/Set.h @@ -0,0 +1,102 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include +#include +#include +#include + +// for std::less<> the transparent comparator +// see https://stackoverflow.com/questions/20317413/what-are-transparent-comparators + +namespace cc { + +// set +template +using TransparentSet = std::set>; + +template +using TransparentMultiSet = std::multiset>; + +template +using PmrTransparentSet = std::set< + Value, std::less<>, + boost::container::pmr::polymorphic_allocator>; + +template +using PmrTransparentMultiSet = std::multiset< + Value, std::less<>, + boost::container::pmr::polymorphic_allocator>; + +// flat_set +template +using FlatSet = boost::container::flat_set>; + +template +using FlatMultiSet = boost::container::flat_multiset>; + +template +using PmrFlatSet = boost::container::pmr::flat_set>; + +template +using PmrFlatMultiSet = boost::container::pmr::flat_multiset>; + +// unordered_set +template +using PmrUnorderedSet = std::unordered_set< + Value, std::hash, std::equal_to, + boost::container::pmr::polymorphic_allocator>; + +template +using PmrUnorderedMultiSet = std::unordered_multiset< + Value, std::hash, std::equal_to, + boost::container::pmr::polymorphic_allocator>; + +// transparent string unordered_set +template +using UnorderedStringSet = std::unordered_set< + Value, + TransparentStringHash, std::equal_to<>>; + +template +using UnorderedStringMultiSet = std::unordered_multiset< + Value, + TransparentStringHash, std::equal_to<>>; + +template +using PmrUnorderedStringSet = std::unordered_set< + Value, + TransparentStringHash, std::equal_to<>, + boost::container::pmr::polymorphic_allocator>; + +template +using PmrUnorderedStringMultiSet = std::unordered_multiset< + Value, + TransparentStringHash, std::equal_to<>, + boost::container::pmr::polymorphic_allocator>; + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/String.h b/native/cocos/renderer/pipeline/custom/String.h new file mode 100644 index 0000000000..a6fc32307c --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/String.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include + +namespace cc { + +using PmrString = std::basic_string< + char, std::char_traits, + boost::container::pmr::polymorphic_allocator>; + +} diff --git a/native/cocos/renderer/pipeline/custom/Utility.h b/native/cocos/renderer/pipeline/custom/Utility.h new file mode 100644 index 0000000000..043dae56cc --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/Utility.h @@ -0,0 +1,52 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include +#include + +// transparent hash +// see https://stackoverflow.com/questions/20317413/what-are-transparent-comparators + +namespace cc { + +template +struct TransparentStringHash { + using is_transparent = void; + using string_view_type = boost::basic_string_view; + + size_t operator()(string_view_type str) const noexcept { + return boost::hash{}(str); + } + size_t operator()(const Char* str) const noexcept { + return boost::hash{}(str); + } + template + size_t operator()(const std::basic_string, Alloc>& str) const noexcept { + return boost::hash{}(str); + } +}; + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/custom/invoke.hpp b/native/cocos/renderer/pipeline/custom/invoke.hpp new file mode 100644 index 0000000000..68db1fa27f --- /dev/null +++ b/native/cocos/renderer/pipeline/custom/invoke.hpp @@ -0,0 +1,305 @@ +/**************************************************************************** + Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/invoke.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +#define INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(...) \ + noexcept(noexcept(__VA_ARGS__)) -> decltype (__VA_ARGS__) { return __VA_ARGS__; } + +// +// void_t +// + +namespace invoke_hpp +{ + namespace impl + { + template < typename... Args > + struct make_void { // NOLINT + using type = void; + }; + } + + template < typename... Args > + using void_t = typename impl::make_void::type; +} // namespace invoke_hpp + +// +// integer_sequence +// + +namespace invoke_hpp +{ + template < typename T, T... Ints > + struct integer_sequence { // NOLINT + using value_type = T; + static constexpr std::size_t size() noexcept { return sizeof...(Ints); } + }; + + template < std::size_t... Ints > + using index_sequence = integer_sequence; + + namespace impl + { + template < typename T, std::size_t N, T... Ints > + struct make_integer_sequence_impl // NOLINT + : make_integer_sequence_impl {}; + + template < typename T, T... Ints > + struct make_integer_sequence_impl + : integer_sequence {}; + } + + template < typename T, std::size_t N > + using make_integer_sequence = impl::make_integer_sequence_impl; + + template < std::size_t N > + using make_index_sequence = make_integer_sequence; + + template < typename... Ts > + using index_sequence_for = make_index_sequence; +} // namespace invoke_hpp + +// +// is_reference_wrapper +// + +namespace invoke_hpp +{ + namespace impl + { + template < typename T > + struct is_reference_wrapper_impl // NOLINT + : std::false_type {}; + + template < typename U > + struct is_reference_wrapper_impl> + : std::true_type {}; + } + + template < typename T > + struct is_reference_wrapper // NOLINT + : impl::is_reference_wrapper_impl::type> {}; +} // namespace invoke_hpp + +// +// invoke +// + +namespace invoke_hpp +{ + namespace impl + { + // + // invoke_member_object_impl + // + + template + < + typename Base, typename F, typename Derived, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke_member_object_impl(F Base::* f, Derived&& ref) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + std::forward(ref).*f) + + template + < + typename Base, typename F, typename RefWrap, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke_member_object_impl(F Base::* f, RefWrap&& ref) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + ref.get().*f) + + template + < + typename Base, typename F, typename Pointer, + typename std::enable_if< + !std::is_base_of::type>::value && + !is_reference_wrapper::type>::value + , int>::type = 0 + > + constexpr auto invoke_member_object_impl(F Base::* f, Pointer&& ptr) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + (*std::forward(ptr)).*f) + + // + // invoke_member_function_impl + // + + template + < + typename Base, typename F, typename Derived, typename... Args, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke_member_function_impl(F Base::* f, Derived&& ref, Args&&... args) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + (std::forward(ref).*f)(std::forward(args)...)) + + template + < + typename Base, typename F, typename RefWrap, typename... Args, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke_member_function_impl(F Base::* f, RefWrap&& ref, Args&&... args) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + (ref.get().*f)(std::forward(args)...)) + + template + < + typename Base, typename F, typename Pointer, typename... Args, + typename std::enable_if< + !std::is_base_of::type>::value && + !is_reference_wrapper::type>::value + , int>::type = 0 + > + constexpr auto invoke_member_function_impl(F Base::* f, Pointer&& ptr, Args&&... args) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + ((*std::forward(ptr)).*f)(std::forward(args)...)) + } // namespace impl + + template + < + typename F, typename... Args, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke(F&& f, Args&&... args) + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + std::forward(f)(std::forward(args)...)) + + template + < + typename F, typename T, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke(F&& f, T&& t) + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + impl::invoke_member_object_impl(std::forward(f), std::forward(t))) + + template + < + typename F, typename... Args, + typename std::enable_if::type>::value, int>::type = 0 + > + constexpr auto invoke(F&& f, Args&&... args) + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + impl::invoke_member_function_impl(std::forward(f), std::forward(args)...)) +} // namespace invoke_hpp + +// +// invoke_result +// + +namespace invoke_hpp +{ + namespace impl + { + struct invoke_result_impl_tag {}; // NOLINT + + template < typename Void, typename F, typename... Args > + struct invoke_result_impl {}; // NOLINT + + template < typename F, typename... Args > + struct invoke_result_impl(), std::declval()...))>, F, Args...> { + using type = decltype(invoke_hpp::invoke(std::declval(), std::declval()...)); + }; + } // namespace impl + + template < typename F, typename... Args > + struct invoke_result // NOLINT + : impl::invoke_result_impl {}; + + template < typename F, typename... Args > + using invoke_result_t = typename invoke_result::type; +} // namespace invoke_hpp + +// +// is_invocable +// + +namespace invoke_hpp +{ + namespace impl + { + struct is_invocable_r_impl_tag {}; // NOLINT + + template < typename Void, typename R, typename F, typename... Args > + struct is_invocable_r_impl // NOLINT + : std::false_type {}; + + template < typename R, typename F, typename... Args > + struct is_invocable_r_impl>, R, F, Args...> + : std::conditional< + std::is_void::value, + std::true_type, + std::is_convertible, R>>::type {}; + } // namespace impl + + template < typename R, typename F, typename... Args > + struct is_invocable_r // NOLINT + : impl::is_invocable_r_impl {}; + + template < typename F, typename... Args > + using is_invocable = is_invocable_r; +} // namespace invoke_hpp + +// +// apply +// + +namespace invoke_hpp +{ + namespace impl + { + template < typename F, typename Tuple, std::size_t... I > + constexpr auto apply_impl(F&& f, Tuple&& args, index_sequence) // NOLINT + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + invoke_hpp::invoke( + std::forward(f), + std::get(std::forward(args))...)) + } + + template < typename F, typename Tuple > + constexpr auto apply(F&& f, Tuple&& args) + INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( + impl::apply_impl( + std::forward(f), + std::forward(args), + make_index_sequence::type>::value>())) +} // namespace invoke_hpp + +#undef INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN diff --git a/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml b/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml index baad311f0a..fc909dab30 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml +++ b/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml @@ -26,6 +26,7 @@ conversions: "dragonBones::": "dragonbones." "cc::gfx::": "gfx." "cc::pipeline::": "nr." + "cc::render::": "render." "cc::scene::": "jsb." "cc::geometry::": "jsb." "cc::event::": "jsb." diff --git a/native/tools/tojs/genbindings.py b/native/tools/tojs/genbindings.py index e0c655a34a..6e1e7e4c5f 100755 --- a/native/tools/tojs/genbindings.py +++ b/native/tools/tojs/genbindings.py @@ -21,6 +21,7 @@ defaultSections = [ 'network', 'gfx', 'pipeline', + 'render', 'spine', 'editor_support', 'dragonbones', diff --git a/native/tools/tojs/render.ini b/native/tools/tojs/render.ini new file mode 100644 index 0000000000..3d4df80305 --- /dev/null +++ b/native/tools/tojs/render.ini @@ -0,0 +1,78 @@ +[render] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = render + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = render + +macro_judgement = + +android_headers = + +android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include + +clang_headers = +clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -mfloat-abi=soft -U__SSE__ + +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources +cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 + + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h + +hpp_headers = + +cpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_scene_auto.h cocos/renderer/pipeline/custom/RenderCommonJsb.h cocos/renderer/pipeline/custom/RenderGraphJsb.h + +replace_headers = + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu.*$". + +classes = DescriptorHierarchy Setter RasterQueueBuilder RasterPassBuilder ComputeQueueBuilder ComputePassBuilder MovePassBuilder CopyPassBuilder Pipeline + +classes_need_extend = + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = + +skip_public_fields = + +getter_setter = + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = DescriptorHierarchy Setter RasterQueueBuilder RasterPassBuilder ComputeQueueBuilder ComputePassBuilder MovePassBuilder CopyPassBuilder Pipeline + +persistent_classes = + +classes_owned_by_cpp = + +obtain_return_value =