本文整理汇总了C#中DepthStencilView类的典型用法代码示例。如果您正苦于以下问题:C# DepthStencilView类的具体用法?C# DepthStencilView怎么用?C# DepthStencilView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DepthStencilView类属于命名空间,在下文中一共展示了DepthStencilView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: D3DApp
protected D3DApp(IntPtr hInstance)
{
AppInst = hInstance;
MainWindowCaption = "D3D11 Application";
DriverType = DriverType.Hardware;
ClientWidth = 800;
ClientHeight = 600;
Enable4XMsaa = false;
Window = null;
AppPaused = false;
Minimized = false;
Maximized = false;
Resizing = false;
Msaa4XQuality = 0;
Device = null;
ImmediateContext = null;
SwapChain = null;
DepthStencilBuffer = null;
RenderTargetView = null;
DepthStencilView = null;
Viewport = new Viewport();
Timer = new GameTimer();
GD3DApp = this;
}
示例2: DX11CubeDepthStencil
public DX11CubeDepthStencil(DX11RenderContext context, int size, SampleDescription sd, Format format)
{
this.context = context;
var texBufferDesc = new Texture2DDescription
{
ArraySize = 6,
BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = DepthFormatsHelper.GetGenericTextureFormat(format),
Height = size,
Width = size,
OptionFlags = ResourceOptionFlags.TextureCube,
SampleDescription = sd,
Usage = ResourceUsage.Default,
MipLevels = 1
};
this.Resource = new Texture2D(context.Device, texBufferDesc);
this.desc = texBufferDesc;
//Create faces SRV/RTV
this.SliceDSV = new DX11SliceDepthStencil[6];
ShaderResourceViewDescription svd = new ShaderResourceViewDescription()
{
Dimension = ShaderResourceViewDimension.TextureCube,
Format = DepthFormatsHelper.GetSRVFormat(format),
MipLevels = 1,
MostDetailedMip = 0,
First2DArrayFace = 0
};
DepthStencilViewDescription dsvd = new DepthStencilViewDescription()
{
ArraySize= 6,
Dimension = DepthStencilViewDimension.Texture2DArray,
FirstArraySlice = 0,
Format = DepthFormatsHelper.GetDepthFormat(format),
MipSlice = 0
};
this.DSV = new DepthStencilView(context.Device, this.Resource, dsvd);
if (context.IsFeatureLevel11)
{
dsvd.Flags = DepthStencilViewFlags.ReadOnlyDepth;
if (format == Format.D24_UNorm_S8_UInt) { dsvd.Flags |= DepthStencilViewFlags.ReadOnlyStencil; }
this.ReadOnlyDSV = new DepthStencilView(context.Device, this.Resource, dsvd);
}
this.SRV = new ShaderResourceView(context.Device, this.Resource, svd);
for (int i = 0; i < 6; i++)
{
this.SliceDSV[i] = new DX11SliceDepthStencil(context, this, i, DepthFormatsHelper.GetDepthFormat(format));
}
}
示例3: DepthStencilTarget
private DepthStencilTarget( int width, int height, Texture2D texture )
{
Width = width;
Height = height;
Texture = texture;
var wrapper = D3D10Wrapper.Instance;
DepthStencilView = new DepthStencilView( wrapper.Device, texture );
}
示例4: Initialize
public void Initialize(DeviceContextHolder holder) {
const Format format = Format.R16G16B16A16_Float;
using (var cubeTex = new Texture2D(holder.Device, new Texture2DDescription {
Width = _cubeMapSize,
Height = _cubeMapSize,
MipLevels = 2,
ArraySize = 6,
SampleDescription = new SampleDescription(1, 0),
Format = format,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.GenerateMipMaps | ResourceOptionFlags.TextureCube
})) {
_targetView = Enumerable.Range(0, 6).Select(x => new RenderTargetView(holder.Device, cubeTex,
new RenderTargetViewDescription {
Format = format,
Dimension =
RenderTargetViewDimension
.Texture2DArray,
ArraySize = 1,
FirstArraySlice = x,
MipSlice = 0
})).ToArray();
_view = new ShaderResourceView(holder.Device, cubeTex, new ShaderResourceViewDescription {
Format = format,
Dimension = ShaderResourceViewDimension.TextureCube,
MostDetailedMip = 0,
MipLevels = -1
});
}
const Format depthFormat = Format.D32_Float;
using (var depthTex = new Texture2D(holder.Device, new Texture2DDescription {
Width = _cubeMapSize,
Height = _cubeMapSize,
MipLevels = 1,
ArraySize = 1,
SampleDescription = new SampleDescription(1, 0),
Format = depthFormat,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.DepthStencil,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
})) {
_depthTargetView = new DepthStencilView(holder.Device, depthTex, new DepthStencilViewDescription {
Format = depthFormat,
Flags = DepthStencilViewFlags.None,
Dimension = DepthStencilViewDimension.Texture2D,
MipSlice = 0,
});
}
}
示例5: Render
public void Render( DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView )
{
deviceContext.ClearRenderTargetView( renderTargetView, Constants.CLEAR_COLOR );
deviceContext.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00 );
//mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 );
//mTinyTextContext.Render();
mStopwatch.Reset();
mStopwatch.Start();
}
示例6: CreateDepthStencilViews
private void CreateDepthStencilViews()
{
var depthStencilViewDesc = new DepthStencilViewDescription();
depthStencilViewDesc.Format = Format.D32_Float;
depthStencilViewDesc.Dimension = DepthStencilViewDimension.Texture2DArray;
depthStencilViewDesc.ArraySize = 1;
depthStencilViewDesc.MipSlice = 0;
for (int i = 0; i < deferredShadingConfiguration.LayerCount; ++i)
{
depthStencilViewDesc.FirstArraySlice = i;
var depthStencilView = new DepthStencilView(device, texture, depthStencilViewDesc);
depthStencilViews.Add(depthStencilView);
}
}
示例7: Resize
public override void Resize(DeviceContextHolder holder, int width, int height) {
base.Resize(holder, width, height);
DepthView = new DepthStencilView(holder.Device, Texture, new DepthStencilViewDescription {
Flags = DepthStencilViewFlags.None,
Format = Format.D24_UNorm_S8_UInt,
Dimension = DepthStencilViewDimension.Texture2D,
MipSlice = 0
});
View = new ShaderResourceView(holder.Device, Texture, new ShaderResourceViewDescription {
Format = Format.R24_UNorm_X8_Typeless,
Dimension = ShaderResourceViewDimension.Texture2D,
MipLevels = 1,
MostDetailedMip = 0
});
}
示例8: ShadowMap
public ShadowMap(Device device, int width, int height) {
_width = width;
_height = height;
_viewport = new Viewport(0, 0, _width, _height, 0, 1.0f);
var texDesc = new Texture2DDescription {
Width = _width,
Height = _height,
MipLevels = 1,
ArraySize = 1,
Format = Format.R24G8_Typeless,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource ,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
var depthMap = new Texture2D(device, texDesc);
depthMap.DebugName = "shadowmap depthmap";
var dsvDesc = new DepthStencilViewDescription {
Flags = DepthStencilViewFlags.None,
Format = Format.D24_UNorm_S8_UInt,
Dimension = DepthStencilViewDimension.Texture2D,
MipSlice = 0
};
_depthMapDSV = new DepthStencilView(device, depthMap, dsvDesc);
var srvDesc = new ShaderResourceViewDescription {
Format = Format.R24_UNorm_X8_Typeless,
Dimension = ShaderResourceViewDimension.Texture2D,
MipLevels = texDesc.MipLevels,
MostDetailedMip = 0
};
DepthMapSRV = new ShaderResourceView(device, depthMap, srvDesc);
Util.ReleaseCom(ref depthMap);
}
示例9: TextureObject
// Functions
public TextureObject()
{
m_Width = m_Height = 1;
m_Mips = 1;
m_Depth = 1;
m_ArraySize = 1;
m_IsCube = false;
m_TexFormat = Format.Unknown;
m_TextureObject2D = null;
m_TextureObject3D = null;
m_RenderTargetView = null;
m_ShaderResourceView = null;
m_DepthStencilView = null;
m_UnorderedAccessView = null;
m_ArrayRenderTargetViews = null;
m_ArrayShaderResourceViews = null;
m_ArrayDepthStencilViews = null;
m_ArrayUnorderedAccessViews = null;
}
示例10: RenderToTextureCommand
public RenderToTextureCommand(int width, int height, SceneManager sceneTree)
: base(CommandType.Action)
{
SceneTree = sceneTree;
RenderTextureDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.R8G8B8A8_UNorm,
Width = width,
Height = height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
};
texture = new Texture2D(Game.Context.Device, RenderTextureDesc);
Texture2DDescription depthBufferDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlags.DepthStencil,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.D32_Float,
Width = width,
Height = height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
};
using (Texture2D depthBuffer = new Texture2D(Game.Context.Device, depthBufferDesc))
{
DepthStencilView = new DepthStencilView(Game.Context.Device, depthBuffer);
}
RenderTargetView = new RenderTargetView(Game.Context.Device, texture);
}
示例11: SetDefaultColorTargets
/// <summary>
/// Sets the default render-targets
/// </summary>
public void SetDefaultColorTargets(DepthStencilView dsv)
{
this.targetWidth = this.colorBuffer.Description.Width;
this.targetHeight = this.colorBuffer.Description.Height;
this.device.ImmediateContext.OutputMerger.SetTargets(dsv, this.colorBufferView);
this.device.ImmediateContext.Rasterizer.SetViewport(0, 0, this.colorBuffer.Description.Width, this.colorBuffer.Description.Height, 0.0f, 1.0f);
this.device.ImmediateContext.ClearRenderTargetView(this.colorBufferView, this.ClearColor);
this.device.ImmediateContext.ClearDepthStencilView(this.depthStencilBufferView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
}
示例12: CreateAndBindTargets
/// <summary>
///
/// </summary>
private void CreateAndBindTargets()
{
this.surfaceD3D.SetRenderTargetDX11(null);
int width = System.Math.Max((int)this.ActualWidth, 100);
int height = System.Math.Max((int)this.ActualHeight, 100);
Disposer.RemoveAndDispose(ref this.colorBufferView);
Disposer.RemoveAndDispose(ref this.depthStencilBufferView);
Disposer.RemoveAndDispose(ref this.colorBuffer);
Disposer.RemoveAndDispose(ref this.depthStencilBuffer);
#if MSAA
Disposer.RemoveAndDispose(ref this.renderTargetNMS);
// check 8,4,2,1
int sampleCount = 8;
int sampleQuality = 0;
if (this.IsMSAAEnabled)
{
do
{
sampleQuality = this.device.CheckMultisampleQualityLevels(Format.B8G8R8A8_UNorm, sampleCount) - 1;
if (sampleQuality > 0)
{
break;
}
else
{
sampleCount /= 2;
}
if (sampleCount == 1)
{
sampleQuality = 0;
break;
}
}
while (true);
}
else
{
sampleCount = 1;
sampleQuality = 0;
}
var sampleDesc = new SampleDescription(sampleCount, sampleQuality);
var optionFlags = ResourceOptionFlags.None;
#else
var sampleDesc = new SampleDescription(1, 0);
var optionFlags = ResourceOptionFlags.Shared;
#endif
var colordesc = new Texture2DDescription
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = Format.B8G8R8A8_UNorm,
Width = width,
Height = height,
MipLevels = 1,
SampleDescription = sampleDesc,
Usage = ResourceUsage.Default,
OptionFlags = optionFlags,
CpuAccessFlags = CpuAccessFlags.None,
ArraySize = 1
};
var depthdesc = new Texture2DDescription
{
BindFlags = BindFlags.DepthStencil,
//Format = Format.D24_UNorm_S8_UInt,
Format = Format.D32_Float_S8X24_UInt,
Width = width,
Height = height,
MipLevels = 1,
SampleDescription = sampleDesc,
Usage = ResourceUsage.Default,
OptionFlags = ResourceOptionFlags.None,
CpuAccessFlags = CpuAccessFlags.None,
ArraySize = 1,
};
this.colorBuffer = new Texture2D(this.device, colordesc);
this.depthStencilBuffer = new Texture2D(this.device, depthdesc);
this.colorBufferView = new RenderTargetView(this.device, this.colorBuffer);
this.depthStencilBufferView = new DepthStencilView(this.device, this.depthStencilBuffer);
#if MSAA
var colordescNMS = new Texture2DDescription
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = Format.B8G8R8A8_UNorm,
Width = width,
Height = height,
MipLevels = 1,
SampleDescription = new SampleDescription(1, 0),
//.........这里部分代码省略.........
示例13: OnResize
public virtual void OnResize()
{
Debug.Assert(ImmediateContext != null);
Debug.Assert(Device != null);
Debug.Assert(SwapChain != null);
Util.ReleaseCom(ref RenderTargetView);
Util.ReleaseCom(ref DepthStencilView);
Util.ReleaseCom(ref DepthStencilBuffer);
SwapChain.ResizeBuffers(1, ClientWidth, ClientHeight, Format.R8G8B8A8_UNorm, SwapChainFlags.None);
using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain<Texture2D>(SwapChain, 0)) {
RenderTargetView = new RenderTargetView(Device, resource);
RenderTargetView.Resource.DebugName = "main render target";
}
var depthStencilDesc = new Texture2DDescription {
Width = ClientWidth,
Height = ClientHeight,
MipLevels = 1,
ArraySize = 1,
Format = Format.D24_UNorm_S8_UInt,
SampleDescription = (Enable4XMsaa && Device.FeatureLevel >= FeatureLevel.Level_10_1) ? new SampleDescription(4, Msaa4XQuality - 1) : new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.DepthStencil,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
DepthStencilBuffer = new Texture2D(Device, depthStencilDesc) { DebugName = "DepthStencilBuffer" };
DepthStencilView = new DepthStencilView(Device, DepthStencilBuffer);
ImmediateContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);
Viewport = new Viewport(0, 0, ClientWidth, ClientHeight, 0.0f, 1.0f);
ImmediateContext.Rasterizer.SetViewports(Viewport);
}
示例14: InitializeBuffers
public void InitializeBuffers()
{
Helper.Dispose(ReadOnlyDepth, litBuffer, litTarget);
DepthStencilViewDescription dsvDesc = Renderer.BackBufferDepth.Description;
dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyDepth;
ReadOnlyDepth = new DepthStencilView(Renderer.Device, Renderer.OutputDepth, dsvDesc);
Texture2DDescription litBufferDesc = Renderer.OutputTexture.Description;
//TODO: This format
litBufferDesc.Format = SlimDX.DXGI.Format.R11G11B10_Float;
using (Texture2D tex = new Texture2D(Renderer.Device, litBufferDesc))
{
litTarget = new RenderTargetView(Renderer.Device, tex);
litBuffer = new ShaderResourceView(Renderer.Device, tex, new ShaderResourceViewDescription()
{
Dimension = tex.Description.SampleDescription.Count > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D,
Format = tex.Description.Format,
ArraySize = 1,
MipLevels = 1,
FirstArraySlice = 0,
MostDetailedMip = 0
});
}
GBuffer.Initialize();
}
示例15: InitializeDepthStencil
private void InitializeDepthStencil(uint nWidth, uint nHeight)
{
// Create depth stencil texture
Texture2DDescription descDepth = new Texture2DDescription()
{
Width = nWidth,
Height = nHeight,
MipLevels = 1,
ArraySize = 1,
Format = Format.D16_UNORM,
SampleDescription = new SampleDescription()
{
Count = 1,
Quality = 0
},
BindFlags = BindFlag.DepthStencil,
};
depthStencil = device.CreateTexture2D(descDepth);
// Create the depth stencil view
DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription()
{
Format = descDepth.Format,
ViewDimension =
DepthStencilViewDimension.
Texture2D
};
depthStencilView = device.CreateDepthStencilView(depthStencil, depthStencilViewDesc);
}