public StageBlock(EffectShaderType type) { Type = type; }
internal DeviceChild GetOrCompileShader(EffectShaderType shaderType, int index, int soRasterizedStream, StreamOutputElement[] soElements, out string profileError) { DeviceChild shader = null; profileError = null; lock (sync) { shader = compiledShadersGroup[(int)shaderType][index]; if (shader == null) { if (RegisteredShaders[index].Level > graphicsDevice.Features.Level) { profileError = string.Format("{0}", RegisteredShaders[index].Level); return(null); } var bytecodeRaw = RegisteredShaders[index].Bytecode; switch (shaderType) { case EffectShaderType.Vertex: shader = new VertexShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Domain: shader = new DomainShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Hull: shader = new HullShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Geometry: if (soElements != null) { // Calculate the strides var soStrides = new List <int>(); foreach (var streamOutputElement in soElements) { for (int i = soStrides.Count; i < (streamOutputElement.Stream + 1); i++) { soStrides.Add(0); } soStrides[streamOutputElement.Stream] += streamOutputElement.ComponentCount * sizeof(float); } shader = new GeometryShader(graphicsDevice, bytecodeRaw, soElements, soStrides.ToArray(), soRasterizedStream); } else { shader = new GeometryShader(graphicsDevice, bytecodeRaw); } break; case EffectShaderType.Pixel: shader = new PixelShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Compute: shader = new ComputeShader(graphicsDevice, bytecodeRaw); break; } compiledShadersGroup[(int)shaderType][index] = ToDispose(shader); } } return(shader); }
internal DeviceChild GetOrCompileShader(EffectShaderType shaderType, int index) { DeviceChild shader = null; lock (sync) { shader = compiledShaders[index]; if (shader == null) { var bytecodeRaw = dataGroup.Shaders[index].Bytecode; switch (shaderType) { case EffectShaderType.Vertex: shader = new VertexShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Domain: shader = new DomainShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Hull: shader = new HullShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Geometry: shader = new GeometryShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Pixel: shader = new PixelShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Compute: shader = new ComputeShader(graphicsDevice, bytecodeRaw); break; } compiledShaders[index] = shader; } } return shader; }
internal DeviceChild GetOrCompileShader(EffectShaderType shaderType, int index, int soRasterizedStream, StreamOutputElement[] soElements, out string profileError) { DeviceChild shader = null; profileError = null; lock (sync) { shader = compiledShadersGroup[(int)shaderType][index]; if (shader == null) { if (RegisteredShaders[index].Level > graphicsDevice.Features.Level) { profileError = string.Format("{0}", RegisteredShaders[index].Level); return null; } var bytecodeRaw = RegisteredShaders[index].Bytecode; switch (shaderType) { case EffectShaderType.Vertex: shader = new VertexShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Domain: shader = new DomainShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Hull: shader = new HullShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Geometry: if (soElements != null) { // Calculate the strides var soStrides = new List<int>(); foreach (var streamOutputElement in soElements) { for (int i = soStrides.Count; i < (streamOutputElement.Stream+1); i++) { soStrides.Add(0); } soStrides[streamOutputElement.Stream] += streamOutputElement.ComponentCount * sizeof(float); } shader = new GeometryShader(graphicsDevice, bytecodeRaw, soElements, soStrides.ToArray(), soRasterizedStream); } else { shader = new GeometryShader(graphicsDevice, bytecodeRaw); } break; case EffectShaderType.Pixel: shader = new PixelShader(graphicsDevice, bytecodeRaw); break; case EffectShaderType.Compute: shader = new ComputeShader(graphicsDevice, bytecodeRaw); break; } compiledShadersGroup[(int)shaderType][index] = ToDispose(shader); } } return shader; }
/// <summary> /// Gets or sets the <see cref="ShaderLink" /> with the specified stage type. /// </summary> /// <param name="effectShaderType">Type of the stage.</param> /// <returns>A <see cref="ShaderLink"/></returns> /// <remarks> /// The return value can be null if there is no shaders associated for this particular stage. /// </remarks> public ShaderLink this[EffectShaderType effectShaderType] { get { return(Links[(int)effectShaderType]); } set { Links[(int)effectShaderType] = value; } }