Skip to content

Commit

Permalink
Merge pull request cocos#7 from LinYunMo/native-simple-batcher2d-new
Browse files Browse the repository at this point in the history
IA bug fix
  • Loading branch information
Zhmz committed Jun 6, 2022
2 parents 0e07928 + cce80d1 commit 5e44c90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
15 changes: 7 additions & 8 deletions native/cocos/2d/renderer/UIMeshBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void UIMeshBuffer::initialize(gfx::Device* device, std::vector<gfx::Attribute*>&
//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() {
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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.push_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) {
Expand Down
5 changes: 0 additions & 5 deletions native/cocos/scene/DrawBatch2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ class DrawBatch2D : public RefCounted {
ccstd::vector<IntrusivePtr<scene::Pass>> _passes;
ccstd::vector<gfx::Shader *> _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};
};
Expand Down
2 changes: 1 addition & 1 deletion native/tools/tojs/2d.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 5e44c90

Please sign in to comment.