Ejemplo n.º 1
0
 private ComputeShaderDispatcher(ProgramObject program, IHostScreen screen, IComputeShader shader)
 {
     Debug.Assert(program.IsEmpty == false);
     _program = program;
     _screen  = screen;
     _shader  = shader;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 public static ComputeShaderDispatcher CreateDispatcher(this IComputeShader shader)
 {
     return(ComputeShaderDispatcher.Create(shader));
 }
Ejemplo n.º 8
0
 public virtual void Visit(IComputeShader shader)
 {
     Shader = shader;
     shader.Accept(this);
 }