diff --git a/cocos/render-scene/core/pass.ts b/cocos/render-scene/core/pass.ts index 408d5938c5f..c09b83e9396 100644 --- a/cocos/render-scene/core/pass.ts +++ b/cocos/render-scene/core/pass.ts @@ -39,7 +39,7 @@ import { MacroRecord, MaterialProperty, customizeType, getBindingFromHandle, getDefaultFromType, getStringFromType, getOffsetFromHandle, getTypeFromHandle, type2reader, type2writer, getCountFromHandle, type2validator, } from './pass-utils'; -import { RenderPassStage, RenderPriority } from '../../rendering/define'; +import { RenderPassStage, RenderPriority, SetIndex } from '../../rendering/define'; import { InstancedBuffer } from '../../rendering/instanced-buffer'; import { ProgramLibrary } from '../../rendering/custom/private'; @@ -469,10 +469,19 @@ export class Pass { * @zh 重置所有 texture 和 sampler 为初始默认值。 */ public resetTextures (): void { - for (let i = 0; i < this._shaderInfo.samplerTextures.length; i++) { - const u = this._shaderInfo.samplerTextures[i]; - for (let j = 0; j < u.count; j++) { - this.resetTexture(u.name, j); + if (cclegacy.rendering) { + const set = this._shaderInfo.descriptors[SetIndex.MATERIAL]; + for (const combined of set.samplerTextures) { + for (let j = 0; j < combined.count; ++j) { + this.resetTexture(combined.name, j); + } + } + } else { + for (let i = 0; i < this._shaderInfo.samplerTextures.length; i++) { + const u = this._shaderInfo.samplerTextures[i]; + for (let j = 0; j < u.count; j++) { + this.resetTexture(u.name, j); + } } } } diff --git a/cocos/rendering/custom/builtin-pipelines.ts b/cocos/rendering/custom/builtin-pipelines.ts index 1403ee8d602..b1e31a85d11 100644 --- a/cocos/rendering/custom/builtin-pipelines.ts +++ b/cocos/rendering/custom/builtin-pipelines.ts @@ -106,7 +106,7 @@ export class DeferredPipelineBuilder implements PipelineBuilder { // Lighting Pass const lightInfo = setupLightingPass(ppl, info, useCluster); // Deferred ForwardPass, for non-surface-shader material and transparent material - setupDeferredForward(ppl, info, lightInfo.rtName); + setupDeferredForward(ppl, info, lightInfo.rtName, useCluster); // Postprocess setupPostprocessPass(ppl, info, lightInfo.rtName); diff --git a/cocos/rendering/custom/pipeline-define.ts b/cocos/rendering/custom/pipeline-define.ts index 87d6a02dd34..1c10c17436c 100644 --- a/cocos/rendering/custom/pipeline-define.ts +++ b/cocos/rendering/custom/pipeline-define.ts @@ -35,7 +35,7 @@ export class CameraInfo { this.width = width; this.height = height; } - public camera; + public camera: Camera; public id = 0xFFFFFFFF; public windowID = 0xFFFFFFFF; public width = 0; @@ -53,9 +53,12 @@ function prepareRenderWindow (camera: Camera): number { return windowID; } -export function prepareResource (ppl: BasicPipeline, camera: Camera, +export function prepareResource ( + ppl: BasicPipeline, + camera: Camera, initResourceFunc: (ppl: BasicPipeline, info: CameraInfo) => void, - updateResourceFunc: (ppl: BasicPipeline, info: CameraInfo) => void): CameraInfo { + updateResourceFunc: (ppl: BasicPipeline, info: CameraInfo) => void, +): CameraInfo { let info = cameraInfos.get(camera); if (info !== undefined) { let width = camera.window.width; @@ -67,6 +70,9 @@ export function prepareResource (ppl: BasicPipeline, camera: Camera, height = 1; } const windowID = prepareRenderWindow(camera); + info.width = width; + info.height = height; + info.windowID = windowID; updateResourceFunc(ppl, info); return info; } @@ -84,7 +90,7 @@ export function prepareResource (ppl: BasicPipeline, camera: Camera, return info; } -function buildShadowRes (ppl: BasicPipeline, name: string, width, height): void { +function buildShadowRes (ppl: BasicPipeline, name: string, width: number, height: number): void { const fboW = width; const fboH = height; const shadowMapName = name; @@ -111,7 +117,7 @@ export function setupShadowRes (ppl: BasicPipeline, cameraInfo: CameraInfo): Sha const _validLights: Light[] = shadowInfo.validLights; let n = 0; let m = 0; - for (;n < shadow.maxReceived && m < validPunctualLights.length;) { + for (; n < shadow.maxReceived && m < validPunctualLights.length;) { const light = validPunctualLights[m]; if (light.type === LightType.SPOT) { const spotLight = light as any; @@ -149,12 +155,17 @@ export function setupShadowRes (ppl: BasicPipeline, cameraInfo: CameraInfo): Sha return shadowInfo; } -export const updateShadowRes = setupShadowRes; +export const updateShadowRes = setupShadowRes; let shadowPass; -function buildShadowPass (passName: Readonly, +function buildShadowPass ( + passName: Readonly, ppl: BasicPipeline, - camera: Camera, light: Light, level: number, - width: Readonly, height: Readonly): void { + camera: Camera, + light: Light, + level: number, + width: Readonly, + height: Readonly, +): void { const fboW = width; const fboH = height; const area = getRenderArea(camera, width, height, light, level); @@ -166,12 +177,21 @@ function buildShadowPass (passName: Readonly, shadowPass.name = passName; shadowPass.setViewport(new Viewport(0, 0, fboW, fboH)); shadowPass.addRenderTarget(shadowMapName, LoadOp.CLEAR, StoreOp.STORE, new Color(1, 1, 1, camera.clearColor.w)); - shadowPass.addDepthStencil(`${shadowMapName}Depth`, LoadOp.CLEAR, StoreOp.DISCARD, - camera.clearDepth, camera.clearStencil, ClearFlagBit.DEPTH_STENCIL); + shadowPass.addDepthStencil( + `${shadowMapName}Depth`, + LoadOp.CLEAR, + StoreOp.DISCARD, + camera.clearDepth, + camera.clearStencil, + ClearFlagBit.DEPTH_STENCIL, + ); } const queue = shadowPass.addQueue(QueueHint.RENDER_OPAQUE, 'shadow-caster'); - queue.addSceneOfCamera(camera, new LightInfo(light, level), - SceneFlags.SHADOW_CASTER); + queue.addSceneOfCamera( + camera, + new LightInfo(light, level), + SceneFlags.SHADOW_CASTER, + ); queue.setViewport(new Viewport(area.x, area.y, area.width, area.height)); } export function setupShadowPass (ppl: BasicPipeline, cameraInfo: CameraInfo): void { @@ -185,14 +205,28 @@ export function setupShadowPass (ppl: BasicPipeline, cameraInfo: CameraInfo): vo if (mainLight && mainLight.shadowEnabled) { shadowInfo.mainLightShadowNames[0] = `MainLightShadow${cameraInfo.id}`; if (mainLight.shadowFixedArea) { - buildShadowPass(shadowInfo.mainLightShadowNames[0], ppl, - camera, mainLight, 0, mapWidth, mapHeight); + buildShadowPass( + shadowInfo.mainLightShadowNames[0], + ppl, + camera, + mainLight, + 0, + mapWidth, + mapHeight, + ); } else { const csmLevel = ppl.pipelineSceneData.csmSupported ? mainLight.csmLevel : 1; shadowInfo.mainLightShadowNames[0] = `MainLightShadow${cameraInfo.id}`; for (let i = 0; i < csmLevel; i++) { - buildShadowPass(shadowInfo.mainLightShadowNames[0], ppl, - camera, mainLight, i, mapWidth, mapHeight); + buildShadowPass( + shadowInfo.mainLightShadowNames[0], + ppl, + camera, + mainLight, + i, + mapWidth, + mapHeight, + ); } } } @@ -201,8 +235,15 @@ export function setupShadowPass (ppl: BasicPipeline, cameraInfo: CameraInfo): vo const light = shadowInfo.validLights[l]; const passName = `SpotLightShadow${l.toString()}${cameraInfo.id}`; shadowInfo.spotLightShadowNames[l] = passName; - buildShadowPass(passName, ppl, - camera, light, 0, mapWidth, mapHeight); + buildShadowPass( + passName, + ppl, + camera, + light, + 0, + mapWidth, + mapHeight, + ); } } @@ -215,8 +256,13 @@ export function setupForwardRes (ppl: BasicPipeline, cameraInfo: CameraInfo, isO if (!isOffScreen) { ppl.addRenderWindow(`ForwardColor${cameraInfo.id}`, Format.BGRA8, width, height, cameraInfo.camera.window); } else { - ppl.addRenderTarget(`ForwardColor${cameraInfo.id}`, getRTFormatBeforeToneMapping(ppl), - width, height, ResourceResidency.PERSISTENT); + ppl.addRenderTarget( + `ForwardColor${cameraInfo.id}`, + getRTFormatBeforeToneMapping(ppl), + width, + height, + ResourceResidency.PERSISTENT, + ); } ppl.addDepthStencil(`ForwardDepthStencil${cameraInfo.id}`, Format.DEPTH_STENCIL, width, height); } @@ -235,7 +281,7 @@ export function updateForwardRes (ppl: BasicPipeline, cameraInfo: CameraInfo, is ppl.updateDepthStencil(`ForwardDepthStencil${cameraInfo.id}`, width, height); } -export function setupDeferredForward (ppl: BasicPipeline, cameraInfo: CameraInfo, inputColor: string): void { +export function setupDeferredForward (ppl: BasicPipeline, cameraInfo: CameraInfo, inputColor: string, clusterLighting?: boolean): void { const area = getRenderArea(cameraInfo.camera, cameraInfo.camera.window.width, cameraInfo.camera.window.height); const width = area.width; const height = area.height; @@ -255,10 +301,12 @@ export function setupDeferredForward (ppl: BasicPipeline, cameraInfo: CameraInfo } } + let sceneFlags = SceneFlags.OPAQUE_OBJECT | SceneFlags.PLANAR_SHADOW | SceneFlags.CUTOUT_OBJECT + | SceneFlags.DRAW_INSTANCING; + sceneFlags |= clusterLighting ? SceneFlags.CLUSTERED_LIGHTING : SceneFlags.DEFAULT_LIGHTING; + forwardPass.addQueue(QueueHint.RENDER_OPAQUE, 'deferred-forward') - .addSceneOfCamera(camera, new LightInfo(), - SceneFlags.OPAQUE_OBJECT | SceneFlags.PLANAR_SHADOW | SceneFlags.CUTOUT_OBJECT - | SceneFlags.DEFAULT_LIGHTING | SceneFlags.DRAW_INSTANCING); + .addSceneOfCamera(camera, new LightInfo(), sceneFlags); forwardPass.addQueue(QueueHint.RENDER_TRANSPARENT, 'deferred-forward') .addSceneOfCamera(camera, new LightInfo(), SceneFlags.TRANSPARENT_OBJECT | SceneFlags.GEOMETRY); } @@ -286,22 +334,29 @@ export function setupForwardPass (ppl: BasicPipeline, cameraInfo: CameraInfo, is } } const camera = cameraInfo.camera; - forwardPass.addRenderTarget(`ForwardColor${cameraInfo.id}`, + forwardPass.addRenderTarget( + `ForwardColor${cameraInfo.id}`, isOffScreen ? LoadOp.CLEAR : getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET), StoreOp.STORE, - new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w)); - forwardPass.addDepthStencil(`ForwardDepthStencil${cameraInfo.id}`, + new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w), + ); + forwardPass.addDepthStencil( + `ForwardDepthStencil${cameraInfo.id}`, isOffScreen ? LoadOp.CLEAR : getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL), // If the depth texture is used by subsequent passes, it must be set to store. isOffScreen ? StoreOp.DISCARD : StoreOp.STORE, camera.clearDepth, camera.clearStencil, - camera.clearFlag); + camera.clearFlag, + ); forwardPass .addQueue(QueueHint.RENDER_OPAQUE) - .addSceneOfCamera(camera, new LightInfo(), + .addSceneOfCamera( + camera, + new LightInfo(), SceneFlags.OPAQUE_OBJECT | SceneFlags.PLANAR_SHADOW | SceneFlags.CUTOUT_OBJECT - | SceneFlags.DEFAULT_LIGHTING | SceneFlags.DRAW_INSTANCING); + | SceneFlags.DEFAULT_LIGHTING | SceneFlags.DRAW_INSTANCING, + ); let sceneFlags = SceneFlags.TRANSPARENT_OBJECT | SceneFlags.GEOMETRY; if (!isOffScreen) { @@ -337,10 +392,11 @@ export function setupReflectionProbeRes (ppl: BasicPipeline, info: CameraInfo): const probes = cclegacy.internal.reflectionProbeManager.getProbes(); if (probes.length === 0) return; for (let i = 0; i < probes.length; i++) { - const probe = probes[i]; + const probe = probes[i] as ReflectionProbe; if (probe.needRender) { if (probes[i].probeType === ProbeType.PLANAR) { - buildReflectionProbeRes(ppl, probe, probe.realtimePlanarTexture.window!, 0); + const window: RenderWindow = probe.realtimePlanarTexture!.window!; + buildReflectionProbeRes(ppl, probe, window, 0); } else if (EDITOR) { for (let faceIdx = 0; faceIdx < probe.bakedCubeTextures.length; faceIdx++) { probe.updateCameraDir(faceIdx); @@ -366,10 +422,20 @@ function buildReflectProbePass (ppl: BasicPipeline, info: CameraInfo, probe: Ref const probePass = ppl.addRenderPass(width, height, 'default'); probePass.name = `ReflectionProbePass${faceIdx}`; probePass.setViewport(new Viewport(0, 0, width, height)); - probePass.addRenderTarget(probePassRTName, getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.RENDER_TARGET), - StoreOp.STORE, new Color(probeCamera.clearColor.x, probeCamera.clearColor.y, probeCamera.clearColor.z, probeCamera.clearColor.w)); - probePass.addDepthStencil(probePassDSName, getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.DEPTH_STENCIL), - StoreOp.STORE, probeCamera.clearDepth, probeCamera.clearStencil, probeCamera.clearFlag); + probePass.addRenderTarget( + probePassRTName, + getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.RENDER_TARGET), + StoreOp.STORE, + new Color(probeCamera.clearColor.x, probeCamera.clearColor.y, probeCamera.clearColor.z, probeCamera.clearColor.w), + ); + probePass.addDepthStencil( + probePassDSName, + getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.DEPTH_STENCIL), + StoreOp.STORE, + probeCamera.clearDepth, + probeCamera.clearStencil, + probeCamera.clearFlag, + ); const passBuilder = probePass.addQueue(QueueHint.RENDER_OPAQUE); passBuilder.addSceneOfCamera(info.camera, new LightInfo(), SceneFlags.REFLECTION_PROBE); updateCameraUBO(passBuilder as unknown as any, probeCamera, ppl); @@ -380,10 +446,11 @@ export function setupReflectionProbePass (ppl: BasicPipeline, info: CameraInfo): const probes = cclegacy.internal.reflectionProbeManager.getProbes(); if (probes.length === 0) return; for (let i = 0; i < probes.length; i++) { - const probe = probes[i]; + const probe = probes[i] as ReflectionProbe; if (probe.needRender) { if (probes[i].probeType === ProbeType.PLANAR) { - buildReflectProbePass(ppl, info, probe, probe.realtimePlanarTexture.window!, 0); + const window = probe.realtimePlanarTexture!.window!; + buildReflectProbePass(ppl, info, probe, window, 0); } else if (EDITOR) { for (let faceIdx = 0; faceIdx < probe.bakedCubeTextures.length; faceIdx++) { probe.updateCameraDir(faceIdx); @@ -465,8 +532,17 @@ export function setupScenePassTiled (pipeline: BasicPipeline, info: CameraInfo, gBufferPass.addRenderTarget(gBufferPassRTName, AccessType.WRITE, '_', LoadOp.CLEAR, StoreOp.DISCARD, emptyColor); gBufferPass.addRenderTarget(gBufferPassNormal, AccessType.WRITE, '_', LoadOp.CLEAR, StoreOp.DISCARD, emptyColor); gBufferPass.addRenderTarget(gBufferPassEmissive, AccessType.WRITE, '_', LoadOp.CLEAR, StoreOp.DISCARD, emptyColor); - gBufferPass.addDepthStencil(gBufferPassDSName, AccessType.WRITE, '_', '_', - LoadOp.CLEAR, StoreOp.DISCARD, camera.clearDepth, camera.clearStencil, camera.clearFlag); + gBufferPass.addDepthStencil( + gBufferPassDSName, + AccessType.WRITE, + '_', + '_', + LoadOp.CLEAR, + StoreOp.DISCARD, + camera.clearDepth, + camera.clearStencil, + camera.clearFlag, + ); gBufferPass .addQueue(QueueHint.RENDER_OPAQUE, 'gbuffer-tiled') .addSceneOfCamera(camera, new LightInfo(), SceneFlags.OPAQUE_OBJECT | SceneFlags.CUTOUT_OBJECT); @@ -494,7 +570,9 @@ export function setupScenePassTiled (pipeline: BasicPipeline, info: CameraInfo, const deferredLightingPassRTName = `deferredLightingPassRTName${info.id}`; lightingPass.addRenderTarget(deferredLightingPassRTName, AccessType.WRITE, '_', LoadOp.CLEAR, StoreOp.STORE, rtColor); lightingPass.addQueue(QueueHint.RENDER_TRANSPARENT, 'deferred-lighting-tiled').addCameraQuad( - camera, lightingInfo.deferredLightingMaterial, 1, + camera, + lightingInfo.deferredLightingMaterial, + 1, SceneFlags.VOLUMETRIC_LIGHTING, ); return { rtName: deferredLightingPassRTName }; @@ -608,7 +686,9 @@ export function setupLightingPass (pipeline: BasicPipeline, info: CameraInfo, us lightingClearColor.w = 0; lightingPass.addRenderTarget(deferredLightingPassRTName, LoadOp.CLEAR, StoreOp.STORE, lightingClearColor); lightingPass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad( - camera, lightingInfo.deferredLightingMaterial, 0, + camera, + lightingInfo.deferredLightingMaterial, + 0, SceneFlags.VOLUMETRIC_LIGHTING, ); // lightingPass.addQueue(QueueHint.RENDER_TRANSPARENT).addSceneOfCamera(camera, new LightInfo(), @@ -640,9 +720,11 @@ export function updatePostprocessRes (ppl: BasicPipeline, info: CameraInfo): voi ppl.updateDepthStencil(postprocessPassDS, width, height); } let postInfo: PostInfo; -export function setupPostprocessPass (ppl: BasicPipeline, +export function setupPostprocessPass ( + ppl: BasicPipeline, info: CameraInfo, - inputTex: string): { rtName: string; dsName: string; } { + inputTex: string, +): { rtName: string; dsName: string; } { if (!postInfo) { postInfo = new PostInfo(); } @@ -665,13 +747,29 @@ export function setupPostprocessPass (ppl: BasicPipeline, postClearColor.y = camera.clearColor.y; postClearColor.z = camera.clearColor.z; } - postprocessPass.addRenderTarget(postprocessPassRTName, - getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET), StoreOp.STORE, postClearColor); - postprocessPass.addDepthStencil(postprocessPassDS, + postprocessPass.addRenderTarget( + postprocessPassRTName, + getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET), + + StoreOp.STORE, + + postClearColor, + ); + postprocessPass.addDepthStencil( + postprocessPassDS, getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL), - StoreOp.STORE, camera.clearDepth, camera.clearStencil, camera.clearFlag); + StoreOp.STORE, + + camera.clearDepth, + + camera.clearStencil, + + camera.clearFlag, + ); postprocessPass.addQueue(QueueHint.NONE).addCameraQuad( - camera, postInfo.postMaterial, 0, + camera, + postInfo.postMaterial, + 0, SceneFlags.NONE, ); if (getProfilerCamera() === camera) { @@ -680,8 +778,10 @@ export function setupPostprocessPass (ppl: BasicPipeline, return { rtName: postprocessPassRTName, dsName: postprocessPassDS }; } -export function setupUIRes (ppl: BasicPipeline, - info: CameraInfo): void { +export function setupUIRes ( + ppl: BasicPipeline, + info: CameraInfo, +): void { const camera = info.camera; const area = getRenderArea(camera, camera.window.width, camera.window.height); const width = area.width; @@ -693,8 +793,10 @@ export function setupUIRes (ppl: BasicPipeline, ppl.addDepthStencil(dsUIAndProfilerPassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED); } -export function updateUIRes (ppl: BasicPipeline, - info: CameraInfo): void { +export function updateUIRes ( + ppl: BasicPipeline, + info: CameraInfo, +): void { const camera = info.camera; const area = getRenderArea(camera, camera.window.width, camera.window.height); const width = area.width; @@ -706,8 +808,10 @@ export function updateUIRes (ppl: BasicPipeline, ppl.updateDepthStencil(dsUIAndProfilerPassDSName, width, height); } -export function setupUIPass (ppl: BasicPipeline, - info: CameraInfo): void { +export function setupUIPass ( + ppl: BasicPipeline, + info: CameraInfo, +): void { const camera = info.camera; const area = getRenderArea(camera, camera.window.width, camera.window.height); const width = area.width; @@ -717,14 +821,22 @@ export function setupUIPass (ppl: BasicPipeline, const uiAndProfilerPass = ppl.addRenderPass(width, height, 'default'); uiAndProfilerPass.name = `CameraUIAndProfilerPass${info.id}`; uiAndProfilerPass.setViewport(new Viewport(area.x, area.y, width, height)); - uiAndProfilerPass.addRenderTarget(dsUIAndProfilerPassRTName, + uiAndProfilerPass.addRenderTarget( + dsUIAndProfilerPassRTName, getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET), StoreOp.STORE, - new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w)); - uiAndProfilerPass.addDepthStencil(dsUIAndProfilerPassDSName, + new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w), + ); + uiAndProfilerPass.addDepthStencil( + dsUIAndProfilerPassDSName, getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL), StoreOp.STORE, - camera.clearDepth, camera.clearStencil, camera.clearFlag); + camera.clearDepth, + + camera.clearStencil, + + camera.clearFlag, + ); const sceneFlags = SceneFlags.UI; uiAndProfilerPass .addQueue(QueueHint.RENDER_TRANSPARENT) diff --git a/cocos/rendering/render-additive-light-queue.ts b/cocos/rendering/render-additive-light-queue.ts index ce569f7260e..0b6534f7ccc 100644 --- a/cocos/rendering/render-additive-light-queue.ts +++ b/cocos/rendering/render-additive-light-queue.ts @@ -27,7 +27,7 @@ import { Model } from '../render-scene/scene/model'; import { PipelineStateManager } from './pipeline-state-manager'; import { Vec3, nextPow2, Mat4, Color, Pool, geometry, cclegacy } from '../core'; import { Device, RenderPass, Buffer, BufferUsageBit, MemoryUsageBit, - BufferInfo, BufferViewInfo, CommandBuffer } from '../gfx'; + BufferInfo, BufferViewInfo, CommandBuffer, deviceManager } from '../gfx'; import { RenderInstancedQueue } from './render-instanced-queue'; import { SphereLight } from '../render-scene/scene/sphere-light'; import { SpotLight } from '../render-scene/scene/spot-light'; @@ -170,7 +170,7 @@ export class RenderAdditiveLightQueue { const keys = descriptorSetMap.keys; for (let i = 0; i < keys.length; i++) { - const key = keys[i]; + const key = keys[i] as Light; const descriptorSet = descriptorSetMap.get(key)!; if (descriptorSet) { const binding = isEnableEffect() ? getDescBindingFromName('CCShadow') : UBOShadow.BINDING; @@ -183,7 +183,7 @@ export class RenderAdditiveLightQueue { } } - private _bindForwardAddLight (validPunctualLights, passLayout = 'default'): void { + private _bindForwardAddLight(validPunctualLights: Light[], passLayout = 'default'): void { const renderObjects = this._pipeline.pipelineSceneData.renderObjects; for (let i = 0; i < renderObjects.length; i++) { const ro = renderObjects[i]; @@ -490,7 +490,7 @@ export class RenderAdditiveLightQueue { this._lightBuffer.resize(this._lightBufferStride * this._lightBufferCount); this._lightBufferData = new Float32Array(this._lightBufferElementCount * this._lightBufferCount); - this._firstLightBufferView.initialize(new BufferViewInfo(this._lightBuffer, 0, UBOForwardLight.SIZE)); + this._firstLightBufferView = deviceManager.gfxDevice.createBuffer(new BufferViewInfo(this._lightBuffer, 0, UBOForwardLight.SIZE)); } for (let l = 0, offset = 0; l < validPunctualLights.length; l++, offset += this._lightBufferElementCount) {