diff --git a/cocos/rendering/custom/scene-culling.ts b/cocos/rendering/custom/scene-culling.ts index c2b74a07516..5beeebd7c2a 100644 --- a/cocos/rendering/custom/scene-culling.ts +++ b/cocos/rendering/custom/scene-culling.ts @@ -791,7 +791,7 @@ export class LightResource { } tryUpdateRenderSceneLocalDescriptorSet (sceneCulling: SceneCulling): void { - if (!this.resized || !sceneCulling.lightBoundsCullings.size) { + if (!sceneCulling.lightBoundsCullings.size) { return; } @@ -802,8 +802,11 @@ export class LightResource { } for (const submodel of model.subModels) { const set = submodel.descriptorSet; - set.bindBuffer(this.binding, this.firstLightBufferView!); - set.update(); + const prev = set.getBuffer(this.binding); + if (this.resized || prev !== this.firstLightBufferView) { + set.bindBuffer(this.binding, this.firstLightBufferView!); + set.update(); + } } } } diff --git a/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp b/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp index 2b6cf72cf8c..5b29a87fc9a 100644 --- a/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp @@ -785,7 +785,7 @@ void LightResource::buildLightBuffer(gfx::CommandBuffer* cmdBuffer) const { } void LightResource::tryUpdateRenderSceneLocalDescriptorSet(const SceneCulling& sceneCulling) { - if (!resized) { + if (sceneCulling.lightBoundsCullingResults.empty()) { return; } @@ -794,8 +794,11 @@ void LightResource::tryUpdateRenderSceneLocalDescriptorSet(const SceneCulling& s CC_EXPECTS(model); for (const auto& submodel : model->getSubModels()) { auto* set = submodel->getDescriptorSet(); - set->bindBuffer(binding, firstLightBufferView); - set->update(); + const auto& prev = set->getBuffer(binding); + if (resized || prev != firstLightBufferView) { + set->bindBuffer(binding, firstLightBufferView); + set->update(); + } } } }