DP-CustomResolution/CustomResolution2782/Shaders/BlitShader.cs

51 lines
1.3 KiB
C#

using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
namespace CustomResolution.Shaders;
public class BlitShader : MiniShader
{
public BlitShader() : base("Blit")
{
}
public override void Dispose()
{
base.Dispose();
}
public void Draw(ShaderResourceView srv)
{
using MiniShaderState state = new();
state.SetShader(Ctx.VertexShader, VS);
state.SetShader(Ctx.PixelShader, PS);
state.SetShader(Ctx.GeometryShader, null);
state.Set(Ctx.InputAssembler, nameof(Ctx.InputAssembler.PrimitiveTopology), PrimitiveTopology.TriangleList);
var blendDesc = Ctx.OutputMerger.BlendState.Description;
blendDesc.RenderTarget[0].IsBlendEnabled = false;
using var blendState = new BlendState(Device, blendDesc);
state.Set(Ctx.OutputMerger, nameof(Ctx.OutputMerger.BlendState), blendState);
state.SetShaderResource(Ctx.PixelShader, 0, srv);
Ctx.Draw(3, 0);
}
[StructLayout(LayoutKind.Sequential)]
public struct TConstants
{
public float Time;
}
}