void ResizeDXGIBuffers(int width, int height) { if (m_app.BackBuffer != null && m_app.SwapChainDesc.ModeDescription.Width == width && m_app.SwapChainDesc.ModeDescription.Height == height) { return; } Pause(true, true); m_app.SetSwapChainDesc(new SwapChainDescription() { BufferCount = 2, ModeDescription = new ModeDescription(width, height, new Rational(60, 0), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }); m_app.ImmediateContext.ClearState(); // スワップチェーン リリース呼び出し SwapChainReleasing(); DXState.InsideDeviceCallback = false; // 解放処理 { var backB = m_app.BackBuffer; m_app.SetBackBuffer(null); Utilities.Dispose(ref backB); var renderView = m_app.BackBufferView; m_app.SetBackBufferView(null); Utilities.Dispose(ref renderView); var depthBff = m_app.DepthBuffer; m_app.SetDepthBuffer(null); Utilities.Dispose(ref depthBff); var depthView = m_app.DepthView; m_app.SetDepthView(null); Utilities.Dispose(ref depthView); } // バックバッファのサイズを変更する m_app.SwapChain.ResizeBuffers( m_app.SwapChainDesc.BufferCount, width, height, Format.Unknown, SwapChainFlags.None); // レンダーターゲットビューとビューポートを設定する // スワップチェーンからバックバッファを取得する m_app.SetBackBuffer(Texture2D.FromSwapChain <Texture2D>(m_app.SwapChain, 0)); m_app.BackBuffer.DebugName = "GDC::BackBuffer"; // バックバッファ上のRenderview m_app.SetBackBufferView(new RenderTargetView(m_app.DXDevice, m_app.BackBuffer)); m_app.BackBufferView.DebugName = "GDC::RenderTargetView"; // 深度バッファを作成する m_app.SetDepthBuffer(new Texture2D(m_app.DXDevice, new Texture2DDescription() { Format = Format.D32_Float_S8X24_UInt, ArraySize = 1, MipLevels = 1, Width = width, Height = height, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None })); m_app.DepthBuffer.DebugName = "GDC::Depth"; // 深度バッファビューを作成する m_app.SetDepthView(new DepthStencilView(m_app.DXDevice, m_app.DepthBuffer)); m_app.DepthView.DebugName = "GDC::DepthView"; // レンダリングのターゲットとビューポートの設定 m_app.ImmediateContext.Rasterizer.SetViewport(new Viewport(0, 0, width, height, 0.0f, 1.0f)); m_app.ImmediateContext.OutputMerger.SetTargets(m_app.DepthView, m_app.BackBufferView); SwapChainResized(m_app.DXDevice, m_app.SwapChain, m_app.SwapChainDesc); DXState.InsideDeviceCallback = false; DXState.DeviceObjectsReset = true; Pause(false, false); }