Added RefCounting, added ConstantBuffers

This commit is contained in:
Simon Lübeß
2021-02-06 19:37:07 +01:00
parent a2e4b5563e
commit 9ea56d6786
17 changed files with 759 additions and 293 deletions
+28 -5
View File
@@ -2,24 +2,34 @@ using System;
namespace GlitchyEngine.Renderer
{
public class Effect
public class Effect : RefCounted
{
protected GraphicsContext _context;
internal VertexShader _vs;
internal PixelShader _ps;
internal VertexShader _vs ~ _?.ReleaseRef();
internal PixelShader _ps ~ _?.ReleaseRef();
public GraphicsContext Context => _context;
public VertexShader VertexShader
{
get => _vs;
set => _vs = value;
set
{
_vs?.ReleaseRef();
_vs = value;
_vs?.AddRef();
}
}
public PixelShader PixelShader
{
get => _ps;
set => _ps = value;
set
{
_ps?.ReleaseRef();
_ps = value;
_ps?.AddRef();
}
}
public void Bind(GraphicsContext context)
@@ -27,5 +37,18 @@ namespace GlitchyEngine.Renderer
context.SetVertexShader(_vs);
context.SetPixelShader(_ps);
}
[Obsolete("Will be removed in the future", false)]
public this()
{
}
public this(String vsPath, String vsEntry, String psPath, String psEntry)
{
Compile(vsPath, vsEntry, psPath, psEntry);
}
protected extern void Compile(String vsPath, String vsEntry, String psPath, String psEntry);
}
}