mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Added basic support for instanced rendering
This commit is contained in:
@@ -2,6 +2,8 @@ using GlitchyEngine.Math;
|
|||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
|
using internal GlitchyEngine.Renderer;
|
||||||
|
|
||||||
extension RendererAPI
|
extension RendererAPI
|
||||||
{
|
{
|
||||||
private GraphicsContext _context;
|
private GraphicsContext _context;
|
||||||
@@ -28,5 +30,10 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
_context.DrawIndexed(geometry.IndexCount, geometry.IndexByteOffset, 0);
|
_context.DrawIndexed(geometry.IndexCount, geometry.IndexByteOffset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void DrawIndexedInstanced(GeometryBinding geometry)
|
||||||
|
{
|
||||||
|
_context.nativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
Debug.Assert(input.Count == output.Count);
|
Debug.Assert(input.Count == output.Count);
|
||||||
|
|
||||||
for(int i < input.Count)
|
for(int i < input.Count)
|
||||||
output[i] = .(input[i].SemanticName, input[i].SemanticIndex, input[i].Format, input[i].InputSlot, input[i].AlignedByteOffset, (.)input[i].InputSlotClass);
|
output[i] = .(input[i].SemanticName, input[i].SemanticIndex, input[i].Format, input[i].InputSlot, input[i].AlignedByteOffset, (.)input[i].InputSlotClass, input[i].InstanceDataStepRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateNativeLayout()
|
protected override void CreateNativeLayout()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
internal VertexLayout _vertexLayout;
|
internal VertexLayout _vertexLayout;
|
||||||
internal uint32 _indexByteOffset;
|
internal uint32 _indexByteOffset;
|
||||||
internal uint32 _indexCount;
|
internal uint32 _indexCount;
|
||||||
|
internal uint32 _instanceCount;
|
||||||
internal PrimitiveTopology _primitiveTopology;
|
internal PrimitiveTopology _primitiveTopology;
|
||||||
|
|
||||||
public this(GraphicsContext context)
|
public this(GraphicsContext context)
|
||||||
@@ -50,6 +51,14 @@ namespace GlitchyEngine.Renderer
|
|||||||
[Inline]
|
[Inline]
|
||||||
public uint32 IndexCount => _indexCount;
|
public uint32 IndexCount => _indexCount;
|
||||||
|
|
||||||
|
public uint32 InstanceCount
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get => _instanceCount;
|
||||||
|
[Inline]
|
||||||
|
set => _instanceCount = value;
|
||||||
|
}
|
||||||
|
|
||||||
[Inline]
|
[Inline]
|
||||||
public PrimitiveTopology PrimitiveTopology => _primitiveTopology;
|
public PrimitiveTopology PrimitiveTopology => _primitiveTopology;
|
||||||
|
|
||||||
|
|||||||
@@ -30,5 +30,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
_rendererAPI.DrawIndexed(geometry);
|
_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 Clear(RenderTarget renderTarget, ColorRGBA clearColor);
|
||||||
|
|
||||||
public extern void DrawIndexed(GeometryBinding geometry);
|
public extern void DrawIndexed(GeometryBinding geometry);
|
||||||
|
|
||||||
|
public extern void DrawInstanced(GeometryBinding geometry);
|
||||||
|
|
||||||
|
public extern void DrawIndexedInstanced(GeometryBinding geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ namespace GlitchyEngine.Renderer
|
|||||||
_vertexType = vertexType;
|
_vertexType = vertexType;
|
||||||
|
|
||||||
_description = .(){
|
_description = .(){
|
||||||
Size = ((uint32)_vertexType.Size * vertexCount),
|
Size = ((uint32)_vertexType.Stride * vertexCount),
|
||||||
Usage = usage,
|
Usage = usage,
|
||||||
CPUAccess = cpuAccess,
|
CPUAccess = cpuAccess,
|
||||||
BindFlags = .Vertex,
|
BindFlags = .Vertex,
|
||||||
MiscFlags = .None
|
MiscFlags = .None
|
||||||
};
|
};
|
||||||
|
|
||||||
_defaultBinding = .(this, (.)_vertexType.Size, 0);
|
_defaultBinding = .(this, (.)_vertexType.Stride, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inline]
|
[Inline]
|
||||||
|
|||||||
Reference in New Issue
Block a user