/// <summary>
        /// Function to return the dispatch call.
        /// </summary>
        /// <param name="allocator">The allocator used to create an instance of the object</param>
        /// <returns>The dispatch call created or updated by this builder.</returns>
        /// <exception cref="GorgonException">Thrown if a <see cref="GorgonComputeShader"/> is not assigned to the <see cref="GorgonComputeShader"/> property with the <see cref="ComputeShader"/> command.</exception>
        /// <remarks>
        /// <para>
        /// Using an <paramref name="allocator"/> can provide different strategies when building dispatch calls.  If omitted, the dispatch call will be created using the standard <see langword="new"/> keyword.
        /// </para>
        /// <para>
        /// A custom allocator can be beneficial because it allows us to use a pool for allocating the objects, and thus allows for recycling of objects. This keeps the garbage collector happy by keeping objects
        /// around for as long as we need them, instead of creating objects that can potentially end up in the large object heap or in Gen 2.
        /// </para>
        /// <para>
        /// A dispatch call requires that at least a vertex shader be bound. If none is present, then the method will throw an exception.
        /// </para>
        /// </remarks>
        public GorgonDispatchCall Build(GorgonRingPool <GorgonDispatchCall> allocator)
        {
            var final = new GorgonDispatchCall();

            final.Setup();

            // Copy over the available constants.
            StateCopy.CopyConstantBuffers(final.D3DState.CsConstantBuffers, _worker.D3DState.CsConstantBuffers, 0);

            // Copy over samplers.
            StateCopy.CopySamplers(final.D3DState.CsSamplers, _worker.D3DState.CsSamplers, 0);

            // Copy over shader resource views.
            (int _, int _) = _worker.D3DState.CsSrvs.GetDirtyItems();

            StateCopy.CopySrvs(final.D3DState.CsSrvs, _worker.D3DState.CsSrvs);

            // Copy over unordered access views.
            StateCopy.CopyReadWriteViews(final.D3DState.CsReadWriteViews, _worker.D3DState.CsReadWriteViews, 0);

            if (_worker.D3DState.ComputeShader == null)
            {
                throw new GorgonException(GorgonResult.CannotCreate, Resources.GORGFX_ERR_NO_COMPUTE_SHADER);
            }

            final.D3DState.ComputeShader = _worker.D3DState.ComputeShader;

            return(final);
        }
 /// <summary>
 /// Function to create a new draw call.
 /// </summary>
 /// <param name="allocator">The allocator to use when creating draw call objects.</param>
 /// <returns>A new draw call.</returns>
 protected abstract TDc OnCreate(GorgonRingPool <TDc> allocator);
 /// <summary>
 /// Function to create a new draw call.
 /// </summary>
 /// <param name="allocator">The allocator to use when creating draw call objects.</param>
 /// <returns>A new draw call.</returns>
 protected override GorgonInstancedCall OnCreate(GorgonRingPool <GorgonInstancedCall> allocator) => allocator == null ? new GorgonInstancedCall() : allocator.Allocate();
 /// <summary>
 /// Function to create a new draw call.
 /// </summary>
 /// <param name="allocator">The allocator to use when creating draw call objects.</param>
 /// <returns>A new draw call.</returns>
 protected override GorgonDrawIndexCall OnCreate(GorgonRingPool <GorgonDrawIndexCall> allocator) => allocator == null ? new GorgonDrawIndexCall() : allocator.Allocate();