From f3ee5c87a9cea943f9a768983fead2b5fe97de67 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Mon, 30 Dec 2024 17:21:29 +0800 Subject: [PATCH] Move classes from interface to implementation (#18091) --- cocos/rendering/custom/layout-graph-editor.ts | 20 +- cocos/rendering/custom/layout-graph-names.ts | 26 + cocos/rendering/custom/layout-graph-utils.ts | 20 +- cocos/rendering/custom/layout-graph.ts | 564 +++++++++++++++++- cocos/rendering/custom/types-names.ts | 27 +- cocos/rendering/custom/types.ts | 232 +------ cocos/rendering/custom/web-program-library.ts | 21 +- .../renderer/pipeline/custom/LayoutGraphFwd.h | 11 + .../pipeline/custom/LayoutGraphNames.h | 23 + .../custom/LayoutGraphSerialization.cpp | 142 +++++ .../custom/LayoutGraphSerialization.h | 27 + .../pipeline/custom/LayoutGraphTypes.cpp | 68 ++- .../pipeline/custom/LayoutGraphTypes.h | 157 +++++ .../pipeline/custom/RenderCommonFwd.h | 8 +- .../pipeline/custom/RenderCommonJsb.cpp | 138 ----- .../pipeline/custom/RenderCommonJsb.h | 15 - .../pipeline/custom/RenderCommonNames.h | 35 +- .../custom/RenderCommonSerialization.cpp | 56 -- .../custom/RenderCommonSerialization.h | 12 - .../pipeline/custom/RenderCommonTypes.h | 71 +-- 20 files changed, 1110 insertions(+), 563 deletions(-) diff --git a/cocos/rendering/custom/layout-graph-editor.ts b/cocos/rendering/custom/layout-graph-editor.ts index 505f004e240..31affe29667 100644 --- a/cocos/rendering/custom/layout-graph-editor.ts +++ b/cocos/rendering/custom/layout-graph-editor.ts @@ -27,10 +27,24 @@ import { EffectAsset } from '../../asset/assets'; import { assert, error, warn } from '../../core'; import { ShaderStageFlagBit, Type, Uniform, UniformBlock } from '../../gfx'; import { DefaultVisitor, depthFirstSearch, GraphColor, MutableVertexPropertyMap } from './graph'; -import { DescriptorBlockData, DescriptorData, DescriptorDB, DescriptorSetData, LayoutGraph, LayoutGraphData, LayoutGraphDataValue, LayoutGraphValue, PipelineLayoutData, RenderPassType, RenderPhase, RenderPhaseData, RenderStageData, ShaderProgramData } from './layout-graph'; +import { + Descriptor, + DescriptorBlock, + DescriptorBlockData, + DescriptorBlockFlattened, + DescriptorBlockIndex, + DescriptorData, DescriptorDB, DescriptorSetData, + DescriptorTypeOrder, + LayoutGraph, LayoutGraphData, LayoutGraphDataValue, LayoutGraphValue, + PipelineLayoutData, RenderPassType, RenderPhase, RenderPhaseData, + RenderStageData, ShaderProgramData, +} from './layout-graph'; +import { getDescriptorTypeOrderName } from './layout-graph-names'; import { ENABLE_SUBPASS, getOrCreateDescriptorID, sortDescriptorBlocks } from './layout-graph-utils'; -import { UpdateFrequency, Descriptor, DescriptorBlock, DescriptorBlockFlattened, DescriptorBlockIndex, DescriptorTypeOrder, ParameterType } from './types'; -import { getUpdateFrequencyName, getDescriptorTypeOrderName } from './types-names'; +import { + ParameterType, UpdateFrequency, +} from './types'; +import { getUpdateFrequencyName } from './types-names'; export function getLayoutGraphDataVersion (): number { return 0; diff --git a/cocos/rendering/custom/layout-graph-names.ts b/cocos/rendering/custom/layout-graph-names.ts index 398a73cfedb..363f52fcfd7 100644 --- a/cocos/rendering/custom/layout-graph-names.ts +++ b/cocos/rendering/custom/layout-graph-names.ts @@ -27,3 +27,29 @@ * The following section is auto-generated. * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= */ +import { DescriptorTypeOrder } from './layout-graph'; + +export function getDescriptorTypeOrderName (e: DescriptorTypeOrder): string { + switch (e) { + case DescriptorTypeOrder.UNIFORM_BUFFER: + return 'UNIFORM_BUFFER'; + case DescriptorTypeOrder.DYNAMIC_UNIFORM_BUFFER: + return 'DYNAMIC_UNIFORM_BUFFER'; + case DescriptorTypeOrder.SAMPLER_TEXTURE: + return 'SAMPLER_TEXTURE'; + case DescriptorTypeOrder.SAMPLER: + return 'SAMPLER'; + case DescriptorTypeOrder.TEXTURE: + return 'TEXTURE'; + case DescriptorTypeOrder.STORAGE_BUFFER: + return 'STORAGE_BUFFER'; + case DescriptorTypeOrder.DYNAMIC_STORAGE_BUFFER: + return 'DYNAMIC_STORAGE_BUFFER'; + case DescriptorTypeOrder.STORAGE_IMAGE: + return 'STORAGE_IMAGE'; + case DescriptorTypeOrder.INPUT_ATTACHMENT: + return 'INPUT_ATTACHMENT'; + default: + return ''; + } +} diff --git a/cocos/rendering/custom/layout-graph-utils.ts b/cocos/rendering/custom/layout-graph-utils.ts index b152c07107a..8fe3a5d9900 100644 --- a/cocos/rendering/custom/layout-graph-utils.ts +++ b/cocos/rendering/custom/layout-graph-utils.ts @@ -23,13 +23,25 @@ ****************************************************************************/ /* eslint-disable max-len */ -import type { LayoutGraphData, PipelineLayoutData, RenderPhaseData } from './layout-graph'; -import { DescriptorBlockData, DescriptorData, DescriptorSetLayoutData, LayoutGraphDataValue } from './layout-graph'; import { EffectAsset } from '../../asset/assets'; import { assert, error, warn } from '../../core'; import { DescriptorSetInfo, DescriptorSetLayout, DescriptorSetLayoutBinding, DescriptorSetLayoutInfo, DescriptorType, Device, Feature, Format, FormatFeatureBit, GetTypeSize, PipelineLayout, PipelineLayoutInfo, ShaderStageFlagBit, Type, Uniform, UniformBlock } from '../../gfx'; -import { UBOForwardLight, UBOForwardLightEnum, UBOSkinning } from '../define'; -import { UpdateFrequency, DescriptorBlockIndex, DescriptorTypeOrder, ParameterType } from './types'; +import { UBOForwardLightEnum, UBOSkinning } from '../define'; +import type { + LayoutGraphData, + PipelineLayoutData, RenderPhaseData, +} from './layout-graph'; +import { + DescriptorBlockData, + DescriptorBlockIndex, + DescriptorData, + DescriptorSetLayoutData, + DescriptorTypeOrder, + LayoutGraphDataValue, +} from './layout-graph'; +import { + ParameterType, UpdateFrequency, +} from './types'; export const INVALID_ID = 0xFFFFFFFF; export const ENABLE_SUBPASS = true; diff --git a/cocos/rendering/custom/layout-graph.ts b/cocos/rendering/custom/layout-graph.ts index 4606d0a302f..86d55808a99 100644 --- a/cocos/rendering/custom/layout-graph.ts +++ b/cocos/rendering/custom/layout-graph.ts @@ -30,8 +30,8 @@ /* eslint-disable max-len */ import { AddressableGraph, AdjI, AdjacencyGraph, BidirectionalGraph, ComponentGraph, ED, InEI, MutableGraph, MutableReferenceGraph, NamedGraph, OutE, OutEI, PolymorphicGraph, PropertyGraph, ReferenceGraph, VertexListGraph, findRelative, getPath } from './graph'; import type { DescriptorSet, DescriptorSetLayout, PipelineLayout } from '../../gfx'; -import { DescriptorSetLayoutInfo, ShaderStageFlagBit, Type, UniformBlock } from '../../gfx'; -import { DescriptorBlock, saveDescriptorBlock, loadDescriptorBlock, DescriptorBlockIndex, saveDescriptorBlockIndex, loadDescriptorBlockIndex, DescriptorTypeOrder, UpdateFrequency, RenderCommonObjectPool } from './types'; +import { DescriptorSetLayoutInfo, Format, ShaderStageFlagBit, Type, UniformBlock } from '../../gfx'; +import { AccessType, ParameterType, UpdateFrequency, ViewDimension, RenderCommonObjectPool } from './types'; import { RecyclePool } from '../../core/memop'; import type { OutputArchive, InputArchive } from './archive'; import { saveUniformBlock, loadUniformBlock, saveDescriptorSetLayoutInfo, loadDescriptorSetLayoutInfo } from './serialization'; @@ -40,6 +40,113 @@ function resetDescriptorSetLayoutInfo (info: DescriptorSetLayoutInfo): void { info.bindings.length = 0; } +export const enum DescriptorTypeOrder { + UNIFORM_BUFFER, + DYNAMIC_UNIFORM_BUFFER, + SAMPLER_TEXTURE, + SAMPLER, + TEXTURE, + STORAGE_BUFFER, + DYNAMIC_STORAGE_BUFFER, + STORAGE_IMAGE, + INPUT_ATTACHMENT, +} + +export class Descriptor { + constructor (type: Type = Type.UNKNOWN) { + this.type = type; + } + reset (type: Type): void { + this.type = type; + this.count = 1; + } + declare type: Type; + count = 1; +} + +export class DescriptorBlock { + reset (): void { + this.descriptors.clear(); + this.uniformBlocks.clear(); + this.capacity = 0; + this.count = 0; + } + readonly descriptors: Map = new Map(); + readonly uniformBlocks: Map = new Map(); + capacity = 0; + count = 0; +} + +export class DescriptorBlockFlattened { + reset (): void { + this.descriptorNames.length = 0; + this.uniformBlockNames.length = 0; + this.descriptors.length = 0; + this.uniformBlocks.length = 0; + this.capacity = 0; + this.count = 0; + } + readonly descriptorNames: string[] = []; + readonly uniformBlockNames: string[] = []; + readonly descriptors: Descriptor[] = []; + readonly uniformBlocks: UniformBlock[] = []; + capacity = 0; + count = 0; +} + +export class DescriptorBlockIndex { + constructor (updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, parameterType: ParameterType = ParameterType.CONSTANTS, descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE) { + this.updateFrequency = updateFrequency; + this.parameterType = parameterType; + this.descriptorType = descriptorType; + this.visibility = visibility; + } + declare updateFrequency: UpdateFrequency; + declare parameterType: ParameterType; + declare descriptorType: DescriptorTypeOrder; + declare visibility: ShaderStageFlagBit; +} + +export class DescriptorGroupBlockIndex { + constructor ( + updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, + parameterType: ParameterType = ParameterType.CONSTANTS, + descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, + visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, + accessType: AccessType = AccessType.READ, + viewDimension: ViewDimension = ViewDimension.TEX2D, + format: Format = Format.UNKNOWN, + ) { + this.updateFrequency = updateFrequency; + this.parameterType = parameterType; + this.descriptorType = descriptorType; + this.visibility = visibility; + this.accessType = accessType; + this.viewDimension = viewDimension; + this.format = format; + } + declare updateFrequency: UpdateFrequency; + declare parameterType: ParameterType; + declare descriptorType: DescriptorTypeOrder; + declare visibility: ShaderStageFlagBit; + declare accessType: AccessType; + declare viewDimension: ViewDimension; + declare format: Format; +} + +export class DescriptorGroupBlock { + reset (): void { + this.descriptors.clear(); + this.uniformBlocks.clear(); + this.capacity = 0; + this.count = 0; + } + readonly descriptors: Map = new Map(); + readonly uniformBlocks: Map = new Map(); + capacity = 0; + count = 0; +} + export class DescriptorDB { reset (): void { this.blocks.clear(); @@ -471,11 +578,101 @@ export class DescriptorSetData { declare /*refcount*/ descriptorSet: DescriptorSet | null; } +export class DescriptorGroupBlockData { + constructor ( + type: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, + visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, + accessType: AccessType = AccessType.READ, + viewDimension: ViewDimension = ViewDimension.TEX2D, + format: Format = Format.UNKNOWN, + capacity = 0, + ) { + this.type = type; + this.visibility = visibility; + this.accessType = accessType; + this.viewDimension = viewDimension; + this.format = format; + this.capacity = capacity; + } + reset ( + type: DescriptorTypeOrder, + visibility: ShaderStageFlagBit, + accessType: AccessType, + viewDimension: ViewDimension, + format: Format, + capacity: number, + ): void { + this.type = type; + this.visibility = visibility; + this.accessType = accessType; + this.viewDimension = viewDimension; + this.format = format; + this.offset = 0; + this.capacity = capacity; + this.descriptors.length = 0; + } + declare type: DescriptorTypeOrder; + declare visibility: ShaderStageFlagBit; + declare accessType: AccessType; + declare viewDimension: ViewDimension; + declare format: Format; + offset = 0; + declare capacity: number; + readonly descriptors: DescriptorData[] = []; +} + +export class DescriptorGroupLayoutData { + constructor ( + slot = 0xFFFFFFFF, + capacity = 0, + descriptorGroupBlocks: DescriptorGroupBlockData[] = [], + uniformBlocks: Map = new Map(), + bindingMap: Map = new Map(), + ) { + this.slot = slot; + this.capacity = capacity; + this.descriptorGroupBlocks = descriptorGroupBlocks; + this.uniformBlocks = uniformBlocks; + this.bindingMap = bindingMap; + } + reset ( + slot: number, + capacity: number, + ): void { + this.slot = slot; + this.capacity = capacity; + this.uniformBlockCapacity = 0; + this.samplerTextureCapacity = 0; + this.descriptorGroupBlocks.length = 0; + this.uniformBlocks.clear(); + this.bindingMap.clear(); + } + declare slot: number; + declare capacity: number; + uniformBlockCapacity = 0; + samplerTextureCapacity = 0; + declare readonly descriptorGroupBlocks: DescriptorGroupBlockData[]; + declare readonly uniformBlocks: Map; + declare readonly bindingMap: Map; +} + +export class DescriptorGroupData { + constructor (descriptorGroupLayoutData: DescriptorGroupLayoutData = new DescriptorGroupLayoutData()) { + this.descriptorGroupLayoutData = descriptorGroupLayoutData; + } + reset (): void { + this.descriptorGroupLayoutData.reset(0xFFFFFFFF, 0); + } + declare readonly descriptorGroupLayoutData: DescriptorGroupLayoutData; +} + export class PipelineLayoutData { reset (): void { this.descriptorSets.clear(); + this.descriptorGroups.clear(); } readonly descriptorSets: Map = new Map(); + readonly descriptorGroups: Map = new Map(); } export class ShaderBindingData { @@ -866,6 +1063,12 @@ export class LayoutGraphObjectPool { this.renderCommon = renderCommon; } reset (): void { + this.d.reset(); // Descriptor + this.db.reset(); // DescriptorBlock + this.dbf.reset(); // DescriptorBlockFlattened + this.dbi.reset(); // DescriptorBlockIndex + this.dgbi.reset(); // DescriptorGroupBlockIndex + this.dgb.reset(); // DescriptorGroupBlock this.dd.reset(); // DescriptorDB this.rp.reset(); // RenderPhase this.lg.reset(); // LayoutGraph @@ -875,6 +1078,9 @@ export class LayoutGraphObjectPool { this.dbd.reset(); // DescriptorBlockData this.dsld.reset(); // DescriptorSetLayoutData this.dsd.reset(); // DescriptorSetData + this.dgbd.reset(); // DescriptorGroupBlockData + this.dgld.reset(); // DescriptorGroupLayoutData + this.dgd.reset(); // DescriptorGroupData this.pld.reset(); // PipelineLayoutData this.sbd.reset(); // ShaderBindingData this.sld.reset(); // ShaderLayoutData @@ -885,6 +1091,60 @@ export class LayoutGraphObjectPool { this.rpd.reset(); // RenderPhaseData this.lgd.reset(); // LayoutGraphData } + createDescriptor ( + type: Type = Type.UNKNOWN, + ): Descriptor { + const v = this.d.add(); // Descriptor + v.reset(type); + return v; + } + createDescriptorBlock (): DescriptorBlock { + const v = this.db.add(); // DescriptorBlock + v.reset(); + return v; + } + createDescriptorBlockFlattened (): DescriptorBlockFlattened { + const v = this.dbf.add(); // DescriptorBlockFlattened + v.reset(); + return v; + } + createDescriptorBlockIndex ( + updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, + parameterType: ParameterType = ParameterType.CONSTANTS, + descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, + visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, + ): DescriptorBlockIndex { + const v = this.dbi.add(); // DescriptorBlockIndex + v.updateFrequency = updateFrequency; + v.parameterType = parameterType; + v.descriptorType = descriptorType; + v.visibility = visibility; + return v; + } + createDescriptorGroupBlockIndex ( + updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, + parameterType: ParameterType = ParameterType.CONSTANTS, + descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, + visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, + accessType: AccessType = AccessType.READ, + viewDimension: ViewDimension = ViewDimension.TEX2D, + format: Format = Format.UNKNOWN, + ): DescriptorGroupBlockIndex { + const v = this.dgbi.add(); // DescriptorGroupBlockIndex + v.updateFrequency = updateFrequency; + v.parameterType = parameterType; + v.descriptorType = descriptorType; + v.visibility = visibility; + v.accessType = accessType; + v.viewDimension = viewDimension; + v.format = format; + return v; + } + createDescriptorGroupBlock (): DescriptorGroupBlock { + const v = this.dgb.add(); // DescriptorGroupBlock + v.reset(); + return v; + } createDescriptorDB (): DescriptorDB { const v = this.dd.add(); // DescriptorDB v.reset(); @@ -948,6 +1208,31 @@ export class LayoutGraphObjectPool { v.reset(descriptorSetLayout, descriptorSet); return v; } + createDescriptorGroupBlockData ( + type: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, + visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, + accessType: AccessType = AccessType.READ, + viewDimension: ViewDimension = ViewDimension.TEX2D, + format: Format = Format.UNKNOWN, + capacity = 0, + ): DescriptorGroupBlockData { + const v = this.dgbd.add(); // DescriptorGroupBlockData + v.reset(type, visibility, accessType, viewDimension, format, capacity); + return v; + } + createDescriptorGroupLayoutData ( + slot = 0xFFFFFFFF, + capacity = 0, + ): DescriptorGroupLayoutData { + const v = this.dgld.add(); // DescriptorGroupLayoutData + v.reset(slot, capacity); + return v; + } + createDescriptorGroupData (): DescriptorGroupData { + const v = this.dgd.add(); // DescriptorGroupData + v.reset(); + return v; + } createPipelineLayoutData (): PipelineLayoutData { const v = this.pld.add(); // PipelineLayoutData v.reset(); @@ -994,6 +1279,12 @@ export class LayoutGraphObjectPool { return v; } public readonly renderCommon: RenderCommonObjectPool; + private readonly d: RecyclePool = createPool(Descriptor); + private readonly db: RecyclePool = createPool(DescriptorBlock); + private readonly dbf: RecyclePool = createPool(DescriptorBlockFlattened); + private readonly dbi: RecyclePool = createPool(DescriptorBlockIndex); + private readonly dgbi: RecyclePool = createPool(DescriptorGroupBlockIndex); + private readonly dgb: RecyclePool = createPool(DescriptorGroupBlock); private readonly dd: RecyclePool = createPool(DescriptorDB); private readonly rp: RecyclePool = createPool(RenderPhase); private readonly lg: RecyclePool = createPool(LayoutGraph); @@ -1003,6 +1294,9 @@ export class LayoutGraphObjectPool { private readonly dbd: RecyclePool = createPool(DescriptorBlockData); private readonly dsld: RecyclePool = createPool(DescriptorSetLayoutData); private readonly dsd: RecyclePool = createPool(DescriptorSetData); + private readonly dgbd: RecyclePool = createPool(DescriptorGroupBlockData); + private readonly dgld: RecyclePool = createPool(DescriptorGroupLayoutData); + private readonly dgd: RecyclePool = createPool(DescriptorGroupData); private readonly pld: RecyclePool = createPool(PipelineLayoutData); private readonly sbd: RecyclePool = createPool(ShaderBindingData); private readonly sld: RecyclePool = createPool(ShaderLayoutData); @@ -1014,6 +1308,171 @@ export class LayoutGraphObjectPool { private readonly lgd: RecyclePool = createPool(LayoutGraphData); } +export function saveDescriptor (a: OutputArchive, v: Descriptor): void { + a.n(v.type); + a.n(v.count); +} + +export function loadDescriptor (a: InputArchive, v: Descriptor): void { + v.type = a.n(); + v.count = a.n(); +} + +export function saveDescriptorBlock (a: OutputArchive, v: DescriptorBlock): void { + a.n(v.descriptors.size); // Map + for (const [k1, v1] of v.descriptors) { + a.s(k1); + saveDescriptor(a, v1); + } + a.n(v.uniformBlocks.size); // Map + for (const [k1, v1] of v.uniformBlocks) { + a.s(k1); + saveUniformBlock(a, v1); + } + a.n(v.capacity); + a.n(v.count); +} + +export function loadDescriptorBlock (a: InputArchive, v: DescriptorBlock): void { + let sz = 0; + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.s(); + const v1 = new Descriptor(); + loadDescriptor(a, v1); + v.descriptors.set(k1, v1); + } + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.s(); + const v1 = new UniformBlock(); + loadUniformBlock(a, v1); + v.uniformBlocks.set(k1, v1); + } + v.capacity = a.n(); + v.count = a.n(); +} + +export function saveDescriptorBlockFlattened (a: OutputArchive, v: DescriptorBlockFlattened): void { + a.n(v.descriptorNames.length); // string[] + for (const v1 of v.descriptorNames) { + a.s(v1); + } + a.n(v.uniformBlockNames.length); // string[] + for (const v1 of v.uniformBlockNames) { + a.s(v1); + } + a.n(v.descriptors.length); // Descriptor[] + for (const v1 of v.descriptors) { + saveDescriptor(a, v1); + } + a.n(v.uniformBlocks.length); // UniformBlock[] + for (const v1 of v.uniformBlocks) { + saveUniformBlock(a, v1); + } + a.n(v.capacity); + a.n(v.count); +} + +export function loadDescriptorBlockFlattened (a: InputArchive, v: DescriptorBlockFlattened): void { + let sz = 0; + sz = a.n(); // string[] + v.descriptorNames.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + v.descriptorNames[i1] = a.s(); + } + sz = a.n(); // string[] + v.uniformBlockNames.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + v.uniformBlockNames[i1] = a.s(); + } + sz = a.n(); // Descriptor[] + v.descriptors.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + const v1 = new Descriptor(); + loadDescriptor(a, v1); + v.descriptors[i1] = v1; + } + sz = a.n(); // UniformBlock[] + v.uniformBlocks.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + const v1 = new UniformBlock(); + loadUniformBlock(a, v1); + v.uniformBlocks[i1] = v1; + } + v.capacity = a.n(); + v.count = a.n(); +} + +export function saveDescriptorBlockIndex (a: OutputArchive, v: DescriptorBlockIndex): void { + a.n(v.updateFrequency); + a.n(v.parameterType); + a.n(v.descriptorType); + a.n(v.visibility); +} + +export function loadDescriptorBlockIndex (a: InputArchive, v: DescriptorBlockIndex): void { + v.updateFrequency = a.n(); + v.parameterType = a.n(); + v.descriptorType = a.n(); + v.visibility = a.n(); +} + +export function saveDescriptorGroupBlockIndex (a: OutputArchive, v: DescriptorGroupBlockIndex): void { + a.n(v.updateFrequency); + a.n(v.parameterType); + a.n(v.descriptorType); + a.n(v.visibility); + a.n(v.accessType); + a.n(v.viewDimension); + a.n(v.format); +} + +export function loadDescriptorGroupBlockIndex (a: InputArchive, v: DescriptorGroupBlockIndex): void { + v.updateFrequency = a.n(); + v.parameterType = a.n(); + v.descriptorType = a.n(); + v.visibility = a.n(); + v.accessType = a.n(); + v.viewDimension = a.n(); + v.format = a.n(); +} + +export function saveDescriptorGroupBlock (a: OutputArchive, v: DescriptorGroupBlock): void { + a.n(v.descriptors.size); // Map + for (const [k1, v1] of v.descriptors) { + a.s(k1); + saveDescriptor(a, v1); + } + a.n(v.uniformBlocks.size); // Map + for (const [k1, v1] of v.uniformBlocks) { + a.s(k1); + saveUniformBlock(a, v1); + } + a.n(v.capacity); + a.n(v.count); +} + +export function loadDescriptorGroupBlock (a: InputArchive, v: DescriptorGroupBlock): void { + let sz = 0; + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.s(); + const v1 = new Descriptor(); + loadDescriptor(a, v1); + v.descriptors.set(k1, v1); + } + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.s(); + const v1 = new UniformBlock(); + loadUniformBlock(a, v1); + v.uniformBlocks.set(k1, v1); + } + v.capacity = a.n(); + v.count = a.n(); +} + export function saveDescriptorDB (a: OutputArchive, v: DescriptorDB): void { a.n(v.blocks.size); // Map for (const [k1, v1] of v.blocks) { @@ -1253,12 +1712,106 @@ export function loadDescriptorSetData (a: InputArchive, v: DescriptorSetData): v // skip, v.descriptorSet: DescriptorSet } +export function saveDescriptorGroupBlockData (a: OutputArchive, v: DescriptorGroupBlockData): void { + a.n(v.type); + a.n(v.visibility); + a.n(v.accessType); + a.n(v.viewDimension); + a.n(v.format); + a.n(v.offset); + a.n(v.capacity); + a.n(v.descriptors.length); // DescriptorData[] + for (const v1 of v.descriptors) { + saveDescriptorData(a, v1); + } +} + +export function loadDescriptorGroupBlockData (a: InputArchive, v: DescriptorGroupBlockData): void { + v.type = a.n(); + v.visibility = a.n(); + v.accessType = a.n(); + v.viewDimension = a.n(); + v.format = a.n(); + v.offset = a.n(); + v.capacity = a.n(); + let sz = 0; + sz = a.n(); // DescriptorData[] + v.descriptors.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + const v1 = new DescriptorData(); + loadDescriptorData(a, v1); + v.descriptors[i1] = v1; + } +} + +export function saveDescriptorGroupLayoutData (a: OutputArchive, v: DescriptorGroupLayoutData): void { + a.n(v.slot); + a.n(v.capacity); + a.n(v.uniformBlockCapacity); + a.n(v.samplerTextureCapacity); + a.n(v.descriptorGroupBlocks.length); // DescriptorGroupBlockData[] + for (const v1 of v.descriptorGroupBlocks) { + saveDescriptorGroupBlockData(a, v1); + } + a.n(v.uniformBlocks.size); // Map + for (const [k1, v1] of v.uniformBlocks) { + a.n(k1); + saveUniformBlock(a, v1); + } + a.n(v.bindingMap.size); // Map + for (const [k1, v1] of v.bindingMap) { + a.n(k1); + a.n(v1); + } +} + +export function loadDescriptorGroupLayoutData (a: InputArchive, v: DescriptorGroupLayoutData): void { + v.slot = a.n(); + v.capacity = a.n(); + v.uniformBlockCapacity = a.n(); + v.samplerTextureCapacity = a.n(); + let sz = 0; + sz = a.n(); // DescriptorGroupBlockData[] + v.descriptorGroupBlocks.length = sz; + for (let i1 = 0; i1 !== sz; ++i1) { + const v1 = new DescriptorGroupBlockData(); + loadDescriptorGroupBlockData(a, v1); + v.descriptorGroupBlocks[i1] = v1; + } + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.n(); + const v1 = new UniformBlock(); + loadUniformBlock(a, v1); + v.uniformBlocks.set(k1, v1); + } + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.n(); + const v1 = a.n(); + v.bindingMap.set(k1, v1); + } +} + +export function saveDescriptorGroupData (a: OutputArchive, v: DescriptorGroupData): void { + saveDescriptorGroupLayoutData(a, v.descriptorGroupLayoutData); +} + +export function loadDescriptorGroupData (a: InputArchive, v: DescriptorGroupData): void { + loadDescriptorGroupLayoutData(a, v.descriptorGroupLayoutData); +} + export function savePipelineLayoutData (a: OutputArchive, v: PipelineLayoutData): void { a.n(v.descriptorSets.size); // Map for (const [k1, v1] of v.descriptorSets) { a.n(k1); saveDescriptorSetData(a, v1); } + a.n(v.descriptorGroups.size); // Map + for (const [k1, v1] of v.descriptorGroups) { + a.n(k1); + saveDescriptorGroupData(a, v1); + } } export function loadPipelineLayoutData (a: InputArchive, v: PipelineLayoutData): void { @@ -1270,6 +1823,13 @@ export function loadPipelineLayoutData (a: InputArchive, v: PipelineLayoutData): loadDescriptorSetData(a, v1); v.descriptorSets.set(k1, v1); } + sz = a.n(); // Map + for (let i1 = 0; i1 !== sz; ++i1) { + const k1 = a.n(); + const v1 = new DescriptorGroupData(); + loadDescriptorGroupData(a, v1); + v.descriptorGroups.set(k1, v1); + } } export function saveShaderBindingData (a: OutputArchive, v: ShaderBindingData): void { diff --git a/cocos/rendering/custom/types-names.ts b/cocos/rendering/custom/types-names.ts index a4c4db17d71..9b76b628134 100644 --- a/cocos/rendering/custom/types-names.ts +++ b/cocos/rendering/custom/types-names.ts @@ -27,7 +27,7 @@ * The following section is auto-generated. * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= */ -import { DescriptorTypeOrder, UpdateFrequency } from './types' +import { UpdateFrequency } from './types'; export function getUpdateFrequencyName (e: UpdateFrequency): string { switch (e) { @@ -45,28 +45,3 @@ export function getUpdateFrequencyName (e: UpdateFrequency): string { return ''; } } - -export function getDescriptorTypeOrderName (e: DescriptorTypeOrder): string { - switch (e) { - case DescriptorTypeOrder.UNIFORM_BUFFER: - return 'UNIFORM_BUFFER'; - case DescriptorTypeOrder.DYNAMIC_UNIFORM_BUFFER: - return 'DYNAMIC_UNIFORM_BUFFER'; - case DescriptorTypeOrder.SAMPLER_TEXTURE: - return 'SAMPLER_TEXTURE'; - case DescriptorTypeOrder.SAMPLER: - return 'SAMPLER'; - case DescriptorTypeOrder.TEXTURE: - return 'TEXTURE'; - case DescriptorTypeOrder.STORAGE_BUFFER: - return 'STORAGE_BUFFER'; - case DescriptorTypeOrder.DYNAMIC_STORAGE_BUFFER: - return 'DYNAMIC_STORAGE_BUFFER'; - case DescriptorTypeOrder.STORAGE_IMAGE: - return 'STORAGE_IMAGE'; - case DescriptorTypeOrder.INPUT_ATTACHMENT: - return 'INPUT_ATTACHMENT'; - default: - return ''; - } -} diff --git a/cocos/rendering/custom/types.ts b/cocos/rendering/custom/types.ts index 7d0e2497b53..4d0812544c8 100644 --- a/cocos/rendering/custom/types.ts +++ b/cocos/rendering/custom/types.ts @@ -28,7 +28,7 @@ * ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! ========================= */ /* eslint-disable max-len */ -import { ResolveMode, ShaderStageFlagBit, Type, UniformBlock } from '../../gfx'; +import { ResolveMode } from '../../gfx'; import type { ReflectionProbe } from '../../render-scene/scene/reflection-probe'; import type { Light } from '../../render-scene/scene'; import { RecyclePool } from '../../core/memop'; @@ -77,6 +77,21 @@ export enum ResourceDimension { TEXTURE3D, } +export enum ViewDimension { + UNKNOWN, + BUFFER, + TEX1D, + TEX1DARRAY, + TEX2D, + TEX2DARRAY, + TEX2DMS, + TEX2DMSARRAY, + TEX3D, + TEXCUBE, + TEXCUBEARRAY, + RAYTRACING_ACCELERATION_STRUCTURE, +} + export enum ResourceFlags { NONE = 0, UNIFORM = 0x1, @@ -163,73 +178,6 @@ export class LightInfo { declare culledByLight: boolean; } -export const enum DescriptorTypeOrder { - UNIFORM_BUFFER, - DYNAMIC_UNIFORM_BUFFER, - SAMPLER_TEXTURE, - SAMPLER, - TEXTURE, - STORAGE_BUFFER, - DYNAMIC_STORAGE_BUFFER, - STORAGE_IMAGE, - INPUT_ATTACHMENT, -} - -export class Descriptor { - constructor (type: Type = Type.UNKNOWN) { - this.type = type; - } - reset (type: Type): void { - this.type = type; - this.count = 1; - } - declare type: Type; - count = 1; -} - -export class DescriptorBlock { - reset (): void { - this.descriptors.clear(); - this.uniformBlocks.clear(); - this.capacity = 0; - this.count = 0; - } - readonly descriptors: Map = new Map(); - readonly uniformBlocks: Map = new Map(); - capacity = 0; - count = 0; -} - -export class DescriptorBlockFlattened { - reset (): void { - this.descriptorNames.length = 0; - this.uniformBlockNames.length = 0; - this.descriptors.length = 0; - this.uniformBlocks.length = 0; - this.capacity = 0; - this.count = 0; - } - readonly descriptorNames: string[] = []; - readonly uniformBlockNames: string[] = []; - readonly descriptors: Descriptor[] = []; - readonly uniformBlocks: UniformBlock[] = []; - capacity = 0; - count = 0; -} - -export class DescriptorBlockIndex { - constructor (updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, parameterType: ParameterType = ParameterType.CONSTANTS, descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE) { - this.updateFrequency = updateFrequency; - this.parameterType = parameterType; - this.descriptorType = descriptorType; - this.visibility = visibility; - } - declare updateFrequency: UpdateFrequency; - declare parameterType: ParameterType; - declare descriptorType: DescriptorTypeOrder; - declare visibility: ShaderStageFlagBit; -} - export const enum ResolveFlags { NONE = 0, COLOR = 1 << 0, @@ -453,10 +401,6 @@ export class RenderCommonObjectPool { } reset (): void { this.li.reset(); // LightInfo - this.d.reset(); // Descriptor - this.db.reset(); // DescriptorBlock - this.dbf.reset(); // DescriptorBlockFlattened - this.dbi.reset(); // DescriptorBlockIndex this.rp.reset(); // ResolvePair this.cp.reset(); // CopyPair this.up.reset(); // UploadPair @@ -473,36 +417,6 @@ export class RenderCommonObjectPool { v.reset(light, level, culledByLight, probe); return v; } - createDescriptor ( - type: Type = Type.UNKNOWN, - ): Descriptor { - const v = this.d.add(); // Descriptor - v.reset(type); - return v; - } - createDescriptorBlock (): DescriptorBlock { - const v = this.db.add(); // DescriptorBlock - v.reset(); - return v; - } - createDescriptorBlockFlattened (): DescriptorBlockFlattened { - const v = this.dbf.add(); // DescriptorBlockFlattened - v.reset(); - return v; - } - createDescriptorBlockIndex ( - updateFrequency: UpdateFrequency = UpdateFrequency.PER_INSTANCE, - parameterType: ParameterType = ParameterType.CONSTANTS, - descriptorType: DescriptorTypeOrder = DescriptorTypeOrder.UNIFORM_BUFFER, - visibility: ShaderStageFlagBit = ShaderStageFlagBit.NONE, - ): DescriptorBlockIndex { - const v = this.dbi.add(); // DescriptorBlockIndex - v.updateFrequency = updateFrequency; - v.parameterType = parameterType; - v.descriptorType = descriptorType; - v.visibility = visibility; - return v; - } createResolvePair ( source = '', target = '', @@ -561,10 +475,6 @@ export class RenderCommonObjectPool { return v; } private readonly li: RecyclePool = createPool(LightInfo); - private readonly d: RecyclePool = createPool(Descriptor); - private readonly db: RecyclePool = createPool(DescriptorBlock); - private readonly dbf: RecyclePool = createPool(DescriptorBlockFlattened); - private readonly dbi: RecyclePool = createPool(DescriptorBlockIndex); private readonly rp: RecyclePool = createPool(ResolvePair); private readonly cp: RecyclePool = createPool(CopyPair); private readonly up: RecyclePool = createPool(UploadPair); @@ -586,116 +496,6 @@ export function loadLightInfo (a: InputArchive, v: LightInfo): void { v.culledByLight = a.b(); } -export function saveDescriptor (a: OutputArchive, v: Descriptor): void { - a.n(v.type); - a.n(v.count); -} - -export function loadDescriptor (a: InputArchive, v: Descriptor): void { - v.type = a.n(); - v.count = a.n(); -} - -export function saveDescriptorBlock (a: OutputArchive, v: DescriptorBlock): void { - a.n(v.descriptors.size); // Map - for (const [k1, v1] of v.descriptors) { - a.s(k1); - saveDescriptor(a, v1); - } - a.n(v.uniformBlocks.size); // Map - for (const [k1, v1] of v.uniformBlocks) { - a.s(k1); - saveUniformBlock(a, v1); - } - a.n(v.capacity); - a.n(v.count); -} - -export function loadDescriptorBlock (a: InputArchive, v: DescriptorBlock): void { - let sz = 0; - sz = a.n(); // Map - for (let i1 = 0; i1 !== sz; ++i1) { - const k1 = a.s(); - const v1 = new Descriptor(); - loadDescriptor(a, v1); - v.descriptors.set(k1, v1); - } - sz = a.n(); // Map - for (let i1 = 0; i1 !== sz; ++i1) { - const k1 = a.s(); - const v1 = new UniformBlock(); - loadUniformBlock(a, v1); - v.uniformBlocks.set(k1, v1); - } - v.capacity = a.n(); - v.count = a.n(); -} - -export function saveDescriptorBlockFlattened (a: OutputArchive, v: DescriptorBlockFlattened): void { - a.n(v.descriptorNames.length); // string[] - for (const v1 of v.descriptorNames) { - a.s(v1); - } - a.n(v.uniformBlockNames.length); // string[] - for (const v1 of v.uniformBlockNames) { - a.s(v1); - } - a.n(v.descriptors.length); // Descriptor[] - for (const v1 of v.descriptors) { - saveDescriptor(a, v1); - } - a.n(v.uniformBlocks.length); // UniformBlock[] - for (const v1 of v.uniformBlocks) { - saveUniformBlock(a, v1); - } - a.n(v.capacity); - a.n(v.count); -} - -export function loadDescriptorBlockFlattened (a: InputArchive, v: DescriptorBlockFlattened): void { - let sz = 0; - sz = a.n(); // string[] - v.descriptorNames.length = sz; - for (let i1 = 0; i1 !== sz; ++i1) { - v.descriptorNames[i1] = a.s(); - } - sz = a.n(); // string[] - v.uniformBlockNames.length = sz; - for (let i1 = 0; i1 !== sz; ++i1) { - v.uniformBlockNames[i1] = a.s(); - } - sz = a.n(); // Descriptor[] - v.descriptors.length = sz; - for (let i1 = 0; i1 !== sz; ++i1) { - const v1 = new Descriptor(); - loadDescriptor(a, v1); - v.descriptors[i1] = v1; - } - sz = a.n(); // UniformBlock[] - v.uniformBlocks.length = sz; - for (let i1 = 0; i1 !== sz; ++i1) { - const v1 = new UniformBlock(); - loadUniformBlock(a, v1); - v.uniformBlocks[i1] = v1; - } - v.capacity = a.n(); - v.count = a.n(); -} - -export function saveDescriptorBlockIndex (a: OutputArchive, v: DescriptorBlockIndex): void { - a.n(v.updateFrequency); - a.n(v.parameterType); - a.n(v.descriptorType); - a.n(v.visibility); -} - -export function loadDescriptorBlockIndex (a: InputArchive, v: DescriptorBlockIndex): void { - v.updateFrequency = a.n(); - v.parameterType = a.n(); - v.descriptorType = a.n(); - v.visibility = a.n(); -} - export function saveResolvePair (a: OutputArchive, v: ResolvePair): void { a.s(v.source); a.s(v.target); diff --git a/cocos/rendering/custom/web-program-library.ts b/cocos/rendering/custom/web-program-library.ts index bc2853459f2..9591a7762fb 100644 --- a/cocos/rendering/custom/web-program-library.ts +++ b/cocos/rendering/custom/web-program-library.ts @@ -25,18 +25,23 @@ /* eslint-disable max-len */ import { EffectAsset } from '../../asset/assets'; -import { Attribute, DescriptorSetLayout, DescriptorType, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE, Device, MemoryAccessBit, PipelineLayout, PipelineLayoutInfo, Shader, ShaderInfo, ShaderStage, ShaderStageFlagBit, Type, Uniform, UniformBlock, UniformInputAttachment, UniformSampler, UniformSamplerTexture, UniformStorageBuffer, UniformStorageImage, UniformTexture, deviceManager, PipelineState, DescriptorSetLayoutInfo, DescriptorSetInfo } from '../../gfx'; -import { genHandles, getActiveAttributes, getCombinationDefines, getShaderInstanceName, getSize, getVariantKey, populateMacros, prepareDefines } from '../../render-scene/core/program-utils'; +import { assert, error, errorID } from '../../core/platform/debug'; +import { Attribute, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE, DescriptorSetInfo, DescriptorSetLayout, DescriptorSetLayoutInfo, DescriptorType, Device, deviceManager, MemoryAccessBit, PipelineLayout, PipelineLayoutInfo, PipelineState, Shader, ShaderInfo, ShaderStage, ShaderStageFlagBit, Type, Uniform, UniformBlock, UniformInputAttachment, UniformSampler, UniformSamplerTexture, UniformStorageBuffer, UniformStorageImage, UniformTexture } from '../../gfx'; import { getDeviceShaderVersion, MacroRecord } from '../../render-scene'; import { IProgramInfo } from '../../render-scene/core/program-lib'; -import { DescriptorBlockData, DescriptorData, DescriptorSetData, DescriptorSetLayoutData, LayoutGraphData, LayoutGraphDataValue, PipelineLayoutData, RenderPhaseData, ShaderProgramData } from './layout-graph'; +import { genHandles, getActiveAttributes, getCombinationDefines, getShaderInstanceName, getSize, getVariantKey, populateMacros, prepareDefines } from '../../render-scene/core/program-utils'; +import { IDescriptorSetLayoutInfo, localDescriptorSetLayout, UBOSkinning } from '../define'; +import { + DescriptorBlockData, DescriptorData, DescriptorSetData, DescriptorSetLayoutData, + DescriptorTypeOrder, + LayoutGraphData, LayoutGraphDataValue, PipelineLayoutData, + RenderPhaseData, ShaderProgramData, +} from './layout-graph'; +import { ENABLE_SUBPASS, generateConstantMacros, getCustomPassID, getCustomPhaseID, getCustomSubpassID, getDescriptorName, getDescriptorNameID, getDescriptorSetLayout, getDescriptorTypeOrder, getEmptyDescriptorSetLayout, getEmptyPipelineLayout, getOrCreateDescriptorID, getOrCreateDescriptorSetLayout, getProgramID, initializeDescriptorSetLayoutInfo, INVALID_ID, makeDescriptorSetLayoutData, populatePipelineLayoutInfo } from './layout-graph-utils'; +import { PipelineRuntime } from './pipeline'; import { ProgramLibrary, ProgramProxy } from './private'; -import { DescriptorTypeOrder, UpdateFrequency } from './types'; +import { UpdateFrequency } from './types'; import { ProgramGroup, ProgramInfo } from './web-types'; -import { getCustomPassID, getCustomPhaseID, getOrCreateDescriptorSetLayout, getEmptyDescriptorSetLayout, getEmptyPipelineLayout, initializeDescriptorSetLayoutInfo, makeDescriptorSetLayoutData, getDescriptorSetLayout, getOrCreateDescriptorID, getDescriptorTypeOrder, getProgramID, getDescriptorNameID, getDescriptorName, INVALID_ID, ENABLE_SUBPASS, getCustomSubpassID, generateConstantMacros, populatePipelineLayoutInfo } from './layout-graph-utils'; -import { assert, error, errorID } from '../../core/platform/debug'; -import { IDescriptorSetLayoutInfo, UBOSkinning, localDescriptorSetLayout } from '../define'; -import { PipelineRuntime } from './pipeline'; const _setIndex = [2, 1, 3, 0]; diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h b/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h index 44ff0ce0947..7cc86c1a9d6 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphFwd.h @@ -38,6 +38,14 @@ namespace cc { namespace render { +enum class DescriptorTypeOrder; + +struct Descriptor; +struct DescriptorBlock; +struct DescriptorBlockFlattened; +struct DescriptorBlockIndex; +struct DescriptorGroupBlockIndex; +struct DescriptorGroupBlock; struct DescriptorDB; struct RenderStageTag; struct RenderPhaseTag; @@ -56,6 +64,9 @@ struct DescriptorData; struct DescriptorBlockData; struct DescriptorSetLayoutData; struct DescriptorSetData; +struct DescriptorGroupBlockData; +struct DescriptorGroupLayoutData; +struct DescriptorGroupData; struct PipelineLayoutData; struct ShaderBindingData; struct ShaderLayoutData; diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h b/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h index 6e8e45f86b7..d1f770b25e3 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphNames.h @@ -36,6 +36,26 @@ namespace cc { namespace render { +inline const char* getName(DescriptorTypeOrder e) noexcept { + switch (e) { + case DescriptorTypeOrder::UNIFORM_BUFFER: return "UNIFORM_BUFFER"; + case DescriptorTypeOrder::DYNAMIC_UNIFORM_BUFFER: return "DYNAMIC_UNIFORM_BUFFER"; + case DescriptorTypeOrder::SAMPLER_TEXTURE: return "SAMPLER_TEXTURE"; + case DescriptorTypeOrder::SAMPLER: return "SAMPLER"; + case DescriptorTypeOrder::TEXTURE: return "TEXTURE"; + case DescriptorTypeOrder::STORAGE_BUFFER: return "STORAGE_BUFFER"; + case DescriptorTypeOrder::DYNAMIC_STORAGE_BUFFER: return "DYNAMIC_STORAGE_BUFFER"; + case DescriptorTypeOrder::STORAGE_IMAGE: return "STORAGE_IMAGE"; + case DescriptorTypeOrder::INPUT_ATTACHMENT: return "INPUT_ATTACHMENT"; + } + return ""; +} +inline const char* getName(const Descriptor& /*v*/) noexcept { return "Descriptor"; } +inline const char* getName(const DescriptorBlock& /*v*/) noexcept { return "DescriptorBlock"; } +inline const char* getName(const DescriptorBlockFlattened& /*v*/) noexcept { return "DescriptorBlockFlattened"; } +inline const char* getName(const DescriptorBlockIndex& /*v*/) noexcept { return "DescriptorBlockIndex"; } +inline const char* getName(const DescriptorGroupBlockIndex& /*v*/) noexcept { return "DescriptorGroupBlockIndex"; } +inline const char* getName(const DescriptorGroupBlock& /*v*/) noexcept { return "DescriptorGroupBlock"; } inline const char* getName(const DescriptorDB& /*v*/) noexcept { return "DescriptorDB"; } inline const char* getName(const RenderStageTag& /*v*/) noexcept { return "RenderStage"; } inline const char* getName(const RenderPhaseTag& /*v*/) noexcept { return "RenderPhase"; } @@ -56,6 +76,9 @@ inline const char* getName(const DescriptorData& /*v*/) noexcept { return "Descr inline const char* getName(const DescriptorBlockData& /*v*/) noexcept { return "DescriptorBlockData"; } inline const char* getName(const DescriptorSetLayoutData& /*v*/) noexcept { return "DescriptorSetLayoutData"; } inline const char* getName(const DescriptorSetData& /*v*/) noexcept { return "DescriptorSetData"; } +inline const char* getName(const DescriptorGroupBlockData& /*v*/) noexcept { return "DescriptorGroupBlockData"; } +inline const char* getName(const DescriptorGroupLayoutData& /*v*/) noexcept { return "DescriptorGroupLayoutData"; } +inline const char* getName(const DescriptorGroupData& /*v*/) noexcept { return "DescriptorGroupData"; } inline const char* getName(const PipelineLayoutData& /*v*/) noexcept { return "PipelineLayoutData"; } inline const char* getName(const ShaderBindingData& /*v*/) noexcept { return "ShaderBindingData"; } inline const char* getName(const ShaderLayoutData& /*v*/) noexcept { return "ShaderLayoutData"; } diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.cpp b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.cpp index 13a94b04b97..fc1545a7d7f 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.cpp +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.cpp @@ -38,6 +38,96 @@ namespace cc { namespace render { +void save(OutputArchive& ar, const Descriptor& v) { + save(ar, v.type); + save(ar, v.count); +} + +void load(InputArchive& ar, Descriptor& v) { + load(ar, v.type); + load(ar, v.count); +} + +void save(OutputArchive& ar, const DescriptorBlock& v) { + save(ar, v.descriptors); + save(ar, v.uniformBlocks); + save(ar, v.capacity); + save(ar, v.count); +} + +void load(InputArchive& ar, DescriptorBlock& v) { + load(ar, v.descriptors); + load(ar, v.uniformBlocks); + load(ar, v.capacity); + load(ar, v.count); +} + +void save(OutputArchive& ar, const DescriptorBlockFlattened& v) { + save(ar, v.descriptorNames); + save(ar, v.uniformBlockNames); + save(ar, v.descriptors); + save(ar, v.uniformBlocks); + save(ar, v.capacity); + save(ar, v.count); +} + +void load(InputArchive& ar, DescriptorBlockFlattened& v) { + load(ar, v.descriptorNames); + load(ar, v.uniformBlockNames); + load(ar, v.descriptors); + load(ar, v.uniformBlocks); + load(ar, v.capacity); + load(ar, v.count); +} + +void save(OutputArchive& ar, const DescriptorBlockIndex& v) { + save(ar, v.updateFrequency); + save(ar, v.parameterType); + save(ar, v.descriptorType); + save(ar, v.visibility); +} + +void load(InputArchive& ar, DescriptorBlockIndex& v) { + load(ar, v.updateFrequency); + load(ar, v.parameterType); + load(ar, v.descriptorType); + load(ar, v.visibility); +} + +void save(OutputArchive& ar, const DescriptorGroupBlockIndex& v) { + save(ar, v.updateFrequency); + save(ar, v.parameterType); + save(ar, v.descriptorType); + save(ar, v.visibility); + save(ar, v.accessType); + save(ar, v.viewDimension); + save(ar, v.format); +} + +void load(InputArchive& ar, DescriptorGroupBlockIndex& v) { + load(ar, v.updateFrequency); + load(ar, v.parameterType); + load(ar, v.descriptorType); + load(ar, v.visibility); + load(ar, v.accessType); + load(ar, v.viewDimension); + load(ar, v.format); +} + +void save(OutputArchive& ar, const DescriptorGroupBlock& v) { + save(ar, v.descriptors); + save(ar, v.uniformBlocks); + save(ar, v.capacity); + save(ar, v.count); +} + +void load(InputArchive& ar, DescriptorGroupBlock& v) { + load(ar, v.descriptors); + load(ar, v.uniformBlocks); + load(ar, v.capacity); + load(ar, v.count); +} + void save(OutputArchive& ar, const DescriptorDB& v) { save(ar, v.blocks); } @@ -229,12 +319,64 @@ void load(InputArchive& ar, DescriptorSetData& v) { // skip, descriptorSet: IntrusivePtr } +void save(OutputArchive& ar, const DescriptorGroupBlockData& v) { + save(ar, v.type); + save(ar, v.visibility); + save(ar, v.accessType); + save(ar, v.viewDimension); + save(ar, v.format); + save(ar, v.offset); + save(ar, v.capacity); + save(ar, v.descriptors); +} + +void load(InputArchive& ar, DescriptorGroupBlockData& v) { + load(ar, v.type); + load(ar, v.visibility); + load(ar, v.accessType); + load(ar, v.viewDimension); + load(ar, v.format); + load(ar, v.offset); + load(ar, v.capacity); + load(ar, v.descriptors); +} + +void save(OutputArchive& ar, const DescriptorGroupLayoutData& v) { + save(ar, v.slot); + save(ar, v.capacity); + save(ar, v.uniformBlockCapacity); + save(ar, v.samplerTextureCapacity); + save(ar, v.descriptorGroupBlocks); + save(ar, v.uniformBlocks); + save(ar, v.bindingMap); +} + +void load(InputArchive& ar, DescriptorGroupLayoutData& v) { + load(ar, v.slot); + load(ar, v.capacity); + load(ar, v.uniformBlockCapacity); + load(ar, v.samplerTextureCapacity); + load(ar, v.descriptorGroupBlocks); + load(ar, v.uniformBlocks); + load(ar, v.bindingMap); +} + +void save(OutputArchive& ar, const DescriptorGroupData& v) { + save(ar, v.descriptorGroupLayoutData); +} + +void load(InputArchive& ar, DescriptorGroupData& v) { + load(ar, v.descriptorGroupLayoutData); +} + void save(OutputArchive& ar, const PipelineLayoutData& v) { save(ar, v.descriptorSets); + save(ar, v.descriptorGroups); } void load(InputArchive& ar, PipelineLayoutData& v) { load(ar, v.descriptorSets); + load(ar, v.descriptorGroups); } void save(OutputArchive& ar, const ShaderBindingData& v) { diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h index e99a734c2f4..3a8b52be324 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h @@ -35,6 +35,24 @@ namespace cc { namespace render { +void save(OutputArchive& ar, const Descriptor& v); +void load(InputArchive& ar, Descriptor& v); + +void save(OutputArchive& ar, const DescriptorBlock& v); +void load(InputArchive& ar, DescriptorBlock& v); + +void save(OutputArchive& ar, const DescriptorBlockFlattened& v); +void load(InputArchive& ar, DescriptorBlockFlattened& v); + +void save(OutputArchive& ar, const DescriptorBlockIndex& v); +void load(InputArchive& ar, DescriptorBlockIndex& v); + +void save(OutputArchive& ar, const DescriptorGroupBlockIndex& v); +void load(InputArchive& ar, DescriptorGroupBlockIndex& v); + +void save(OutputArchive& ar, const DescriptorGroupBlock& v); +void load(InputArchive& ar, DescriptorGroupBlock& v); + void save(OutputArchive& ar, const DescriptorDB& v); void load(InputArchive& ar, DescriptorDB& v); @@ -65,6 +83,15 @@ void load(InputArchive& ar, DescriptorSetLayoutData& v); void save(OutputArchive& ar, const DescriptorSetData& v); void load(InputArchive& ar, DescriptorSetData& v); +void save(OutputArchive& ar, const DescriptorGroupBlockData& v); +void load(InputArchive& ar, DescriptorGroupBlockData& v); + +void save(OutputArchive& ar, const DescriptorGroupLayoutData& v); +void load(InputArchive& ar, DescriptorGroupLayoutData& v); + +void save(OutputArchive& ar, const DescriptorGroupData& v); +void load(InputArchive& ar, DescriptorGroupData& v); + void save(OutputArchive& ar, const PipelineLayoutData& v); void load(InputArchive& ar, PipelineLayoutData& v); diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp index 893a72f2bba..a27917ed9bb 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp @@ -166,11 +166,75 @@ DescriptorSetData::DescriptorSetData(DescriptorSetData&& rhs, const allocator_ty descriptorSetLayout(std::move(rhs.descriptorSetLayout)), descriptorSet(std::move(rhs.descriptorSet)) {} +DescriptorGroupBlockData::DescriptorGroupBlockData(const allocator_type& alloc) noexcept +: descriptors(alloc) {} + +DescriptorGroupBlockData::DescriptorGroupBlockData(DescriptorTypeOrder typeIn, gfx::ShaderStageFlagBit visibilityIn, AccessType accessTypeIn, ViewDimension viewDimensionIn, gfx::Format formatIn, uint32_t capacityIn, const allocator_type& alloc) noexcept // NOLINT +: type(typeIn), + visibility(visibilityIn), + accessType(accessTypeIn), + viewDimension(viewDimensionIn), + format(formatIn), + capacity(capacityIn), + descriptors(alloc) {} + +DescriptorGroupBlockData::DescriptorGroupBlockData(DescriptorGroupBlockData&& rhs, const allocator_type& alloc) +: type(rhs.type), + visibility(rhs.visibility), + accessType(rhs.accessType), + viewDimension(rhs.viewDimension), + format(rhs.format), + offset(rhs.offset), + capacity(rhs.capacity), + descriptors(std::move(rhs.descriptors), alloc) {} + +DescriptorGroupBlockData::DescriptorGroupBlockData(DescriptorGroupBlockData const& rhs, const allocator_type& alloc) +: type(rhs.type), + visibility(rhs.visibility), + accessType(rhs.accessType), + viewDimension(rhs.viewDimension), + format(rhs.format), + offset(rhs.offset), + capacity(rhs.capacity), + descriptors(rhs.descriptors, alloc) {} + +DescriptorGroupLayoutData::DescriptorGroupLayoutData(const allocator_type& alloc) noexcept +: descriptorGroupBlocks(alloc), + uniformBlocks(alloc), + bindingMap(alloc) {} + +DescriptorGroupLayoutData::DescriptorGroupLayoutData(uint32_t slotIn, uint32_t capacityIn, ccstd::pmr::vector descriptorGroupBlocksIn, PmrUnorderedMap uniformBlocksIn, PmrFlatMap bindingMapIn, const allocator_type& alloc) noexcept // NOLINT +: slot(slotIn), + capacity(capacityIn), + descriptorGroupBlocks(std::move(descriptorGroupBlocksIn), alloc), + uniformBlocks(std::move(uniformBlocksIn), alloc), + bindingMap(std::move(bindingMapIn), alloc) {} + +DescriptorGroupLayoutData::DescriptorGroupLayoutData(DescriptorGroupLayoutData&& rhs, const allocator_type& alloc) +: slot(rhs.slot), + capacity(rhs.capacity), + uniformBlockCapacity(rhs.uniformBlockCapacity), + samplerTextureCapacity(rhs.samplerTextureCapacity), + descriptorGroupBlocks(std::move(rhs.descriptorGroupBlocks), alloc), + uniformBlocks(std::move(rhs.uniformBlocks), alloc), + bindingMap(std::move(rhs.bindingMap), alloc) {} + +DescriptorGroupData::DescriptorGroupData(const allocator_type& alloc) noexcept +: descriptorGroupLayoutData(alloc) {} + +DescriptorGroupData::DescriptorGroupData(DescriptorGroupLayoutData descriptorGroupLayoutDataIn, const allocator_type& alloc) noexcept +: descriptorGroupLayoutData(std::move(descriptorGroupLayoutDataIn), alloc) {} + +DescriptorGroupData::DescriptorGroupData(DescriptorGroupData&& rhs, const allocator_type& alloc) +: descriptorGroupLayoutData(std::move(rhs.descriptorGroupLayoutData), alloc) {} + PipelineLayoutData::PipelineLayoutData(const allocator_type& alloc) noexcept -: descriptorSets(alloc) {} +: descriptorSets(alloc), + descriptorGroups(alloc) {} PipelineLayoutData::PipelineLayoutData(PipelineLayoutData&& rhs, const allocator_type& alloc) -: descriptorSets(std::move(rhs.descriptorSets), alloc) {} +: descriptorSets(std::move(rhs.descriptorSets), alloc), + descriptorGroups(std::move(rhs.descriptorGroups), alloc) {} ShaderBindingData::ShaderBindingData(const allocator_type& alloc) noexcept : descriptorBindings(alloc) {} diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h index bf95fe0fb0d..f21d9f977c7 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphTypes.h @@ -51,6 +51,94 @@ namespace cc { namespace render { +enum class DescriptorTypeOrder { + UNIFORM_BUFFER, + DYNAMIC_UNIFORM_BUFFER, + SAMPLER_TEXTURE, + SAMPLER, + TEXTURE, + STORAGE_BUFFER, + DYNAMIC_STORAGE_BUFFER, + STORAGE_IMAGE, + INPUT_ATTACHMENT, +}; + +struct Descriptor { + Descriptor() = default; + Descriptor(gfx::Type typeIn) noexcept // NOLINT + : type(typeIn) {} + + gfx::Type type{gfx::Type::UNKNOWN}; + uint32_t count{1}; +}; + +struct DescriptorBlock { + ccstd::map descriptors; + ccstd::map uniformBlocks; + uint32_t capacity{0}; + uint32_t count{0}; +}; + +struct DescriptorBlockFlattened { + ccstd::vector descriptorNames; + ccstd::vector uniformBlockNames; + ccstd::vector descriptors; + ccstd::vector uniformBlocks; + uint32_t capacity{0}; + uint32_t count{0}; +}; + +struct DescriptorBlockIndex { + DescriptorBlockIndex() = default; + DescriptorBlockIndex(UpdateFrequency updateFrequencyIn, ParameterType parameterTypeIn, DescriptorTypeOrder descriptorTypeIn, gfx::ShaderStageFlagBit visibilityIn) noexcept + : updateFrequency(updateFrequencyIn), + parameterType(parameterTypeIn), + descriptorType(descriptorTypeIn), + visibility(visibilityIn) {} + + UpdateFrequency updateFrequency{UpdateFrequency::PER_INSTANCE}; + ParameterType parameterType{ParameterType::CONSTANTS}; + DescriptorTypeOrder descriptorType{DescriptorTypeOrder::UNIFORM_BUFFER}; + gfx::ShaderStageFlagBit visibility{gfx::ShaderStageFlagBit::NONE}; +}; + +inline bool operator<(const DescriptorBlockIndex& lhs, const DescriptorBlockIndex& rhs) noexcept { + return std::forward_as_tuple(lhs.updateFrequency, lhs.parameterType, lhs.descriptorType, lhs.visibility) < + std::forward_as_tuple(rhs.updateFrequency, rhs.parameterType, rhs.descriptorType, rhs.visibility); +} + +struct DescriptorGroupBlockIndex { + DescriptorGroupBlockIndex() = default; + DescriptorGroupBlockIndex(UpdateFrequency updateFrequencyIn, ParameterType parameterTypeIn, DescriptorTypeOrder descriptorTypeIn, gfx::ShaderStageFlagBit visibilityIn, AccessType accessTypeIn, ViewDimension viewDimensionIn, gfx::Format formatIn) noexcept + : updateFrequency(updateFrequencyIn), + parameterType(parameterTypeIn), + descriptorType(descriptorTypeIn), + visibility(visibilityIn), + accessType(accessTypeIn), + viewDimension(viewDimensionIn), + format(formatIn) {} + + UpdateFrequency updateFrequency{UpdateFrequency::PER_INSTANCE}; + ParameterType parameterType{ParameterType::CONSTANTS}; + DescriptorTypeOrder descriptorType{DescriptorTypeOrder::UNIFORM_BUFFER}; + gfx::ShaderStageFlagBit visibility{gfx::ShaderStageFlagBit::NONE}; + AccessType accessType{AccessType::READ}; + ViewDimension viewDimension{ViewDimension::TEX2D}; + gfx::Format format{gfx::Format::UNKNOWN}; +}; + +inline bool operator<(const DescriptorGroupBlockIndex& lhs, const DescriptorGroupBlockIndex& rhs) noexcept { + return std::forward_as_tuple(lhs.updateFrequency, lhs.parameterType, lhs.descriptorType, lhs.visibility, lhs.accessType, lhs.viewDimension, lhs.format) < + std::forward_as_tuple(rhs.updateFrequency, rhs.parameterType, rhs.descriptorType, rhs.visibility, rhs.accessType, rhs.viewDimension, rhs.format); +} + +struct DescriptorGroupBlock { + ccstd::map descriptors; + ccstd::map uniformBlocks; + uint32_t capacity{0}; + uint32_t count{0}; +}; + struct DescriptorDB { using allocator_type = boost::container::pmr::polymorphic_allocator; allocator_type get_allocator() const noexcept { // NOLINT @@ -397,6 +485,74 @@ struct DescriptorSetData { IntrusivePtr descriptorSet; }; +struct DescriptorGroupBlockData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {descriptors.get_allocator().resource()}; + } + + DescriptorGroupBlockData(const allocator_type& alloc) noexcept; // NOLINT + DescriptorGroupBlockData(DescriptorTypeOrder typeIn, gfx::ShaderStageFlagBit visibilityIn, AccessType accessTypeIn, ViewDimension viewDimensionIn, gfx::Format formatIn, uint32_t capacityIn, const allocator_type& alloc) noexcept; + DescriptorGroupBlockData(DescriptorGroupBlockData&& rhs, const allocator_type& alloc); + DescriptorGroupBlockData(DescriptorGroupBlockData const& rhs, const allocator_type& alloc); + + DescriptorGroupBlockData(DescriptorGroupBlockData&& rhs) noexcept = default; + DescriptorGroupBlockData(DescriptorGroupBlockData const& rhs) = delete; + DescriptorGroupBlockData& operator=(DescriptorGroupBlockData&& rhs) = default; + DescriptorGroupBlockData& operator=(DescriptorGroupBlockData const& rhs) = default; + + DescriptorTypeOrder type{DescriptorTypeOrder::UNIFORM_BUFFER}; + gfx::ShaderStageFlagBit visibility{gfx::ShaderStageFlagBit::NONE}; + AccessType accessType{AccessType::READ}; + ViewDimension viewDimension{ViewDimension::TEX2D}; + gfx::Format format{gfx::Format::UNKNOWN}; + uint32_t offset{0}; + uint32_t capacity{0}; + ccstd::pmr::vector descriptors; +}; + +struct DescriptorGroupLayoutData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {descriptorGroupBlocks.get_allocator().resource()}; + } + + DescriptorGroupLayoutData(const allocator_type& alloc) noexcept; // NOLINT + DescriptorGroupLayoutData(uint32_t slotIn, uint32_t capacityIn, ccstd::pmr::vector descriptorGroupBlocksIn, PmrUnorderedMap uniformBlocksIn, PmrFlatMap bindingMapIn, const allocator_type& alloc) noexcept; + DescriptorGroupLayoutData(DescriptorGroupLayoutData&& rhs, const allocator_type& alloc); + + DescriptorGroupLayoutData(DescriptorGroupLayoutData&& rhs) noexcept = default; + DescriptorGroupLayoutData(DescriptorGroupLayoutData const& rhs) = delete; + DescriptorGroupLayoutData& operator=(DescriptorGroupLayoutData&& rhs) = default; + DescriptorGroupLayoutData& operator=(DescriptorGroupLayoutData const& rhs) = delete; + + uint32_t slot{0xFFFFFFFF}; + uint32_t capacity{0}; + uint32_t uniformBlockCapacity{0}; + uint32_t samplerTextureCapacity{0}; + ccstd::pmr::vector descriptorGroupBlocks; + PmrUnorderedMap uniformBlocks; + PmrFlatMap bindingMap; +}; + +struct DescriptorGroupData { + using allocator_type = boost::container::pmr::polymorphic_allocator; + allocator_type get_allocator() const noexcept { // NOLINT + return {descriptorGroupLayoutData.get_allocator().resource()}; + } + + DescriptorGroupData(const allocator_type& alloc) noexcept; // NOLINT + DescriptorGroupData(DescriptorGroupLayoutData descriptorGroupLayoutDataIn, const allocator_type& alloc) noexcept; + DescriptorGroupData(DescriptorGroupData&& rhs, const allocator_type& alloc); + + DescriptorGroupData(DescriptorGroupData&& rhs) noexcept = default; + DescriptorGroupData(DescriptorGroupData const& rhs) = delete; + DescriptorGroupData& operator=(DescriptorGroupData&& rhs) = default; + DescriptorGroupData& operator=(DescriptorGroupData const& rhs) = delete; + + DescriptorGroupLayoutData descriptorGroupLayoutData; +}; + struct PipelineLayoutData { using allocator_type = boost::container::pmr::polymorphic_allocator; allocator_type get_allocator() const noexcept { // NOLINT @@ -412,6 +568,7 @@ struct PipelineLayoutData { PipelineLayoutData& operator=(PipelineLayoutData const& rhs) = delete; ccstd::pmr::map descriptorSets; + ccstd::pmr::map descriptorGroups; }; struct ShaderBindingData { diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h b/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h index 577063d2b4b..dedb48694d4 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h +++ b/native/cocos/renderer/pipeline/custom/RenderCommonFwd.h @@ -50,6 +50,7 @@ struct RaytraceTag; enum class ResourceResidency; enum class QueueHint; enum class ResourceDimension; +enum class ViewDimension; enum class ResourceFlags : uint32_t; struct BufferTag; @@ -64,13 +65,6 @@ enum class ClearValueType; struct LightInfo; -enum class DescriptorTypeOrder; - -struct Descriptor; -struct DescriptorBlock; -struct DescriptorBlockFlattened; -struct DescriptorBlockIndex; - enum class ResolveFlags : uint32_t; struct ResolvePair; diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp index bd4e0b1baf8..921285003d2 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp +++ b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.cpp @@ -54,66 +54,6 @@ bool nativevalue_to_se(const cc::render::LightInfo &from, se::Value &to, se::Obj return true; } -bool nativevalue_to_se(const cc::render::Descriptor &from, se::Value &to, se::Object *ctx) { // NOLINT - se::HandleObject obj(se::Object::createPlainObject()); - se::Value tmp; - - nativevalue_to_se(from.type, tmp, ctx); - obj->setProperty("type", tmp); - - nativevalue_to_se(from.count, tmp, ctx); - obj->setProperty("count", tmp); - - to.setObject(obj); - return true; -} - -bool nativevalue_to_se(const cc::render::DescriptorBlockFlattened &from, se::Value &to, se::Object *ctx) { // NOLINT - se::HandleObject obj(se::Object::createPlainObject()); - se::Value tmp; - - nativevalue_to_se(from.descriptorNames, tmp, ctx); - obj->setProperty("descriptorNames", tmp); - - nativevalue_to_se(from.uniformBlockNames, tmp, ctx); - obj->setProperty("uniformBlockNames", tmp); - - nativevalue_to_se(from.descriptors, tmp, ctx); - obj->setProperty("descriptors", tmp); - - nativevalue_to_se(from.uniformBlocks, tmp, ctx); - obj->setProperty("uniformBlocks", tmp); - - nativevalue_to_se(from.capacity, tmp, ctx); - obj->setProperty("capacity", tmp); - - nativevalue_to_se(from.count, tmp, ctx); - obj->setProperty("count", tmp); - - to.setObject(obj); - return true; -} - -bool nativevalue_to_se(const cc::render::DescriptorBlockIndex &from, se::Value &to, se::Object *ctx) { // NOLINT - se::HandleObject obj(se::Object::createPlainObject()); - se::Value tmp; - - nativevalue_to_se(from.updateFrequency, tmp, ctx); - obj->setProperty("updateFrequency", tmp); - - nativevalue_to_se(from.parameterType, tmp, ctx); - obj->setProperty("parameterType", tmp); - - nativevalue_to_se(from.descriptorType, tmp, ctx); - obj->setProperty("descriptorType", tmp); - - nativevalue_to_se(from.visibility, tmp, ctx); - obj->setProperty("visibility", tmp); - - to.setObject(obj); - return true; -} - bool nativevalue_to_se(const cc::render::ResolvePair &from, se::Value &to, se::Object *ctx) { // NOLINT se::HandleObject obj(se::Object::createPlainObject()); se::Value tmp; @@ -259,84 +199,6 @@ bool sevalue_to_native(const se::Value &from, cc::render: return ok; } -template <> -bool sevalue_to_native(const se::Value &from, cc::render::Descriptor *to, se::Object *ctx) { // NOLINT - SE_PRECONDITION2(from.isObject(), false, " Convert parameter to Descriptor failed !"); - - auto *obj = const_cast(from.toObject()); - bool ok = true; - se::Value field; - obj->getProperty("type", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->type), ctx); - } - obj->getProperty("count", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->count), ctx); - } - return ok; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::render::DescriptorBlockFlattened *to, se::Object *ctx) { // NOLINT - SE_PRECONDITION2(from.isObject(), false, " Convert parameter to DescriptorBlockFlattened failed !"); - - auto *obj = const_cast(from.toObject()); - bool ok = true; - se::Value field; - obj->getProperty("descriptorNames", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->descriptorNames), ctx); - } - obj->getProperty("uniformBlockNames", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->uniformBlockNames), ctx); - } - obj->getProperty("descriptors", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->descriptors), ctx); - } - obj->getProperty("uniformBlocks", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->uniformBlocks), ctx); - } - obj->getProperty("capacity", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->capacity), ctx); - } - obj->getProperty("count", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->count), ctx); - } - return ok; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::render::DescriptorBlockIndex *to, se::Object *ctx) { // NOLINT - SE_PRECONDITION2(from.isObject(), false, " Convert parameter to DescriptorBlockIndex failed !"); - - auto *obj = const_cast(from.toObject()); - bool ok = true; - se::Value field; - obj->getProperty("updateFrequency", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->updateFrequency), ctx); - } - obj->getProperty("parameterType", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->parameterType), ctx); - } - obj->getProperty("descriptorType", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->descriptorType), ctx); - } - obj->getProperty("visibility", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->visibility), ctx); - } - return ok; -} - template <> bool sevalue_to_native(const se::Value &from, cc::render::ResolvePair *to, se::Object *ctx) { // NOLINT SE_PRECONDITION2(from.isObject(), false, " Convert parameter to ResolvePair failed !"); diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h index 79ffe839395..fbe60b9a023 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h +++ b/native/cocos/renderer/pipeline/custom/RenderCommonJsb.h @@ -34,12 +34,6 @@ bool nativevalue_to_se(const cc::render::LightInfo &from, se::Value &to, se::Object *ctx); // NOLINT -bool nativevalue_to_se(const cc::render::Descriptor &from, se::Value &to, se::Object *ctx); // NOLINT - -bool nativevalue_to_se(const cc::render::DescriptorBlockFlattened &from, se::Value &to, se::Object *ctx); // NOLINT - -bool nativevalue_to_se(const cc::render::DescriptorBlockIndex &from, se::Value &to, se::Object *ctx); // NOLINT - bool nativevalue_to_se(const cc::render::ResolvePair &from, se::Value &to, se::Object *ctx); // NOLINT bool nativevalue_to_se(const cc::render::CopyPair &from, se::Value &to, se::Object *ctx); // NOLINT @@ -52,15 +46,6 @@ bool nativevalue_to_se(const cc::render::MovePair &from, se::Value &to, se::Obje template <> bool sevalue_to_native(const se::Value &from, cc::render::LightInfo *to, se::Object *ctx); // NOLINT -template <> -bool sevalue_to_native(const se::Value &from, cc::render::Descriptor *to, se::Object *ctx); // NOLINT - -template <> -bool sevalue_to_native(const se::Value &from, cc::render::DescriptorBlockFlattened *to, se::Object *ctx); // NOLINT - -template <> -bool sevalue_to_native(const se::Value &from, cc::render::DescriptorBlockIndex *to, se::Object *ctx); // NOLINT - template <> bool sevalue_to_native(const se::Value &from, cc::render::ResolvePair *to, se::Object *ctx); // NOLINT diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonNames.h b/native/cocos/renderer/pipeline/custom/RenderCommonNames.h index 2655cce5ac0..8ad17c9cae9 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonNames.h +++ b/native/cocos/renderer/pipeline/custom/RenderCommonNames.h @@ -92,6 +92,23 @@ inline const char* getName(ResourceDimension e) noexcept { } return ""; } +inline const char* getName(ViewDimension e) noexcept { + switch (e) { + case ViewDimension::UNKNOWN: return "UNKNOWN"; + case ViewDimension::BUFFER: return "BUFFER"; + case ViewDimension::TEX1D: return "TEX1D"; + case ViewDimension::TEX1DARRAY: return "TEX1DARRAY"; + case ViewDimension::TEX2D: return "TEX2D"; + case ViewDimension::TEX2DARRAY: return "TEX2DARRAY"; + case ViewDimension::TEX2DMS: return "TEX2DMS"; + case ViewDimension::TEX2DMSARRAY: return "TEX2DMSARRAY"; + case ViewDimension::TEX3D: return "TEX3D"; + case ViewDimension::TEXCUBE: return "TEXCUBE"; + case ViewDimension::TEXCUBEARRAY: return "TEXCUBEARRAY"; + case ViewDimension::RAYTRACING_ACCELERATION_STRUCTURE: return "RAYTRACING_ACCELERATION_STRUCTURE"; + } + return ""; +} inline const char* getName(const BufferTag& /*v*/) noexcept { return "Buffer"; } inline const char* getName(const TextureTag& /*v*/) noexcept { return "Texture"; } inline const char* getName(TaskType e) noexcept { @@ -134,24 +151,6 @@ inline const char* getName(ClearValueType e) noexcept { return ""; } inline const char* getName(const LightInfo& /*v*/) noexcept { return "LightInfo"; } -inline const char* getName(DescriptorTypeOrder e) noexcept { - switch (e) { - case DescriptorTypeOrder::UNIFORM_BUFFER: return "UNIFORM_BUFFER"; - case DescriptorTypeOrder::DYNAMIC_UNIFORM_BUFFER: return "DYNAMIC_UNIFORM_BUFFER"; - case DescriptorTypeOrder::SAMPLER_TEXTURE: return "SAMPLER_TEXTURE"; - case DescriptorTypeOrder::SAMPLER: return "SAMPLER"; - case DescriptorTypeOrder::TEXTURE: return "TEXTURE"; - case DescriptorTypeOrder::STORAGE_BUFFER: return "STORAGE_BUFFER"; - case DescriptorTypeOrder::DYNAMIC_STORAGE_BUFFER: return "DYNAMIC_STORAGE_BUFFER"; - case DescriptorTypeOrder::STORAGE_IMAGE: return "STORAGE_IMAGE"; - case DescriptorTypeOrder::INPUT_ATTACHMENT: return "INPUT_ATTACHMENT"; - } - return ""; -} -inline const char* getName(const Descriptor& /*v*/) noexcept { return "Descriptor"; } -inline const char* getName(const DescriptorBlock& /*v*/) noexcept { return "DescriptorBlock"; } -inline const char* getName(const DescriptorBlockFlattened& /*v*/) noexcept { return "DescriptorBlockFlattened"; } -inline const char* getName(const DescriptorBlockIndex& /*v*/) noexcept { return "DescriptorBlockIndex"; } inline const char* getName(const ResolvePair& /*v*/) noexcept { return "ResolvePair"; } inline const char* getName(const CopyPair& /*v*/) noexcept { return "CopyPair"; } inline const char* getName(const UploadPair& /*v*/) noexcept { return "UploadPair"; } diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.cpp b/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.cpp index 348f72864da..686de7f6f28 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.cpp +++ b/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.cpp @@ -49,62 +49,6 @@ void load(InputArchive& ar, LightInfo& v) { load(ar, v.culledByLight); } -void save(OutputArchive& ar, const Descriptor& v) { - save(ar, v.type); - save(ar, v.count); -} - -void load(InputArchive& ar, Descriptor& v) { - load(ar, v.type); - load(ar, v.count); -} - -void save(OutputArchive& ar, const DescriptorBlock& v) { - save(ar, v.descriptors); - save(ar, v.uniformBlocks); - save(ar, v.capacity); - save(ar, v.count); -} - -void load(InputArchive& ar, DescriptorBlock& v) { - load(ar, v.descriptors); - load(ar, v.uniformBlocks); - load(ar, v.capacity); - load(ar, v.count); -} - -void save(OutputArchive& ar, const DescriptorBlockFlattened& v) { - save(ar, v.descriptorNames); - save(ar, v.uniformBlockNames); - save(ar, v.descriptors); - save(ar, v.uniformBlocks); - save(ar, v.capacity); - save(ar, v.count); -} - -void load(InputArchive& ar, DescriptorBlockFlattened& v) { - load(ar, v.descriptorNames); - load(ar, v.uniformBlockNames); - load(ar, v.descriptors); - load(ar, v.uniformBlocks); - load(ar, v.capacity); - load(ar, v.count); -} - -void save(OutputArchive& ar, const DescriptorBlockIndex& v) { - save(ar, v.updateFrequency); - save(ar, v.parameterType); - save(ar, v.descriptorType); - save(ar, v.visibility); -} - -void load(InputArchive& ar, DescriptorBlockIndex& v) { - load(ar, v.updateFrequency); - load(ar, v.parameterType); - load(ar, v.descriptorType); - load(ar, v.visibility); -} - void save(OutputArchive& ar, const ResolvePair& v) { save(ar, v.source); save(ar, v.target); diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.h b/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.h index 54232e0c890..eeffe166806 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.h +++ b/native/cocos/renderer/pipeline/custom/RenderCommonSerialization.h @@ -38,18 +38,6 @@ namespace render { void save(OutputArchive& ar, const LightInfo& v); void load(InputArchive& ar, LightInfo& v); -void save(OutputArchive& ar, const Descriptor& v); -void load(InputArchive& ar, Descriptor& v); - -void save(OutputArchive& ar, const DescriptorBlock& v); -void load(InputArchive& ar, DescriptorBlock& v); - -void save(OutputArchive& ar, const DescriptorBlockFlattened& v); -void load(InputArchive& ar, DescriptorBlockFlattened& v); - -void save(OutputArchive& ar, const DescriptorBlockIndex& v); -void load(InputArchive& ar, DescriptorBlockIndex& v); - void save(OutputArchive& ar, const ResolvePair& v); void load(InputArchive& ar, ResolvePair& v); diff --git a/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h index aebbc2afec8..e05ec9d4a85 100644 --- a/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h +++ b/native/cocos/renderer/pipeline/custom/RenderCommonTypes.h @@ -102,6 +102,21 @@ enum class ResourceDimension { TEXTURE3D, }; +enum class ViewDimension { + UNKNOWN, + BUFFER, + TEX1D, + TEX1DARRAY, + TEX2D, + TEX2DARRAY, + TEX2DMS, + TEX2DMSARRAY, + TEX3D, + TEXCUBE, + TEXCUBEARRAY, + RAYTRACING_ACCELERATION_STRUCTURE, +}; + enum class ResourceFlags : uint32_t { NONE = 0, UNIFORM = 0x1, @@ -245,62 +260,6 @@ struct LightInfo { bool culledByLight{false}; }; -enum class DescriptorTypeOrder { - UNIFORM_BUFFER, - DYNAMIC_UNIFORM_BUFFER, - SAMPLER_TEXTURE, - SAMPLER, - TEXTURE, - STORAGE_BUFFER, - DYNAMIC_STORAGE_BUFFER, - STORAGE_IMAGE, - INPUT_ATTACHMENT, -}; - -struct Descriptor { - Descriptor() = default; - Descriptor(gfx::Type typeIn) noexcept // NOLINT - : type(typeIn) {} - - gfx::Type type{gfx::Type::UNKNOWN}; - uint32_t count{1}; -}; - -struct DescriptorBlock { - ccstd::map descriptors; - ccstd::map uniformBlocks; - uint32_t capacity{0}; - uint32_t count{0}; -}; - -struct DescriptorBlockFlattened { - ccstd::vector descriptorNames; - ccstd::vector uniformBlockNames; - ccstd::vector descriptors; - ccstd::vector uniformBlocks; - uint32_t capacity{0}; - uint32_t count{0}; -}; - -struct DescriptorBlockIndex { - DescriptorBlockIndex() = default; - DescriptorBlockIndex(UpdateFrequency updateFrequencyIn, ParameterType parameterTypeIn, DescriptorTypeOrder descriptorTypeIn, gfx::ShaderStageFlagBit visibilityIn) noexcept - : updateFrequency(updateFrequencyIn), - parameterType(parameterTypeIn), - descriptorType(descriptorTypeIn), - visibility(visibilityIn) {} - - UpdateFrequency updateFrequency{UpdateFrequency::PER_INSTANCE}; - ParameterType parameterType{ParameterType::CONSTANTS}; - DescriptorTypeOrder descriptorType{DescriptorTypeOrder::UNIFORM_BUFFER}; - gfx::ShaderStageFlagBit visibility{gfx::ShaderStageFlagBit::NONE}; -}; - -inline bool operator<(const DescriptorBlockIndex& lhs, const DescriptorBlockIndex& rhs) noexcept { - return std::forward_as_tuple(lhs.updateFrequency, lhs.parameterType, lhs.descriptorType, lhs.visibility) < - std::forward_as_tuple(rhs.updateFrequency, rhs.parameterType, rhs.descriptorType, rhs.visibility); -} - enum class ResolveFlags : uint32_t { NONE = 0, COLOR = 1 << 0,