/// <summary> /// /// </summary> /// <param name="passDescription"></param> /// <param name="manager"></param> public ShaderPass(ShaderPassDescription passDescription, IEffectsManager manager) { Name = passDescription.Name; effectsManager = manager; if (passDescription.ShaderList != null) { foreach (var shader in passDescription.ShaderList) { var s = manager.ShaderManager.RegisterShader(shader); switch (shader.ShaderType) { case ShaderStage.Vertex: vertexShader = s as VertexShader; break; case ShaderStage.Domain: domainShader = s as DomainShader; break; case ShaderStage.Hull: hullShader = s as HullShader; break; case ShaderStage.Geometry: geometryShader = s as GeometryShader; break; case ShaderStage.Pixel: pixelShader = s as PixelShader; break; case ShaderStage.Compute: computeShader = s as ComputeShader; break; } } } blendState = passDescription.BlendStateDescription != null? manager.StateManager.Register((BlendStateDescription)passDescription.BlendStateDescription) : BlendStateProxy.Empty; depthStencilState = passDescription.DepthStencilStateDescription != null? manager.StateManager.Register((DepthStencilStateDescription)passDescription.DepthStencilStateDescription) : DepthStencilStateProxy.Empty; rasterState = passDescription.RasterStateDescription != null? manager.StateManager.Register((RasterizerStateDescription)passDescription.RasterStateDescription) : RasterizerStateProxy.Empty; BlendFactor = passDescription.BlendFactor; StencilRef = passDescription.StencilRef; SampleMask = passDescription.SampleMask; Topology = passDescription.Topology; if (passDescription.InputLayoutDescription != null) { layout = manager.ShaderManager.RegisterInputLayout(passDescription.InputLayoutDescription); } }
public void SetRasterState(RasterizerStateProxy rasterState) { if (AutoSkipRedundantStateSetting && currRasterState == rasterState) { return; } deviceContext.Rasterizer.State = rasterState; currRasterState = rasterState; }
/// <summary> /// Creates the state of the raster. /// </summary> /// <param name="description">The description.</param> /// <param name="force">if set to <c>true</c> [force].</param> /// <returns></returns> protected virtual bool CreateRasterState(RasterizerStateDescription description, bool force) { if (!IsAttached && !force) { return(false); } RemoveAndDispose(ref rasterState); rasterState = Collect(EffectTechnique.EffectsManager.StateManager.Register(description)); return(true); }
public void Reset() { CurrShaderPass = null; currRasterState = null; currBlendState = null; currDepthStencilState = null; currBlendFactor = null; currSampleMask = uint.MaxValue; currStencilRef = 0; }
/// <summary> /// /// </summary> /// <param name="passDescription"></param> /// <param name="manager"></param> public ShaderPass(ShaderPassDescription passDescription, IEffectsManager manager) { Name = passDescription.Name; if (passDescription.ShaderList != null) { foreach (var shader in passDescription.ShaderList) { shaders[shader.ShaderType.ToIndex()] = manager.ShaderManager.RegisterShader(shader); } } for (int i = 0; i < shaders.Length; ++i) { if (shaders[i] == null) { var type = i.ToShaderStage(); switch (type) { case ShaderStage.Vertex: shaders[i] = NullShader.VertexNull; break; case ShaderStage.Hull: shaders[i] = NullShader.HullNull; break; case ShaderStage.Domain: shaders[i] = NullShader.DomainNull; break; case ShaderStage.Geometry: shaders[i] = NullShader.GeometryNull; break; case ShaderStage.Pixel: shaders[i] = NullShader.PixelNull; break; case ShaderStage.Compute: shaders[i] = NullShader.ComputeNull; break; } } } BlendState = passDescription.BlendStateDescription != null? Collect(manager.StateManager.Register((BlendStateDescription)passDescription.BlendStateDescription)) : BlendStateProxy.Empty; DepthStencilState = passDescription.DepthStencilStateDescription != null? Collect(manager.StateManager.Register((DepthStencilStateDescription)passDescription.DepthStencilStateDescription)) : DepthStencilStateProxy.Empty; RasterState = passDescription.RasterStateDescription != null? Collect(manager.StateManager.Register((RasterizerStateDescription)passDescription.RasterStateDescription)) : RasterizerStateProxy.Empty; }
public void Reset() { CurrShaderPass = null; currRasterState = null; currBlendState = null; currDepthStencilState = null; currBlendFactor = null; currSampleMask = uint.MaxValue; currStencilRef = 0; currInputLayout = null; currPrimitiveTopology = PrimitiveTopology.Undefined; }
/// <summary> /// Sets the state. /// </summary> /// <param name="rasterizerStateDesc">The rasterizer state desc.</param> public void SetState(RasterizerStateDescription?rasterizerStateDesc) { if (IsNULL) { return; } if (RasterState != RasterizerStateProxy.Empty) { RemoveAndDispose(ref rasterState); } rasterState = rasterizerStateDesc != null? effectsManager.StateManager.Register(rasterizerStateDesc.Value) : RasterizerStateProxy.Empty; }
/// <summary> /// /// </summary> /// <param name="description"></param> /// <param name="force"></param> /// <returns></returns> protected virtual bool CreateRasterState(RasterizerStateDescription description, bool force) { RemoveAndDispose(ref rasterState); RemoveAndDispose(ref invertCullModeState); rasterState = Collect(EffectTechnique.EffectsManager.StateManager.Register(description)); var invCull = description; if (description.CullMode != CullMode.None) { invCull.CullMode = description.CullMode == CullMode.Back ? CullMode.Front : CullMode.Back; } invertCullModeState = Collect(EffectTechnique.EffectsManager.StateManager.Register(invCull)); return(true); }
protected override bool CreateRasterState(RasterizerStateDescription description, bool force) { if (base.CreateRasterState(description, force)) { RemoveAndDispose(ref rasterStateWireframe); var wireframeDesc = description; wireframeDesc.FillMode = FillMode.Wireframe; wireframeDesc.DepthBias = -100; wireframeDesc.SlopeScaledDepthBias = -2f; wireframeDesc.DepthBiasClamp = -0.00008f; rasterStateWireframe = Collect(EffectTechnique.EffectsManager.StateManager.Register(wireframeDesc)); return(true); } else { return(false); } }
public void Reset() { currRasterState = null; currBlendState = null; currDepthStencilState = null; currBlendFactor = null; currSampleMask = uint.MaxValue; currStencilRef = 0; currInputLayout = null; currPrimitiveTopology = PrimitiveTopology.Undefined; for (int i = 0; i < ConstantBufferCheck.Length; ++i) { ConstantBufferCheck[i] = null; } for (int i = 0; i < SamplerStateCheck.Length; ++i) { SamplerStateCheck[i] = null; } }
protected override bool CreateRasterState(RasterizerStateDescription description, bool force) { if (!base.CreateRasterState(description, force)) { return(false); } #region Create states RemoveAndDispose(ref backfaceRasterState); this.backfaceRasterState = Collect(EffectTechnique.EffectsManager.StateManager.Register(new RasterizerStateDescription() { FillMode = FillMode.Solid, CullMode = CullMode.Front, DepthBias = description.DepthBias, DepthBiasClamp = description.DepthBiasClamp, SlopeScaledDepthBias = description.SlopeScaledDepthBias, IsDepthClipEnabled = description.IsDepthClipEnabled, IsFrontCounterClockwise = description.IsFrontCounterClockwise, IsMultisampleEnabled = false, IsScissorEnabled = false })); #endregion return(true); }
protected override void OnDetach() { DynamicReflector = null; rasterStateWireframe = null; base.OnDetach(); }
protected override void OnDetach() { backfaceRasterState = null; base.OnDetach(); }
protected override void OnDetach() { rasterState = null; invertCullModeState = null; base.OnDetach(); }
/// <summary> /// Sets the state of the raster. /// </summary> /// <param name="rasterState">State of the raster.</param> public void SetRasterState(RasterizerStateProxy rasterState) { DeviceContext.Rasterizer.State = rasterState; }
protected override void OnDetach() { rasterStateWireframe = null; base.OnDetach(); }