Skip to content

Commit 89a402b

Browse files
committed
fix(2d): fix buffer update error
1 parent fdddc3d commit 89a402b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/core/src/RenderPipeline/BatchUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ export class BatchUtils {
6161
}
6262
chunk.updateIndexLength += length;
6363
chunk.updateVertexStart = Math.min(chunk.updateVertexStart, start);
64-
chunk.updateVertexLength = Math.max(chunk.updateVertexLength, start + size);
64+
chunk.updateVertexEnd = Math.max(chunk.updateVertexEnd, start + size);
6565
}
6666
}

packages/core/src/RenderPipeline/PrimitiveChunk.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
VertexElementFormat
1515
} from "../graphic";
1616
import { ReturnableObjectPool } from "../utils/ReturnableObjectPool";
17-
import { VertexArea } from "./VertexArea";
1817
import { SubPrimitiveChunk } from "./SubPrimitiveChunk";
18+
import { VertexArea } from "./VertexArea";
1919

2020
/**
2121
* @internal
@@ -30,7 +30,7 @@ export class PrimitiveChunk {
3030
indices: Uint16Array;
3131

3232
updateVertexStart = Number.MAX_SAFE_INTEGER;
33-
updateVertexLength = Number.MIN_SAFE_INTEGER;
33+
updateVertexEnd = Number.MIN_SAFE_INTEGER;
3434
updateIndexLength = 0;
3535

3636
vertexFreeAreas: Array<VertexArea>;
@@ -90,18 +90,18 @@ export class PrimitiveChunk {
9090
uploadBuffer(): void {
9191
// Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
9292
// Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
93-
const { primitive, updateVertexStart, updateVertexLength } = this;
94-
if (updateVertexStart !== Number.MAX_SAFE_INTEGER && updateVertexLength !== Number.MIN_SAFE_INTEGER) {
93+
const { primitive, updateVertexStart, updateVertexEnd } = this;
94+
if (updateVertexStart !== Number.MAX_SAFE_INTEGER && updateVertexEnd !== Number.MIN_SAFE_INTEGER) {
9595
primitive.vertexBufferBindings[0].buffer.setData(
9696
this.vertices,
9797
updateVertexStart * 4,
9898
updateVertexStart,
99-
updateVertexLength,
99+
updateVertexEnd - updateVertexStart,
100100
SetDataOptions.Discard
101101
);
102102

103103
this.updateVertexStart = Number.MAX_SAFE_INTEGER;
104-
this.updateVertexLength = Number.MIN_SAFE_INTEGER;
104+
this.updateVertexEnd = Number.MIN_SAFE_INTEGER;
105105
}
106106

107107
primitive.indexBufferBinding.buffer.setData(this.indices, 0, 0, this.updateIndexLength, SetDataOptions.Discard);

0 commit comments

Comments
 (0)