private IEnumerable<InputAssemblerVertexOutput> GetVertexStreamInternal(
			InputSignatureChunk vertexShaderInputSignature,
			int vertexCount, int instanceID, int vertexID, 
			VertexBufferIndex[] vertexBufferIndices)
		{
			var inputParameterCount = vertexShaderInputSignature.Parameters.Count;
			Dictionary<int, InputLayout.ProcessedInputElement> inputElementsKeyedByRegister = null;
			if (InputLayout != null)
				inputElementsKeyedByRegister = InputLayout.Elements.ToDictionary(x => x.RegisterIndex);

		    var processedVertexHandler = ProcessedVertex;

			for (int i = 0; i < vertexCount; i++)
			{
				var output = new InputAssemblerVertexOutput();
				output.VertexID = vertexID++;
				output.InstanceID = instanceID;
				output.Data = new Number4[inputParameterCount];
				
				// TODO: Support non-32-bit formats.
				foreach (var parameter in vertexShaderInputSignature.Parameters)
				{
					switch (parameter.SystemValueType)
					{
						case Name.Undefined:
						case Name.Position:
							if (inputElementsKeyedByRegister == null)
								throw new Exception("InputLayout must be set in order to use these system value types.");
							var inputElement = inputElementsKeyedByRegister[(int) parameter.Register];
							vertexBufferIndices[inputElement.InputSlot].GetData(
								output.Data, inputElement.RegisterIndex,
								inputElement.AlignedByteOffset,
								FormatHelper.SizeOfInBytes(inputElement.Format));
							break;
						case Name.VertexID:
							output.Data[parameter.Register] = new Number4(output.VertexID, 0, 0, 0);
							break;
						case Name.InstanceID:
							output.Data[parameter.Register] = new Number4(output.InstanceID, 0, 0, 0);
							break;
					}
				}

                if (processedVertexHandler != null)
                    processedVertexHandler(this, new InputAssemblerVertexEventArgs(output));

				yield return output;

				foreach (var vertexBufferIndex in vertexBufferIndices)
					vertexBufferIndex.Increment(InputClassification.PerVertexData);
			}
		}
 public InputAssemblerVertexEventArgs(InputAssemblerVertexOutput vertex)
 {
     _vertex = vertex;
 }
        private IEnumerable <InputAssemblerVertexOutput> GetVertexStreamInternal(
            InputSignatureChunk vertexShaderInputSignature,
            int vertexCount, int instanceID, int vertexID,
            VertexBufferIndex[] vertexBufferIndices)
        {
            var inputParameterCount = vertexShaderInputSignature.Parameters.Count;
            Dictionary <int, InputLayout.ProcessedInputElement> inputElementsKeyedByRegister = null;

            if (InputLayout != null)
            {
                inputElementsKeyedByRegister = InputLayout.Elements.ToDictionary(x => x.RegisterIndex);
            }

            var processedVertexHandler = ProcessedVertex;

            for (int i = 0; i < vertexCount; i++)
            {
                var output = new InputAssemblerVertexOutput();
                output.VertexID   = vertexID++;
                output.InstanceID = instanceID;
                output.Data       = new Number4[inputParameterCount];

                // TODO: Support non-32-bit formats.
                foreach (var parameter in vertexShaderInputSignature.Parameters)
                {
                    switch (parameter.SystemValueType)
                    {
                    case Name.Undefined:
                    case Name.Position:
                        if (inputElementsKeyedByRegister == null)
                        {
                            throw new Exception("InputLayout must be set in order to use these system value types.");
                        }
                        var inputElement = inputElementsKeyedByRegister[(int)parameter.Register];
                        vertexBufferIndices[inputElement.InputSlot].GetData(
                            output.Data, inputElement.RegisterIndex,
                            inputElement.AlignedByteOffset,
                            FormatHelper.SizeOfInBytes(inputElement.Format));
                        break;

                    case Name.VertexID:
                        output.Data[parameter.Register] = new Number4(output.VertexID, 0, 0, 0);
                        break;

                    case Name.InstanceID:
                        output.Data[parameter.Register] = new Number4(output.InstanceID, 0, 0, 0);
                        break;
                    }
                }

                if (processedVertexHandler != null)
                {
                    processedVertexHandler(this, new InputAssemblerVertexEventArgs(output));
                }

                yield return(output);

                foreach (var vertexBufferIndex in vertexBufferIndices)
                {
                    vertexBufferIndex.Increment(InputClassification.PerVertexData);
                }
            }
        }
 public InputAssemblerVertexEventArgs(InputAssemblerVertexOutput vertex)
 {
     _vertex = vertex;
 }