Beispiel #1
0
        public static ComputeBuffer CreateBuffer <T>(this ComputeShader shader, string name, int count)
        {
            var buffer = ComputeBufferEx.Create <T>(count);

            shader.SetBuffer(0, name, buffer);

            return(buffer);
        }
Beispiel #2
0
        public static ComputeBuffer CreateBufferWithLength <T>(this ComputeShader shader, string name, T[] data)
        {
            if (data.Length == 0)
            {
                var buffer = ComputeBufferEx.Create <T>(1);
                shader.SetBuffer(0, name, buffer);
                shader.SetInt(name + "_length", 0);
                return(buffer);
            }
            else
            {
                var buffer = ComputeBufferEx.Create <T>(data.Length);
                buffer.SetData(data);
                shader.SetBuffer(0, name, buffer);
                shader.SetInt(name + "_length", data.Length);

                return(buffer);
            }
        }