# Mesh batching

**URL:** <https://forum.defold.com/t/mesh-batching/78509>\
**Category:** Questions\
**Created:** [October 18, 2024, 5:51pm UTC](https://forum.defold.com/t/mesh-batching/78509 "2024-10-18T17:51:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [October 18, 2024, 5:51pm UTC](https://forum.defold.com/t/mesh-batching/78509/1 "2024-10-18T17:51:45Z")

</div>

I have two meshes with the same materials and the same vertex and fragment constants. The vertex space is set to World.

Should they be batched in the same drawcall? It seems to me that two drawcalls are used.

Is there something I am missing?

Thanks!

EDIT: The mesh uses triangle strip as primitive type. Is this preventing batching? In any case, triangle strips could be batched using degenerate triangles.  
Of course I could batch the strips myself in lua. But just to understand.

---

<div class="post-metadata">

**Author:** ![Dragosha](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dragosha/32/5103_2.png) [@Dragosha](https://forum.defold.com/u/Dragosha)\
**Post date:** [October 19, 2024, 4:33am UTC](https://forum.defold.com/t/mesh-batching/78509/2 "2024-10-19T04:33:22Z")

</div>

> [@roccosaienz](#):
>
> Is there something I am missing?

the same texture?

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [October 19, 2024, 8:53am UTC](https://forum.defold.com/t/mesh-batching/78509/3 "2024-10-19T08:53:41Z")

</div>

Yes, same texture

---

<div class="post-metadata">

**Author:** ![Dragosha](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dragosha/32/5103_2.png) [@Dragosha](https://forum.defold.com/u/Dragosha)\
**Post date:** [October 19, 2024, 8:58am UTC](https://forum.defold.com/t/mesh-batching/78509/4 "2024-10-19T08:58:13Z")

</div>

Hmm, in that case, try testing draw calls with more of these meshes. Maybe the second DC is a GUI or profiler drawing?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 19, 2024, 9:00am UTC](https://forum.defold.com/t/mesh-batching/78509/5 "2024-10-19T09:00:57Z")

</div>

When in doubt, check the source code:

> <https://github.com/defold/defold/blob/dev/engine/gamesys/src/gamesys/components/comp_mesh.cpp#L320-L352>

Do you have the same buffers? Same vertex declaration?

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [October 19, 2024, 11:22am UTC](https://forum.defold.com/t/mesh-batching/78509/6 "2024-10-19T11:22:30Z")

</div>

No, no, each time I add a new mesh I see a new drawcall

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [October 19, 2024, 11:25am UTC](https://forum.defold.com/t/mesh-batching/78509/7 "2024-10-19T11:25:27Z")

</div>

The meshes have the same vertex declaration, yes; position, normal and colors.

About buffers. I am not sure I understand what you mean. Each mesh has its own buffer (otherwise they are the same mesh in different positions). But also different mesh could be batched if they have the same vertex data and the same material. Or not?

---

<div class="post-metadata">

**Author:** ![abeg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/abeg/32/30906_2.png) [@abeg](https://forum.defold.com/u/abeg)\
**Post date:** [January 20, 2025, 7:34pm UTC](https://forum.defold.com/t/mesh-batching/78509/8 "2025-01-20T19:34:36Z")

</div>

I’ve come across the same and have submitted a bug on gitHub with more details about the issue (see [Mesh component render batching does not work #10082](https://github.com/defold/defold/issues/10082)).

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [January 20, 2025, 8:47pm UTC](https://forum.defold.com/t/mesh-batching/78509/9 "2025-01-20T20:47:37Z")

</div>

Thank you so much for this! You have done an amazing work in reporting the issue!
