private ComputeShaderDispatcher(ProgramObject program, IHostScreen screen, IComputeShader shader) { Debug.Assert(program.IsEmpty == false); _program = program; _screen = screen; _shader = shader; }
public static ComputeShaderDispatcher Create(IComputeShader shader) { ArgumentNullException.ThrowIfNull(shader); var screen = Engine.GetValidCurrentContext(); var source = IComputeShader.GetShaderSourceInternal(shader); var program = ShaderCompiler.CompileComputeShader(source); var instance = new ComputeShaderDispatcher(program, screen, shader); ContextAssociatedMemorySafety.Register(instance, screen); return(instance); }
public void Dispatch(int xGroupCount, int yGroupCount, int zGroupCount) { var screen = _screen; ContextMismatchException.ThrowIfContextNotEqual(Engine.GetValidCurrentContext(), screen); var program = _program; ProgramObject.UseProgram(program); var context = new ComputeShaderContext(screen); var uniform = new ShaderDataDispatcher(program); IComputeShader.OnDispatchingInternal(_shader, uniform, context); IComputeShader.DispatchCompute(xGroupCount, yGroupCount, zGroupCount); }
public GpuLossyCalculator(IDevice device) { computeShader = device.Create.ComputeShader(ShaderParser.Parse(ComputeShaderText)); mipInfoBuffer = device.Create.Buffer(new BufferDescription { BindFlags = BindFlags.UniformBuffer, Usage = Usage.Dynamic, SizeInBytes = MipInfo.Size }); formatId = device.Adapter.GetSupportedFormats(FormatSupport.Texture2D).First(x => x.ExplicitFormat == ExplicitFormat.R8G8B8A8_UINT).ID; }
public GpuSpatialDiffCalculator(IDevice device) { computeShader = device.Create.ComputeShader(ShaderParser.Parse(ForwardComputeShaderText)); formatId = device.Adapter.GetSupportedFormats(FormatSupport.Texture2D).First(x => x.ExplicitFormat == ExplicitFormat.R8G8B8A8_UINT).ID; }
public GpuChannelSwapper(IDevice device) { computeShader = device.Create.ComputeShader(ShaderParser.Parse(ComputeShaderText)); rgbaFormat = device.Adapter.GetSupportedFormats(FormatSupport.Texture2D).First(x => x.ExplicitFormat == ExplicitFormat.R8G8B8A8_UNORM).ID; bgraFormat = device.Adapter.GetSupportedFormats(FormatSupport.Texture2D).First(x => x.ExplicitFormat == ExplicitFormat.B8G8R8A8_UNORM).ID; }
public static ComputeShaderDispatcher CreateDispatcher(this IComputeShader shader) { return(ComputeShaderDispatcher.Create(shader)); }
public virtual void Visit(IComputeShader shader) { Shader = shader; shader.Accept(this); }