Beispiel #1
0
        public static FDataBuffer <float> CreateUniformBuffer(VkDevice device, VkPhysicalDevice physicalDevice, int modelCount)
        {
            FDataBuffer <float> buffer = new FDataBuffer <float>(device, physicalDevice, 16 * 4 + 16 * 4 + (16 * modelCount) * 4,
                                                                 VkBufferUsageFlags.UniformBuffer, VkSharingMode.Exclusive);

            float[]      id     = Matrix4x4.Identity.ToFloatArray();
            Span <float> idSpan = id.AsSpan();

            Span <float> span = buffer.Map();

            for (int i = 0; i < span.Length; i += 16)
            {
                Span <float> mat = span.Slice(i, 16);
                for (int j = 0; j < mat.Length; j++)
                {
                    mat[j] = idSpan[j];
                }
            }
            span = buffer.UnMap();
            return(buffer);
        }