protected override void BeforeRender(DX11GraphicsRenderer renderer, DX11RenderContext context) { renderer.EnableDepth = this.FInDepthBuffer[0]; renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(targets[context]); }
protected override void AfterRender(DX11GraphicsRenderer renderer, DX11RenderContext context) { if (this.genmipmap && this.sd.Count == 1) { for (int i = 0; i < this.FOutBuffers.SliceCount; i++) { context.CurrentDeviceContext.GenerateMips(this.FOutBuffers[i][context].SRV); } } }
protected override void BeforeRender(DX11GraphicsRenderer renderer, DX11RenderContext context) { renderer.EnableDepth = this.FInDepthBuffer[0]; renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(targets[context]); if (FTAClear[0]) { context.CurrentDeviceContext.ClearUnorderedAccessView(FOutTexArray[0][context].UAV, new [] { (float)FTAClearCol[0].R, (float)FTAClearCol[0].G, (float)FTAClearCol[0].B, (float)FTAClearCol[0].A }); } }
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; if (this.updateddevices.Contains(context)) { return; } SampleDescription sd = new SampleDescription(1, 0); if (this.FResized || this.FInvalidateSwapChain || this.swapchain == null) { if (this.swapchain != null) { this.swapchain.Dispose(); } this.swapchain = new DX11SwapChain(context, this.form.Handle, Format.R8G8B8A8_UNorm, sd, this.FInRate[0]); } if (this.renderer == null) { this.renderer = new DX11GraphicsRenderer(this.FHost, context); } this.updateddevices.Add(context); if (this.FInFullScreen[0] != this.swapchain.IsFullScreen) { if (this.FInFullScreen[0]) { this.prevx = this.form.Width; this.prevy = this.form.Height; /*Screen screen = Screen.FromControl(this.form);*/ this.form.FormBorderStyle = FormBorderStyle.None; this.form.Width = Convert.ToInt32(this.FInRes[0].X); this.form.Height = Convert.ToInt32(this.FInRes[0].Y); this.swapchain.Resize(); this.swapchain.SetFullScreen(true); this.setfull = false; } else { this.swapchain.SetFullScreen(false); this.form.FormBorderStyle = FormBorderStyle.Fixed3D; this.form.Width = this.prevx; this.form.Height = this.prevy; this.swapchain.Resize(); } } }
protected override void BeforeRender(DX11GraphicsRenderer renderer, DX11RenderContext context) { IDX11RenderTargetView[] rtvs = new IDX11RenderTargetView[this.FOutBuffers.SliceCount]; for (int i = 0; i < this.FOutBuffers.SliceCount; i++) { rtvs[i] = this.FOutBuffers[i][context]; } renderer.EnableDepth = this.FInDepthBuffer[0]; renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(rtvs); }
protected override void AfterRender(DX11GraphicsRenderer renderer, DX11RenderContext context) { if (this.sd.Count > 1) { context.CurrentDeviceContext.ResolveSubresource(targets[context].Resource, 0, targetresolve[context].Resource, 0, targets[context].Format); } if (this.genmipmap && this.sd.Count == 1) { for (int i = 0; i < this.FOutBuffers.SliceCount; i++) { context.CurrentDeviceContext.GenerateMips(targets[context].SRV); } } }
public void Render(DX11RenderContext context) { Device device = context.Device; if (!this.updateddevices.Contains(context)) { this.Update(context); } if (this.rendereddevices.Contains(context)) { return; } Exception exception = null; if (this.FInEnabled[0]) { if (this.BeginQuery != null) { this.BeginQuery(context); } DX11SwapChain chain = this.FOutBackBuffer[0][context]; DX11GraphicsRenderer renderer = this.renderers[context]; renderer.EnableDepth = this.FInDepthBuffer[0]; renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(chain); renderer.SetTargets(); try { if (this.FInClear[0]) { //Remove Shader view if bound as is context.CurrentDeviceContext.ClearRenderTargetView(chain.RTV, this.FInBgColor[0]); } if (this.FInClearDepth[0]) { if (this.FInDepthBuffer[0]) { this.depthmanager.Clear(context, this.FInClearDepthValue[0]); } } //Only call render if layer connected if (this.FInLayer.IsConnected) { int rtmax = Math.Max(this.FInProjection.SliceCount, this.FInView.SliceCount); rtmax = Math.Max(rtmax, this.FInViewPort.SliceCount); settings.ViewportCount = rtmax; bool viewportpop = this.FInViewPort.IsConnected; for (int i = 0; i < rtmax; i++) { this.RenderSlice(context, settings, i, viewportpop); } } if (this.EndQuery != null) { this.EndQuery(context); } } catch (Exception ex) { exception = ex; } finally { renderer.CleanTargets(); } } this.rendereddevices.Add(context); //Rethrow if (exception != null) { throw exception; } }
protected abstract void AfterRender(DX11GraphicsRenderer renderer, DX11RenderContext OnDevice);
public void Render(DX11RenderContext context) { if (this.currentSpreadMax == 0) { return; } Device device = context.Device; //Just in case if (!this.updateddevices.Contains(context)) { this.Update(context); } if (this.rendereddevices.Contains(context)) { return; } if (this.FInEnabled[0]) { DX11GraphicsRenderer renderer = this.renderers[context]; if (this.BeginQuery != null) { this.BeginQuery(context); } this.BeforeRender(renderer, context); Exception exception = null; try { renderer.SetTargets(); if (this.FInClearDepth[0] && this.FInDepthBuffer[0]) { this.depthmanager.Clear(context, this.FInClearDepthValue[0]); } this.DoClear(context); if (this.FInLayer.IsConnected) { int rtmax = Math.Max(this.FInProjection.SliceCount, this.FInView.SliceCount); rtmax = Math.Max(rtmax, this.FInViewPort.SliceCount); settings.ViewportCount = rtmax; bool viewportpop = this.FInViewPort.IsConnected; float cw = (float)this.width; float ch = (float)this.height; for (int i = 0; i < rtmax; i++) { settings.ViewportIndex = i; settings.ApplyTransforms(this.FInView[i], this.FInProjection[i], this.FInAspect[i], this.FInCrop[i]); settings.RenderWidth = this.width; settings.RenderHeight = this.height; settings.BackBuffer = this.GetMainTarget(context); settings.CustomSemantics.Clear(); settings.ResourceSemantics.Clear(); if (viewportpop) { context.RenderTargetStack.PushViewport(this.FInViewPort[i].Normalize(cw, ch)); } try { this.FInLayer.RenderAll(context, settings); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (viewportpop) { context.RenderTargetStack.Pop(); } } } //Post render this.AfterRender(renderer, context); } catch (Exception ex) { exception = ex; } finally { if (this.EndQuery != null) { this.EndQuery(context); } renderer.CleanTargets(); } this.rendereddevices.Add(context); if (exception != null) { throw exception; } } }
public void Update(DX11RenderContext context) { Device device = context.Device; if (this.updateddevices.Contains(context)) { return; } int samplecount = Convert.ToInt32(FInAASamplesPerPixel[0].Name); SampleDescription sd = new SampleDescription(samplecount, 0); if (this.FResized || this.FInvalidateSwapChain || this.swapchain == null) { List <SampleDescription> sds = context.GetMultisampleFormatInfo(Format.R8G8B8A8_UNorm); int maxlevels = sds[sds.Count - 1].Count; if (sd.Count > maxlevels) { logger.Log(LogType.Warning, "Multisample count too high for this format, reverted to: " + maxlevels); sd.Count = maxlevels; } if (this.swapchain != null) { this.swapchain.Dispose(); } this.swapchain = new DX11SwapChain(context, this.form.Handle, Format.R8G8B8A8_UNorm, sd, this.FInRate[0], 2, this.FInFlipSequential[0]); this.FInvalidateSwapChain = false; } if (this.renderer == null) { this.renderer = new DX11GraphicsRenderer(context); } bool fs = this.swapchain.IsFullScreen; if (this.FInFullScreen[0] != fs) { if (this.FInFullScreen[0]) { this.prevx = this.form.Width; this.prevy = this.form.Height; /*Screen screen = Screen.FromControl(this.form);*/ this.form.FormBorderStyle = FormBorderStyle.None; this.form.Width = Convert.ToInt32(this.FInRes[0].X); this.form.Height = Convert.ToInt32(this.FInRes[0].Y); this.depthmanager.NeedReset = true; this.swapchain.Resize(); this.swapchain.SetFullScreen(true); } else { this.swapchain.SetFullScreen(false); this.form.FormBorderStyle = FormBorderStyle.Fixed3D; this.form.Width = this.prevx; this.form.Height = this.prevy; this.swapchain.Resize(); } } this.depthmanager.Update(context, this.swapchain.Width, this.swapchain.Height, sd); this.updateddevices.Add(context); this.FOutIsFullScreen[0] = fs; }
protected override void AfterRender(DX11GraphicsRenderer renderer, DX11RenderContext OnDevice) { }
public void Render(DX11RenderContext context) { Device device = context.Device; if (!this.updateddevices.Contains(context)) { this.Update(null, context); } if (this.rendereddevices.Contains(context)) { return; } if (this.FInEnabled[0]) { if (this.BeginQuery != null) { this.BeginQuery(context); } DX11SwapChain chain = this.FOutBackBuffer[0][context]; DX11GraphicsRenderer renderer = this.renderers[context]; renderer.EnableDepth = this.FInDepthBuffer[0]; renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(chain); renderer.SetTargets(); if (this.FInClear[0]) { //Remove Shader view if bound as is context.CurrentDeviceContext.ClearRenderTargetView(chain.RTV, this.FInBgColor[0].Color); } if (this.FInClearDepth[0]) { if (this.FInDepthBuffer[0]) { this.depthmanager.Clear(context); } } //Only call render if layer connected if (this.FInLayer.PluginIO.IsConnected) { int rtmax = Math.Max(this.FInProjection.SliceCount, this.FInView.SliceCount); rtmax = Math.Max(rtmax, this.FInViewPort.SliceCount); settings.ViewportCount = rtmax; bool viewportpop = this.FInViewPort.PluginIO.IsConnected; float cw = (float)this.ClientSize.Width; float ch = (float)this.ClientSize.Height; for (int i = 0; i < rtmax; i++) { settings.ViewportIndex = i; settings.View = this.FInView[i]; Matrix proj = this.FInProjection[i]; Matrix aspect = Matrix.Invert(this.FInAspect[i]); Matrix crop = Matrix.Invert(this.FInCrop[i]); settings.Projection = proj * aspect * crop; settings.ViewProjection = settings.View * settings.Projection; settings.BackBuffer = this.FOutBackBuffer[0][context]; settings.RenderWidth = this.FOutBackBuffer[0][context].Resource.Description.Width; settings.RenderHeight = this.FOutBackBuffer[0][context].Resource.Description.Height; settings.ResourceSemantics.Clear(); settings.CustomSemantics.Clear(); if (viewportpop) { context.RenderTargetStack.PushViewport(this.FInViewPort[i].Normalize(cw, ch)); } //Call render on all layers for (int j = 0; j < this.FInLayer.SliceCount; j++) { this.FInLayer[j][context].Render(this.FInLayer.PluginIO, context, settings); } if (viewportpop) { context.RenderTargetStack.PopViewport(); } } } if (this.EndQuery != null) { this.EndQuery(context); } renderer.CleanTargets(); //OnDevice.RenderTargetStack.Pop(); } this.rendereddevices.Add(context); }
public void Render(DX11RenderContext context) { Device device = context.Device; //Just in case if (!this.updateddevices.Contains(context)) { this.Update(null, context); } if (this.rendereddevices.Contains(context)) { return; } if (this.FInEnabled[0]) { if (this.BeginQuery != null) { this.BeginQuery(context); } DX11GraphicsRenderer renderer = this.renderers[context]; this.BeforeRender(renderer, context); renderer.SetTargets(); if (this.FInClearDepth[0] && this.FInDepthBuffer[0]) { this.depthmanager.Clear(context); } if (this.FInClear[0]) { renderer.Clear(this.FInBgColor[0]); } if (this.FInLayer.PluginIO.IsConnected) { int rtmax = Math.Max(this.FInProjection.SliceCount, this.FInView.SliceCount); rtmax = Math.Max(rtmax, this.FInViewPort.SliceCount); DX11RenderSettings settings = new DX11RenderSettings(); settings.ViewportCount = rtmax; bool viewportpop = this.FInViewPort.PluginIO.IsConnected; float cw = (float)this.width; float ch = (float)this.height; for (int i = 0; i < rtmax; i++) { settings.ViewportIndex = i; settings.View = this.FInView[i]; Matrix proj = this.FInProjection[i]; Matrix aspect = Matrix.Invert(this.FInAspect[i]); Matrix crop = Matrix.Invert(this.FInCrop[i]); settings.Projection = proj * aspect * crop; settings.ViewProjection = settings.View * settings.Projection; settings.RenderWidth = this.width; settings.RenderHeight = this.height; settings.BackBuffer = this.GetMainTarget(context); settings.CustomSemantics.Clear(); settings.ResourceSemantics.Clear(); if (viewportpop) { context.RenderTargetStack.PushViewport(this.FInViewPort[i].Normalize(cw, ch)); } //Call render on all layers for (int j = 0; j < this.FInLayer.SliceCount; j++) { try { this.FInLayer[j][context].Render(this.FInLayer.PluginIO, context, settings); } catch (Exception ex) { Console.WriteLine(ex.Message); } } if (viewportpop) { context.RenderTargetStack.PopViewport(); } } } //Post render this.AfterRender(renderer, context); renderer.CleanTargets(); if (this.EndQuery != null) { this.EndQuery(context); } this.rendereddevices.Add(context); } }