diff --git a/cocos/rendering/custom/compiler.ts b/cocos/rendering/custom/compiler.ts index 24fcd50f4f9..d7757099e42 100644 --- a/cocos/rendering/custom/compiler.ts +++ b/cocos/rendering/custom/compiler.ts @@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -import { DEBUG } from 'internal:constants'; -import { Buffer, Framebuffer, LoadOp, StoreOp, Texture, Viewport } from '../../gfx'; +import { Buffer, Framebuffer, Texture, Viewport } from '../../gfx'; +import { genHashValue } from './define'; import { VectorGraphColorMap } from './effect'; import { DefaultVisitor, depthFirstSearch, ReferenceGraphView } from './graph'; import { LayoutGraphData } from './layout-graph'; @@ -34,50 +34,7 @@ import { RenderGraphValue, } from './render-graph'; import { AccessType, ResourceResidency, SceneFlags } from './types'; -import { hashCombineKey, hashCombineStr } from './define'; -function genHashValue (pass: RasterPass): void { - let hashCode = ''; - for (const [name, raster] of pass.rasterViews) { - hashCode += hashCombineKey(name); - hashCode += hashCombineKey(raster.slotName); - hashCode += hashCombineKey(raster.accessType); - hashCode += hashCombineKey(raster.attachmentType); - hashCode += hashCombineKey(raster.loadOp); - hashCode += hashCombineKey(raster.storeOp); - hashCode += hashCombineKey(raster.clearFlags); - hashCode += hashCombineKey(raster.clearColor.x); - hashCode += hashCombineKey(raster.clearColor.y); - hashCode += hashCombineKey(raster.clearColor.z); - hashCode += hashCombineKey(raster.clearColor.w); - hashCode += hashCombineKey(raster.slotID); - hashCode += hashCombineKey(raster.shaderStageFlags); - } - for (const [name, computes] of pass.computeViews) { - hashCode += hashCombineKey(name); - for (const compute of computes) { - hashCode += hashCombineKey(compute.name); - hashCode += hashCombineKey(compute.accessType); - hashCode += hashCombineKey(compute.clearFlags); - hashCode += hashCombineKey(compute.clearValueType); - hashCode += hashCombineKey(compute.clearValue.x); - hashCode += hashCombineKey(compute.clearValue.y); - hashCode += hashCombineKey(compute.clearValue.z); - hashCode += hashCombineKey(compute.clearValue.w); - hashCode += hashCombineKey(compute.shaderStageFlags); - } - } - hashCode += hashCombineKey(pass.width); - hashCode += hashCombineKey(pass.height); - hashCode += hashCombineKey(pass.viewport.left); - hashCode += hashCombineKey(pass.viewport.top); - hashCode += hashCombineKey(pass.viewport.width); - hashCode += hashCombineKey(pass.viewport.height); - hashCode += hashCombineKey(pass.viewport.minDepth); - hashCode += hashCombineKey(pass.viewport.maxDepth); - hashCode += hashCombineKey(pass.showStatistics ? 1 : 0); - pass.hashValue = hashCombineStr(hashCode); -} const readViews: Map = new Map(); class PassVisitor implements RenderGraphVisitor { public queueID = 0xFFFFFFFF; @@ -129,9 +86,6 @@ class PassVisitor implements RenderGraphVisitor { } private _useResourceInfo (input: string, raster: RasterView): void { - if (!DEBUG) { - return; - } const resContext = this.context.resourceContext; const useContext = resContext.get(input); const resGraph = this.context.resourceGraph; @@ -173,11 +127,6 @@ class PassVisitor implements RenderGraphVisitor { private _fetchValidPass (): void { const rg = this.context.renderGraph; const resContext = this.context.resourceContext; - if (!DEBUG && rg.getValid(this.passID)) { - rg.setValid(this.queueID, true); - rg.setValid(this.sceneID, true); - return; - } const outputId = this.resID; const outputName = this.context.resourceGraph.vertexName(outputId); readViews.clear(); @@ -187,9 +136,7 @@ class PassVisitor implements RenderGraphVisitor { // find the pass if (readName === outputName && raster.accessType !== AccessType.READ) { - if (DEBUG) { - this._useResourceInfo(readName, raster); - } + this._useResourceInfo(readName, raster); rg.setValid(this.passID, true); rg.setValid(this.queueID, true); rg.setValid(this.sceneID, true); @@ -199,7 +146,7 @@ class PassVisitor implements RenderGraphVisitor { readViews.set(readName, raster); } } - if (DEBUG && validPass) return; + if (validPass) return; if (rg.getValid(this.sceneID)) { for (const [readName, raster] of pass.rasterViews) { context.pipeline.resourceUses.push(readName); @@ -215,19 +162,17 @@ class PassVisitor implements RenderGraphVisitor { } } for (const [computeName, cViews] of pass.computeViews) { - if (DEBUG) { - let resUseContext = resContext.get(computeName); - if (!resUseContext) { - resUseContext = new ResourceUseContext(); - resContext.set(computeName, resUseContext); - } - const computes = resUseContext.computes; - const currUseComputes = computes.get(this.passID); - if (currUseComputes) { - currUseComputes.push(cViews); - } else { - computes.set(this.passID, [cViews]); - } + let resUseContext = resContext.get(computeName); + if (!resUseContext) { + resUseContext = new ResourceUseContext(); + resContext.set(computeName, resUseContext); + } + const computes = resUseContext.computes; + const currUseComputes = computes.get(this.passID); + if (currUseComputes) { + currUseComputes.push(cViews); + } else { + computes.set(this.passID, [cViews]); } resourceGraph = this.context.resourceGraph; vertID = resourceGraph.find(computeName); diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts index 648946d75a7..bddd3c9b299 100644 --- a/cocos/rendering/custom/define.ts +++ b/cocos/rendering/custom/define.ts @@ -45,7 +45,7 @@ import { } from './types'; import { Vec4, geometry, toRadian, cclegacy } from '../../core'; import { RenderWindow } from '../../render-scene/core/render-window'; -import { RenderData, RenderGraph } from './render-graph'; +import { RasterPass, RenderData, RenderGraph } from './render-graph'; import { WebPipeline } from './web-pipeline'; import { DescriptorSetData, LayoutGraphData } from './layout-graph'; import { AABB } from '../../core/geometry'; @@ -617,15 +617,12 @@ function updateDefaultConstantBlock (blockId: number, sceneId: number, idxRD: nu } export function updatePerPassUBO (layout: string, sceneId: number, idxRD: number, user: RenderData): void { - const constantMap = user.constants; - const samplers = user.samplers; - const textures = user.textures; - const buffers = user.buffers; + const { constants, samplers, textures, buffers } = user; const webPip = cclegacy.director.root.pipeline as WebPipeline; const lg = webPip.layoutGraph; const descriptorSetData = getDescriptorSetDataFromLayout(layout)!; currBindBuffs.clear(); - for (const [key, data] of constantMap) { + for (const [key, data] of constants) { let constantBlock = constantBlockMap.get(key); if (!constantBlock) { const currMemKey = Array.from(lg.constantIndex).find(([_, v]) => v === key)![0]; @@ -683,7 +680,6 @@ export function updatePerPassUBO (layout: string, sceneId: number, idxRD: number bindGlobalDesc(descriptorSet, bindId, value); } } - descriptorSet.update(); } export function hashCombineKey (val): string { @@ -866,3 +862,46 @@ export function getSubpassOrPassID (sceneId: number, rg: RenderGraph, lg: Layout } return layoutId; } + +export function genHashValue (pass: RasterPass): void { + let hashCode = ''; + for (const [name, raster] of pass.rasterViews) { + hashCode += hashCombineKey(name); + hashCode += hashCombineKey(raster.slotName); + hashCode += hashCombineKey(raster.accessType); + hashCode += hashCombineKey(raster.attachmentType); + hashCode += hashCombineKey(raster.loadOp); + hashCode += hashCombineKey(raster.storeOp); + hashCode += hashCombineKey(raster.clearFlags); + hashCode += hashCombineKey(raster.clearColor.x); + hashCode += hashCombineKey(raster.clearColor.y); + hashCode += hashCombineKey(raster.clearColor.z); + hashCode += hashCombineKey(raster.clearColor.w); + hashCode += hashCombineKey(raster.slotID); + hashCode += hashCombineKey(raster.shaderStageFlags); + } + for (const [name, computes] of pass.computeViews) { + hashCode += hashCombineKey(name); + for (const compute of computes) { + hashCode += hashCombineKey(compute.name); + hashCode += hashCombineKey(compute.accessType); + hashCode += hashCombineKey(compute.clearFlags); + hashCode += hashCombineKey(compute.clearValueType); + hashCode += hashCombineKey(compute.clearValue.x); + hashCode += hashCombineKey(compute.clearValue.y); + hashCode += hashCombineKey(compute.clearValue.z); + hashCode += hashCombineKey(compute.clearValue.w); + hashCode += hashCombineKey(compute.shaderStageFlags); + } + } + hashCode += hashCombineKey(pass.width); + hashCode += hashCombineKey(pass.height); + hashCode += hashCombineKey(pass.viewport.left); + hashCode += hashCombineKey(pass.viewport.top); + hashCode += hashCombineKey(pass.viewport.width); + hashCode += hashCombineKey(pass.viewport.height); + hashCode += hashCombineKey(pass.viewport.minDepth); + hashCode += hashCombineKey(pass.viewport.maxDepth); + hashCode += hashCombineKey(pass.showStatistics ? 1 : 0); + pass.hashValue = hashCombineStr(hashCode); +} diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 3e643036033..5afd96ba92f 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -525,7 +525,6 @@ class DeviceComputeQueue implements RecordingInterface { private _renderPhase: RenderPhaseData | null = null; private _descSetData: DescriptorSetData | null = null; private _layoutID = -1; - private _isUpdateUBO = false; private _isUploadInstance = false; private _isUploadBatched = false; private _queueId = -1; @@ -551,15 +550,12 @@ class DeviceComputeQueue implements RecordingInterface { get renderPhase (): RenderPhaseData | null { return this._renderPhase; } set queueId (val) { this._queueId = val; } get queueId (): number { return this._queueId; } - set isUpdateUBO (update: boolean) { this._isUpdateUBO = update; } - get isUpdateUBO (): boolean { return this._isUpdateUBO; } set isUploadInstance (value: boolean) { this._isUploadInstance = value; } get isUploadInstance (): boolean { return this._isUploadInstance; } set isUploadBatched (value: boolean) { this._isUploadBatched = value; } get isUploadBatched (): boolean { return this._isUploadBatched; } reset (): void { - this._isUpdateUBO = false; this._isUploadInstance = false; this._isUploadBatched = false; } @@ -586,7 +582,6 @@ class DeviceRenderQueue implements RecordingInterface { private _viewport: Viewport | null = null; private _scissor: Rect | null = null; private _layoutID = -1; - private _isUpdateUBO = false; private _isUploadInstance = false; private _isUploadBatched = false; get phaseID (): number { return this._phaseID; } @@ -608,8 +603,6 @@ class DeviceRenderQueue implements RecordingInterface { private _queueId = -1; set queueId (val) { this._queueId = val; } get queueId (): number { return this._queueId; } - set isUpdateUBO (update: boolean) { this._isUpdateUBO = update; } - get isUpdateUBO (): boolean { return this._isUpdateUBO; } set isUploadInstance (value: boolean) { this._isUploadInstance = value; } get isUploadInstance (): boolean { return this._isUploadInstance; } set isUploadBatched (value: boolean) { this._isUploadBatched = value; } @@ -642,7 +635,6 @@ class DeviceRenderQueue implements RecordingInterface { } reset (): void { this._renderScenes.length = 0; - this._isUpdateUBO = false; this._isUploadInstance = false; this._isUploadBatched = false; this._blitDesc?.reset(); @@ -743,7 +735,7 @@ const renderPassArea = new Rect(); const resourceVisitor = new ResourceVisitor(); class DeviceRenderPass implements RecordingInterface { protected _renderPass: RenderPass; - protected _framebuffer: Framebuffer; + protected _framebuffer!: Framebuffer; protected _clearColor: Color[] = []; protected _deviceQueues: Map = new Map(); protected _clearDepth = 1; @@ -768,13 +760,7 @@ class DeviceRenderPass implements RecordingInterface { let depthTex: Texture | null = null; let swapchain: Swapchain | null = null; let framebuffer: Framebuffer | null = null; - for (const cv of rasterPass.computeViews) { - this._applyRenderLayout(cv); - } - // update the layout descriptorSet - if (this.renderLayout && this.renderLayout.descriptorSet) { - this.renderLayout.descriptorSet.update(); - } + this._processRenderLayout(rasterPass); for (const [resName, rasterV] of rasterPass.rasterViews) { let resTex = context.deviceTextures.get(resName); if (!resTex) { @@ -852,11 +838,11 @@ class DeviceRenderPass implements RecordingInterface { renderPassInfo.depthStencilAttachment = depthStencilAttachment; } this._renderPass = device.createRenderPass(renderPassInfo); - this._framebuffer = framebuffer || device.createFramebuffer(new FramebufferInfo( - this._renderPass, + this._createFramebuffer( + framebuffer, swapchain ? [swapchain.colorTexture] : colorTexs, swapchain ? swapchain.depthStencilTexture : depthTex, - )); + ); } get indexOfRD (): number { return this._idxOfRenderData; } get rasterID (): number { return this._rasterID; } @@ -994,6 +980,27 @@ class DeviceRenderPass implements RecordingInterface { postRecord (): void { // nothing to do } + + private _processRenderLayout (pass: RasterPass): void { + for (const cv of pass.computeViews) { + this._applyRenderLayout(cv); + } + // update the layout descriptorSet + if (this.renderLayout && this.renderLayout.descriptorSet) { + this.renderLayout.descriptorSet.update(); + } + } + + private _createFramebuffer (fbo: Framebuffer | null, cols: Texture[], depthTex: Texture | null): void { + if (!fbo && !cols.length) return; + if (this._framebuffer && fbo !== this._framebuffer) this._framebuffer.destroy(); + this._framebuffer = fbo || context.device.createFramebuffer(new FramebufferInfo( + this._renderPass, + cols, + depthTex, + )); + } + resetResource (id: number, pass: RasterPass): void { this._rasterID = id; this._rasterPass = pass; @@ -1006,13 +1013,7 @@ class DeviceRenderPass implements RecordingInterface { const currFramebuffer = this._framebuffer; const currFBDepthTex = currFramebuffer.depthStencilTexture; let depTexture = currFramebuffer ? currFBDepthTex : null; - for (const cv of pass.computeViews) { - this._applyRenderLayout(cv); - } - // update the layout descriptorSet - if (this.renderLayout && this.renderLayout.descriptorSet) { - this.renderLayout.descriptorSet.update(); - } + this._processRenderLayout(pass); const resGraph = context.resourceGraph; const currentWidth = currFramebuffer ? currFramebuffer.width : 0; @@ -1072,14 +1073,7 @@ class DeviceRenderPass implements RecordingInterface { } } } - if (!framebuffer && colTextures.length) { - this._framebuffer.destroy(); - this._framebuffer = context.device.createFramebuffer(new FramebufferInfo( - this._renderPass, - colTextures, - depTexture, - )); - } + this._createFramebuffer(framebuffer, colTextures, depTexture); } } @@ -1225,18 +1219,6 @@ class DeviceRenderScene implements RecordingInterface { } protected _recordUI (): void { - const devicePass = this._currentQueue.devicePass; - const rasterId = devicePass.rasterID; - const passRenderData = context.renderGraph.getData(rasterId); - // RasterPass first - this._updateGlobal(passRenderData, this.sceneID); - // then Queue - const queueId = this._currentQueue.queueId; - const queueRenderData = context.renderGraph.getData(queueId)!; - this._updateGlobal(queueRenderData, this.sceneID); - - this._currentQueue.isUpdateUBO = true; - const batches = this.camera!.scene!.batches; for (let i = 0; i < batches.length; i++) { const batch = batches[i]; @@ -1300,7 +1282,6 @@ class DeviceRenderScene implements RecordingInterface { } protected _updateRenderData (): void { - if (this._currentQueue.isUpdateUBO) return; const devicePass = this._currentQueue.devicePass; const rasterId = devicePass.rasterID; const passRenderData = context.renderGraph.getData(rasterId); @@ -1311,9 +1292,7 @@ class DeviceRenderScene implements RecordingInterface { const queueId = this._currentQueue.queueId; const queueRenderData = context.renderGraph.getData(queueId)!; this._updateGlobal(queueRenderData, sceneId); - const sceneRenderData = context.renderGraph.getData(sceneId)!; - if (sceneRenderData) this._updateGlobal(sceneRenderData, sceneId); - this._currentQueue.isUpdateUBO = true; + context.passDescriptorSet?.update(); } private _applyViewport (): void { @@ -1339,7 +1318,7 @@ class DeviceRenderScene implements RecordingInterface { public record (): void { const devicePass = this._currentQueue.devicePass; const sceneCulling = context.culling; - this._updateRenderData(); + if (!devicePass.indexOfRD) this._updateRenderData(); this._applyViewport(); // Currently processing blit and camera first if (this.blit) { @@ -1349,9 +1328,10 @@ class DeviceRenderScene implements RecordingInterface { const renderQueueQuery = sceneCulling.renderQueueQueryIndex.get(this.sceneID)!; const renderQueue = sceneCulling.renderQueues[renderQueueQuery.renderQueueTarget]; const graphSceneData = this.sceneData!; - if (bool(graphSceneData.flags & SceneFlags.REFLECTION_PROBE)) renderQueue.probeQueue.applyMacro(); + const isProbe = bool(graphSceneData.flags & SceneFlags.REFLECTION_PROBE); + if (isProbe) renderQueue.probeQueue.applyMacro(); renderQueue.recordCommands(context.commandBuffer, this._renderPass, graphSceneData.flags); - if (bool(graphSceneData.flags & SceneFlags.REFLECTION_PROBE)) renderQueue.probeQueue.removeMacro(); + if (isProbe) renderQueue.probeQueue.removeMacro(); if (graphSceneData.flags & SceneFlags.GEOMETRY) { this.camera!.geometryRenderer?.render( devicePass.renderPass, @@ -1440,11 +1420,12 @@ class BlitInfo { const vb = this._genQuadVertexData(SurfaceTransform.IDENTITY, new Rect(0, 0, context.width, context.height)); this._pipelineIAData.quadVB!.update(vb); this._createLightVolumes(); + const size: number = UBOLocalEnum.SIZE; this._localUBO = context.device.createBuffer(new BufferInfo( BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, MemoryUsageBit.DEVICE, - UBOLocalEnum.SIZE, - UBOLocalEnum.SIZE, + size, + size, )); } diff --git a/cocos/rendering/custom/web-pipeline-types.ts b/cocos/rendering/custom/web-pipeline-types.ts index b3abc00d876..d338a0981fa 100644 --- a/cocos/rendering/custom/web-pipeline-types.ts +++ b/cocos/rendering/custom/web-pipeline-types.ts @@ -900,48 +900,37 @@ export class RenderDrawQueue { } export class RenderInstancingQueue { - passInstances: Map = new Map(); - instanceBuffers: Array = new Array(); - + /** + * @en A set of instanced buffer + * @zh Instance 合批缓存集合。 + */ + public queue = new Set(); empty (): boolean { - return this.passInstances.size === 0; + return this.queue.size === 0; } add (pass: Pass, subModel: SubModel, passID: number): void { - const iter = this.passInstances.get(pass); - if (iter === undefined) { - const instanceBufferID = this.passInstances.size; - if (instanceBufferID >= this.instanceBuffers.length) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - this.instanceBuffers.push(new InstancedBuffer(pass)); - } - this.passInstances.set(pass, instanceBufferID); - - const instanceBuffer = this.instanceBuffers[instanceBufferID]; - instanceBuffer.pass = pass; - const instances = instanceBuffer.instances; - } - - const instancedBuffer = this.instanceBuffers[this.passInstances.get(pass)!]; + const instancedBuffer = pass.getInstancedBuffer(); instancedBuffer.merge(subModel, passID); + this.queue.add(instancedBuffer); } clear (): void { - this.passInstances.clear(); - const instanceBuffers = this.instanceBuffers; - instanceBuffers.forEach((instance) => { - instance.clear(); - }); + const it = this.queue.values(); let res = it.next(); + while (!res.done) { + res.value.clear(); + res = it.next(); + } + this.queue.clear(); } sort (): void {} uploadBuffers (cmdBuffer: CommandBuffer): void { - for (const [pass, bufferID] of this.passInstances.entries()) { - const instanceBuffer = this.instanceBuffers[bufferID]; - if (instanceBuffer.hasPendingModels) { - instanceBuffer.uploadBuffers(cmdBuffer); - } + const it = this.queue.values(); let res = it.next(); + while (!res.done) { + if (res.value.hasPendingModels) res.value.uploadBuffers(cmdBuffer); + res = it.next(); } } @@ -952,7 +941,7 @@ export class RenderInstancingQueue { offset = 0, dynamicOffsets: number[] | null = null, ): void { - const renderQueue = this.instanceBuffers; + const renderQueue = this.queue; for (const instanceBuffer of renderQueue) { if (!instanceBuffer.hasPendingModels) { continue; diff --git a/cocos/rendering/custom/web-pipeline.ts b/cocos/rendering/custom/web-pipeline.ts index a2be1408239..8f0472aea82 100644 --- a/cocos/rendering/custom/web-pipeline.ts +++ b/cocos/rendering/custom/web-pipeline.ts @@ -24,7 +24,7 @@ /* eslint-disable max-len */ import { systemInfo } from 'pal/system-info'; -import { EDITOR } from 'internal:constants'; +import { DEBUG, EDITOR } from 'internal:constants'; import { DescriptorSetLayout, Device, Feature, Format, FormatFeatureBit, Sampler, Swapchain, Texture, ClearFlagBit, DescriptorSet, deviceManager, Viewport, API, CommandBuffer, Type, SamplerInfo, Filter, Address, DescriptorSetInfo, LoadOp, StoreOp, ShaderStageFlagBit, BufferInfo, TextureInfo, TextureType, ResolveMode, SampleCount, Color, ComparisonFunc } from '../../gfx'; import { Vec4, macro, cclegacy, RecyclePool } from '../../core'; import { AccessType, AttachmentType, CopyPair, LightInfo, LightingMode, MovePair, QueueHint, RenderCommonObjectPool, ResolvePair, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency, UploadPair } from './types'; @@ -45,7 +45,7 @@ import { GeometryRenderer } from '../geometry-renderer'; import { Material } from '../../asset/assets'; import { decideProfilerCamera } from '../pipeline-funcs'; import { DebugViewCompositeType } from '../debug-view'; -import { buildReflectionProbePass } from './define'; +import { buildReflectionProbePass, genHashValue } from './define'; import { createGfxDescriptorSetsAndPipelines } from './layout-graph-utils'; import { Root } from '../../root'; import { Scene } from '../../scene-graph'; @@ -261,7 +261,7 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild lightTarget && !(sceneFlags & SceneFlags.SHADOW_CASTER) ? CullingFlags.CAMERA_FRUSTUM | CullingFlags.LIGHT_BOUNDS : CullingFlags.CAMERA_FRUSTUM, lightTarget, ); - this._renderGraph.addVertex(RenderGraphValue.Scene, sceneData, name, '', renderGraphPool.createRenderData(), false, this._vertID); + this._renderGraph.addVertex(RenderGraphValue.Scene, sceneData, name, '', renderGraphPool.createRenderData(), !DEBUG, this._vertID); const layoutName = this.getParentLayout(); const scene: Scene = cclegacy.director.getScene(); setCameraUBOValues( @@ -286,7 +286,7 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild light, ); const renderData = renderGraphPool.createRenderData(); - const sceneId = this._renderGraph.addVertex(RenderGraphValue.Scene, sceneData, 'Scene', '', renderData, false, this._vertID); + const sceneId = this._renderGraph.addVertex(RenderGraphValue.Scene, sceneData, 'Scene', '', renderData, !DEBUG, this._vertID); if (!(sceneFlags & SceneFlags.NON_BUILTIN)) { const layoutName = this.getParentLayout(); setCameraUBOValues( @@ -310,7 +310,7 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild name, '', renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); const layoutName = this.getParentLayout(); @@ -335,7 +335,7 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild 'CameraQuad', '', renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); const layoutName = this.getParentLayout(); @@ -362,7 +362,7 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild 'ClearRenderTarget', '', renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); } @@ -449,7 +449,7 @@ export class WebRenderSubpassBuilder extends WebSetter implements RenderSubpassB const layoutId = this._lg.locateChild(this._layoutID, layoutName); const queue = renderGraphPool.createRenderQueue(hint, layoutId); const data = renderGraphPool.createRenderData(); - const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID); + const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, !DEBUG, this._vertID); const queueBuilder = pipelinePool.renderQueueBuilder.add(); queueBuilder.update(data, this._renderGraph, this._lg, queueID, queue, this._pipeline); return queueBuilder; @@ -574,7 +574,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR this._pass.subpassGraph.addVertex(name, renderGraphPool.createSubpass()); const subpass = renderGraphPool.createRasterSubpass(subpassID, 1, 0); const data = renderGraphPool.createRenderData(); - const vertID = this._renderGraph.addVertex(RenderGraphValue.RasterSubpass, subpass, name, layoutName, data, false); + const vertID = this._renderGraph.addVertex(RenderGraphValue.RasterSubpass, subpass, name, layoutName, data, !DEBUG); const result = pipelinePool.renderSubpassBuilder.add(); result.update(data, this._renderGraph, this._lg, vertID, subpass, this._pipeline); return result; @@ -583,7 +583,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR const layoutId = this._lg.locateChild(this._layoutID, layoutName); const queue = renderGraphPool.createRenderQueue(hint, layoutId); const data = renderGraphPool.createRenderData(); - const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID); + const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, !DEBUG, this._vertID); const result = pipelinePool.renderQueueBuilder.add(); result.update(data, this._renderGraph, this._lg, queueID, queue, this._pipeline); return result; @@ -597,7 +597,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR 'Queue', '', renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); this._renderGraph.addVertex( @@ -606,7 +606,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR name, '', renderGraphPool.createRenderData(), - false, + !DEBUG, queueId, ); } @@ -619,7 +619,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR 'Queue', '', renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); this._renderGraph.addVertex( @@ -628,7 +628,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR name, '', renderGraphPool.createRenderData(), - false, + !DEBUG, queueId, ); } @@ -690,7 +690,7 @@ export class WebComputeQueueBuilder extends WebSetter implements ComputeQueueBui renderGraphPool.createRenderData(), - false, + !DEBUG, this._vertID, ); @@ -752,7 +752,7 @@ export class WebComputePassBuilder extends WebSetter implements ComputePassBuild const layoutId = this._lg.locateChild(this._layoutID, layoutName); const queue = renderGraphPool.createRenderQueue(QueueHint.RENDER_OPAQUE, layoutId); const data = renderGraphPool.createRenderData(); - const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID); + const queueID = this._renderGraph.addVertex(RenderGraphValue.Queue, queue, '', layoutName, data, !DEBUG, this._vertID); const computeQueueBuilder = pipelinePool.computeQueueBuilder.add(); computeQueueBuilder.update(data, this._renderGraph, this._lg, queueID, queue, this._pipeline); return computeQueueBuilder; @@ -1083,7 +1083,7 @@ export class WebPipeline implements BasicPipeline { const pass = renderGraphPool.createComputePass(); const data = renderGraphPool.createRenderData(); - const vertID = this._renderGraph!.addVertex(RenderGraphValue.Compute, pass, name, passName, data, false); + const vertID = this._renderGraph!.addVertex(RenderGraphValue.Compute, pass, name, passName, data, !DEBUG); const result = pipelinePool.computePassBuilder.add(); result.update(data, this._renderGraph!, this._layoutGraph, this._resourceGraph, vertID, pass, this._pipelineSceneData); setComputeConstants(result, passName); @@ -1097,7 +1097,7 @@ export class WebPipeline implements BasicPipeline { pass.uploadPairs.push(up); } - const vertID = this._renderGraph!.addVertex(RenderGraphValue.Copy, pass, name, '', renderGraphPool.createRenderData(), false); + const vertID = this._renderGraph!.addVertex(RenderGraphValue.Copy, pass, name, '', renderGraphPool.createRenderData(), !DEBUG); // const result = new WebCopyPassBuilder(this._renderGraph!, vertID, pass); } @@ -1529,10 +1529,18 @@ export class WebPipeline implements BasicPipeline { if (!this._renderGraph) { throw new Error('RenderGraph cannot be built without being created'); } - if (!this._compiler) { - this._compiler = new Compiler(this, this._renderGraph, this._resourceGraph, this._layoutGraph); + if (DEBUG) { + if (!this._compiler) { + this._compiler = new Compiler(this, this._renderGraph, this._resourceGraph, this._layoutGraph); + } + this._compiler.compile(this._renderGraph); + } else { + this._renderGraph.x.forEach((vert) => { + if (vert.t === RenderGraphValue.RasterPass) { + genHashValue(vert.j as RasterPass); + } + }); } - this._compiler.compile(this._renderGraph); } execute (): void { @@ -1612,9 +1620,8 @@ export class WebPipeline implements BasicPipeline { pass.viewport.height = height; pass.count = count; pass.quality = quality; - const data = renderGraphPool.createRenderData(); - const vertID = this._renderGraph!.addVertex(RenderGraphValue.RasterPass, pass, name, layoutName, data, false); + const vertID = this._renderGraph!.addVertex(RenderGraphValue.RasterPass, pass, name, layoutName, data, !DEBUG); const result = pipelinePool.renderPassBuilder.add(); result.update(data, this._renderGraph!, this._layoutGraph, this._resourceGraph, vertID, pass, this._pipelineSceneData); this._updateRasterPassConstants(result, width, height, layoutName);