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.invalidate || ti.format != this.format) { this.invalidate = false; 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(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); }
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; } } }
private SampleDescription TrySampleDescription(DX11RenderContext context, SampleDescription sd) { 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; } return(sd); }
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.FOutBackBuffer[0][context] == null) { //Set preset first int bufferCount = this.FInBufferCount[0]; if (bufferCount < 1) { logger.Log(LogType.Warning, "Less than one buffer specified, seting to 1"); bufferCount = 1; } if (this.FInFlipSequential[0]) { if (bufferCount < 2) { logger.Log(LogType.Warning, "Flip sequential mode requires at least 2 buffers, setting to 2"); bufferCount = 2; } if (sd.Count > 1) { logger.Log(LogType.Warning, "Flip sequential mode does not support Multisampling, disabling"); sd.Count = 1; } } else { 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.SafeDisposeAll(context); this.FOutBackBuffer[0][context] = new DX11SwapChain(context, this.Handle, Format.R8G8B8A8_UNorm, sd, this.FInRefreshRate[0], bufferCount, this.FInFlipSequential[0]); this.FInvalidateSwapChain = false; #if DEBUG this.FOutBackBuffer[0][context].Resource.DebugName = "BackBuffer"; #endif this.depthmanager.NeedReset = true; } DX11SwapChain sc = this.FOutBackBuffer[0][context]; if (!this.renderers.ContainsKey(context)) { this.renderers.Add(context, new DX11GraphicsRenderer(context)); } this.depthmanager.Update(context, sc.Width, sc.Height, sd); this.updateddevices.Add(context); }
protected override void OnUpdate(DX11RenderContext context) { bool resetta = true; try { var ptadesc = FOutTexArray[0][context].Description; resetta = FTADepth[0] != ptadesc.ArraySize || (int)FTASize[0].x != ptadesc.Width || (int)FTASize[0].y != ptadesc.Height || FTAFormat[0] != ptadesc.Format; } catch (Exception e) { } if (resetta) { try { FOutTexArray[0].Dispose(context); } catch (Exception e) { } var tadesc = new Texture2DDescription { ArraySize = FTADepth[0], Width = (int)FTASize[0].x, Height = (int)FTASize[0].y, Format = FTAFormat[0], BindFlags = BindFlags.UnorderedAccess | BindFlags.ShaderResource, //CpuAccessFlags = CpuAccessFlags.None, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), //Usage = ResourceUsage.Default }; FOutTexArray[0][context] = new DX11RWTextureArray2D(context, new Texture2D(context.Device, tadesc)); foreach (var semantic in CustomSemantics) { semantic.Dispose(); } CustomSemantics.Clear(); CustomSemantics.Add(new RWTexture2dArrayRenderSemantic("TEXTUREARRAY", false) { Data = FOutTexArray[0][context] }); CustomSemantics.Add(new Texture2dArrayRenderSemantic("TEXTUREARRAY_SRV", false) { Data = FOutTexArray[0][context] }); } TexInfo ti = this.rtm.GetRenderTarget(context); if (ti.w != this.width || ti.h != this.height || !this.targets.ContainsKey(context) || this.invalidate || ti.format != this.format) { this.invalidate = false; 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], this.FInSharedTex[0]).Element; DX11RenderTarget2D temptargetresolve = context.ResourcePool.LockRenderTarget(this.width, this.height, ti.format, new SampleDescription(1, 0), this.FInDoMipMaps[0], this.FInMipLevel[0], this.FInSharedTex[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], this.FInSharedTex[0]).Element; targets[context] = temptarget; this.FOutBuffers[0][context] = temptarget; this.FOutAABuffers[0][context] = temptarget; } } }
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; }