Use static D3D11 device and context

This commit is contained in:
Simon Lübeß
2021-10-13 22:56:22 +02:00
parent 84daee95e4
commit 0cbbf94fe6
51 changed files with 448 additions and 345 deletions
@@ -1,6 +1,10 @@
#if GE_D3D11
using GlitchyEngine.Math;
using GlitchyEngine.Platform.DX11;
using internal GlitchyEngine.Renderer;
using internal GlitchyEngine.Platform.DX11;
namespace GlitchyEngine.Renderer
{
@@ -8,12 +12,12 @@ namespace GlitchyEngine.Renderer
extension RendererAPI
{
private GraphicsContext _context;
private GraphicsContext _context ~ _?.ReleaseRef();
public GraphicsContext Context
{
get => _context;
set => _context = value;
set => SetReference!(_context, value);
}
public static override API Api => .D3D11;
@@ -30,12 +34,12 @@ namespace GlitchyEngine.Renderer
public override void Clear(DepthStencilTarget target, float depthValue, uint8 stencilValue, DepthStencilClearFlag clearFlags)
{
_context.nativeContext.ClearDepthStencilView(target.nativeView, (.)clearFlags, depthValue, stencilValue);
NativeContext.ClearDepthStencilView(target.nativeView, (.)clearFlags, depthValue, stencilValue);
}
public override void Clear(RenderTarget2D renderTarget, float depthValue, uint8 stencilValue, DepthStencilClearFlag clearFlags)
{
_context.nativeContext.ClearDepthStencilView(renderTarget._depthStenilTarget.nativeView, (.)clearFlags, depthValue, stencilValue);
NativeContext.ClearDepthStencilView(renderTarget._depthStenilTarget.nativeView, (.)clearFlags, depthValue, stencilValue);
}
public override void DrawIndexed(GeometryBinding geometry)
@@ -48,7 +52,7 @@ namespace GlitchyEngine.Renderer
public override void DrawIndexedInstanced(GeometryBinding geometry)
{
_context.nativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
NativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
}
public override void SetViewport(Viewport viewport)
@@ -57,3 +61,5 @@ namespace GlitchyEngine.Renderer
}
}
}
#endif