/// <summary> /// Function to assign a sampler to a shader on the pipeline. /// </summary> /// <param name="shaderType">The type of shader to update.</param> /// <param name="sampler">The sampler to assign.</param> /// <param name="index">[Optional] The index of the sampler.</param> /// <returns>The fluent interface for this builder.</returns> /// <exception cref="ArgumentOutOfRangeException">Thrown if the <paramref name="index"/> parameter is less than 0, or greater than/equal to <see cref="GorgonSamplerStates.MaximumSamplerStateCount"/>.</exception> /// <exception cref="NotSupportedException">Thrown if the <paramref name="shaderType"/> is not valid.</exception> /// <remarks> /// <para> /// <see cref="ShaderType.Compute"/> shaders are not supported in this method will throw an exception. /// </para> /// </remarks> public TB SamplerState(ShaderType shaderType, GorgonSamplerState sampler, int index = 0) { if ((index < 0) || (index >= GorgonSamplerStates.MaximumSamplerStateCount)) { throw new ArgumentOutOfRangeException(nameof(index), string.Format(Resources.GORGFX_ERR_INVALID_SAMPLER_INDEX, GorgonSamplerStates.MaximumSamplerStateCount)); } switch (shaderType) { case ShaderType.Pixel: DrawCall.D3DState.PsSamplers[index] = sampler; break; case ShaderType.Vertex: DrawCall.D3DState.VsSamplers[index] = sampler; break; case ShaderType.Geometry: DrawCall.D3DState.GsSamplers[index] = sampler; break; case ShaderType.Domain: DrawCall.D3DState.DsSamplers[index] = sampler; break; case ShaderType.Hull: DrawCall.D3DState.HsSamplers[index] = sampler; break; default: throw new NotSupportedException(string.Format(Resources.GORGFX_ERR_SHADER_UNKNOWN_TYPE, shaderType)); } return((TB)this); }
/// <summary> /// Function to assign a sampler to a shader on the pipeline. /// </summary> /// <param name="sampler">The sampler to assign.</param> /// <param name="index">[Optional] The index of the sampler.</param> /// <returns>The fluent interface for this builder.</returns> /// <exception cref="ArgumentOutOfRangeException">Thrown if the <paramref name="index"/> parameter is less than 0, or greater than/equal to <see cref="GorgonSamplerStates.MaximumSamplerStateCount"/>.</exception> public GorgonDispatchCallBuilder SamplerState(GorgonSamplerState sampler, int index = 0) { if ((index < 0) || (index >= GorgonSamplerStates.MaximumSamplerStateCount)) { throw new ArgumentOutOfRangeException(nameof(index), string.Format(Resources.GORGFX_ERR_INVALID_SAMPLER_INDEX, GorgonSamplerStates.MaximumSamplerStateCount)); } _worker.D3DState.CsSamplers[index] = sampler; return(this); }