private NNedi3Shader GetShader(NNedi3Neurons neurons, bool u) { var filename = string.Format("NNEDI3_{3}_{0}_{1}{2}.cso", s_NeuronCount[(int)neurons], s_CodePath[(int)CodePath], Structured ? "_S" : string.Empty, u ? "u" : "v"); return(new NNedi3Shader(FromByteCode(filename)) { Neurons = neurons, Structured = Structured }); }
private string GetShaderFileName(NNedi3Neurons neurons) { return(string.Format("NNEDI3_{0}_{1}{2}.cso", s_NeuronCount[(int)neurons], s_CodePath[(int)CodePath], Structured ? "_S" : string.Empty)); }
/* // This causes .NET JIT internal limitation error, so we have to explicitly declare a filter class for each NNEDi3 neuron count public class Nnedi3Filter<TWeights, TWeightsSum> : Shader11Filter where TWeights : struct where TWeightsSum : struct { private readonly TWeights m_Weights1; private readonly TWeights m_Weights2; private readonly TWeightsSum m_WeightsSum; private bool m_WeightsUploaded; public Nnedi3Filter(IShader11 shader, TWeights weights1, TWeights weights2, TWeightsSum weightsSum, IFilter<IBaseTexture> inputFilter) : base(shader, inputFilter) { m_Weights1 = weights1; m_Weights2 = weights2; m_WeightsSum = weightsSum; } protected override void LoadInputs(IList<IBaseTexture> inputs) { base.LoadInputs(inputs); if (!m_WeightsUploaded) { Shader.SetConstantBuffer(2, m_Weights1); Shader.SetConstantBuffer(3, m_Weights2); Shader.SetConstantBuffer(4, m_WeightsSum); m_WeightsUploaded = true; } } } */ public static IFilter CreateFilter(IShader11 shader, IFilter input, NNedi3Neurons neurons) { switch (neurons) { case NNedi3Neurons.Neurons16: return new Nnedi3N16Filter(shader, input); case NNedi3Neurons.Neurons32: return new Nnedi3N32Filter(shader, input); case NNedi3Neurons.Neurons64: return new Nnedi3N64Filter(shader, input); case NNedi3Neurons.Neurons128: return new Nnedi3N128Filter(shader, input); case NNedi3Neurons.Neurons256: return new Nnedi3N256Filter(shader, input); default: throw new ArgumentOutOfRangeException("neurons"); } }