public void Update(IPluginIO pin, 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.FOutBackBuffer[0][context] == null) { this.FOutBackBuffer[0].Dispose(context); 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; } this.FOutBackBuffer[0][context] = new DX11SwapChain(context, this.Handle, Format.R8G8B8A8_UNorm, sd, 60, this.FInBufferCount[0]); #if DEBUG this.FOutBackBuffer[0][context].Resource.DebugName = "BackBuffer"; #endif this.depthmanager.NeedReset = true; } DX11SwapChain sc = this.FOutBackBuffer[0][context]; if (this.FResized) { //if (!sc.IsFullScreen) //{ // sc.Resize(); // } //this.FInvalidateSwapChain = true; } if (!this.renderers.ContainsKey(context)) { this.renderers.Add(context, new DX11GraphicsRenderer(this.FHost, context)); } this.depthmanager.Update(context, sc.Width, sc.Height, sd); this.updateddevices.Add(context); }
protected override void OnUpdate(DX11RenderContext context) { //Grab a temp target if enabled TexInfo ti = this.rtm.GetRenderTarget(context); if (ti.w != this.width || ti.h != this.height || !this.targets.ContainsKey(context) || this.FInAASamplesPerPixel.IsChanged || ti.format !=this.format) { this.width = ti.w; this.height = ti.h; this.format = ti.format; this.depthmanager.NeedReset = true; if (targets.ContainsKey(context)) { context.ResourcePool.Unlock(targets[context]); } if (targetresolve.ContainsKey(context)) { context.ResourcePool.Unlock(targetresolve[context]); } int aacount = Convert.ToInt32(this.FInAASamplesPerPixel[0].Name); int aaquality = 0; if (aacount > 1) { List<SampleDescription> sds = context.GetMultisampleFormatInfo(ti.format); int maxlevels = sds[sds.Count - 1].Count; if (aacount > maxlevels) { FHost.Log(TLogType.Warning, "Multisample count too high for this format, reverted to: " + maxlevels); aacount = maxlevels; } DX11RenderTarget2D temptarget = context.ResourcePool.LockRenderTarget(this.width, this.height, ti.format, new SampleDescription(aacount,aaquality), this.FInDoMipMaps[0], this.FInMipLevel[0]).Element; DX11RenderTarget2D temptargetresolve = context.ResourcePool.LockRenderTarget(this.width, this.height, ti.format, new SampleDescription(1, 0), this.FInDoMipMaps[0], this.FInMipLevel[0]).Element; targets[context] = temptarget; targetresolve[context] = temptargetresolve; this.FOutBuffers[0][context] = temptargetresolve; this.FOutAABuffers[0][context] = temptarget; } else { //Bind both texture as same output DX11RenderTarget2D temptarget = context.ResourcePool.LockRenderTarget(this.width, this.height, ti.format, new SampleDescription(aacount, aaquality), this.FInDoMipMaps[0], this.FInMipLevel[0]).Element; targets[context] = temptarget; this.FOutBuffers[0][context] = temptarget; this.FOutAABuffers[0][context] = temptarget; } } }
public void Update(DX11RenderContext context, int w, int h,SampleDescription sd) { if (this.currentmode == eDepthBufferMode.Standard) { DX11DepthStencil ds; if (this.NeedReset || !this.depthoutputpin.IOObject[0].Data.ContainsKey(context)) { if (this.depthoutputpin.IOObject[0] != null) { this.depthoutputpin.IOObject[0].Dispose(context); } if (sd.Count > 1) { if (!context.IsAtLeast101) { host.Log(TLogType.Warning, "Device Feature Level Needs at least 10.1 to create Multisampled Depth Buffer, rolling back to 1"); sd.Count = 1; } } Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin.IOObject[0].Name); List<SampleDescription> sds = context.GetMultisampleFormatInfo(depthfmt); int maxlevels = sds[sds.Count - 1].Count; if (sd.Count > maxlevels) { host.Log(TLogType.Warning, "Multisample count too high for this depth format, reverted to: " + maxlevels); sd.Count = maxlevels; } ds = new DX11DepthStencil(context, w, h, sd, depthfmt); #if DEBUG ds.Resource.DebugName = "DepthStencil"; #endif this.depthoutputpin.IOObject[0][context] = ds; } } }