fix(rendering): use lightIdx instead of loop index l in GPU instancing forward-add light path - #19185
Closed
UC-RX0 wants to merge 1 commit into
Closed
fix(rendering): use lightIdx instead of loop index l in GPU instancing forward-add light path#19185UC-RX0 wants to merge 1 commit into
UC-RX0 wants to merge 1 commit into
Conversation
|
Too many files changed for review. ( |
UC-RX0
force-pushed
the
fix/instancing-light-index
branch
from
June 26, 2026 03:29
0a629f3 to
20536d0
Compare
fix(rendering): use lightIdx instead of loop index l in GPU instancing forward-add light path In _addRenderQueue, the BatchingSchemes.INSTANCING branch was using the local loop index l for getInstancedBuffer() and _instancedQueues[] instead of lightIdx (the global light index from validPunctualLights). This caused mismatched indexing between the instancing path (which used local per-model light indices) and recordCommandBuffer / gatherLightPasses (which use global light indices), resulting in wrong UBO/descriptor bindings for additional lights when different models have different light culling results under GPU instancing. Also added: - Null check in recordCommandBuffer for sparse _instancedQueues entries - lightIdx multiplier on dynamicOffsets for consistency with non-instancing default branch and _instancedLightPassPool convention Fixes: cocos#19170 @
UC-RX0
force-pushed
the
fix/instancing-light-index
branch
from
June 29, 2026 02:36
20536d0 to
33e4363
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Code Size Check Report
Interface Check ReportThis pull request does not change any public interfaces ! |
|
@UC-RX0 ❗ There was an error during the execution of the tasks. Please check the logs for more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
_addRenderQueueofrender-additive-light-queue.ts, theBatchingSchemes.INSTANCINGbranch was using the local loop indexlforgetInstancedBuffer(l)and_instancedQueues[l]instead oflightIdx(the global light index fromvalidPunctualLights).This caused mismatched indexing between:
l)recordCommandBuffer/gatherLightPasses(use global light indiceslightIdx)Result: wrong UBO/descriptor bindings for additional lights when different models have different light culling results under GPU instancing. The non-instancing
defaultbranch already correctly useslightIdx.Fix
Changed 3 occurrences of
ltolightIdxin theBatchingSchemes.INSTANCINGcase:pass.getInstancedBuffer(l)→pass.getInstancedBuffer(lightIdx)this._instancedQueues[l]→this._instancedQueues[lightIdx](2 occurrences)Reproduce Conditions
validPunctualLights)BatchingSchemes.INSTANCING)_lightCullingresults (non-uniform_lightIndicesper model)Fixes: #19170
Changelog