/// <summary>Initializes a new instance of the <see cref="GraphicsPrimitive" /> class.</summary> /// <param name="graphicsDevice">The graphics device for which the primitive was created.</param> /// <param name="graphicsPipeline">The graphics pipeline used for rendering the primitive.</param> /// <param name="vertexBuffer">The graphics buffer which holds the vertices for the primitive.</param> /// <param name="indexBuffer">The graphics buffer which holds the indices for the primitive or <c>null</c> if none exists.</param> /// <param name="constantBuffers">The constant buffers which hold the constant data for the primitive or an empty span if none exist.</param> /// <exception cref="ArgumentNullException"><paramref name="graphicsDevice" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="graphicsPipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="vertexBuffer" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="graphicsPipeline" /> was not created for <paramref name="graphicsDevice" />.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBuffer" /> was not created for <paramref name="graphicsDevice" />.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBuffer" /> was not created for <paramref name="graphicsDevice" />.</exception> protected GraphicsPrimitive(GraphicsDevice graphicsDevice, GraphicsPipeline graphicsPipeline, GraphicsBuffer vertexBuffer, GraphicsBuffer?indexBuffer, ReadOnlySpan <GraphicsBuffer> constantBuffers) { ThrowIfNull(graphicsPipeline, nameof(graphicsPipeline)); ThrowIfNull(vertexBuffer, nameof(vertexBuffer)); if (graphicsPipeline.GraphicsDevice != graphicsDevice) { ThrowArgumentOutOfRangeException(nameof(graphicsPipeline), graphicsPipeline); } if (vertexBuffer.GraphicsDevice != graphicsDevice) { ThrowArgumentOutOfRangeException(nameof(vertexBuffer), vertexBuffer); } if ((indexBuffer != null) && (indexBuffer.GraphicsDevice != graphicsDevice)) { ThrowArgumentOutOfRangeException(nameof(indexBuffer), indexBuffer); } _graphicsDevice = graphicsDevice; _graphicsPipeline = graphicsPipeline; _vertexBuffer = vertexBuffer; _indexBuffer = indexBuffer; _constantBuffers = constantBuffers.ToArray(); }
/// <summary>Creates a new graphics primitive for the device.</summary> /// <param name="pipeline">The pipeline used for rendering the graphics primitive.</param> /// <param name="vertexBufferRegion">The buffer region which holds the vertices for the graphics primitive.</param> /// <param name="vertexBufferStride">The stride of <paramref name="vertexBufferRegion" />.</param> /// <param name="indexBufferRegion">The buffer region which holds the indices for the graphics primitive or <c>default</c> if none exists.</param> /// <param name="indexBufferStride">The stride of <paramref name="indexBufferRegion" />.</param> /// <param name="inputResourceRegions">The resources which hold the input data for the graphics primitive or an empty span if none exist.</param> /// <exception cref="ArgumentNullException"><paramref name="pipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="pipeline" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBufferRegion" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBufferRegion" /> was not created for this device.</exception> /// <exception cref="ObjectDisposedException">The device has been disposed.</exception> public abstract GraphicsPrimitive CreatePrimitive(GraphicsPipeline pipeline, in GraphicsMemoryRegion <GraphicsResource> vertexBufferRegion, uint vertexBufferStride, in GraphicsMemoryRegion <GraphicsResource> indexBufferRegion = default, uint indexBufferStride = 0, ReadOnlySpan <GraphicsMemoryRegion <GraphicsResource> > inputResourceRegions = default);
/// <summary>Creates a new graphics primitive for the device.</summary> /// <param name="pipeline">The pipeline used for rendering the graphics primitive.</param> /// <param name="vertexBufferView">The buffer view which holds the vertices for the graphics primitive.</param> /// <param name="indexBufferView">The buffer view which holds the indices for the graphics primitive or <c>default</c> if none exists.</param> /// <param name="inputResources">The resources which hold the input data for the graphics primitive or an empty span if none exist.</param> /// <exception cref="ArgumentNullException"><paramref name="pipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="vertexBufferView" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="pipeline" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBufferView" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBufferView" /> was not created for this device.</exception> /// <exception cref="ObjectDisposedException">The device has been disposed.</exception> public abstract GraphicsPrimitive CreatePrimitive(GraphicsPipeline pipeline, in GraphicsBufferView vertexBufferView, in GraphicsBufferView indexBufferView = default, ReadOnlySpan <GraphicsResource> inputResources = default);
/// <summary>Initializes a new instance of the <see cref="GraphicsPrimitive" /> class.</summary> /// <param name="device">The device which manages the primitive.</param> /// <param name="pipeline">The pipeline used for rendering the primitive.</param> /// <param name="vertexBufferRegion">The buffer region which holds the vertices for the primitive.</param> /// <param name="vertexBufferStride">The stride of the vertices in <paramref name="vertexBufferRegion" />.</param> /// <param name="indexBufferRegion">The buffer region which holds the indices for the primitive or <c>default</c> if none exists.</param> /// <param name="indexBufferStride">The stride of the indices in <paramref name="indexBufferRegion" />.</param> /// <param name="inputResourceRegions">The resource regions which hold the input data for the primitive or an empty span if none exist.</param> /// <exception cref="ArgumentNullException"><paramref name="device" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="pipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="vertexBufferRegion" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="pipeline" /> is incompatible as it belongs to a different device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBufferRegion" /> was not created for <paramref name="device" />.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBufferRegion" /> was not created for <paramref name="device" />.</exception> protected GraphicsPrimitive(GraphicsDevice device, GraphicsPipeline pipeline, in GraphicsMemoryRegion <GraphicsResource> vertexBufferRegion, uint vertexBufferStride, in GraphicsMemoryRegion <GraphicsResource> indexBufferRegion, uint indexBufferStride, ReadOnlySpan <GraphicsMemoryRegion <GraphicsResource> > inputResourceRegions)
/// <summary>Creates a new graphics primitive for the device.</summary> /// <param name="graphicsPipeline">The graphics pipeline used for rendering the graphics primitive.</param> /// <param name="vertexBuffer">The graphics buffer which holds the vertices for the graphics primitive.</param> /// <param name="indexBuffer">The graphics buffer which holds the indices for the graphics primitive or <c>null</c> if none exists.</param> /// <param name="inputBuffers"></param> /// <exception cref="ArgumentNullException"><paramref name="graphicsPipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="vertexBuffer" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="graphicsPipeline" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBuffer" /> was not created for this device.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBuffer" /> was not created for this device.</exception> /// <exception cref="ObjectDisposedException">The device has been disposed.</exception> public abstract GraphicsPrimitive CreateGraphicsPrimitive(GraphicsPipeline graphicsPipeline, GraphicsBuffer vertexBuffer, GraphicsBuffer?indexBuffer = null, ReadOnlySpan <GraphicsBuffer> inputBuffers = default);
/// <summary>Initializes a new instance of the <see cref="GraphicsPrimitive" /> class.</summary> /// <param name="device">The device for which the primitive was created.</param> /// <param name="pipeline">The pipeline used for rendering the primitive.</param> /// <param name="vertexBufferView">The buffer which holds the vertices for the primitive.</param> /// <param name="indexBufferView">The buffer which holds the indices for the primitive or <c>default</c> if none exists.</param> /// <param name="inputResources">The resources which hold the input data for the primitive or an empty span if none exist.</param> /// <exception cref="ArgumentNullException"><paramref name="device" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="pipeline" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="vertexBufferView" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="pipeline" /> was not created for <paramref name="device" />.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexBufferView" /> was not created for <paramref name="device" />.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indexBufferView" /> was not created for <paramref name="device" />.</exception> protected GraphicsPrimitive(GraphicsDevice device, GraphicsPipeline pipeline, in GraphicsBufferView vertexBufferView, in GraphicsBufferView indexBufferView, ReadOnlySpan <GraphicsResource> inputResources)