Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the state updater.
        /// </summary>
        /// <param name="context">GPU context</param>
        /// <param name="channel">GPU channel</param>
        /// <param name="state">3D engine state</param>
        /// <param name="drawState">Draw state</param>
        public StateUpdater(GpuContext context, GpuChannel channel, DeviceStateWithShadow <ThreedClassState> state, DrawState drawState)
        {
            _context            = context;
            _channel            = channel;
            _state              = state;
            _drawState          = drawState;
            _currentProgramInfo = new ShaderProgramInfo[Constants.ShaderStages];

            // ShaderState must be the first, as other state updates depends on information from the currently bound shader.
            // Rasterizer and scissor states are checked by render target clear, their indexes
            // must be updated on the constants "RasterizerStateIndex" and "ScissorStateIndex" if modified.
            // The vertex buffer state may be forced dirty when a indexed draw starts, the "VertexBufferStateIndex"
            // constant must be updated if modified.
            // The order of the other state updates doesn't matter.
            _updateTracker = new StateUpdateTracker <ThreedClassState>(new[]
            {
                new StateUpdateCallbackEntry(UpdateShaderState,
                                             nameof(ThreedClassState.ShaderBaseAddress),
                                             nameof(ThreedClassState.ShaderState)),

                new StateUpdateCallbackEntry(UpdateRasterizerState, nameof(ThreedClassState.RasterizeEnable)),
                new StateUpdateCallbackEntry(UpdateScissorState, nameof(ThreedClassState.ScissorState)),

                new StateUpdateCallbackEntry(UpdateVertexBufferState,
                                             nameof(ThreedClassState.VertexBufferDrawState),
                                             nameof(ThreedClassState.VertexBufferInstanced),
                                             nameof(ThreedClassState.VertexBufferState),
                                             nameof(ThreedClassState.VertexBufferEndAddress)),

                new StateUpdateCallbackEntry(UpdateTfBufferState, nameof(ThreedClassState.TfBufferState)),
                new StateUpdateCallbackEntry(UpdateUserClipState, nameof(ThreedClassState.ClipDistanceEnable)),

                new StateUpdateCallbackEntry(UpdateRenderTargetState,
                                             nameof(ThreedClassState.RtColorState),
                                             nameof(ThreedClassState.RtDepthStencilState),
                                             nameof(ThreedClassState.RtControl),
                                             nameof(ThreedClassState.RtDepthStencilSize),
                                             nameof(ThreedClassState.RtDepthStencilEnable)),

                new StateUpdateCallbackEntry(UpdateDepthClampState, nameof(ThreedClassState.ViewVolumeClipControl)),

                new StateUpdateCallbackEntry(UpdateAlphaTestState,
                                             nameof(ThreedClassState.AlphaTestEnable),
                                             nameof(ThreedClassState.AlphaTestRef),
                                             nameof(ThreedClassState.AlphaTestFunc)),

                new StateUpdateCallbackEntry(UpdateDepthTestState,
                                             nameof(ThreedClassState.DepthTestEnable),
                                             nameof(ThreedClassState.DepthWriteEnable),
                                             nameof(ThreedClassState.DepthTestFunc)),

                new StateUpdateCallbackEntry(UpdateViewportTransform,
                                             nameof(ThreedClassState.DepthMode),
                                             nameof(ThreedClassState.ViewportTransform),
                                             nameof(ThreedClassState.ViewportExtents),
                                             nameof(ThreedClassState.YControl)),

                new StateUpdateCallbackEntry(UpdateDepthBiasState,
                                             nameof(ThreedClassState.DepthBiasState),
                                             nameof(ThreedClassState.DepthBiasFactor),
                                             nameof(ThreedClassState.DepthBiasUnits),
                                             nameof(ThreedClassState.DepthBiasClamp)),

                new StateUpdateCallbackEntry(UpdateStencilTestState,
                                             nameof(ThreedClassState.StencilBackMasks),
                                             nameof(ThreedClassState.StencilTestState),
                                             nameof(ThreedClassState.StencilBackTestState)),

                new StateUpdateCallbackEntry(UpdateSamplerPoolState,
                                             nameof(ThreedClassState.SamplerPoolState),
                                             nameof(ThreedClassState.SamplerIndex)),

                new StateUpdateCallbackEntry(UpdateTexturePoolState, nameof(ThreedClassState.TexturePoolState)),
                new StateUpdateCallbackEntry(UpdateVertexAttribState, nameof(ThreedClassState.VertexAttribState)),

                new StateUpdateCallbackEntry(UpdateLineState,
                                             nameof(ThreedClassState.LineWidthSmooth),
                                             nameof(ThreedClassState.LineSmoothEnable)),

                new StateUpdateCallbackEntry(UpdatePointState,
                                             nameof(ThreedClassState.PointSize),
                                             nameof(ThreedClassState.VertexProgramPointSize),
                                             nameof(ThreedClassState.PointSpriteEnable),
                                             nameof(ThreedClassState.PointCoordReplace)),

                new StateUpdateCallbackEntry(UpdatePrimitiveRestartState, nameof(ThreedClassState.PrimitiveRestartState)),

                new StateUpdateCallbackEntry(UpdateIndexBufferState,
                                             nameof(ThreedClassState.IndexBufferState),
                                             nameof(ThreedClassState.IndexBufferCount)),

                new StateUpdateCallbackEntry(UpdateFaceState, nameof(ThreedClassState.FaceState)),

                new StateUpdateCallbackEntry(UpdateRtColorMask,
                                             nameof(ThreedClassState.RtColorMaskShared),
                                             nameof(ThreedClassState.RtColorMask)),

                new StateUpdateCallbackEntry(UpdateBlendState,
                                             nameof(ThreedClassState.BlendIndependent),
                                             nameof(ThreedClassState.BlendConstant),
                                             nameof(ThreedClassState.BlendStateCommon),
                                             nameof(ThreedClassState.BlendEnableCommon),
                                             nameof(ThreedClassState.BlendEnable),
                                             nameof(ThreedClassState.BlendState)),

                new StateUpdateCallbackEntry(UpdateLogicOpState, nameof(ThreedClassState.LogicOpState))
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the draw manager.
 /// </summary>
 /// <param name="context">GPU context</param>
 /// <param name="channel">GPU channel</param>
 /// <param name="state">Channel state</param>
 /// <param name="drawState">Draw state</param>
 public DrawManager(GpuContext context, GpuChannel channel, DeviceStateWithShadow <ThreedClassState> state, DrawState drawState)
 {
     _context   = context;
     _channel   = channel;
     _state     = state;
     _drawState = drawState;
 }