Added basic support for instanced rendering

This commit is contained in:
Simon Lübeß
2021-05-30 19:37:23 +02:00
parent 0f2c481616
commit ae290936b9
6 changed files with 29 additions and 3 deletions
@@ -12,6 +12,7 @@ namespace GlitchyEngine.Renderer
internal VertexLayout _vertexLayout;
internal uint32 _indexByteOffset;
internal uint32 _indexCount;
internal uint32 _instanceCount;
internal PrimitiveTopology _primitiveTopology;
public this(GraphicsContext context)
@@ -50,6 +51,14 @@ namespace GlitchyEngine.Renderer
[Inline]
public uint32 IndexCount => _indexCount;
public uint32 InstanceCount
{
[Inline]
get => _instanceCount;
[Inline]
set => _instanceCount = value;
}
[Inline]
public PrimitiveTopology PrimitiveTopology => _primitiveTopology;
@@ -30,5 +30,11 @@ namespace GlitchyEngine.Renderer
{
_rendererAPI.DrawIndexed(geometry);
}
[Inline]
public static void DrawIndexedInstanced(GeometryBinding geometry)
{
_rendererAPI.DrawIndexedInstanced(geometry);
}
}
}
@@ -20,5 +20,9 @@ namespace GlitchyEngine.Renderer
public extern void Clear(RenderTarget renderTarget, ColorRGBA clearColor);
public extern void DrawIndexed(GeometryBinding geometry);
public extern void DrawInstanced(GeometryBinding geometry);
public extern void DrawIndexedInstanced(GeometryBinding geometry);
}
}
+2 -2
View File
@@ -30,14 +30,14 @@ namespace GlitchyEngine.Renderer
_vertexType = vertexType;
_description = .(){
Size = ((uint32)_vertexType.Size * vertexCount),
Size = ((uint32)_vertexType.Stride * vertexCount),
Usage = usage,
CPUAccess = cpuAccess,
BindFlags = .Vertex,
MiscFlags = .None
};
_defaultBinding = .(this, (.)_vertexType.Size, 0);
_defaultBinding = .(this, (.)_vertexType.Stride, 0);
}
[Inline]