private ShaderResourceViewProxy CreateRenderTarget(int width, int height, MSAALevel msaa) { #if MSAA MSAA = msaa; #endif TargetWidth = width; TargetHeight = height; DisposeBuffers(); ColorBufferSampleDesc = GetMSAASampleDescription(); OnCreateRenderTargetAndDepthBuffers(width, height, UseDepthStencilBuffer, out colorBuffer, out depthStencilBuffer); backBuffer = OnCreateBackBuffer(width, height); backBuffer.CreateRenderTargetView(); fullResPPBuffer = Collect(new PingPongColorBuffers(Format, width, height, this.deviceResources)); fullResDepthStencilPool = Collect(new TexturePool(this.deviceResources, new Texture2DDescription() { Width = width, Height = height, ArraySize = 1, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) })); Initialized = true; OnNewBufferCreated?.Invoke(this, new Texture2DArgs(backBuffer)); return(backBuffer); }
private void InitializeTexturePools(int width, int height) { fullResPPBuffer = new PingPongColorBuffers(Format, width, height, this.DeviceResources); fullResDepthStencilPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = width, Height = height, ArraySize = 1, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); fullResRenderTargetPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = width, Height = height, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, ArraySize = 1, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); halfResDepthStencilPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = Math.Max(2, width / 2), Height = Math.Max(2, height / 2), ArraySize = 1, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); halfResRenderTargetPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = Math.Max(2, width / 2), Height = Math.Max(2, height / 2), BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, ArraySize = 1, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); quarterResDepthStencilPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = Math.Max(2, width / 4), Height = Math.Max(2, height / 4), ArraySize = 1, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); quarterResRenderTargetPool = new TexturePool(this.DeviceResources, new Texture2DDescription() { Width = Math.Max(2, width / 4), Height = Math.Max(2, height / 4), BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Usage = ResourceUsage.Default, ArraySize = 1, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0) }); }