Skip to content

Commit

Permalink
add IOS check
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e committed Sep 18, 2024
1 parent 722540e commit fe7d55a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cocos/gfx/webgl/webgl-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import { BYTEDANCE } from 'internal:constants';
import { systemInfo } from 'pal/system-info';
import { debugID, error, errorID, CachedArray, cclegacy, assertID } from '../../core';
import { WebGLCommandAllocator } from './webgl-command-allocator';
import { WebGLEXT } from './webgl-define';
Expand All @@ -39,6 +40,7 @@ import {
TextureBlit, Filter,
} from '../base/define';
import { WebGLStateCache } from './webgl-state-cache';
import { OS } from '../../../pal/system-info/enum-type';

export function GFXFormatToWebGLType (format: Format, gl: WebGLRenderingContext): GLenum {
switch (format) {
Expand Down Expand Up @@ -830,7 +832,7 @@ export function WebGLCmdFuncUpdateBuffer (
}
}

if ((gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
// Fix performance issue on iOS.
// TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases.
// We should use multiple buffers to avoid stall (cpu write conflicts with gpu read).
Expand Down
8 changes: 5 additions & 3 deletions cocos/gfx/webgl2/webgl2-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
THE SOFTWARE.
*/

import { systemInfo } from 'pal/system-info';
import {
BufferUsageBit, ColorMask, CullMode, DynamicStateFlagBit, Filter, Format, TextureType, Type, FormatInfo,
FormatInfos, FormatSize, LoadOp, MemoryUsageBit, SampleCount, ShaderStageFlagBit, TextureFlagBit,
Expand All @@ -47,6 +48,7 @@ import {
IWebGL2GPURenderPass,
} from './webgl2-gpu-objects';
import { CachedArray, error, errorID, cclegacy, assertID, debugID } from '../../core';
import { OS } from '../../../pal/system-info/enum-type';

const WebGLWraps: GLenum[] = [
0x2901, // WebGLRenderingContext.REPEAT
Expand Down Expand Up @@ -1001,7 +1003,7 @@ export function WebGL2CmdFuncUpdateBuffer (
cache.glArrayBuffer = gpuBuffer.glBuffer;
}

if ((gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
// Fix performance issue on iOS.
// TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases.
// We should use multiple buffers to avoid stall (cpu write conflicts with gpu read).
Expand All @@ -1028,7 +1030,7 @@ export function WebGL2CmdFuncUpdateBuffer (
cache.glElementArrayBuffer = gpuBuffer.glBuffer;
}

if ((gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
// Fix performance issue on iOS.
// TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases.
// We should use multiple buffers to avoid stall (cpu write conflicts with gpu read).
Expand All @@ -1047,7 +1049,7 @@ export function WebGL2CmdFuncUpdateBuffer (
cache.glUniformBuffer = gpuBuffer.glBuffer;
}

if ((gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) {
// Fix performance issue on iOS.
// TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases.
// We should use multiple buffers to avoid stall (cpu write conflicts with gpu read).
Expand Down

0 comments on commit fe7d55a

Please sign in to comment.