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[] {
};
var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport; // D2Dをサポートするなら必須。
#if DEBUG
+ // D3D11 Debugメッセージは、プロジェクトプロパティで「ネイティブコードのデバッグを有効にする」を ON にしないと表示されないので注意。
creationFlags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
#endif
// デバイスとスワップチェーンを作成する。
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>() )
}
//----------------
#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.サイズに依存するリソースを作成する();
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 );
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
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() {
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 );
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;