Textures can now hold SamplerStates

This commit is contained in:
Simon Lübeß
2021-02-08 15:48:00 +01:00
parent ea140f0532
commit 9219ccf9d8
3 changed files with 32 additions and 7 deletions
@@ -39,7 +39,7 @@ namespace GlitchyEngine.Renderer
nativeTexture.GetDescription(out nativeDesc);
}
public override void Bind(uint32 slot)
protected override void ImplBind(uint32 slot)
{
_context.nativeContext.VertexShader.SetShaderResources(slot, 1, &nativeView);
_context.nativeContext.PixelShader.SetShaderResources(slot, 1, &nativeView);
+27 -3
View File
@@ -5,16 +5,40 @@ namespace GlitchyEngine.Renderer
public abstract class Texture : RefCounted
{
protected GraphicsContext _context ~ _?.ReleaseRef();
protected SamplerState _samplerState ~ _?.ReleaseRef();
public GraphicsContext Context => _context;
public SamplerState SamplerState
{
get => _samplerState;
set
{
if(_samplerState == value)
return;
_samplerState?.ReleaseRef();
_samplerState = value;
_samplerState?.AddRef();
}
}
public abstract uint32 Width {get;}
public abstract uint32 Height {get;}
public abstract uint32 Depth {get;}
public abstract uint32 ArraySize {get;}
public abstract uint32 MipLevels {get;}
public abstract void Bind(uint32 slot = 0);
public void Bind(uint32 slot = 0)
{
ImplBind(slot);
if(_samplerState != null)
_samplerState.Bind(slot);
}
protected abstract void ImplBind(uint32 slot);
protected this(GraphicsContext context)
{
@@ -32,7 +56,7 @@ namespace GlitchyEngine.Renderer
public override extern uint32 ArraySize {get;}
public override extern uint32 MipLevels {get;}
public override extern void Bind(uint32 slot = 0);
protected override extern void ImplBind(uint32 slot);
public this(GraphicsContext context, String path) : base(context)
{