OSDN Git Service

サンプラーステートを、デバイスリソース から テクスチャ の共通項目(static) へ委譲。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Sep 2016 14:43:28 +0000 (23:43 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Sep 2016 14:43:28 +0000 (23:43 +0900)
FDK24/メディア/テクスチャ.cs
FDK24/メディア/デバイスリソース.cs

index 32a62fa..8cc5627 100644 (file)
@@ -81,9 +81,27 @@ namespace FDK.メディア
                        テクスチャ.RasterizerState = new SharpDX.Direct3D11.RasterizerState( dr.D3DDevice, RSDesc );
                        //----------------
                        #endregion
+                       #region " サンプラーステート "
+                       //----------------
+                       var descSampler = new SharpDX.Direct3D11.SamplerStateDescription() {
+                               Filter = SharpDX.Direct3D11.Filter.Anisotropic,
+                               AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap,
+                               AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap,
+                               AddressW = SharpDX.Direct3D11.TextureAddressMode.Wrap,
+                               MipLodBias = 0.0f,
+                               MaximumAnisotropy = 2,
+                               ComparisonFunction = SharpDX.Direct3D11.Comparison.Never,
+                               BorderColor = new SharpDX.Mathematics.Interop.RawColor4( 0f, 0f, 0f, 0f ),
+                               MinimumLod = float.MinValue,
+                               MaximumLod = float.MaxValue,
+                       };
+                       テクスチャ.SamplerState = new SharpDX.Direct3D11.SamplerState( dr.D3DDevice, descSampler );
+                       //----------------
+                       #endregion
                }
                public static void 共有リソースを解放する()
                {
+                       テクスチャ.SamplerState?.Dispose();
                        テクスチャ.RasterizerState?.Dispose();
                        テクスチャ.BlendState?.Dispose();
                        テクスチャ.PixelShader?.Dispose();
@@ -94,6 +112,7 @@ namespace FDK.メディア
                protected static SharpDX.Direct3D11.PixelShader PixelShader = null;
                protected static SharpDX.Direct3D11.BlendState BlendState = null;
                protected static SharpDX.Direct3D11.RasterizerState RasterizerState = null;
+               protected static SharpDX.Direct3D11.SamplerState SamplerState = null;
 
                // 個別項目
 
@@ -188,7 +207,7 @@ namespace FDK.メディア
                        d3dContext.PixelShader.Set( テクスチャ.PixelShader );
                        d3dContext.PixelShader.SetConstantBuffers( 0, this.ConstantBuffer );
                        d3dContext.PixelShader.SetShaderResources( 0, 1, dr.ShaderResourceView );
-                       d3dContext.PixelShader.SetSamplers( 0, 1, dr.SamplerState );
+                       d3dContext.PixelShader.SetSamplers( 0, 1, テクスチャ.SamplerState );
 
                        // 出力マージャ
                        d3dContext.OutputMerger.SetTargets( dr.DepthStencilView, dr.RenderTargetView );
index fd85c1a..e3e31fe 100644 (file)
@@ -45,7 +45,6 @@ namespace FDK.メディア
                public SharpDX.Direct3D11.DepthStencilView DepthStencilView => this.bs_DepthStencilView;
                public SharpDX.Direct3D11.DepthStencilState DepthStencilState => this.bs_DepthStencilState;
                public SharpDX.Direct3D11.ShaderResourceView ShaderResourceView => this.bs_ShaderResourceView;
-               public SharpDX.Direct3D11.SamplerState SamplerState => this.bs_SamplerState;
                protected SharpDX.Size2F ShaderResourceViewSize;
 
                public void すべてのリソースを作成する( System.Drawing.Size バックバッファサイズ, IntPtr ウィンドウハンドル )
@@ -141,23 +140,6 @@ namespace FDK.メディア
                        //D3DX11CreateShaderResourceViewFromFile( g_pD3DDevice, L"texture.png", NULL, NULL, &g_pTextureSRV, &hr );
                        //----------------
                        #endregion
-                       #region " サンプラー "
-                       //----------------
-                       var descSampler = new SharpDX.Direct3D11.SamplerStateDescription() {
-                               Filter = SharpDX.Direct3D11.Filter.Anisotropic,
-                               AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap,
-                               AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap,
-                               AddressW = SharpDX.Direct3D11.TextureAddressMode.Wrap,
-                               MipLodBias = 0.0f,
-                               MaximumAnisotropy = 2,
-                               ComparisonFunction = SharpDX.Direct3D11.Comparison.Never,
-                               BorderColor = new SharpDX.Mathematics.Interop.RawColor4( 0f, 0f, 0f, 0f ),
-                               MinimumLod = float.MinValue,
-                               MaximumLod = float.MaxValue,
-                       };
-                       this.bs_SamplerState = new SharpDX.Direct3D11.SamplerState( this.bs_D3DDevice, descSampler );
-                       //----------------
-                       #endregion
 
                        this.サイズに依存するリソースを作成する();
                }
@@ -173,7 +155,6 @@ namespace FDK.メディア
 
                        // 取得したインターフェイスの開放
                        this.bs_DepthStencilState?.Dispose();
-                       this.bs_SamplerState?.Dispose();
                        this.bs_ShaderResourceView?.Dispose();
                        this.bs_SwapChain?.Dispose();
                        this.bs_D3DDevice?.Dispose();
@@ -304,7 +285,6 @@ namespace FDK.メディア
                private SharpDX.Mathematics.Interop.RawViewportF[] bs_ViewPort = new SharpDX.Mathematics.Interop.RawViewportF[ 1 ];
                private SharpDX.Direct3D11.DepthStencilState bs_DepthStencilState = null;
                private SharpDX.Direct3D11.ShaderResourceView bs_ShaderResourceView = null;
-               private SharpDX.Direct3D11.SamplerState bs_SamplerState = null;
                private SharpDX.Direct3D11.RenderTargetView bs_RenderTargetView = null;
                private SharpDX.Direct3D11.Texture2D bs_DepthStencil = null;
                private SharpDX.Direct3D11.DepthStencilView bs_DepthStencilView = null;