From e36739ea8fc3ccf6c967f785399be66ada39448a Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Mon, 6 Jun 2022 14:17:48 +0800 Subject: [PATCH 1/2] IA bug fix --- native/cocos/2d/renderer/UIMeshBuffer.cpp | 6 +++--- native/cocos/scene/DrawBatch2D.h | 5 ----- native/tools/tojs/2d.ini | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/native/cocos/2d/renderer/UIMeshBuffer.cpp b/native/cocos/2d/renderer/UIMeshBuffer.cpp index 6b16bae7c94..b756d095a0d 100644 --- a/native/cocos/2d/renderer/UIMeshBuffer.cpp +++ b/native/cocos/2d/renderer/UIMeshBuffer.cpp @@ -38,7 +38,7 @@ void UIMeshBuffer::initialize(gfx::Device* device, std::vector& //for (index_t i = 0; i < attrs.size(); i++) { // _attributes.push_back(*attrs[i]); //} - _iaPool.push_back(createNewIA(device)); + // _iaPool.push_back(createNewIA(device)); } void UIMeshBuffer::reset() { @@ -82,7 +82,7 @@ void UIMeshBuffer::setDirty() { gfx::InputAssembler* UIMeshBuffer::requireFreeIA(gfx::Device* device) { if (_nextFreeIAHandle >= _iaPool.size()) { - _iaPool.push_back(createNewIA(device)); + createNewIA(device); } auto ia = _iaPool[_nextFreeIAHandle]; _nextFreeIAHandle++; @@ -147,7 +147,7 @@ gfx::InputAssembler* UIMeshBuffer::createNewIA(gfx::Device* device) { _iaInfo.indexBuffer = indexBuffer; auto* ia = device->createInputAssembler(_iaInfo); - _iaPool.push_back(ia); + _iaPool.emplace_back(ia); return ia; } diff --git a/native/cocos/scene/DrawBatch2D.h b/native/cocos/scene/DrawBatch2D.h index 4f6b3c6b3ae..42b55e58049 100644 --- a/native/cocos/scene/DrawBatch2D.h +++ b/native/cocos/scene/DrawBatch2D.h @@ -69,11 +69,6 @@ class DrawBatch2D : public RefCounted { ccstd::vector> _passes; ccstd::vector _shaders; - gfx::Texture *_texture{nullptr}; // Or use DS? - gfx::Sampler *_sampler{nullptr}; // Or use DS? - uint32_t textureHash{0}; // May don`t need - uint32_t samplerHash{0}; // May don`t need - Node *_useLocalData{nullptr}; // May don`t need Model *_model{nullptr}; }; diff --git a/native/tools/tojs/2d.ini b/native/tools/tojs/2d.ini index 6120a51acb7..91430ae8e3b 100644 --- a/native/tools/tojs/2d.ini +++ b/native/tools/tojs/2d.ini @@ -45,7 +45,7 @@ classes = RenderEntity UIMeshBuffer Batcher2d AdvanceRenderData # functions from all classes. skip = RenderEntity::[getRenderDataArr parseLayout refreshLayout getStride getSize], Batcher2d::[parseAttr getBatches], - UIMeshBuffer::[requireFreeIA createNewIA recycleIA] + UIMeshBuffer::[requireFreeIA createNewIA recycleIA resetIA] rename_functions = From cce80d180be9a3f1f988ee3f132d307645197188 Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Mon, 6 Jun 2022 14:34:07 +0800 Subject: [PATCH 2/2] ia new bug --- native/cocos/2d/renderer/UIMeshBuffer.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/native/cocos/2d/renderer/UIMeshBuffer.cpp b/native/cocos/2d/renderer/UIMeshBuffer.cpp index b756d095a0d..3fe14cd245a 100644 --- a/native/cocos/2d/renderer/UIMeshBuffer.cpp +++ b/native/cocos/2d/renderer/UIMeshBuffer.cpp @@ -145,13 +145,12 @@ gfx::InputAssembler* UIMeshBuffer::createNewIA(gfx::Device* device) { _iaInfo.attributes = _attributes; _iaInfo.vertexBuffers.emplace_back(vertexBuffer); _iaInfo.indexBuffer = indexBuffer; - - auto* ia = device->createInputAssembler(_iaInfo); - _iaPool.emplace_back(ia); - - return ia; } - return _iaPool.back(); + auto* ia = device->createInputAssembler(_iaInfo); + _iaPool.emplace_back(ia); + + return ia; + // return _iaPool.back(); } void UIMeshBuffer::syncSharedBufferToNative(index_t* buffer) {