Skip to content

Commit

Permalink
skip batch when GFX Texture is null (#16273)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinYunMo authored Sep 18, 2023
1 parent 5aecd91 commit 1ee3a59
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,15 @@ export class Batcher2D implements IBatcher {
* @param mat - The material used
* @param enableBatch - component support multi draw batch or not
*/
public commitMiddleware (comp: UIRenderer, meshBuffer: MeshBuffer, indexOffset: number,
indexCount: number, tex: TextureBase, mat: Material, enableBatch: boolean): void {
public commitMiddleware (
comp: UIRenderer,
meshBuffer: MeshBuffer,
indexOffset: number,
indexCount: number,
tex: TextureBase,
mat: Material,
enableBatch: boolean,
): void {
// check if need merge draw batch
const texture = tex.getGFXTexture();
if (enableBatch && this._middlewareEnableBatch && this._middlewareBuffer === meshBuffer
Expand Down Expand Up @@ -654,7 +661,7 @@ export class Batcher2D implements IBatcher {
this._currBID = -1;

// Request ia failed
if (!ia) {
if (!ia || !this._currTexture) {
return;
}

Expand All @@ -671,7 +678,7 @@ export class Batcher2D implements IBatcher {

const curDrawBatch = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc();
curDrawBatch.visFlags = this._currLayer;
curDrawBatch.texture = this._currTexture!;
curDrawBatch.texture = this._currTexture;
curDrawBatch.sampler = this._currSampler;
curDrawBatch.inputAssembler = ia;
curDrawBatch.useLocalData = this._currTransform;
Expand Down

0 comments on commit 1ee3a59

Please sign in to comment.