本文整理汇总了C#中SharpDX.Direct3D11.RenderTargetView类的典型用法代码示例。如果您正苦于以下问题:C# RenderTargetView类的具体用法?C# RenderTargetView怎么用?C# RenderTargetView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RenderTargetView类属于SharpDX.Direct3D11命名空间,在下文中一共展示了RenderTargetView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderTarget2D
internal RenderTarget2D(GraphicsDevice device, Direct3D11.Texture2D texture, RenderTargetView renderTargetView = null, bool pureRenderTarget = false)
: base(device.MainDevice, texture)
{
this.pureRenderTarget = pureRenderTarget;
this.customRenderTargetView = renderTargetView;
Initialize(Resource);
}
示例2: DisplayHistogram
internal static void DisplayHistogram(RenderTargetView rtv)
{
RC.Context.PixelShader.SetShaderResource(0, m_histogram.ShaderView);
RC.Context.PixelShader.Set(m_drawHistogram);
RC.Context.OutputMerger.SetRenderTargets(rtv);
MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 64, 512, 64));
}
示例3: MyBackbuffer
internal MyBackbuffer(SharpDX.Direct3D11.Resource swapChainBB)
{
m_resource = swapChainBB;
m_resource.DebugName = m_debugName;
m_rtv = new RenderTargetView(MyRender11.Device, swapChainBB);
m_rtv.DebugName = m_debugName;
}
示例4: ArgumentOutOfRangeException
RenderTargetView IRenderTarget.GetRenderTargetView(int arraySlice)
{
if (arraySlice >= Depth)
throw new ArgumentOutOfRangeException("The arraySlice is out of range for this Texture3D.");
// Dispose the previous target.
if (_currentSlice != arraySlice && _renderTargetView != null)
{
_renderTargetView.Dispose();
_renderTargetView = null;
}
// Create the new target view interface.
if (_renderTargetView == null)
{
_currentSlice = arraySlice;
var desc = new RenderTargetViewDescription
{
Format = SharpDXHelper.ToFormat(_format),
Dimension = RenderTargetViewDimension.Texture3D,
Texture3D =
{
DepthSliceCount = -1,
FirstDepthSlice = arraySlice,
MipSlice = 0,
}
};
_renderTargetView = new RenderTargetView(GraphicsDevice._d3dDevice, GetTexture(), desc);
}
return _renderTargetView;
}
示例5: InitializeDeviceResources
private void InitializeDeviceResources()
{
ModeDescription backBufferDesc = new ModeDescription(Width, Height, new Rational(60, 1), Format.R8G8B8A8_UNorm);
// Descriptor for the swap chain
SwapChainDescription swapChainDesc = new SwapChainDescription()
{
ModeDescription = backBufferDesc,
SampleDescription = new SampleDescription(1, 0),
Usage = Usage.RenderTargetOutput,
BufferCount = 1,
OutputHandle = renderForm.Handle,
IsWindowed = true
};
// Create device and swap chain
D3D11.Device.CreateWithSwapChain(DriverType.Hardware, D3D11.DeviceCreationFlags.None, swapChainDesc, out d3dDevice, out swapChain);
d3dDeviceContext = d3dDevice.ImmediateContext;
// Create render target view for back buffer
using(D3D11.Texture2D backBuffer = swapChain.GetBackBuffer<D3D11.Texture2D>(0))
{
renderTargetView = new D3D11.RenderTargetView(d3dDevice, backBuffer);
}
// Set back buffer as current render target view
d3dDeviceContext.OutputMerger.SetRenderTargets(renderTargetView);
}
示例6: Draw
public void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
{
var deviceChanged = _device != device || _context != context;
_device = device;
_context = context;
if (deviceChanged)
{
DrawingSurfaceState.Device = _device;
DrawingSurfaceState.Context = _context;
DrawingSurfaceState.RenderTargetView = renderTargetView;
}
if (!_game.Initialized)
{
// Start running the game.
_game.Run(GameRunBehavior.Asynchronous);
}
else if (deviceChanged)
{
_game.GraphicsDevice.Initialize();
Microsoft.Xna.Framework.Content.ContentManager.ReloadGraphicsContent();
// DeviceReset events
_game.graphicsDeviceManager.OnDeviceReset(EventArgs.Empty);
_game.GraphicsDevice.OnDeviceReset();
}
_game.GraphicsDevice.UpdateTarget(renderTargetView);
_game.GraphicsDevice.ResetRenderTargets();
_game.Tick();
_host.RequestAdditionalFrame();
}
示例7: Renderer
public Renderer(IntPtr swapChainPtr, OverlayConfig overlayConfig)
{
OverlayConfig = overlayConfig;
Overlays = new List<IOverlay>();
var swapChain = (SwapChain) swapChainPtr;
Device = swapChain.GetDevice<Device>();
Texture2D = swapChain.GetBackBuffer<Texture2D>(0);
try
{
DeviceContext = new DeviceContext(Device);
}
catch (SharpDXException)
{
DeviceContext = Device.ImmediateContext;
}
TargetView = new RenderTargetView(Device, Texture2D);
if (DeferredContext)
{
DeviceContext.Rasterizer.SetViewports(new ViewportF(0, 0, Texture2D.Description.Width, Texture2D.Description.Height, 0, 1));
DeviceContext.OutputMerger.SetTargets(TargetView);
}
SpriteEngine = new DXSpriteRenderer(Device, DeviceContext);
SpriteEngine?.Initialize();
InitializeElementResources();
}
示例8: RenderTexture
public RenderTexture(Device device, Vector2I screenSize)
{
var textureDesc = new Texture2DDescription()
{
Width = screenSize.X,
Height = screenSize.Y,
MipLevels = 1,
ArraySize = 1,
Format = Format.R32G32B32A32_Float,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
_renderTargetTexture = new Texture2D(device, textureDesc);
_renderTargetView = new RenderTargetView(device, _renderTargetTexture,
new RenderTargetViewDescription
{
Format = textureDesc.Format,
Dimension = RenderTargetViewDimension.Texture2D,
Texture2D = {MipSlice = 0},
});
// Create the render target view.
ShaderResourceView = new ShaderResourceView(device, _renderTargetTexture,
new ShaderResourceViewDescription
{
Format = textureDesc.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = { MipLevels = 1, MostDetailedMip = 0 },
});
}
示例9: Draw
public override void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
{
// We just clear the render target view
context.ClearRenderTargetView(renderTargetView, Color.CornflowerBlue);
// Ask the DrawingSurface to call us back
host.RequestAdditionalFrame();
}
示例10: GetRenderTargets
/// <summary>
/// Get references to the render targets that are available to the {{output-merger stage}}.
/// </summary>
/// <remarks>
/// Any returned interfaces will have their reference count incremented by one. Applications should call {{IUnknown::Release}} on the returned interfaces when they are no longer needed to avoid memory leaks.
/// </remarks>
/// <param name="numViews">Number of render targets to retrieve. </param>
/// <returns>an array of render targets views (see <see cref="SharpDX.Direct3D11.RenderTargetView"/>) to be filled with the render targets from the device.</returns>
/// <unmanaged>void OMGetRenderTargets([In] int NumViews,[Out, Buffer, Optional] ID3D10RenderTargetView** ppRenderTargetViews,[Out, Optional] ID3D10DepthStencilView** ppDepthStencilView)</unmanaged>
public SharpDX.Direct3D11.RenderTargetView[] GetRenderTargets(int numViews)
{
var renderTargets = new RenderTargetView[numViews];
DepthStencilView depthStencilView;
GetRenderTargets(numViews, renderTargets, out depthStencilView);
if (depthStencilView != null)
depthStencilView.Dispose();
return renderTargets;
}
示例11: Apply
public virtual void Apply(DeviceContext context, ShaderResourceView source, RenderTargetView destination, float scale = 1f, float offset = 0f)
{
context.OutputMerger.SetTargets(destination);
context.PixelShader.SetShaderResource(0, source);
Texture2D tex2D = destination.ResourceAs<Texture2D>();
context.Rasterizer.SetViewport(0f, 0f, (float)tex2D.Description.Width, (float)tex2D.Description.Height, 0f, 1f);
tex2D.Dispose();
ScreenQuad.Draw(context, scale, offset);
}
示例12: DisplayHistogram
internal static void DisplayHistogram(RenderTargetView rtv, ShaderResourceView avgLumSrv)
{
RC.DeviceContext.PixelShader.SetShaderResources(0, m_histogram.ShaderView, avgLumSrv);
RC.DeviceContext.PixelShader.Set(m_drawHistogram);
RC.DeviceContext.OutputMerger.SetRenderTargets(rtv);
MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 64, 512, 64));
RC.DeviceContext.PixelShader.Set(m_drawTonemapping);
MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 128, 512, 64));
}
示例13: RenderTargetSurface
/// <summary>
///
/// </summary>
/// <param name="rtv"></param>
internal RenderTargetSurface( RenderTargetView rtv, UnorderedAccessView uav, Resource resource, int subresource, ColorFormat format, int width, int height, int sampleCount )
{
Width = width;
Height = height;
Format = format;
SampleCount = sampleCount;
RTV = rtv;
UAV = uav;
Resource = resource;
Subresource = subresource;
}
示例14: Run
internal static void Run(RenderTargetView renderTarget, RenderTargetView intermediateRenderTarget, ShaderResourceView intermediateResourceView, ShaderResourceView initialResourceView,
int maxOffset = 5, MyBlurDensityFunctionType densityFunctionType = MyBlurDensityFunctionType.Gaussian, float WeightParameter = 1.5f,
DepthStencilState depthStencilState = null, int stencilRef = 0x0, bool copyOnStencilFail = false,
float depthDiscardThreshold = 0.0f, MyViewport? viewport = null)
{
ProfilerShort.Begin("MyBlur.Run");
MyGpuProfiler.IC_BeginBlock("MyBlur.Run");
Debug.Assert(initialResourceView != null);
Debug.Assert(intermediateResourceView != null);
Debug.Assert(intermediateRenderTarget != null);
Debug.Assert(renderTarget != null);
int shaderKey = InitShaders(densityFunctionType, maxOffset, copyOnStencilFail, depthDiscardThreshold);
RC.DeviceContext.PixelShader.SetConstantBuffer(5, m_blurConstantBuffer);
BlurConstants constants = new BlurConstants
{
DistributionWeight = WeightParameter,
StencilRef = stencilRef,
};
var mapping = MyMapping.MapDiscard(m_blurConstantBuffer);
mapping.WriteAndPosition(ref constants);
mapping.Unmap();
// Horizontal pass
MyRender11.DeviceContext.ClearRenderTargetView(intermediateRenderTarget, Color4.White);
RC.DeviceContext.OutputMerger.SetTargets(intermediateRenderTarget);
RC.SetDS(depthStencilState, stencilRef);
RC.DeviceContext.PixelShader.SetShaderResource(0, MyGBuffer.Main.DepthStencil.m_SRV_depth);
RC.DeviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
RC.DeviceContext.PixelShader.SetShaderResource(5, initialResourceView);
RC.SetPS(m_blurShaders[shaderKey].Item1);
MyScreenPass.DrawFullscreenQuad(viewport);
RC.DeviceContext.PixelShader.SetShaderResource(5, null);
// Vertical pass
MyRender11.DeviceContext.ClearRenderTargetView(renderTarget, Color4.White);
RC.DeviceContext.OutputMerger.SetTargets(renderTarget);
RC.SetDS(depthStencilState, stencilRef);
RC.DeviceContext.PixelShader.SetShaderResource(0, MyGBuffer.Main.DepthStencil.m_SRV_depth);
RC.DeviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
RC.DeviceContext.PixelShader.SetShaderResource(5, intermediateResourceView);
RC.SetPS(m_blurShaders[shaderKey].Item2);
MyScreenPass.DrawFullscreenQuad(viewport);
RC.DeviceContext.PixelShader.SetShaderResource(0, null);
RC.DeviceContext.PixelShader.SetShaderResource(4, null);
RC.DeviceContext.PixelShader.SetShaderResource(5, null);
MyGpuProfiler.IC_EndBlock();
ProfilerShort.End();
}
示例15: Update
public void Update(Device device, DeviceContext context, RenderTargetView renderTargetView)
{
if (device != _device)
{
_device = device;
CreateDeviceResources();
}
_deviceContext = context;
_renderTargetview = renderTargetView;
CreateWindowSizeDependentResources();
}