OSDN Git Service

デバイスリソース クラスに、D3D11デバッグ情報の出力を追加。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Tue, 20 Sep 2016 02:13:36 +0000 (11:13 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Tue, 20 Sep 2016 02:13:36 +0000 (11:13 +0900)
FDK24/メディア/デバイスリソース.cs
StrokeStyleT/StrokeStyleT.cs
StrokeStyleT/曲/Node.cs

index c4e5f9b..dc15b4d 100644 (file)
@@ -124,6 +124,7 @@ namespace FDK.メディア
                                SampleDescription = new SharpDX.DXGI.SampleDescription( 1, 0 ),
                                SwapEffect = SharpDX.DXGI.SwapEffect.Discard,
                                Usage = SharpDX.DXGI.Usage.RenderTargetOutput,
+                               Flags = SharpDX.DXGI.SwapChainFlags.AllowModeSwitch,
                        };
                        // 機能レベル
                        var featureLevels = new SharpDX.Direct3D.FeatureLevel[] {
@@ -133,6 +134,7 @@ namespace FDK.メディア
                        };
                        var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport; // D2Dをサポートするなら必須。
 #if DEBUG
+                       // D3D11 Debugメッセージは、プロジェクトプロパティで「ネイティブコードのデバッグを有効にする」を ON にしないと表示されないので注意。
                        creationFlags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
 #endif
                        // デバイスとスワップチェーンを作成する。
@@ -152,6 +154,12 @@ namespace FDK.メディア
                        using( d3dDevice )
                        {
                                // D3D 関連
+
+                               #region " デバイスからデバッグオブジェクトを取得する。"
+                               //----------------
+                               this.bs_D3DDeviceDebug = d3dDevice.QueryInterfaceOrNull<SharpDX.Direct3D11.DeviceDebug>();
+                               //----------------
+                               #endregion
                                #region " D3DDevice が ID3D11VideoDevice を実装してないならエラー。(Win8以降のPCでは実装されているはず。) "
                                //-----------------
                                using( var videoDevice = d3dDevice.QueryInterfaceOrNull<SharpDX.Direct3D11.VideoDevice>() )
@@ -185,35 +193,6 @@ namespace FDK.メディア
                                }
                                //----------------
                                #endregion
-                               #region " 深度ステンシルステートを作成する。"
-                               //----------------
-                               var DepthSencil = new SharpDX.Direct3D11.DepthStencilStateDescription() {
-                                       IsDepthEnabled = true,  // 深度テストあり
-                                       DepthWriteMask = SharpDX.Direct3D11.DepthWriteMask.All,     // 書き込む
-                                       DepthComparison = SharpDX.Direct3D11.Comparison.Less,   // 手前の物体を描画
-                                       IsStencilEnabled = false,   // ステンシルテストなし。
-                                       StencilReadMask = 0,    // ステンシル読み込みマスク。
-                                       StencilWriteMask = 0,   // ステンシル書き込みマスク。
-
-                                       // 面が表を向いている場合のステンシル・テストの設定
-                                       FrontFace = new SharpDX.Direct3D11.DepthStencilOperationDescription() {
-                                               FailOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
-                                               DepthFailOperation = SharpDX.Direct3D11.StencilOperation.Keep,  // 維持
-                                               PassOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
-                                               Comparison = SharpDX.Direct3D11.Comparison.Never,   // 常に失敗
-                                       },
-
-                                       // 面が裏を向いている場合のステンシル・テストの設定
-                                       BackFace = new SharpDX.Direct3D11.DepthStencilOperationDescription() {
-                                               FailOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
-                                               DepthFailOperation = SharpDX.Direct3D11.StencilOperation.Keep,  // 維持
-                                               PassOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
-                                               Comparison = SharpDX.Direct3D11.Comparison.Always,  // 常に成功
-                                       },
-                               };
-                               this.bs_D3DDepthStencilState = new SharpDX.Direct3D11.DepthStencilState( d3dDevice, DepthSencil );
-                               //----------------
-                               #endregion
                        }
 
                        this.サイズに依存するリソースを作成する();
@@ -221,14 +200,12 @@ namespace FDK.メディア
                public void すべてのリソースを解放する()
                {
                        // D3D 関連
-                       var d3dDevice = (SharpDX.Direct3D11.Device) null;
-                       using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.DXGIDeviceManager, out d3dDevice ) )
-                       {
-                               d3dDevice.ImmediateContext?.ClearState();   // デバイスステートをクリアする。
-                       }
                        this.bs_SwapChain?.SetFullscreenState( fullscreen: false, targetRef: null );    // スワップチェインをウインドウモードにする。
                        this.サイズに依存するリソースを解放する();
-                       FDK.Utilities.解放する( ref this.bs_D3DDepthStencilState );
+
+                       this.bs_D3DDeviceDebug?.ReportLiveDeviceObjects( SharpDX.Direct3D11.ReportingLevel.Summary );
+
+                       FDK.Utilities.解放する( ref this.bs_D3DDeviceDebug );
                        FDK.Utilities.解放する( ref this.bs_SwapChain );
                        FDK.Utilities.解放する( ref this.bs_DXGIDeviceManager );
 
@@ -247,7 +224,7 @@ namespace FDK.メディア
                                width: (int) this.物理画面サイズpx.Width,
                                height: (int) this.物理画面サイズpx.Height,
                                newFormat: SharpDX.DXGI.Format.B8G8R8A8_UNorm,
-                               swapChainFlags: SharpDX.DXGI.SwapChainFlags.None );
+                               swapChainFlags: SharpDX.DXGI.SwapChainFlags.AllowModeSwitch );
                        //----------------
                        #endregion
 
@@ -288,6 +265,35 @@ namespace FDK.メディア
                                        this.bs_D3DDepthStencilView = new SharpDX.Direct3D11.DepthStencilView( d3dDevice, this.bs_D3DDepthStencil, descDSV );
                                        //----------------
                                        #endregion
+                                       #region " 深度ステンシルステートを作成する。"
+                                       //----------------
+                                       var DepthSencil = new SharpDX.Direct3D11.DepthStencilStateDescription() {
+                                               IsDepthEnabled = true,  // 深度テストあり
+                                               DepthWriteMask = SharpDX.Direct3D11.DepthWriteMask.All,     // 書き込む
+                                               DepthComparison = SharpDX.Direct3D11.Comparison.Less,   // 手前の物体を描画
+                                               IsStencilEnabled = false,   // ステンシルテストなし。
+                                               StencilReadMask = 0,    // ステンシル読み込みマスク。
+                                               StencilWriteMask = 0,   // ステンシル書き込みマスク。
+
+                                               // 面が表を向いている場合のステンシル・テストの設定
+                                               FrontFace = new SharpDX.Direct3D11.DepthStencilOperationDescription() {
+                                                       FailOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
+                                                       DepthFailOperation = SharpDX.Direct3D11.StencilOperation.Keep,  // 維持
+                                                       PassOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
+                                                       Comparison = SharpDX.Direct3D11.Comparison.Never,   // 常に失敗
+                                               },
+
+                                               // 面が裏を向いている場合のステンシル・テストの設定
+                                               BackFace = new SharpDX.Direct3D11.DepthStencilOperationDescription() {
+                                                       FailOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
+                                                       DepthFailOperation = SharpDX.Direct3D11.StencilOperation.Keep,  // 維持
+                                                       PassOperation = SharpDX.Direct3D11.StencilOperation.Keep,   // 維持
+                                                       Comparison = SharpDX.Direct3D11.Comparison.Always,  // 常に成功
+                                               },
+                                       };
+                                       this.bs_D3DDepthStencilState = new SharpDX.Direct3D11.DepthStencilState( d3dDevice, DepthSencil );
+                                       //----------------
+                                       #endregion
                                        #region " ビューポートの設定 "
                                        //----------------
                                        this.bs_D3DViewPort[ 0 ] = new SharpDX.Mathematics.Interop.RawViewportF() {
@@ -368,10 +374,13 @@ namespace FDK.メディア
                        var d3dDevice = (SharpDX.Direct3D11.Device) null;
                        using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.DXGIDeviceManager, out d3dDevice ) )
                        {
-                               // 描画ターゲットを解除する。
+                               // デバイスステートをすべてクリアする。
+                               d3dDevice.ImmediateContext.ClearState();
                                d3dDevice.ImmediateContext.OutputMerger.ResetTargets();
 
                                FDK.メディア.テクスチャ.共有リソースを解放する();
+
+                               FDK.Utilities.解放する( ref this.bs_D3DDepthStencilState );
                                FDK.Utilities.解放する( ref this.bs_D3DDepthStencilView );
                                FDK.Utilities.解放する( ref this.bs_D3DDepthStencil );
                                FDK.Utilities.解放する( ref this.bs_D3DRenderTargetView );
@@ -431,6 +440,7 @@ namespace FDK.メディア
                private SharpDX.Direct3D11.RenderTargetView bs_D3DRenderTargetView = null;
                private SharpDX.Direct3D11.Texture2D bs_D3DDepthStencil = null;
                private SharpDX.Direct3D11.DepthStencilView bs_D3DDepthStencilView = null;
+               private SharpDX.Direct3D11.DeviceDebug bs_D3DDeviceDebug = null;
                private SharpDX.Direct2D1.Device1 bs_D2DDevice1 = null;
                private SharpDX.Direct2D1.DeviceContext1 bs_D2DContext1 = null;
                private SharpDX.Direct2D1.Bitmap1 bs_D2DRenderTargetBitmap = null;
index 6520a2f..ea9cb0d 100644 (file)
@@ -46,7 +46,7 @@ namespace SST
 
                        this.Text = $"StrokeStyle<T> {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
                        this.ClientSize = new System.Drawing.Size( 1920, 1080 );        // 物理画面サイズpx
-                       this.設計画面サイズdpx = new SharpDX.Size2F( 1920, 1080 );       // 設計画面サイズdpx
+                       this.設計画面サイズdpx = new SharpDX.Size2F( 1920, 1080 ); // 設計画面サイズdpx
 
                        #region " System.Stopwatch が高解像度タイマを使わないならエラー。"
                        //-----------------
index bcce955..1c4b15d 100644 (file)
@@ -68,7 +68,7 @@ namespace SST.曲
 
                public virtual SharpDX.Size2F ノード画像サイズdpx => new SharpDX.Size2F( 314f, 220f );   // 規定の設計値[dpx]
                public virtual SharpDX.Size2F タイトル画像サイズdpx => new SharpDX.Size2F( 314f, 220f ); // 規定の設計値[dpx](暫定)
-                                                                                                                                                                               //=> new SharpDX.Size2F( 314f, 82f ); } // 規定の設計値[dpx](最終)
+                                                                                                               //=> new SharpDX.Size2F( 314f, 82f ); } // 規定の設計値[dpx](最終)
                protected override void On活性化( デバイスリソース dr )
                {
                        // タイトル部の文字画像を作成する。
@@ -79,6 +79,7 @@ namespace SST.曲
                }
                protected override void On非活性化( デバイスリソース dr )
                {
+                       this.子リスト.Remove( this.タイトル画像 );
                }
                protected override void Onデバイス依存リソースの作成( デバイスリソース dr )
                {