public GLControlWrapperSlimDX9(IGL_SlimDX9 sdx) { _sdx = sdx; SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserMouse, true); Resize += GLControlWrapper_SlimDX_Resize; }
public GLControlWrapper_SlimDX9(IGL_SlimDX9 sdx) { this.sdx = sdx; //uhhh not sure what we need to be doing here //SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserMouse, true); Resize += new EventHandler(GLControlWrapper_SlimDX_Resize); }
void UpdateSourceDrawingWork(JobInfo job) { bool alternateVsync = false; // only used by alternate vsync IGL_SlimDX9 dx9 = null; if (!job.Offscreen) { //apply the vsync setting (should probably try to avoid repeating this) var vsync = Global.Config.VSyncThrottle || Global.Config.VSync; //ok, now this is a bit undesirable. //maybe the user wants vsync, but not vsync throttle. //this makes sense... but we don't have the infrastructure to support it now (we'd have to enable triple buffering or something like that) //so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice. //update 26-mar-2016: this upsets me. When fast-forwarding and skipping frames, vsync should still work. But I'm not changing it yet if (Global.DisableSecondaryThrottling) { vsync = false; } //for now, it's assumed that the presentation panel is the main window, but that may not always be true if (vsync && Global.Config.DispAlternateVsync && Global.Config.VSyncThrottle) { dx9 = GL as IGL_SlimDX9; if (dx9 != null) { alternateVsync = true; //unset normal vsync if we've chosen the alternate vsync vsync = false; } } //TODO - whats so hard about triple buffering anyway? just enable it always, and change api to SetVsync(enable,throttle) //maybe even SetVsync(enable,throttlemethod) or just SetVsync(enable,throttle,advanced) if (LastVsyncSetting != vsync || LastVsyncSettingGraphicsControl != presentationPanel.GraphicsControl) { if (LastVsyncSetting == null && vsync) { // Workaround for vsync not taking effect at startup (Intel graphics related?) presentationPanel.GraphicsControl.SetVsync(false); } presentationPanel.GraphicsControl.SetVsync(vsync); LastVsyncSettingGraphicsControl = presentationPanel.GraphicsControl; LastVsyncSetting = vsync; } } // begin rendering on this context // should this have been done earlier? // do i need to check this on an intel video card to see if running excessively is a problem? (it used to be in the FinalTarget command below, shouldn't be a problem) //GraphicsControl.Begin(); // CRITICAL POINT for yabause+GL //TODO - auto-create and age these (and dispose when old) int rtCounter = 0; _currentFilterProgram.RenderTargetProvider = new DisplayManagerRenderTargetProvider(size => ShaderChainFrugalizers[rtCounter++].Get(size)); GL.BeginScene(); // run filter chain Texture2d texCurr = null; RenderTarget rtCurr = null; bool inFinalTarget = false; foreach (var step in _currentFilterProgram.Program) { switch (step.Type) { case FilterProgram.ProgramStepType.Run: { int fi = (int)step.Args; var f = _currentFilterProgram.Filters[fi]; f.SetInput(texCurr); f.Run(); var orec = f.FindOutput(); if (orec != null) { if (orec.SurfaceDisposition == SurfaceDisposition.Texture) { texCurr = f.GetOutput(); rtCurr = null; } } break; } case FilterProgram.ProgramStepType.NewTarget: { var size = (Size)step.Args; rtCurr = ShaderChainFrugalizers[rtCounter++].Get(size); rtCurr.Bind(); _currentFilterProgram.CurrRenderTarget = rtCurr; break; } case FilterProgram.ProgramStepType.FinalTarget: { inFinalTarget = true; rtCurr = null; _currentFilterProgram.CurrRenderTarget = null; GL.BindRenderTarget(null); break; } } } GL.EndScene(); if (job.Offscreen) { job.OffscreenBb = rtCurr.Texture2d.Resolve(); job.OffscreenBb.DiscardAlpha(); } else { Debug.Assert(inFinalTarget); // wait for vsync to begin if (alternateVsync) { dx9.AlternateVsyncPass(0); } // present and conclude drawing presentationPanel.GraphicsControl.SwapBuffers(); // wait for vsync to end if (alternateVsync) { dx9.AlternateVsyncPass(1); } // nope. don't do this. workaround for slow context switching on intel GPUs. just switch to another context when necessary before doing anything // presentationPanel.GraphicsControl.End(); } }