public void GetOrCreate(VertexInputLayout layout, out InputLayoutPair currentPassPreviousPair) { lock (Cache) { if (!Cache.TryGetValue(layout, out currentPassPreviousPair)) { currentPassPreviousPair = new InputLayoutPair(layout, ToDispose(new InputLayout(device, Bytecode, layout.InputElements))); Cache.Add(layout, currentPassPreviousPair); } } }
/// <summary> /// Initializes a new instance of the <see cref="PrimitiveBatch{T}" /> class. /// </summary> /// <param name="graphicsDevice">The device.</param> /// <param name="maxIndices">The max indices.</param> /// <param name="maxVertices">The max vertices.</param> public PrimitiveBatch(GraphicsDevice graphicsDevice, int maxIndices = DefaultBatchSize * 3, int maxVertices = DefaultBatchSize) : base(graphicsDevice, maxIndices, maxVertices, Utilities.SizeOf <T>()) { var vertexElements = VertexElement.FromType <T>(); // If the type has some VertexElement description, we can use them directly to setup the vertex input layout. if (vertexElements != null) { vertexInputLayout = VertexInputLayout.New(0, vertexElements); } }
protected virtual void ReadVertexBuffer(ref VertexBufferBinding vertexBufferBinding) { // Read the number of vertices int count = Reader.ReadInt32(); // Read vertex elements int vertexElementCount = Reader.ReadInt32(); var elements = new VertexElement[vertexElementCount]; for (int i = 0; i < vertexElementCount; i++) { elements[i].Serialize(this); } vertexBufferBinding.Layout = VertexInputLayout.New(0, elements); // Read Vertex Buffer int sizeInBytes = Reader.ReadInt32(); SerializeMemoryRegion(SharedMemoryPointer, sizeInBytes); vertexBufferBinding.Buffer = Buffer.New(GraphicsDevice, new DataPointer(SharedMemoryPointer, sizeInBytes), sizeInBytes / count, BufferFlags.VertexBuffer, ResourceUsage.Immutable); }
public InputLayoutPair(VertexInputLayout vertexInputLayout, InputLayout inputLayout) { VertexInputLayout = vertexInputLayout; InputLayout = inputLayout; }
public SharedData(GraphicsDevice device) { VertexBuffer = ToDispose(Buffer.Vertex.New(device, QuadsVertices)); VertexBufferFullQuad = ToDispose(Buffer.Vertex.New(device, FullQuadsVertices)); VertexInputLayout = VertexInputLayout.FromBuffer(0, VertexBuffer); }