Skip to content

Commit c5071f9

Browse files
committed
Fix iOS compilation.
1 parent 0d4b417 commit c5071f9

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

core/renderer/backend/metal/CommandBufferMTL.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,25 @@ class CommandBufferMTL : public CommandBuffer
164164
std::size_t count,
165165
std::size_t offset,
166166
bool wireframe) override;
167-
167+
168+
/**
169+
* Draw primitives with an index list instanced.
170+
* @param primitiveType The type of primitives that elements are assembled into.
171+
* @param indexType The type if indexes, either 16 bit integer or 32 bit integer.
172+
* @param count The number of indexes to read from the index buffer for each instance.
173+
* @param offset Byte offset within indexBuffer to start reading indexes from.
174+
* @param instance Count of
175+
* instances to draw at once.
176+
* @see `setIndexBuffer(Buffer* buffer)`
177+
* @see `drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)`
178+
*/
179+
virtual void drawElementsInstanced(PrimitiveType primitiveType,
180+
IndexFormat indexType,
181+
std::size_t count,
182+
std::size_t offset,
183+
int instance,
184+
bool wireframe = false) override;
185+
168186
/**
169187
* Do some resources release.
170188
*/

core/renderer/backend/metal/CommandBufferMTL.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,22 @@ inline int clamp(int value, int min, int max)
310310
indexBufferOffset:offset];
311311
}
312312

313+
void CommandBufferMTL::drawElementsInstanced(PrimitiveType primitiveType,
314+
IndexFormat indexType,
315+
std::size_t count,
316+
std::size_t offset,
317+
int instanceCount,
318+
bool /* wireframe */)
319+
{
320+
prepareDrawing();
321+
[_mtlRenderEncoder drawIndexedPrimitives:toMTLPrimitive(primitiveType)
322+
indexCount:count
323+
indexType:toMTLIndexType(indexType)
324+
indexBuffer:_mtlIndexBuffer
325+
indexBufferOffset:offset
326+
instanceCount:instanceCount];
327+
}
328+
313329
void CommandBufferMTL::endRenderPass()
314330
{
315331
afterDraw();

core/renderer/backend/opengl/CommandBufferGL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void CommandBufferGL::drawElementsInstanced(PrimitiveType primitiveType,
263263
IndexFormat indexType,
264264
std::size_t count,
265265
std::size_t offset,
266-
int instance,
266+
int instanceCount,
267267
bool wireframe)
268268
{
269269
prepareDrawing();
@@ -276,7 +276,7 @@ void CommandBufferGL::drawElementsInstanced(PrimitiveType primitiveType,
276276
#endif
277277
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer->getHandler());
278278
glDrawElementsInstanced(UtilsGL::toGLPrimitiveType(primitiveType), count, UtilsGL::toGLIndexType(indexType),
279-
(GLvoid*)offset, instance);
279+
(GLvoid*)offset, instanceCount);
280280
CHECK_GL_ERROR_DEBUG();
281281
#ifndef AX_USE_GLES // glPolygonMode is only supported in Desktop OpenGL
282282
if (wireframe)

core/renderer/backend/opengl/CommandBufferGL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class CommandBufferGL final : public CommandBuffer
177177
IndexFormat indexType,
178178
std::size_t count,
179179
std::size_t offset,
180-
int instance,
180+
int instanceCount,
181181
bool wireframe = false) override;
182182

183183
/**

0 commit comments

Comments
 (0)