From dfeed4a5c92dd74bb73d65513cb03279b572bc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Tue, 23 Mar 2021 19:07:41 +0100 Subject: [PATCH] Moved ImplBind implementation from Texture2D to Texture --- .../src/Platform/DX11/Renderer/Dx11Texture.bf | 18 +++++++++++------- GlitchyEngine/src/Renderer/Texture.bf | 4 +--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf index 6699c0a..86dbfc6 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf @@ -7,10 +7,20 @@ using internal GlitchyEngine.Renderer; namespace GlitchyEngine.Renderer { + extension Texture + { + protected internal ID3D11ShaderResourceView* nativeView ~ _?.Release(); + + protected override void ImplBind(uint32 slot) + { + _context.nativeContext.VertexShader.SetShaderResources(slot, 1, &nativeView); + _context.nativeContext.PixelShader.SetShaderResources(slot, 1, &nativeView); + } + } + extension Texture2D { internal ID3D11Texture2D* nativeTexture ~ _?.Release(); - internal ID3D11ShaderResourceView* nativeView ~ _?.Release(); internal Texture2DDescription nativeDesc; public override uint32 Width => nativeDesc.Width; @@ -38,11 +48,5 @@ namespace GlitchyEngine.Renderer nativeTexture.GetDescription(out nativeDesc); } - - protected override void ImplBind(uint32 slot) - { - _context.nativeContext.VertexShader.SetShaderResources(slot, 1, &nativeView); - _context.nativeContext.PixelShader.SetShaderResources(slot, 1, &nativeView); - } } } diff --git a/GlitchyEngine/src/Renderer/Texture.bf b/GlitchyEngine/src/Renderer/Texture.bf index 97eec96..1c3f649 100644 --- a/GlitchyEngine/src/Renderer/Texture.bf +++ b/GlitchyEngine/src/Renderer/Texture.bf @@ -38,7 +38,7 @@ namespace GlitchyEngine.Renderer _samplerState.Bind(slot); } - protected abstract void ImplBind(uint32 slot); + protected extern void ImplBind(uint32 slot); protected this(GraphicsContext context) { @@ -56,8 +56,6 @@ namespace GlitchyEngine.Renderer public override extern uint32 ArraySize {get;} public override extern uint32 MipLevels {get;} - protected override extern void ImplBind(uint32 slot); - public this(GraphicsContext context, String path) : base(context) { this._path = new String(path);