Shaders and BufferCollection now use append allocation

This commit is contained in:
Simon Lübeß
2020-12-31 13:19:27 +01:00
parent ebb5d94c1f
commit e021da8e0b
4 changed files with 14 additions and 14 deletions
+7 -12
View File
@@ -7,26 +7,21 @@ namespace GlitchyEngine.Renderer
{ {
typealias BufferEntry = (String Name, int Index, Buffer Buffer, bool OwnsBuffer); typealias BufferEntry = (String Name, int Index, Buffer Buffer, bool OwnsBuffer);
List<BufferEntry> _buffers ~ delete _; List<BufferEntry> _buffers ~ delete:append _;
Dictionary<StringView, Buffer> _strToBuf ~ delete _; Dictionary<StringView, Buffer> _strToBuf ~ delete:append _;
Dictionary<int, Buffer> _idxToBuf ~ delete _; Dictionary<int, Buffer> _idxToBuf ~ delete:append _;
//[AllowAppend] [AllowAppend]
public this() public this()
{ {
/*List<BufferEntry> buffers = append .(); let buffers = append List<BufferEntry>();
Dictionary<StringView, Buffer> strToBuf = append .(); let strToBuf = append Dictionary<StringView, Buffer>();
Dictionary<int, Buffer> idxToBuf = append .(); let idxToBuf = append Dictionary<int, Buffer>();
_buffers = buffers; _buffers = buffers;
_strToBuf = strToBuf; _strToBuf = strToBuf;
_idxToBuf = idxToBuf; _idxToBuf = idxToBuf;
*/
_buffers = new .();
_strToBuf = new .();
_idxToBuf = new .();
} }
public ~this() public ~this()
@@ -4,6 +4,7 @@ namespace GlitchyEngine.Renderer
{ {
public class PixelShader : Shader public class PixelShader : Shader
{ {
[AllowAppend]
public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null) public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null)
: base(context, source, entryPoint, macros) { } : base(context, source, entryPoint, macros) { }
+5 -2
View File
@@ -23,15 +23,18 @@ namespace GlitchyEngine.Renderer
{ {
protected GraphicsContext _context; protected GraphicsContext _context;
protected BufferCollection _buffers ~ delete _; protected BufferCollection _buffers ~ delete:append _;
public GraphicsContext Context => _context; public GraphicsContext Context => _context;
public BufferCollection Buffers => _buffers; public BufferCollection Buffers => _buffers;
[AllowAppend]
public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null) public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null)
{ {
_buffers = new BufferCollection(); let buffers = append BufferCollection();
_buffers = buffers;
_context = context; _context = context;
CompileFromSource(source, entryPoint); CompileFromSource(source, entryPoint);
} }
@@ -4,6 +4,7 @@ namespace GlitchyEngine.Renderer
{ {
public class VertexShader : Shader public class VertexShader : Shader
{ {
[AllowAppend]
public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null) public this(GraphicsContext context, String source, String entryPoint, ShaderDefine[] macros = null)
: base(context, source, entryPoint, macros) { } : base(context, source, entryPoint, macros) { }