Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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);
 }