public static MeshGeometry New <TIndex>( Device device, GraphicsCommandList commandList, IEnumerable <TIndex> indices, string name = "Default") where TIndex : struct { TIndex[] indexArray = indices.ToArray(); int indexBufferByteSize = Utilities.SizeOf(indexArray); Resource indexBuffer = D3DUtil.CreateDefaultBuffer( device, commandList, indexArray, indexBufferByteSize, out Resource indexBufferUploader); return(new MeshGeometry { Name = name, IndexCount = indexArray.Length, IndexFormat = GetIndexFormat <TIndex>(), IndexBufferByteSize = indexBufferByteSize, IndexBufferGPU = indexBuffer, IndexBufferCPU = indexArray, _toDispose = { indexBuffer, indexBufferUploader } }); }
private void BuildBuffers() { // Generate some data. var dataA = new Data[NumDataElements]; var dataB = new Data[NumDataElements]; for (int i = 0; i < NumDataElements; i++) { dataA[i].V1 = new Vector3(i, i, i); dataA[i].V2 = new Vector2(i, 0); dataB[i].V1 = new Vector3(-i, i, 0.0f); dataB[i].V2 = new Vector2(0, -i); } long byteSize = dataA.Length * Utilities.SizeOf <Data>(); // Create some buffers to be used as SRVs. _inputBufferA = D3DUtil.CreateDefaultBuffer( Device, CommandList, dataA, byteSize, out _inputUploadBufferA); _inputBufferB = D3DUtil.CreateDefaultBuffer( Device, CommandList, dataB, byteSize, out _inputUploadBufferB); // Create the buffer that will be a UAV. _outputBuffer = Device.CreateCommittedResource( new HeapProperties(HeapType.Default), HeapFlags.None, ResourceDescription.Buffer(byteSize, ResourceFlags.AllowUnorderedAccess), ResourceStates.UnorderedAccess); _readBackBuffer = Device.CreateCommittedResource( new HeapProperties(HeapType.Readback), HeapFlags.None, ResourceDescription.Buffer(byteSize), ResourceStates.CopyDestination); }