using System.Collections; using System.Collections.Generic; using UnityEngine; namespace UltraCombos { public static class ExtensionMethods { public static ComputeBuffer CreateIndirectComputeArgsBuffer(this ComputeShader shader, int num_thread_x, int num_thread_y, int num_thread_z) { uint x, y, z; shader.GetKernelThreadGroupSizes(0, out x, out y, out z); uint[] args = new uint[3] { (uint)Mathf.CeilToInt((float)num_thread_x / x), (uint)Mathf.CeilToInt((float)num_thread_y / y), (uint)Mathf.CeilToInt((float)num_thread_z / z) }; var buf = new ComputeBuffer(1, args.Length * sizeof(uint), ComputeBufferType.IndirectArguments); buf.SetData(args); return buf; } } }