public virtual async Task <PipelineState> CreateComputePipelineStateAsync() { CompiledShader compiledShader = await CreateShaderAsync(); RootSignature rootSignature = CreateRootSignature(); PipelineState pipelineState = new PipelineState(GraphicsDevice, rootSignature, compiledShader.Shaders["compute"]); return(pipelineState); }
public async Task <PipelineState> CreateGraphicsPipelineStateAsync(InputElementDescription[] inputElements) { CompiledShader compiledShader = await CreateShaderAsync(); RootSignature rootSignature = CreateRootSignature(); PipelineState pipelineState = new PipelineState(GraphicsDevice, rootSignature, inputElements, compiledShader.Shaders["vertex"], compiledShader.Shaders["pixel"], compiledShader.Shaders.ContainsKey("geometry") ? compiledShader.Shaders["geometry"] : null, compiledShader.Shaders.ContainsKey("hull") ? compiledShader.Shaders["hull"] : null, compiledShader.Shaders.ContainsKey("domain") ? compiledShader.Shaders["domain"] : null); return(pipelineState); }
public override async Task <object> CreateAssetAsync(IServiceProvider services) { IContentManager contentManager = services.GetRequiredService <IContentManager>(); CompiledShader compiledShader = new CompiledShader(); foreach (var shaderSource in ShaderSources) { using Stream stream = await contentManager.FileProvider.OpenStreamAsync(shaderSource.Value, FileMode.Open, FileAccess.Read); using MemoryStream memoryStream = new MemoryStream(); await stream.CopyToAsync(memoryStream); compiledShader.Shaders[shaderSource.Key] = memoryStream.ToArray(); } return(compiledShader); }
public virtual Task <CompiledShader> CreateShaderAsync() { if (Shader is null) { throw new InvalidOperationException(); } CompiledShader compiledShader = new CompiledShader(); ShaderGenerator shaderGenerator = new ShaderGenerator(Shader, Settings); ShaderGeneratorResult result = shaderGenerator.GenerateShader(); foreach (var entryPoint in result.EntryPoints) { compiledShader.Shaders[entryPoint.Key] = ShaderCompiler.Compile(GetShaderStage(entryPoint.Key), result.ShaderSource, entryPoint.Value); } return(Task.FromResult(compiledShader)); }