private void ApplyDepthChanges(GLCmdBufferPipelineItem next) { var enabled = (next.Flags & GLGraphicsPipelineFlagBits.DepthBufferEnabled) != 0; if (mDepth.IsDepthBufferEnabled != enabled) { if (mDepth.IsDepthBufferEnabled) { mDepth.DisableDepthBuffer(); } else { mDepth.EnableDepthBuffer(); } } var oldDepthWrite = (mPastDepthState.Flags & GLGraphicsPipelineFlagBits.DepthBufferWriteEnabled); var newDepthWrite = (next.Flags & GLGraphicsPipelineFlagBits.DepthBufferWriteEnabled); var pastDepth = mPastDepthState.DepthState; var nextDepth = next.DepthState; if ((oldDepthWrite & newDepthWrite) != oldDepthWrite) { mDepth.SetDepthMask(newDepthWrite != 0); } if (pastDepth.DepthBufferFunction != nextDepth.DepthBufferFunction) { mDepth.SetDepthBufferFunc(nextDepth.DepthBufferFunction); } }
private void SetupDepthSettings(IGLGraphicsPipeline pipeline) { var depthState = ExtractDepthState(pipeline); if (ChangesFoundInDepth(depthState)) { ApplyDepthChanges(depthState); mPastDepthState = depthState; } }
private bool ChangesFoundInDepth(GLCmdBufferPipelineItem next) { var mask = GLGraphicsPipelineFlagBits.DepthBufferEnabled | GLGraphicsPipelineFlagBits.DepthBufferWriteEnabled; var pastFlags = mask & mPastDepthState.Flags; var nextFlags = mask & next.Flags; return((pastFlags != nextFlags) || (!mPastDepthState.DepthState.Equals(next.DepthState))); }
public GLCmdBufferPipelineItem GeneratePipelineItem(IGLGraphicsPipeline pipeline) { GLGraphicsPipelineFlagBits flags = pipeline.Flags; var pipelineItem = new GLCmdBufferPipelineItem { Flags = flags, DepthState = pipeline.DepthState, StencilState = pipeline.StencilState, }; return(pipelineItem); }
public void Initialize() { const int NO_OF_COLOR_ATTACHMENTS = 4; mPastColorBlendEnums = mBlend.Initialize(NO_OF_COLOR_ATTACHMENTS); var initialStencilValue = mStencil.Initialize(); mPastStencilInfo = initialStencilValue; mPastFrontWriteMask = initialStencilValue.Front.WriteMask; mPastBackWriteMask = initialStencilValue.Back.WriteMask; mPastFrontStencilInfo = new GLCmdStencilFunctionInfo { CompareMask = initialStencilValue.Front.CompareMask, ReferenceMask = initialStencilValue.Front.Reference, StencilFunction = initialStencilValue.Enums.FrontStencilFunction, }; mPastBackStencilInfo = new GLCmdStencilFunctionInfo { CompareMask = initialStencilValue.Back.CompareMask, ReferenceMask = initialStencilValue.Back.Reference, StencilFunction = initialStencilValue.Enums.BackStencilFunction, }; var initialDepthValue = mDepth.Initialize(); PreviousPipeline = new GLCmdBufferPipelineItem { DepthState = initialDepthValue, StencilState = initialStencilValue.Enums, }; mPastRasterization = mRaster.Initialize(); mPastClearValues = mClear.Initialize(); }