mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
metal: handle triangle strip draws
This commit is contained in:
@@ -112,6 +112,19 @@ static MTLStencilOperation getMTLStencilOperation(StencilAction action)
|
|||||||
return MTLStencilOperationKeep;
|
return MTLStencilOperationKeep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MTLPrimitiveType getMTLPrimitiveType(PrimitiveType prim)
|
||||||
|
{
|
||||||
|
switch (prim)
|
||||||
|
{
|
||||||
|
case PRIMITIVE_TRIANGLES: return MTLPrimitiveTypeTriangle;
|
||||||
|
case PRIMITIVE_TRIANGLE_STRIP: return MTLPrimitiveTypeTriangleStrip;
|
||||||
|
case PRIMITIVE_TRIANGLE_FAN: return MTLPrimitiveTypeTriangle; // This needs to be emulated.
|
||||||
|
case PRIMITIVE_POINTS: return MTLPrimitiveTypePoint;
|
||||||
|
case PRIMITIVE_MAX_ENUM: return MTLPrimitiveTypeTriangle;
|
||||||
|
}
|
||||||
|
return MTLPrimitiveTypeTriangle;
|
||||||
|
}
|
||||||
|
|
||||||
static inline id<MTLTexture> getMTLTexture(love::graphics::Texture *tex)
|
static inline id<MTLTexture> getMTLTexture(love::graphics::Texture *tex)
|
||||||
{
|
{
|
||||||
return tex ? (__bridge id<MTLTexture>)(void *) tex->getHandle() : nil;
|
return tex ? (__bridge id<MTLTexture>)(void *) tex->getHandle() : nil;
|
||||||
@@ -765,7 +778,7 @@ void Graphics::draw(const DrawCommand &cmd)
|
|||||||
|
|
||||||
setVertexBuffers(encoder, cmd.buffers);
|
setVertexBuffers(encoder, cmd.buffers);
|
||||||
|
|
||||||
[encoder drawPrimitives:MTLPrimitiveTypeTriangle
|
[encoder drawPrimitives:getMTLPrimitiveType(cmd.primitiveType)
|
||||||
vertexStart:cmd.vertexStart
|
vertexStart:cmd.vertexStart
|
||||||
vertexCount:cmd.vertexCount
|
vertexCount:cmd.vertexCount
|
||||||
instanceCount:cmd.instanceCount];
|
instanceCount:cmd.instanceCount];
|
||||||
@@ -793,7 +806,7 @@ void Graphics::draw(const DrawIndexedCommand &cmd)
|
|||||||
|
|
||||||
auto indexType = cmd.indexType == INDEX_UINT32 ? MTLIndexTypeUInt32 : MTLIndexTypeUInt16;
|
auto indexType = cmd.indexType == INDEX_UINT32 ? MTLIndexTypeUInt32 : MTLIndexTypeUInt16;
|
||||||
|
|
||||||
[encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle
|
[encoder drawIndexedPrimitives:getMTLPrimitiveType(cmd.primitiveType)
|
||||||
indexCount:cmd.indexCount
|
indexCount:cmd.indexCount
|
||||||
indexType:indexType
|
indexType:indexType
|
||||||
indexBuffer:getMTLBuffer(cmd.indexBuffer)
|
indexBuffer:getMTLBuffer(cmd.indexBuffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user