From 4e19ec4f1127e6caa59879299de31ab1d8385a63 Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Tue, 15 Oct 2024 19:30:49 +0800 Subject: [PATCH] fix pointer --- cocos/gfx/base/define.ts | 7 ++++++- cocos/gfx/base/states/texture-barrier.ts | 10 ++++++---- native/tools/gfx-define-generator/generate.js | 6 ++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cocos/gfx/base/define.ts b/cocos/gfx/base/define.ts index 66e9cdf6aa4..cc67e380d71 100644 --- a/cocos/gfx/base/define.ts +++ b/cocos/gfx/base/define.ts @@ -1796,8 +1796,13 @@ export class DescriptorSetInfo { declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object constructor ( - public readonly layout: DescriptorSetLayout = null!, + public layout: DescriptorSetLayout = null!, ) {} + + public copy (info: Readonly): DescriptorSetInfo { + this.layout = info.layout; + return this; + } } export class PipelineLayoutInfo { diff --git a/cocos/gfx/base/states/texture-barrier.ts b/cocos/gfx/base/states/texture-barrier.ts index 97d23609f9b..9f3f8282404 100644 --- a/cocos/gfx/base/states/texture-barrier.ts +++ b/cocos/gfx/base/states/texture-barrier.ts @@ -45,10 +45,12 @@ export class TextureBarrier extends GFXObject { static computeHash (info: Readonly): number { let res = `${info.prevAccesses} ${info.nextAccesses}`; res += info.type; - res += info.baseMipLevel; - res += info.levelCount; - res += info.baseSlice; - res += info.sliceCount; + res += info.range.mipLevel; + res += info.range.levelCount; + res += info.range.firstSlice; + res += info.range.numSlices; + res += info.range.basePlane; + res += info.range.planeCount; res += info.discardContents; res += info.srcQueue ? info.srcQueue.type : 0; res += info.dstQueue ? info.dstQueue.type : 0; diff --git a/native/tools/gfx-define-generator/generate.js b/native/tools/gfx-define-generator/generate.js index c60a0793b2a..0a53870cd83 100644 --- a/native/tools/gfx-define-generator/generate.js +++ b/native/tools/gfx-define-generator/generate.js @@ -171,7 +171,9 @@ while (structCap) { // structRE can not reliably extract the correct member declaration range let memberList = getMemberList(header, structCap.index + structCap[1].length); // discard pointer signs - memberList = memberList.replace(/\*/g, ''); + const memberList2 = memberList.replace(/\*/g, ''); + const hasPointer = memberList2 !== memberList; + memberList = memberList2; let memberCap = structMemberRE.exec(memberList); while (memberCap) { @@ -187,7 +189,7 @@ while (structCap) { type = type.replace(/(\b)(?:String)(\b)/, '$1string$2'); type = type.replace(/(\b)(?:ccstd::string)(\b)/, '$1string$2'); type = type.replace(/(\b)(?:ccstd::hash_t)(\b)/, '$1number$2'); - if (memberCap[1]) {readonly = true;} + if (memberCap[1] && !hasPointer) {readonly = true;} const isArray = type.endsWith('[]'); const decayedType = isArray ? type.slice(0, -2) : type;