Esempio n. 1
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;
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a new instance of the 3D engine class.
        /// </summary>
        /// <param name="context">GPU context</param>
        /// <param name="channel">GPU channel</param>
        public ThreedClass(GpuContext context, GpuChannel channel, GPFifoClass fifoClass)
        {
            _context   = context;
            _fifoClass = fifoClass;
            _state     = new DeviceStateWithShadow <ThreedClassState>(new Dictionary <string, RwCallback>
            {
                { nameof(ThreedClassState.LaunchDma), new RwCallback(LaunchDma, null) },
                { nameof(ThreedClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
                { nameof(ThreedClassState.SyncpointAction), new RwCallback(IncrementSyncpoint, null) },
                { nameof(ThreedClassState.InvalidateSamplerCacheNoWfi), new RwCallback(InvalidateSamplerCacheNoWfi, null) },
                { nameof(ThreedClassState.InvalidateTextureHeaderCacheNoWfi), new RwCallback(InvalidateTextureHeaderCacheNoWfi, null) },
                { nameof(ThreedClassState.TextureBarrier), new RwCallback(TextureBarrier, null) },
                { nameof(ThreedClassState.TextureBarrierTiled), new RwCallback(TextureBarrierTiled, null) },
                { nameof(ThreedClassState.DrawTextureSrcY), new RwCallback(DrawTexture, null) },
                { nameof(ThreedClassState.VbElementU8), new RwCallback(VbElementU8, null) },
                { nameof(ThreedClassState.VbElementU16), new RwCallback(VbElementU16, null) },
                { nameof(ThreedClassState.VbElementU32), new RwCallback(VbElementU32, null) },
                { nameof(ThreedClassState.ResetCounter), new RwCallback(ResetCounter, null) },
                { nameof(ThreedClassState.RenderEnableCondition), new RwCallback(null, Zero) },
                { nameof(ThreedClassState.DrawEnd), new RwCallback(DrawEnd, null) },
                { nameof(ThreedClassState.DrawBegin), new RwCallback(DrawBegin, null) },
                { nameof(ThreedClassState.DrawIndexedSmall), new RwCallback(DrawIndexedSmall, null) },
                { nameof(ThreedClassState.DrawIndexedSmall2), new RwCallback(DrawIndexedSmall2, null) },
                { nameof(ThreedClassState.DrawIndexedSmallIncInstance), new RwCallback(DrawIndexedSmallIncInstance, null) },
                { nameof(ThreedClassState.DrawIndexedSmallIncInstance2), new RwCallback(DrawIndexedSmallIncInstance2, null) },
                { nameof(ThreedClassState.IndexBufferCount), new RwCallback(SetIndexBufferCount, null) },
                { nameof(ThreedClassState.Clear), new RwCallback(Clear, null) },
                { nameof(ThreedClassState.SemaphoreControl), new RwCallback(Report, null) },
                { nameof(ThreedClassState.SetFalcon04), new RwCallback(SetFalcon04, null) },
                { nameof(ThreedClassState.UniformBufferUpdateData), new RwCallback(ConstantBufferUpdate, null) },
                { nameof(ThreedClassState.UniformBufferBindVertex), new RwCallback(ConstantBufferBindVertex, null) },
                { nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) },
                { nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) },
                { nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) },
                { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) }
            });

            _i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);

            var drawState = new DrawState();

            _drawManager      = new DrawManager(context, channel, _state, drawState);
            _semaphoreUpdater = new SemaphoreUpdater(context, channel, _state);
            _cbUpdater        = new ConstantBufferUpdater(channel, _state);
            _stateUpdater     = new StateUpdater(context, channel, _state, drawState);

            // This defaults to "always", even without any register write.
            // Reads just return 0, regardless of what was set there.
            _state.State.RenderEnableCondition = Condition.Always;
        }
Esempio n. 3
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))
            });
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new instance of the semaphore updater.
 /// </summary>
 /// <param name="context">GPU context</param>
 /// <param name="channel">GPU channel</param>
 /// <param name="state">Channel state</param>
 public SemaphoreUpdater(GpuContext context, GpuChannel channel, DeviceStateWithShadow <ThreedClassState> state)
 {
     _context = context;
     _channel = channel;
     _state   = state;
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a new instance of the constant buffer updater.
 /// </summary>
 /// <param name="channel">GPU channel</param>
 /// <param name="state">Channel state</param>
 public ConstantBufferUpdater(GpuChannel channel, DeviceStateWithShadow <ThreedClassState> state)
 {
     _channel = channel;
     _state   = state;
 }