public void Run(ComputeBuffer buf, string bufName) { // update our thread count/unity size/total resolution values if necessary if (buf.count != this.count_) { this.count_ = (uint)buf.count; Vector2Int resolution = new ThreadSize(this.count_, (uint)threadSize_.x, (uint)threadSize_.y).Resolution; uint count = (uint)resolution.x * (uint)resolution.y; this.unitSize_ = new ThreadSize(count, (uint)threadSize_.x, (uint)threadSize_.y).UnitSize; #if UNITY_EDITOR // Update info in Unity editor for debugging... this.Count = (int)count; this.Res = resolution; this.UnitRes = this.unitSize_; #endif } this.Shader.SetBuffer(this.kernel_, bufName, buf); // IF our owner set our horizontal resolution variable name, we'll set it here if (this.resx_ != null) { this.Shader.SetInt(this.resx_, this.threadSize_.x * this.unitSize_.x); } // Dispatch this.Shader.Dispatch(Kernel, unitSize_.x, unitSize_.y, 1); }
public void Run(ComputeBuffer mainBuf) { if (this.opts == null) { return; // TODO; log warning? } // get shader var shader = opts.ComputeShader; if (shader == null) { return; } // kernel if (opts.KernelName != null) { this.kernel_ = shader.FindKernel(opts.KernelName); } //if (this.kernel_ == null) return; // execution/threading details // update our thread count/unity size/total resolution values if necessary if (mainBuf.count != this.count_) { this.count_ = (uint)mainBuf.count; Vector2Int resolution = new ThreadSize(this.count_, (uint)opts.ThreadSize.x, (uint)opts.ThreadSize.y).Resolution; uint count = (uint)resolution.x * (uint)resolution.y; this.unitSize_ = new ThreadSize(count, (uint)opts.ThreadSize.x, (uint)opts.ThreadSize.y).UnitSize; #if UNITY_EDITOR // Update info in Unity editor for debugging... this.Count = (int)count; this.Res = resolution; this.UnitRes = this.unitSize_; #endif } if (opts.NameResolutionX != null) { shader.SetInt(opts.NameResolutionX, this.threadSize_.x * this.unitSize_.x); } foreach (var cfg in opts.ShaderConfigurators) { cfg.Invoke(shader, this.kernel_); } if (this.opts.MainBufName != null) { shader.SetBuffer(this.kernel_, this.opts.MainBufName, mainBuf); } shader.Dispatch(Kernel, unitSize_.x, unitSize_.y, 1); }